upgrade to Dotclear 2.27

This commit is contained in:
Jean-Christian Paul Denis 2023-08-16 22:03:40 +02:00
parent d433d2033d
commit 4dbab7441a
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
20 changed files with 207 additions and 293 deletions

View File

@ -37,7 +37,7 @@ class ActivityReportActions
__('Feed named "%s" point to "%s" has been updated by "%s"'), __('Feed named "%s" point to "%s" has been updated by "%s"'),
'zoneclearFeedServerAfterUpdateFeed', 'zoneclearFeedServerAfterUpdateFeed',
function (Cursor $cur, int $id): void { function (Cursor $cur, int $id): void {
$user = dcCore::app()->auth?->getInfo('user_cn'); $user = dcCore::app()->auth->getInfo('user_cn');
if (!is_string($user)) { if (!is_string($user)) {
return; return;
} }
@ -64,7 +64,7 @@ class ActivityReportActions
__('A new feed named "%s" point to "%s" was added by "%s"'), __('A new feed named "%s" point to "%s" was added by "%s"'),
'zoneclearFeedServerAfterAddFeed', 'zoneclearFeedServerAfterAddFeed',
function (Cursor $cur, int $id): void { function (Cursor $cur, int $id): void {
$user = dcCore::app()->auth?->getInfo('user_cn'); $user = dcCore::app()->auth->getInfo('user_cn');
if (!is_string($user) if (!is_string($user)
|| !is_string($cur->getField('feed_name')) || !is_string($cur->getField('feed_name'))
|| !is_string($cur->getField('feed_feed')) || !is_string($cur->getField('feed_feed'))
@ -115,7 +115,7 @@ class ActivityReportActions
} }
$row = new FeedRow($rs); $row = new FeedRow($rs);
$user = dcCore::app()->auth?->getInfo('user_cn'); $user = dcCore::app()->auth->getInfo('user_cn');
if (!is_string($user)) { if (!is_string($user)) {
return; return;
} }

View File

@ -14,27 +14,22 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer; namespace Dotclear\Plugin\zoneclearFeedServer;
use dcAdmin;
use dcCore; use dcCore;
use dcPage; use Dotclear\Core\Process;
use dcMenu;
use dcNsProcess;
/** /**
* Backend prepend. * Backend prepend.
*/ */
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;
} }
@ -54,42 +49,19 @@ class Backend extends dcNsProcess
'adminBlogPreferencesFormV2' => [BackendBehaviors::class, 'adminBlogPreferencesFormV2'], 'adminBlogPreferencesFormV2' => [BackendBehaviors::class, 'adminBlogPreferencesFormV2'],
]); ]);
// nullsafe
if (is_null(dcCore::app()->blog)) {
return false;
}
// not active // not active
if (!dcCore::app()->blog->settings->get(My::id())->get('active') if (!My::settings()->get('active') || '' == My::settings()->get('user')) {
|| '' == dcCore::app()->blog->settings->get(My::id())->get('user')
) {
return false; return false;
} }
// get user perm
$has_perm = dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
]), dcCore::app()->blog->id);
// add sidebar menu icon
if ((dcCore::app()->menu[dcAdmin::MENU_PLUGINS] instanceof dcMenu)) {
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(dcCore::app()->adminurl->get('admin.plugin.' . My::id())) . '(&.*)?$/',
$_SERVER['REQUEST_URI']
),
$has_perm
);
}
// no perm // no perm
if (!$has_perm) { if (!My::checkContext(My::MENU)) {
return true; return true;
} }
// sidebar menu
My::addBackendMenuItem();
// behaviors that require user perm // behaviors that require user perm
dcCore::app()->addBehaviors([ dcCore::app()->addBehaviors([
'adminDashboardFavoritesV2' => [BackendBehaviors::class, 'adminDashboardFavoritesV2'], 'adminDashboardFavoritesV2' => [BackendBehaviors::class, 'adminDashboardFavoritesV2'],

View File

@ -16,9 +16,8 @@ namespace Dotclear\Plugin\zoneclearFeedServer;
use ArrayObject; use ArrayObject;
use dcCore; use dcCore;
use dcPage;
use dcFavorites;
use dcSettings; use dcSettings;
use Dotclear\Core\Backend\Favorites;
use Dotclear\Database\MetaRecord; use Dotclear\Database\MetaRecord;
use Dotclear\Helper\Html\Form\{ use Dotclear\Helper\Html\Form\{
Checkbox, Checkbox,
@ -218,7 +217,7 @@ class BackendBehaviors
[(new Para()) [(new Para())
->items([ ->items([
(new Link()) (new Link())
->href(dcCore::app()->adminurl?->get('admin.plugin.' . My::id())) ->href(My::managerUrl())
->text(__('Configure feeds')), ->text(__('Configure feeds')),
])] : ])] :
[], [],
@ -231,13 +230,13 @@ class BackendBehaviors
/** /**
* User dashboard favorites icon. * User dashboard favorites icon.
*/ */
public static function adminDashboardFavoritesV2(dcFavorites $favs): void public static function adminDashboardFavoritesV2(Favorites $favs): void
{ {
$favs->register(My::id(), [ $favs->register(My::id(), [
'title' => My::name(), 'title' => My::name(),
'url' => dcCore::app()->adminurl->get('admin.plugin.' . My::id()), 'url' => My::manageUrl(),
'small-icon' => dcPage::getPF(My::id() . '/icon.svg'), 'small-icon' => My::icons(),
'large-icon' => dcPage::getPF(My::id() . '/icon.svg'), 'large-icon' => My::icons(),
'permissions' => dcCore::app()->auth->makePermissions([ 'permissions' => dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_USAGE, dcCore::app()->auth::PERMISSION_USAGE,
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
@ -250,11 +249,8 @@ class BackendBehaviors
} }
$fav['title'] .= '<br />' . sprintf(__('%s feed disabled', '%s feeds disabled', (int) $count), (int) $count); $fav['title'] .= '<br />' . sprintf(__('%s feed disabled', '%s feeds disabled', (int) $count), (int) $count);
$fav['large-icon'] = dcPage::getPF(My::id() . '/icon-update.svg'); $fav['large-icon'] = My::fileURL('icon-update.svg');
$fav['url'] = dcCore::app()->adminurl->get( $fav['url'] = My::manageUrl(['part' => 'feeds', 'sortby' => 'feed_status', 'order' => 'asc']);
'admin.plugin.' . My::id(),
['part' => 'feeds', 'sortby' => 'feed_status', 'order' => 'asc']
);
}, },
]); ]);
} }
@ -329,7 +325,7 @@ class BackendBehaviors
} else { } else {
$row = new FeedRow(ZoneclearFeedServer::instance()->getFeeds(['feed_id' => $rs_meta->f('meta_id')])); $row = new FeedRow(ZoneclearFeedServer::instance()->getFeeds(['feed_id' => $rs_meta->f('meta_id')]));
$item = (new Link()) $item = (new Link())
->href(dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), ['part' => 'feed', 'feed_id' => $row->id]) . '#feed') ->href(My::manageUrl(['part' => 'feed', 'feed_id' => $row->id]) . '#feed')
->title(__('edit feed')) ->title(__('edit feed'))
->text(Html::escapeHTML($row->name)); ->text(Html::escapeHTML($row->name));
} }
@ -341,7 +337,7 @@ class BackendBehaviors
*/ */
public static function adminPostHeaders(): string public static function adminPostHeaders(): string
{ {
return dcPage::jsModuleLoad(My::id() . '/js/post.js'); return My::jsLoad('post');
} }
/** /**
@ -402,10 +398,7 @@ class BackendBehaviors
]); ]);
if (!$fid->isEmpty()) { if (!$fid->isEmpty()) {
$edit = (new Link()) $edit = (new Link())
->href(dcCore::app()->adminurl->get( ->href(My::manageUrl(['part' => 'feed', 'feed_id' => $fid->f('meta_id')]))
'admin.plugin.' . My::id(),
['part' => 'feed', 'feed_id' => $fid->f('meta_id')]
))
->text(__('Edit this feed')); ->text(__('Edit this feed'));
} }
} }

View File

@ -14,28 +14,28 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer; namespace Dotclear\Plugin\zoneclearFeedServer;
use adminModulesList;
use dcCore; use dcCore;
use dcPage; use Dotclear\Core\Backend\{
use dcNsProcess; Notices,
ModulesList,
Page
};
use Dotclear\Core\Process;
use Exception; use Exception;
/** /**
* Backend module configuration. * Backend module configuration.
*/ */
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));
&& 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;
} }
@ -47,13 +47,13 @@ class Config extends dcNsProcess
try { try {
BackendBehaviors::adminBeforeBlogSettingsUpdate(null); BackendBehaviors::adminBeforeBlogSettingsUpdate(null);
dcPage::addSuccessNotice( Notices::addSuccessNotice(
__('Configuration has been successfully updated.') __('Configuration has been successfully updated.')
); );
dcCore::app()->adminurl?->redirect('admin.plugins', [ dcCore::app()->admin->url->redirect('admin.plugins', [
'module' => My::id(), 'module' => My::id(),
'conf' => '1', 'conf' => '1',
'redir' => !(dcCore::app()->admin->__get('list') instanceof adminModulesList) ? '' : dcCore::app()->admin->__get('list')->getRedir(), 'redir' => !(dcCore::app()->admin->__get('list') instanceof ModulesList) ? '' : dcCore::app()->admin->__get('list')->getRedir(),
]); ]);
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
@ -64,12 +64,12 @@ class Config extends dcNsProcess
public static function render(): void public static function render(): void
{ {
if (!static::$init) { if (!self::status()) {
return; return;
} }
BackendBehaviors::adminBlogPreferencesFormV2(null); BackendBehaviors::adminBlogPreferencesFormV2(null);
dcPage::helpBlock('zoneclearFeedServer'); Page::helpBlock('zoneclearFeedServer');
} }
} }

