Compare commits

...

10 Commits

13 changed files with 178 additions and 195 deletions

View File

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

View File

@ -18,12 +18,12 @@ $this->registerModule(
'Expired entries',
'Change entries options at a given date',
'Jean-Christian Denis and Contributors',
'2023.03.21',
'2023.07.30',
[
'requires' => [['core', '2.25']],
'requires' => [['core', '2.27']],
'permissions' => dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_USAGE,
dcAuth::PERMISSION_CONTENT_ADMIN,
dcCore::app()->auth::PERMISSION_USAGE,
dcCore::app()->auth::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.03.21</version>
<version>2023.07.30</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.03.21/plugin-postExpired.zip</file>
<da:dcmin>2.25</da:dcmin>
<file>https://github.com/JcDenis/postExpired/releases/download/v2023.07.30/plugin-postExpired.zip</file>
<da:dcmin>2.27</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,25 +1,17 @@
/* -- 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 ------------------------------------*/
/*global $, dotclear, datePicker */
'use strict';
$(function(){
$(() => {
if (typeof datePicker === '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'),
{cookie:'dcx_postexpired_admin_form_sidebar',legend_click:true}
);
}
$('#post_expired h4').toggleWithLegend(
$('#post_expired').children().not('h4'),
{user_pref:'dcx_postexpired_admin_form_sidebar',legend_click:true}
);
});

View File

@ -9,19 +9,21 @@
# DOT NOT MODIFY THIS FILE !
#
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';
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';

View File

@ -1,87 +1,60 @@
# 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 2013.11.03\n"
"Project-Id-Version: postExpired 2023.05.21\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2013-11-03T22:12:31+00:00\n"
"PO-Revision-Date: 2023-05-21T13:03:45+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 :"
#: _admin.php:440
#: _admin.php:470
#: _admin.php:485
#: _admin.php:499
#: _admin.php:513
msgid "Change password"
msgstr "Modifier le mot de passe"
msgid "Leave empty to remove it"
msgstr "Laisser vide pour le supprimer"
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,28 +15,18 @@ declare(strict_types=1);
namespace Dotclear\Plugin\postExpired;
use dcCore;
use dcNsProcess;
use Dotclear\Core\Process;
class Backend extends dcNsProcess
class Backend extends Process
{
public static function init(): bool
{
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;
return self::status(My::checkContext(My::BACKEND));
}
public static function process(): bool
{
if (!static::$init) {
if (!self::status()) {
return false;
}

View File

@ -17,17 +17,23 @@ namespace Dotclear\Plugin\postExpired;
use ArrayObject;
use DateTimeZone;
use dcCore;
use dcPostsActions;
use dcPage;
use Dotclear\Core\Backend\Action\ActionsPosts;
use Dotclear\Core\Backend\{
Notices,
Page
};
use Dotclear\Database\{
Cursor,
MetaRecord
};
use Dotclear\Helper\Html\Form\{
Checkbox,
Datetime,
Form,
Hidden,
Input,
Label,
Note,
Option,
Para,
Text,
@ -47,9 +53,9 @@ class BackendBehaviors
/**
* Add actions to posts page combo.
*
* @param dcPostsActions $pa dcPostsActions instance
* @param ActionsPosts $pa ActionsPosts instance
*/
public static function adminPostsActions(dcPostsActions $pa): void
public static function adminPostsActions(ActionsPosts $pa): void
{
$pa->addAction(
[
@ -77,7 +83,7 @@ class BackendBehaviors
*/
public static function adminPostHeaders(): string
{
return dcPage::jsModuleLoad(My::id() . '/js/backend.js');
return My::jsLoad('backend');
}
/**
@ -124,11 +130,15 @@ class BackendBehaviors
self::delPostExpired($post_id);
if (!empty($_POST['post_expired_date'])
&& (!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_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'])
)
) {
self::setPostExpired($post_id, new ArrayObject($_POST));
}
}
@ -136,35 +146,34 @@ class BackendBehaviors
/**
* Posts actions callback to add expired date.
*
* @param dcPostsActions $pa dcPostsActions instance
* @param ActionsPosts $pa ActionsPosts instance
* @param ArrayObject $post _POST actions
*/
public static function callbackAdd(dcPostsActions $pa, ArrayObject $post): void
public static function callbackAdd(ActionsPosts $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 epired date
// Add expired date
if (!empty($post['post_expired_date'])
&& (!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_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'])
)
) {
foreach ($posts_ids as $post_id) {
self::delPostExpired($post_id);
self::setPostExpired($post_id, $post);
}
dcPage::addSuccessNotice(__('Expired date added.'));
Notices::addSuccessNotice(__('Expired date added.'));
$pa->redirect(true);
// Display form
@ -173,27 +182,25 @@ class BackendBehaviors
$posts = $pa->getRS();
$pa->beginPage(
dcPage::breadcrumb([
Page::breadcrumb([
Html::escapeHTML(dcCore::app()->blog->name) => '',
$pa->getCallerTitle() => $pa->getRedirection(true),
__('Add expired date to this selection') => '',
]),
//dcPage::jsDatePicker() .
//Page::jsDatePicker() .
self::adminPostHeaders()
);
echo
(new Form('peadd'))->method('post')->action($pa->getURI())->fields([
(new Text('', $pa->getCheckboxes())),
(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')),
],
)),
(new Para())->items([
... 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();
@ -203,10 +210,10 @@ class BackendBehaviors
/**
* Posts actions callback to add expired date.
*
* @param dcPostsActions $pa dcPostsActions instance
* @param ActionsPosts $pa ActionsPosts instance
* @param ArrayObject $post _POST actions
*/
public static function callbackRemove(dcPostsActions $pa, ArrayObject $post): void
public static function callbackRemove(ActionsPosts $pa, ArrayObject $post): void
{
// No entry
$posts_ids = $pa->getIDs();
@ -219,7 +226,7 @@ class BackendBehaviors
self::delPostExpired($post_id);
}
dcPage::addSuccessNotice(__('Expired date deleted.'));
Notices::addSuccessNotice(__('Expired date deleted.'));
$pa->redirect(true);
}
@ -242,12 +249,14 @@ class BackendBehaviors
private static function setPostExpired(int $post_id, ArrayObject $post): void
{
$post_expired = [
'status' => '',
'category' => '',
'selected' => '',
'comment' => '',
'trackback' => '',
'date' => self::dateFromUser($post['post_expired_date']),
'status' => '',
'category' => '',
'selected' => '',
'comment' => '',
'trackback' => '',
'password' => '',
'newpassword' => '',
'date' => self::dateFromUser($post['post_expired_date']),
];
if (!empty($post['post_expired_status'])) {
@ -265,6 +274,12 @@ 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,
@ -283,11 +298,6 @@ 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) {
@ -303,20 +313,20 @@ class BackendBehaviors
}
$fields['post_expired_date'] = (new Para())->items([
(new Label(__('Date:')))->for('post_expired_date'),
(new Label(__('Date:'), Label::OUTSIDE_LABEL_BEFORE))->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:')))->for('post_expired_status'),
(new Label(__('Status:'), Label::OUTSIDE_LABEL_BEFORE))->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:')))->for('post_expired_category'),
(new Label(__('Category:'), Label::OUTSIDE_LABEL_BEFORE))->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']
@ -325,21 +335,29 @@ class BackendBehaviors
]);
$fields['post_expired_selected'] = (new Para())->items([
(new Label(__('Selection:')))->for('post_expired_selected'),
(new Label(__('Selection:'), Label::OUTSIDE_LABEL_BEFORE))->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:')))->for('post_expired_comment'),
(new Label(__('Comments status:'), Label::OUTSIDE_LABEL_BEFORE))->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:')))->for('post_expired_trackback'),
(new Label(__('Trackbacks status:'), Label::OUTSIDE_LABEL_BEFORE))->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();
@ -358,11 +376,6 @@ class BackendBehaviors
*/
private static function categoriesCombo(MetaRecord $categories): array
{
// nullsafe
if (is_null(dcCore::app()->blog)) {
return [];
}
// Getting categories
$categories_combo = [
__('Not changed') => '',
@ -452,7 +465,7 @@ class BackendBehaviors
*/
private static function dateFromUser(string $date): string
{
$u = is_null(dcCore::app()->auth) ? 'UTC' : dcCore::app()->auth->getInfo('user_tz');
$u = !isset(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') : '';
@ -467,7 +480,7 @@ class BackendBehaviors
*/
private static function dateToUser(string $date): string
{
$u = is_null(dcCore::app()->auth) ? 'UTC' : dcCore::app()->auth->getInfo('user_tz');
$u = !isset(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,20 +15,18 @@ declare(strict_types=1);
namespace Dotclear\Plugin\postExpired;
use dcCore;
use dcNsProcess;
use Dotclear\Core\Process;
class Frontend extends dcNsProcess
class Frontend extends Process
{
public static function init(): bool
{
static::$init = true;
return static::$init;
return self::status(My::checkContext(My::FRONTEND));
}
public static function process(): bool
{
if (!static::$init) {
if (!self::status()) {
return false;
}
@ -40,7 +38,7 @@ class Frontend extends dcNsProcess
if (in_array(dcCore::app()->url->type, ['default', 'feed'])) {
dcCore::app()->addBehavior(
'publicBeforeDocumentV2',
[FrontendBehaviors::class, 'publicBeforeDocument']
[FrontendBehaviors::class, 'publicBeforeDocumentV2']
);
}
dcCore::app()->addBehavior(

View File

@ -34,16 +34,11 @@ class FrontendBehaviors
/**
* Check if there are expired dates.
*/
public static function publicBeforeDocument(): void
public static function publicBeforeDocumentV2(): 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(dcCore::app()->prefix . dcBlog::POST_TABLE_NAME)
$posts = $sql->from($sql->as(dcCore::app()->prefix . dcBlog::POST_TABLE_NAME, 'P'))
->columns([
'P.post_id',
'P.post_tz',
@ -61,7 +56,7 @@ class FrontendBehaviors
->select();
// No expired date
if ($posts->isEmpty()) {
if (is_null($posts) || $posts->isEmpty()) {
return;
}
@ -128,6 +123,11 @@ 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,6 +17,7 @@ namespace Dotclear\Plugin\postExpired;
use ArrayObject;
use dcCore;
use dcTemplate;
use Dotclear\Helper\Date;
/**
* @ingroup DC_PLUGIN_POSTEXPIRED
@ -66,13 +67,13 @@ class FrontendTemplate
$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, Date::class . '::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, Date::class . '::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())");
$res = sprintf($f, Date::class . "::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, Date::class . '::dt2str(dcCore::app()->blog->settings->system->date_format,dcCore::app()->ctx->posts->postExpiredDate())');
}
return '<?php if (null !== dcCore::app()->ctx->posts->postExpiredDate()) { echo ' . $res . '; } ?>';
@ -90,7 +91,7 @@ class FrontendTemplate
return
'<?php if (null !== dcCore::app()->ctx->posts->postExpiredDate()) { echo ' . sprintf(
dcCore::app()->tpl->getFilters($attr),
'dt::dt2str(' .
Date::class . '::dt2str(' .
(
!empty($attr['format']) ?
"'" . addslashes($attr['format']) . "'" : 'dcCore::app()->blog->settings->system->time_format'

View File

@ -15,33 +15,23 @@ declare(strict_types=1);
namespace Dotclear\Plugin\postExpired;
use dcCore;
use Dotclear\Module\MyPlugin;
/**
* Module definiton shortcut.
* This module definiton.
*/
class My
class My extends MyPlugin
{
/** @var string This plugin meta type */
/** @var string This module meta type */
public const META_TYPE = 'post_expired';
/**
* This module id.
*
* @return string The module id
*/
public static function id(): string
public static function checkCustomContext(int $context): ?bool
{
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'));
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);
}
/**