Compare commits

..

2 Commits

Author SHA1 Message Date
Jean-Christian Paul Denis 411ea6cbed
miss this one 2023-11-04 21:26:11 +01:00
Jean-Christian Paul Denis 02a44ac22a
code review 2023-11-04 21:22:19 +01:00
8 changed files with 52 additions and 39 deletions

View File

@ -1,3 +1,10 @@
postExpired 2023.11.04
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Fix typo
* Code review (phpstan)
postExpired 2023.10.19
===========================================================
* Require Dotclear 2.28

View File

@ -1,8 +1,8 @@
# README
[![Release](https://img.shields.io/badge/release-2023.08.13-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/postExpired/releases)
![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
[![Release](https://img.shields.io/badge/release-2023.11.04-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/postExpired/releases)
![Date](https://img.shields.io/badge/date-2023.11.04-c44d58.svg)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/postExpired)
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/postExpired/src/branch/master/LICENSE)
@ -10,8 +10,7 @@
_postExpired_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
> Add options to the sidebar of post edition page
to change some options of a post at a given time.
> Add options to the sidebar of post edition page to change some options of a post at a given time.
## REQUIREMENTS

View File

@ -18,7 +18,7 @@ $this->registerModule(
'Expired entries',
'Change entries options at a given date',
'Jean-Christian Denis and Contributors',
'2023.10.19',
'2023.11.04',
[
'requires' => [['core', '2.28']],
'permissions' => 'My',

View File

@ -2,10 +2,10 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="postExpired">
<name>Expired entries</name>
<version>2023.10.19</version>
<version>2023.11.04</version>
<author>Jean-Christian Denis and Contributors</author>
<desc>Change entries options at a given date</desc>
<file>https://git.dotclear.watch/JcDenis/postExpired/releases/download/v2023.10.19/plugin-postExpired.zip</file>
<file>https://git.dotclear.watch/JcDenis/postExpired/releases/download/v2023.11.04/plugin-postExpired.zip</file>
<da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/postExpired/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/postExpired/issues</da:support>

View File

@ -81,9 +81,9 @@ class BackendBehaviors
/**
* Add form to post sidebar.
*
* @param ArrayObject $main_items Main items
* @param ArrayObject $sidebar_items Sidebar items
* @param ?MetaRecord $post Post record or null
* @param ArrayObject<string, mixed> $main_items Main items
* @param ArrayObject<string, mixed> $sidebar_items Sidebar items
* @param ?MetaRecord $post Post record or null
*/
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, ?MetaRecord $post): void
{
@ -138,8 +138,8 @@ class BackendBehaviors
/**
* Posts actions callback to add expired date.
*
* @param ActionsPosts $pa ActionsPosts instance
* @param ArrayObject $post _POST actions
* @param ActionsPosts $pa ActionsPosts instance
* @param ArrayObject<string, mixed> $post _POST actions
*/
public static function callbackAdd(ActionsPosts $pa, ArrayObject $post): void
{
@ -161,8 +161,8 @@ class BackendBehaviors
)
) {
foreach ($posts_ids as $post_id) {
self::delPostExpired($post_id);
self::setPostExpired($post_id, $post);
self::delPostExpired((int) $post_id);
self::setPostExpired((int) $post_id, $post);
}
Notices::addSuccessNotice(__('Expired date added.'));
@ -202,8 +202,8 @@ class BackendBehaviors
/**
* Posts actions callback to add expired date.
*
* @param ActionsPosts $pa ActionsPosts instance
* @param ArrayObject $post _POST actions
* @param ActionsPosts $pa ActionsPosts instance
* @param ArrayObject<string, mixed> $post _POST actions
*/
public static function callbackRemove(ActionsPosts $pa, ArrayObject $post): void
{
@ -215,7 +215,7 @@ class BackendBehaviors
// Delete expired date
foreach ($posts_ids as $post_id) {
self::delPostExpired($post_id);
self::delPostExpired((int) $post_id);
}
Notices::addSuccessNotice(__('Expired date deleted.'));
@ -235,8 +235,8 @@ class BackendBehaviors
/**
* Save expired date.
*
* @param int $post_id Post id
* @param ArrayObject $post _POST fields
* @param int $post_id Post id
* @param ArrayObject<string, mixed> $post _POST fields
*/
private static function setPostExpired(int $post_id, ArrayObject $post): void
{
@ -286,7 +286,8 @@ class BackendBehaviors
* @param string $post_type Posts type
* @param null|int $post_id Post ID
* @param bool $render Render fileds to HTML
* @return array Array of object form fields
*
* @return array<string, string|Para> Array of object form fields
*/
private static function fieldsPostExpired(string $post_type, ?int $post_id = null, bool $render = true): array
{
@ -346,13 +347,15 @@ class BackendBehaviors
(new Checkbox('post_expired_password', !empty($post_expired['password'])))->value(1),
(new Label(__('Change password'), Label::OUTSIDE_LABEL_AFTER))->for('post_expired_password')->class('classic'),
(new Label(__('New password:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_newpassword'),
(new Input('post_expired_newpassword'))->size(65)->maxlenght(255)->class('maximal')->value(empty($post_expired['newpassword']) ? '' : $post_expired['newpassword']),
(new Input('post_expired_newpassword'))->size(65)->maxlength(255)->class('maximal')->value(empty($post_expired['newpassword']) ? '' : $post_expired['newpassword']),
(new Note())->text(__('Leave empty to remove it'))->class('form-note'),
]);
if ($render) {
foreach ($fields as $k => $v) {
$fields[$k] = $v->render();
if (!is_string($v)) {
$fields[$k] = $v->render();
}
}
}
@ -364,7 +367,7 @@ class BackendBehaviors
*
* @param MetaRecord $categories Categories recordset
*
* @return array Categorires combo
* @return array<int|string, string|Option> Categorires combo
*/
private static function categoriesCombo(MetaRecord $categories): array
{
@ -394,7 +397,7 @@ class BackendBehaviors
/**
* Custom status combo.
*
* @return array Status combo
* @return array<string, string> Status combo
*/
private static function statusCombo(): array
{
@ -409,7 +412,7 @@ class BackendBehaviors
/**
* Custom selection combo.
*
* @return array Selection combo
* @return array<string, string> Selection combo
*/
private static function selectedCombo(): array
{
@ -423,7 +426,7 @@ class BackendBehaviors
/**
* Custom comment status combo.
*
* @return array Comment status combo
* @return array<string, string> Comment status combo
*/
private static function commentCombo(): array
{
@ -437,7 +440,7 @@ class BackendBehaviors
/**
* Custom trackback status combo.
*
* @return array Trackback status combo
* @return array<string, string> Trackback status combo
*/
private static function trackbackCombo(): array
{

View File

@ -20,8 +20,8 @@ class FrontendTemplate
/**
* Template condition to check if there is an expired date.
*
* @param ArrayObject $attr Block attributes
* @param string $content Block content
* @param ArrayObject<string, mixed> $attr Block attributes
* @param string $content Block content
*
* @return string
*/
@ -47,7 +47,7 @@ class FrontendTemplate
/**
* Template for expired date.
*
* @param ArrayObject $attr Value attributes
* @param ArrayObject<string, mixed> $attr Value attributes
*
* @return string
*/
@ -73,7 +73,7 @@ class FrontendTemplate
/**
* Template for expired time.
*
* @param ArrayObject $attr Value attributes
* @param ArrayObject<string, mixed> $attr Value attributes
*
* @return string
*/

View File

@ -24,7 +24,7 @@ class My extends MyPlugin
* This is saved into post_meta as meta_id value,
* so this must be less than 255 caracters.
*
* @param array $in Array of options
* @param array<string, string> $in Array of options
*
* @return string "Serialized" options
*/
@ -43,14 +43,14 @@ class My extends MyPlugin
*
* @param string $in "Serialized" options
*
* @return array Array of options
* @return array<string, string> Array of options
*/
public static function decode(string $in): array
{
$out = [];
foreach (explode(';', $in) as $v) {
$v = explode('|', $v);
$out[$v[0]] = $v[1];
$v = explode('|', $v);
$out[(string) $v[0]] = (string) $v[1];
}
return $out;

View File

@ -17,7 +17,11 @@ use Dotclear\Schema\Extension\Post;
*/
class rsExtPostExpired extends Post
{
/** @var array $memory Memory to prevent redondant call */
/**
* Memory to prevent redondant call.
*
* @var array<string, string> $memory
*/
protected static array $memory = [];
/**
@ -40,8 +44,8 @@ class rsExtPostExpired extends Post
return '';
}
$v = My::decode($rs_date->f('meta_id'));
static::$memory[$rs->f('post_id')] = $v['date'];
$v = My::decode($rs_date->f('meta_id'));
static::$memory[(string) $rs->f('post_id')] = (string) $v['date'];
}
return static::$memory[$rs->f('post_id')];