View File

@ -15,9 +15,9 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer; namespace Dotclear\Plugin\zoneclearFeedServer;
use ArrayObject; use ArrayObject;
use dcActions;
use dcCore; use dcCore;
use dcPage; use Dotclear\Core\Backend\Action\Actions;
use Dotclear\Core\Backend\Page;
use Dotclear\Database\MetaRecord; use Dotclear\Database\MetaRecord;
use Dotclear\Helper\Html\Form\{ use Dotclear\Helper\Html\Form\{
Link, Link,
@ -29,7 +29,7 @@ use Exception;
/** /**
* Backend feeds list actions handler. * Backend feeds list actions handler.
*/ */
class FeedsActions extends dcActions class FeedsActions extends Actions
{ {
public ZoneclearFeedServer $zcfs; public ZoneclearFeedServer $zcfs;
@ -61,9 +61,9 @@ class FeedsActions extends dcActions
public function beginPage(string $breadcrumb = '', string $head = ''): void public function beginPage(string $breadcrumb = '', string $head = ''): void
{ {
dcPage::openModule( Page::openModule(
My::name(), My::name(),
dcPage::jsLoad('js/_posts_actions.js') . Page::jsLoad('js/_posts_actions.js') .
$head $head
); );
echo echo
@ -78,14 +78,14 @@ class FeedsActions extends dcActions
public function endPage(): void public function endPage(): void
{ {
dcPage::closeModule(); Page::closeModule();
} }
public function error(Exception $e): void public function error(Exception $e): void
{ {
dcCore::app()->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
$this->beginPage( $this->beginPage(
dcPage::breadcrumb([ Page::breadcrumb([
Html::escapeHTML((string) dcCore::app()->blog?->name) => '', Html::escapeHTML((string) dcCore::app()->blog?->name) => '',
$this->getCallerTitle() => $this->getRedirection(true), $this->getCallerTitle() => $this->getRedirection(true),
__('Feeds actions') => '', __('Feeds actions') => '',

View File

@ -17,7 +17,10 @@ namespace Dotclear\Plugin\zoneclearFeedServer;
use ArrayObject; use ArrayObject;
use dcCore; use dcCore;
use dcMeta; use dcMeta;
use dcPage; use Dotclear\Core\Backend\{
Notices,
Page
};
use Dotclear\Database\Statement\DeleteStatement; use Dotclear\Database\Statement\DeleteStatement;
use Dotclear\Helper\Html\Form\{ use Dotclear\Helper\Html\Form\{
Form, Form,
@ -93,7 +96,7 @@ class FeedsDefaultActions
$ap->zcfs->enableFeed($id, $enable); $ap->zcfs->enableFeed($id, $enable);
} }
dcPage::addSuccessNotice(sprintf( Notices::addSuccessNotice(sprintf(
$enable ? $enable ?
__( __(
'%d feed has been successfully enabled.', '%d feed has been successfully enabled.',
@ -150,7 +153,7 @@ class FeedsDefaultActions
} }
} }
dcPage::addSuccessNotice( Notices::addSuccessNotice(
__('Entries have been successfully deleted.') __('Entries have been successfully deleted.')
); );
$ap->redirect(true); $ap->redirect(true);
@ -173,7 +176,7 @@ class FeedsDefaultActions
$ap->zcfs->deleteFeed($id); $ap->zcfs->deleteFeed($id);
} }
dcPage::addSuccessNotice(sprintf( Notices::addSuccessNotice(sprintf(
__( __(
'%d feed has been successfully deleted.', '%d feed has been successfully deleted.',
'%d feeds have been successfully deleted.', '%d feeds have been successfully deleted.',
@ -201,7 +204,7 @@ class FeedsDefaultActions
$ap->zcfs->checkFeedsUpdate($id, true); $ap->zcfs->checkFeedsUpdate($id, true);
} }
dcPage::addSuccessNotice(sprintf( Notices::addSuccessNotice(sprintf(
__('%d feed has been successfully updated.', '%d feeds have been successfully updated.', count($ids)), __('%d feed has been successfully updated.', '%d feeds have been successfully updated.', count($ids)),
count($ids) count($ids)
)); ));
@ -229,7 +232,7 @@ class FeedsDefaultActions
//$ap->zcfs->checkFeedsUpdate($id, true); //$ap->zcfs->checkFeedsUpdate($id, true);
} }
dcPage::addSuccessNotice(sprintf( Notices::addSuccessNotice(sprintf(
__('Last update of %s feed successfully reseted.', 'Last update of %s feeds successfully reseted.', count($ids)), __('Last update of %s feed successfully reseted.', 'Last update of %s feeds successfully reseted.', count($ids)),
count($ids) count($ids)
)); ));
@ -259,14 +262,14 @@ class FeedsDefaultActions
$ap->zcfs->updateFeed($id, $cur); $ap->zcfs->updateFeed($id, $cur);
} }
dcPage::addSuccessNotice(sprintf( Notices::addSuccessNotice(sprintf(
__('Category of %s feed successfully changed.', 'Category of %s feeds successfully changed.', count($ids)), __('Category of %s feed successfully changed.', 'Category of %s feeds successfully changed.', count($ids)),
count($ids) count($ids)
)); ));
$ap->redirect(true); $ap->redirect(true);
} else { } else {
$ap->beginPage( $ap->beginPage(
dcPage::breadcrumb([ Page::breadcrumb([
Html::escapeHTML((string) dcCore::app()->blog?->name) => '', Html::escapeHTML((string) dcCore::app()->blog?->name) => '',
__('Feeds server') => '', __('Feeds server') => '',
$ap->getCallerTitle() => $ap->getRedirection(true), $ap->getCallerTitle() => $ap->getRedirection(true),
@ -325,14 +328,14 @@ class FeedsDefaultActions
$ap->zcfs->updateFeed($id, $cur); $ap->zcfs->updateFeed($id, $cur);
} }
dcPage::addSuccessNotice(sprintf( Notices::addSuccessNotice(sprintf(
__('Update frequency of %s feed successfully changed.', 'Update frequency of %s feeds successfully changed.', count($ids)), __('Update frequency of %s feed successfully changed.', 'Update frequency of %s feeds successfully changed.', count($ids)),
count($ids) count($ids)
)); ));
$ap->redirect(true); $ap->redirect(true);
} else { } else {
$ap->beginPage( $ap->beginPage(
dcPage::breadcrumb( Page::breadcrumb(
[ [
Html::escapeHTML((string) dcCore::app()->blog?->name) => '', Html::escapeHTML((string) dcCore::app()->blog?->name) => '',
__('Feeds server') => '', __('Feeds server') => '',

View File

@ -15,10 +15,12 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer; namespace Dotclear\Plugin\zoneclearFeedServer;
use ArrayObject; use ArrayObject;
use adminGenericFilterV2;
use adminGenericListV2;
use dcCore; use dcCore;
use dcPager; use Dotclear\Core\Backend\Filter\Filters;
use Dotclear\Core\Backend\Listing\{
Listing,
Pager
};
use Dotclear\Helper\Date; use Dotclear\Helper\Date;
use Dotclear\Helper\Html\Form\{ use Dotclear\Helper\Html\Form\{
Checkbox, Checkbox,
@ -32,9 +34,9 @@ use Dotclear\Helper\Html\Html;
/** /**
* Backend feeds list. * Backend feeds list.
*/ */
class FeedsList extends adminGenericListV2 class FeedsList extends Listing
{ {
public function display(adminGenericFilterV2 $filter, string $enclose_block = ''): void public function display(Filters $filter, string $enclose_block = ''): void
{ {
if ($this->rs->isEmpty()) { if ($this->rs->isEmpty()) {
echo echo
@ -53,7 +55,7 @@ class FeedsList extends adminGenericListV2
$page = is_numeric($filter->value('page')) ? (int) $filter->value('page') : 1; $page = is_numeric($filter->value('page')) ? (int) $filter->value('page') : 1;
$nbpp = is_numeric($filter->value('nb')) ? (int) $filter->value('nb') : 10; $nbpp = is_numeric($filter->value('nb')) ? (int) $filter->value('nb') : 10;
$count = (int) $this->rs_count; $count = (int) $this->rs_count;
$pager = new dcPager($page, $count, $nbpp, 10); $pager = new Pager($page, $count, $nbpp, 10);
$cols = new ArrayObject([ $cols = new ArrayObject([
'title' => (new Text('th', __('Name'))) 'title' => (new Text('th', __('Name')))
@ -120,11 +122,11 @@ class FeedsList extends adminGenericListV2
$shunk_feed = substr($shunk_feed, 0, 50) . '...' . substr($shunk_feed, -20); $shunk_feed = substr($shunk_feed, 0, 50) . '...' . substr($shunk_feed, -20);
} }
$url = dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), ['part' => 'feed', 'feed_id' => $row->id]); $url = My::manageUrl(['part' => 'feed', 'feed_id' => $row->id]);
if (!is_string($url)) { if (!is_string($url)) {
$url = ''; $url = '';
} }
$tz = dcCore::app()->auth?->getInfo('user_tz'); $tz = dcCore::app()->auth->getInfo('user_tz');
if (!is_string($tz)) { if (!is_string($tz)) {
$tz = 'UTC'; $tz = 'UTC';
} }

View File

@ -15,8 +15,8 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer; namespace Dotclear\Plugin\zoneclearFeedServer;
use dcCore; use dcCore;
use dcNsProcess;
use dcUtils; use dcUtils;
use Dotclear\Core\Process;
use Dotclear\Database\MetaRecord; use Dotclear\Database\MetaRecord;
use Dotclear\Helper\Html\Html; use Dotclear\Helper\Html\Html;
use Exception; use Exception;
@ -24,18 +24,16 @@ use Exception;
/** /**
* Frontend prepend. * Frontend prepend.
*/ */
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) { if (!self::status()) {
return false; return false;
} }

View File

@ -15,28 +15,23 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer; namespace Dotclear\Plugin\zoneclearFeedServer;
use dcCore; use dcCore;
use dcNsProcess; use Dotclear\Core\Process;
use Dotclear\Database\Structure; use Dotclear\Database\Structure;
use Exception; use Exception;
/** /**
* Module installation. * Module installation.
*/ */
class Install extends dcNsProcess class Install extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
if (defined('DC_CONTEXT_ADMIN')) { return self::status(My::checkContext(My::INSTALL));
$version = dcCore::app()->plugins->moduleInfo(My::id(), 'version');
static::$init = is_string($version) ? dcCore::app()->newVersion(My::id(), $version) : true;
}
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init) { if (!self::status()) {
return false; return false;
} }
@ -75,10 +70,7 @@ class Install extends dcNsProcess
(new Structure(dcCore::app()->con, dcCore::app()->prefix))->synchronize($s); (new Structure(dcCore::app()->con, dcCore::app()->prefix))->synchronize($s);
// Settings // Settings
$s = dcCore::app()->blog?->settings->get(My::id()); $s = My::settings();
if (is_null($s)) {
return false;
}
$s->put('active', false, 'boolean', 'Enable zoneclearBlogServer', false, true); $s->put('active', false, 'boolean', 'Enable zoneclearBlogServer', false, true);
$s->put('pub_active', false, 'boolean', 'Enable public page of list of feeds', false, true); $s->put('pub_active', false, 'boolean', 'Enable public page of list of feeds', false, true);
$s->put('post_status_new', true, 'boolean', 'Enable auto publish new posts', false, true); $s->put('post_status_new', true, 'boolean', 'Enable auto publish new posts', false, true);

View File

@ -14,11 +14,16 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer; namespace Dotclear\Plugin\zoneclearFeedServer;
use adminGenericFilterV2;
use dcAdminFilters;
use dcCore; use dcCore;
use dcNsProcess; use Dotclear\Core\Backend\Filter\{
use dcPage; Filters,
FiltersLibrary
};
use Dotclear\Core\Backend\{
Notices,
Page
};
use Dotclear\Core\Process;
use Dotclear\Helper\Html\Form\{ use Dotclear\Helper\Html\Form\{
Div, Div,
Form, Form,
@ -34,27 +39,23 @@ use Exception;
/** /**
* Backend feeds list manage page. * Backend feeds list manage page.
*/ */
class Manage extends dcNsProcess class Manage extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init == defined('DC_CONTEXT_ADMIN') self::status(My::checkContext(My::MANAGE));
&& !is_null(dcCore::app()->blog)
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
]), dcCore::app()->blog->id);
// call period manage page // call period manage page
if (($_REQUEST['part'] ?? 'feeds') === 'feed') { if (($_REQUEST['part'] ?? 'feeds') === 'feed') {
static::$init = ManageFeed::init(); self::status(ManageFeed::init());
} }
return static::$init; return self::status();
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init) { if (!self::status()) {
return false; return false;
} }
@ -78,7 +79,7 @@ class Manage extends dcNsProcess
public static function render(): void public static function render(): void
{ {
if (!static::$init) { if (!self::status()) {
return; return;
} }
@ -87,16 +88,16 @@ class Manage extends dcNsProcess
// not configured // not configured
if (!$s->active || !$s->user) { if (!$s->active || !$s->user) {
dcPage::openModule(My::id()); Page::openModule(My::id());
echo echo
dcPage::breadcrumb([ Page::breadcrumb([
__('Plugins') => '', __('Plugins') => '',
My::name() => '', My::name() => '',
]) . ]) .
dcPage::notices(); Notices::getNotices();
dcPage::closeModule(); Page::closeModule();
return; return;
} }
@ -118,10 +119,10 @@ class Manage extends dcNsProcess
} }
// feeds filters // feeds filters
$feeds_filter = new adminGenericFilterV2(My::id() . 'feeds'); $feeds_filter = new Filters(My::id() . 'feeds');
$feeds_filter->add('part', 'feeds'); $feeds_filter->add('part', 'feeds');
$feeds_filter->add(dcAdminFilters::getPageFilter()); $feeds_filter->add(FiltersLibrary::getPageFilter());
$feeds_filter->add(dcAdminFilters::getSearchFilter()); $feeds_filter->add(FiltersLibrary::getSearchFilter());
$params = $feeds_filter->params(); $params = $feeds_filter->params();
// feeds list // feeds list
@ -133,24 +134,24 @@ class Manage extends dcNsProcess
dcCore::app()->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
} }
dcPage::openModule( Page::openModule(
My::id(), My::id(),
( (
isset($feeds_list) && !dcCore::app()->error->flag() ? isset($feeds_list) && !dcCore::app()->error->flag() ?
$feeds_filter->js(dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'feeds'], '&')) . $feeds_filter->js(My::manageUrl(['part' => 'feeds'], '&')) .
dcPage::jsModuleLoad(My::id() . '/js/feeds.js') My::jsLoad('feeds')
: '' : ''
) . ) .
dcPage::jsPageTabs() Page::jsPageTabs()
); );
echo echo
dcPage::breadcrumb([ Page::breadcrumb([
__('Plugins') => '', __('Plugins') => '',
My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()), My::name() => My::manageUrl(),
__('Feeds list') => '', __('Feeds list') => '',
]) . ]) .
dcPage::notices(); Notices::getNotices();
echo echo
(new Para()) (new Para())
@ -159,21 +160,21 @@ class Manage extends dcNsProcess
(new Link()) (new Link())
->class('button add') ->class('button add')
->text(__('New feed')) ->text(__('New feed'))
->href((string) dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'feed'])), ->href((string) My::manageUrl(['part' => 'feed'])),
]) ])
->render(); ->render();
if (isset($feeds_list)) { if (isset($feeds_list)) {
$feeds_filter->display( $feeds_filter->display(
'admin.plugin.' . My::id(), 'admin.plugin.' . My::id(),
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.' . My::id(), ['part' => 'feeds']) My::parsedHiddenFields(['part' => 'feeds'])
); );
$feeds_list->display( $feeds_list->display(
$feeds_filter, $feeds_filter,
(new Form('form-feeds')) (new Form('form-feeds'))
->method('post') ->method('post')
->action(dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'feeds'])) ->action(My::manageUrl(['part' => 'feeds']))
->fields([ ->fields([
(new Text('', '%s')), (new Text('', '%s')),
(new Div()) (new Div())
@ -183,25 +184,22 @@ class Manage extends dcNsProcess
->class('col checkboxes-helpers'), ->class('col checkboxes-helpers'),
(new Para()) (new Para())
->class('col right') ->class('col right')
->items(array_merge( ->items([
dcCore::app()->adminurl->hiddenFormFields('admin.plugin.' . My::id(), $feeds_filter->values(true)),
[
(new Label(__('Selected feeds action:'), Label::OUTSIDE_LABEL_BEFORE)) (new Label(__('Selected feeds action:'), Label::OUTSIDE_LABEL_BEFORE))
->for('action'), ->for('action'),
(new Select('action')) (new Select('action'))
->items($feeds_actions_page->getCombo()), ->items($feeds_actions_page->getCombo()),
(new Submit('feeds-action')) (new Submit('feeds-action'))
->value(__('ok')), ->value(__('ok')),
dcCore::app()->formNonce(false), ... My::hiddenFields($feeds_filter->values(true)),
] ]),
)),
]), ]),
]) ])
->render() ->render()
); );
} }
dcPage::closeModule(); Page::closeModule();
} }
} }

View File

@ -15,9 +15,12 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer; namespace Dotclear\Plugin\zoneclearFeedServer;
use dcCore; use dcCore;
use dcNsProcess; use Dotclear\Core\Backend\Action\ActionsPosts;
use dcPage; use Dotclear\Core\Backend\{
use dcPostsActions; Notices,
Page
};
use Dotclear\Core\Process;
use Dotclear\Helper\Html\Form\{ use Dotclear\Helper\Html\Form\{
Checkbox, Checkbox,
Div, Div,
@ -37,23 +40,16 @@ use Exception;
/** /**
* Backend feed and feed posts manage page. * Backend feed and feed posts manage page.
*/ */
class ManageFeed extends dcNsProcess class ManageFeed extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init == defined('DC_CONTEXT_ADMIN') return self::status(My::checkContext(My::MANAGE) && ($_REQUEST['part'] ?? 'feeds') === 'feed');
&& !is_null(dcCore::app()->blog)
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
]), dcCore::app()->blog->id)
&& ($_REQUEST['part'] ?? 'feeds') === 'feed';
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init) { if (!self::status()) {
return false; return false;
} }
@ -104,13 +100,8 @@ class ManageFeed extends dcNsProcess
throw new Exception(__('Failed to save feed.')); throw new Exception(__('Failed to save feed.'));
} }
dcPage::addSuccessNotice( Notices::addSuccessNotice(__('Feed successfully created.'));
__('Feed successfully created.') My::redirect(['part' => 'feed', 'feed_id' => $id]);
);
dcCore::app()->adminurl?->redirect(
'admin.plugin.' . My::id(),
['part' => 'feed', 'feed_id' => $id]
);
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
@ -125,7 +116,7 @@ class ManageFeed extends dcNsProcess
public static function render(): void public static function render(): void
{ {
if (!static::$init) { if (!self::status()) {
return; return;
} }
@ -136,7 +127,7 @@ class ManageFeed extends dcNsProcess
// Prepared entries list // Prepared entries list
if ($v->id && $v->can_view_page) { if ($v->id && $v->can_view_page) {
// posts actions // posts actions
$posts_actions_page = new dcPostsActions( $posts_actions_page = new ActionsPosts(
'plugin.php', 'plugin.php',
[ [
'p' => My::id(), 'p' => My::id(),
@ -188,25 +179,25 @@ class ManageFeed extends dcNsProcess
} }
// display // display
dcPage::openModule( Page::openModule(
My::id(), My::id(),
( (
$v->id && isset($post_filter) && !dcCore::app()->error->flag() ? $v->id && isset($post_filter) && !dcCore::app()->error->flag() ?
$post_filter->js(dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'feed', 'feed_id' => $v->id], '&') . '#entries') . $post_filter->js(My::manageUrl(['part' => 'feed', 'feed_id' => $v->id], '&') . '#entries') .
dcPage::jsModuleLoad(My::id() . '/js/feed.js') My::jsLoad('feed')
: '' : ''
) . ) .
dcPage::jsPageTabs() . Page::jsPageTabs() .
$v->next_headlink . "\n" . $v->prev_headlink $v->next_headlink . "\n" . $v->prev_headlink
); );
echo echo
dcPage::breadcrumb([ Page::breadcrumb([
__('Plugins') => '', __('Plugins') => '',
My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()), My::name() => My::manageUrl(),
($v->id ? __('Edit feed') : __('New feed')) => '', ($v->id ? __('Edit feed') : __('New feed')) => '',
]) . ]) .
dcPage::notices() . Notices::getNotices() .
(new Text('h3', ($v->id ? sprintf(__('Edit feed "%s"'), Html::escapeHTML($v->name)) : __('New feed'))))->render(); (new Text('h3', ($v->id ? sprintf(__('Edit feed "%s"'), Html::escapeHTML($v->name)) : __('New feed'))))->render();
if ($v->can_view_page) { if ($v->can_view_page) {
@ -232,7 +223,7 @@ class ManageFeed extends dcNsProcess
->items([ ->items([
(new Form('edit-entry-form')) (new Form('edit-entry-form'))
->method('post') ->method('post')
->action(dcCore::app()->adminurl->get('admin.plugin.' . My::id())) ->action(My::manageUrl())
->fields([ ->fields([
(new Div()) (new Div())
->class('two-cols') ->class('two-cols')
@ -379,19 +370,16 @@ class ManageFeed extends dcNsProcess
]), ]),
(new Para()) (new Para())
->class('clear') ->class('clear')
->items(array_merge( ->items([
dcCore::app()->adminurl->hiddenFormFields('admin.plugin.' . My::id(), [ (new Submit(['save']))
->value(__('Save') . ' (s)')
->accesskey('s'),
... My::hiddenFields([
'part' => 'feed', 'part' => 'feed',
'feed_id' => (string) $v->id, 'feed_id' => (string) $v->id,
'action' => 'savefeed', 'action' => 'savefeed',
]), ]),
[ ]),
(new Submit(['save']))
->value(__('Save') . ' (s)')
->accesskey('s'),
dcCore::app()->formNonce(false),
]
)),
]), ]),
]) ])
->render(); ->render();
@ -403,7 +391,7 @@ class ManageFeed extends dcNsProcess
# show posts filters # show posts filters
$post_filter->display( $post_filter->display(
['admin.plugin.' . My::id(),'#entries'], ['admin.plugin.' . My::id(),'#entries'],
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.' . My::id(), [ My::manageUrl([
'part' => 'feed', 'part' => 'feed',
'feed_id' => $v->id, 'feed_id' => $v->id,
]) ])
@ -417,10 +405,10 @@ class ManageFeed extends dcNsProcess
# show posts # show posts
$post_list->display( $post_list->display(
$post_filter, $post_filter,
dcCore::app()->adminurl->get('admin.plugin.' . My::id(), $args, '&') . '#entries', My::manageUrl($args, '&') . '#entries',
(new Form('form-entries')) (new Form('form-entries'))
->method('post') ->method('post')
->action(dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'feed']) . '#entries') ->action(My::manageUrl(['part' => 'feed']) . '#entries')
->fields([ ->fields([
(new Text('', '%s')), (new Text('', '%s')),
(new Div()) (new Div())
@ -430,22 +418,18 @@ class ManageFeed extends dcNsProcess
->class('col checkboxes-helpers'), ->class('col checkboxes-helpers'),
(new Para()) (new Para())
->class('col right') ->class('col right')
->items(array_merge( ->items([
dcCore::app()->adminurl->hiddenFormFields('admin.plugin.' . My::id(), $post_filter->values()), (new Hidden('redir', My::manageUrl($post_filter->values()))),
[
(new Hidden('redir', dcCore::app()->adminurl->get('admin.plugin.' . My::id(), $post_filter->values()))),
(new Label(__('Selected entries action:'), Label::OUTSIDE_LABEL_BEFORE)) (new Label(__('Selected entries action:'), Label::OUTSIDE_LABEL_BEFORE))
->for('action'), ->for('action'),
(new Select('action')) (new Select('action'))
->items($posts_actions_page->getCombo()), ->items($posts_actions_page->getCombo()),
(new Submit('feed-action')) (new Submit('feed-action'))
->value(__('ok')), ->value(__('ok')),
dcCore::app()->formNonce(false), ... My::hiddenFields($post_filter->values()),
]
)),
]), ]),
]),
]) ])
->render() ->render()
); );
@ -453,6 +437,6 @@ class ManageFeed extends dcNsProcess
echo '</div>'; echo '</div>';
} }
dcPage::closeModule(); Page::closeModule();
} }
} }

