Compare commits

..

No commits in common. "fb9958fdcc1d5eb50b3904f2ab07329f5b31943d" and "a5384aaea6ff488fe29cdf9f8874a54a08e52963" have entirely different histories.

13 changed files with 195 additions and 178 deletions

View File

@ -1,26 +1,3 @@
2023.07.30
- require Dotclear 2.27
- require PHP 7.4+
- update to Dotclear 2.27-dev
2023.05.21
- require dotclear 2.26
- fix sidebar menu toggle
- add ability to change password
2023.05.13
- require dotclear 2.26
- fix sql statement
- fix backend js
- cleanup for dotclear 2.26 stable
2023.04.23
- require dotclear 2.26
- use latest dotclear namespace
- use sql statement
- fix nullsafe warnings
- add some inline code doc
2023.03.21
- require dotclear 2.25
- use namespace

View File

@ -3,7 +3,7 @@
[![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.27-blue.svg)](https://fr.dotclear.org/download)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.25-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)
@ -20,8 +20,7 @@ to change some options of a post at a given time.
postExpired requires:
* contentadmin permissions
* Dotclear 2.27
* PHP 7.4+
* Dotclear 2.25
## USAGE

View File

@ -18,12 +18,12 @@ $this->registerModule(
'Expired entries',
'Change entries options at a given date',
'Jean-Christian Denis and Contributors',
'2023.07.30',
'2023.03.21',
[
'requires' => [['core', '2.27']],
'requires' => [['core', '2.25']],
'permissions' => dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_USAGE,
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
dcAuth::PERMISSION_USAGE,
dcAuth::PERMISSION_CONTENT_ADMIN,
]),
'type' => 'plugin',
'support' => 'https://github.com/JcDenis/' . basename(__DIR__),

View File

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="postExpired">
<name>Expired entries</name>
<version>2023.07.30</version>
<version>2023.03.21</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/v2023.07.30/plugin-postExpired.zip</file>
<da:dcmin>2.27</da:dcmin>
<file>https://github.com/JcDenis/postExpired/releases/download/v2023.03.21/plugin-postExpired.zip</file>
<da:dcmin>2.25</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,17 +1,25 @@
/*global $, dotclear, datePicker */
'use strict';
/* -- BEGIN LICENSE BLOCK ----------------------------------
*
* This file is part of postExpired, a plugin for Dotclear 2.
*
* Copyright (c) 2009-2013 Jean-Christian Denis and contributors
* contact@jcdenis.fr http://jcd.lv
*
* Licensed under the GPL version 2.0 license.
* A copy of this license is available in LICENSE file or at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* -- END LICENSE BLOCK ------------------------------------*/
$(() => {
if (typeof datePicker === 'function') {
$(function(){
var post_pe_field=document.getElementById('post_expired_date');
if(post_pe_field!=undefined){
var post_pe_dtPick=new datePicker(post_pe_field);
post_pe_dtPick.img_top='1.5em';
post_pe_dtPick.draw();
}
}
$('#post_expired h4').toggleWithLegend(
$('#post_expired').children().not('h4'),
{user_pref:'dcx_postexpired_admin_form_sidebar',legend_click:true}
{cookie:'dcx_postexpired_admin_form_sidebar',legend_click:true}
);
});

View File

@ -9,21 +9,19 @@
# DOT NOT MODIFY THIS FILE !
#
use Dotclear\Helper\L10n;
L10n::$locales['Expired entries'] = 'Billets périmés';
L10n::$locales['Add expired date'] = 'Ajouter une date de péremption';
L10n::$locales['Remove expired date'] = 'Retirer une date de péremption';
L10n::$locales['Expired date'] = 'Date de péremption';
L10n::$locales['Expired date added.'] = 'Date de péremption ajoutée.';
L10n::$locales['Add expired date to this selection'] = 'Ajouter une date de péremtion à cette sélection';
L10n::$locales['Expired date deleted.'] = 'Dtae de péremtion supprimé';
L10n::$locales['On this date, change:'] = 'Á cette date, changer :';
L10n::$locales['Selection:'] = 'Séléction :';
L10n::$locales['Comments status:'] = 'Status des commentaires :';
L10n::$locales['Trackbacks status:'] = 'Status des rétroliens :';
L10n::$locales['Change password'] = 'Modifier le mot de passe';
L10n::$locales['Leave empty to remove it'] = 'Laisser vide pour le supprimer';
L10n::$locales['Not changed'] = 'Inchangé';
L10n::$locales['Expired on'] = 'Expire le';
L10n::$locales['This entry has no expiration date'] = 'Ce billet n\'a pas de date de péremption';
l10n::$locales['Expired entries'] = 'Billets périmés';
l10n::$locales['Add expired date'] = 'Ajouter une date de péremption';
l10n::$locales['Remove expired date'] = 'Retirer une date de péremption';
l10n::$locales['Expired date'] = 'Date de péremption';
l10n::$locales['Expired date added.'] = 'Date de péremption ajoutée.';
l10n::$locales['Add expired date to this selection'] = 'Ajouter une date de péremtion à cette sélection';
l10n::$locales['Expired date deleted.'] = 'Dtae de péremtion supprimé';
l10n::$locales['On this date, change:'] = 'Á cette date, changer :';
l10n::$locales['Selection:'] = 'Séléction :';
l10n::$locales['Comments status:'] = 'Status des commentaires :';
l10n::$locales['Trackbacks status:'] = 'Status des rétroliens :';
l10n::$locales['Not changed'] = 'Inchangé';
l10n::$locales['Opened'] = 'Ouvert';
l10n::$locales['Closed'] = 'Fermé';
l10n::$locales['Expired on'] = 'Expire le';
l10n::$locales['This entry has no expiration date'] = 'Ce billet n\'a pas de date de péremption';

View File

@ -1,60 +1,87 @@
# Language: Français
# Module: postExpired - 2013.11.03
# Date: 2013-11-03 22:12:31
# Translated with translater 2013.05.11
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: postExpired 2023.05.21\n"
"Project-Id-Version: postExpired 2013.11.03\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2023-05-21T13:03:45+00:00\n"
"PO-Revision-Date: 2013-11-03T22:12:31+00:00\n"
"Last-Translator: Jean-Christian Denis\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: _admin.php:100
#: _admin.php:110
msgid "Expired entries"
msgstr "Billets périmés"
#: _admin.php:101
msgid "Add expired date"
msgstr "Ajouter une date de péremption"
#: _admin.php:111
msgid "Remove expired date"
msgstr "Retirer une date de péremption"
#: _admin.php:139
msgid "Expired date"
msgstr "Date de péremption"
#: _admin.php:209
msgid "Expired date added."
msgstr "Date de péremption ajoutée."
#: _admin.php:222
msgid "Add expired date to this selection"
msgstr "Ajouter une date de péremtion à cette sélection"
#: _admin.php:269
msgid "Expired date deleted."
msgstr "Dtae de péremtion supprimé"
#: _admin.php:370
msgid "On this date, change:"
msgstr "Á cette date, changer :"
#: _admin.php:398
msgid "Selection:"
msgstr "Séléction :"
#: _admin.php:409
msgid "Comments status:"
msgstr "Status des commentaires :"
#: _admin.php:419
msgid "Trackbacks status:"
msgstr "Status des rétroliens :"
msgid "Change password"
msgstr "Modifier le mot de passe"
msgid "Leave empty to remove it"
msgstr "Laisser vide pour le supprimer"
#: _admin.php:440
#: _admin.php:470
#: _admin.php:485
#: _admin.php:499
#: _admin.php:513
msgid "Not changed"
msgstr "Inchangé"
#: _admin.php:500
#: _admin.php:514
msgid "Opened"
msgstr "Ouvert"
#: _admin.php:501
#: _admin.php:515
msgid "Closed"
msgstr "Fermé"
#: _public.php:25
msgid "Expired on"
msgstr "Expire le"
#: _public.php:26
msgid "This entry has no expiration date"
msgstr "Ce billet n'a pas de date de péremption"

View File

@ -15,18 +15,28 @@ declare(strict_types=1);
namespace Dotclear\Plugin\postExpired;
use dcCore;
use Dotclear\Core\Process;
use dcNsProcess;
class Backend extends Process
class Backend extends dcNsProcess
{
public static function init(): bool
{
return self::status(My::checkContext(My::BACKEND));
static::$init = defined('DC_CONTEXT_ADMIN')
&& !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog)
&& dcCore::app()->auth->check(
dcCore::app()->auth->makePermissions(
[
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN]
),
dcCore::app()->blog->id
);
return static::$init;
}
public static function process(): bool
{
if (!self::status()) {
if (!static::$init) {
return false;
}

View File

@ -17,23 +17,17 @@ namespace Dotclear\Plugin\postExpired;
use ArrayObject;
use DateTimeZone;
use dcCore;
use Dotclear\Core\Backend\Action\ActionsPosts;
use Dotclear\Core\Backend\{
Notices,
Page
};
use dcPostsActions;
use dcPage;
use Dotclear\Database\{
Cursor,
MetaRecord
};
use Dotclear\Helper\Html\Form\{
Checkbox,
Datetime,
Form,
Hidden,
Input,
Label,
Note,
Option,
Para,
Text,
@ -53,9 +47,9 @@ class BackendBehaviors
/**
* Add actions to posts page combo.
*
* @param ActionsPosts $pa ActionsPosts instance
* @param dcPostsActions $pa dcPostsActions instance
*/
public static function adminPostsActions(ActionsPosts $pa): void
public static function adminPostsActions(dcPostsActions $pa): void
{
$pa->addAction(
[
@ -83,7 +77,7 @@ class BackendBehaviors
*/
public static function adminPostHeaders(): string
{
return My::jsLoad('backend');
return dcPage::jsModuleLoad(My::id() . '/js/backend.js');
}
/**
@ -130,15 +124,11 @@ class BackendBehaviors
self::delPostExpired($post_id);
if (!empty($_POST['post_expired_date'])
&& (
!empty($_POST['post_expired_status'])
&& (!empty($_POST['post_expired_status'])
|| !empty($_POST['post_expired_category'])
|| !empty($_POST['post_expired_selected'])
|| !empty($_POST['post_expired_comment'])
|| !empty($_POST['post_expired_trackback'])
|| !empty($_POST['post_expired_password'])
)
) {
|| !empty($_POST['post_expired_trackback']))) {
self::setPostExpired($post_id, new ArrayObject($_POST));
}
}
@ -146,34 +136,35 @@ class BackendBehaviors
/**
* Posts actions callback to add expired date.
*
* @param ActionsPosts $pa ActionsPosts instance
* @param dcPostsActions $pa dcPostsActions instance
* @param ArrayObject $post _POST actions
*/
public static function callbackAdd(ActionsPosts $pa, ArrayObject $post): void
public static function callbackAdd(dcPostsActions $pa, ArrayObject $post): void
{
// nullsafe
if (is_null(dcCore::app()->blog)) {
return;
}
// No entry
$posts_ids = $pa->getIDs();
if (empty($posts_ids)) {
throw new Exception(__('No entry selected'));
}
// Add expired date
// Add epired date
if (!empty($post['post_expired_date'])
&& (
!empty($post['post_expired_status'])
&& (!empty($post['post_expired_status'])
|| !empty($post['post_expired_category'])
|| !empty($post['post_expired_selected'])
|| !empty($post['post_expired_comment'])
|| !empty($post['post_expired_trackback'])
|| !empty($post['post_expired_password'])
)
) {
|| !empty($post['post_expired_trackback']))) {
foreach ($posts_ids as $post_id) {
self::delPostExpired($post_id);
self::setPostExpired($post_id, $post);
}
Notices::addSuccessNotice(__('Expired date added.'));
dcPage::addSuccessNotice(__('Expired date added.'));
$pa->redirect(true);
// Display form
@ -182,25 +173,27 @@ class BackendBehaviors
$posts = $pa->getRS();
$pa->beginPage(
Page::breadcrumb([
dcPage::breadcrumb([
Html::escapeHTML(dcCore::app()->blog->name) => '',
$pa->getCallerTitle() => $pa->getRedirection(true),
__('Add expired date to this selection') => '',
]),
//Page::jsDatePicker() .
//dcPage::jsDatePicker() .
self::adminPostHeaders()
);
echo
(new Form('peadd'))->method('post')->action($pa->getURI())->fields([
(new Text('', $pa->getCheckboxes())),
(new Para())->items([
... self::fieldsPostExpired($posts->f('post_type'), null, false),
... $pa->hiddenFields(),
(new Para())->items(array_merge(
self::fieldsPostExpired($posts->f('post_type'), null, false),
$pa->hiddenFields(),
[
dcCore::app()->formNonce(false),
(new Hidden(['action'], 'post_expired_add')),
(new Submit(['do']))->value(__('Save')),
]),
],
)),
])->render();
$pa->endPage();
@ -210,10 +203,10 @@ class BackendBehaviors
/**
* Posts actions callback to add expired date.
*
* @param ActionsPosts $pa ActionsPosts instance
* @param dcPostsActions $pa dcPostsActions instance
* @param ArrayObject $post _POST actions
*/
public static function callbackRemove(ActionsPosts $pa, ArrayObject $post): void
public static function callbackRemove(dcPostsActions $pa, ArrayObject $post): void
{
// No entry
$posts_ids = $pa->getIDs();
@ -226,7 +219,7 @@ class BackendBehaviors
self::delPostExpired($post_id);
}
Notices::addSuccessNotice(__('Expired date deleted.'));
dcPage::addSuccessNotice(__('Expired date deleted.'));
$pa->redirect(true);
}
@ -254,8 +247,6 @@ class BackendBehaviors
'selected' => '',
'comment' => '',
'trackback' => '',
'password' => '',
'newpassword' => '',
'date' => self::dateFromUser($post['post_expired_date']),
];
@ -274,12 +265,6 @@ class BackendBehaviors
if (!empty($post['post_expired_trackback'])) {
$post_expired['trackback'] = (string) $post['post_expired_trackback'];
}
if (!empty($post['post_expired_password'])) {
$post_expired['password'] = (string) $post['post_expired_password'];
}
if (!empty($post['post_expired_newpassword'])) {
$post_expired['newpassword'] = (string) $post['post_expired_newpassword'];
}
dcCore::app()->meta->setPostMeta(
$post_id,
@ -298,6 +283,11 @@ class BackendBehaviors
*/
private static function fieldsPostExpired(string $post_type, ?int $post_id = null, bool $render = true): array
{
// nullsafe
if (is_null(dcCore::app()->blog)) {
return [];
}
$fields = $post_expired = [];
if ($post_id) {
@ -313,20 +303,20 @@ class BackendBehaviors
}
$fields['post_expired_date'] = (new Para())->items([
(new Label(__('Date:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_date'),
(new Label(__('Date:')))->for('post_expired_date'),
(new Datetime('post_expired_date', Html::escapeHTML(self::dateToUser($post_expired['date'] ?? 'now'))))->class(empty($post_expired['date']) ? 'invalid' : ''),
]);
$fields['post_expired_status'] = (new Para())->items([
(new Text('strong', __('On this date, change:'))),
(new Text('br')),
(new Label(__('Status:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_status'),
(new Label(__('Status:')))->for('post_expired_status'),
(new Select('post_expired_status'))->default(empty($post_expired['status']) ? '' : $post_expired['status'])->items(self::statusCombo()),
]);
if ($post_type == 'post') {
$fields['post_expired_category'] = (new Para())->items([
(new Label(__('Category:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_category'),
(new Label(__('Category:')))->for('post_expired_category'),
(new Select('post_expired_category'))->default(empty($post_expired['category']) ? '' : $post_expired['category'])->items(self::categoriesCombo(
dcCore::app()->blog->getCategories(
['post_type' => 'post']
@ -335,29 +325,21 @@ class BackendBehaviors
]);
$fields['post_expired_selected'] = (new Para())->items([
(new Label(__('Selection:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_selected'),
(new Label(__('Selection:')))->for('post_expired_selected'),
(new Select('post_expired_selected'))->default(empty($post_expired['selected']) ? '' : $post_expired['selected'])->items(self::selectedCombo()),
]);
}
$fields['post_expired_comment'] = (new Para())->items([
(new Label(__('Comments status:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_comment'),
(new Label(__('Comments status:')))->for('post_expired_comment'),
(new Select('post_expired_comment'))->default(empty($post_expired['comment']) ? '' : $post_expired['comment'])->items(self::commentCombo()),
]);
$fields['post_expired_trackback'] = (new Para())->items([
(new Label(__('Trackbacks status:'), Label::OUTSIDE_LABEL_BEFORE))->for('post_expired_trackback'),
(new Label(__('Trackbacks status:')))->for('post_expired_trackback'),
(new Select('post_expired_trackback'))->default(empty($post_expired['trackback']) ? '' : $post_expired['trackback'])->items(self::trackbackCombo()),
]);
$fields['post_expired_password'] = (new Para())->items([
(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 Note())->text(__('Leave empty to remove it'))->class('form-note'),
]);
if ($render) {
foreach ($fields as $k => $v) {
$fields[$k] = $v->render();
@ -376,6 +358,11 @@ class BackendBehaviors
*/
private static function categoriesCombo(MetaRecord $categories): array
{
// nullsafe
if (is_null(dcCore::app()->blog)) {
return [];
}
// Getting categories
$categories_combo = [
__('Not changed') => '',
@ -465,7 +452,7 @@ class BackendBehaviors
*/
private static function dateFromUser(string $date): string
{
$u = !isset(dcCore::app()->auth) ? 'UTC' : dcCore::app()->auth->getInfo('user_tz');
$u = is_null(dcCore::app()->auth) ? 'UTC' : dcCore::app()->auth->getInfo('user_tz');
$d = date_create($date, new DateTimeZone($u));
return $d ? date_format($d->setTimezone(new DateTimeZone('UTC')), 'Y-m-d H:i:00') : '';
@ -480,7 +467,7 @@ class BackendBehaviors
*/
private static function dateToUser(string $date): string
{
$u = !isset(dcCore::app()->auth) ? 'UTC' : dcCore::app()->auth->getInfo('user_tz');
$u = is_null(dcCore::app()->auth) ? 'UTC' : dcCore::app()->auth->getInfo('user_tz');
$d = date_create($date, new DateTimeZone('UTC'));
return $d ? date_format($d->setTimezone(new DateTimeZone($u)), 'Y-m-d\TH:i') : '';

View File

@ -15,18 +15,20 @@ declare(strict_types=1);
namespace Dotclear\Plugin\postExpired;
use dcCore;
use Dotclear\Core\Process;
use dcNsProcess;
class Frontend extends Process
class Frontend extends dcNsProcess
{
public static function init(): bool
{
return self::status(My::checkContext(My::FRONTEND));
static::$init = true;
return static::$init;
}
public static function process(): bool
{
if (!self::status()) {
if (!static::$init) {
return false;
}
@ -38,7 +40,7 @@ class Frontend extends Process
if (in_array(dcCore::app()->url->type, ['default', 'feed'])) {
dcCore::app()->addBehavior(
'publicBeforeDocumentV2',
[FrontendBehaviors::class, 'publicBeforeDocumentV2']
[FrontendBehaviors::class, 'publicBeforeDocument']
);
}
dcCore::app()->addBehavior(

View File

@ -34,11 +34,16 @@ class FrontendBehaviors
/**
* Check if there are expired dates.
*/
public static function publicBeforeDocumentV2(): void
public static function publicBeforeDocument(): void
{
// nullsafe
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog)) {
return;
}
// Get expired dates and post_id
$sql = new SelectStatement();
$posts = $sql->from($sql->as(dcCore::app()->prefix . dcBlog::POST_TABLE_NAME, 'P'))
$posts = $sql->from(dcCore::app()->prefix . dcBlog::POST_TABLE_NAME)
->columns([
'P.post_id',
'P.post_tz',
@ -56,7 +61,7 @@ class FrontendBehaviors
->select();
// No expired date
if (is_null($posts) || $posts->isEmpty()) {
if ($posts->isEmpty()) {
return;
}
@ -123,11 +128,6 @@ class FrontendBehaviors
case 'trackback':
$post_cur->setField('post_open_tb', $v);
break;
case 'password':
$post_cur->setField('post_password', empty($post_expired['newpassword']) ? '' : $post_expired['newpassword']);
break;
}
}

View File

@ -17,7 +17,6 @@ namespace Dotclear\Plugin\postExpired;
use ArrayObject;
use dcCore;
use dcTemplate;
use Dotclear\Helper\Date;
/**
* @ingroup DC_PLUGIN_POSTEXPIRED
@ -67,13 +66,13 @@ class FrontendTemplate
$f = dcCore::app()->tpl->getFilters($attr);
if (!empty($attr['rfc822'])) {
$res = sprintf($f, Date::class . '::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, Date::class . '::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, Date::class . "::dt2str('" . $format . "',dcCore::app()->ctx->posts->postExpiredDate())");
$res = sprintf($f, "dt::dt2str('" . $format . "',dcCore::app()->ctx->posts->postExpiredDate())");
} else {
$res = sprintf($f, Date::class . '::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 . '; } ?>';
@ -91,7 +90,7 @@ class FrontendTemplate
return
'<?php if (null !== dcCore::app()->ctx->posts->postExpiredDate()) { echo ' . sprintf(
dcCore::app()->tpl->getFilters($attr),
Date::class . '::dt2str(' .
'dt::dt2str(' .
(
!empty($attr['format']) ?
"'" . addslashes($attr['format']) . "'" : 'dcCore::app()->blog->settings->system->time_format'

View File

@ -15,23 +15,33 @@ declare(strict_types=1);
namespace Dotclear\Plugin\postExpired;
use dcCore;
use Dotclear\Module\MyPlugin;
/**
* This module definiton.
* Module definiton shortcut.
*/
class My extends MyPlugin
class My
{
/** @var string This module meta type */
/** @var string This plugin meta type */
public const META_TYPE = 'post_expired';
public static function checkCustomContext(int $context): ?bool
/**
* This module id.
*
* @return string The module id
*/
public static function id(): string
{
return $context !== My::BACKEND ? null :
defined('DC_CONTEXT_ADMIN')
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
]), dcCore::app()->blog->id);
return basename(dirname(__DIR__));
}
/**
* This module name.
*
* @return string The module translated name
*/
public static function name(): string
{
return __((string) dcCore::app()->plugins->moduleInfo(self::id(), 'name'));
}
/**