Compare commits

..

No commits in common. "411ea6cbedfe47f881a675f6d6c6f15e635d3e58" and "a1470bd16f84df06472ec6352beacf3fb8cc4a83" have entirely different histories.

8 changed files with 39 additions and 52 deletions

View File

@ -1,10 +1,3 @@
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.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)
[![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)
[![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,7 +10,8 @@
_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.11.04',
'2023.10.19',
[
'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.11.04</version>
<version>2023.10.19</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.11.04/plugin-postExpired.zip</file>
<file>https://git.dotclear.watch/JcDenis/postExpired/releases/download/v2023.10.19/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,8 +81,8 @@ class BackendBehaviors
/**
* Add form to post sidebar.
*
* @param ArrayObject<string, mixed> $main_items Main items
* @param ArrayObject<string, mixed> $sidebar_items Sidebar items
* @param ArrayObject $main_items Main items
* @param ArrayObject $sidebar_items Sidebar items
* @param ?MetaRecord $post Post record or null
*/
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, ?MetaRecord $post): void
@ -139,7 +139,7 @@ class BackendBehaviors
* Posts actions callback to add expired date.
*
* @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
{
@ -161,8 +161,8 @@ class BackendBehaviors
)
) {
foreach ($posts_ids as $post_id) {
self::delPostExpired((int) $post_id);
self::setPostExpired((int) $post_id, $post);
self::delPostExpired($post_id);
self::setPostExpired($post_id, $post);
}
Notices::addSuccessNotice(__('Expired date added.'));
@ -203,7 +203,7 @@ class BackendBehaviors
* Posts actions callback to add expired date.
*
* @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
{
@ -215,7 +215,7 @@ class BackendBehaviors
// Delete expired date
foreach ($posts_ids as $post_id) {
self::delPostExpired((int) $post_id);
self::delPostExpired($post_id);
}
Notices::addSuccessNotice(__('Expired date deleted.'));
@ -236,7 +236,7 @@ class BackendBehaviors
* Save expired date.
*
* @param int $post_id Post id
* @param ArrayObject<string, mixed> $post _POST fields
* @param ArrayObject $post _POST fields
*/
private static function setPostExpired(int $post_id, ArrayObject $post): void
{
@ -286,8 +286,7 @@ class BackendBehaviors
* @param string $post_type Posts type
* @param null|int $post_id Post ID
* @param bool $render Render fileds to HTML
*
* @return array<string, string|Para> Array of object form fields
* @return array Array of object form fields
*/
private static function fieldsPostExpired(string $post_type, ?int $post_id = null, bool $render = true): array
{
@ -347,17 +346,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)->maxlength(255)->class('maximal')->value(empty($post_expired['newpassword']) ? '' : $post_expired['newpassword']),
(new Input('post_expired_newpassword'))->size(65)->maxlenght(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) {
if (!is_string($v)) {
$fields[$k] = $v->render();
}
}
}
return $fields;
}
@ -367,7 +364,7 @@ class BackendBehaviors
*
* @param MetaRecord $categories Categories recordset
*
* @return array<int|string, string|Option> Categorires combo
* @return array Categorires combo
*/
private static function categoriesCombo(MetaRecord $categories): array
{
@ -397,7 +394,7 @@ class BackendBehaviors
/**
* Custom status combo.
*
* @return array<string, string> Status combo
* @return array Status combo
*/
private static function statusCombo(): array
{
@ -412,7 +409,7 @@ class BackendBehaviors
/**
* Custom selection combo.
*
* @return array<string, string> Selection combo
* @return array Selection combo
*/
private static function selectedCombo(): array
{
@ -426,7 +423,7 @@ class BackendBehaviors
/**
* Custom comment status combo.
*
* @return array<string, string> Comment status combo
* @return array Comment status combo
*/
private static function commentCombo(): array
{
@ -440,7 +437,7 @@ class BackendBehaviors
/**
* Custom trackback status combo.
*
* @return array<string, string> Trackback status combo
* @return array Trackback status combo
*/
private static function trackbackCombo(): array
{

View File

@ -20,7 +20,7 @@ class FrontendTemplate
/**
* Template condition to check if there is an expired date.
*
* @param ArrayObject<string, mixed> $attr Block attributes
* @param ArrayObject $attr Block attributes
* @param string $content Block content
*
* @return string
@ -47,7 +47,7 @@ class FrontendTemplate
/**
* Template for expired date.
*
* @param ArrayObject<string, mixed> $attr Value attributes
* @param ArrayObject $attr Value attributes
*
* @return string
*/
@ -73,7 +73,7 @@ class FrontendTemplate
/**
* Template for expired time.
*
* @param ArrayObject<string, mixed> $attr Value attributes
* @param ArrayObject $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<string, string> $in Array of options
* @param array $in Array of options
*
* @return string "Serialized" options
*/
@ -43,14 +43,14 @@ class My extends MyPlugin
*
* @param string $in "Serialized" options
*
* @return array<string, string> Array of options
* @return array Array of options
*/
public static function decode(string $in): array
{
$out = [];
foreach (explode(';', $in) as $v) {
$v = explode('|', $v);
$out[(string) $v[0]] = (string) $v[1];
$out[$v[0]] = $v[1];
}
return $out;

View File

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