View File

@ -54,7 +54,7 @@ class ManageFeedVars
$feed_headlink = '<link rel="%s" title="%s" href="' . dcCore::app()->admin->getPageURL() . '&amp;part=feed&amp;feed_id=%s" />'; $feed_headlink = '<link rel="%s" title="%s" href="' . dcCore::app()->admin->getPageURL() . '&amp;part=feed&amp;feed_id=%s" />';
$feed_link = '<a href="' . dcCore::app()->admin->getPageURL() . '&amp;part=feed&amp;feed_id=%s" title="%s">%s</a>'; $feed_link = '<a href="' . dcCore::app()->admin->getPageURL() . '&amp;part=feed&amp;feed_id=%s" title="%s">%s</a>';
$lang = dcCore::app()->auth?->getInfo('user_lang'); $lang = dcCore::app()->auth->getInfo('user_lang');
// default values // default values
$feed_id = 0; $feed_id = 0;

View File

@ -14,15 +14,15 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer; namespace Dotclear\Plugin\zoneclearFeedServer;
use dcCore; use Dotclear\Module\MyPlugin;
/** /**
* This module definitions. * This module definitions.
*/ */
class My class My extends MyPlugin
{ {
/** @var string This module database table name */ /** @var string This module database table name */
public const TABLE_NAME = 'zc_feed'; public const TABLE_NAME = \initZoneclearFeedServer::TABLE_NAME;
/** @var string This module meta prefix */ /** @var string This module meta prefix */
public const META_PREFIX = 'zoneclearfeed_'; public const META_PREFIX = 'zoneclearfeed_';
@ -55,29 +55,8 @@ class My
'FeedFeedURL', 'FeedFeedURL',
]; ];
/** public static function checkCustomContext(int $context): ?bool
* This module id.
*/
public static function id(): string
{ {
return basename(dirname(__DIR__)); return $context == My::BACKEND ? defined('DC_CONTEXT_ADMIN') : null;
}
/**
* 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,19 +15,21 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer; namespace Dotclear\Plugin\zoneclearFeedServer;
use ArrayObject; use ArrayObject;
use adminGenericFilterV2;
use dcAdminCombos;
use dcAdminFilter;
use dcAdminFilters;
use dcCore; use dcCore;
use dcUtils; use dcUtils;
use Dotclear\Core\Backend\Combos;
use Dotclear\Core\Backend\Filter\{
Filter,
Filters,
FiltersLibrary
};
use Dotclear\Helper\Html\Html; use Dotclear\Helper\Html\Html;
use Exception; use Exception;
/** /**
* Backend feed posts list filters. * Backend feed posts list filters.
*/ */
class PostsFilter extends adminGenericFilterV2 class PostsFilter extends Filters
{ {
public function __construct() public function __construct()
{ {
@ -35,7 +37,7 @@ class PostsFilter extends adminGenericFilterV2
parent::__construct('posts'); parent::__construct('posts');
$filters = new ArrayObject([ $filters = new ArrayObject([
dcAdminFilters::getPageFilter(), FiltersLibrary::getPageFilter(),
$this->getPostUserFilter(), $this->getPostUserFilter(),
$this->getPostCategoriesFilter(), $this->getPostCategoriesFilter(),
$this->getPostStatusFilter(), $this->getPostStatusFilter(),
@ -53,7 +55,7 @@ class PostsFilter extends adminGenericFilterV2
/** /**
* Posts users select * Posts users select
* *
* @return null|dcAdminFilter * @return null|Filter
*/ */
public function getPostUserFilter() public function getPostUserFilter()
{ {
@ -70,10 +72,10 @@ class PostsFilter extends adminGenericFilterV2
return null; return null;
} }
$combo = dcAdminCombos::getUsersCombo($users); $combo = Combos::getUsersCombo($users);
dcUtils::lexicalKeySort($combo); dcUtils::lexicalKeySort($combo);
return (new dcAdminFilter('user_id')) return (new Filter('user_id'))
->param() ->param()
->title(__('Author:')) ->title(__('Author:'))
->options(array_merge( ->options(array_merge(
@ -86,7 +88,7 @@ class PostsFilter extends adminGenericFilterV2
/** /**
* Posts categories select * Posts categories select
* *
* @return null|dcAdminFilter * @return null|Filter
*/ */
public function getPostCategoriesFilter() public function getPostCategoriesFilter()
{ {
@ -116,7 +118,7 @@ class PostsFilter extends adminGenericFilterV2
} }
} }
return (new dcAdminFilter('cat_id')) return (new Filter('cat_id'))
->param() ->param()
->title(__('Category:')) ->title(__('Category:'))
->options($combo) ->options($combo)
@ -126,21 +128,21 @@ class PostsFilter extends adminGenericFilterV2
/** /**
* Posts status select * Posts status select
*/ */
public function getPostStatusFilter(): dcAdminFilter public function getPostStatusFilter(): Filter
{ {
return (new dcAdminFilter('status')) return (new Filter('status'))
->param('post_status') ->param('post_status')
->title(__('Status:')) ->title(__('Status:'))
->options(array_merge( ->options(array_merge(
['-' => ''], ['-' => ''],
dcAdminCombos::getPostStatusesCombo() Combos::getPostStatusesCombo()
)); ));
} }
/** /**
* Posts by month select * Posts by month select
* *
* @return null|dcAdminFilter * @return null|Filter
*/ */
public function getPostMonthFilter() public function getPostMonthFilter()
{ {
@ -157,13 +159,13 @@ class PostsFilter extends adminGenericFilterV2
return null; return null;
} }
return (new dcAdminFilter('month')) return (new Filter('month'))
->param('post_month', function ($f) { return substr($f[0], 4, 2); }) ->param('post_month', function ($f) { return substr($f[0], 4, 2); })
->param('post_year', function ($f) { return substr($f[0], 0, 4); }) ->param('post_year', function ($f) { return substr($f[0], 0, 4); })
->title(__('Month:')) ->title(__('Month:'))
->options(array_merge( ->options(array_merge(
['-' => ''], ['-' => ''],
dcAdminCombos::getDatesCombo($dates) Combos::getDatesCombo($dates)
)); ));
} }
} }

View File

@ -15,9 +15,11 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer; namespace Dotclear\Plugin\zoneclearFeedServer;
use ArrayObject; use ArrayObject;
use adminGenericListV2;
use dcCore; use dcCore;
use dcPager; use Dotclear\Core\Backend\Listing\{
Listing,
Pager
};
use Dotclear\Helper\Date; use Dotclear\Helper\Date;
use Dotclear\Helper\Html\Form\{ use Dotclear\Helper\Html\Form\{
Checkbox, Checkbox,
@ -31,7 +33,7 @@ use Dotclear\Helper\Html\Html;
/** /**
* Backend feed posts lists. * Backend feed posts lists.
*/ */
class PostsList extends adminGenericListV2 class PostsList extends Listing
{ {
public function display(PostsFilter $filter, string $base_url, string $enclose_block = ''): void public function display(PostsFilter $filter, string $base_url, string $enclose_block = ''): void
{ {
@ -52,7 +54,7 @@ class PostsList extends adminGenericListV2
$page = is_numeric($filter->value('page')) ? (int) $filter->value('page') : 1; $page = is_numeric($filter->value('page')) ? (int) $filter->value('page') : 1;
$nbpp = is_numeric($filter->value('nb')) ? (int) $filter->value('nb') : 10; $nbpp = is_numeric($filter->value('nb')) ? (int) $filter->value('nb') : 10;
$count = (int) $this->rs_count; $count = (int) $this->rs_count;
$pager = new dcPager($page, $count, $nbpp, 10); $pager = new Pager($page, $count, $nbpp, 10);
$pager->base_url = $base_url; $pager->base_url = $base_url;
$cols = new ArrayObject([ $cols = new ArrayObject([
@ -106,7 +108,7 @@ class PostsList extends adminGenericListV2
{ {
$cat_title = (new Text('', __('None'))); $cat_title = (new Text('', __('None')));
if ($this->rs->cat_title if ($this->rs->cat_title
&& dcCore::app()->auth?->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CATEGORIES]), dcCore::app()->blog?->id) && dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CATEGORIES]), dcCore::app()->blog?->id)
) { ) {
$cat_title = (new Link()) $cat_title = (new Link())
->href('category.php?id=' . $this->rs->cat_id) ->href('category.php?id=' . $this->rs->cat_id)

View File

@ -15,23 +15,21 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer; namespace Dotclear\Plugin\zoneclearFeedServer;
use dcCore; use dcCore;
use dcNsProcess; use Dotclear\Core\Process;
/** /**
* Module prepend. * Module prepend.
*/ */
class Prepend extends dcNsProcess class Prepend extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_RC_PATH'); return self::status(My::checkContext(My::PREPEND));
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

@ -14,9 +14,6 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer; namespace Dotclear\Plugin\zoneclearFeedServer;
use dcCore;
use Exception;
/** /**
* Module settings (type hinting). * Module settings (type hinting).
*/ */
@ -52,11 +49,7 @@ class Settings
*/ */
protected function __construct() protected function __construct()
{ {
if (is_null(dcCore::app()->blog)) { $s = My::settings();
throw new Exception(__('Blog is not defined'));
}
$s = dcCore::app()->blog->settings->get(My::id());
$update_limit = is_numeric($s->get('update_limit')) ? (int) $s->get('update_limit') : 1; $update_limit = is_numeric($s->get('update_limit')) ? (int) $s->get('update_limit') : 1;
@ -101,7 +94,7 @@ class Settings
*/ */
public function set(string $key, mixed $value): bool public function set(string $key, mixed $value): bool
{ {
$s = dcCore::app()->blog?->settings->get(My::id()); $s = My::settings();
if (!is_null($s) && property_exists($this, $key) && settype($value, gettype($this->{$key})) === true) { if (!is_null($s) && property_exists($this, $key) && settype($value, gettype($this->{$key})) === true) {
$s->drop($key); $s->drop($key);

View File

@ -15,24 +15,22 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer; namespace Dotclear\Plugin\zoneclearFeedServer;
use dcCore; use dcCore;
use dcNsProcess; use Dotclear\Core\Process;
use Dotclear\Plugin\Uninstaller\Uninstaller; use Dotclear\Plugin\Uninstaller\Uninstaller;
/** /**
* Plugin Uninstaller actions. * Plugin Uninstaller actions.
*/ */
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;
} }

View File

@ -90,7 +90,7 @@ class UrlHandler extends dcUrlHandlers
if (!is_string($theme)) { if (!is_string($theme)) {
self::p404(); self::p404();
} }
$tplset = dcCore::app()->themes->moduleInfo($theme, 'tplset'); $tplset = dcCore::app()->themes->getDefine($theme)->get('tplset');
$path = My::path() . '/default-templates/'; $path = My::path() . '/default-templates/';
if (!empty($tplset) && is_dir($path . $tplset)) { if (!empty($tplset) && is_dir($path . $tplset)) {
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), $path . $tplset); dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), $path . $tplset);