prepare to DC 2.24

This commit is contained in:
Jean-Christian Denis 2022-11-15 22:39:21 +01:00
parent 57165b0541
commit 53ed454fac
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
4 changed files with 55 additions and 61 deletions

View file

@ -1,18 +1,17 @@
<?php <?php
/** /**
* @brief lastBlogUpdate, a plugin for Dotclear 2 * @brief lastBlogUpdate, a plugin for Dotclear 2
* *
* @package Dotclear * @package Dotclear
* @subpackage Plugin * @subpackage Plugin
* *
* @author Jean-Christian Denis, Pierre Van Glabeke * @author Jean-Christian Denis, Pierre Van Glabeke
* *
* @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';

View file

@ -1,16 +1,15 @@
<?php <?php
/** /**
* @brief lastBlogUpdate, a plugin for Dotclear 2 * @brief lastBlogUpdate, a plugin for Dotclear 2
* *
* @package Dotclear * @package Dotclear
* @subpackage Plugin * @subpackage Plugin
* *
* @author Jean-Christian Denis, Pierre Van Glabeke * @author Jean-Christian Denis, Pierre Van Glabeke
* *
* @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(
'Last blog update', 'Last blog update',
'Show the dates of last updates of your blog in a widget', 'Show the dates of last updates of your blog in a widget',
'Jean-Christian Denis, Pierre Van Glabeke', 'Jean-Christian Denis, Pierre Van Glabeke',
'2021.09.17', '2022.11.12',
[ [
'requires' => [['core', '2.19']], 'requires' => [['core', '2.24']],
'permissions' => 'usage,contentadmin', 'permissions' => dcCore::app()->auth->makePermissions([
'type' => 'plugin', dcAuth::PERMISSION_USAGE,
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=332950#p332950', dcAuth::PERMISSION_CONTENT_ADMIN,
'details' => 'http://plugins.dotaddict.org/dc2/details/lastBlogUpdate', ]),
'repository' => 'https://raw.githubusercontent.com/JcDenis/lastBlogUpdate/master/dcstore.xml' 'type' => 'plugin',
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=332950#p332950',
'details' => 'http://plugins.dotaddict.org/dc2/details/lastBlogUpdate',
'repository' => 'https://raw.githubusercontent.com/JcDenis/lastBlogUpdate/master/dcstore.xml',
] ]
); );

View file

@ -1,36 +1,32 @@
<?php <?php
/** /**
* @brief lastBlogUpdate, a plugin for Dotclear 2 * @brief lastBlogUpdate, a plugin for Dotclear 2
* *
* @package Dotclear * @package Dotclear
* @subpackage Plugin * @subpackage Plugin
* *
* @author Jean-Christian Denis, Pierre Van Glabeke * @author Jean-Christian Denis, Pierre Van Glabeke
* *
* @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';
function lastBlogUpdateWidgetPublic($w) function lastBlogUpdateWidgetPublic($w)
{ {
global $core;
if ($w->offline) { if ($w->offline) {
return null; return null;
} }
# Nothing to display # Nothing to display
if ($w->homeonly == 1 && $core->url->type != 'default' if ($w->homeonly == 1 && dcCore::app()->url->type != 'default'
|| $w->homeonly == 2 && $core->url->type == 'default' || $w->homeonly == 2 && dcCore::app()->url->type == 'default'
|| !$w->blog_show && !$w->post_show && !$w->comment_show && !$w->media_show || !$w->blog_show && !$w->post_show && !$w->comment_show && !$w->media_show
|| !$w->blog_text && !$w->post_text && !$w->comment_text && !$w->media_text) { || !$w->blog_text && !$w->post_text && !$w->comment_text && !$w->media_text) {
return null; return null;
} }
@ -39,18 +35,18 @@ function lastBlogUpdateWidgetPublic($w)
# Blog # Blog
if ($w->blog_show && $w->blog_text) { if ($w->blog_show && $w->blog_text) {
$title = $w->blog_title ? sprintf('<strong>%s</strong>', html::escapeHTML($w->blog_title)) : ''; $title = $w->blog_title ? sprintf('<strong>%s</strong>', html::escapeHTML($w->blog_title)) : '';
$text = dt::str($w->blog_text, $core->blog->upddt, $core->blog->settings->system->blog_timezone); $text = dt::str($w->blog_text, dcCore::app()->blog->upddt, dcCore::app()->blog->settings->system->blog_timezone);
$blog = sprintf('<li>%s%s</li>', $title, $text); $blog = sprintf('<li>%s%s</li>', $title, $text);
} }
# Post # Post
if ($w->post_show && $w->post_text) { if ($w->post_show && $w->post_text) {
$rs = $core->blog->getPosts(['limit' => 1, 'no_content' => true]); $rs = dcCore::app()->blog->getPosts(['limit' => 1, 'no_content' => true]);
if (!$rs->isEmpty()) { if (!$rs->isEmpty()) {
$title = $w->post_title ? sprintf('<strong>%s</strong>', html::escapeHTML($w->post_title)) : ''; $title = $w->post_title ? sprintf('<strong>%s</strong>', html::escapeHTML($w->post_title)) : '';
$text = dt::str($w->post_text, strtotime($rs->post_upddt), $core->blog->settings->system->blog_timezone); $text = dt::str($w->post_text, strtotime($rs->post_upddt), dcCore::app()->blog->settings->system->blog_timezone);
$link = $rs->getURL(); $link = $rs->getURL();
$over = $rs->post_title; $over = $rs->post_title;
$post = sprintf('<li>%s<a href="%s" title="%s">%s</a></li>', $title, $link, $over, $text); $post = sprintf('<li>%s<a href="%s" title="%s">%s</a></li>', $title, $link, $over, $text);
} }
@ -58,12 +54,12 @@ function lastBlogUpdateWidgetPublic($w)
# Comment # Comment
if ($w->comment_show && $w->comment_text) { if ($w->comment_show && $w->comment_text) {
$rs = $core->blog->getComments(['limit' => 1, 'no_content' => true]); $rs = dcCore::app()->blog->getComments(['limit' => 1, 'no_content' => true]);
if (!$rs->isEmpty()) { if (!$rs->isEmpty()) {
$title = $w->comment_title ? sprintf('<strong>%s</strong>', html::escapeHTML($w->comment_title)) : ''; $title = $w->comment_title ? sprintf('<strong>%s</strong>', html::escapeHTML($w->comment_title)) : '';
$text = dt::str($w->comment_text, strtotime($rs->comment_upddt), $core->blog->settings->system->blog_timezone); $text = dt::str($w->comment_text, strtotime($rs->comment_upddt), dcCore::app()->blog->settings->system->blog_timezone);
$link = $core->blog->url . $core->getPostPublicURL($rs->post_type, html::sanitizeURL($rs->post_url)) . '#c' . $rs->comment_id; $link = dcCore::app()->blog->url . dcCore::app()->getPostPublicURL($rs->post_type, html::sanitizeURL($rs->post_url)) . '#c' . $rs->comment_id;
$over = $rs->post_title; $over = $rs->post_title;
$comment = sprintf('<li>%s<a href="%s" title="%s">%s</a></li>', $title, $link, $over, $text); $comment = sprintf('<li>%s<a href="%s" title="%s">%s</a></li>', $title, $link, $over, $text);
} }
@ -71,22 +67,22 @@ function lastBlogUpdateWidgetPublic($w)
# Media # Media
if ($w->media_show && $w->media_text) { if ($w->media_show && $w->media_text) {
$rs = $core->con->select( $rs = dcCore::app()->con->select(
'SELECT media_upddt FROM ' . $core->prefix . 'media ' . 'SELECT media_upddt FROM ' . dcCore::app()->prefix . dcMedia::MEDIA_TABLE_NAME . ' ' .
"WHERE media_path='" . $core->con->escape($core->blog->settings->system->public_path) . "' " . "WHERE media_path='" . dcCore::app()->con->escape(dcCore::app()->blog->settings->system->public_path) . "' " .
'ORDER BY media_upddt DESC ' . $core->con->limit(1) 'ORDER BY media_upddt DESC ' . dcCore::app()->con->limit(1)
); );
if (!$rs->isEmpty()) { if (!$rs->isEmpty()) {
$title = $w->media_title ? sprintf('<strong>%s</strong>', html::escapeHTML($w->media_title)) : ''; $title = $w->media_title ? sprintf('<strong>%s</strong>', html::escapeHTML($w->media_title)) : '';
$text = dt::str($w->media_text, strtotime($rs->f('media_upddt')), $core->blog->settings->system->blog_timezone); $text = dt::str($w->media_text, strtotime($rs->f('media_upddt')), dcCore::app()->blog->settings->system->blog_timezone);
$media = sprintf('<li>%s%s</li>', $title, $text); $media = sprintf('<li>%s%s</li>', $title, $text);
} }
} }
# --BEHAVIOR-- lastBlogUpdateWidgetParse # --BEHAVIOR-- lastBlogUpdateWidgetParse
$addons = $core->callBehavior('lastBlogUpdateWidgetParse', $core, $w); $addons = dcCore::app()->callBehavior('lastBlogUpdateWidgetParse', $w);
# Nothing to display # Nothing to display
if (!$blog && !$post && !$comment && !$media && !$addons) { if (!$blog && !$post && !$comment && !$media && !$addons) {
@ -101,4 +97,4 @@ function lastBlogUpdateWidgetPublic($w)
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
sprintf('<ul>%s</ul>', $blog . $post . $comment . $media . $addons) sprintf('<ul>%s</ul>', $blog . $post . $comment . $media . $addons)
); );
} }

View file

@ -1,34 +1,31 @@
<?php <?php
/** /**
* @brief lastBlogUpdate, a plugin for Dotclear 2 * @brief lastBlogUpdate, a plugin for Dotclear 2
* *
* @package Dotclear * @package Dotclear
* @subpackage Plugin * @subpackage Plugin
* *
* @author Jean-Christian Denis, Pierre Van Glabeke * @author Jean-Christian Denis, Pierre Van Glabeke
* *
* @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('initWidgets', 'lastBlogUpdateWidgetAdmin'); dcCore::app()->addBehavior('initWidgets', 'lastBlogUpdateWidgetAdmin');
function lastBlogUpdateWidgetAdmin($w) function lastBlogUpdateWidgetAdmin($w)
{ {
global $core;
$w $w
->create( ->create(
'lastblogupdate', 'lastblogupdate',
__('LastBlogUpdate: dates of lastest updates'), __('LastBlogUpdate: dates of lastest updates'),
'lastBlogUpdateWidgetPublic', 'lastBlogUpdateWidgetPublic',
null, null,
"Show the dates of last updates of your blog in a widget" 'Show the dates of last updates of your blog in a widget'
) )
->addTitle(__('Dates of lastest updates')) ->addTitle(__('Dates of lastest updates'))
->setting( ->setting(
'blog_show', 'blog_show',
@ -104,11 +101,11 @@ function lastBlogUpdateWidgetAdmin($w)
); );
# --BEHAVIOR-- lastBlogUpdateWidgetInit # --BEHAVIOR-- lastBlogUpdateWidgetInit
$core->callBehavior('lastBlogUpdateWidgetInit', $w); dcCore::app()->callBehavior('lastBlogUpdateWidgetInit', $w);
$w->lastblogupdate $w->lastblogupdate
->addHomeOnly() ->addHomeOnly()
->addContentOnly() ->addContentOnly()
->addClass() ->addClass()
->addOffline(); ->addOffline();
} }