diff --git a/CHANGELOG.md b/CHANGELOG.md
index e93a1eb..fb9114f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,6 @@
+2022.11.12
+- require Dotclear 2.24
+
2022.05.16
- require Dotclear 2.22
- fix period dates
diff --git a/_admin.php b/_admin.php
index 85c0675..af35f64 100644
--- a/_admin.php
+++ b/_admin.php
@@ -15,74 +15,73 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
-$core->blog->settings->addNamespace('periodical');
+dcCore::app()->blog->settings->addNamespace('periodical');
-$core->addBehavior(
- 'adminBlogPreferencesForm',
+dcCore::app()->addBehavior(
+ 'adminBlogPreferencesFormV2',
['adminPeriodical', 'adminBlogPreferencesForm']
);
-$core->addBehavior(
+dcCore::app()->addBehavior(
'adminBeforeBlogSettingsUpdate',
['adminPeriodical', 'adminBeforeBlogSettingsUpdate']
);
-$core->addBehavior(
- 'adminFiltersLists',
+dcCore::app()->addBehavior(
+ 'adminFiltersListsV2',
['adminPeriodical', 'adminFiltersLists']
);
-$core->addBehavior(
- 'adminColumnsLists',
+dcCore::app()->addBehavior(
+ 'adminColumnsListsV2',
['adminPeriodical', 'adminColumnsLists']
);
-$core->addBehavior(
- 'adminColumnsLists',
- ['adminPeriodical', 'adminColumnsLists']
-);
-$core->addBehavior(
- 'adminPostListHeader',
+dcCore::app()->addBehavior(
+ 'adminPostListHeaderV2',
['adminPeriodical', 'adminPostListHeader']
);
-$core->addBehavior(
- 'adminPostListValue',
+dcCore::app()->addBehavior(
+ 'adminPostListValueV2',
['adminPeriodical', 'adminPostListValue']
);
-if ($core->blog->settings->periodical->periodical_active) {
+if (dcCore::app()->blog->settings->periodical->periodical_active) {
- $_menu['Plugins']->addItem(
+ dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('Periodical'),
- $core->adminurl->get('admin.plugin.periodical'),
+ dcCore::app()->adminurl->get('admin.plugin.periodical'),
dcPage::getPF('periodical/icon.png'),
- preg_match('/' . preg_quote($core->adminurl->get('admin.plugin.periodical')) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
- $core->auth->check('usage,contentadmin', $core->blog->id)
+ preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.periodical')) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
+ dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
+ dcAuth::PERMISSION_USAGE,
+ dcAuth::PERMISSION_CONTENT_ADMIN,
+ ]), dcCore::app()->blog->id)
);
- $core->addBehavior(
- 'adminDashboardFavorites',
+ dcCore::app()->addBehavior(
+ 'adminDashboardFavoritesV2',
['adminPeriodical', 'adminDashboardFavorites']
);
- $core->addBehavior(
+ dcCore::app()->addBehavior(
'adminPostHeaders',
['adminPeriodical', 'adminPostHeaders']
);
- $core->addBehavior(
- 'adminPostsActionsPage',
- ['adminPeriodical', 'adminPostsActionsPage']
+ dcCore::app()->addBehavior(
+ 'adminPostsActions',
+ ['adminPeriodical', 'adminPostsActions']
);
- $core->addBehavior(
+ dcCore::app()->addBehavior(
'adminPostFormItems',
['adminPeriodical', 'adminPostFormItems']
);
- $core->addBehavior(
+ dcCore::app()->addBehavior(
'adminAfterPostUpdate',
['adminPeriodical', 'adminAfterPostSave']
);
- $core->addBehavior(
+ dcCore::app()->addBehavior(
'adminAfterPostCreate',
['adminPeriodical', 'adminAfterPostSave']
);
}
-$core->addBehavior(
+dcCore::app()->addBehavior(
'adminBeforePostDelete',
['adminPeriodical', 'adminBeforePostDelete']
);
@@ -106,10 +105,10 @@ class adminPeriodical
];
}
- protected static function period($core)
+ protected static function period()
{
if (self::$per === null) {
- self::$per = new periodical($core);
+ self::$per = new periodical();
}
return self::$per;
}
@@ -117,10 +116,9 @@ class adminPeriodical
/**
* Add settings to blog preference
*
- * @param dcCore $core dcCore instance
* @param dcSettings $blog_settings dcSettings instance
*/
- public static function adminBlogPreferencesForm(dcCore $core, dcSettings $blog_settings)
+ public static function adminBlogPreferencesForm(dcSettings $blog_settings)
{
$s_active = (boolean) $blog_settings->periodical->periodical_active;
$s_upddate = (boolean) $blog_settings->periodical->periodical_upddate;
@@ -162,10 +160,9 @@ class adminPeriodical
/**
* User pref for periods columns lists.
*
- * @param dcCore $core dcCore instance
* @param arrayObject $cols Columns
*/
- public static function adminColumnsLists(dcCore $core, $cols)
+ public static function adminColumnsLists($cols)
{
$cols['periodical'] = [
__('Periodical'),
@@ -184,10 +181,9 @@ class adminPeriodical
/**
* User pref periods filters options.
*
- * @param dcCore $core dcCore instance
* @param arrayObject $sorts Sort options
*/
- public static function adminFiltersLists(dcCore $core, $sorts)
+ public static function adminFiltersLists($sorts)
{
$sorts['periodical'] = [
__('Periodical'),
@@ -201,13 +197,12 @@ class adminPeriodical
/**
* Add columns period to posts list header.
*
- * @param dcCore $core dcCore instance
* @param record $rs record instance
* @param arrayObject $cols Columns
*/
- public static function adminPostListHeader(dcCore $core, $rs, $cols)
+ public static function adminPostListHeader($rs, $cols)
{
- if ($core->blog->settings->periodical->periodical_active) {
+ if (dcCore::app()->blog->settings->periodical->periodical_active) {
$cols['period'] = '
' . __('Period') . ' | ';
}
}
@@ -215,21 +210,20 @@ class adminPeriodical
/**
* Add columns period to posts list values.
*
- * @param dcCore $core dcCore instance
* @param record $rs record instance
* @param arrayObject $cols Columns
*/
- public static function adminPostListValue(dcCore $core, $rs, $cols)
+ public static function adminPostListValue($rs, $cols)
{
- if (!$core->blog->settings->periodical->periodical_active) {
+ if (!dcCore::app()->blog->settings->periodical->periodical_active) {
return null;
}
- $r = self::period($core)->getPosts(['post_id' => $rs->post_id]);
+ $r = self::period()->getPosts(['post_id' => $rs->post_id]);
if ($r->isEmpty()) {
$name = '-';
} else {
- $url = $core->adminurl->get('admin.plugin.periodical', ['part' => 'period', 'period_id' => $r->periodical_id]);
+ $url = dcCore::app()->adminurl->get('admin.plugin.periodical', ['part' => 'period', 'period_id' => $r->periodical_id]);
$name = '' . html::escapeHTML($r->periodical_title) . '';
}
$cols['period'] = '' . $name . ' | ';
@@ -238,19 +232,20 @@ class adminPeriodical
/**
* Favorites.
*
- * @param dcCore $core dcCore instance
* @param arrayObject $favs Array of favorites
*/
- public static function adminDashboardFavorites(dcCore $core, $favs)
+ public static function adminDashboardFavorites(dcFavorites $favs)
{
$favs->register('periodical', [
'title' => __('Periodical'),
'url' => 'plugin.php?p=periodical',
'small-icon' => 'index.php?pf=periodical/icon.png',
'large-icon' => 'index.php?pf=periodical/icon-big.png',
- 'permissions' => $core->auth->check(
- 'usage,contentadmin',
- $core->blog->id
+ 'permissions' => dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
+ dcAuth::PERMISSION_USAGE,
+ dcAuth::PERMISSION_CONTENT_ADMIN,
+ ]),
+ dcCore::app()->blog->id
),
'active_cb' => [
'adminPeriodical',
@@ -289,23 +284,25 @@ class adminPeriodical
*/
public static function adminBeforePostDelete($post_id)
{
- self::delPeriod($GLOBALS['core'], $post_id);
+ self::delPeriod($post_id);
}
/**
* Add actions to posts page combo
*
- * @param dcCore $core dcCore instance
- * @param dcPostsActionsPage $ap dcPostsActionsPage instance
+ * @param dcPostsActions $ap dcPostsActions instance
*/
- public static function adminPostsActionsPage(dcCore $core, dcPostsActionsPage $pa)
+ public static function adminPostsActions(dcPostsActions $pa)
{
$pa->addAction(
[__('Periodical') => [__('Add to periodical') => 'periodical_add']],
['adminPeriodical', 'callbackAdd']
);
- if (!$core->auth->check('delete,contentadmin', $core->blog->id)) {
+ if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
+ dcAuth::PERMISSION_DELETE,
+ dcAuth::PERMISSION_CONTENT_ADMIN,
+ ]), dcCore::app()->blog->id)) {
return null;
}
$pa->addAction(
@@ -317,11 +314,10 @@ class adminPeriodical
/**
* Posts actions callback to remove period
*
- * @param dcCore $core dcCore instance
- * @param dcPostsActionsPage $pa dcPostsActionsPage instance
+ * @param dcPostsActions $pa dcPostsActions instance
* @param ArrayObject $post _POST actions
*/
- public static function callbackRemove(dcCore $core, dcPostsActionsPage $pa, ArrayObject $post)
+ public static function callbackRemove(dcPostsActions $pa, ArrayObject $post)
{
# No entry
$posts_ids = $pa->getIDs();
@@ -330,13 +326,16 @@ class adminPeriodical
}
# No right
- if (!$core->auth->check('delete,contentadmin', $core->blog->id)) {
+ if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
+ dcAuth::PERMISSION_DELETE,
+ dcAuth::PERMISSION_CONTENT_ADMIN,
+ ]), dcCore::app()->blog->id)) {
throw new Exception(__('No enough right'));
}
# Remove linked period
foreach($posts_ids as $post_id) {
- self::delPeriod($core, $post_id);
+ self::delPeriod($post_id);
}
dcPage::addSuccessNotice(__('Posts have been removed from periodical.'));
@@ -346,11 +345,10 @@ class adminPeriodical
/**
* Posts actions callback to add period
*
- * @param dcCore $core dcCore instance
- * @param dcPostsActionsPage $pa dcPostsActionsPage instance
+ * @param dcPostsActions $pa dcPostsActions instance
* @param ArrayObject $post _POST actions
*/
- public static function callbackAdd(dcCore $core, dcPostsActionsPage $pa, ArrayObject $post)
+ public static function callbackAdd(dcPostsActions $pa, ArrayObject $post)
{
# No entry
$posts_ids = $pa->getIDs();
@@ -363,8 +361,8 @@ class adminPeriodical
# Save action
if (!empty($post['periodical'])) {
foreach($posts_ids as $post_id) {
- self::delPeriod($core, $post_id);
- self::addPeriod($core, $post_id, $post['periodical']);
+ self::delPeriod($post_id);
+ self::addPeriod($post_id, $post['periodical']);
}
dcPage::addSuccessNotice(__('Posts have been added to periodical.'));
@@ -375,7 +373,7 @@ class adminPeriodical
else {
$pa->beginPage(
dcPage::breadcrumb(array(
- html::escapeHTML($core->blog->name) => '',
+ html::escapeHTML(dcCore::app()->blog->name) => '',
$pa->getCallerTitle() => $pa->getRedirection(true),
__('Add a period to this selection') => ''
))
@@ -385,10 +383,10 @@ class adminPeriodical
''
);
diff --git a/inc/index.periods.php b/inc/index.periods.php
index bca9d9f..27d943e 100644
--- a/inc/index.periods.php
+++ b/inc/index.periods.php
@@ -15,10 +15,10 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
-dcPage::check('usage,contentadmin');
+dcPage::check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_USAGE, dcAuth::PERMISSION_CONTENT_ADMIN]));
# Objects
-$per = new periodical($core);
+$per = new periodical();
# Default values
$action = isset($_POST['action']) ? $_POST['action'] : '';
@@ -32,17 +32,17 @@ if ($action == 'deleteperiods' && !empty($_POST['periods'])) {
$per->delPeriod($id);
}
- dcPage::addSuccessNotice(
+ dcAdminNotices::addSuccessNotice(
__('Periods removed.')
);
if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']);
} else {
- $core->adminurl->redirect('admin.plugin.periodical', ['part' => 'periods']);
+ dcCore::app()->adminurl->redirect('admin.plugin.periodical', ['part' => 'periods']);
}
} catch (Exception $e) {
- $core->error->add($e->getMessage());
+ dcCore::app()->error->add($e->getMessage());
}
}
# Delete periods related posts links (without delete periods)
@@ -53,17 +53,17 @@ if ($action == 'emptyperiods' && !empty($_POST['periods'])) {
$per->delPeriodPosts($id);
}
- dcPage::addSuccessNotice(
+ dcAdminNotices::addSuccessNotice(
__('Periods emptied.')
);
if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']);
} else {
- $core->adminurl->redirect('admin.plugin.periodical', ['part' => 'periods']);
+ dcCore::app()->adminurl->redirect('admin.plugin.periodical', ['part' => 'periods']);
}
} catch (Exception $e) {
- $core->error->add($e->getMessage());
+ dcCore::app()->error->add($e->getMessage());
}
}
@@ -73,7 +73,7 @@ $combo_action = [
];
# Filters
-$p_filter = new adminGenericFilter($core, 'periodical');
+$p_filter = new adminGenericFilter(dcCore::app(), 'periodical');
$p_filter->add('part', 'periods');
$params = $p_filter->params();
@@ -82,16 +82,16 @@ $params = $p_filter->params();
try {
$periods = $per->getPeriods($params);
$counter = $per->getPeriods($params, true);
- $period_list = new adminPeriodicalList($core, $periods, $counter->f(0));
+ $period_list = new adminPeriodicalList(dcCore::app(), $periods, $counter->f(0));
} catch (Exception $e) {
- $core->error->add($e->getMessage());
+ dcCore::app()->error->add($e->getMessage());
}
# Display
echo
'' . __('Periodical') . '' .
dcPage::jsLoad(dcPage::getPF('periodical/js/checkbox.js')) .
-$p_filter->js($core->adminurl->get('admin.plugin.periodical', ['part' => 'periods'])) .
+$p_filter->js(dcCore::app()->adminurl->get('admin.plugin.periodical', ['part' => 'periods'])) .
'' .
'' .
@@ -102,7 +102,7 @@ dcPage::breadcrumb([
dcPage::notices() .
'
-' . __('New period') . '
+' . __('New period') . '
';
# Filters
@@ -110,7 +110,7 @@ $p_filter->display('admin.plugin.periodical', form::hidden('p', 'periodical') .
# Periods list
$period_list->periodDisplay($p_filter,
- ''
);
diff --git a/inc/lib.index.pager.php b/inc/lib.index.pager.php
index 8924f22..1426290 100644
--- a/inc/lib.index.pager.php
+++ b/inc/lib.index.pager.php
@@ -22,6 +22,8 @@ if (!defined('DC_CONTEXT_ADMIN')) {
*/
class adminPeriodicalList extends adminGenericList
{
+ private $periodical = null;
+
public function periodDisplay($filter, $enclose_block='')
{
if ($this->rs->isEmpty()) {
@@ -31,7 +33,8 @@ class adminPeriodicalList extends adminGenericList
echo '' . __('No period') . '
';
}
} else {
- $pager = new dcPager($filter->page, $this->rs_count, $filter->nb, 10);
+ $this->periodical = new periodical();
+ $pager = new dcPager((int) $filter->page, $this->rs_count, $filter->nb, 10);
$pager->var_page = 'page';
$periods = [];
@@ -75,8 +78,8 @@ class adminPeriodicalList extends adminGenericList
private function periodLine($checked)
{
- $nb_posts = $this->rs->periodical->getPosts(['periodical_id' => $this->rs->periodical_id], true)->f(0);
- $url = $this->core->adminurl->get('admin.plugin.periodical', ['part' => 'period', 'period_id' => $this->rs->periodical_id]);
+ $nb_posts = $this->periodical->getPosts(['periodical_id' => $this->rs->periodical_id], true)->f(0);
+ $url = dcCore::app()->adminurl->get('admin.plugin.periodical', ['part' => 'period', 'period_id' => $this->rs->periodical_id]);
$name = '' . html::escapeHTML($this->rs->periodical_title) . '';
@@ -84,8 +87,8 @@ class adminPeriodicalList extends adminGenericList
'' . $nb_posts . '' :
'0';
- $interval = in_array($this->rs->periodical_pub_int, $this->rs->periodical->getTimesCombo()) ?
- __(array_search($this->rs->periodical_pub_int, $this->rs->periodical->getTimesCombo())) : __('Unknow frequence');
+ $interval = in_array($this->rs->periodical_pub_int, $this->periodical->getTimesCombo()) ?
+ __(array_search($this->rs->periodical_pub_int, $this->periodical->getTimesCombo())) : __('Unknow frequence');
$cols = new ArrayObject([
'check' => '' . form::checkbox(['periods[]'], $this->rs->periodical_id, ['checked' => $checked]) . ' | ',
@@ -169,7 +172,7 @@ class adminPeriodicalList extends adminGenericList
private function postLine($checked)
{
- if ($this->core->auth->check('categories', $this->core->blog->id)) {
+ if (dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_CATEGORIES]), dcCore::app()->blog->id)) {
$cat_link = '%s';
} else {
$cat_link = '%2$s';
diff --git a/index.php b/index.php
index 387026b..4963ded 100644
--- a/index.php
+++ b/index.php
@@ -18,7 +18,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
$part = !empty($_REQUEST['part']) ? $_REQUEST['part'] : 'periods';
if ($part == 'period') {
- include dirname(__FILE__) . '/inc/index.period.php';
+ include __DIR__ . '/inc/index.period.php';
} else {
- include dirname(__FILE__) . '/inc/index.periods.php';
+ include __DIR__ . '/inc/index.periods.php';
}
\ No newline at end of file
diff --git a/locales/en/resources.php b/locales/en/resources.php
index 71c7abb..f61f0bd 100644
--- a/locales/en/resources.php
+++ b/locales/en/resources.php
@@ -15,4 +15,4 @@ if (!defined('DC_RC_PATH')) {
return null;
}
-$__resources['help']['periodical'] = dirname(__FILE__) . '/help/help.html';
\ No newline at end of file
+dcCore::app()->resources['help']['periodical'] = __DIR__ . '/help/help.html';
\ No newline at end of file
diff --git a/locales/fr/resources.php b/locales/fr/resources.php
index 71c7abb..f61f0bd 100644
--- a/locales/fr/resources.php
+++ b/locales/fr/resources.php
@@ -15,4 +15,4 @@ if (!defined('DC_RC_PATH')) {
return null;
}
-$__resources['help']['periodical'] = dirname(__FILE__) . '/help/help.html';
\ No newline at end of file
+dcCore::app()->resources['help']['periodical'] = __DIR__ . '/help/help.html';
\ No newline at end of file