Compare commits
10 Commits
a5384aaea6
...
fb9958fdcc
Author | SHA1 | Date |
---|---|---|
Jean-Christian Paul Denis | fb9958fdcc | |
Jean-Christian Paul Denis | 5618a4c803 | |
Jean-Christian Paul Denis | 7f931f24ad | |
Jean-Christian Paul Denis | e7cbc6eedb | |
Jean-Christian Paul Denis | a36f65455c | |
Jean-Christian Paul Denis | 1369a30d03 | |
Jean-Christian Paul Denis | 2dbc74d1dc | |
Jean-Christian Paul Denis | 5ca7695494 | |
Jean-Christian Paul Denis | 4a191db4eb | |
Jean-Christian Paul Denis | 809606c889 |
23
CHANGELOG.md
23
CHANGELOG.md
|
@ -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
|
2023.03.21
|
||||||
- require dotclear 2.25
|
- require dotclear 2.25
|
||||||
- use namespace
|
- use namespace
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
[![Release](https://img.shields.io/github/v/release/JcDenis/postExpired)](https://github.com/JcDenis/postExpired/releases)
|
[![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)
|
[![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)
|
[![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)
|
[![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)
|
[![License](https://img.shields.io/github/license/JcDenis/postExpired)](https://github.com/JcDenis/postExpired/blob/master/LICENSE)
|
||||||
|
|
||||||
|
@ -20,7 +20,8 @@ to change some options of a post at a given time.
|
||||||
postExpired requires:
|
postExpired requires:
|
||||||
|
|
||||||
* contentadmin permissions
|
* contentadmin permissions
|
||||||
* Dotclear 2.25
|
* Dotclear 2.27
|
||||||
|
* PHP 7.4+
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,12 @@ $this->registerModule(
|
||||||
'Expired entries',
|
'Expired entries',
|
||||||
'Change entries options at a given date',
|
'Change entries options at a given date',
|
||||||
'Jean-Christian Denis and Contributors',
|
'Jean-Christian Denis and Contributors',
|
||||||
'2023.03.21',
|
'2023.07.30',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.25']],
|
'requires' => [['core', '2.27']],
|
||||||
'permissions' => dcCore::app()->auth->makePermissions([
|
'permissions' => dcCore::app()->auth->makePermissions([
|
||||||
dcAuth::PERMISSION_USAGE,
|
dcCore::app()->auth::PERMISSION_USAGE,
|
||||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||||
]),
|
]),
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
|
'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
<modules xmlns:da="http://dotaddict.org/da/">
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
<module id="postExpired">
|
<module id="postExpired">
|
||||||
<name>Expired entries</name>
|
<name>Expired entries</name>
|
||||||
<version>2023.03.21</version>
|
<version>2023.07.30</version>
|
||||||
<author>Jean-Christian Denis and Contributors</author>
|
<author>Jean-Christian Denis and Contributors</author>
|
||||||
<desc>Change entries options at a given date</desc>
|
<desc>Change entries options at a given date</desc>
|
||||||
<file>https://github.com/JcDenis/postExpired/releases/download/v2023.03.21/plugin-postExpired.zip</file>
|
<file>https://github.com/JcDenis/postExpired/releases/download/v2023.07.30/plugin-postExpired.zip</file>
|
||||||
<da:dcmin>2.25</da:dcmin>
|
<da:dcmin>2.27</da:dcmin>
|
||||||
<da:details>https://plugins.dotaddict.org/dc2/details/postExpired</da:details>
|
<da:details>https://plugins.dotaddict.org/dc2/details/postExpired</da:details>
|
||||||
<da:support>https://github.com/JcDenis/postExpired</da:support>
|
<da:support>https://github.com/JcDenis/postExpired</da:support>
|
||||||
</module>
|
</module>
|
||||||
|
|
|
@ -1,25 +1,17 @@
|
||||||
/* -- BEGIN LICENSE BLOCK ----------------------------------
|
/*global $, dotclear, datePicker */
|
||||||
*
|
'use strict';
|
||||||
* 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 ------------------------------------*/
|
|
||||||
|
|
||||||
$(function(){
|
$(() => {
|
||||||
|
if (typeof datePicker === 'function') {
|
||||||
var post_pe_field=document.getElementById('post_expired_date');
|
var post_pe_field=document.getElementById('post_expired_date');
|
||||||
if(post_pe_field!=undefined){
|
if(post_pe_field!=undefined){
|
||||||
var post_pe_dtPick=new datePicker(post_pe_field);
|
var post_pe_dtPick=new datePicker(post_pe_field);
|
||||||
post_pe_dtPick.img_top='1.5em';
|
post_pe_dtPick.img_top='1.5em';
|
||||||
post_pe_dtPick.draw();
|
post_pe_dtPick.draw();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$('#post_expired h4').toggleWithLegend(
|
$('#post_expired h4').toggleWithLegend(
|
||||||
$('#post_expired').children().not('h4'),
|
$('#post_expired').children().not('h4'),
|
||||||
{cookie:'dcx_postexpired_admin_form_sidebar',legend_click:true}
|
{user_pref:'dcx_postexpired_admin_form_sidebar',legend_click:true}
|
||||||
);
|
);
|
||||||
});
|
});
|
|
@ -9,19 +9,21 @@
|
||||||
# DOT NOT MODIFY THIS FILE !
|
# DOT NOT MODIFY THIS FILE !
|
||||||
#
|
#
|
||||||
|
|
||||||
l10n::$locales['Expired entries'] = 'Billets périmés';
|
use Dotclear\Helper\L10n;
|
||||||
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 entries'] = 'Billets périmés';
|
||||||
l10n::$locales['Expired date'] = 'Date de péremption';
|
L10n::$locales['Add expired date'] = 'Ajouter une date de péremption';
|
||||||
l10n::$locales['Expired date added.'] = 'Date de péremption ajoutée.';
|
L10n::$locales['Remove expired date'] = 'Retirer une date de péremption';
|
||||||
l10n::$locales['Add expired date to this selection'] = 'Ajouter une date de péremtion à cette sélection';
|
L10n::$locales['Expired date'] = 'Date de péremption';
|
||||||
l10n::$locales['Expired date deleted.'] = 'Dtae de péremtion supprimé';
|
L10n::$locales['Expired date added.'] = 'Date de péremption ajoutée.';
|
||||||
l10n::$locales['On this date, change:'] = 'Á cette date, changer :';
|
L10n::$locales['Add expired date to this selection'] = 'Ajouter une date de péremtion à cette sélection';
|
||||||
l10n::$locales['Selection:'] = 'Séléction :';
|
L10n::$locales['Expired date deleted.'] = 'Dtae de péremtion supprimé';
|
||||||
l10n::$locales['Comments status:'] = 'Status des commentaires :';
|
L10n::$locales['On this date, change:'] = 'Á cette date, changer :';
|
||||||
l10n::$locales['Trackbacks status:'] = 'Status des rétroliens :';
|
L10n::$locales['Selection:'] = 'Séléction :';
|
||||||
l10n::$locales['Not changed'] = 'Inchangé';
|
L10n::$locales['Comments status:'] = 'Status des commentaires :';
|
||||||
l10n::$locales['Opened'] = 'Ouvert';
|
L10n::$locales['Trackbacks status:'] = 'Status des rétroliens :';
|
||||||
l10n::$locales['Closed'] = 'Fermé';
|
L10n::$locales['Change password'] = 'Modifier le mot de passe';
|
||||||
l10n::$locales['Expired on'] = 'Expire le';
|
L10n::$locales['Leave empty to remove it'] = 'Laisser vide pour le supprimer';
|
||||||
l10n::$locales['This entry has no expiration date'] = 'Ce billet n\'a pas de date de péremption';
|
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';
|
||||||
|
|
|
@ -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 ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"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"
|
"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"
|
"Last-Translator: Jean-Christian Denis\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||||
|
|
||||||
#: _admin.php:100
|
|
||||||
#: _admin.php:110
|
|
||||||
msgid "Expired entries"
|
msgid "Expired entries"
|
||||||
msgstr "Billets périmés"
|
msgstr "Billets périmés"
|
||||||
|
|
||||||
#: _admin.php:101
|
|
||||||
msgid "Add expired date"
|
msgid "Add expired date"
|
||||||
msgstr "Ajouter une date de péremption"
|
msgstr "Ajouter une date de péremption"
|
||||||
|
|
||||||
#: _admin.php:111
|
|
||||||
msgid "Remove expired date"
|
msgid "Remove expired date"
|
||||||
msgstr "Retirer une date de péremption"
|
msgstr "Retirer une date de péremption"
|
||||||
|
|
||||||
#: _admin.php:139
|
|
||||||
msgid "Expired date"
|
msgid "Expired date"
|
||||||
msgstr "Date de péremption"
|
msgstr "Date de péremption"
|
||||||
|
|
||||||
#: _admin.php:209
|
|
||||||
msgid "Expired date added."
|
msgid "Expired date added."
|
||||||
msgstr "Date de péremption ajoutée."
|
msgstr "Date de péremption ajoutée."
|
||||||
|
|
||||||
#: _admin.php:222
|
|
||||||
msgid "Add expired date to this selection"
|
msgid "Add expired date to this selection"
|
||||||
msgstr "Ajouter une date de péremtion à cette sélection"
|
msgstr "Ajouter une date de péremtion à cette sélection"
|
||||||
|
|
||||||
#: _admin.php:269
|
|
||||||
msgid "Expired date deleted."
|
msgid "Expired date deleted."
|
||||||
msgstr "Dtae de péremtion supprimé"
|
msgstr "Dtae de péremtion supprimé"
|
||||||
|
|
||||||
#: _admin.php:370
|
|
||||||
msgid "On this date, change:"
|
msgid "On this date, change:"
|
||||||
msgstr "Á cette date, changer :"
|
msgstr "Á cette date, changer :"
|
||||||
|
|
||||||
#: _admin.php:398
|
|
||||||
msgid "Selection:"
|
msgid "Selection:"
|
||||||
msgstr "Séléction :"
|
msgstr "Séléction :"
|
||||||
|
|
||||||
#: _admin.php:409
|
|
||||||
msgid "Comments status:"
|
msgid "Comments status:"
|
||||||
msgstr "Status des commentaires :"
|
msgstr "Status des commentaires :"
|
||||||
|
|
||||||
#: _admin.php:419
|
|
||||||
msgid "Trackbacks status:"
|
msgid "Trackbacks status:"
|
||||||
msgstr "Status des rétroliens :"
|
msgstr "Status des rétroliens :"
|
||||||
|
|
||||||
#: _admin.php:440
|
msgid "Change password"
|
||||||
#: _admin.php:470
|
msgstr "Modifier le mot de passe"
|
||||||
#: _admin.php:485
|
|
||||||
#: _admin.php:499
|
msgid "Leave empty to remove it"
|
||||||
#: _admin.php:513
|
msgstr "Laisser vide pour le supprimer"
|
||||||
|
|
||||||
msgid "Not changed"
|
msgid "Not changed"
|
||||||
msgstr "Inchangé"
|
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"
|
msgid "Expired on"
|
||||||
msgstr "Expire le"
|
msgstr "Expire le"
|
||||||
|
|
||||||
#: _public.php:26
|
|
||||||
msgid "This entry has no expiration date"
|
msgid "This entry has no expiration date"
|
||||||
msgstr "Ce billet n'a pas de date de péremption"
|
msgstr "Ce billet n'a pas de date de péremption"
|
||||||
|
|
||||||
|
|
|
@ -15,28 +15,18 @@ declare(strict_types=1);
|
||||||
namespace Dotclear\Plugin\postExpired;
|
namespace Dotclear\Plugin\postExpired;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcNsProcess;
|
use Dotclear\Core\Process;
|
||||||
|
|
||||||
class Backend extends dcNsProcess
|
class Backend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
return self::status(My::checkContext(My::BACKEND));
|
||||||
&& !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
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,17 +17,23 @@ namespace Dotclear\Plugin\postExpired;
|
||||||
use ArrayObject;
|
use ArrayObject;
|
||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcPostsActions;
|
use Dotclear\Core\Backend\Action\ActionsPosts;
|
||||||
use dcPage;
|
use Dotclear\Core\Backend\{
|
||||||
|
Notices,
|
||||||
|
Page
|
||||||
|
};
|
||||||
use Dotclear\Database\{
|
use Dotclear\Database\{
|
||||||
Cursor,
|
Cursor,
|
||||||
MetaRecord
|
MetaRecord
|
||||||
};
|
};
|
||||||
use Dotclear\Helper\Html\Form\{
|
use Dotclear\Helper\Html\Form\{
|
||||||
|
Checkbox,
|
||||||
Datetime,
|
Datetime,
|
||||||
Form,
|
Form,
|
||||||
Hidden,
|
Hidden,
|
||||||
|
Input,
|
||||||
Label,
|
Label,
|
||||||
|
Note,
|
||||||
Option,
|
Option,
|
||||||
Para,
|
Para,
|
||||||
Text,
|
Text,
|
||||||
|
@ -47,9 +53,9 @@ class BackendBehaviors
|
||||||
/**
|
/**
|
||||||
* Add actions to posts page combo.
|
* 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(
|
$pa->addAction(
|
||||||
[
|
[
|
||||||
|
@ -77,7 +83,7 @@ class BackendBehaviors
|
||||||
*/
|
*/
|
||||||
public static function adminPostHeaders(): string
|
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);
|
self::delPostExpired($post_id);
|
||||||
|
|
||||||
if (!empty($_POST['post_expired_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_category'])
|
||||||
|| !empty($_POST['post_expired_selected'])
|
|| !empty($_POST['post_expired_selected'])
|
||||||
|| !empty($_POST['post_expired_comment'])
|
|| !empty($_POST['post_expired_comment'])
|
||||||
|| !empty($_POST['post_expired_trackback']))) {
|
|| !empty($_POST['post_expired_trackback'])
|
||||||
|
|| !empty($_POST['post_expired_password'])
|
||||||
|
)
|
||||||
|
) {
|
||||||
self::setPostExpired($post_id, new ArrayObject($_POST));
|
self::setPostExpired($post_id, new ArrayObject($_POST));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,35 +146,34 @@ class BackendBehaviors
|
||||||
/**
|
/**
|
||||||
* Posts actions callback to add expired date.
|
* Posts actions callback to add expired date.
|
||||||
*
|
*
|
||||||
* @param dcPostsActions $pa dcPostsActions instance
|
* @param ActionsPosts $pa ActionsPosts instance
|
||||||
* @param ArrayObject $post _POST actions
|
* @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
|
// No entry
|
||||||
$posts_ids = $pa->getIDs();
|
$posts_ids = $pa->getIDs();
|
||||||
if (empty($posts_ids)) {
|
if (empty($posts_ids)) {
|
||||||
throw new Exception(__('No entry selected'));
|
throw new Exception(__('No entry selected'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add epired date
|
// Add expired date
|
||||||
if (!empty($post['post_expired_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_category'])
|
||||||
|| !empty($post['post_expired_selected'])
|
|| !empty($post['post_expired_selected'])
|
||||||
|| !empty($post['post_expired_comment'])
|
|| !empty($post['post_expired_comment'])
|
||||||
|| !empty($post['post_expired_trackback']))) {
|
|| !empty($post['post_expired_trackback'])
|
||||||
|
|| !empty($post['post_expired_password'])
|
||||||
|
)
|
||||||
|
) {
|
||||||
foreach ($posts_ids as $post_id) {
|
foreach ($posts_ids as $post_id) {
|
||||||
self::delPostExpired($post_id);
|
self::delPostExpired($post_id);
|
||||||
self::setPostExpired($post_id, $post);
|
self::setPostExpired($post_id, $post);
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::addSuccessNotice(__('Expired date added.'));
|
Notices::addSuccessNotice(__('Expired date added.'));
|
||||||
$pa->redirect(true);
|
$pa->redirect(true);
|
||||||
|
|
||||||
// Display form
|
// Display form
|
||||||
|
@ -173,27 +182,25 @@ class BackendBehaviors
|
||||||
$posts = $pa->getRS();
|
$posts = $pa->getRS();
|
||||||
|
|
||||||
$pa->beginPage(
|
$pa->beginPage(
|
||||||
dcPage::breadcrumb([
|
Page::breadcrumb([
|
||||||
Html::escapeHTML(dcCore::app()->blog->name) => '',
|
Html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||||
$pa->getCallerTitle() => $pa->getRedirection(true),
|
$pa->getCallerTitle() => $pa->getRedirection(true),
|
||||||
__('Add expired date to this selection') => '',
|
__('Add expired date to this selection') => '',
|
||||||
]),
|
]),
|
||||||
//dcPage::jsDatePicker() .
|
//Page::jsDatePicker() .
|
||||||
self::adminPostHeaders()
|
self::adminPostHeaders()
|
||||||
);
|
);
|
||||||
|
|
||||||
echo
|
echo
|
||||||
(new Form('peadd'))->method('post')->action($pa->getURI())->fields([
|
(new Form('peadd'))->method('post')->action($pa->getURI())->fields([
|
||||||
(new Text('', $pa->getCheckboxes())),
|
(new Text('', $pa->getCheckboxes())),
|
||||||
(new Para())->items(array_merge(
|
(new Para())->items([
|
||||||
self::fieldsPostExpired($posts->f('post_type'), null, false),
|
... self::fieldsPostExpired($posts->f('post_type'), null, false),
|
||||||
$pa->hiddenFields(),
|
... $pa->hiddenFields(),
|
||||||
[
|
|
||||||
dcCore::app()->formNonce(false),
|
dcCore::app()->formNonce(false),
|
||||||
(new Hidden(['action'], 'post_expired_add')),
|
(new Hidden(['action'], 'post_expired_add')),
|
||||||
(new Submit(['do']))->value(__('Save')),
|
(new Submit(['do']))->value(__('Save')),
|
||||||
],
|
]),
|
||||||
)),
|
|
||||||
])->render();
|
])->render();
|
||||||
|
|
||||||
$pa->endPage();
|
$pa->endPage();
|
||||||
|
@ -203,10 +210,10 @@ class BackendBehaviors
|
||||||
/**
|
/**
|
||||||
* Posts actions callback to add expired date.
|
* Posts actions callback to add expired date.
|
||||||
*
|
*
|
||||||
* @param dcPostsActions $pa dcPostsActions instance
|
* @param ActionsPosts $pa ActionsPosts instance
|
||||||
* @param ArrayObject $post _POST actions
|
* @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
|
// No entry
|
||||||
$posts_ids = $pa->getIDs();
|
$posts_ids = $pa->getIDs();
|
||||||
|
@ -219,7 +226,7 @@ class BackendBehaviors
|
||||||
self::delPostExpired($post_id);
|
self::delPostExpired($post_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::addSuccessNotice(__('Expired date deleted.'));
|
Notices::addSuccessNotice(__('Expired date deleted.'));
|
||||||
$pa->redirect(true);
|
$pa->redirect(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,6 +254,8 @@ class BackendBehaviors
|
||||||
'selected' => '',
|
'selected' => '',
|
||||||
'comment' => '',
|
'comment' => '',
|
||||||
'trackback' => '',
|
'trackback' => '',
|
||||||
|
'password' => '',
|
||||||
|
'newpassword' => '',
|
||||||
'date' => self::dateFromUser($post['post_expired_date']),
|
'date' => self::dateFromUser($post['post_expired_date']),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -265,6 +274,12 @@ class BackendBehaviors
|
||||||
if (!empty($post['post_expired_trackback'])) {
|
if (!empty($post['post_expired_trackback'])) {
|
||||||
$post_expired['trackback'] = (string) $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(
|
dcCore::app()->meta->setPostMeta(
|
||||||
$post_id,
|
$post_id,
|
||||||
|
@ -283,11 +298,6 @@ class BackendBehaviors
|
||||||
*/
|
*/
|
||||||
private static function fieldsPostExpired(string $post_type, ?int $post_id = null, bool $render = true): array
|
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 = [];
|
$fields = $post_expired = [];
|
||||||
|
|
||||||
if ($post_id) {
|
if ($post_id) {
|
||||||
|
@ -303,20 +313,20 @@ class BackendBehaviors
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields['post_expired_date'] = (new Para())->items([
|
$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' : ''),
|
(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([
|
$fields['post_expired_status'] = (new Para())->items([
|
||||||
(new Text('strong', __('On this date, change:'))),
|
(new Text('strong', __('On this date, change:'))),
|
||||||
(new Text('br')),
|
(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()),
|
(new Select('post_expired_status'))->default(empty($post_expired['status']) ? '' : $post_expired['status'])->items(self::statusCombo()),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($post_type == 'post') {
|
if ($post_type == 'post') {
|
||||||
$fields['post_expired_category'] = (new Para())->items([
|
$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(
|
(new Select('post_expired_category'))->default(empty($post_expired['category']) ? '' : $post_expired['category'])->items(self::categoriesCombo(
|
||||||
dcCore::app()->blog->getCategories(
|
dcCore::app()->blog->getCategories(
|
||||||
['post_type' => 'post']
|
['post_type' => 'post']
|
||||||
|
@ -325,21 +335,29 @@ class BackendBehaviors
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$fields['post_expired_selected'] = (new Para())->items([
|
$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()),
|
(new Select('post_expired_selected'))->default(empty($post_expired['selected']) ? '' : $post_expired['selected'])->items(self::selectedCombo()),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields['post_expired_comment'] = (new Para())->items([
|
$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()),
|
(new Select('post_expired_comment'))->default(empty($post_expired['comment']) ? '' : $post_expired['comment'])->items(self::commentCombo()),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$fields['post_expired_trackback'] = (new Para())->items([
|
$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()),
|
(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) {
|
if ($render) {
|
||||||
foreach ($fields as $k => $v) {
|
foreach ($fields as $k => $v) {
|
||||||
$fields[$k] = $v->render();
|
$fields[$k] = $v->render();
|
||||||
|
@ -358,11 +376,6 @@ class BackendBehaviors
|
||||||
*/
|
*/
|
||||||
private static function categoriesCombo(MetaRecord $categories): array
|
private static function categoriesCombo(MetaRecord $categories): array
|
||||||
{
|
{
|
||||||
// nullsafe
|
|
||||||
if (is_null(dcCore::app()->blog)) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getting categories
|
// Getting categories
|
||||||
$categories_combo = [
|
$categories_combo = [
|
||||||
__('Not changed') => '',
|
__('Not changed') => '',
|
||||||
|
@ -452,7 +465,7 @@ class BackendBehaviors
|
||||||
*/
|
*/
|
||||||
private static function dateFromUser(string $date): string
|
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));
|
$d = date_create($date, new DateTimeZone($u));
|
||||||
|
|
||||||
return $d ? date_format($d->setTimezone(new DateTimeZone('UTC')), 'Y-m-d H:i:00') : '';
|
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
|
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'));
|
$d = date_create($date, new DateTimeZone('UTC'));
|
||||||
|
|
||||||
return $d ? date_format($d->setTimezone(new DateTimeZone($u)), 'Y-m-d\TH:i') : '';
|
return $d ? date_format($d->setTimezone(new DateTimeZone($u)), 'Y-m-d\TH:i') : '';
|
||||||
|
|
|
@ -15,20 +15,18 @@ declare(strict_types=1);
|
||||||
namespace Dotclear\Plugin\postExpired;
|
namespace Dotclear\Plugin\postExpired;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcNsProcess;
|
use Dotclear\Core\Process;
|
||||||
|
|
||||||
class Frontend extends dcNsProcess
|
class Frontend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = true;
|
return self::status(My::checkContext(My::FRONTEND));
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +38,7 @@ class Frontend extends dcNsProcess
|
||||||
if (in_array(dcCore::app()->url->type, ['default', 'feed'])) {
|
if (in_array(dcCore::app()->url->type, ['default', 'feed'])) {
|
||||||
dcCore::app()->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'publicBeforeDocumentV2',
|
'publicBeforeDocumentV2',
|
||||||
[FrontendBehaviors::class, 'publicBeforeDocument']
|
[FrontendBehaviors::class, 'publicBeforeDocumentV2']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
dcCore::app()->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
|
|
|
@ -34,16 +34,11 @@ class FrontendBehaviors
|
||||||
/**
|
/**
|
||||||
* Check if there are expired dates.
|
* 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
|
// Get expired dates and post_id
|
||||||
$sql = new SelectStatement();
|
$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([
|
->columns([
|
||||||
'P.post_id',
|
'P.post_id',
|
||||||
'P.post_tz',
|
'P.post_tz',
|
||||||
|
@ -61,7 +56,7 @@ class FrontendBehaviors
|
||||||
->select();
|
->select();
|
||||||
|
|
||||||
// No expired date
|
// No expired date
|
||||||
if ($posts->isEmpty()) {
|
if (is_null($posts) || $posts->isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +123,11 @@ class FrontendBehaviors
|
||||||
case 'trackback':
|
case 'trackback':
|
||||||
$post_cur->setField('post_open_tb', $v);
|
$post_cur->setField('post_open_tb', $v);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'password':
|
||||||
|
$post_cur->setField('post_password', empty($post_expired['newpassword']) ? '' : $post_expired['newpassword']);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace Dotclear\Plugin\postExpired;
|
||||||
use ArrayObject;
|
use ArrayObject;
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcTemplate;
|
use dcTemplate;
|
||||||
|
use Dotclear\Helper\Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup DC_PLUGIN_POSTEXPIRED
|
* @ingroup DC_PLUGIN_POSTEXPIRED
|
||||||
|
@ -66,13 +67,13 @@ class FrontendTemplate
|
||||||
$f = dcCore::app()->tpl->getFilters($attr);
|
$f = dcCore::app()->tpl->getFilters($attr);
|
||||||
|
|
||||||
if (!empty($attr['rfc822'])) {
|
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'])) {
|
} 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) {
|
} 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 {
|
} 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 . '; } ?>';
|
return '<?php if (null !== dcCore::app()->ctx->posts->postExpiredDate()) { echo ' . $res . '; } ?>';
|
||||||
|
@ -90,7 +91,7 @@ class FrontendTemplate
|
||||||
return
|
return
|
||||||
'<?php if (null !== dcCore::app()->ctx->posts->postExpiredDate()) { echo ' . sprintf(
|
'<?php if (null !== dcCore::app()->ctx->posts->postExpiredDate()) { echo ' . sprintf(
|
||||||
dcCore::app()->tpl->getFilters($attr),
|
dcCore::app()->tpl->getFilters($attr),
|
||||||
'dt::dt2str(' .
|
Date::class . '::dt2str(' .
|
||||||
(
|
(
|
||||||
!empty($attr['format']) ?
|
!empty($attr['format']) ?
|
||||||
"'" . addslashes($attr['format']) . "'" : 'dcCore::app()->blog->settings->system->time_format'
|
"'" . addslashes($attr['format']) . "'" : 'dcCore::app()->blog->settings->system->time_format'
|
||||||
|
|
30
src/My.php
30
src/My.php
|
@ -15,33 +15,23 @@ declare(strict_types=1);
|
||||||
namespace Dotclear\Plugin\postExpired;
|
namespace Dotclear\Plugin\postExpired;
|
||||||
|
|
||||||
use dcCore;
|
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';
|
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 basename(dirname(__DIR__));
|
return $context !== My::BACKEND ? null :
|
||||||
}
|
defined('DC_CONTEXT_ADMIN')
|
||||||
|
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||||
/**
|
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||||
* This module name.
|
]), dcCore::app()->blog->id);
|
||||||
*
|
|
||||||
* @return string The module translated name
|
|
||||||
*/
|
|
||||||
public static function name(): string
|
|
||||||
{
|
|
||||||
return __((string) dcCore::app()->plugins->moduleInfo(self::id(), 'name'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue