upgrade to Dotclear 2.27
parent
cad66522a1
commit
899a61ed5f
|
@ -16,37 +16,28 @@ namespace Dotclear\Plugin\postslistOptions;
|
||||||
|
|
||||||
use ArrayObject;
|
use ArrayObject;
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcNsProcess;
|
use Dotclear\Core\Backend\Action\ActionsPosts;
|
||||||
use dcPostsActions;
|
use Dotclear\Core\Process;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improve admin class
|
* Improve admin class
|
||||||
*
|
*
|
||||||
* Add menu and dashboard icons, load Improve action modules.
|
* Add menu and dashboard icons, load Improve action modules.
|
||||||
*/
|
*/
|
||||||
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_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;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->addBehavior('adminPostsActions', function (dcPostsActions $pa) {
|
dcCore::app()->addBehavior('adminPostsActions', function (ActionsPosts $pa) {
|
||||||
$pa->addAction(
|
$pa->addAction(
|
||||||
[
|
[
|
||||||
__('Comments') => [
|
__('Comments') => [
|
||||||
|
@ -60,7 +51,7 @@ class Backend extends dcNsProcess
|
||||||
__('Delete all trackbacks') => 'trackbacksdelete',
|
__('Delete all trackbacks') => 'trackbacksdelete',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
function (dcPostsActions $pa, ArrayObject $post) {
|
function (ActionsPosts $pa, ArrayObject $post) {
|
||||||
$actions = [
|
$actions = [
|
||||||
'commentsopen',
|
'commentsopen',
|
||||||
'commentsclose',
|
'commentsclose',
|
||||||
|
|
|
@ -17,8 +17,11 @@ namespace Dotclear\Plugin\postslistOptions;
|
||||||
use ArrayObject;
|
use ArrayObject;
|
||||||
use dcBlog;
|
use dcBlog;
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcPage;
|
use Dotclear\Core\Backend\{
|
||||||
use dcPostsActions;
|
Notices,
|
||||||
|
Page
|
||||||
|
};
|
||||||
|
use Dotclear\Core\Backend\Action\ActionsPosts;
|
||||||
use Dotclear\Helper\Html\Form\{
|
use Dotclear\Helper\Html\Form\{
|
||||||
Form,
|
Form,
|
||||||
Hidden,
|
Hidden,
|
||||||
|
@ -31,25 +34,25 @@ use Exception;
|
||||||
|
|
||||||
class BackendBehaviors
|
class BackendBehaviors
|
||||||
{
|
{
|
||||||
public static function commentsOpen(dcPostsActions $pa, ArrayObject $post): void
|
public static function commentsOpen(ActionsPosts $pa, ArrayObject $post): void
|
||||||
{
|
{
|
||||||
foreach (self::getPostsIds($pa) as $post_id) {
|
foreach (self::getPostsIds($pa) as $post_id) {
|
||||||
self::updPostOption($post_id, 'post_open_comment', 1);
|
self::updPostOption($post_id, 'post_open_comment', 1);
|
||||||
}
|
}
|
||||||
dcPage::addSuccessNotice(__('Comments successfully opened.'));
|
Notices::addSuccessNotice(__('Comments successfully opened.'));
|
||||||
$pa->redirect(true);
|
$pa->redirect(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function commentsClose(dcPostsActions $pa, ArrayObject $post): void
|
public static function commentsClose(ActionsPosts $pa, ArrayObject $post): void
|
||||||
{
|
{
|
||||||
foreach (self::getPostsIds($pa) as $post_id) {
|
foreach (self::getPostsIds($pa) as $post_id) {
|
||||||
self::updPostOption($post_id, 'post_open_comment', 0);
|
self::updPostOption($post_id, 'post_open_comment', 0);
|
||||||
}
|
}
|
||||||
dcPage::addSuccessNotice(__('Comments successfully closed.'));
|
Notices::addSuccessNotice(__('Comments successfully closed.'));
|
||||||
$pa->redirect(true);
|
$pa->redirect(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function commentsDelete(dcPostsActions $pa, ArrayObject $post): void
|
public static function commentsDelete(ActionsPosts $pa, ArrayObject $post): void
|
||||||
{
|
{
|
||||||
//nullsafe
|
//nullsafe
|
||||||
if (is_null(dcCore::app()->blog)) {
|
if (is_null(dcCore::app()->blog)) {
|
||||||
|
@ -60,7 +63,7 @@ class BackendBehaviors
|
||||||
|
|
||||||
if (empty($_POST['confirmdeletecomments'])) {
|
if (empty($_POST['confirmdeletecomments'])) {
|
||||||
$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),
|
||||||
__('Delete posts comments') => '',
|
__('Delete posts comments') => '',
|
||||||
|
@ -94,30 +97,30 @@ class BackendBehaviors
|
||||||
self::delPostComments($post_id, false);
|
self::delPostComments($post_id, false);
|
||||||
self::updPostOption($post_id, 'nb_comment', 0);
|
self::updPostOption($post_id, 'nb_comment', 0);
|
||||||
}
|
}
|
||||||
dcPage::addSuccessNotice(__('Comments successfully deleted.'));
|
Notices::addSuccessNotice(__('Comments successfully deleted.'));
|
||||||
$pa->redirect(true);
|
$pa->redirect(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function trackbacksOpen(dcPostsActions $pa, ArrayObject $post): void
|
public static function trackbacksOpen(ActionsPosts $pa, ArrayObject $post): void
|
||||||
{
|
{
|
||||||
foreach (self::getPostsIds($pa) as $post_id) {
|
foreach (self::getPostsIds($pa) as $post_id) {
|
||||||
self::updPostOption($post_id, 'post_open_tb', 1);
|
self::updPostOption($post_id, 'post_open_tb', 1);
|
||||||
}
|
}
|
||||||
dcPage::addSuccessNotice(__('Trackbacks successfully opened.'));
|
Notices::addSuccessNotice(__('Trackbacks successfully opened.'));
|
||||||
$pa->redirect(true);
|
$pa->redirect(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function trackbacksClose(dcPostsActions $pa, ArrayObject $post): void
|
public static function trackbacksClose(ActionsPosts $pa, ArrayObject $post): void
|
||||||
{
|
{
|
||||||
foreach (self::getPostsIds($pa) as $post_id) {
|
foreach (self::getPostsIds($pa) as $post_id) {
|
||||||
self::updPostOption($post_id, 'post_open_tb', 0);
|
self::updPostOption($post_id, 'post_open_tb', 0);
|
||||||
}
|
}
|
||||||
dcPage::addSuccessNotice(__('Trackbacks successfully closed.'));
|
Notices::addSuccessNotice(__('Trackbacks successfully closed.'));
|
||||||
$pa->redirect(true);
|
$pa->redirect(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function trackbacksDelete(dcPostsActions $pa, ArrayObject $post): void
|
public static function trackbacksDelete(ActionsPosts $pa, ArrayObject $post): void
|
||||||
{
|
{
|
||||||
//nullsafe
|
//nullsafe
|
||||||
if (is_null(dcCore::app()->blog)) {
|
if (is_null(dcCore::app()->blog)) {
|
||||||
|
@ -128,7 +131,7 @@ class BackendBehaviors
|
||||||
|
|
||||||
if (empty($_POST['confirmdeletetrackbacks'])) {
|
if (empty($_POST['confirmdeletetrackbacks'])) {
|
||||||
$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),
|
||||||
__('Delete posts trackbacks') => '',
|
__('Delete posts trackbacks') => '',
|
||||||
|
@ -159,12 +162,12 @@ class BackendBehaviors
|
||||||
self::delPostComments($post_id, true);
|
self::delPostComments($post_id, true);
|
||||||
self::updPostOption($post_id, 'nb_trackback', 0);
|
self::updPostOption($post_id, 'nb_trackback', 0);
|
||||||
}
|
}
|
||||||
dcPage::addSuccessNotice(__('Trackbacks successfully deleted.'));
|
Notices::addSuccessNotice(__('Trackbacks successfully deleted.'));
|
||||||
$pa->redirect(true);
|
$pa->redirect(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getPostsIds(dcPostsActions $pa): array
|
private static function getPostsIds(ActionsPosts $pa): array
|
||||||
{
|
{
|
||||||
$posts_ids = $pa->getIDs();
|
$posts_ids = $pa->getIDs();
|
||||||
if (empty($posts_ids)) {
|
if (empty($posts_ids)) {
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief postslistOptions, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Dotclear\Plugin\postslistOptions;
|
||||||
|
|
||||||
|
use Dotclear\Module\MyPlugin;
|
||||||
|
|
||||||
|
class My extends MyPlugin
|
||||||
|
{
|
||||||
|
}
|
Loading…
Reference in New Issue