prepare to DC 2.24
This commit is contained in:
parent
b857875b0f
commit
7208abc9d6
@ -10,9 +10,8 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
require dirname(__FILE__) . '/_widgets.php';
|
require __DIR__ . '/_widgets.php';
|
||||||
|
12
_define.php
12
_define.php
@ -10,7 +10,6 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -19,13 +18,16 @@ $this->registerModule(
|
|||||||
'Entry information list',
|
'Entry information list',
|
||||||
'Show Entry informations on a widget',
|
'Show Entry informations on a widget',
|
||||||
'Jean-Christian Denis, Pierre Van Glabeke',
|
'Jean-Christian Denis, Pierre Van Glabeke',
|
||||||
'0.7',
|
'0.8',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.19']],
|
'requires' => [['core', '2.24']],
|
||||||
'permissions' => 'usage,contentadmin',
|
'permissions' => dcCore::app()->auth->makePermissions([
|
||||||
|
dcAuth::PERMISSION_USAGE,
|
||||||
|
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||||
|
]),
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=332974#p332974',
|
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=332974#p332974',
|
||||||
'details' => 'http://plugins.dotaddict.org/dc2/details/postInfoWidget',
|
'details' => 'http://plugins.dotaddict.org/dc2/details/postInfoWidget',
|
||||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/postInfoWidget/master/dcstore.xml'
|
'repository' => 'https://raw.githubusercontent.com/JcDenis/postInfoWidget/master/dcstore.xml',
|
||||||
]
|
]
|
||||||
);
|
);
|
@ -10,9 +10,8 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
require dirname(__FILE__) . '/_widgets.php';
|
require __DIR__ . '/_widgets.php';
|
||||||
|
105
_widgets.php
105
_widgets.php
@ -10,12 +10,11 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'initWidgets',
|
'initWidgets',
|
||||||
['postInfoWidget', 'adminWidget']
|
['postInfoWidget', 'adminWidget']
|
||||||
);
|
);
|
||||||
@ -24,8 +23,6 @@ class postInfoWidget
|
|||||||
{
|
{
|
||||||
public static function adminWidget($w)
|
public static function adminWidget($w)
|
||||||
{
|
{
|
||||||
global $core;
|
|
||||||
|
|
||||||
$w
|
$w
|
||||||
->create(
|
->create(
|
||||||
'postinfowidget',
|
'postinfowidget',
|
||||||
@ -72,7 +69,7 @@ class postInfoWidget
|
|||||||
'text'
|
'text'
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($core->plugins->moduleExists('tags')) {
|
if (dcCore::app()->plugins->moduleExists('tags')) {
|
||||||
$w->postinfowidget->setting(
|
$w->postinfowidget->setting(
|
||||||
'tag_str',
|
'tag_str',
|
||||||
__('Tags text (%T = tags list):'),
|
__('Tags text (%T = tags list):'),
|
||||||
@ -141,11 +138,11 @@ class postInfoWidget
|
|||||||
__('Try to adapt style'),
|
__('Try to adapt style'),
|
||||||
'small',
|
'small',
|
||||||
'combo',
|
'combo',
|
||||||
array(
|
[
|
||||||
__('No style') => '-',
|
__('No style') => '-',
|
||||||
__('Small icon') => 'small',
|
__('Small icon') => 'small',
|
||||||
__('Normal icon') => 'normal'
|
__('Normal icon') => 'normal',
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
/*
|
/*
|
||||||
$w->postinfowidget
|
$w->postinfowidget
|
||||||
@ -169,7 +166,7 @@ class postInfoWidget
|
|||||||
);
|
);
|
||||||
//*/
|
//*/
|
||||||
# --BEHAVIOR-- postInfoWidgetAdmin
|
# --BEHAVIOR-- postInfoWidgetAdmin
|
||||||
$core->callBehavior('postInfoWidgetAdmin', $w);
|
dcCore::app()->callBehavior('postInfoWidgetAdmin', $w);
|
||||||
|
|
||||||
$w->postinfowidget
|
$w->postinfowidget
|
||||||
->addContentOnly()
|
->addContentOnly()
|
||||||
@ -179,14 +176,12 @@ class postInfoWidget
|
|||||||
|
|
||||||
public static function publicWidget($w)
|
public static function publicWidget($w)
|
||||||
{
|
{
|
||||||
global $core, $_ctx;
|
|
||||||
|
|
||||||
if ($w->offline) {
|
if ($w->offline) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($core->url->type != 'post'
|
if (dcCore::app()->url->type != 'post'
|
||||||
|| !$_ctx->posts->post_id){
|
|| !dcCore::app()->ctx->posts->post_id) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,8 +194,8 @@ class postInfoWidget
|
|||||||
'date',
|
'date',
|
||||||
dt::str(
|
dt::str(
|
||||||
$w->dt_str,
|
$w->dt_str,
|
||||||
strtotime($_ctx->posts->post_dt),
|
strtotime(dcCore::app()->ctx->posts->post_dt),
|
||||||
$core->blog->settings->system->blog_timezone
|
dcCore::app()->blog->settings->system->blog_timezone
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -211,8 +206,8 @@ class postInfoWidget
|
|||||||
'create',
|
'create',
|
||||||
dt::str(
|
dt::str(
|
||||||
$w->creadt_str,
|
$w->creadt_str,
|
||||||
strtotime($_ctx->posts->post_creadt),
|
strtotime(dcCore::app()->ctx->posts->post_creadt),
|
||||||
$core->blog->settings->system->blog_timezone
|
dcCore::app()->blog->settings->system->blog_timezone
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -223,26 +218,24 @@ class postInfoWidget
|
|||||||
'update',
|
'update',
|
||||||
dt::str(
|
dt::str(
|
||||||
$w->upddt_str,
|
$w->upddt_str,
|
||||||
strtotime($_ctx->posts->post_upddt),
|
strtotime(dcCore::app()->ctx->posts->post_upddt),
|
||||||
$core->blog->settings->system->blog_timezone
|
dcCore::app()->blog->settings->system->blog_timezone
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($w->lang_str != '') {
|
if ($w->lang_str != '') {
|
||||||
$ln = l10n::getISOcodes();
|
$ln = l10n::getISOcodes();
|
||||||
$lang_code = $_ctx->posts->post_lang ?
|
$lang_code = dcCore::app()->ctx->posts->post_lang ?
|
||||||
$_ctx->posts->post_lang :
|
dcCore::app()->ctx->posts->post_lang :
|
||||||
$core->blog->settings->system->lang;
|
dcCore::app()->blog->settings->system->lang;
|
||||||
$lang_name = isset($ln[$lang_code]) ?
|
$lang_name = $ln[$lang_code] ?? $lang_code;
|
||||||
$ln[$lang_code] :
|
|
||||||
$lang_code;
|
|
||||||
$lang_flag = file_exists(
|
$lang_flag = file_exists(
|
||||||
dirname(__FILE__) .
|
dirname(__FILE__) .
|
||||||
'/img/flags/' .
|
'/img/flags/' .
|
||||||
$lang_code . '.png'
|
$lang_code . '.png'
|
||||||
) ?
|
) ?
|
||||||
'<img src="' . $core->blog->getQmarkURL() .
|
'<img src="' . dcCore::app()->blog->getQmarkURL() .
|
||||||
'pf=postInfoWidget/img/flags/' .
|
'pf=postInfoWidget/img/flags/' .
|
||||||
$lang_code . '.png" alt="' . $lang_name . '" />' :
|
$lang_code . '.png" alt="' . $lang_name . '" />' :
|
||||||
'';
|
'';
|
||||||
@ -264,13 +257,13 @@ class postInfoWidget
|
|||||||
'author',
|
'author',
|
||||||
str_replace(
|
str_replace(
|
||||||
'%T',
|
'%T',
|
||||||
$_ctx->posts->getAuthorLink(),
|
dcCore::app()->ctx->posts->getAuthorLink(),
|
||||||
html::escapeHTML($w->author_str)
|
html::escapeHTML($w->author_str)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($w->category_str != '' && $_ctx->posts->cat_id) {
|
if ($w->category_str != '' && dcCore::app()->ctx->posts->cat_id) {
|
||||||
$content .= postInfoWidget::li(
|
$content .= postInfoWidget::li(
|
||||||
$w,
|
$w,
|
||||||
'category',
|
'category',
|
||||||
@ -278,25 +271,25 @@ class postInfoWidget
|
|||||||
'%T',
|
'%T',
|
||||||
sprintf(
|
sprintf(
|
||||||
$link,
|
$link,
|
||||||
$_ctx->posts->getCategoryURL(),
|
dcCore::app()->ctx->posts->getCategoryURL(),
|
||||||
html::escapeHTML($_ctx->posts->cat_title)
|
html::escapeHTML(dcCore::app()->ctx->posts->cat_title)
|
||||||
),
|
),
|
||||||
html::escapeHTML($w->category_str)
|
html::escapeHTML($w->category_str)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($w->tag_str != '' && $core->plugins->moduleExists('tags')) {
|
if ($w->tag_str != '' && dcCore::app()->plugins->moduleExists('tags')) {
|
||||||
$meta = $core->meta->getMetadata([
|
$meta = dcCore::app()->meta->getMetadata([
|
||||||
'meta_type' => 'tag',
|
'meta_type' => 'tag',
|
||||||
'post_id' => $_ctx->posts->post_id
|
'post_id' => dcCore::app()->ctx->posts->post_id,
|
||||||
]);
|
]);
|
||||||
$metas = [];
|
$metas = [];
|
||||||
while ($meta->fetch()) {
|
while ($meta->fetch()) {
|
||||||
$metas[$meta->meta_id] = sprintf(
|
$metas[$meta->meta_id] = sprintf(
|
||||||
$link,
|
$link,
|
||||||
$core->blog->url .
|
dcCore::app()->blog->url .
|
||||||
$core->url->getBase('tag') . "/" .
|
dcCore::app()->url->getBase('tag') . '/' .
|
||||||
rawurlencode($meta->meta_id),
|
rawurlencode($meta->meta_id),
|
||||||
$meta->meta_id
|
$meta->meta_id
|
||||||
);
|
);
|
||||||
@ -315,7 +308,7 @@ class postInfoWidget
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($w->attachment_str != '') {
|
if ($w->attachment_str != '') {
|
||||||
$nb = $_ctx->posts->countMedia();
|
$nb = dcCore::app()->ctx->posts->countMedia();
|
||||||
if ($nb == 0) {
|
if ($nb == 0) {
|
||||||
$attachment_numeric = 0;
|
$attachment_numeric = 0;
|
||||||
$attachment_textual = __('no attachment');
|
$attachment_textual = __('no attachment');
|
||||||
@ -354,8 +347,8 @@ class postInfoWidget
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($w->comment_str != '' && $_ctx->posts->commentsActive()) {
|
if ($w->comment_str != '' && dcCore::app()->ctx->posts->commentsActive()) {
|
||||||
$nb = $_ctx->posts->nb_comment;
|
$nb = dcCore::app()->ctx->posts->nb_comment;
|
||||||
if ($nb == 0) {
|
if ($nb == 0) {
|
||||||
$comment_numeric = 0;
|
$comment_numeric = 0;
|
||||||
$comment_textual = __('no comment');
|
$comment_textual = __('no comment');
|
||||||
@ -394,8 +387,8 @@ class postInfoWidget
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($w->trackback_str != '' && $_ctx->posts->trackbacksActive()) {
|
if ($w->trackback_str != '' && dcCore::app()->ctx->posts->trackbacksActive()) {
|
||||||
$nb = $_ctx->posts->nb_trackback;
|
$nb = dcCore::app()->ctx->posts->nb_trackback;
|
||||||
if ($nb == 0) {
|
if ($nb == 0) {
|
||||||
$trackback_numeric = 0;
|
$trackback_numeric = 0;
|
||||||
$trackback_textual = __('no trackback');
|
$trackback_textual = __('no trackback');
|
||||||
@ -428,7 +421,7 @@ class postInfoWidget
|
|||||||
'trackback',
|
'trackback',
|
||||||
str_replace(
|
str_replace(
|
||||||
['%T', '%D'],
|
['%T', '%D'],
|
||||||
array($trackback_textual, $trackback_numeric),
|
[$trackback_textual, $trackback_numeric],
|
||||||
html::escapeHTML($w->trackback_str)
|
html::escapeHTML($w->trackback_str)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -443,26 +436,26 @@ class postInfoWidget
|
|||||||
[
|
[
|
||||||
sprintf(
|
sprintf(
|
||||||
$link,
|
$link,
|
||||||
$_ctx->posts->getURL(),
|
dcCore::app()->ctx->posts->getURL(),
|
||||||
__('Permalink')
|
__('Permalink')
|
||||||
),
|
),
|
||||||
$_ctx->posts->getURL()
|
dcCore::app()->ctx->posts->getURL(),
|
||||||
],
|
],
|
||||||
html::escapeHTML($w->permalink_str)
|
html::escapeHTML($w->permalink_str)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($w->feed && $_ctx->posts->commentsActive()) {
|
if ($w->feed && dcCore::app()->ctx->posts->commentsActive()) {
|
||||||
$content .= postInfoWidget::li(
|
$content .= postInfoWidget::li(
|
||||||
$w,
|
$w,
|
||||||
'feed',
|
'feed',
|
||||||
sprintf(
|
sprintf(
|
||||||
$link,
|
$link,
|
||||||
$core->blog->url .
|
dcCore::app()->blog->url .
|
||||||
$core->url->getBase('feed') .
|
dcCore::app()->url->getBase('feed') .
|
||||||
'/atom/comments/' .
|
'/atom/comments/' .
|
||||||
$_ctx->posts->post_id,
|
dcCore::app()->ctx->posts->post_id,
|
||||||
__("This post's comments feed"),
|
__("This post's comments feed"),
|
||||||
html::escapeHTML($w->tag_str)
|
html::escapeHTML($w->tag_str)
|
||||||
)
|
)
|
||||||
@ -471,7 +464,7 @@ class postInfoWidget
|
|||||||
|
|
||||||
if ($w->navprevpost) {
|
if ($w->navprevpost) {
|
||||||
$npp = postInfoWidget::nav(
|
$npp = postInfoWidget::nav(
|
||||||
$_ctx->posts,
|
dcCore::app()->ctx->posts,
|
||||||
-1,
|
-1,
|
||||||
false,
|
false,
|
||||||
__('Previous entry'),
|
__('Previous entry'),
|
||||||
@ -487,7 +480,7 @@ class postInfoWidget
|
|||||||
}
|
}
|
||||||
if ($w->navnextpost) {
|
if ($w->navnextpost) {
|
||||||
$nnp = postInfoWidget::nav(
|
$nnp = postInfoWidget::nav(
|
||||||
$_ctx->posts,
|
dcCore::app()->ctx->posts,
|
||||||
1,
|
1,
|
||||||
false,
|
false,
|
||||||
__('Next entry'),
|
__('Next entry'),
|
||||||
@ -504,7 +497,7 @@ class postInfoWidget
|
|||||||
|
|
||||||
if ($w->navprevcat) {
|
if ($w->navprevcat) {
|
||||||
$npc = postInfoWidget::nav(
|
$npc = postInfoWidget::nav(
|
||||||
$_ctx->posts,
|
dcCore::app()->ctx->posts,
|
||||||
-1,
|
-1,
|
||||||
true,
|
true,
|
||||||
__('Previous entry of this category'),
|
__('Previous entry of this category'),
|
||||||
@ -521,7 +514,7 @@ class postInfoWidget
|
|||||||
|
|
||||||
if ($w->navnextcat) {
|
if ($w->navnextcat) {
|
||||||
$nnc = postInfoWidget::nav(
|
$nnc = postInfoWidget::nav(
|
||||||
$_ctx->posts,
|
dcCore::app()->ctx->posts,
|
||||||
1,
|
1,
|
||||||
true,
|
true,
|
||||||
__('Next entry of this category'),
|
__('Next entry of this category'),
|
||||||
@ -537,7 +530,7 @@ class postInfoWidget
|
|||||||
}
|
}
|
||||||
|
|
||||||
# --BEHAVIOR-- postInfoWidgetPublic
|
# --BEHAVIOR-- postInfoWidgetPublic
|
||||||
$content .= $core->callBehavior('postInfoWidgetPublic', $w);
|
$content .= dcCore::app()->callBehavior('postInfoWidgetPublic', $w);
|
||||||
|
|
||||||
if (empty($content)) {
|
if (empty($content)) {
|
||||||
return null;
|
return null;
|
||||||
@ -579,10 +572,8 @@ class postInfoWidget
|
|||||||
|
|
||||||
public static function li($w, $i, $c)
|
public static function li($w, $i, $c)
|
||||||
{
|
{
|
||||||
global $core;
|
|
||||||
|
|
||||||
$s = ' style="padding-left:%spx;background: transparent url(\'' .
|
$s = ' style="padding-left:%spx;background: transparent url(\'' .
|
||||||
$core->blog->getQmarkURL() .
|
dcCore::app()->blog->getQmarkURL() .
|
||||||
'pf=postInfoWidget/img/%s%s.png\') no-repeat left center;"';
|
'pf=postInfoWidget/img/%s%s.png\') no-repeat left center;"';
|
||||||
if ($w->style == 'small') {
|
if ($w->style == 'small') {
|
||||||
$s = sprintf($s, 16, $i, '-small');
|
$s = sprintf($s, 16, $i, '-small');
|
||||||
@ -598,9 +589,7 @@ class postInfoWidget
|
|||||||
|
|
||||||
public static function nav($p, $d, $r, $t, $c)
|
public static function nav($p, $d, $r, $t, $c)
|
||||||
{
|
{
|
||||||
global $core;
|
$rs = dcCore::app()->blog->getNextPost($p, $d, $r);
|
||||||
|
|
||||||
$rs = $core->blog->getNextPost($p, $d, $r);
|
|
||||||
if (is_null($rs)) {
|
if (is_null($rs)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user