upgrade to Dotclear 2.27

This commit is contained in:
Jean-Christian Denis 2023-08-12 22:56:03 +02:00
parent 5b5010edbc
commit cde1aa319a
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
8 changed files with 74 additions and 116 deletions

View file

@ -1,7 +1,9 @@
$(function(){ /*global $, dotclear, datePicker */
/* toogle admin form sidebar */ 'use strict';
$('#fac h5').toggleWithLegend(
$('#fac').children().not('h5'), $(() => {
{cookie:'dcx_fac_admin_form_sidebar',legend_click:true} $('#fac h5').toggleWithLegend(
); $('#fac').children().not('h5'),
{user_pref:'dcx_fac_admin_form_sidebar',legend_click:true}
);
}); });

View file

@ -15,20 +15,18 @@ declare(strict_types=1);
namespace Dotclear\Plugin\fac; namespace Dotclear\Plugin\fac;
use dcCore; use dcCore;
use dcNsProcess; use Dotclear\Core\Process;
class Backend extends dcNsProcess class Backend extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_CONTEXT_ADMIN'); return self::status(My::checkContext(My::BACKEND));
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init) { if (!self::status()) {
return false; return false;
} }

View file

@ -16,9 +16,12 @@ namespace Dotclear\Plugin\fac;
use ArrayObject; use ArrayObject;
use dcCore; use dcCore;
use dcPage;
use dcPostsActions;
use dcSettings; use dcSettings;
use Dotclear\Core\Backend\{
Notices,
Page
};
use Dotclear\Core\Backend\Action\ActionsPosts;
use Dotclear\Database\{ use Dotclear\Database\{
Cursor, Cursor,
MetaRecord MetaRecord
@ -61,7 +64,7 @@ class BackendBehaviors
__('category pages') => 'category', __('category pages') => 'category',
__('entries feed') => 'feed', __('entries feed') => 'feed',
]; ];
if (dcCore::app()->plugins->moduleExists('muppet') && class_exists('\muppet')) { if (dcCore::app()->plugins->getDefine('muppet')->isDefined() && class_exists('\muppet')) {
foreach (\muppet::getPostTypes() as $k => $v) { foreach (\muppet::getPostTypes() as $k => $v) {
$types[sprintf( $types[sprintf(
__('"%s" pages from extension muppet'), __('"%s" pages from extension muppet'),
@ -80,9 +83,6 @@ class BackendBehaviors
*/ */
public static function adminBlogPreferencesFormV2(dcSettings $blog_settings): void public static function adminBlogPreferencesFormV2(dcSettings $blog_settings): void
{ {
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->adminurl)) {
return;
}
$lines = ''; $lines = '';
$fac_public_tpltypes = json_decode($blog_settings->get(My::id())->get('public_tpltypes'), true); $fac_public_tpltypes = json_decode($blog_settings->get(My::id())->get('public_tpltypes'), true);
if (!is_array($fac_public_tpltypes)) { if (!is_array($fac_public_tpltypes)) {
@ -96,15 +96,15 @@ class BackendBehaviors
} }
echo echo
'<div class="fieldset"><h4 id="fac_params">Feed after content</h4>' . '<div class="fieldset"><h4 id="' . My::id() . '_params">Feed after content</h4>' .
'<p class="form-note">' . '<p class="form-note">' .
__('To add feed to an entry edit this entry and put in sidebar the url of the feed and select a format.') . __('To add feed to an entry edit this entry and put in sidebar the url of the feed and select a format.') .
'</p>'; '</p>';
if (dcCore::app()->auth->isSuperAdmin()) { if (dcCore::app()->auth->isSuperAdmin()) {
echo '<p><a href="' . dcCore::app()->adminurl->get('admin.plugins', [ echo '<p><a href="' . dcCore::app()->admin->url->get('admin.plugins', [
'module' => My::id(), 'module' => My::id(),
'conf' => 1, 'conf' => 1,
'redir' => dcCore::app()->adminurl->get('admin.blog.pref') . '#fac_params', 'redir' => dcCore::app()->admin->url->get('admin.blog.pref') . '#params.' . My::id() . '_params',
]) . '">' . __('Configure formats') . '</a></p>'; ]) . '">' . __('Configure formats') . '</a></p>';
} }
@ -160,7 +160,7 @@ class BackendBehaviors
*/ */
public static function adminPostHeaders(): string public static function adminPostHeaders(): string
{ {
return dcPage::jsModuleLoad(My::id() . '/js/backend.js'); return My::jsLoad('backend');
} }
/** /**
@ -172,7 +172,7 @@ class BackendBehaviors
*/ */
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, ?MetaRecord $post): void public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, ?MetaRecord $post): void
{ {
if (is_null(dcCore::app()->blog) || !dcCore::app()->blog->settings->get(My::id())->get('active')) { if (is_null(dcCore::app()->blog) || !My::settings()->get('active')) {
return; return;
} }
@ -231,11 +231,11 @@ class BackendBehaviors
/** /**
* Add actions to posts page combo * Add actions to posts page combo
* *
* @param dcPostsActions $pa dcPostsActionsPage instance * @param ActionsPosts $pa ActionsPostsPage instance
*/ */
public static function adminPostsActions(dcPostsActions $pa): void public static function adminPostsActions(ActionsPosts $pa): void
{ {
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->auth) || !dcCore::app()->blog->settings->get(My::id())->get('active')) { if (is_null(dcCore::app()->blog) || !My::settings()->get('active')) {
return; return;
} }
@ -259,12 +259,12 @@ class BackendBehaviors
/** /**
* Posts actions callback to remove linked feed * Posts actions callback to remove linked feed
* *
* @param dcPostsActions $pa dcPostsActions instance * @param ActionsPosts $pa ActionsPosts instance
* @param ArrayObject $post _POST actions * @param ArrayObject $post _POST actions
*/ */
public static function callbackRemove(dcPostsActions $pa, ArrayObject $post): void public static function callbackRemove(ActionsPosts $pa, ArrayObject $post): void
{ {
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->auth)) { if (is_null(dcCore::app()->blog)) {
return; return;
} }
# No entry # No entry
@ -286,17 +286,17 @@ class BackendBehaviors
self::delFeed($post_id); self::delFeed($post_id);
} }
dcPage::addSuccessNotice(__('Linked feed deleted.')); Notices::addSuccessNotice(__('Linked feed deleted.'));
$pa->redirect(true); $pa->redirect(true);
} }
/** /**
* Posts actions callback to add linked feed * Posts actions callback to add linked feed
* *
* @param dcPostsActions $pa dcPostsActions instance * @param ActionsPosts $pa ActionsPosts instance
* @param ArrayObject $post _POST actions * @param ArrayObject $post _POST actions
*/ */
public static function callbackAdd(dcPostsActions $pa, ArrayObject $post): void public static function callbackAdd(ActionsPosts $pa, ArrayObject $post): void
{ {
if (is_null(dcCore::app()->blog)) { if (is_null(dcCore::app()->blog)) {
return; return;
@ -315,13 +315,13 @@ class BackendBehaviors
self::addFeed($post_id, $post); self::addFeed($post_id, $post);
} }
dcPage::addSuccessNotice(__('Linked feed added.')); Notices::addSuccessNotice(__('Linked feed added.'));
$pa->redirect(true); $pa->redirect(true);
# Display form # Display form
} else { } else {
$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),
__('Linked feed to this selection') => '', __('Linked feed to this selection') => '',
@ -351,7 +351,7 @@ class BackendBehaviors
*/ */
protected static function formFeed(string $url = '', string $format = ''): string protected static function formFeed(string $url = '', string $format = ''): string
{ {
if (is_null(dcCore::app()->blog) || !dcCore::app()->blog->settings->get(My::id())->get('active')) { if (is_null(dcCore::app()->blog) || !My::settings()->get('active')) {
return ''; return '';
} }
@ -382,7 +382,7 @@ class BackendBehaviors
if (is_null(dcCore::app()->blog)) { if (is_null(dcCore::app()->blog)) {
return []; return [];
} }
$formats = json_decode(dcCore::app()->blog->settings->get(My::id())->get('formats'), true); $formats = json_decode((string) My::settings()->get('formats'), true);
if (!is_array($formats) || empty($formats)) { if (!is_array($formats) || empty($formats)) {
return []; return [];
} }

View file

@ -15,8 +15,11 @@ declare(strict_types=1);
namespace Dotclear\Plugin\fac; namespace Dotclear\Plugin\fac;
use dcCore; use dcCore;
use dcPage; use Dotclear\Core\Process;
use dcNsProcess; use Dotclear\Core\Backend\{
Notices,
Page
};
use Dotclear\Helper\Html\Html; use Dotclear\Helper\Html\Html;
use Dotclear\Helper\Html\Form\{ use Dotclear\Helper\Html\Form\{
Checkbox, Checkbox,
@ -30,25 +33,21 @@ use Dotclear\Helper\Html\Form\{
}; };
use Exception; use Exception;
class Config extends dcNsProcess class Config extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init == defined('DC_CONTEXT_ADMIN') return self::status(My::checkContext(My::CONFIG));
&& !is_null(dcCore::app()->auth)
&& dcCore::app()->auth->isSuperAdmin();
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init) { if (!self::status()) {
return false; return false;
} }
//nullsafe //nullsafe
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) { if (is_null(dcCore::app()->blog)) {
return false; return false;
} }
@ -56,7 +55,7 @@ class Config extends dcNsProcess
dcCore::app()->admin->__get('list')->getURL() . '#plugins' : $_REQUEST['redir']; dcCore::app()->admin->__get('list')->getURL() . '#plugins' : $_REQUEST['redir'];
# -- Get settings -- # -- Get settings --
$s = dcCore::app()->blog->settings->get(My::id()); $s = My::settings();
$fac_formats = json_decode($s->get('formats'), true); $fac_formats = json_decode($s->get('formats'), true);
@ -88,10 +87,10 @@ class Config extends dcNsProcess
dcCore::app()->blog->triggerBlog(); dcCore::app()->blog->triggerBlog();
dcPage::addSuccessNotice( Notices::addSuccessNotice(
__('Configuration successfully updated.') __('Configuration successfully updated.')
); );
dcCore::app()->adminurl->redirect( dcCore::app()->admin->url->redirect(
'admin.plugins', 'admin.plugins',
['module' => My::id(), 'conf' => 1, 'redir' => dcCore::app()->admin->__get('list')->getRedir()] ['module' => My::id(), 'conf' => 1, 'redir' => dcCore::app()->admin->__get('list')->getRedir()]
); );
@ -105,16 +104,11 @@ class Config extends dcNsProcess
public static function render(): void public static function render(): void
{ {
if (!static::$init) { if (!self::status()) {
return; return;
} }
//nullsafe $s = My::settings();
if (is_null(dcCore::app()->blog)) {
return;
}
$s = dcCore::app()->blog->settings->get(My::id());
$fac_formats = json_decode($s->get('formats'), true); $fac_formats = json_decode($s->get('formats'), true);
@ -148,7 +142,7 @@ class Config extends dcNsProcess
echo ' echo '
<div class="fieldset"> <div class="fieldset">
<h4>' . __('Informations') . '</h4> <h4 id="' . My::id() . 'Params">' . __('Informations') . '</h4>
<div class="two-boxes"> <div class="two-boxes">
@ -176,7 +170,7 @@ class Config extends dcNsProcess
</div>'; </div>';
dcPage::helpBlock('fac'); Page::helpBlock('fac');
} }
private static function displayFacFormat(string $title, string $uid, array $format): void private static function displayFacFormat(string $title, string $uid, array $format): void

View file

@ -16,24 +16,22 @@ namespace Dotclear\Plugin\fac;
use context; use context;
use dcCore; use dcCore;
use dcNsProcess; use Dotclear\Core\Process;
use Dotclear\Helper\Date; use Dotclear\Helper\Date;
use Dotclear\Helper\Html\Html; use Dotclear\Helper\Html\Html;
use Dotclear\Helper\Network\Feed\Reader; use Dotclear\Helper\Network\Feed\Reader;
use Exception; use Exception;
class Frontend extends dcNsProcess class Frontend extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_RC_PATH'); return self::status(My::checkContext(My::FRONTEND));
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init || is_null(dcCore::app()->blog) || !dcCore::app()->blog->settings->get(My::id())->get('active')) { if (!self::status() || is_null(dcCore::app()->blog) || !My::settings()->get('active')) {
return false; return false;
} }
@ -49,7 +47,7 @@ class Frontend extends dcNsProcess
} }
// Not in page to show // Not in page to show
$types = json_decode((string) dcCore::app()->blog->settings->get(My::id())->get('public_tpltypes'), true); $types = json_decode((string) My::settings()->get('public_tpltypes'), true);
if (!is_array($types) if (!is_array($types)
|| !in_array(dcCore::app()->url->type, $types)) { || !in_array(dcCore::app()->url->type, $types)) {
return; return;
@ -91,7 +89,7 @@ class Frontend extends dcNsProcess
'linescontentnohtml' => '1', 'linescontentnohtml' => '1',
]; ];
$formats = json_decode((string) dcCore::app()->blog->settings->get(My::id())->get('formats'), true); $formats = json_decode((string) My::settings()->get('formats'), true);
if (empty($formats) if (empty($formats)
|| !is_array($formats) || !is_array($formats)
|| !isset($formats[$fac_format->f('meta_id')])) { || !isset($formats[$fac_format->f('meta_id')])) {
@ -119,25 +117,25 @@ class Frontend extends dcNsProcess
// Feed title // Feed title
$feedtitle = ''; $feedtitle = '';
if ('' != dcCore::app()->blog->settings->get(My::id())->get('defaultfeedtitle')) { if ('' != My::settings()->get('defaultfeedtitle')) {
$feedtitle = '<h3>' . Html::escapeHTML( $feedtitle = '<h3>' . Html::escapeHTML(
empty($feed->title) ? empty($feed->title) ?
str_replace( str_replace(
'%T', '%T',
__('a related feed'), __('a related feed'),
dcCore::app()->blog->settings->get(My::id())->get('defaultfeedtitle') (string) My::settings()->get('defaultfeedtitle')
) : ) :
str_replace( str_replace(
'%T', '%T',
$feed->title, $feed->title,
dcCore::app()->blog->settings->get(My::id())->get('defaultfeedtitle') (string) My::settings()->get('defaultfeedtitle')
) )
) . '</h3>'; ) . '</h3>';
} }
// Feed desc // Feed desc
$feeddesc = ''; $feeddesc = '';
if (dcCore::app()->blog->settings->get(My::id())->get('showfeeddesc') if (My::settings()->get('showfeeddesc')
&& '' != $feed->description) { && '' != $feed->description) {
$feeddesc = '<p>' . context::global_filters( $feeddesc = '<p>' . context::global_filters(
$feed->description, $feed->description,

View file

@ -16,26 +16,19 @@ namespace Dotclear\Plugin\fac;
use dcCore; use dcCore;
use dcNamespace; use dcNamespace;
use dcNsProcess; use Dotclear\Core\Process;
use Exception; use Exception;
class Install extends dcNsProcess class Install extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_CONTEXT_ADMIN') return self::status(My::checkContext(My::INSTALL));
&& dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version'));
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init) { if (!self::status()) {
return false;
}
if (is_null(dcCore::app()->blog)) {
return false; return false;
} }
@ -110,7 +103,7 @@ class Install extends dcNsProcess
// Set module settings // Set module settings
foreach ($mod_conf as $v) { foreach ($mod_conf as $v) {
dcCore::app()->blog->settings->get(My::id())->put( My::settings()->put(
$v[0], $v[0],
$v[2], $v[2],
$v[3], $v[3],

View file

@ -14,36 +14,11 @@ declare(strict_types=1);
namespace Dotclear\Plugin\fac; namespace Dotclear\Plugin\fac;
use dcCore; use Dotclear\Module\MyPlugin;
/** /**
* This module definitions. * This module definitions.
*/ */
class My class My extends MyPlugin
{ {
/**
* 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__);
}
} }

View file

@ -15,21 +15,19 @@ declare(strict_types=1);
namespace Dotclear\Plugin\fac; namespace Dotclear\Plugin\fac;
use dcCore; use dcCore;
use dcNsProcess; use Dotclear\Core\Process;
use Dotclear\Plugin\Uninstaller\Uninstaller; use Dotclear\Plugin\Uninstaller\Uninstaller;
class Uninstall extends dcNsProcess class Uninstall extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_CONTEXT_ADMIN'); return self::status(My::checkContext(My::UNINSTALL));
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) { if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
return false; return false;
} }