Compare commits
3 Commits
b2b003a125
...
45e84abd9f
Author | SHA1 | Date |
---|---|---|
Jean-Christian Paul Denis | 45e84abd9f | |
Jean-Christian Paul Denis | 7502423750 | |
Jean-Christian Paul Denis | d37c179661 |
156
CHANGELOG.md
156
CHANGELOG.md
|
@ -1,82 +1,102 @@
|
|||
todo:
|
||||
- cleanup plugin importExport features
|
||||
postWidgetText 2023.08.15
|
||||
===========================================================
|
||||
* Require Dotclear 2.27
|
||||
* Require PHP 8.1
|
||||
* Fix pgsql support
|
||||
* Upgrade to Dotclear 2.27 stable
|
||||
* Move third party repository
|
||||
* Use Dotclear style for CHANGELOG
|
||||
|
||||
2023.05.13
|
||||
- require dotclear 2.26
|
||||
- require PHP 8.0+
|
||||
- use define php_min
|
||||
- fix post editor
|
||||
postWidgetText 2023.05.13
|
||||
===========================================================
|
||||
* require dotclear 2.26
|
||||
* require PHP 8.0+
|
||||
* use define php_min
|
||||
* fix post editor
|
||||
|
||||
2023.04.26
|
||||
- require dotclear 2.26
|
||||
- require PHP 8.0+
|
||||
- use namespace
|
||||
- use sql statement
|
||||
- add use columns preference
|
||||
- add list filters
|
||||
- add plugin Uninstaller features (no direct actions)
|
||||
- various fixes
|
||||
postWidgetText 2023.04.26
|
||||
===========================================================
|
||||
* require dotclear 2.26
|
||||
* require PHP 8.0+
|
||||
* use namespace
|
||||
* use sql statement
|
||||
* add use columns preference
|
||||
* add list filters
|
||||
* add plugin Uninstaller features (no direct actions)
|
||||
* various fixes
|
||||
|
||||
2022.12.23
|
||||
- use SVG icon
|
||||
- use constant for table name
|
||||
- use abstract plugin id and settings ns
|
||||
- use short settings id
|
||||
- use new addBehaviors
|
||||
- fix autoload
|
||||
- fix permissions
|
||||
- fix install
|
||||
- fix phpstan errors
|
||||
postWidgetText 2022.12.23
|
||||
===========================================================
|
||||
* use SVG icon
|
||||
* use constant for table name
|
||||
* use abstract plugin id and settings ns
|
||||
* use short settings id
|
||||
* use new addBehaviors
|
||||
* fix autoload
|
||||
* fix permissions
|
||||
* fix install
|
||||
* fix phpstan errors
|
||||
|
||||
2022.11.20
|
||||
- fix compatibility with Dotclear 2.24 (required)
|
||||
postWidgetText 2022.11.20
|
||||
===========================================================
|
||||
* fix compatibility with Dotclear 2.24 (required)
|
||||
|
||||
2021.11.06
|
||||
- fix error on empty record on widget
|
||||
- update to PS12
|
||||
postWidgetText 2021.11.06
|
||||
===========================================================
|
||||
* fix error on empty record on widget
|
||||
* update to PS12
|
||||
|
||||
2021.10.30
|
||||
- clean up code
|
||||
- update license
|
||||
- update translations
|
||||
- check Dotclear 2.19
|
||||
- check php7.3+, php8.0
|
||||
- complete readme file
|
||||
- fix widget rendering
|
||||
- fix combo name
|
||||
- fix javascript
|
||||
- add user pref for posts list filters (dc 2.20)
|
||||
- move config to blog pref
|
||||
postWidgetText 2021.10.30
|
||||
===========================================================
|
||||
* clean up code
|
||||
* update license
|
||||
* update translations
|
||||
* check Dotclear 2.19
|
||||
* check php7.3+, php8.0
|
||||
* complete readme file
|
||||
* fix widget rendering
|
||||
* fix combo name
|
||||
* fix javascript
|
||||
* add user pref for posts list filters (dc 2.20)
|
||||
* move config to blog pref
|
||||
|
||||
2013.11.21
|
||||
- Switch to Dotclear 2.6 and clean up code
|
||||
- Change icons
|
||||
- Add dashboard icon
|
||||
postWidgetText 2013.11.21
|
||||
===========================================================
|
||||
* Switch to Dotclear 2.6 and clean up code
|
||||
* Change icons
|
||||
* Add dashboard icon
|
||||
|
||||
2011.06.10
|
||||
- Fixed export bug (thks @noe)
|
||||
- (c) 2011
|
||||
postWidgetText 2011.06.10
|
||||
===========================================================
|
||||
* Fixed export bug (thks @noe)
|
||||
* (c) 2011
|
||||
|
||||
2011.04.11
|
||||
- Changed version numbering
|
||||
- Fixed Dotclear 2.2.3 chage on plugin page (thks @tomek)
|
||||
- Fixed call to $core->blog on prepend
|
||||
postWidgetText 2011.04.11
|
||||
===========================================================
|
||||
* Changed version numbering
|
||||
* Fixed Dotclear 2.2.3 chage on plugin page (thks @tomek)
|
||||
* Fixed call to $core->blog on prepend
|
||||
|
||||
0.6.1 - 2010.11.12
|
||||
- Fixed install on nightly build
|
||||
postWidgetText 0.6.1 - 2010.11.12
|
||||
===========================================================
|
||||
* Fixed install on nightly build
|
||||
|
||||
0.6 - 2010-06-08
|
||||
- Switched to DC 2.2
|
||||
postWidgetText 0.6 - 2010-06-08
|
||||
===========================================================
|
||||
* Switched to DC 2.2
|
||||
|
||||
0.5 - 2010.04.07
|
||||
- Rewrited and cleaned extension
|
||||
- Changed table
|
||||
postWidgetText 0.5 - 2010.04.07
|
||||
===========================================================
|
||||
* Rewrited and cleaned extension
|
||||
* Changed table
|
||||
|
||||
0.4 - 2009.08.23
|
||||
- Added behaviors
|
||||
- Added custom widget title
|
||||
- Added "plugin page'' support
|
||||
postWidgetText 0.4 - 2009.08.23
|
||||
===========================================================
|
||||
* Added behaviors
|
||||
* Added custom widget title
|
||||
* Added "plugin page'' support
|
||||
|
||||
0.3
|
||||
- Fixed php 5.3 compatibility
|
||||
- Fixed typo in export function
|
||||
postWidgetText 0.3
|
||||
===========================================================
|
||||
* Fixed php 5.3 compatibility
|
||||
* Fixed typo in export function
|
31
README.md
31
README.md
|
@ -1,11 +1,10 @@
|
|||
# README
|
||||
|
||||
[![Release](https://img.shields.io/github/v/release/JcDenis/postWidgetText)](https://github.com/JcDenis/postWidgetText/releases)
|
||||
[![Date](https://img.shields.io/github/release-date/JcDenis/postWidgetText)](https://github.com/JcDenis/postWidgetText/releases)
|
||||
[![Issues](https://img.shields.io/github/issues/JcDenis/postWidgetText)](https://github.com/JcDenis/postWidgetText/issues)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.svg)](https://fr.dotclear.org/download)
|
||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/postWidgetText)
|
||||
[![License](https://img.shields.io/github/license/JcDenis/postWidgetText)](https://github.com/JcDenis/postWidgetText/blob/master/LICENSE)
|
||||
[![Release](https://img.shields.io/badge/release-2023.08.15-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)
|
||||
[![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/postWidgetText)
|
||||
[![License](https://img.shields.io/github/license/JcDenis/postWidgetText)](https://git.dotclear.watch/JcDenis/postWidgetText/blob/master/LICENSE)
|
||||
|
||||
## WHAT IS POSTWIDGETTEXT ?
|
||||
|
||||
|
@ -16,12 +15,12 @@ Add a widget related to an entry with custom titles and content.
|
|||
|
||||
## REQUIREMENTS
|
||||
|
||||
_postWidgetText_ requires:
|
||||
_postWidgetText_ requires:
|
||||
|
||||
* permissions to manage widgets
|
||||
* permissions to manage entries
|
||||
* Dotclear 2.26
|
||||
* PHP 8.0+
|
||||
* permissions to manage widgets
|
||||
* permissions to manage entries
|
||||
* Dotclear 2.27
|
||||
* PHP 8.0+
|
||||
|
||||
Note this plugin add table called post_option to Dotclear database.
|
||||
|
||||
|
@ -37,12 +36,12 @@ Manage (delete) "widgets" from sidebar menu called "Post widget text".
|
|||
|
||||
## LINKS
|
||||
|
||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||
* Source & contribution : [GitHub Page](https://github.com/JcDenis/postWidgetText)
|
||||
* Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/postWidgetText)
|
||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/postWidgetText) or [GitHub Page](https://github.com/JcDenis/postWidgetText)
|
||||
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/postWidgetText/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/postWidgetText)
|
||||
|
||||
## CONTRIBUTORS
|
||||
|
||||
* Jean-Christian Denis
|
||||
* Jean-Christian Denis (author)
|
||||
|
||||
You are welcome to contribute to this code.
|
||||
You are welcome to contribute to this code.
|
||||
|
|
16
_define.php
16
_define.php
|
@ -10,7 +10,7 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH') || is_null(dcCore::app()->auth)) {
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -18,22 +18,22 @@ $this->registerModule(
|
|||
'Post widget text',
|
||||
'Add a widget with a text related to an entry',
|
||||
'Jean-Christian Denis and Contributors',
|
||||
'2023.05.13',
|
||||
'2023.08.15',
|
||||
[
|
||||
'requires' => [
|
||||
['php', '8.0'],
|
||||
['core', '2.26'],
|
||||
['core', '2.27'],
|
||||
],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_USAGE,
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
]),
|
||||
'type' => 'plugin',
|
||||
'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
|
||||
'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
|
||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
|
||||
'settings' => [
|
||||
'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',
|
||||
]
|
||||
);
|
||||
|
|
10
dcstore.xml
10
dcstore.xml
|
@ -2,12 +2,12 @@
|
|||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="postWidgetText">
|
||||
<name>Post widget text</name>
|
||||
<version>2023.05.13</version>
|
||||
<version>2023.08.15</version>
|
||||
<author>Jean-Christian Denis and Contributors</author>
|
||||
<desc>Add a widget with a text related to an entry</desc>
|
||||
<file>https://github.com/JcDenis/postWidgetText/releases/download/v2023.05.13/plugin-postWidgetText.zip</file>
|
||||
<da:dcmin>2.26</da:dcmin>
|
||||
<da:details>https://plugins.dotaddict.org/dc2/details/postWidgetText</da:details>
|
||||
<da:support>https://github.com/JcDenis/postWidgetText</da:support>
|
||||
<file>https://git.dotclear.watch/JcDenis/postWidgetText/releases/download/v2023.08.15/plugin-postWidgetText.zip</file>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<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>
|
||||
</module>
|
||||
</modules>
|
||||
|
|
|
@ -14,47 +14,25 @@ declare(strict_types=1);
|
|||
|
||||
namespace Dotclear\Plugin\postWidgetText;
|
||||
|
||||
use dcAdmin;
|
||||
use dcCore;
|
||||
use dcPage;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
class Backend extends dcNsProcess
|
||||
class Backend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog)
|
||||
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_USAGE,
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
]), dcCore::app()->blog->id);
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::BACKEND));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// backend sidebar menu icon
|
||||
if (Utils::isActive()) {
|
||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||
My::name(),
|
||||
dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
||||
dcPage::getPF(My::id() . '/icon.svg'),
|
||||
preg_match('/' . preg_quote((string) dcCore::app()->adminurl->get('admin.plugin.' . My::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
||||
dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CONTENT_ADMIN]), dcCore::app()->blog->id)
|
||||
);
|
||||
// backend user dashboard favorites icon
|
||||
dcCore::app()->addBehavior('adminDashboardFavoritesV2', [BackendBehaviors::class, 'adminDashboardFavoritesV2']);
|
||||
My::addBackendMenuItem();
|
||||
}
|
||||
|
||||
// backend pwt management
|
||||
|
@ -82,7 +60,7 @@ class Backend extends dcNsProcess
|
|||
]);
|
||||
|
||||
// add plugin "importExport" features
|
||||
if (!is_null(dcCore::app()->blog) && dcCore::app()->blog->settings->get(My::id())->get('importexport_active')) {
|
||||
if (!My::settings()->get('importexport_active')) {
|
||||
dcCore::app()->addBehaviors([
|
||||
'exportFullV2' => [ImportExport::class, 'exportFullV2'],
|
||||
'exportSingleV2' => [ImportExport::class, 'exportSingleV2'],
|
||||
|
|
|
@ -15,10 +15,8 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\postWidgetText;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use dcFavorites;
|
||||
use dcPage;
|
||||
use dcSettings;
|
||||
use Dotclear\Core\Backend\Favorites;
|
||||
use Dotclear\Database\{
|
||||
Cursor,
|
||||
MetaRecord
|
||||
|
@ -122,24 +120,20 @@ class BackendBehaviors
|
|||
/**
|
||||
* Add user dashboard icon.
|
||||
*
|
||||
* @param dcFavorites $favs The user favorites
|
||||
* @param Favorites $favs The user favorites
|
||||
*/
|
||||
public static function adminDashboardFavoritesV2(dcFavorites $favs): void
|
||||
public static function adminDashboardFavoritesV2(Favorites $favs): void
|
||||
{
|
||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->adminurl)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$favs->register(My::id(), [
|
||||
'title' => __('Post widget text'),
|
||||
'url' => dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
||||
'small-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
||||
'large-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_USAGE,
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
]),
|
||||
]);
|
||||
$favs->register(
|
||||
My::id(),
|
||||
[
|
||||
'title' => My::name(),
|
||||
'url' => My::manageUrl(),
|
||||
'small-icon' => My::icons(),
|
||||
'large-icon' => My::icons(),
|
||||
//'permissions' => null,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,7 +143,7 @@ class BackendBehaviors
|
|||
*/
|
||||
public static function adminPostHeaders(): string
|
||||
{
|
||||
return dcPage::jsModuleLoad(My::id() . '/js/backend.js');
|
||||
return My::jsLoad('backend');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -253,7 +247,7 @@ class BackendBehaviors
|
|||
}
|
||||
# Upddate widget
|
||||
else {
|
||||
Utils::updWidget($w->f('option_id'), $wcur);
|
||||
Utils::updWidget((int) $w->f('option_id'), $wcur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,20 +15,18 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\postWidgetText;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
class Frontend extends dcNsProcess
|
||||
class Frontend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_RC_PATH');
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::FRONTEND));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,28 +15,20 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\postWidgetText;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Database\Structure;
|
||||
use Exception;
|
||||
|
||||
class Install extends dcNsProcess
|
||||
class Install extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version'));
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::INSTALL));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -62,7 +54,7 @@ class Install extends dcNsProcess
|
|||
(new Structure(dcCore::app()->con, dcCore::app()->prefix))->synchronize($s);
|
||||
|
||||
// Settings
|
||||
$s = dcCore::app()->blog->settings->get(My::id());
|
||||
$s = My::settings();
|
||||
$s->put(
|
||||
'active',
|
||||
true,
|
||||
|
|
|
@ -14,38 +14,29 @@ declare(strict_types=1);
|
|||
|
||||
namespace Dotclear\Plugin\postWidgetText;
|
||||
|
||||
use dcAdminFilters;
|
||||
use adminGenericFilterV2;
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use dcPage;
|
||||
use Dotclear\Core\Backend\Filter\{
|
||||
Filters,
|
||||
FiltersLibrary
|
||||
};
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
Page
|
||||
};
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Helper\Network\Http;
|
||||
use Exception;
|
||||
|
||||
use form;
|
||||
|
||||
class Manage extends dcNsProcess
|
||||
class Manage extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog)
|
||||
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_USAGE,
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
]), dcCore::app()->blog->id);
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::MANAGE));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// nullsafe check
|
||||
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -56,13 +47,13 @@ class Manage extends dcNsProcess
|
|||
Utils::delWidget((int) $id);
|
||||
}
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
Notices::addSuccessNotice(
|
||||
__('Posts widgets successfully delete.')
|
||||
);
|
||||
if (!empty($_POST['redir'])) {
|
||||
Http::redirect($_POST['redir']);
|
||||
} else {
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id());
|
||||
My::redirect();
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
|
@ -74,21 +65,21 @@ class Manage extends dcNsProcess
|
|||
|
||||
public static function render(): void
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// nullsafe check
|
||||
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
# filters
|
||||
$filter = new adminGenericFilterV2('pwt');
|
||||
$filter->add(dcAdminFilters::getPageFilter());
|
||||
$filter->add(dcAdminFilters::getInputFilter('search_post_title', __('Entry:')));
|
||||
$filter->add(dcAdminFilters::getInputFilter('search_widget_title', __('Widget:')));
|
||||
$filter->add(dcAdminFilters::getInputFilter('user_id', __('User:')));
|
||||
$filter = new Filters('pwt');
|
||||
$filter->add(FiltersLibrary::getPageFilter());
|
||||
$filter->add(FiltersLibrary::getInputFilter('search_post_title', __('Entry:')));
|
||||
$filter->add(FiltersLibrary::getInputFilter('search_widget_title', __('Widget:')));
|
||||
$filter->add(FiltersLibrary::getInputFilter('user_id', __('User:')));
|
||||
$params = $filter->params();
|
||||
|
||||
# Get posts with text widget
|
||||
|
@ -102,38 +93,37 @@ class Manage extends dcNsProcess
|
|||
}
|
||||
|
||||
// display
|
||||
dcPage::openModule(
|
||||
Page::openModule(
|
||||
My::name(),
|
||||
dcPage::jsPageTabs() .
|
||||
dcPage::jsModuleLoad(My::id() . '/js/manage.js') .
|
||||
$filter->js(dcCore::app()->adminurl->get('admin.plugin.' . My::id()) . '#record')
|
||||
Page::jsPageTabs() .
|
||||
My::jsLoad('manage') .
|
||||
$filter->js(My::manageUrl() . '#record')
|
||||
);
|
||||
|
||||
echo
|
||||
dcPage::breadcrumb([
|
||||
Page::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
My::name() => '',
|
||||
]) .
|
||||
dcPage::notices();
|
||||
Notices::getNotices();
|
||||
|
||||
if ($posts_list) {
|
||||
$filter->display('admin.plugin.' . My::id(), form::hidden('p', My::id()));
|
||||
$filter->display('admin.plugin.' . My::id());
|
||||
|
||||
$posts_list->display(
|
||||
$filter,
|
||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . My::id()) . '" method="post" id="form-entries">' .
|
||||
'<form action="' . My::manageUrl() . '" method="post" id="form-entries">' .
|
||||
'%s' .
|
||||
'<div class="two-cols">' .
|
||||
'<p class="col checkboxes-helpers"></p>' .
|
||||
'<p class="col right">' .
|
||||
'<input id="do-action" class="delete" type="submit" name="save" value="' . __('Delete selected widgets') . '" /></p>' .
|
||||
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.' . My::id(), array_merge(['p' => My::id()], $filter->values(true))) .
|
||||
dcCore::app()->formNonce() .
|
||||
My::parsedHiddenFields($filter->values(true)) .
|
||||
'</div>' .
|
||||
'</form>'
|
||||
);
|
||||
}
|
||||
|
||||
dcPage::closeModule();
|
||||
Page::closeModule();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,11 +15,13 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\postWidgetText;
|
||||
|
||||
use ArrayObject;
|
||||
use adminGenericFilterV2;
|
||||
use adminGenericListV2;
|
||||
use context;
|
||||
use dcCore;
|
||||
use dcPager;
|
||||
use Dotclear\Core\Backend\Filter\Filters;
|
||||
use Dotclear\Core\Backend\Listing\{
|
||||
Listing,
|
||||
Pager
|
||||
};
|
||||
use Dotclear\Helper\Date;
|
||||
use Dotclear\Helper\Html\Form\Checkbox;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
|
@ -29,18 +31,18 @@ use Dotclear\Helper\Html\Html;
|
|||
* @brief postWidgetText - admin list methods.
|
||||
* @since 2.6
|
||||
*/
|
||||
class ManageList extends adminGenericListV2
|
||||
class ManageList extends Listing
|
||||
{
|
||||
public function display(adminGenericFilterV2 $filter, string $enclose = '%s'): void
|
||||
public function display(Filters $filter, string $enclose = '%s'): void
|
||||
{
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog)) {
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// prepare page
|
||||
$blocks = explode('%s', $enclose);
|
||||
$pager = new dcPager((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');
|
||||
|
||||
// no record
|
||||
|
|
32
src/My.php
32
src/My.php
|
@ -14,39 +14,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Dotclear\Plugin\postWidgetText;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* This module definitions.
|
||||
*/
|
||||
class My
|
||||
class My extends MyPlugin
|
||||
{
|
||||
/** @var string Plugin table name */
|
||||
public const TABLE_NAME = 'post_option';
|
||||
|
||||
/**
|
||||
* This module id.
|
||||
*/
|
||||
public static function id(): string
|
||||
{
|
||||
return basename(dirname(__DIR__));
|
||||
}
|
||||
|
||||
/**
|
||||
* This module name.
|
||||
*/
|
||||
public static function name(): string
|
||||
{
|
||||
$name = dcCore::app()->plugins->moduleInfo(self::id(), 'name');
|
||||
|
||||
return __(is_string($name) ? $name : self::id());
|
||||
}
|
||||
|
||||
/**
|
||||
* This module path.
|
||||
*/
|
||||
public static function path(): string
|
||||
{
|
||||
return dirname(__DIR__);
|
||||
}
|
||||
public const TABLE_NAME = \initPostWidgetText::PWT_TABLE_NAME;
|
||||
}
|
||||
|
|
|
@ -15,21 +15,19 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\postWidgetText;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
|
||||
class Uninstall extends dcNsProcess
|
||||
class Uninstall extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN');
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::UNINSTALL));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class Utils
|
|||
*/
|
||||
public static function isActive(): bool
|
||||
{
|
||||
return !is_null(dcCore::app()->blog) && dcCore::app()->blog->settings->get(My::id())->get('active');
|
||||
return My::settings()->get('active');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,17 +70,20 @@ class Utils
|
|||
}
|
||||
|
||||
$sql = new SelectStatement();
|
||||
$sql->columns([
|
||||
'option_id',
|
||||
'option_creadt',
|
||||
'option_upddt',
|
||||
'option_type',
|
||||
'option_format',
|
||||
'option_lang',
|
||||
'option_title',
|
||||
'option_content',
|
||||
'option_content_xhtml',
|
||||
]);
|
||||
|
||||
if (!$count_only) {
|
||||
$sql->columns([
|
||||
'option_id',
|
||||
'option_creadt',
|
||||
'option_upddt',
|
||||
'option_type',
|
||||
'option_format',
|
||||
'option_lang',
|
||||
'option_title',
|
||||
'option_content',
|
||||
'option_content_xhtml',
|
||||
]);
|
||||
}
|
||||
|
||||
$sql->join(
|
||||
(new JoinStatement())
|
||||
|
@ -142,7 +145,7 @@ class Utils
|
|||
public static function addWidget(Cursor $cur): int
|
||||
{
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog)) {
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
throw new Exception(__('Blog is not set'));
|
||||
}
|
||||
|
||||
|
@ -203,7 +206,7 @@ class Utils
|
|||
public static function updWidget(int $id, Cursor $cur): void
|
||||
{
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog)) {
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
throw new Exception(__('Blog is not set'));
|
||||
}
|
||||
|
||||
|
@ -254,7 +257,7 @@ class Utils
|
|||
public static function delWidget(int $id, ?string $type = null): void
|
||||
{
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog)) {
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
throw new Exception(__('Blog is not set'));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue