Compare commits

..

1 Commits

Author SHA1 Message Date
c757540ca4
upgrade to Dotclear 2.28 2023-10-20 18:17:42 +02:00
7 changed files with 116 additions and 132 deletions

View File

@ -1,37 +1,43 @@
postslistOptions 2023.08.13 postslistOptions 2023.10.20
=========================================================== ===========================================================
* Require Dotclear 2.27 * Require Dotclear 2.28
* Require PHP 7.4 * Require PHP 8.1
* Upgrade to Dotclear 2.27 * Upgrade to Dotclear 2.28
* Move third party repository
* Use Dotclear style for CHANGELOG postslistOptions 2023.08.13
===========================================================
postslistOptions 2023.04.23 * Require Dotclear 2.27
=========================================================== * Require PHP 7.4
* require dotclear 2.26 * Upgrade to Dotclear 2.27
* use latest dotclear namespace * Move third party repository
* remove magic * Use Dotclear style for CHANGELOG
* fix nullsafe warnings
postslistOptions 2023.04.23
postslistOptions 2023.03.21 ===========================================================
=========================================================== * require dotclear 2.26
* require Dotclear 2.25 * use latest dotclear namespace
* use namespace * remove magic
* fix nullsafe warnings
postslistOptions 2022.12.23
=========================================================== postslistOptions 2023.03.21
* fix permissions ===========================================================
* use anonymous function * require Dotclear 2.25
* use namespace
postslistOptions 2022.11.28
=========================================================== postslistOptions 2022.12.23
* Use SVG icon ===========================================================
* Update to Dotclear 2.24 * fix permissions
* use anonymous function
postslistOptions 2013.07.10
=========================================================== postslistOptions 2022.11.28
* Fixed action on multiple posts ===========================================================
* Use SVG icon
postslistOptions 0.1 20100910 * Update to Dotclear 2.24
===========================================================
postslistOptions 2013.07.10
===========================================================
* Fixed action on multiple posts
postslistOptions 0.1 20100910
===========================================================
* First lab release (closes #557) * First lab release (closes #557)

View File

@ -1,26 +1,23 @@
# README # README
[![Release](https://img.shields.io/badge/release-2023.08.13-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/postslistOptions/releases) [![Release](https://img.shields.io/badge/release-2023.08.13-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/postslistOptions/releases)
[![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)](https://git.dotclear.watch/JcDenis/postslistOptions/releases) ![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download) [![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/postslistOptions) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/postslistOptions)
[![License](https://img.shields.io/github/license/JcDenis/postslistOptions)](https://git.dotclear.watch/JcDenis/postslistOptions/blob/master/LICENSE) [![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/postslistOptions/src/branch/master/LICENSE)
## WHAT IS POSTsLISTOPTIONS ? ## ABOUT
"Posts list options" is a plugin for the open-source _postslistOptions_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
web publishing software called Dotclear.
It add options on the posts list action box like > Add options on the posts list action box like
open/close/delete comments/trackbacks on multiple posts. open/close/delete comments/trackbacks on multiple posts.
## REQUIREMENTS ## REQUIREMENTS
_postslistOptions_ requires: * Dotclear 2.28
* PHP 8.1
* admin permissions * Dotclear admin permissions
* Dotclear 2.27
* PHP 7.4
## USAGE ## USAGE
@ -31,12 +28,13 @@ Then this plugin adds options de the posts list actions box.
## LINKS ## LINKS
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html) * [License](https://git.dotclear.watch/JcDenis/postslistOptions/src/branch/master/LICENSE)
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/postslistOptions) or [GitHub Page](https://github.com/JcDenis/postslistOptions) * [Packages & details](https://git.dotclear.watch/JcDenis/postslistOptions/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/postslistOptions))
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/postslistOptions/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/postslistOptions) * [Sources & contributions](https://git.dotclear.watch/JcDenis/postslistOptions) (or on [GitHub](https://github.com/JcDenis/postslistOptions))
* [Issues & security](https://git.dotclear.watch/JcDenis/postslistOptions/issues) (or on [GitHub](https://github.com/JcDenis/postslistOptions/issues))
## CONTRIBUTORS ## CONTRIBUTORS
* Jean-Christian Denis * Jean-Christian Denis (author)
You are welcome to contribute to this code. You are welcome to contribute to this code.

View File

@ -1,32 +1,29 @@
<?php <?php
/** /**
* @brief postslistOptions, a plugin for Dotclear 2 * @file
* @brief The plugin postslistOptions definition
* @ingroup postslistOptions
* *
* @package Dotclear * @defgroup postslistOptions Plugin dcLog.
* @subpackage Plugin
* *
* @author Jean-Christian Denis and Contributors * Add some options on admin posts list.
* *
* @copyright Jean-Christian Denis * @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_RC_PATH')) { declare(strict_types=1);
return null;
}
$this->registerModule( $this->registerModule(
'Posts list options', 'Posts list options',
'Add some options on admin posts list', 'Add some options on admin posts list',
'Jean-Christian Denis and Contributors', 'Jean-Christian Denis and Contributors',
'2023.08.13', '2023.10.20',
[ [
'requires' => [['core', '2.27']], 'requires' => [['core', '2.28']],
'permissions' => dcCore::app()->auth->makePermissions([ 'permissions' => 'My',
dcCore::app()->auth::PERMISSION_ADMIN, 'type' => 'plugin',
]), 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'type' => 'plugin', 'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues', 'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
] ]
); );

View File

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="postslistOptions"> <module id="postslistOptions">
<name>Posts list options</name> <name>Posts list options</name>
<version>2023.08.13</version> <version>2023.10.20</version>
<author>Jean-Christian Denis and Contributors</author> <author>Jean-Christian Denis and Contributors</author>
<desc>Add some options on admin posts list</desc> <desc>Add some options on admin posts list</desc>
<file>https://git.dotclear.watch/JcDenis/postslistOptions/releases/download/v2023.08.13/plugin-postslistOptions.zip</file> <file>https://git.dotclear.watch/JcDenis/postslistOptions/releases/download/v2023.10.20/plugin-postslistOptions.zip</file>
<da:dcmin>2.27</da:dcmin> <da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/postslistOptions/src/branch/master/README.md</da:details> <da:details>https://git.dotclear.watch/JcDenis/postslistOptions/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/postslistOptions/issues</da:support> <da:support>https://git.dotclear.watch/JcDenis/postslistOptions/issues</da:support>
</module> </module>

View File

@ -1,28 +1,20 @@
<?php <?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); declare(strict_types=1);
namespace Dotclear\Plugin\postslistOptions; namespace Dotclear\Plugin\postslistOptions;
use ArrayObject; use ArrayObject;
use dcCore; use Dotclear\App;
use Dotclear\Core\Backend\Action\ActionsPosts; use Dotclear\Core\Backend\Action\ActionsPosts;
use Dotclear\Core\Process; use Dotclear\Core\Process;
/** /**
* Improve admin class * @brief postslistOptions backend class.
* @ingroup postslistOptions
* *
* Add menu and dashboard icons, load Improve action modules. * @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
class Backend extends Process class Backend extends Process
{ {
@ -37,7 +29,7 @@ class Backend extends Process
return false; return false;
} }
dcCore::app()->addBehavior('adminPostsActions', function (ActionsPosts $pa) { App::behavior()->addBehavior('adminPostsActions', function (ActionsPosts $pa) {
$pa->addAction( $pa->addAction(
[ [
__('Comments') => [ __('Comments') => [

View File

@ -1,22 +1,11 @@
<?php <?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); declare(strict_types=1);
namespace Dotclear\Plugin\postslistOptions; namespace Dotclear\Plugin\postslistOptions;
use ArrayObject; use ArrayObject;
use dcBlog; use Dotclear\App;
use dcCore;
use Dotclear\Core\Backend\{ use Dotclear\Core\Backend\{
Notices, Notices,
Page Page
@ -32,6 +21,13 @@ use Dotclear\Helper\Html\Form\{
use Dotclear\Helper\Html\Html; use Dotclear\Helper\Html\Html;
use Exception; use Exception;
/**
* @brief postslistOptions backend behaviors class.
* @ingroup postslistOptions
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class BackendBehaviors class BackendBehaviors
{ {
public static function commentsOpen(ActionsPosts $pa, ArrayObject $post): void public static function commentsOpen(ActionsPosts $pa, ArrayObject $post): void
@ -54,8 +50,7 @@ class BackendBehaviors
public static function commentsDelete(ActionsPosts $pa, ArrayObject $post): void public static function commentsDelete(ActionsPosts $pa, ArrayObject $post): void
{ {
//nullsafe if (!App::blog()->isDefined()) {
if (is_null(dcCore::app()->blog)) {
return; return;
} }
@ -64,9 +59,9 @@ class BackendBehaviors
if (empty($_POST['confirmdeletecomments'])) { if (empty($_POST['confirmdeletecomments'])) {
$pa->beginPage( $pa->beginPage(
Page::breadcrumb([ Page::breadcrumb([
Html::escapeHTML(dcCore::app()->blog->name) => '', Html::escapeHTML(App::blog()->name()) => '',
$pa->getCallerTitle() => $pa->getRedirection(true), $pa->getCallerTitle() => $pa->getRedirection(true),
__('Delete posts comments') => '', __('Delete posts comments') => '',
]) ])
); );
@ -78,16 +73,14 @@ class BackendBehaviors
(new Text('', $pa->getCheckboxes())), (new Text('', $pa->getCheckboxes())),
(new Text('p', __('Are you sure you want to delete all comments?'))), (new Text('p', __('Are you sure you want to delete all comments?'))),
(new Para()) (new Para())
->__call('items', [array_merge( ->__call('items', [
[ (new Submit(['do']))
(new Submit(['do'])) ->__call('value', [__('yes')]),
->__call('value', [__('yes')]), App::nonce()->formNonce(),
dcCore::app()->formNonce(false), (new Hidden(['action'], 'commentsdelete')),
(new Hidden(['action'], 'commentsdelete')), (new Hidden(['confirmdeletecomments'], '1')),
(new Hidden(['confirmdeletecomments'], '1')), ... $pa->hiddenFields(),
], ]),
$pa->hiddenFields(),
)]),
]]) ]])
->render(); ->render();
@ -122,8 +115,7 @@ class BackendBehaviors
public static function trackbacksDelete(ActionsPosts $pa, ArrayObject $post): void public static function trackbacksDelete(ActionsPosts $pa, ArrayObject $post): void
{ {
//nullsafe if (!App::blog()->isDefined()) {
if (is_null(dcCore::app()->blog)) {
return; return;
} }
@ -132,9 +124,9 @@ class BackendBehaviors
if (empty($_POST['confirmdeletetrackbacks'])) { if (empty($_POST['confirmdeletetrackbacks'])) {
$pa->beginPage( $pa->beginPage(
Page::breadcrumb([ Page::breadcrumb([
Html::escapeHTML(dcCore::app()->blog->name) => '', Html::escapeHTML(App::blog()->name()) => '',
$pa->getCallerTitle() => $pa->getRedirection(true), $pa->getCallerTitle() => $pa->getRedirection(true),
__('Delete posts trackbacks') => '', __('Delete posts trackbacks') => '',
]) ])
); );
@ -146,13 +138,13 @@ class BackendBehaviors
(new Text('', $pa->getCheckboxes())), (new Text('', $pa->getCheckboxes())),
(new Text('p', __('Are you sure you want to delete all trackbacks?'))), (new Text('p', __('Are you sure you want to delete all trackbacks?'))),
(new Para()) (new Para())
->__call('items', [array_merge([ ->__call('items', [
(new Submit(['do'])) (new Submit(['do']))
->__call('value', [__('yes')]), ->__call('value', [__('yes')]),
dcCore::app()->formNonce(false), App::nonce()->formNonce(),
(new Hidden(['action'], 'trackbacksdelete')), (new Hidden(['action'], 'trackbacksdelete')),
(new Hidden(['confirmdeletetrackbacks'], '1')), (new Hidden(['confirmdeletetrackbacks'], '1')),
], $pa->hiddenFields())]), ... $pa->hiddenFields()]),
]]) ]])
->render(); ->render();
@ -179,28 +171,26 @@ class BackendBehaviors
private static function updPostOption(int $id, string $option, int $value): void private static function updPostOption(int $id, string $option, int $value): void
{ {
//nullsafe if (!App::blog()->isDefined()) {
if (is_null(dcCore::app()->blog)) {
return; return;
} }
$id = abs((int) $id); $id = abs((int) $id);
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcBlog::POST_TABLE_NAME); $cur = App::blog()->openPostCursor();
$cur->setField($option, $value); $cur->setField($option, $value);
$cur->setField('post_upddt', date('Y-m-d H:i:s')); $cur->setField('post_upddt', date('Y-m-d H:i:s'));
$cur->update( $cur->update(
'WHERE post_id = ' . $id . ' ' . 'WHERE post_id = ' . $id . ' ' .
"AND blog_id = '" . dcCore::app()->con->escapeStr((string) dcCore::app()->blog->id) . "' " "AND blog_id = '" . App::con()->escapeStr(App::blog()->id()) . "' "
); );
dcCore::app()->blog->triggerBlog(); App::blog()->triggerBlog();
} }
private static function delPostComments(int $id, bool $tb = false): void private static function delPostComments(int $id, bool $tb = false): void
{ {
//nullsafe if (!App::blog()->isDefined()) {
if (is_null(dcCore::app()->blog)) {
return; return;
} }
@ -209,11 +199,11 @@ class BackendBehaviors
'post_id' => abs((int) $id), 'post_id' => abs((int) $id),
'comment_trackback' => $tb ? 1 : 0, 'comment_trackback' => $tb ? 1 : 0,
]; ];
$comments = dcCore::app()->blog->getComments($params); $comments = App::blog()->getComments($params);
while ($comments->fetch()) { while ($comments->fetch()) {
// slower but preserve behaviors // slower but preserve behaviors
dcCore::app()->blog->delComment($comments->f('comment_id')); App::blog()->delComment($comments->f('comment_id'));
} }
} }
} }

View File

@ -18,4 +18,5 @@ use Dotclear\Module\MyPlugin;
class My extends MyPlugin class My extends MyPlugin
{ {
// Use defautl permissions
} }