Compare commits

..

No commits in common. "13e976fc1b85a18b6b46346a829731ca4a1ca484" and "bac772ad25d52377f23fda5cedc2c869ee84a911" have entirely different histories.

9 changed files with 50 additions and 124 deletions

View File

@ -1,11 +1,3 @@
periodical 2023.11.04
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Fix typo
* Fix perms
* Code review (phpstan)
periodical 2023.10.20 periodical 2023.10.20
=========================================================== ===========================================================
* Require Dotclear 2.28 * Require Dotclear 2.28

View File

@ -1,7 +1,7 @@
# README # README
[![Release](https://img.shields.io/badge/release-2023.11.04-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/periodical/releases) [![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.11.04-c44d58.svg) ![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) [![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) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/periodical)
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/periodical/src/branch/master/LICENSE) [![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/periodical/src/branch/master/LICENSE)

View File

@ -17,7 +17,7 @@ $this->registerModule(
'Periodical', 'Periodical',
'Published periodically entries', 'Published periodically entries',
'Jean-Christian Denis and contributors', 'Jean-Christian Denis and contributors',
'2023.11.04', '2023.10.20',
[ [
'requires' => [['core', '2.28']], 'requires' => [['core', '2.28']],
'permissions' => 'My', 'permissions' => 'My',

View File

@ -2,10 +2,10 @@
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="periodical"> <module id="periodical">
<name>Periodical</name> <name>Periodical</name>
<version>2023.11.04</version> <version>2023.10.20</version>
<author>Jean-Christian Denis and contributors</author> <author>Jean-Christian Denis and contributors</author>
<desc>Published periodically entries</desc> <desc>Published periodically entries</desc>
<file>https://git.dotclear.watch/JcDenis/periodical/releases/download/v2023.11.04/plugin-periodical.zip</file> <file>https://git.dotclear.watch/JcDenis/periodical/releases/download/v2023.10.20/plugin-periodical.zip</file>
<da:dcmin>2.28</da:dcmin> <da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/periodical/src/branch/master/README.md</da:details> <da:details>https://git.dotclear.watch/JcDenis/periodical/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/periodical/issues</da:support> <da:support>https://git.dotclear.watch/JcDenis/periodical/issues</da:support>

View File

@ -40,11 +40,6 @@ use Exception;
*/ */
class BackendBehaviors class BackendBehaviors
{ {
/**
* Periods combo.
*
* @var array<string, int> $combo_period
*/
private static array $combo_period = []; private static array $combo_period = [];
/** /**
@ -96,7 +91,7 @@ class BackendBehaviors
/** /**
* User pref for periods columns lists. * User pref for periods columns lists.
* *
* @param ArrayObject<string, mixed> $cols Columns * @param ArrayObject $cols Columns
*/ */
public static function adminColumnsListsV2(ArrayObject $cols): void public static function adminColumnsListsV2(ArrayObject $cols): void
{ {
@ -117,7 +112,7 @@ class BackendBehaviors
/** /**
* User pref periods filters options. * User pref periods filters options.
* *
* @param ArrayObject<string, mixed> $sorts Sort options * @param ArrayObject $sorts Sort options
*/ */
public static function adminFiltersListsV2(ArrayObject $sorts): void public static function adminFiltersListsV2(ArrayObject $sorts): void
{ {
@ -133,8 +128,8 @@ class BackendBehaviors
/** /**
* Add columns period to posts list header. * Add columns period to posts list header.
* *
* @param MetaRecord $rs Record instance * @param MetaRecord $rs record instance
* @param ArrayObject<string, mixed> $cols Columns * @param ArrayObject $cols Columns
*/ */
public static function adminPostListHeaderV2(MetaRecord $rs, ArrayObject $cols): void public static function adminPostListHeaderV2(MetaRecord $rs, ArrayObject $cols): void
{ {
@ -146,8 +141,8 @@ class BackendBehaviors
/** /**
* Add columns period to posts list values. * Add columns period to posts list values.
* *
* @param MetaRecord $rs Record instance * @param MetaRecord $rs record instance
* @param ArrayObject<string, mixed> $cols Columns * @param ArrayObject $cols Columns
*/ */
public static function adminPostListValueV2(MetaRecord $rs, ArrayObject $cols): void public static function adminPostListValueV2(MetaRecord $rs, ArrayObject $cols): void
{ {
@ -230,8 +225,8 @@ class BackendBehaviors
/** /**
* Posts actions callback to remove period. * Posts actions callback to remove period.
* *
* @param ActionsPosts $pa ActionsPosts instance * @param ActionsPosts $pa ActionsPosts instance
* @param ArrayObject<string, mixed> $post _POST actions * @param ArrayObject $post _POST actions
*/ */
public static function callbackRemove(ActionsPosts $pa, ArrayObject $post): void public static function callbackRemove(ActionsPosts $pa, ArrayObject $post): void
{ {
@ -251,7 +246,7 @@ class BackendBehaviors
// Remove linked period // Remove linked period
foreach ($posts_ids as $post_id) { foreach ($posts_ids as $post_id) {
self::delPeriod((int) $post_id); self::delPeriod($post_id);
} }
Notices::addSuccessNotice(__('Posts have been removed from periodical.')); Notices::addSuccessNotice(__('Posts have been removed from periodical.'));
@ -261,8 +256,8 @@ class BackendBehaviors
/** /**
* Posts actions callback to add period. * Posts actions callback to add period.
* *
* @param ActionsPosts $pa ActionsPosts instance * @param ActionsPosts $pa ActionsPosts instance
* @param ArrayObject<string, mixed> $post _POST actions * @param ArrayObject $post _POST actions
*/ */
public static function callbackAdd(ActionsPosts $pa, ArrayObject $post): void public static function callbackAdd(ActionsPosts $pa, ArrayObject $post): void
{ {
@ -277,8 +272,8 @@ class BackendBehaviors
// Save action // Save action
if (!empty($post['periodical'])) { if (!empty($post['periodical'])) {
foreach ($posts_ids as $post_id) { foreach ($posts_ids as $post_id) {
self::delPeriod((int) $post_id); self::delPeriod($post_id);
self::addPeriod((int) $post_id, (int) $post['periodical']); self::addPeriod($post_id, (int) $post['periodical']);
} }
Notices::addSuccessNotice(__('Posts have been added to periodical.')); Notices::addSuccessNotice(__('Posts have been added to periodical.'));
@ -314,9 +309,9 @@ class BackendBehaviors
/** /**
* Add form to post sidebar. * Add form to post sidebar.
* *
* @param ArrayObject<string, mixed> $main_items Main items * @param ArrayObject $main_items Main items
* @param ArrayObject<string, mixed> $sidebar_items Sidebar items * @param ArrayObject $sidebar_items Sidebar items
* @param null|MetaRecord $post Post record or null * @param null|MetaRecord $post Post record or null
*/ */
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, ?MetaRecord $post): void public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, ?MetaRecord $post): void
{ {
@ -370,7 +365,7 @@ class BackendBehaviors
/** /**
* Combo of available periods. * Combo of available periods.
* *
* @return array<string, int> List of period * @return array List of period
*/ */
private static function comboPeriod(): array private static function comboPeriod(): array
{ {

View File

@ -225,7 +225,7 @@ class ManagePeriod extends Process
(new Form('periodicalbhv'))->method('post')->action(App::backend()->getPageURL())->fields([ (new Form('periodicalbhv'))->method('post')->action(App::backend()->getPageURL())->fields([
(new Para())->items([ (new Para())->items([
(new Label(__('Title:')))->for('period_title'), (new Label(__('Title:')))->for('period_title'),
(new Input('period_title'))->size(65)->maxlength(255)->class('maximal')->value(Html::escapeHTML($vars->period_title)), (new Input('period_title'))->size(65)->maxlenght(255)->class('maximal')->value(Html::escapeHTML($vars->period_title)),
]), ]),
(new Div())->class('two-boxes')->items([ (new Div())->class('two-boxes')->items([
(new Div())->class('box odd')->items([ (new Div())->class('box odd')->items([

View File

@ -13,102 +13,46 @@ namespace Dotclear\Plugin\periodical;
*/ */
class ManageVars class ManageVars
{ {
/** /** @var ManageVars $container Self instance */
* Self instance.
*
* @var ManageVars $container
*/
private static $container; private static $container;
/** /** @var string $action The post form action */
* The post form action.
*
* @var string $action
*/
public readonly string $action; public readonly string $action;
/** /** @var string $redir The post form redirection */
* The post form redirection.
*
* @var string $redir
*/
public readonly string $redir; public readonly string $redir;
/** /** @var array $periods The post form periods */
* The post form periods.
*
* @var array<int, int> $periods
*/
public readonly array $periods; public readonly array $periods;
/** /** @var array $entries The post form entries */
* The post form entries.
*
* @var array<int, int> $entries
*/
public readonly array $entries; public readonly array $entries;
/** /** @var null|int $period_id The post form period id */
* The post form period id.
*
* @var null|int $period_id
*/
public readonly ?int $period_id; public readonly ?int $period_id;
/** /** @var string $period_title The psort form period title */
* The psort form period title.
*
* @var string $period_title
*/
public readonly string $period_title; public readonly string $period_title;
/** /** @var int $period_pub_nb The post form period publication number */
* The post form period publication number.
*
* @var int $period_pub_nb
*/
public readonly int $period_pub_nb; public readonly int $period_pub_nb;
/** /** @var string $period_pub_int The post form period publication interval */
* The post form period publication interval.
*
* @var string $period_pub_int
*/
public readonly string $period_pub_int; public readonly string $period_pub_int;
/** /** @var string $period_curdt The post form period current date */
* The post form period current date.
*
* @var string $period_curdt
*/
public readonly string $period_curdt; public readonly string $period_curdt;
/** /** @var string $period_curdt The post form period end date */
* The post form period end date.
*
* @var string $period_curdt
*/
public readonly string $period_enddt; public readonly string $period_enddt;
/** /** @var bool $bad_period_id Is period ID wrong */
* Is period ID wrong .
*
* @var bool $bad_period_id
*/
public readonly bool $bad_period_id; public readonly bool $bad_period_id;
/** /** @var bool $bad_period_curdt Is period current date wrong */
* Is period current date wrong.
*
* @var bool $bad_period_curdt
*/
public readonly bool $bad_period_curdt; public readonly bool $bad_period_curdt;
/** /** @var bool $bad_period_enddt Is period end date wrong */
* Is period end date wrong.
*
* @var bool $bad_period_enddt
*/
public readonly bool $bad_period_enddt; public readonly bool $bad_period_enddt;
/** /**

View File

@ -19,7 +19,6 @@ class My extends MyPlugin
public static function checkCustomContext(int $context): ?bool public static function checkCustomContext(int $context): ?bool
{ {
return match ($context) { return match ($context) {
// Add usage perm to backend
self::MANAGE, self::MENU => App::task()->checkContext('BACKEND') self::MANAGE, self::MENU => App::task()->checkContext('BACKEND')
&& App::auth()->check(App::auth()->makePermissions([ && App::auth()->check(App::auth()->makePermissions([
App::auth()::PERMISSION_USAGE, App::auth()::PERMISSION_USAGE,
@ -33,7 +32,7 @@ class My extends MyPlugin
/** /**
* Periods action combo. * Periods action combo.
* *
* @return array<string, string> * @return array<string,sting>
*/ */
public static function periodsActionCombo(): array public static function periodsActionCombo(): array
{ {
@ -46,7 +45,7 @@ class My extends MyPlugin
/** /**
* Period entries action combo. * Period entries action combo.
* *
* @return array<string, array<string, string>> * @return array<string,array{string,string}>
*/ */
public static function entriesActionsCombo(): array public static function entriesActionsCombo(): array
{ {
@ -64,7 +63,7 @@ class My extends MyPlugin
/** /**
* Periods sortby combo. * Periods sortby combo.
* *
* @return array<string, string> * @return array<string,string>
*/ */
public static function sortbyCombo(): array public static function sortbyCombo(): array
{ {
@ -78,7 +77,7 @@ class My extends MyPlugin
/** /**
* Period combo. * Period combo.
* *
* @return array<string, string> * @return array<string,string>
*/ */
public static function periodCombo(): array public static function periodCombo(): array
{ {

View File

@ -30,12 +30,8 @@ use Exception;
*/ */
class Utils class Utils
{ {
/** /** @var null|string $lock File lock for update */
* File lock for update. private static $lock = null;
*
* @var null|string $lock
*/
private static ?string $lock = null;
/** /**
* Get periodical table cursor. * Get periodical table cursor.
@ -50,9 +46,9 @@ class Utils
/** /**
* Get periods. * Get periods.
* *
* @param array<string, mixed>|ArrayObject<string, mixed> $params Parameters * @param array|ArrayObject $params Parameters
* @param bool $count_only Only counts results * @param bool $count_only Only counts results
* @param SelectStatement $ext_sql Optional SelectStatement instance * @param SelectStatement $ext_sql Optional SelectStatement instance
* *
* @return MetaRecord A record with some more capabilities * @return MetaRecord A record with some more capabilities
*/ */
@ -238,9 +234,9 @@ class Utils
/** /**
* Get posts related to periods. * Get posts related to periods.
* *
* @param array<string, mixed>|ArrayObject<string, mixed> $params Parameters * @param array|ArrayObject $params Parameters
* @param bool $count_only Only counts results * @param bool $count_only Only counts results
* @param SelectStatement $ext_sql Optional SelectStatement instance * @param SelectStatement $ext_sql Optional SelectStatement instance
* *
* @return MetaRecord A record with some more capabilities * @return MetaRecord A record with some more capabilities
*/ */
@ -308,7 +304,7 @@ class Utils
$sql->and('P.post_status = ' . App::blog()::POST_PENDING); $sql->and('P.post_status = ' . App::blog()::POST_PENDING);
} }
return App::blog()->getPosts($params, $count_only, $sql); return App::blog()->getPosts($params, $count_only, $sql) ?? MetaRecord::newFromArray([]);
} }
/** /**