upgrade to Dotclear 2.27
This commit is contained in:
parent
5b5010edbc
commit
cde1aa319a
8 changed files with 74 additions and 116 deletions
|
@ -1,7 +1,9 @@
|
|||
$(function(){
|
||||
/* toogle admin form sidebar */
|
||||
$('#fac h5').toggleWithLegend(
|
||||
$('#fac').children().not('h5'),
|
||||
{cookie:'dcx_fac_admin_form_sidebar',legend_click:true}
|
||||
);
|
||||
/*global $, dotclear, datePicker */
|
||||
'use strict';
|
||||
|
||||
$(() => {
|
||||
$('#fac h5').toggleWithLegend(
|
||||
$('#fac').children().not('h5'),
|
||||
{user_pref:'dcx_fac_admin_form_sidebar',legend_click:true}
|
||||
);
|
||||
});
|
|
@ -15,20 +15,18 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\fac;
|
||||
|
||||
use dcCore;
|
||||
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');
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::BACKEND));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,12 @@ namespace Dotclear\Plugin\fac;
|
|||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use dcPage;
|
||||
use dcPostsActions;
|
||||
use dcSettings;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
Page
|
||||
};
|
||||
use Dotclear\Core\Backend\Action\ActionsPosts;
|
||||
use Dotclear\Database\{
|
||||
Cursor,
|
||||
MetaRecord
|
||||
|
@ -61,7 +64,7 @@ class BackendBehaviors
|
|||
__('category pages') => 'category',
|
||||
__('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) {
|
||||
$types[sprintf(
|
||||
__('"%s" pages from extension muppet'),
|
||||
|
@ -80,9 +83,6 @@ class BackendBehaviors
|
|||
*/
|
||||
public static function adminBlogPreferencesFormV2(dcSettings $blog_settings): void
|
||||
{
|
||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->adminurl)) {
|
||||
return;
|
||||
}
|
||||
$lines = '';
|
||||
$fac_public_tpltypes = json_decode($blog_settings->get(My::id())->get('public_tpltypes'), true);
|
||||
if (!is_array($fac_public_tpltypes)) {
|
||||
|
@ -96,15 +96,15 @@ class BackendBehaviors
|
|||
}
|
||||
|
||||
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">' .
|
||||
__('To add feed to an entry edit this entry and put in sidebar the url of the feed and select a format.') .
|
||||
'</p>';
|
||||
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(),
|
||||
'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>';
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ class BackendBehaviors
|
|||
*/
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -231,11 +231,11 @@ class BackendBehaviors
|
|||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
@ -259,12 +259,12 @@ class BackendBehaviors
|
|||
/**
|
||||
* Posts actions callback to remove linked feed
|
||||
*
|
||||
* @param dcPostsActions $pa dcPostsActions instance
|
||||
* @param ActionsPosts $pa ActionsPosts instance
|
||||
* @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;
|
||||
}
|
||||
# No entry
|
||||
|
@ -286,17 +286,17 @@ class BackendBehaviors
|
|||
self::delFeed($post_id);
|
||||
}
|
||||
|
||||
dcPage::addSuccessNotice(__('Linked feed deleted.'));
|
||||
Notices::addSuccessNotice(__('Linked feed deleted.'));
|
||||
$pa->redirect(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Posts actions callback to add linked feed
|
||||
*
|
||||
* @param dcPostsActions $pa dcPostsActions instance
|
||||
* @param ActionsPosts $pa ActionsPosts instance
|
||||
* @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)) {
|
||||
return;
|
||||
|
@ -315,13 +315,13 @@ class BackendBehaviors
|
|||
self::addFeed($post_id, $post);
|
||||
}
|
||||
|
||||
dcPage::addSuccessNotice(__('Linked feed added.'));
|
||||
Notices::addSuccessNotice(__('Linked feed added.'));
|
||||
$pa->redirect(true);
|
||||
|
||||
# Display form
|
||||
# Display form
|
||||
} else {
|
||||
$pa->beginPage(
|
||||
dcPage::breadcrumb([
|
||||
Page::breadcrumb([
|
||||
Html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||
$pa->getCallerTitle() => $pa->getRedirection(true),
|
||||
__('Linked feed to this selection') => '',
|
||||
|
@ -351,7 +351,7 @@ class BackendBehaviors
|
|||
*/
|
||||
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 '';
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ class BackendBehaviors
|
|||
if (is_null(dcCore::app()->blog)) {
|
||||
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)) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -15,8 +15,11 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\fac;
|
||||
|
||||
use dcCore;
|
||||
use dcPage;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
Page
|
||||
};
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
|
@ -30,25 +33,21 @@ use Dotclear\Helper\Html\Form\{
|
|||
};
|
||||
use Exception;
|
||||
|
||||
class Config extends dcNsProcess
|
||||
class Config extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init == defined('DC_CONTEXT_ADMIN')
|
||||
&& !is_null(dcCore::app()->auth)
|
||||
&& dcCore::app()->auth->isSuperAdmin();
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::CONFIG));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//nullsafe
|
||||
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -56,7 +55,7 @@ class Config extends dcNsProcess
|
|||
dcCore::app()->admin->__get('list')->getURL() . '#plugins' : $_REQUEST['redir'];
|
||||
|
||||
# -- Get settings --
|
||||
$s = dcCore::app()->blog->settings->get(My::id());
|
||||
$s = My::settings();
|
||||
|
||||
$fac_formats = json_decode($s->get('formats'), true);
|
||||
|
||||
|
@ -88,10 +87,10 @@ class Config extends dcNsProcess
|
|||
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
Notices::addSuccessNotice(
|
||||
__('Configuration successfully updated.')
|
||||
);
|
||||
dcCore::app()->adminurl->redirect(
|
||||
dcCore::app()->admin->url->redirect(
|
||||
'admin.plugins',
|
||||
['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
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$s = dcCore::app()->blog->settings->get(My::id());
|
||||
$s = My::settings();
|
||||
|
||||
$fac_formats = json_decode($s->get('formats'), true);
|
||||
|
||||
|
@ -148,7 +142,7 @@ class Config extends dcNsProcess
|
|||
|
||||
echo '
|
||||
<div class="fieldset">
|
||||
<h4>' . __('Informations') . '</h4>
|
||||
<h4 id="' . My::id() . 'Params">' . __('Informations') . '</h4>
|
||||
|
||||
<div class="two-boxes">
|
||||
|
||||
|
@ -176,7 +170,7 @@ class Config extends dcNsProcess
|
|||
|
||||
</div>';
|
||||
|
||||
dcPage::helpBlock('fac');
|
||||
Page::helpBlock('fac');
|
||||
}
|
||||
|
||||
private static function displayFacFormat(string $title, string $uid, array $format): void
|
||||
|
|
|
@ -16,24 +16,22 @@ namespace Dotclear\Plugin\fac;
|
|||
|
||||
use context;
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Helper\Date;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Helper\Network\Feed\Reader;
|
||||
use Exception;
|
||||
|
||||
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 || 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;
|
||||
}
|
||||
|
||||
|
@ -49,7 +47,7 @@ class Frontend extends dcNsProcess
|
|||
}
|
||||
|
||||
// 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)
|
||||
|| !in_array(dcCore::app()->url->type, $types)) {
|
||||
return;
|
||||
|
@ -91,7 +89,7 @@ class Frontend extends dcNsProcess
|
|||
'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)
|
||||
|| !is_array($formats)
|
||||
|| !isset($formats[$fac_format->f('meta_id')])) {
|
||||
|
@ -119,25 +117,25 @@ class Frontend extends dcNsProcess
|
|||
|
||||
// Feed title
|
||||
$feedtitle = '';
|
||||
if ('' != dcCore::app()->blog->settings->get(My::id())->get('defaultfeedtitle')) {
|
||||
if ('' != My::settings()->get('defaultfeedtitle')) {
|
||||
$feedtitle = '<h3>' . Html::escapeHTML(
|
||||
empty($feed->title) ?
|
||||
str_replace(
|
||||
'%T',
|
||||
__('a related feed'),
|
||||
dcCore::app()->blog->settings->get(My::id())->get('defaultfeedtitle')
|
||||
(string) My::settings()->get('defaultfeedtitle')
|
||||
) :
|
||||
str_replace(
|
||||
'%T',
|
||||
$feed->title,
|
||||
dcCore::app()->blog->settings->get(My::id())->get('defaultfeedtitle')
|
||||
(string) My::settings()->get('defaultfeedtitle')
|
||||
)
|
||||
) . '</h3>';
|
||||
}
|
||||
|
||||
// Feed desc
|
||||
$feeddesc = '';
|
||||
if (dcCore::app()->blog->settings->get(My::id())->get('showfeeddesc')
|
||||
if (My::settings()->get('showfeeddesc')
|
||||
&& '' != $feed->description) {
|
||||
$feeddesc = '<p>' . context::global_filters(
|
||||
$feed->description,
|
||||
|
|
|
@ -16,26 +16,19 @@ namespace Dotclear\Plugin\fac;
|
|||
|
||||
use dcCore;
|
||||
use dcNamespace;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
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;
|
||||
}
|
||||
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -110,7 +103,7 @@ class Install extends dcNsProcess
|
|||
|
||||
// Set module settings
|
||||
foreach ($mod_conf as $v) {
|
||||
dcCore::app()->blog->settings->get(My::id())->put(
|
||||
My::settings()->put(
|
||||
$v[0],
|
||||
$v[2],
|
||||
$v[3],
|
||||
|
|
29
src/My.php
29
src/My.php
|
@ -14,36 +14,11 @@ declare(strict_types=1);
|
|||
|
||||
namespace Dotclear\Plugin\fac;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* 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__);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,21 +15,19 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\fac;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue