release 2022.11.20

This commit is contained in:
Jean-Christian Paul Denis 2022-11-20 21:43:32 +01:00
parent 947b0cf339
commit beb6a186d1
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
9 changed files with 195 additions and 266 deletions

View File

@ -1,5 +1,6 @@
2022.04.27.1 - dev
- [ ] fix wrong timezone on admin vs public expired date
2022.11.20
- fix compatibility with Dotclear 2.24 (required)
- fix wrong timezone on admin vs public expired date
2022.04.27
- require Dotclear 2.21.3

View File

@ -3,11 +3,10 @@
[![Release](https://img.shields.io/github/v/release/JcDenis/postExpired)](https://github.com/JcDenis/postExpired/releases)
[![Date](https://img.shields.io/github/release-date/JcDenis/postExpired)](https://github.com/JcDenis/postExpired/releases)
[![Issues](https://img.shields.io/github/issues/JcDenis/postExpired)](https://github.com/JcDenis/postExpired/issues)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.20-blue.svg)](https://fr.dotclear.org/download)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.24-blue.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/postExpired)
[![License](https://img.shields.io/github/license/JcDenis/postExpired)](https://github.com/JcDenis/postExpired/blob/master/LICENSE)
## WHAT IS POSTEXPIRED ?
Post expired is a plugin for the open-source
@ -21,7 +20,7 @@ to change some options of a post at a given time.
postExpired requires:
* contentadmin permissions
* Dotclear 2.21.3
* Dotclear 2.24
## USAGE

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
@ -93,21 +92,21 @@ class adminBehaviorPostExpired
public static function adminPostsActions(dcPostsActions $pa)
{
$pa->addAction(
array(
__('Expired entries') => array(
__('Add expired date') => 'post_expired_add'
)
),
array('adminBehaviorPostExpired', 'callbackAdd')
[
__('Expired entries') => [
__('Add expired date') => 'post_expired_add',
],
],
['adminBehaviorPostExpired', 'callbackAdd']
);
$pa->addAction(
array(
__('Expired entries') => array(
__('Remove expired date') => 'post_expired_remove'
)
),
array('adminBehaviorPostExpired', 'callbackRemove')
[
__('Expired entries') => [
__('Remove expired date') => 'post_expired_remove',
],
],
['adminBehaviorPostExpired', 'callbackRemove']
);
}
@ -134,13 +133,13 @@ class adminBehaviorPostExpired
return null;
}
$sidebar_items['post_expired'] = array(
$sidebar_items['post_expired'] = [
'title' => __('Expired date'),
'items' => self::fieldsPostExpired(
$post->post_type,
$post->post_id
)
);
),
];
}
/**
@ -208,11 +207,11 @@ class adminBehaviorPostExpired
$posts = $pa->getRS();
$pa->beginPage(
dcPage::breadcrumb(array(
dcPage::breadcrumb([
html::escapeHTML(dcCore::app()->blog->name) => '',
$pa->getCallerTitle() => $pa->getRedirection(true),
__('Add expired date to this selection') => ''
)),
__('Add expired date to this selection') => '',
]),
//dcPage::jsDatePicker() .
self::adminPostHeaders()
);
@ -225,7 +224,7 @@ class adminBehaviorPostExpired
dcCore::app()->formNonce() .
$pa->getHiddenFields() .
form::hidden(array('action'), 'post_expired_add') .
form::hidden(['action'], 'post_expired_add') .
'<input type="submit" value="' . __('Save') . '" /></p>' .
'</form>';
@ -274,7 +273,7 @@ class adminBehaviorPostExpired
*/
protected static function setPostExpired($post_id, $post)
{
$post_expired = array(
$post_expired = [
'status' => '',
'category' => '',
'selected' => '',
@ -283,28 +282,23 @@ class adminBehaviorPostExpired
'date' => date(
'Y-m-d H:i:00',
strtotime($post['post_expired_date'])
)
);
),
];
if (!empty($post['post_expired_status'])) {
$post_expired['status'] =
(string) $post['post_expired_status'];
$post_expired['status'] = (string) $post['post_expired_status'];
}
if (!empty($post['post_expired_category'])) {
$post_expired['category'] =
(string) $post['post_expired_category'];
$post_expired['category'] = (string) $post['post_expired_category'];
}
if (!empty($post['post_expired_selected'])) {
$post_expired['selected'] =
(string) $post['post_expired_selected'];
$post_expired['selected'] = (string) $post['post_expired_selected'];
}
if (!empty($post['post_expired_comment'])) {
$post_expired['comment'] =
(string) $post['post_expired_comment'];
$post_expired['comment'] = (string) $post['post_expired_comment'];
}
if (!empty($post['post_expired_trackback'])) {
$post_expired['trackback'] =
(string) $post['post_expired_trackback'];
$post_expired['trackback'] = (string) $post['post_expired_trackback'];
}
dcCore::app()->meta->setPostMeta(
@ -322,14 +316,13 @@ class adminBehaviorPostExpired
*/
protected static function fieldsPostExpired($post_type, $post_id = null)
{
$fields = $post_expired = array();
$fields = $post_expired = [];
if ($post_id) {
$rs = dcCore::app()->meta->getMetadata([
'meta_type' => 'post_expired',
'post_id' => $post_id,
'limit' => 1
'limit' => 1,
]);
if (!$rs->isEmpty()) {
@ -337,8 +330,7 @@ class adminBehaviorPostExpired
}
}
$fields['post_expired_date'] =
'<p><label for="post_expired_date">' .
$fields['post_expired_date'] = '<p><label for="post_expired_date">' .
__('Date:') . '</label>' .
form::datetime('post_expired_date', [
'default' => html::escapeHTML(dt::str('%Y-%m-%dT%H:%M', strtotime($post_expired['date'] ?? 0))),
@ -346,8 +338,7 @@ class adminBehaviorPostExpired
])
. '</p>';
$fields['post_expired_status'] =
'<h5>' . __('On this date, change:') . '</h5>' .
$fields['post_expired_status'] = '<h5>' . __('On this date, change:') . '</h5>' .
'<p><label for="post_expired_status">' .
__('Status:') . '</label>' .
form::combo(
@ -358,23 +349,20 @@ class adminBehaviorPostExpired
) . '</p>';
if ($post_type == 'post') {
$fields['post_expired_category'] =
'<p><label for="post_expired_category">' .
$fields['post_expired_category'] = '<p><label for="post_expired_category">' .
__('Category:') . '</label>' .
form::combo(
'post_expired_category',
self::categoriesCombo(
dcCore::app()->blog->getCategories(
array('post_type' => 'post')
['post_type' => 'post']
)
),
empty($post_expired['category']) ?
'' : $post_expired['category']
) . '</p>';
$fields['post_expired_selected'] =
'<p><label for="post_expired_selected">' .
$fields['post_expired_selected'] = '<p><label for="post_expired_selected">' .
__('Selection:') . '</label>' .
form::combo(
'post_expired_selected',
@ -384,8 +372,7 @@ class adminBehaviorPostExpired
) . '</p>';
}
$fields['post_expired_comment'] =
'<p><label for="post_expired_comment">' .
$fields['post_expired_comment'] = '<p><label for="post_expired_comment">' .
__('Comments status:') . '</label>' .
form::combo(
'post_expired_comment',
@ -394,8 +381,7 @@ class adminBehaviorPostExpired
'' : $post_expired['comment']
) . '</p>';
$fields['post_expired_trackback'] =
'<p><label for="post_expired_trackback">' .
$fields['post_expired_trackback'] = '<p><label for="post_expired_trackback">' .
__('Trackbacks status:') . '</label>' .
form::combo(
'post_expired_trackback',
@ -416,13 +402,14 @@ class adminBehaviorPostExpired
protected static function categoriesCombo(dcRecord $categories)
{
# Getting categories
$categories_combo = array(
$categories_combo = [
__('Not changed') => '',
__('Uncategorized') => '!'
);
__('Uncategorized') => '!',
];
try {
$categories = dcCore::app()->blog->getCategories(
array('post_type' => 'post')
['post_type' => 'post']
);
while ($categories->fetch()) {
$categories_combo[] = new formSelectOption(
@ -431,7 +418,7 @@ class adminBehaviorPostExpired
);
}
} catch (Exception $e) {
return array();
return [];
}
return $categories_combo;
@ -444,12 +431,12 @@ class adminBehaviorPostExpired
*/
protected static function statusCombo()
{
return array(
return [
__('Not changed') => '',
__('Published') => '!1',
__('Pending') => '!-2',
__('Unpublished') => '!0'
);
__('Unpublished') => '!0',
];
}
/**
@ -459,11 +446,11 @@ class adminBehaviorPostExpired
*/
protected static function selectedCombo()
{
return array(
return [
__('Not changed') => '',
__('Selected') => '!1',
__('Not selected') => '!0'
);
__('Not selected') => '!0',
];
}
/**
@ -473,11 +460,11 @@ class adminBehaviorPostExpired
*/
protected static function commentCombo()
{
return array(
return [
__('Not changed') => '',
__('Opened') => '!1',
__('Closed') => '!0'
);
__('Closed') => '!0',
];
}
/**
@ -487,10 +474,10 @@ class adminBehaviorPostExpired
*/
protected static function trackbackCombo()
{
return array(
return [
__('Not changed') => '',
__('Opened') => '!1',
__('Closed') => '!0'
);
__('Closed') => '!0',
];
}
}

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
@ -29,6 +28,6 @@ $this->registerModule(
'type' => 'plugin',
'support' => 'https://github.com/JcDenis/postExpired',
'details' => 'https://plugins.dotaddict.org/dc2/details/postExpired',
'repository' => 'https://raw.githubusercontent.com/JcDenis/postExpired/master/dcstore.xml'
'repository' => 'https://raw.githubusercontent.com/JcDenis/postExpired/master/dcstore.xml',
]
);

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
@ -34,7 +33,9 @@ try {
if (!method_exists('dcUtils', 'versionsCompare')
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
throw new Exception(sprintf(
'%s requires Dotclear %s', $mod_id, $dc_min
'%s requires Dotclear %s',
$mod_id,
$dc_min
));
}

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
@ -26,7 +25,7 @@ if (!defined('DC_RC_PATH')) {
*/
function encodePostExpired($in)
{
$out = array();
$out = [];
foreach ($in as $k => $v) {
$out[] = $k . '|' . $v;
}
@ -42,7 +41,7 @@ function encodePostExpired($in)
*/
function decodePostExpired($in)
{
$out = array();
$out = [];
foreach (explode(';', $in) as $v) {
$v = explode('|', $v);
$out[$v[0]] = $v[1];

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
@ -23,7 +22,7 @@ __('Expired on');
__('This entry has no expiration date');
# launch update only on public home page and feed
if (in_array(dcCore::app()->url->type, array('default', 'feed'))) {
if (in_array(dcCore::app()->url->type, ['default', 'feed'])) {
dcCore::app()->addBehavior(
'publicBeforeDocumentV2',
['publicBehaviorPostExpired', 'publicBeforeDocument']
@ -55,7 +54,6 @@ class publicBehaviorPostExpired
{
/**
* Check if there are expired dates
*
*/
public static function publicBeforeDocument()
{
@ -85,7 +83,6 @@ class publicBehaviorPostExpired
# Loop through marked posts
$updated = false;
while ($posts->fetch()) {
# Decode meta record
$post_expired = decodePostExpired($posts->meta_id);
@ -95,7 +92,7 @@ class publicBehaviorPostExpired
if ($now_tz > $meta_tz) {
# Delete meta for expired date
dcCore::app()->auth->sudo(
array(dcCore::app()->meta, 'delPostMeta'),
[dcCore::app()->meta, 'delPostMeta'],
$posts->post_id,
'post_expired'
);
@ -111,29 +108,33 @@ class publicBehaviorPostExpired
}
# values are prefixed by "!"
$v = (integer) substr($v, 1);
$v = (int) substr($v, 1);
# Put value in post cursor
switch($k)
{
switch($k) {
case 'status':
$post_cur->post_status = $v;
break;
case 'category':
$post_cur->cat_id = $v ? $v : null;
break;
case 'selected':
$post_cur->post_selected = $v;
break;
case 'comment':
$post_cur->post_open_comment = $v;
break;
case 'trackback':
$post_cur->post_open_tb = $v;
break;
}
}
@ -184,7 +185,7 @@ class rsExtPostExpiredPublic extends rsExtPost
$rs_date = $rs->core->meta->getMetadata([
'meta_type' => 'post_expired',
'post_id' => $rs->post_id,
'limit'=> 1
'limit' => 1,
]);
if ($rs_date->isEmpty()) {
@ -214,19 +215,19 @@ class tplPostExpired
*/
public static function EntryExpiredIf($attr, $content)
{
$if = array();
$if = [];
$operator = isset($attr['operator']) ?
self::getOperator($attr['operator']) : '&&';
if (isset($attr['has_date'])) {
$sign = (boolean) $attr['has_date'] ? '!' : '=';
$sign = (bool) $attr['has_date'] ? '!' : '=';
$if[] = '(null ' . $sign . '== dcCore::app()->ctx->posts->postExpiredDate())';
} else {
$if[] = '(null !== dcCore::app()->ctx->posts->postExpiredDate())';
}
return
"<?php if(" . implode(' ' . $operator . ' ', $if) . ") : ?>\n" .
'<?php if(' . implode(' ' . $operator . ' ', $if) . ") : ?>\n" .
$content .
"<?php endif; ?>\n";
}
@ -243,13 +244,13 @@ class tplPostExpired
$f = dcCore::app()->tpl->getFilters($attr);
if (!empty($attr['rfc822'])) {
$res = sprintf($f, "dt::rfc822(strtotime(dcCore::app()->ctx->posts->postExpiredDate()),dcCore::app()->ctx->posts->post_tz)");
$res = sprintf($f, 'dt::rfc822(strtotime(dcCore::app()->ctx->posts->postExpiredDate()),dcCore::app()->ctx->posts->post_tz)');
} elseif (!empty($attr['iso8601'])) {
$res = sprintf($f, "dt::iso8601(strtotime(dcCore::app()->ctx->posts->postExpiredDate(),dcCore::app()->ctx->posts->post_tz)");
$res = sprintf($f, 'dt::iso8601(strtotime(dcCore::app()->ctx->posts->postExpiredDate(),dcCore::app()->ctx->posts->post_tz)');
} elseif ($format) {
$res = sprintf($f, "dt::dt2str('" . $format . "',dcCore::app()->ctx->posts->postExpiredDate())");
} else {
$res = sprintf($f, "dt::dt2str(dcCore::app()->blog->settings->system->date_format,dcCore::app()->ctx->posts->postExpiredDate())");
$res = sprintf($f, 'dt::dt2str(dcCore::app()->blog->settings->system->date_format,dcCore::app()->ctx->posts->postExpiredDate())');
}
return '<?php if (null !== dcCore::app()->ctx->posts->postExpiredDate()) { echo ' . $res . '; } ?>';
@ -264,10 +265,12 @@ class tplPostExpired
{
return
'<?php if (null !== dcCore::app()->ctx->posts->postExpiredDate()) { echo ' . sprintf(
dcCore::app()->tpl->getFilters($attr), "dt::dt2str(" .
(!empty($attr['format']) ?
"'" . addslashes($attr['format']) . "'" : "dcCore::app()->blog->settings->system->time_format"
) . ",dcCore::app()->ctx->posts->postExpiredDate())"
dcCore::app()->tpl->getFilters($attr),
'dt::dt2str(' .
(
!empty($attr['format']) ?
"'" . addslashes($attr['format']) . "'" : 'dcCore::app()->blog->settings->system->time_format'
) . ',dcCore::app()->ctx->posts->postExpiredDate())'
) . '; } ?>';
}
@ -278,8 +281,7 @@ class tplPostExpired
*/
protected static function getOperator($op)
{
switch (strtolower($op))
{
switch (strtolower($op)) {
case 'or':
case '||':
return '||';

View File

@ -1,11 +1,12 @@
<?xml version="1.0"?>
<modules xmlns:da="http://dotaddict.org/da/">
<module id="postExpired">
<name>Billets périmés</name>
<version>2022.04.27</version>
<name>Expired entries</name>
<version>2022.11.12</version>
<author>Jean-Christian Denis and Contributors</author>
<desc>Change entries options at a given date</desc>
<file>https://github.com/JcDenis/postExpired/releases/download/v2022.04.27/plugin-postExpired.zip</file>
<da:dcmin>2.121</da:dcmin>
<file>https://github.com/JcDenis/postExpired/releases/download/v2022.11.12/plugin-postExpired.zip</file>
<da:dcmin>2.24</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/postExpired</da:details>
<da:support>https://github.com/JcDenis/postExpired</da:support>
</module>

View File

@ -1,60 +0,0 @@
<?php
// Language: Français
// Module: postExpired - 2013.11.03
// Date: 2013-11-03 22:12:31
// Translated with dcTranslater - 2013.05.11
#_admin.php:100
#_admin.php:110
$GLOBALS['__l10n']['Expired entries'] = 'Billets périmés';
#_admin.php:101
$GLOBALS['__l10n']['Add expired date'] = 'Ajouter une date de péremption';
#_admin.php:111
$GLOBALS['__l10n']['Remove expired date'] = 'Retirer une date de péremption';
#_admin.php:139
$GLOBALS['__l10n']['Expired date'] = 'Date de péremption';
#_admin.php:209
$GLOBALS['__l10n']['Expired date added.'] = 'Date de péremption ajoutée.';
#_admin.php:222
$GLOBALS['__l10n']['Add expired date to this selection'] = 'Ajouter une date de péremtion à cette sélection';
#_admin.php:269
$GLOBALS['__l10n']['Expired date deleted.'] = 'Dtae de péremtion supprimé';
#_admin.php:370
$GLOBALS['__l10n']['On this date, change:'] = 'Á cette date, changer :';
#_admin.php:398
$GLOBALS['__l10n']['Selection:'] = 'Séléction :';
#_admin.php:409
$GLOBALS['__l10n']['Comments status:'] = 'Status des commentaires :';
#_admin.php:419
$GLOBALS['__l10n']['Trackbacks status:'] = 'Status des rétroliens :';
#_admin.php:440
#_admin.php:470
#_admin.php:485
#_admin.php:499
#_admin.php:513
$GLOBALS['__l10n']['Not changed'] = 'Inchangé';
#_admin.php:500
#_admin.php:514
$GLOBALS['__l10n']['Opened'] = 'Ouvert';
#_admin.php:501
#_admin.php:515
$GLOBALS['__l10n']['Closed'] = 'Fermé';
#_public.php:25
$GLOBALS['__l10n']['Expired on'] = 'Expire le';
#_public.php:26
$GLOBALS['__l10n']['This entry has no expiration date'] = 'Ce billet n\'a pas de date de péremption';