Compare commits
No commits in common. "master" and "v2023.08.12" have entirely different histories.
master
...
v2023.08.1
12
CHANGELOG.md
12
CHANGELOG.md
@ -1,15 +1,3 @@
|
||||
lastBlogUpdate 2023.10.19
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Code review (callable)
|
||||
|
||||
lastBlogUpdate 2023.10.11
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Upgrade to Dotclear 2.28
|
||||
|
||||
lastBlogUpdate 2023.08.12
|
||||
===========================================================
|
||||
* Require Dotclear 2.27
|
||||
|
34
README.md
34
README.md
@ -1,22 +1,25 @@
|
||||
# README
|
||||
|
||||
[![Release](https://img.shields.io/badge/release-2023.10.19-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/lastBlogUpdate/releases)
|
||||
![Date](https://img.shields.io/badge/date-2023.10.19-c44d58.svg)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
|
||||
[![Release](https://img.shields.io/badge/release-2023.08.12-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/lastBlogUpdate/releases)
|
||||
[![Date](https://img.shields.io/badge/date-2023.08.12-c44d58.svg)](https://git.dotclear.watch/JcDenis/lastBlogUpdate/releases)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/lastBlogUpdate)
|
||||
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/lastBlogUpdate/src/branch/master/LICENSE)
|
||||
[![License](https://img.shields.io/github/license/JcDenis/lastBlogUpdate)](https://git.dotclear.watch/JcDenis/lastBlogUpdate/blob/master/LICENSE)
|
||||
|
||||
## ABOUT
|
||||
## WHAT IS LASTBLOGUPDATE ?
|
||||
|
||||
_lastBlogUpdate_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
||||
_last blog update_ is a plugin for the open-source
|
||||
web publishing software called Dotclear.
|
||||
|
||||
> Simply show visitors last update of posts, comments, etc of your blog.
|
||||
Simply show visitors last update of posts, comments, etc of your blog.
|
||||
|
||||
## REQUIREMENTS
|
||||
|
||||
* Dotclear 2.28
|
||||
* PHP 8.1+
|
||||
* Dotclear permissions to manage widgets
|
||||
_lastBlogUpdate_ requires:
|
||||
|
||||
* permissions to manage widgets
|
||||
* Dotclear 2.27
|
||||
* PHP 7.4+
|
||||
|
||||
## USAGE
|
||||
|
||||
@ -27,15 +30,14 @@ Add and configure _Last blog update_ from widgets manager.
|
||||
|
||||
## LINKS
|
||||
|
||||
* [License](https://git.dotclear.watch/JcDenis/lastBlogUpdate/src/branch/master/LICENSE)
|
||||
* [Packages & details](https://git.dotclear.watch/JcDenis/lastBlogUpdate/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/lastBlogUpdate))
|
||||
* [Sources & contributions](https://git.dotclear.watch/JcDenis/lastBlogUpdate) (or on [GitHub](https://github.com/JcDenis/lastBlogUpdate))
|
||||
* [Issues & security](https://git.dotclear.watch/JcDenis/lastBlogUpdate/issues) (or on [GitHub](https://github.com/JcDenis/lastBlogUpdate/issues))
|
||||
* [Discuss & help](ttp://forum.dotclear.org/viewtopic.php?pid=332950#p332950)
|
||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/lastBlogUpdate) or [GitHub Page](https://github.com/JcDenis/lastBlogUpdate)
|
||||
* Packages & details : [Gitea Page](https://git.dotclear.watch/JcDenis/lastBlogUpdate/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/lastBlogUpdate)
|
||||
* Discuss and help : [Dotclear Forum](ttp://forum.dotclear.org/viewtopic.php?pid=332950#p332950)
|
||||
|
||||
## CONTRIBUTORS
|
||||
|
||||
* Jean-Christian Denis (author)
|
||||
* Jean-Christian Denis
|
||||
* Pierre Van Glabeke
|
||||
|
||||
You are welcome to contribute to this code.
|
||||
|
34
_define.php
34
_define.php
@ -1,27 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* @brief The plugin lastBlogUpdate definition
|
||||
* @ingroup lastBlogUpdate
|
||||
* @brief lastBlogUpdate, a plugin for Dotclear 2
|
||||
*
|
||||
* @defgroup lastBlogUpdate Plugin lastBlogUpdate.
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* Show the dates of last updates of your blog in a widget.
|
||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->registerModule(
|
||||
'Last blog update',
|
||||
'Show the dates of last updates of your blog in a widget',
|
||||
'Jean-Christian Denis, Pierre Van Glabeke',
|
||||
'2023.10.19',
|
||||
'2023.08.12',
|
||||
[
|
||||
'requires' => [['core', '2.28']],
|
||||
'permissions' => 'My',
|
||||
'type' => 'plugin',
|
||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
|
||||
'requires' => [['core', '2.27']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_USAGE,
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
]),
|
||||
'type' => 'plugin',
|
||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
|
||||
]
|
||||
);
|
||||
|
@ -2,11 +2,11 @@
|
||||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="lastBlogUpdate">
|
||||
<name>Last blog update</name>
|
||||
<version>2023.10.19</version>
|
||||
<version>2023.08.12</version>
|
||||
<author>Jean-Christian Denis, Pierre Van Glabeke</author>
|
||||
<desc>Show the dates of last updates of your blog in a widget</desc>
|
||||
<file>https://git.dotclear.watch/JcDenis/lastBlogUpdate/releases/download/v2023.10.19/plugin-lastBlogUpdate.zip</file>
|
||||
<da:dcmin>2.28</da:dcmin>
|
||||
<file>https://git.dotclear.watch/JcDenis/lastBlogUpdate/releases/download/v2023.08.12/plugin-lastBlogUpdate.zip</file>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<da:details>https://git.dotclear.watch/JcDenis/lastBlogUpdate/src/branch/master/README.md</da:details>
|
||||
<da:support>https://git.dotclear.watch/JcDenis/lastBlogUpdate/issues</da:support>
|
||||
</module>
|
||||
|
@ -1,19 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief lastBlogUpdate, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\lastBlogUpdate;
|
||||
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* @brief lastBlogUpdate backend class.
|
||||
* @ingroup lastBlogUpdate
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Backend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
@ -27,7 +30,9 @@ class Backend extends Process
|
||||
return false;
|
||||
}
|
||||
|
||||
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
|
||||
dcCore::app()->addBehaviors([
|
||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,19 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief lastBlogUpdate, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\lastBlogUpdate;
|
||||
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* @brief lastBlogUpdate frontend class.
|
||||
* @ingroup lastBlogUpdate
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Frontend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
@ -27,7 +30,9 @@ class Frontend extends Process
|
||||
return false;
|
||||
}
|
||||
|
||||
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
|
||||
dcCore::app()->addBehaviors([
|
||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
20
src/My.php
20
src/My.php
@ -1,19 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief lastBlogUpdate, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\lastBlogUpdate;
|
||||
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* @brief lastBlogUpdate My helper.
|
||||
* @ingroup lastBlogUpdate
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class My extends MyPlugin
|
||||
{
|
||||
// Use default permissions
|
||||
}
|
||||
|
@ -1,23 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief lastBlogUpdate, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\lastBlogUpdate;
|
||||
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use dcMedia;
|
||||
use Dotclear\Database\Statement\SelectStatement;
|
||||
use Dotclear\Helper\Date;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Plugin\widgets\WidgetsStack;
|
||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
||||
|
||||
/**
|
||||
* @brief lastBlogUpdate widgets class.
|
||||
* @ingroup lastBlogUpdate
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Widgets
|
||||
{
|
||||
public static function initWidgets(WidgetsStack $w): void
|
||||
@ -26,7 +30,7 @@ class Widgets
|
||||
->create(
|
||||
'lastblogupdate',
|
||||
__('Last blog update'),
|
||||
self::parseWidget(...),
|
||||
[self::class, 'parseWidget'],
|
||||
null,
|
||||
'Show the dates of last updates of your blog in a widget'
|
||||
)
|
||||
@ -105,9 +109,9 @@ class Widgets
|
||||
);
|
||||
|
||||
# --BEHAVIOR-- lastBlogUpdateWidgetInit
|
||||
App::behavior()->callBehavior('lastBlogUpdateWidgetInit', $w);
|
||||
dcCore::app()->callBehavior('lastBlogUpdateWidgetInit', $w);
|
||||
|
||||
$w->__get('lastblogupdate')
|
||||
$w->lastblogupdate
|
||||
->addHomeOnly()
|
||||
->addContentOnly()
|
||||
->addClass()
|
||||
@ -116,30 +120,30 @@ class Widgets
|
||||
|
||||
public static function parseWidget(WidgetsElement $w): string
|
||||
{
|
||||
if ($w->offline || !App::blog()->isDefined()) {
|
||||
if ($w->offline || is_null(dcCore::app()->blog)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
# Nothing to display
|
||||
if (!$w->checkHomeOnly(App::url()->type)
|
||||
if (!$w->checkHomeOnly(dcCore::app()->url->type)
|
||||
|| !$w->blog_show && !$w->post_show && !$w->comment_show && !$w->media_show
|
||||
|| !$w->blog_text && !$w->post_text && !$w->comment_text && !$w->media_text) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$blog = $post = $comment = $media = $addons = '';
|
||||
$tz = is_string(App::blog()->settings()->get('system')->get('blog_timezone')) ? App::blog()->settings()->get('system')->get('blog_timezone') : 'UTC';
|
||||
$tz = is_string(dcCore::app()->blog->settings->get('system')->get('blog_timezone')) ? dcCore::app()->blog->settings->get('system')->get('blog_timezone') : 'UTC';
|
||||
|
||||
# Blog
|
||||
if ($w->blog_show && $w->blog_text) {
|
||||
if ($w->blog_show && $w->blog_text && is_numeric(dcCore::app()->blog->upddt)) {
|
||||
$title = $w->blog_title ? sprintf('<strong>%s</strong>', Html::escapeHTML($w->blog_title)) : '';
|
||||
$text = Date::str($w->blog_text, App::blog()->upddt(), $tz);
|
||||
$text = Date::str($w->blog_text, (int) dcCore::app()->blog->upddt, $tz);
|
||||
$blog = sprintf('<li>%s %s</li>', $title, $text);
|
||||
}
|
||||
|
||||
# Post
|
||||
if ($w->post_show && $w->post_text) {
|
||||
$rs = App::blog()->getPosts(['limit' => 1, 'no_content' => true]);
|
||||
$rs = dcCore::app()->blog->getPosts(['limit' => 1, 'no_content' => true]);
|
||||
if (!$rs->isEmpty()) {
|
||||
$title = $w->post_title ? sprintf('<strong>%s</strong>', Html::escapeHTML($w->post_title)) : '';
|
||||
$text = Date::str($w->post_text, (int) strtotime(is_string($rs->f('post_upddt')) ? $rs->f('post_upddt') : ''), $tz);
|
||||
@ -152,11 +156,11 @@ class Widgets
|
||||
|
||||
# Comment
|
||||
if ($w->comment_show && $w->comment_text) {
|
||||
$rs = App::blog()->getComments(['limit' => 1, 'no_content' => true]);
|
||||
$rs = dcCore::app()->blog->getComments(['limit' => 1, 'no_content' => true]);
|
||||
if (!$rs->isEmpty()) {
|
||||
$title = $w->comment_title ? sprintf('<strong>%s</strong>', Html::escapeHTML($w->comment_title)) : '';
|
||||
$text = Date::str($w->comment_text, (int) strtotime(is_string($rs->f('comment_upddt')) ? $rs->f('comment_upddt') : ''), $tz);
|
||||
$link = App::blog()->url() . App::postTypes()->get(is_string($rs->f('post_type')) ? $rs->f('post_type') : '')->publicUrl(Html::sanitizeURL(is_string($rs->f('post_url')) ? $rs->f('post_url') : '')) . '#c' . $rs->f('comment_id');
|
||||
$link = dcCore::app()->blog->url . dcCore::app()->getPostPublicURL(is_string($rs->f('post_type')) ? $rs->f('post_type') : '', Html::sanitizeURL(is_string($rs->f('post_url')) ? $rs->f('post_url') : '')) . '#c' . $rs->f('comment_id');
|
||||
$over = is_string($rs->f('post_title')) ? $rs->f('post_title') : '';
|
||||
|
||||
$comment = sprintf('<li>%s <a href="%s" title="%s">%s</a></li>', $title, $link, $over, $text);
|
||||
@ -165,9 +169,9 @@ class Widgets
|
||||
|
||||
# Media
|
||||
if ($w->media_show && $w->media_text) {
|
||||
$path = App::blog()->settings()->get('system')->get('public_path');
|
||||
$path = dcCore::app()->blog->settings->get('system')->get('public_path');
|
||||
$sql = new SelectStatement();
|
||||
$rs = $sql->from(App::con()->prefix() . App::postMedia()::MEDIA_TABLE_NAME)
|
||||
$rs = $sql->from(dcCore::app()->prefix . dcMedia::MEDIA_TABLE_NAME)
|
||||
->column('media_upddt')
|
||||
->where('media_path = ' . $sql->quote(is_string($path) ? $path : ''))
|
||||
->order('media_upddt DESC')
|
||||
@ -183,7 +187,7 @@ class Widgets
|
||||
}
|
||||
|
||||
# --BEHAVIOR-- lastBlogUpdateWidgetParse
|
||||
$addons = App::behavior()->callBehavior('lastBlogUpdateWidgetParse', $w);
|
||||
$addons = dcCore::app()->callBehavior('lastBlogUpdateWidgetParse', $w);
|
||||
|
||||
# Nothing to display
|
||||
if (!$blog && !$post && !$comment && !$media && !$addons) {
|
||||
|
Loading…
Reference in New Issue
Block a user