diff --git a/CHANGELOG.md b/CHANGELOG.md
index e3feca6..bc8116a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+periodical 2023.10.20
+===========================================================
+* Require Dotclear 2.28
+* Require PHP 8.1
+* Upgrade to Dotclear 2.28
+
periodical 2023.08.15
===========================================================
* Require Dotclear 2.27
diff --git a/README.md b/README.md
index 19cb883..55842b6 100644
--- a/README.md
+++ b/README.md
@@ -1,28 +1,25 @@
# README
[![Release](https://img.shields.io/badge/release-2023.08.15-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/periodical/releases)
-[![Date](https://img.shields.io/badge/date-2023.08.15-c44d58.svg)](https://git.dotclear.watch/JcDenis/periodical/releases)
+![Date](https://img.shields.io/badge/date-2023.08.15-c44d58.svg)
[![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/periodical)
-[![License](https://img.shields.io/github/license/JcDenis/periodical)](https://git.dotclear.watch/JcDenis/periodical/blob/master/LICENSE)
+[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/periodical/src/branch/master/LICENSE)
-## WHAT IS PERIODICAL ?
+## ABOUT
-_Periodical_ is a plugin for the open-source
-web publishing software called Dotclear.
+_periodical_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
-You can manage and publish automatically lists of posts
+> Manage and publish automatically lists of posts
at regular periods. For exemple, you just need to add posts to a period
and they will be publish ones after the others every week.
## REQUIREMENTS
- _periodical_ requires:
-
-* admin permissions to configure plugin
-* usage,contentadmin permissions to link feeds
-* Dotclear 2.27
+* Dotclear 2.28
* PHP 8.1+
+* Dotclear admin permissions to configure plugin
+* Dotclear usage,contentadmin permissions to link feeds
## NOTICE
@@ -45,10 +42,11 @@ You can also add or remove period to multiple posts from posts actions page.
## LINKS
-* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
-* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/periodical) or [GitHub Page](https://github.com/JcDenis/periodical)
-* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/periodical/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/periodical)
-* Discuss & help : [Dotclear Forum](https://forum.dotclear.org/viewtopic.php?id=42289)
+* [License](https://git.dotclear.watch/JcDenis/periodical/src/branch/master/LICENSE)
+* [Packages & details](https://git.dotclear.watch/JcDenis/periodical/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/periodical))
+* [Sources & contributions](https://git.dotclear.watch/JcDenis/periodical) (or on [GitHub](https://github.com/JcDenis/periodical))
+* [Issues & security](https://git.dotclear.watch/JcDenis/periodical/issues) (or on [GitHub](https://github.com/JcDenis/periodical/issues))
+* [Discuss & help](https://forum.dotclear.org/viewtopic.php?id=42289)
## CONTRIBUTORS
diff --git a/_define.php b/_define.php
index e652988..a9e7259 100644
--- a/_define.php
+++ b/_define.php
@@ -1,39 +1,30 @@
registerModule(
'Periodical',
'Published periodically entries',
'Jean-Christian Denis and contributors',
- '2023.08.15',
+ '2023.10.20',
[
- 'requires' => [
- ['php', '8.1'],
- ['core', '2.27'],
- ],
- 'permissions' => dcCore::app()->auth->makePermissions([
- dcCore::app()->auth::PERMISSION_USAGE,
- dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
- ]),
- 'settings' => [
- 'blog' => '#params.' . basename(__DIR__) . '_params',
- ],
- '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.28']],
+ 'permissions' => 'My',
+ 'settings' => ['blog' => '#params.' . basename(__DIR__) . '_params'],
+ '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',
]
);
diff --git a/_init.php b/_init.php
deleted file mode 100644
index 0868be2..0000000
--- a/_init.php
+++ /dev/null
@@ -1,21 +0,0 @@
-
Periodical
- 2023.08.15
+ 2023.10.20
Jean-Christian Denis and contributors
Published periodically entries
- https://git.dotclear.watch/JcDenis/periodical/releases/download/v2023.08.15/plugin-periodical.zip
- 2.27
+ https://git.dotclear.watch/JcDenis/periodical/releases/download/v2023.10.20/plugin-periodical.zip
+ 2.28
https://git.dotclear.watch/JcDenis/periodical/src/branch/master/README.md
https://git.dotclear.watch/JcDenis/periodical/issues
diff --git a/locales/en/resources.php b/locales/en/resources.php
index 22d6045..c173f6c 100644
--- a/locales/en/resources.php
+++ b/locales/en/resources.php
@@ -1,19 +1,10 @@
resources['help']['periodical'] = __DIR__ . '/help/help.html';
+/**
+ * @file
+ * @brief The plugin periodical definition
+ * @ingroup periodical
+ *
+ * @author Jean-Christian Denis
+ * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
+ */
+\Dotclear\App::backend()->resources()->set('help', 'periodical', __DIR__ . '/help/help.html');
diff --git a/locales/fr/resources.php b/locales/fr/resources.php
index 22d6045..c173f6c 100644
--- a/locales/fr/resources.php
+++ b/locales/fr/resources.php
@@ -1,19 +1,10 @@
resources['help']['periodical'] = __DIR__ . '/help/help.html';
+/**
+ * @file
+ * @brief The plugin periodical definition
+ * @ingroup periodical
+ *
+ * @author Jean-Christian Denis
+ * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
+ */
+\Dotclear\App::backend()->resources()->set('help', 'periodical', __DIR__ . '/help/help.html');
diff --git a/src/Backend.php b/src/Backend.php
index 009f95b..927d906 100644
--- a/src/Backend.php
+++ b/src/Backend.php
@@ -1,22 +1,19 @@
addBehaviors([
- 'adminBlogPreferencesFormV2' => [BackendBehaviors::class, 'adminBlogPreferencesFormV2'],
- 'adminBeforeBlogSettingsUpdate' => [BackendBehaviors::class, 'adminBeforeBlogSettingsUpdate'],
- 'adminFiltersListsV2' => [BackendBehaviors::class, 'adminFiltersListsV2'],
- 'adminColumnsListsV2' => [BackendBehaviors::class, 'adminColumnsListsV2'],
- 'adminPostListHeaderV2' => [BackendBehaviors::class, 'adminPostListHeaderV2'],
- 'adminPostListValueV2' => [BackendBehaviors::class, 'adminPostListValueV2'],
- 'adminBeforePostDelete' => [BackendBehaviors::class, 'adminBeforePostDelete'],
+ App::behavior()->addBehaviors([
+ 'adminBlogPreferencesFormV2' => BackendBehaviors::adminBlogPreferencesFormV2(...),
+ 'adminBeforeBlogSettingsUpdate' => BackendBehaviors::adminBeforeBlogSettingsUpdate(...),
+ 'adminFiltersListsV2' => BackendBehaviors::adminFiltersListsV2(...),
+ 'adminColumnsListsV2' => BackendBehaviors::adminColumnsListsV2(...),
+ 'adminPostListHeaderV2' => BackendBehaviors::adminPostListHeaderV2(...),
+ 'adminPostListValueV2' => BackendBehaviors::adminPostListValueV2(...),
+ 'adminBeforePostDelete' => BackendBehaviors::adminBeforePostDelete(...),
]);
if (My::settings()->get('periodical_active')) {
@@ -46,13 +43,13 @@ class Backend extends Process
My::addBackendMenuItem();
// register bakend behaviors required user permissions
- dcCore::app()->addBehaviors([
- 'adminDashboardFavoritesV2' => [BackendBehaviors::class, 'adminDashboardFavoritesV2'],
- 'adminPostHeaders' => [BackendBehaviors::class, 'adminPostHeaders'],
- 'adminPostsActions' => [BackendBehaviors::class, 'adminPostsActions'],
- 'adminPostFormItems' => [BackendBehaviors::class, 'adminPostFormItems'],
- 'adminAfterPostUpdate' => [BackendBehaviors::class, 'adminAfterPostSave'],
- 'adminAfterPostCreate' => [BackendBehaviors::class, 'adminAfterPostSave'],
+ App::behavior()->addBehaviors([
+ 'adminDashboardFavoritesV2' => BackendBehaviors::adminDashboardFavoritesV2(...),
+ 'adminPostHeaders' => BackendBehaviors::adminPostHeaders(...),
+ 'adminPostsActions' => BackendBehaviors::adminPostsActions(...),
+ 'adminPostFormItems' => BackendBehaviors::adminPostFormItems(...),
+ 'adminAfterPostUpdate' => BackendBehaviors::adminAfterPostSave(...),
+ 'adminAfterPostCreate' => BackendBehaviors::adminAfterPostSave(...),
]);
}
diff --git a/src/BackendBehaviors.php b/src/BackendBehaviors.php
index b0a9698..589c903 100644
--- a/src/BackendBehaviors.php
+++ b/src/BackendBehaviors.php
@@ -1,22 +1,11 @@
get(My::id());
@@ -87,9 +79,9 @@ class BackendBehaviors
/**
* Save blog settings.
*
- * @param dcSettings $blog_settings dcSettings instance
+ * @param BlogSettingsInterface $blog_settings BlogSettingsInterface instance
*/
- public static function adminBeforeBlogSettingsUpdate(dcSettings $blog_settings): void
+ public static function adminBeforeBlogSettingsUpdate(BlogSettingsInterface $blog_settings): void
{
$blog_settings->get(My::id())->put('periodical_active', !empty($_POST['periodical_active']));
$blog_settings->get(My::id())->put('periodical_upddate', !empty($_POST['periodical_upddate']));
@@ -180,9 +172,9 @@ class BackendBehaviors
'url' => My::manageUrl(),
'small-icon' => My::icons(),
'large-icon' => My::icons(),
- 'permissions' => dcCore::app()->auth->makePermissions([
- dcCore::app()->auth::PERMISSION_USAGE,
- dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
+ 'permissions' => App::auth()->makePermissions([
+ App::auth()::PERMISSION_USAGE,
+ App::auth()::PERMISSION_CONTENT_ADMIN,
]),
]);
}
@@ -216,16 +208,16 @@ class BackendBehaviors
{
$pa->addAction(
[My::name() => [__('Add to periodical') => 'periodical_add']],
- [self::class, 'callbackAdd']
+ self::callbackAdd(...)
);
- if (dcCore::app()->auth?->check(dcCore::app()->auth->makePermissions([
- dcCore::app()->auth::PERMISSION_DELETE,
- dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
- ]), dcCore::app()->blog?->id)) {
+ if (App::auth()->check(App::auth()->makePermissions([
+ App::auth()::PERMISSION_DELETE,
+ App::auth()::PERMISSION_CONTENT_ADMIN,
+ ]), App::blog()->id())) {
$pa->addAction(
[My::name() => [__('Remove from periodical') => 'periodical_remove']],
- [self::class, 'callbackRemove']
+ self::callbackRemove(...)
);
}
}
@@ -245,10 +237,10 @@ class BackendBehaviors
}
// No right
- if (!dcCore::app()->auth?->check(dcCore::app()->auth->makePermissions([
- dcCore::app()->auth::PERMISSION_DELETE,
- dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
- ]), dcCore::app()->blog?->id)) {
+ if (!App::auth()->check(App::auth()->makePermissions([
+ App::auth()::PERMISSION_DELETE,
+ App::auth()::PERMISSION_CONTENT_ADMIN,
+ ]), App::blog()->id())) {
throw new Exception(__('No enough right'));
}
@@ -292,9 +284,9 @@ class BackendBehaviors
else {
$pa->beginPage(
Page::breadcrumb([
- Html::escapeHTML((string) dcCore::app()->blog?->name) => '',
- $pa->getCallerTitle() => $pa->getRedirection(true),
- __('Add a period to this selection') => '',
+ Html::escapeHTML(App::blog()->name()) => '',
+ $pa->getCallerTitle() => $pa->getRedirection(true),
+ __('Add a period to this selection') => '',
])
);
@@ -302,14 +294,12 @@ class BackendBehaviors
(new Form('periodicaladd'))->method('post')->action($pa->getURI())->fields([
(new Text('', $pa->getCheckboxes())),
self::formPeriod(0),
- (new Para())->items(array_merge(
- [
- dcCore::app()->formNonce(false),
- (new Hidden(['action'], 'periodical_add')),
- (new Submit(['do']))->value(__('Save')),
- ],
- $pa->hiddenFields()
- )),
+ (new Para())->items([
+ App::nonce()->formNonce(),
+ (new Hidden(['action'], 'periodical_add')),
+ (new Submit(['do']))->value(__('Save')),
+ ... $pa->hiddenFields(),
+ ]),
])->render();
$pa->endPage();
diff --git a/src/Dater.php b/src/Dater.php
index b1792a1..48394de 100644
--- a/src/Dater.php
+++ b/src/Dater.php
@@ -1,25 +1,21 @@
auth?->getInfo('user_tz');
+ $tz = App::auth()->getInfo('user_tz');
$d = date_create($date, new DateTimeZone($tz ?? 'UTC'));
return $d ? date_format($d->setTimezone(new DateTimeZone('UTC')), $format) : '';
@@ -49,7 +45,7 @@ class Dater
*/
public static function toUser(string $date, string $format = 'Y-m-d\TH:i'): string
{
- $tz = dcCore::app()->auth?->getInfo('user_tz');
+ $tz = App::auth()->getInfo('user_tz');
$d = date_create($date, new DateTimeZone('UTC'));
return $d ? date_format($d->setTimezone(new DateTimeZone($tz ?? 'UTC')), $format) : '';
diff --git a/src/Frontend.php b/src/Frontend.php
index e67e339..8111d26 100644
--- a/src/Frontend.php
+++ b/src/Frontend.php
@@ -1,32 +1,25 @@
url->type, ['default', 'feed']));
+ return self::status(My::checkContext(My::FRONTEND) && in_array((string) App::url()->type, ['default', 'feed']));
}
public static function process(): bool
@@ -35,8 +28,8 @@ class Frontend extends Process
return false;
}
- dcCore::app()->addBehavior('publicBeforeDocumentV2', function (): void {
- if (is_null(dcCore::app()->blog)) {
+ App::behavior()->addBehavior('publicBeforeDocumentV2', function (): void {
+ if (!App::blog()->isDefined()) {
return;
}
@@ -46,7 +39,7 @@ class Frontend extends Process
Utils::lockUpdate();
// Get periods
- $periods = dcCore::app()->auth->sudo([Utils::class, 'getPeriods']);
+ $periods = App::auth()->sudo(Utils::getPeriods(...));
// No period
if ($periods->isEmpty()) {
@@ -60,7 +53,7 @@ class Frontend extends Process
if (!preg_match('/^(post_dt|post_creadt|post_id) (asc|desc)$/', $posts_order)) {
$posts_order = 'post_dt asc';
}
- $cur_period = dcCore::app()->con->openCursor(dcCore::app()->prefix . My::id());
+ $cur_period = App::con()->openCursor(App::con()->prefix() . My::id());
while ($periods->fetch()) {
// Check if period is ongoing
@@ -89,19 +82,19 @@ class Frontend extends Process
// Get posts to publish related to this period
$posts_params = [];
$posts_params['periodical_id'] = $periods->f('periodical_id');
- $posts_params['post_status'] = dcBlog::POST_PENDING;
+ $posts_params['post_status'] = App::blog()::POST_PENDING;
$posts_params['order'] = $posts_order;
$posts_params['limit'] = $limit * $max_nb;
$posts_params['no_content'] = true;
- $posts = dcCore::app()->auth->sudo([Utils::class, 'getPosts'], $posts_params);
+ $posts = App::auth()->sudo(Utils::getPosts(...), $posts_params);
if (!$posts->isEmpty()) {
- $cur_post = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcBlog::POST_TABLE_NAME);
+ $cur_post = App::blgo()->openPostCursor();
while ($posts->fetch()) {
// Publish post with right date
$cur_post->clean();
- $cur_post->setField('post_status', dcBlog::POST_PUBLISHED);
+ $cur_post->setField('post_status', App::blog()::POST_PUBLISHED);
// Update post date with right date
if ($s->get('periodical_upddate')) {
@@ -112,7 +105,7 @@ class Frontend extends Process
// Also update post url with right date
if ($s->get('periodical_updurl')) {
- $cur_post->setField('post_url', dcCore::app()->blog->getPostURL(
+ $cur_post->setField('post_url', App::blog()->getPostURL(
'',
$cur_post->getField('post_dt'),
$posts->f('post_title'),
@@ -122,7 +115,7 @@ class Frontend extends Process
$cur_post->update(
'WHERE post_id = ' . $posts->f('post_id') . ' ' .
- "AND blog_id = '" . dcCore::app()->con->escapeStr(dcCore::app()->blog->id) . "' "
+ "AND blog_id = '" . App::con()->escapeStr(App::blog()->id()) . "' "
);
// Delete post relation to this period
@@ -137,9 +130,9 @@ class Frontend extends Process
}
// --BEHAVIOR-- periodicalAfterPublishedPeriodicalEntry
- dcCore::app()->callBehavior('periodicalAfterPublishedPeriodicalEntry', $posts, $periods);
+ App::behavior()->callBehavior('periodicalAfterPublishedPeriodicalEntry', $posts, $periods);
}
- dcCore::app()->blog->triggerBlog();
+ App::blog()->triggerBlog();
}
}
@@ -148,7 +141,7 @@ class Frontend extends Process
$cur_period->setField('periodical_curdt', Dater::toDate($loop_ts, 'Y-m-d H:i:00'));
$cur_period->update(
'WHERE periodical_id = ' . $periods->f('periodical_id') . ' ' .
- "AND blog_id = '" . dcCore::app()->con->escapeStr(dcCore::app()->blog->id) . "' "
+ "AND blog_id = '" . App::con()->escapeStr(App::blog()->id()) . "' "
);
}
}
diff --git a/src/Install.php b/src/Install.php
index dec31c6..91a84ce 100644
--- a/src/Install.php
+++ b/src/Install.php
@@ -1,24 +1,21 @@
con, dcCore::app()->prefix);
+ $t = new Structure(App::con(), App::con()->prefix());
// create database table
$t->__get(My::id())
@@ -49,7 +46,7 @@ class Install extends Process
->primary('pk_periodical', 'periodical_id')
->index('idx_periodical_type', 'btree', 'periodical_type');
- (new Structure(dcCore::app()->con, dcCore::app()->prefix))->synchronize($t);
+ (new Structure(App::con(), App::con()->prefix()))->synchronize($t);
// set default settings
$s = My::settings();
@@ -60,7 +57,7 @@ class Install extends Process
return true;
} catch (Exception $e) {
- dcCore::app()->error->add($e->getMessage());
+ App::error()->add($e->getMessage());
return false;
}
diff --git a/src/Manage.php b/src/Manage.php
index 3491422..4a8378c 100644
--- a/src/Manage.php
+++ b/src/Manage.php
@@ -1,20 +1,10 @@
'periods']);
}
} catch (Exception $e) {
- dcCore::app()->error->add($e->getMessage());
+ App::error()->add($e->getMessage());
}
}
@@ -98,7 +92,7 @@ class Manage extends Process
My::redirect(['part' => 'periods']);
}
} catch (Exception $e) {
- dcCore::app()->error->add($e->getMessage());
+ App::error()->add($e->getMessage());
}
}
@@ -133,7 +127,7 @@ class Manage extends Process
$counter = Utils::getPeriods($params, true);
$period_list = new ManageList($periods, $counter->f(0));
} catch (Exception $e) {
- dcCore::app()->error->add($e->getMessage());
+ App::error()->add($e->getMessage());
}
// Display
@@ -150,7 +144,7 @@ class Manage extends Process
Notices::getNotices() .
'
- ' . __('New period') . '
+ ' . __('New period') . '
';
if (isset($period_list)) {
@@ -160,7 +154,7 @@ class Manage extends Process
// Periods list
$period_list->periodDisplay(
$p_filter,
- '