upgrade to Dotclear 2.27

This commit is contained in:
Jean-Christian 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"'),
'zoneclearFeedServerAfterUpdateFeed',
function (Cursor $cur, int $id): void {
$user = dcCore::app()->auth?->getInfo('user_cn');
$user = dcCore::app()->auth->getInfo('user_cn');
if (!is_string($user)) {
return;
}
@ -64,7 +64,7 @@ class ActivityReportActions
__('A new feed named "%s" point to "%s" was added by "%s"'),
'zoneclearFeedServerAfterAddFeed',
function (Cursor $cur, int $id): void {
$user = dcCore::app()->auth?->getInfo('user_cn');
$user = dcCore::app()->auth->getInfo('user_cn');
if (!is_string($user)
|| !is_string($cur->getField('feed_name'))
|| !is_string($cur->getField('feed_feed'))
@ -115,7 +115,7 @@ class ActivityReportActions
}
$row = new FeedRow($rs);
$user = dcCore::app()->auth?->getInfo('user_cn');
$user = dcCore::app()->auth->getInfo('user_cn');
if (!is_string($user)) {
return;
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -15,10 +15,12 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer;
use ArrayObject;
use adminGenericFilterV2;
use adminGenericListV2;
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,
@ -32,9 +34,9 @@ use Dotclear\Helper\Html\Html;
/**
* 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()) {
echo
@ -53,7 +55,7 @@ class FeedsList extends adminGenericListV2
$page = is_numeric($filter->value('page')) ? (int) $filter->value('page') : 1;
$nbpp = is_numeric($filter->value('nb')) ? (int) $filter->value('nb') : 10;
$count = (int) $this->rs_count;
$pager = new dcPager($page, $count, $nbpp, 10);
$pager = new Pager($page, $count, $nbpp, 10);
$cols = new ArrayObject([
'title' => (new Text('th', __('Name')))
@ -120,11 +122,11 @@ class FeedsList extends adminGenericListV2
$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)) {
$url = '';
}
$tz = dcCore::app()->auth?->getInfo('user_tz');
$tz = dcCore::app()->auth->getInfo('user_tz');
if (!is_string($tz)) {
$tz = 'UTC';
}

View file

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

View file

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

View file

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

View file

@ -14,15 +14,15 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer;
use dcCore;
use Dotclear\Module\MyPlugin;
/**
* This module definitions.
*/
class My
class My extends MyPlugin
{
/** @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 */
public const META_PREFIX = 'zoneclearfeed_';
@ -55,29 +55,8 @@ class My
'FeedFeedURL',
];
/**
* This module id.
*/
public static function id(): string
public static function checkCustomContext(int $context): ?bool
{
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__);
return $context == My::BACKEND ? defined('DC_CONTEXT_ADMIN') : null;
}
}

View file

@ -15,19 +15,21 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer;
use ArrayObject;
use adminGenericFilterV2;
use dcAdminCombos;
use dcAdminFilter;
use dcAdminFilters;
use dcCore;
use dcUtils;
use Dotclear\Core\Backend\Combos;
use Dotclear\Core\Backend\Filter\{
Filter,
Filters,
FiltersLibrary
};
use Dotclear\Helper\Html\Html;
use Exception;
/**
* Backend feed posts list filters.
*/
class PostsFilter extends adminGenericFilterV2
class PostsFilter extends Filters
{
public function __construct()
{
@ -35,7 +37,7 @@ class PostsFilter extends adminGenericFilterV2
parent::__construct('posts');
$filters = new ArrayObject([
dcAdminFilters::getPageFilter(),
FiltersLibrary::getPageFilter(),
$this->getPostUserFilter(),
$this->getPostCategoriesFilter(),
$this->getPostStatusFilter(),
@ -53,7 +55,7 @@ class PostsFilter extends adminGenericFilterV2
/**
* Posts users select
*
* @return null|dcAdminFilter
* @return null|Filter
*/
public function getPostUserFilter()
{
@ -70,10 +72,10 @@ class PostsFilter extends adminGenericFilterV2
return null;
}
$combo = dcAdminCombos::getUsersCombo($users);
$combo = Combos::getUsersCombo($users);
dcUtils::lexicalKeySort($combo);
return (new dcAdminFilter('user_id'))
return (new Filter('user_id'))
->param()
->title(__('Author:'))
->options(array_merge(
@ -86,7 +88,7 @@ class PostsFilter extends adminGenericFilterV2
/**
* Posts categories select
*
* @return null|dcAdminFilter
* @return null|Filter
*/
public function getPostCategoriesFilter()
{
@ -116,7 +118,7 @@ class PostsFilter extends adminGenericFilterV2
}
}
return (new dcAdminFilter('cat_id'))
return (new Filter('cat_id'))
->param()
->title(__('Category:'))
->options($combo)
@ -126,21 +128,21 @@ class PostsFilter extends adminGenericFilterV2
/**
* Posts status select
*/
public function getPostStatusFilter(): dcAdminFilter
public function getPostStatusFilter(): Filter
{
return (new dcAdminFilter('status'))
return (new Filter('status'))
->param('post_status')
->title(__('Status:'))
->options(array_merge(
['-' => ''],
dcAdminCombos::getPostStatusesCombo()
Combos::getPostStatusesCombo()
));
}
/**
* Posts by month select
*
* @return null|dcAdminFilter
* @return null|Filter
*/
public function getPostMonthFilter()
{
@ -157,13 +159,13 @@ class PostsFilter extends adminGenericFilterV2
return null;
}
return (new dcAdminFilter('month'))
return (new Filter('month'))
->param('post_month', function ($f) { return substr($f[0], 4, 2); })
->param('post_year', function ($f) { return substr($f[0], 0, 4); })
->title(__('Month:'))
->options(array_merge(
['-' => ''],
dcAdminCombos::getDatesCombo($dates)
Combos::getDatesCombo($dates)
));
}
}

View file

@ -15,9 +15,11 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer;
use ArrayObject;
use adminGenericListV2;
use dcCore;
use dcPager;
use Dotclear\Core\Backend\Listing\{
Listing,
Pager
};
use Dotclear\Helper\Date;
use Dotclear\Helper\Html\Form\{
Checkbox,
@ -31,7 +33,7 @@ use Dotclear\Helper\Html\Html;
/**
* Backend feed posts lists.
*/
class PostsList extends adminGenericListV2
class PostsList extends Listing
{
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;
$nbpp = is_numeric($filter->value('nb')) ? (int) $filter->value('nb') : 10;
$count = (int) $this->rs_count;
$pager = new dcPager($page, $count, $nbpp, 10);
$pager = new Pager($page, $count, $nbpp, 10);
$pager->base_url = $base_url;
$cols = new ArrayObject([
@ -106,7 +108,7 @@ class PostsList extends adminGenericListV2
{
$cat_title = (new Text('', __('None')));
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())
->href('category.php?id=' . $this->rs->cat_id)

View file

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

View file

@ -14,9 +14,6 @@ declare(strict_types=1);
namespace Dotclear\Plugin\zoneclearFeedServer;
use dcCore;
use Exception;
/**
* Module settings (type hinting).
*/
@ -52,11 +49,7 @@ class Settings
*/
protected function __construct()
{
if (is_null(dcCore::app()->blog)) {
throw new Exception(__('Blog is not defined'));
}
$s = dcCore::app()->blog->settings->get(My::id());
$s = My::settings();
$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
{
$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) {
$s->drop($key);

View file

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

View file

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