prepare to DC 2.24
parent
09bcd72b54
commit
152aa8d3c4
|
@ -1,3 +1,6 @@
|
|||
2022.11.12
|
||||
- require Dotclear 2.24
|
||||
|
||||
2022.05.16
|
||||
- require Dotclear 2.22
|
||||
- fix period dates
|
||||
|
|
172
_admin.php
172
_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'] = '<th scope="col">' . __('Period') . '</th>';
|
||||
}
|
||||
}
|
||||
|
@ -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 = '<a href="' . $url . '#period" title="' . __('edit period') . '">' . html::escapeHTML($r->periodical_title) . '</a>';
|
||||
}
|
||||
$cols['period'] = '<td class="nowrap">' . $name . '</td>';
|
||||
|
@ -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
|
|||
'<form action="' . $pa->getURI() . '" method="post">' .
|
||||
$pa->getCheckboxes() .
|
||||
|
||||
self::formPeriod($core) .
|
||||
self::formPeriod() .
|
||||
|
||||
'<p>'.
|
||||
$core->formNonce() .
|
||||
dcCore::app()->formNonce() .
|
||||
$pa->getHiddenFields() .
|
||||
form::hidden(['action'], 'periodical_add') .
|
||||
'<input type="submit" value="' . __('Save') . '" /></p>' .
|
||||
|
@ -407,18 +405,16 @@ class adminPeriodical
|
|||
*/
|
||||
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, $post)
|
||||
{
|
||||
global $core;
|
||||
|
||||
# Get existing linked period
|
||||
$period = '';
|
||||
if ($post) {
|
||||
$rs = self::period($core)->getPosts(['post_id' => $post->post_id]);
|
||||
$rs = self::period()->getPosts(['post_id' => $post->post_id]);
|
||||
$period = $rs->isEmpty() ? '' : $rs->periodical_id;
|
||||
}
|
||||
|
||||
# Set linked period form items
|
||||
$sidebar_items['options-box']['items']['period'] =
|
||||
self::formPeriod($core, $period);
|
||||
self::formPeriod($period);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -429,29 +425,26 @@ class adminPeriodical
|
|||
*/
|
||||
public static function adminAfterPostSave(cursor $cur, $post_id)
|
||||
{
|
||||
global $core;
|
||||
|
||||
if (!isset($_POST['periodical'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
# Delete old linked period
|
||||
self::delPeriod($core, $post_id);
|
||||
self::delPeriod($post_id);
|
||||
|
||||
# Add new linked period
|
||||
self::addPeriod($core, $post_id, $_POST['periodical']);
|
||||
self::addPeriod($post_id, $_POST['periodical']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Posts period form field
|
||||
*
|
||||
* @param dcCore $core dcCore instance
|
||||
* @param string $period Period
|
||||
* @return string Period form content
|
||||
*/
|
||||
protected static function formPeriod(dcCore $core, $period='')
|
||||
protected static function formPeriod($period='')
|
||||
{
|
||||
$combo = self::comboPeriod($core);
|
||||
$combo = self::comboPeriod();
|
||||
|
||||
if (empty($combo)) {
|
||||
return null;
|
||||
|
@ -467,13 +460,12 @@ class adminPeriodical
|
|||
/**
|
||||
* Combo of available periods
|
||||
*
|
||||
* @param dcCore $core dcCore instance
|
||||
* @return array List of period
|
||||
*/
|
||||
protected static function comboPeriod(dcCore $core)
|
||||
protected static function comboPeriod()
|
||||
{
|
||||
if (adminPeriodical::$combo_period === null) {
|
||||
$periods = self::period($core)->getPeriods();
|
||||
$periods = self::period()->getPeriods();
|
||||
|
||||
if ($periods->isEmpty()) {
|
||||
adminPeriodical::$combo_period = [];
|
||||
|
@ -492,27 +484,25 @@ class adminPeriodical
|
|||
/**
|
||||
* Remove period from posts.
|
||||
*
|
||||
* @param dcCore $core dcCore instance
|
||||
* @param integer $post_id Post id
|
||||
*/
|
||||
protected static function delPeriod(dcCore $core, $post_id)
|
||||
protected static function delPeriod($post_id)
|
||||
{
|
||||
if ($post_id === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$post_id = (integer) $post_id;
|
||||
self::period($core)->delPost($post_id);
|
||||
self::period()->delPost($post_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add period to posts
|
||||
*
|
||||
* @param dcCore $core dcCore instance
|
||||
* @param integer $post_id Post id
|
||||
* @param array $period Period
|
||||
*/
|
||||
protected static function addPeriod($core, $post_id, $period)
|
||||
protected static function addPeriod($post_id, $period)
|
||||
{
|
||||
# Not saved
|
||||
if ($post_id === null || empty($period)) {
|
||||
|
@ -520,7 +510,7 @@ class adminPeriodical
|
|||
}
|
||||
|
||||
# Get periods
|
||||
$period = self::period($core)->getPeriods(['periodical_id' => $period]);
|
||||
$period = self::period()->getPeriods(['periodical_id' => $period]);
|
||||
|
||||
# No period
|
||||
if ($period->isEmpty()) {
|
||||
|
@ -530,6 +520,6 @@ class adminPeriodical
|
|||
$post_id = (integer) $post_id;
|
||||
|
||||
# Add relation
|
||||
self::period($core)->addPost($period->periodical_id, $post_id);
|
||||
self::period()->addPost($period->periodical_id, $post_id);
|
||||
}
|
||||
}
|
10
_define.php
10
_define.php
|
@ -19,10 +19,14 @@ $this->registerModule(
|
|||
'Periodical',
|
||||
'Published periodically entries',
|
||||
'Jean-Christian Denis and contributors',
|
||||
'2022.05.16',
|
||||
'2022.11.12',
|
||||
[
|
||||
'requires' => [['core', '2.22']],
|
||||
'permissions' => 'usage,contentadmin',
|
||||
'requires' => [['core', '2.24']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_USAGE,
|
||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
]),
|
||||
'usage,contentadmin',
|
||||
'type' => 'plugin',
|
||||
'support' => 'https://github.com/JcDenis/periodical',
|
||||
'details' => 'https://plugins.dotaddict.org/dc2/details/periodical',
|
||||
|
|
18
_install.php
18
_install.php
|
@ -15,9 +15,9 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||
return null;
|
||||
}
|
||||
|
||||
$dc_min = '2.22';
|
||||
$new_version = $core->plugins->moduleInfo('periodical', 'version');
|
||||
$old_version = $core->getVersion('periodical');
|
||||
$dc_min = '2.24';
|
||||
$new_version = dcCore::app()->plugins->moduleInfo('periodical', 'version');
|
||||
$old_version = dcCore::app()->getVersion('periodical');
|
||||
|
||||
if (version_compare($old_version, $new_version, '>=')) {
|
||||
return null;
|
||||
|
@ -34,7 +34,7 @@ try {
|
|||
}
|
||||
|
||||
# Tables
|
||||
$t = new dbStruct($core->con,$core->prefix);
|
||||
$t = new dbStruct(dcCore::app()->con,dcCore::app()->prefix);
|
||||
|
||||
# Table principale des sondages
|
||||
$t->periodical
|
||||
|
@ -51,23 +51,23 @@ try {
|
|||
->primary('pk_periodical', 'periodical_id')
|
||||
->index('idx_periodical_type', 'btree', 'periodical_type');
|
||||
|
||||
$ti = new dbStruct($core->con, $core->prefix);
|
||||
$ti = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
|
||||
$changes = $ti->synchronize($t);
|
||||
|
||||
# Settings
|
||||
$core->blog->settings->addNamespace('periodical');
|
||||
$s = $core->blog->settings->periodical;
|
||||
dcCore::app()->blog->settings->addNamespace('periodical');
|
||||
$s = dcCore::app()->blog->settings->periodical;
|
||||
$s->put('periodical_active', false, 'boolean', 'Enable extension', false, true);
|
||||
$s->put('periodical_upddate', true, 'boolean', 'Update post date', false, true);
|
||||
$s->put('periodical_updurl', false, 'boolean', 'Update post url', false, true);
|
||||
$s->put('periodical_pub_order', 'post_dt asc', 'string', 'Order of publication', false, true);
|
||||
|
||||
# Version
|
||||
$core->setVersion('periodical', $new_version);
|
||||
dcCore::app()->setVersion('periodical', $new_version);
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
return false;
|
|
@ -15,9 +15,7 @@ if (!defined('DC_RC_PATH')) {
|
|||
return null;
|
||||
}
|
||||
|
||||
$d = dirname(__FILE__) . '/inc/';
|
||||
|
||||
# DB class
|
||||
$__autoload['periodical'] = $d . 'class.periodical.php';
|
||||
Clearbricks::lib()->autoload(['periodical' => __DIR__ . '/inc/class.periodical.php']);
|
||||
# Admin list and pagers
|
||||
$__autoload['adminPeriodicalList'] = $d . 'lib.index.pager.php';
|
||||
Clearbricks::lib()->autoload(['adminPeriodicalList' => __DIR__ . '/inc/lib.index.pager.php']);
|
33
_public.php
33
_public.php
|
@ -15,14 +15,14 @@ if (!defined('DC_RC_PATH')) {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (!in_array($core->url->type, ['default', 'feed'])) {
|
||||
if (!in_array(dcCore::app()->url->type, ['default', 'feed'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$core->blog->settings->addNamespace('periodical');
|
||||
dcCore::app()->blog->settings->addNamespace('periodical');
|
||||
|
||||
$core->addBehavior(
|
||||
'publicBeforeDocument',
|
||||
dcCore::app()->addBehavior(
|
||||
'publicBeforeDocumentV2',
|
||||
['publicPeriodical', 'publicBeforeDocument']
|
||||
);
|
||||
|
||||
|
@ -36,18 +36,17 @@ class publicPeriodical
|
|||
/**
|
||||
* Publish periodical
|
||||
*
|
||||
* @param dcCore $core dcCore instance
|
||||
*/
|
||||
public static function publicBeforeDocument(dcCore $core)
|
||||
public static function publicBeforeDocument()
|
||||
{
|
||||
try {
|
||||
$per = new periodical($core);
|
||||
$s = $core->blog->settings->periodical;
|
||||
$per = new periodical();
|
||||
$s = dcCore::app()->blog->settings->periodical;
|
||||
|
||||
$per->lockUpdate();
|
||||
|
||||
# Get periods
|
||||
$periods = $core->auth->sudo([$per, 'getPeriods']);
|
||||
$periods = dcCore::app()->auth->sudo([$per, 'getPeriods']);
|
||||
|
||||
# No period
|
||||
if ($periods->isEmpty()) {
|
||||
|
@ -61,7 +60,7 @@ class publicPeriodical
|
|||
if (!preg_match('/^(post_dt|post_creadt|post_id) (asc|desc)$/', $posts_order)) {
|
||||
$posts_order = 'post_dt asc';
|
||||
}
|
||||
$cur_period = $core->con->openCursor($core->prefix . 'periodical');
|
||||
$cur_period = dcCore::app()->con->openCursor(dcCore::app()->prefix . 'periodical');
|
||||
|
||||
while($periods->fetch()) {
|
||||
# Check if period is ongoing
|
||||
|
@ -99,10 +98,10 @@ class publicPeriodical
|
|||
$posts_params['order'] = $posts_order;
|
||||
$posts_params['limit'] = $limit * $max_nb;
|
||||
$posts_params['no_content'] = true;
|
||||
$posts = $core->auth->sudo([$per, 'getPosts'], $posts_params);
|
||||
$posts = dcCore::app()->auth->sudo([$per, 'getPosts'], $posts_params);
|
||||
|
||||
if (!$posts->isEmpty()) {
|
||||
$cur_post = $core->con->openCursor($core->prefix . 'post');
|
||||
$cur_post = dcCore::app()->con->openCursor(dcCore::app()->prefix . 'post');
|
||||
|
||||
while($posts->fetch()) {
|
||||
# Publish post with right date
|
||||
|
@ -119,12 +118,12 @@ class publicPeriodical
|
|||
|
||||
# Also update post url with right date
|
||||
if ($s->periodical_updurl) {
|
||||
$cur_post->post_url = $core->blog->getPostURL('', $cur_post->post_dt, $posts->post_title, $posts->post_id);
|
||||
$cur_post->post_url = dcCore::app()->blog->getPostURL('', $cur_post->post_dt, $posts->post_title, $posts->post_id);
|
||||
}
|
||||
|
||||
$cur_post->update(
|
||||
'WHERE post_id = ' . $posts->post_id . ' ' .
|
||||
"AND blog_id = '" . $core->con->escape($core->blog->id) . "' "
|
||||
"AND blog_id = '" . dcCore::app()->con->escape(dcCore::app()->blog->id) . "' "
|
||||
);
|
||||
|
||||
# Delete post relation to this period
|
||||
|
@ -139,10 +138,10 @@ class publicPeriodical
|
|||
}
|
||||
|
||||
# --BEHAVIOR-- periodicalAfterPublishedPeriodicalEntry
|
||||
$core->callBehavior('periodicalAfterPublishedPeriodicalEntry', $core, $posts, $periods);
|
||||
dcCore::app()->callBehavior('periodicalAfterPublishedPeriodicalEntry', $posts, $periods);
|
||||
|
||||
}
|
||||
$core->blog->triggerBlog();
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,7 +150,7 @@ class publicPeriodical
|
|||
$cur_period->periodical_curdt = date('Y-m-d H:i:s', $loop_tz);
|
||||
$cur_period->update(
|
||||
'WHERE periodical_id = ' . $periods->periodical_id . ' ' .
|
||||
"AND blog_id = '" . $core->con->escape($core->blog->id) . "' "
|
||||
"AND blog_id = '" . dcCore::app()->con->escape(dcCore::app()->blog->id) . "' "
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,20 +17,18 @@ if (!defined('DC_RC_PATH')){
|
|||
|
||||
class periodical
|
||||
{
|
||||
public $core;
|
||||
public $con;
|
||||
|
||||
protected $table;
|
||||
protected $blog;
|
||||
private $lock = null;
|
||||
|
||||
public function __construct($core)
|
||||
public function __construct()
|
||||
{
|
||||
$this->core = $core;
|
||||
$this->con = $core->con;
|
||||
$this->con = dcCore::app()->con;
|
||||
|
||||
$this->table = $core->con->escape($core->prefix . 'periodical');
|
||||
$this->blog = $core->con->escape($core->blog->id);
|
||||
$this->table = dcCore::app()->con->escape(dcCore::app()->prefix . 'periodical');
|
||||
$this->blog = dcCore::app()->con->escape(dcCore::app()->blog->id);
|
||||
}
|
||||
|
||||
public function openCursor()
|
||||
|
@ -96,8 +94,8 @@ class periodical
|
|||
$q .= $this->con->limit($params['limit']);
|
||||
}
|
||||
$rs = $this->con->select($q);
|
||||
$rs->core = $this->core;
|
||||
$rs->periodical = $this;
|
||||
//$rs->core = dcCore::app();
|
||||
//$rs->periodical = $this;
|
||||
|
||||
return $rs;
|
||||
}
|
||||
|
@ -114,7 +112,7 @@ class periodical
|
|||
$cur->periodical_id = $id;
|
||||
$cur->blog_id = $this->blog;
|
||||
$cur->periodical_type = 'post';
|
||||
$cur->periodical_tz = $this->core->auth->getInfo('user_tz');
|
||||
$cur->periodical_tz = dcCore::app()->auth->getInfo('user_tz');
|
||||
$cur->insert();
|
||||
$this->con->unlock();
|
||||
} catch (Exception $e) {
|
||||
|
@ -130,7 +128,7 @@ class periodical
|
|||
|
||||
if ($cur->periodical_tz == ''
|
||||
&& ($cur->periodical_curdt != '' || $cur->periodical_enddt != '')) {
|
||||
$cur->periodical_tz = $this->core->auth->getInfo('user_tz');
|
||||
$cur->periodical_tz = dcCore::app()->auth->getInfo('user_tz');
|
||||
}
|
||||
$cur->update(
|
||||
"WHERE blog_id = '" . $this->blog . "' " .
|
||||
|
@ -183,7 +181,7 @@ class periodical
|
|||
}
|
||||
|
||||
$this->con->execute(
|
||||
'DELETE FROM ' . $this->core->prefix . 'meta ' .
|
||||
'DELETE FROM ' . dcCore::app()->prefix . 'meta ' .
|
||||
"WHERE meta_type = 'periodical' " .
|
||||
"AND post_id " . $this->con->in($ids)
|
||||
);
|
||||
|
@ -214,7 +212,7 @@ class periodical
|
|||
$params['columns'][] = 'T.periodical_pub_int';
|
||||
$params['columns'][] = 'T.periodical_pub_nb';
|
||||
|
||||
$params['join'] .= 'LEFT JOIN ' . $this->core->prefix . 'meta R ON P.post_id = R.post_id ';
|
||||
$params['join'] .= 'LEFT JOIN ' . dcCore::app()->prefix . 'meta R ON P.post_id = R.post_id ';
|
||||
$params['join'] .= 'LEFT JOIN ' . $this->table . ' T ON CAST(T.periodical_id as char) = CAST(R.meta_id as char) ';
|
||||
|
||||
$params['sql'] .= "AND R.meta_type = 'periodical' ";
|
||||
|
@ -229,7 +227,7 @@ class periodical
|
|||
$params['sql'] .= 'AND T.periodical_id ' . $this->con->in($params['periodical_id']);
|
||||
unset($params['periodical_id']);
|
||||
}
|
||||
if ($this->core->auth->check('admin', $this->core->blog->id)) {
|
||||
if (dcCore::app()->auth->check('admin', dcCore::app()->blog->id)) {
|
||||
if (isset($params['post_status'])) {
|
||||
if ($params['post_status'] != '') {
|
||||
$params['sql'] .= 'AND P.post_status = ' . (integer) $params['post_status'] . ' ';
|
||||
|
@ -240,7 +238,7 @@ class periodical
|
|||
$params['sql'] .= 'AND P.post_status = -2 ';
|
||||
}
|
||||
|
||||
$rs = $this->core->blog->getPosts($params, $count_only);
|
||||
$rs = dcCore::app()->blog->getPosts($params, $count_only);
|
||||
$rs->periodical = $this;
|
||||
|
||||
return $rs;
|
||||
|
@ -258,8 +256,8 @@ class periodical
|
|||
return;
|
||||
}
|
||||
|
||||
$cur = $this->con->openCursor($this->core->prefix .'meta');
|
||||
$this->con->writeLock($this->core->prefix . 'meta');
|
||||
$cur = $this->con->openCursor(dcCore::app()->prefix .'meta');
|
||||
$this->con->writeLock(dcCore::app()->prefix . 'meta');
|
||||
|
||||
try {
|
||||
$cur->post_id = $post_id;
|
||||
|
@ -279,7 +277,7 @@ class periodical
|
|||
$post_id = (integer) $post_id;
|
||||
|
||||
$this->con->execute(
|
||||
'DELETE FROM ' . $this->core->prefix . 'meta ' .
|
||||
'DELETE FROM ' . dcCore::app()->prefix . 'meta ' .
|
||||
"WHERE meta_type = 'periodical' " .
|
||||
"AND post_id = '" . $post_id . "' "
|
||||
);
|
||||
|
@ -311,7 +309,7 @@ class periodical
|
|||
}
|
||||
|
||||
$this->con->execute(
|
||||
'DELETE FROM ' . $this->core->prefix . 'meta ' .
|
||||
'DELETE FROM ' . dcCore::app()->prefix . 'meta ' .
|
||||
"WHERE meta_type = 'periodical' " .
|
||||
"AND post_id " . $this->con->in($ids)
|
||||
);
|
||||
|
|
|
@ -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'] : '';
|
||||
|
@ -41,7 +41,7 @@ if (!empty($_REQUEST['period_id'])) {
|
|||
'periodical_id' => $_REQUEST['period_id']
|
||||
]);
|
||||
if ($rs->isEmpty()) {
|
||||
$core->error->add(__('This period does not exist.'));
|
||||
dcCore::app()->error->add(__('This period does not exist.'));
|
||||
$period_id = null;
|
||||
} else {
|
||||
$period_id = $rs->periodical_id;
|
||||
|
@ -77,7 +77,7 @@ if ($action == 'setperiod') {
|
|||
}
|
||||
$period_curdt = date('Y-m-d H:i', $period_curdt);
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
if (!empty($_POST['period_enddt'])) {
|
||||
|
@ -90,7 +90,7 @@ if ($action == 'setperiod') {
|
|||
}
|
||||
$period_enddt = date('Y-m-d H:i', $period_enddt);
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,19 +101,19 @@ if ($action == 'setperiod') {
|
|||
if (!$old_titles->isEmpty()) {
|
||||
while($old_titles->fetch()) {
|
||||
if (!$period_id || $old_titles->periodical_id != $period_id) {
|
||||
$core->error->add(__('Period title is already taken'));
|
||||
dcCore::app()->error->add(__('Period title is already taken'));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($period_title)) {
|
||||
$core->error->add(__('Period title is required'));
|
||||
dcCore::app()->error->add(__('Period title is required'));
|
||||
}
|
||||
if (strtotime($period_curdt) > strtotime($period_enddt)) {
|
||||
$core->error->add(__('Start date must be older than end date'));
|
||||
dcCore::app()->error->add(__('Start date must be older than end date'));
|
||||
}
|
||||
|
||||
# If no error, set period
|
||||
if (!$core->error->flag()) {
|
||||
if (!dcCore::app()->error->flag()) {
|
||||
$cur = $per->openCursor();
|
||||
$cur->periodical_title = $period_title;
|
||||
$cur->periodical_curdt = $period_curdt;
|
||||
|
@ -125,14 +125,14 @@ if ($action == 'setperiod') {
|
|||
if ($period_id) {
|
||||
$per->updPeriod($period_id, $cur);
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
dcAdminNotices::addSuccessNotice(
|
||||
__('Period successfully updated.')
|
||||
);
|
||||
# Create period
|
||||
} else {
|
||||
$period_id = $per->addPeriod($cur);
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
dcAdminNotices::addSuccessNotice(
|
||||
__('Period successfully created.')
|
||||
);
|
||||
}
|
||||
|
@ -140,33 +140,33 @@ if ($action == 'setperiod') {
|
|||
if (!empty($_POST['redir'])) {
|
||||
http::redirect($_POST['redir']);
|
||||
} else {
|
||||
$core->adminurl->redirect('admin.plugin.periodical', ['part' => 'period', 'period_id' => $period_id], '#period');
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.periodical', ['part' => 'period', 'period_id' => $period_id], '#period');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Actions on related posts
|
||||
if (!$core->error->flag() && $period_id && $action && !empty($_POST['periodical_entries'])) {
|
||||
if (!dcCore::app()->error->flag() && $period_id && $action && !empty($_POST['periodical_entries'])) {
|
||||
# Publish posts
|
||||
if ($action == 'publish') {
|
||||
try {
|
||||
foreach($_POST['periodical_entries'] as $id) {
|
||||
$id = (integer) $id;
|
||||
$core->blog->updPostStatus($id, 1);
|
||||
dcCore::app()->blog->updPostStatus($id, 1);
|
||||
$per->delPost($id);
|
||||
}
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
dcAdminNotices::addSuccessNotice(
|
||||
__('Entries successfully published.')
|
||||
);
|
||||
|
||||
if (!empty($_POST['redir'])) {
|
||||
http::redirect($_POST['redir']);
|
||||
} else {
|
||||
$core->adminurl->redirect('admin.plugin.periodical', ['part' => 'period', 'period_id' => $period_id], '#posts');
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.periodical', ['part' => 'period', 'period_id' => $period_id], '#posts');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,21 +175,21 @@ if (!$core->error->flag() && $period_id && $action && !empty($_POST['periodical_
|
|||
try {
|
||||
foreach($_POST['periodical_entries'] as $id) {
|
||||
$id = (integer) $id;
|
||||
$core->blog->updPostStatus($id,0);
|
||||
dcCore::app()->blog->updPostStatus($id,0);
|
||||
$per->delPost($id);
|
||||
}
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
dcAdminNotices::addSuccessNotice(
|
||||
__('Entries successfully unpublished.')
|
||||
);
|
||||
|
||||
if (!empty($_POST['redir'])) {
|
||||
http::redirect($_POST['redir']);
|
||||
} else {
|
||||
$core->adminurl->redirect('admin.plugin.periodical', ['part' => 'period', 'period_id' => $period_id], '#posts');
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.periodical', ['part' => 'period', 'period_id' => $period_id], '#posts');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,17 +201,17 @@ if (!$core->error->flag() && $period_id && $action && !empty($_POST['periodical_
|
|||
$per->delPost($id);
|
||||
}
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
dcAdminNotices::addSuccessNotice(
|
||||
__('Entries successfully removed.')
|
||||
);
|
||||
|
||||
if (!empty($_POST['redir'])) {
|
||||
http::redirect($_POST['redir']);
|
||||
} else {
|
||||
$core->adminurl->redirect('admin.plugin.periodical', ['part' => 'period', 'period_id' => $period_id], '#posts');
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.periodical', ['part' => 'period', 'period_id' => $period_id], '#posts');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ if (!$core->error->flag() && $period_id && $action && !empty($_POST['periodical_
|
|||
# Prepare combos for posts list
|
||||
if ($period_id) {
|
||||
# Filters
|
||||
$post_filter = new adminPostFilter($core);
|
||||
$post_filter = new adminPostFilter();
|
||||
$post_filter->add('part', 'period');
|
||||
|
||||
$params = $post_filter->params();
|
||||
|
@ -230,14 +230,14 @@ if ($period_id) {
|
|||
try {
|
||||
$posts = $per->getPosts($params);
|
||||
$counter = $per->getPosts($params, true);
|
||||
$post_list = new adminPeriodicalList($core, $posts, $counter->f(0));
|
||||
$post_list = new adminPeriodicalList(dcCore::app(), $posts, $counter->f(0));
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
$starting_script =
|
||||
dcPage::jsLoad(dcPage::getPF('periodical/js/checkbox.js')) .
|
||||
$post_filter->js($core->adminurl->get('admin.plugin.periodical', ['part' => 'period', 'period_id' => $period_id], '&').'#posts');
|
||||
$post_filter->js(dcCore::app()->adminurl->get('admin.plugin.periodical', ['part' => 'period', 'period_id' => $period_id], '&').'#posts');
|
||||
}
|
||||
|
||||
# Display
|
||||
|
@ -253,7 +253,7 @@ dcPage::jsPageTabs() .
|
|||
echo
|
||||
dcPage::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
__('Periodical') => $p_url . '&part=periods',
|
||||
__('Periodical') => dcCore::app()->admin->getPageURL() . '&part=periods',
|
||||
(null === $period_id ? __('New period') : __('Edit period')) => ''
|
||||
]) .
|
||||
dcPage::notices();
|
||||
|
@ -261,7 +261,7 @@ dcPage::notices();
|
|||
# Period form
|
||||
echo '
|
||||
<div id="period"><h3>' . (null === $period_id ? __('New period') : __('Edit period')) . '</h3>
|
||||
<form method="post" action="' . $p_url . '">
|
||||
<form method="post" action="' . dcCore::app()->admin->getPageURL() . '">
|
||||
|
||||
<p><label for="period_title">' . __('Title:') . '</label>' .
|
||||
form::field('period_title', 60, 255, html::escapeHTML($period_title), 'maximal') . '</p>
|
||||
|
@ -292,7 +292,7 @@ form::number('period_pub_nb', ['min' => 1, 'max' => 20, 'default' => $period_pub
|
|||
|
||||
<div class="clear">
|
||||
<p><input type="submit" name="save" value="' . __('Save') . '" />' .
|
||||
$core->formNonce() .
|
||||
dcCore::app()->formNonce() .
|
||||
form::hidden(['action'], 'setperiod') .
|
||||
form::hidden(['period_id'], $period_id) .
|
||||
form::hidden(['part'], 'period') .'
|
||||
|
@ -301,7 +301,7 @@ form::hidden(['part'], 'period') .'
|
|||
</form>
|
||||
</div>';
|
||||
|
||||
if ($period_id && !$core->error->flag()) {
|
||||
if ($period_id && !dcCore::app()->error->flag()) {
|
||||
|
||||
# Actions combo box
|
||||
$combo_action = [];
|
||||
|
@ -309,7 +309,7 @@ if ($period_id && !$core->error->flag()) {
|
|||
$combo_action[__('Entries')][__('Unpublish')] = 'unpublish';
|
||||
$combo_action[__('Periodical')][__('Remove from periodical')] = 'remove_post_periodical';
|
||||
|
||||
$base_url = $p_url .
|
||||
$base_url = dcCore::app()->admin->getPageURL() .
|
||||
'&period_id=' .$period_id .
|
||||
'&part=period' .
|
||||
'&user_id=' . $post_filter->user_id .
|
||||
|
@ -330,7 +330,7 @@ if ($period_id && !$core->error->flag()) {
|
|||
|
||||
# Filters
|
||||
$post_filter->display(['admin.plugin.periodical', '#posts'],
|
||||
$core->adminurl->getHiddenFormFields('admin.plugin.periodical', [
|
||||
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.periodical', [
|
||||
'period_id' => $period_id,
|
||||
'part' => 'period'
|
||||
])
|
||||
|
@ -338,7 +338,7 @@ if ($period_id && !$core->error->flag()) {
|
|||
|
||||
# Posts list
|
||||
$post_list->postDisplay($post_filter, $base_url,
|
||||
'<form action="' . $p_url . '" method="post" id="form-entries">' .
|
||||
'<form action="' . dcCore::app()->admin->getPageURL() . '" method="post" id="form-entries">' .
|
||||
|
||||
'%s' .
|
||||
|
||||
|
@ -348,11 +348,11 @@ if ($period_id && !$core->error->flag()) {
|
|||
'<p class="col right">' . __('Selected entries action:') . ' ' .
|
||||
form::combo('action', $combo_action) .
|
||||
'<input type="submit" value="' . __('ok') . '" /></p>' .
|
||||
$core->adminurl->getHiddenFormFields('admin.plugin.periodical', array_merge($post_filter->values(), [
|
||||
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.periodical', array_merge($post_filter->values(), [
|
||||
'period_id' => $period_id,
|
||||
'redir' => sprintf($base_url, $post_filter->page)
|
||||
])) .
|
||||
$core->formNonce() .
|
||||
dcCore::app()->formNonce() .
|
||||
'</div>' .
|
||||
'</form>'
|
||||
);
|
||||
|
|
|
@ -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
|
||||
'<html><head><title>' . __('Periodical') . '</title>' .
|
||||
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'])) .
|
||||
'</head>' .
|
||||
'<body>' .
|
||||
|
||||
|
@ -102,7 +102,7 @@ dcPage::breadcrumb([
|
|||
dcPage::notices() .
|
||||
|
||||
'<p class="top-add">
|
||||
<a class="button add" href="' . $p_url . '&part=period">' . __('New period') . '</a>
|
||||
<a class="button add" href="' . dcCore::app()->admin->getPageURL() . '&part=period">' . __('New period') . '</a>
|
||||
</p>';
|
||||
|
||||
# Filters
|
||||
|
@ -110,7 +110,7 @@ $p_filter->display('admin.plugin.periodical', form::hidden('p', 'periodical') .
|
|||
|
||||
# Periods list
|
||||
$period_list->periodDisplay($p_filter,
|
||||
'<form action="' . $p_url . '" method="post" id="form-periods">' .
|
||||
'<form action="' . dcCore::app()->admin->getPageURL() . '" method="post" id="form-periods">' .
|
||||
|
||||
'%s' .
|
||||
|
||||
|
@ -120,8 +120,8 @@ $period_list->periodDisplay($p_filter,
|
|||
'<p class="col right">' . __('Selected periods action:') . ' ' .
|
||||
form::combo('action', $combo_action) .
|
||||
'<input type="submit" value="' . __('ok') . '" /></p>' .
|
||||
$core->adminurl->getHiddenFormFields('admin.plugin.periodical', array_merge(['p' => 'periodical'], $p_filter->values(true))) .
|
||||
$core->formNonce() .
|
||||
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.periodical', array_merge(['p' => 'periodical'], $p_filter->values(true))) .
|
||||
dcCore::app()->formNonce() .
|
||||
'</div>' .
|
||||
'</form>'
|
||||
);
|
||||
|
|
|
@ -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 '<p><strong>' . __('No period') . '</strong></p>';
|
||||
}
|
||||
} 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 = '<a href="' . $url . '#period" title="' . __('edit period') . '">' . html::escapeHTML($this->rs->periodical_title) . '</a>';
|
||||
|
||||
|
@ -84,8 +87,8 @@ class adminPeriodicalList extends adminGenericList
|
|||
'<a href="' . $url . '#posts" title="' . __('view related entries') . '">' . $nb_posts . '</a>' :
|
||||
'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' => '<td class="nowrap">' . form::checkbox(['periods[]'], $this->rs->periodical_id, ['checked' => $checked]) . '</td>',
|
||||
|
@ -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 = '<a href="category.php?id=%s">%s</a>';
|
||||
} else {
|
||||
$cat_link = '%2$s';
|
||||
|
|
|
@ -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';
|
||||
}
|
|
@ -15,4 +15,4 @@ if (!defined('DC_RC_PATH')) {
|
|||
return null;
|
||||
}
|
||||
|
||||
$__resources['help']['periodical'] = dirname(__FILE__) . '/help/help.html';
|
||||
dcCore::app()->resources['help']['periodical'] = __DIR__ . '/help/help.html';
|
|
@ -15,4 +15,4 @@ if (!defined('DC_RC_PATH')) {
|
|||
return null;
|
||||
}
|
||||
|
||||
$__resources['help']['periodical'] = dirname(__FILE__) . '/help/help.html';
|
||||
dcCore::app()->resources['help']['periodical'] = __DIR__ . '/help/help.html';
|
Loading…
Reference in New Issue