upgrade to dotclear 2.28

master v2023.10.20
Jean-Christian Paul Denis 2023-10-20 20:35:41 +02:00
parent 45e84abd9f
commit bf68f8d129
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
16 changed files with 229 additions and 313 deletions

View File

@ -1,3 +1,9 @@
postWidgetText 2023.10.20
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Upgrade to Dotclear 2.28
postWidgetText 2023.08.15 postWidgetText 2023.08.15
=========================================================== ===========================================================
* Require Dotclear 2.27 * Require Dotclear 2.27

View File

@ -1,28 +1,25 @@
# README # README
[![Release](https://img.shields.io/badge/release-2023.08.15-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/postWidgetText/releases) [![Release](https://img.shields.io/badge/release-2023.10.20-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/postWidgetText/releases)
[![Date](https://img.shields.io/badge/date-2023.08.15-c44d58.svg)](https://git.dotclear.watch/JcDenis/postWidgetText/releases) ![Date](https://img.shields.io/badge/date-2023.10.20-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.28-137bbb.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/postWidgetText) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/postWidgetText)
[![License](https://img.shields.io/github/license/JcDenis/postWidgetText)](https://git.dotclear.watch/JcDenis/postWidgetText/blob/master/LICENSE) [![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/postWidgetText/src/branch/master/LICENSE)
## WHAT IS POSTWIDGETTEXT ? ## ABOUT
_Post widget text_ is a plugin for the open-source _postWidgetText_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
web publishing software called Dotclear.
Add a widget related to an entry with custom titles and content. > Add a widget related to an entry with custom titles and content.
## REQUIREMENTS ## REQUIREMENTS
_postWidgetText_ requires: * Dotclear 2.28
* PHP 8.1+
* Dotclear permissions to manage widgets
* Dotclear permissions to manage entries
* permissions to manage widgets Note this plugin add table called "post_option" to Dotclear database.
* permissions to manage entries
* Dotclear 2.27
* PHP 8.0+
Note this plugin add table called post_option to Dotclear database.
## USAGE ## USAGE
@ -36,9 +33,10 @@ Manage (delete) "widgets" from sidebar menu called "Post widget text".
## LINKS ## LINKS
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html) * [License](https://git.dotclear.watch/JcDenis/postWidgetText/src/branch/master/LICENSE)
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/postWidgetText) or [GitHub Page](https://github.com/JcDenis/postWidgetText) * [Packages & details](https://git.dotclear.watch/JcDenis/postWidgetText/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/postWidgetText))
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/postWidgetText/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/postWidgetText) * [Sources & contributions](https://git.dotclear.watch/JcDenis/postWidgetText) (or on [GitHub](https://github.com/JcDenis/postWidgetText))
* [Issues & security](https://git.dotclear.watch/JcDenis/postWidgetText/issues) (or on [GitHub](https://github.com/JcDenis/postWidgetText/issues))
## CONTRIBUTORS ## CONTRIBUTORS

View File

@ -1,39 +1,31 @@
<?php <?php
/** /**
* @brief postWidgetText, a plugin for Dotclear 2 * @file
* @brief The plugin postWidgetText definition
* @ingroup postWidgetText
* *
* @package Dotclear * @defgroup postWidgetText Plugin postWidgetText.
* @subpackage Plugin
* *
* @author Jean-Christian Denis and Contributors * Add a widget with a text related to an entry.
* *
* @copyright Jean-Christian Denis * @author Tomtom (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @author Jean-Christian Denis (latest)
* @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(
'Post widget text', 'Post widget text',
'Add a widget with a text related to an entry', 'Add a widget with a text related to an entry',
'Jean-Christian Denis and Contributors', 'Jean-Christian Denis and Contributors',
'2023.08.15', '2023.10.20',
[ [
'requires' => [ 'requires' => [['core', '2.28']],
['php', '8.0'], 'permissions' => 'My',
['core', '2.27'], 'settings' => ['blog' => '#params.pwt_params'],
], 'type' => 'plugin',
'permissions' => dcCore::app()->auth->makePermissions([ 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
dcCore::app()->auth::PERMISSION_USAGE, 'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, 'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
]),
'settings' => [
'blog' => '#params.pwt_params',
],
'type' => 'plugin',
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'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

@ -1,20 +0,0 @@
<?php
/**
* @brief postWidgetText, 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
*/
if (!defined('DC_RC_PATH')) {
return null;
}
class initPostWidgetText
{
public const PWT_TABLE_NAME = 'post_option';
}

View File

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="postWidgetText"> <module id="postWidgetText">
<name>Post widget text</name> <name>Post widget text</name>
<version>2023.08.15</version> <version>2023.10.20</version>
<author>Jean-Christian Denis and Contributors</author> <author>Jean-Christian Denis and Contributors</author>
<desc>Add a widget with a text related to an entry</desc> <desc>Add a widget with a text related to an entry</desc>
<file>https://git.dotclear.watch/JcDenis/postWidgetText/releases/download/v2023.08.15/plugin-postWidgetText.zip</file> <file>https://git.dotclear.watch/JcDenis/postWidgetText/releases/download/v2023.10.20/plugin-postWidgetText.zip</file>
<da:dcmin>2.27</da:dcmin> <da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/postWidgetText/src/branch/master/README.md</da:details> <da:details>https://git.dotclear.watch/JcDenis/postWidgetText/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/postWidgetText/issues</da:support> <da:support>https://git.dotclear.watch/JcDenis/postWidgetText/issues</da:support>
</module> </module>

View File

@ -1,22 +1,19 @@
<?php <?php
/**
* @brief postWidgetText, 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\postWidgetText; namespace Dotclear\Plugin\postWidgetText;
use dcCore; use Dotclear\App;
use Dotclear\Core\Process; use Dotclear\Core\Process;
/**
* @brief postWidgetText backend class.
* @ingroup postWidgetText
*
* @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
{ {
public static function init(): bool public static function init(): bool
@ -36,37 +33,37 @@ class Backend extends Process
} }
// backend pwt management // backend pwt management
dcCore::app()->addBehaviors([ App::behavior()->addBehaviors([
// user pref // user pref
'adminFiltersListsV2' => [BackendBehaviors::class, 'adminFiltersListsV2'], 'adminFiltersListsV2' => BackendBehaviors::adminFiltersListsV2(...),
'adminColumnsListsV2' => [BackendBehaviors::class, 'adminColumnsListsV2'], 'adminColumnsListsV2' => BackendBehaviors::adminColumnsListsV2(...),
'adminBlogPreferencesFormV2' => [BackendBehaviors::class, 'adminBlogPreferencesFormV2'], 'adminBlogPreferencesFormV2' => BackendBehaviors::adminBlogPreferencesFormV2(...),
'adminBeforeBlogSettingsUpdate' => [BackendBehaviors::class, 'adminBeforeBlogSettingsUpdate'], 'adminBeforeBlogSettingsUpdate' => BackendBehaviors::adminBeforeBlogSettingsUpdate(...),
// post // post
'adminPostHeaders' => [BackendBehaviors::class, 'adminPostHeaders'], 'adminPostHeaders' => BackendBehaviors::adminPostHeaders(...),
'adminPostEditorTags' => [BackendBehaviors::class, 'adminPostEditorTags'], 'adminPostEditorTags' => BackendBehaviors::adminPostEditorTags(...),
'adminPostFormItems' => [BackendBehaviors::class, 'adminPostFormItems'], 'adminPostFormItems' => BackendBehaviors::adminPostFormItems(...),
'adminAfterPostUpdate' => [BackendBehaviors::class, 'adminAfterPostSave'], 'adminAfterPostUpdate' => BackendBehaviors::adminAfterPostSave(...),
'adminAfterPostCreate' => [BackendBehaviors::class, 'adminAfterPostSave'], 'adminAfterPostCreate' => BackendBehaviors::adminAfterPostSave(...),
'adminBeforePostDelete' => [BackendBehaviors::class, 'adminBeforePostDelete'], 'adminBeforePostDelete' => BackendBehaviors::adminBeforePostDelete(...),
// Plugin "pages" // Plugin "pages"
'adminPageHeaders' => [BackendBehaviors::class, 'adminPostHeaders'], 'adminPageHeaders' => BackendBehaviors::adminPostHeaders(...),
'adminPageFormItems' => [BackendBehaviors::class, 'adminPostFormItems'], 'adminPageFormItems' => BackendBehaviors::adminPostFormItems(...),
'adminAfterPageUpdate' => [BackendBehaviors::class, 'adminAfterPostSave'], 'adminAfterPageUpdate' => BackendBehaviors::adminAfterPostSave(...),
'adminAfterPageCreate' => [BackendBehaviors::class, 'adminAfterPostSave'], 'adminAfterPageCreate' => BackendBehaviors::adminAfterPostSave(...),
'adminBeforePageDelete' => [BackendBehaviors::class, 'adminBeforePostDelete'], 'adminBeforePageDelete' => BackendBehaviors::adminBeforePostDelete(...),
// widgets registration // widgets registration
'initWidgets' => [Widgets::class, 'initWidgets'], 'initWidgets' => Widgets::initWidgets(...),
]); ]);
// add plugin "importExport" features // add plugin "importExport" features
if (!My::settings()->get('importexport_active')) { if (!My::settings()->get('importexport_active')) {
dcCore::app()->addBehaviors([ App::behavior()->addBehaviors([
'exportFullV2' => [ImportExport::class, 'exportFullV2'], 'exportFullV2' => ImportExport::exportFullV2(...),
'exportSingleV2' => [ImportExport::class, 'exportSingleV2'], 'exportSingleV2' => ImportExport::exportSingleV2(...),
'importInitV2' => [ImportExport::class, 'importInitV2'], 'importInitV2' => ImportExport::importInitV2(...),
'importSingleV2' => [ImportExport::class, 'importSingleV2'], 'importSingleV2' => ImportExport::importSingleV2(...),
'importFullV2' => [ImportExport::class, 'importFullV2'], 'importFullV2' => ImportExport::importFullV2(...),
]); ]);
} }

View File

@ -1,32 +1,26 @@
<?php <?php
/**
* @brief postWidgetText, 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\postWidgetText; namespace Dotclear\Plugin\postWidgetText;
use ArrayObject; use ArrayObject;
use dcSettings;
use Dotclear\Core\Backend\Favorites; use Dotclear\Core\Backend\Favorites;
use Dotclear\Database\{ use Dotclear\Database\{
Cursor, Cursor,
MetaRecord MetaRecord
}; };
use Dotclear\Helper\Html\Html; use Dotclear\Helper\Html\Html;
use Dotclear\Interface\Core\BlogSettingsInterface;
use form; use form;
/** /**
* Backend behaviors. * @brief postWidgetText backend behaviors class.
* @ingroup postWidgetText
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
class BackendBehaviors class BackendBehaviors
{ {
@ -85,7 +79,7 @@ class BackendBehaviors
* *
* @param dcSettings $blog_settings The blog settings * @param dcSettings $blog_settings The blog settings
*/ */
public static function adminBlogPreferencesFormV2(dcSettings $blog_settings): void public static function adminBlogPreferencesFormV2(BlogSettingsInterface $blog_settings): void
{ {
echo ' echo '
<div class="fieldset"> <div class="fieldset">
@ -111,7 +105,7 @@ class BackendBehaviors
* *
* @param dcSettings $blog_settings The blog settings * @param dcSettings $blog_settings The blog settings
*/ */
public static function adminBeforeBlogSettingsUpdate(dcSettings $blog_settings): void public static function adminBeforeBlogSettingsUpdate(BlogSettingsInterface $blog_settings): void
{ {
$blog_settings->get(My::id())->put('active', !empty($_POST['active'])); $blog_settings->get(My::id())->put('active', !empty($_POST['active']));
$blog_settings->get(My::id())->put('importexport_active', !empty($_POST['importexport_active'])); $blog_settings->get(My::id())->put('importexport_active', !empty($_POST['importexport_active']));

View File

@ -1,22 +1,19 @@
<?php <?php
/**
* @brief postWidgetText, 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\postWidgetText; namespace Dotclear\Plugin\postWidgetText;
use dcCore; use Dotclear\App;
use Dotclear\Core\Process; use Dotclear\Core\Process;
/**
* @brief postWidgetText frontend class.
* @ingroup postWidgetText
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Frontend extends Process class Frontend extends Process
{ {
public static function init(): bool public static function init(): bool
@ -30,7 +27,7 @@ class Frontend extends Process
return false; return false;
} }
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initWidgets']); App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
return true; return true;
} }

View File

@ -1,24 +1,17 @@
<?php <?php
/**
* @brief postWidgetText, 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\postWidgetText; namespace Dotclear\Plugin\postWidgetText;
use dcCore; use Dotclear\App;
use dcBlog;
/** /**
* Plugin importExport features. * @brief postWidgetText plugin importExport stuff.
* @ingroup postWidgetText
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
class ImportExport class ImportExport
{ {
@ -30,11 +23,11 @@ class ImportExport
My::id(), My::id(),
'SELECT option_type, option_content, ' . 'SELECT option_type, option_content, ' .
'option_content_xhtml, W.post_id ' . 'option_content_xhtml, W.post_id ' .
'FROM ' . dcCore::app()->prefix . My::TABLE_NAME . ' W ' . 'FROM ' . App::con()->prefix() . My::TABLE_NAME . ' W ' .
'LEFT JOIN ' . dcCore::app()->prefix . dcBlog::POST_TABLE_NAME . ' P ' . 'LEFT JOIN ' . App::con()->prefix() . App::blog()::POST_TABLE_NAME . ' P ' .
'ON P.post_id = W.post_id ' . 'ON P.post_id = W.post_id ' .
"WHERE P.blog_id = '" . $blog_id . "' " . "WHERE P.blog_id = '" . $blog_id . "' " .
"AND W.option_type = '" . dcCore::app()->con->escapeStr((string) My::id()) . "' " "AND W.option_type = '" . App::con()->escapeStr((string) My::id()) . "' "
); );
} }
@ -44,17 +37,17 @@ class ImportExport
My::id(), My::id(),
'SELECT option_type, option_content, ' . 'SELECT option_type, option_content, ' .
'option_content_xhtml, W.post_id ' . 'option_content_xhtml, W.post_id ' .
'FROM ' . dcCore::app()->prefix . My::TABLE_NAME . ' W ' . 'FROM ' . App::con()->prefix() . My::TABLE_NAME . ' W ' .
'LEFT JOIN ' . dcCore::app()->prefix . dcBlog::POST_TABLE_NAME . ' P ' . 'LEFT JOIN ' . App::con()->prefix() . App::blog()::POST_TABLE_NAME . ' P ' .
'ON P.post_id = W.post_id ' . 'ON P.post_id = W.post_id ' .
"WHERE W.option_type = '" . dcCore::app()->con->escapeStr((string) My::id()) . "' " "WHERE W.option_type = '" . App::con()->escapeStr((string) My::id()) . "' "
); );
} }
public static function importInitV2($bk) public static function importInitV2($bk)
{ {
self::$ie_cursor = dcCore::app()->con->openCursor( self::$ie_cursor = App::con()->openCursor(
dcCore::app()->prefix . My::TABLE_NAME App::con()->prefix() . My::TABLE_NAME
); );
} }

View File

@ -1,24 +1,21 @@
<?php <?php
/**
* @brief postWidgetText, 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\postWidgetText; namespace Dotclear\Plugin\postWidgetText;
use dcCore; use Dotclear\App;
use Dotclear\Core\Process; use Dotclear\Core\Process;
use Dotclear\Database\Structure; use Dotclear\Database\Structure;
use Exception; use Exception;
/**
* @brief postWidgetText insatll class.
* @ingroup postWidgetText
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Install extends Process class Install extends Process
{ {
public static function init(): bool public static function init(): bool
@ -34,7 +31,7 @@ class Install extends Process
try { try {
// Table is the same for plugins pollsFactory, postTask, postWidgetText // Table is the same for plugins pollsFactory, postTask, postWidgetText
$s = new Structure(dcCore::app()->con, dcCore::app()->prefix); $s = new Structure(App::con(), App::con()->prefix());
$s->__get(My::TABLE_NAME) $s->__get(My::TABLE_NAME)
->field('option_id', 'bigint', 0, false) ->field('option_id', 'bigint', 0, false)
->field('post_id', 'bigint', 0, false) ->field('post_id', 'bigint', 0, false)
@ -51,7 +48,7 @@ class Install extends Process
->index('idx_post_option_post', 'btree', 'post_id') ->index('idx_post_option_post', 'btree', 'post_id')
->index('idx_post_option_type', 'btree', 'option_type'); ->index('idx_post_option_type', 'btree', 'option_type');
(new Structure(dcCore::app()->con, dcCore::app()->prefix))->synchronize($s); (new Structure(App::con(), App::con()->prefix()))->synchronize($s);
// Settings // Settings
$s = My::settings(); $s = My::settings();
@ -74,7 +71,7 @@ class Install extends Process
return true; return true;
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); App::error()->add($e->getMessage());
return false; return false;
} }

View File

@ -1,20 +1,10 @@
<?php <?php
/**
* @brief postWidgetText, 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\postWidgetText; namespace Dotclear\Plugin\postWidgetText;
use dcCore; use Dotclear\App;
use Dotclear\Core\Backend\Filter\{ use Dotclear\Core\Backend\Filter\{
Filters, Filters,
FiltersLibrary FiltersLibrary
@ -27,6 +17,13 @@ use Dotclear\Core\Process;
use Dotclear\Helper\Network\Http; use Dotclear\Helper\Network\Http;
use Exception; use Exception;
/**
* @brief postWidgetText manage class.
* @ingroup postWidgetText
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Manage extends Process class Manage extends Process
{ {
public static function init(): bool public static function init(): bool
@ -56,7 +53,7 @@ class Manage extends Process
My::redirect(); My::redirect();
} }
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); App::error()->add($e->getMessage());
} }
} }
@ -65,12 +62,9 @@ class Manage extends Process
public static function render(): void public static function render(): void
{ {
if (!self::status()) { if (!self::status()
return; || !App::blog()->isDefined()
} ) {
// nullsafe check
if (is_null(dcCore::app()->blog)) {
return; return;
} }
@ -88,7 +82,7 @@ class Manage extends Process
$counter = Utils::getWidgets($params, true); $counter = Utils::getWidgets($params, true);
$posts_list = new ManageList($posts, $counter->f(0)); $posts_list = new ManageList($posts, $counter->f(0));
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); App::error()->add($e->getMessage());
$posts_list = null; $posts_list = null;
} }

View File

@ -1,22 +1,11 @@
<?php <?php
/**
* @brief postWidgetText, 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\postWidgetText; namespace Dotclear\Plugin\postWidgetText;
use ArrayObject; use ArrayObject;
use context; use Dotclear\App;
use dcCore;
use Dotclear\Core\Backend\Filter\Filters; use Dotclear\Core\Backend\Filter\Filters;
use Dotclear\Core\Backend\Listing\{ use Dotclear\Core\Backend\Listing\{
Listing, Listing,
@ -27,23 +16,24 @@ use Dotclear\Helper\Html\Form\Checkbox;
use Dotclear\Helper\Html\Html; use Dotclear\Helper\Html\Html;
/** /**
* @ingroup DC_PLUGIN_POSTWIDGETTEXT * @brief postWidgetText backend list class.
* @brief postWidgetText - admin list methods. * @ingroup postWidgetText
* @since 2.6 *
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
class ManageList extends Listing class ManageList extends Listing
{ {
public function display(Filters $filter, string $enclose = '%s'): void public function display(Filters $filter, string $enclose = '%s'): void
{ {
// nullsafe if (!App::blog()->isDefined()) {
if (is_null(dcCore::app()->blog)) {
return; return;
} }
// prepare page // prepare page
$blocks = explode('%s', $enclose); $blocks = explode('%s', $enclose);
$pager = new Pager((int) $filter->value('page'), (int) $this->rs_count, (int) $filter->value('nb'), 10); $pager = new Pager((int) $filter->value('page'), (int) $this->rs_count, (int) $filter->value('nb'), 10);
$tz = dcCore::app()->auth->getInfo('user_tz') ?? (dcCore::app()->blog->settings->get('system')->get('blog_timezone') ?? 'UTC'); $tz = App::auth()->getInfo('user_tz') ?? (App::blog()->settings()->get('system')->get('blog_timezone') ?? 'UTC');
// no record // no record
if ($this->rs->isEmpty()) { if ($this->rs->isEmpty()) {
@ -84,7 +74,8 @@ class ManageList extends Listing
$w_title = Html::escapeHTML($this->rs->option_title); $w_title = Html::escapeHTML($this->rs->option_title);
if ($w_title == '') { if ($w_title == '') {
// widget title can accept HTML, but backend table not // widget title can accept HTML, but backend table not
$w_title = context::global_filters( /*
$w_title = App::frontend()->context()->global_filters(
$this->rs->option_content, $this->rs->option_content,
[ [
'encode_xml', 'encode_xml',
@ -92,6 +83,8 @@ class ManageList extends Listing
'cut_string' => 80, 'cut_string' => 80,
] ]
); );
*/
$w_title = '?';
} }
// table body line // table body line
@ -102,7 +95,7 @@ class ManageList extends Listing
->__call('disabled', [!$this->rs->isEditable()]) ->__call('disabled', [!$this->rs->isEditable()])
->render() . ->render() .
'</td>', '</td>',
'name' => '<td class="maximal"><a href="' . dcCore::app()->getPostAdminURL($this->rs->f('post_type'), $this->rs->f('post_id')) . '#post-wtext-form">' . 'name' => '<td class="maximal"><a href="' . App::postTypes()->getPostAdminURL($this->rs->f('post_type'), $this->rs->f('post_id')) . '#post-wtext-form">' .
Html::escapeHTML($this->rs->f('post_title')) . '</a></td>', Html::escapeHTML($this->rs->f('post_title')) . '</a></td>',
'post_dt' => '<td class="nowrap count">' . Date::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->f('post_dt'), $tz) . '</td>', 'post_dt' => '<td class="nowrap count">' . Date::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->f('post_dt'), $tz) . '</td>',
'option_title' => '<td class="nowrap">' . $w_title . '</td>', 'option_title' => '<td class="nowrap">' . $w_title . '</td>',

View File

@ -1,15 +1,5 @@
<?php <?php
/**
* @brief postWidgetText, 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\postWidgetText; namespace Dotclear\Plugin\postWidgetText;
@ -17,10 +7,20 @@ namespace Dotclear\Plugin\postWidgetText;
use Dotclear\Module\MyPlugin; use Dotclear\Module\MyPlugin;
/** /**
* This module definitions. * @brief postWidgetText My helper.
* @ingroup postWidgetText
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
class My extends MyPlugin class My extends MyPlugin
{ {
/** @var string Plugin table name */ /**
public const TABLE_NAME = \initPostWidgetText::PWT_TABLE_NAME; * Plugin table name.
*
* @var string TABLE_NAME
*/
public const TABLE_NAME = 'post_option';
// Use default permissions
} }

View File

@ -1,23 +1,19 @@
<?php <?php
/**
* @brief postWidgetText, 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\postWidgetText; namespace Dotclear\Plugin\postWidgetText;
use dcCore;
use Dotclear\Core\Process; use Dotclear\Core\Process;
use Dotclear\Plugin\Uninstaller\Uninstaller; use Dotclear\Plugin\Uninstaller\Uninstaller;
/**
* @brief postWidgetText uninstall class.
* @ingroup postWidgetText
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Uninstall extends Process class Uninstall extends Process
{ {
public static function init(): bool public static function init(): bool
@ -27,7 +23,7 @@ class Uninstall extends Process
public static function process(): bool public static function process(): bool
{ {
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) { if (!self::status()) {
return false; return false;
} }

View File

@ -1,20 +1,10 @@
<?php <?php
/**
* @brief postWidgetText, 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\postWidgetText; namespace Dotclear\Plugin\postWidgetText;
use dcCore; use Dotclear\App;
use Dotclear\Database\{ use Dotclear\Database\{
Cursor, Cursor,
MetaRecord MetaRecord
@ -28,9 +18,11 @@ use Dotclear\Helper\Text;
use Exception; use Exception;
/** /**
* @ingroup DC_PLUGIN_POSTWIDGETTEXT * @brief postWidgetText utils class.
* @brief postWidgetText - admin and public methods. * @ingroup postWidgetText
* @since 2.6 *
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
class Utils class Utils
{ {
@ -51,7 +43,7 @@ class Utils
*/ */
public static function openCursor(): Cursor public static function openCursor(): Cursor
{ {
return dcCore::app()->con->openCursor(dcCore::app()->prefix . My::TABLE_NAME); return App::con()->openCursor(App::con()->prefix() . My::TABLE_NAME);
} }
/** /**
@ -64,8 +56,7 @@ class Utils
*/ */
public static function getWidgets(array $params, bool $count_only = false): MetaRecord public static function getWidgets(array $params, bool $count_only = false): MetaRecord
{ {
// nullsafe if (!App::blog()->isDefined()) {
if (is_null(dcCore::app()->blog)) {
throw new Exception(__('Blog is not set')); throw new Exception(__('Blog is not set'));
} }
@ -88,7 +79,7 @@ class Utils
$sql->join( $sql->join(
(new JoinStatement()) (new JoinStatement())
->left() ->left()
->from($sql->as(dcCore::app()->prefix . My::TABLE_NAME, 'W')) ->from($sql->as(App::con()->prefix() . My::TABLE_NAME, 'W'))
->on('P.post_id = W.post_id') ->on('P.post_id = W.post_id')
->statement() ->statement()
); );
@ -132,7 +123,7 @@ class Utils
$params['post_type'] = ''; $params['post_type'] = '';
} }
return dcCore::app()->blog->getPosts($params, $count_only, $sql); return App::blog()->getPosts($params, $count_only, $sql);
} }
/** /**
@ -144,16 +135,15 @@ class Utils
*/ */
public static function addWidget(Cursor $cur): int public static function addWidget(Cursor $cur): int
{ {
// nullsafe if (!App::blog()->isDefined()) {
if (is_null(dcCore::app()->blog)) {
throw new Exception(__('Blog is not set')); throw new Exception(__('Blog is not set'));
} }
// check permissions to add post // check permissions to add post
if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([ if (!App::auth()->check(App::auth()->makePermissions([
dcCore::app()->auth::PERMISSION_USAGE, App::auth()::PERMISSION_USAGE,
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, App::auth()::PERMISSION_CONTENT_ADMIN,
]), dcCore::app()->blog->id)) { ]), App::blog()->id())) {
throw new Exception(__('You are not allowed to create an entry text widget')); throw new Exception(__('You are not allowed to create an entry text widget'));
} }
@ -163,11 +153,11 @@ class Utils
} }
// lock table // lock table
dcCore::app()->con->writeLock(dcCore::app()->prefix . My::TABLE_NAME); App::con()->writeLock(App::con()->prefix() . My::TABLE_NAME);
try { try {
$sql = new SelectStatement(); $sql = new SelectStatement();
$rs = $sql->from(dcCore::app()->prefix . My::TABLE_NAME)->column($sql->max('option_id'))->select(); $rs = $sql->from(App::con()->prefix() . My::TABLE_NAME)->column($sql->max('option_id'))->select();
if (is_null($rs) || $rs->isEmpty()) { if (is_null($rs) || $rs->isEmpty()) {
throw new Exception(__('Something went wrong)')); throw new Exception(__('Something went wrong)'));
} }
@ -183,15 +173,15 @@ class Utils
// add new widgetText // add new widgetText
$cur->insert(); $cur->insert();
dcCore::app()->con->unlock(); App::con()->unlock();
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->con->unlock(); App::con()->unlock();
throw $e; throw $e;
} }
// update blog // update blog
dcCore::app()->blog->triggerBlog(); App::blog()->triggerBlog();
// return new widgetText ID // return new widgetText ID
return (int) $cur->getField('option_id'); return (int) $cur->getField('option_id');
@ -205,16 +195,15 @@ class Utils
*/ */
public static function updWidget(int $id, Cursor $cur): void public static function updWidget(int $id, Cursor $cur): void
{ {
// nullsafe if (!App::blog()->isDefined()) {
if (is_null(dcCore::app()->blog)) {
throw new Exception(__('Blog is not set')); throw new Exception(__('Blog is not set'));
} }
// check permission to delete post // check permission to delete post
if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([ if (!App::auth()->check(App::auth()->makePermissions([
dcCore::app()->auth::PERMISSION_USAGE, App::auth()::PERMISSION_USAGE,
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, App::auth()::PERMISSION_CONTENT_ADMIN,
]), dcCore::app()->blog->id)) { ]), App::blog()->id())) {
throw new Exception(__('You are not allowed to update entries text widget')); throw new Exception(__('You are not allowed to update entries text widget'));
} }
@ -228,10 +217,10 @@ class Utils
$cur->setField('option_upddt', date('Y-m-d H:i:s')); $cur->setField('option_upddt', date('Y-m-d H:i:s'));
// check if user is post owner // check if user is post owner
if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CONTENT_ADMIN]), dcCore::app()->blog->id)) { if (!App::auth()->check(App::auth()->makePermissions([App::auth()::PERMISSION_CONTENT_ADMIN]), App::blog()->id())) {
$rs = self::getWidgets([ $rs = self::getWidgets([
'option_id' => $id, 'option_id' => $id,
'user_id' => dcCore::app()->con->escapeStr((string) dcCore::app()->auth->userID()), 'user_id' => App::con()->escapeStr(App::auth()->userID()),
'no_content' => true, 'no_content' => true,
'limit' => 1, 'limit' => 1,
]); ]);
@ -245,7 +234,7 @@ class Utils
$cur->update('WHERE option_id = ' . $id . ' '); $cur->update('WHERE option_id = ' . $id . ' ');
// update blog // update blog
dcCore::app()->blog->triggerBlog(); App::blog()->triggerBlog();
} }
/** /**
@ -256,16 +245,15 @@ class Utils
*/ */
public static function delWidget(int $id, ?string $type = null): void public static function delWidget(int $id, ?string $type = null): void
{ {
// nullsafe if (!App::blog()->idDefined()) {
if (is_null(dcCore::app()->blog)) {
throw new Exception(__('Blog is not set')); throw new Exception(__('Blog is not set'));
} }
// check permission to delete post // check permission to delete post
if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([ if (!App::auth()->check(App::auth()->makePermissions([
dcCore::app()->auth::PERMISSION_DELETE, App::auth()::PERMISSION_DELETE,
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, App::auth()::PERMISSION_CONTENT_ADMIN,
]), dcCore::app()->blog->id)) { ]), App::blog()->id())) {
throw new Exception(__('You are not allowed to delete entries text widget')); throw new Exception(__('You are not allowed to delete entries text widget'));
} }
@ -278,10 +266,10 @@ class Utils
} }
// check if user is post owner // check if user is post owner
if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CONTENT_ADMIN]), dcCore::app()->blog->id)) { if (!App::auth()->check(App::auth()->makePermissions([App::auth()::PERMISSION_CONTENT_ADMIN]), App::blog()->id())) {
$rs = self::getWidgets([ $rs = self::getWidgets([
'option_id' => $id, 'option_id' => $id,
'user_id' => dcCore::app()->con->escapeStr((string) dcCore::app()->auth->userID()), 'user_id' => App::con()->escapeStr(App::auth()->userID()),
'no_content' => true, 'no_content' => true,
'limit' => 1, 'limit' => 1,
]); ]);
@ -293,13 +281,13 @@ class Utils
// delete widgetText // delete widgetText
$sql = new DeleteStatement(); $sql = new DeleteStatement();
$sql->from(dcCore::app()->prefix . My::TABLE_NAME) $sql->from(App::con()->prefix() . My::TABLE_NAME)
->where('option_id = ' . $id) ->where('option_id = ' . $id)
->and('option_type = ' . $sql->quote($type)) ->and('option_type = ' . $sql->quote($type))
->delete(); ->delete();
// update blog // update blog
dcCore::app()->blog->triggerBlog(); App::blog()->triggerBlog();
} }
/** /**
@ -314,16 +302,16 @@ class Utils
public static function setWidgetContent(int $option_id, string $format, string $lang, ?string &$content, ?string &$content_xhtml): void public static function setWidgetContent(int $option_id, string $format, string $lang, ?string &$content, ?string &$content_xhtml): void
{ {
if ($format == 'wiki') { if ($format == 'wiki') {
dcCore::app()->initWikiPost(); App::filter()->initWikiPost();
dcCore::app()->wiki2xhtml->setOpt('note_prefix', 'wnote-' . $option_id); App::filter()->wiki()->setOpt('note_prefix', 'wnote-' . $option_id);
if (strpos($lang, 'fr') === 0) { if (strpos($lang, 'fr') === 0) {
dcCore::app()->wiki2xhtml->setOpt('active_fr_syntax', 1); App::filter()->wiki()->setOpt('active_fr_syntax', 1);
} }
} }
if ($content) { if ($content) {
$content_xhtml = dcCore::app()->callFormater($format, $content); $content_xhtml = App::formater()->callEditorFormater('dcLegacyEditor', $format, $content);
$content_xhtml = dcCore::app()->HTMLfilter($content_xhtml); $content_xhtml = App::filter()->HTMLfilter($content_xhtml);
} else { } else {
$content_xhtml = ''; $content_xhtml = '';
} }
@ -331,7 +319,7 @@ class Utils
$excerpt = $excerpt_xhtml = ''; $excerpt = $excerpt_xhtml = '';
# --BEHAVIOR-- coreAfterPostContentFormat -- array # --BEHAVIOR-- coreAfterPostContentFormat -- array
dcCore::app()->callBehavior('coreAfterPostContentFormat', [ App::behavior()->callBehavior('coreAfterPostContentFormat', [
'excerpt' => &$excerpt, 'excerpt' => &$excerpt,
'content' => &$content, 'content' => &$content,
'excerpt_xhtml' => &$excerpt_xhtml, 'excerpt_xhtml' => &$excerpt_xhtml,

View File

@ -1,28 +1,20 @@
<?php <?php
/**
* @brief postWidgetText, 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\postWidgetText; namespace Dotclear\Plugin\postWidgetText;
use dcCore; use Dotclear\App;
use Dotclear\Helper\Html\Html; use Dotclear\Helper\Html\Html;
use Dotclear\Plugin\widgets\WidgetsStack; use Dotclear\Plugin\widgets\WidgetsStack;
use Dotclear\Plugin\widgets\WidgetsElement; use Dotclear\Plugin\widgets\WidgetsElement;
/** /**
* @ingroup DC_PLUGIN_POSTWIDGETTEXT * @brief postWidgetText widgets class.
* @brief postWidgetText - admin and public widget methods. * @ingroup postWidgetText
* @since 2.6 *
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
class Widgets class Widgets
{ {
@ -37,7 +29,7 @@ class Widgets
->create( ->create(
basename(__DIR__), basename(__DIR__),
__('Post widget text'), __('Post widget text'),
[self::class, 'parseWidget'], self::parseWidget(...),
null, null,
__('Add a widget with a text related to an entry') __('Add a widget with a text related to an entry')
) )
@ -68,9 +60,8 @@ class Widgets
{ {
if ($w->__get('offline') if ($w->__get('offline')
|| !Utils::isActive() || !Utils::isActive()
|| is_null(dcCore::app()->ctx) || !App::frontend()->context()->exists('posts')
|| !dcCore::app()->ctx->exists('posts') || !App::frontend()->context()->__get('posts')->f('post_id')
|| !dcCore::app()->ctx->__get('posts')->f('post_id')
) { ) {
return ''; return '';
} }
@ -78,7 +69,7 @@ class Widgets
$title = $w->__get('title') ?: null; $title = $w->__get('title') ?: null;
$content = ''; $content = '';
$rs = Utils::getWidgets(['post_id' => dcCore::app()->ctx->__get('posts')->f('post_id')]); $rs = Utils::getWidgets(['post_id' => App::frontend()->context()->__get('posts')->f('post_id')]);
if ($rs->isEmpty()) { if ($rs->isEmpty()) {
return ''; return '';
} }
@ -86,11 +77,11 @@ class Widgets
if ('' != $rs->f('option_title')) { if ('' != $rs->f('option_title')) {
$title = $rs->f('option_title'); $title = $rs->f('option_title');
} }
if ('' != $rs->f('option_content_xhtml')) { if ('' != $rs->f('option_content')) {
$content = $rs->f('option_content_xhtml'); $content = $rs->f('option_content');
} }
if ('' == $content && $w->__get('excerpt')) { if ('' == $content && $w->__get('excerpt')) {
$content = dcCore::app()->ctx->__get('posts')->f('post_excerpt_xhtml'); $content = App::frontend()->context()->__get('posts')->f('post_excerpt');
} }
return $w->renderDiv( return $w->renderDiv(