fix old core call, and some psr, phpstan stuff
This commit is contained in:
parent
24491b0676
commit
8649c2c11e
12 changed files with 327 additions and 313 deletions
50
_admin.php
50
_admin.php
|
@ -10,7 +10,6 @@
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +42,6 @@ dcCore::app()->addBehavior(
|
||||||
);
|
);
|
||||||
|
|
||||||
if (dcCore::app()->blog->settings->periodical->periodical_active) {
|
if (dcCore::app()->blog->settings->periodical->periodical_active) {
|
||||||
|
|
||||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||||
__('Periodical'),
|
__('Periodical'),
|
||||||
dcCore::app()->adminurl->get('admin.plugin.periodical'),
|
dcCore::app()->adminurl->get('admin.plugin.periodical'),
|
||||||
|
@ -101,7 +99,7 @@ class adminPeriodical
|
||||||
return [
|
return [
|
||||||
__('Next update') => 'periodical_curdt',
|
__('Next update') => 'periodical_curdt',
|
||||||
__('End date') => 'periodical_enddt',
|
__('End date') => 'periodical_enddt',
|
||||||
__('Frequence') => 'periodical_pub_int'
|
__('Frequence') => 'periodical_pub_int',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +108,7 @@ class adminPeriodical
|
||||||
if (self::$per === null) {
|
if (self::$per === null) {
|
||||||
self::$per = new periodical();
|
self::$per = new periodical();
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$per;
|
return self::$per;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,9 +119,9 @@ class adminPeriodical
|
||||||
*/
|
*/
|
||||||
public static function adminBlogPreferencesForm(dcSettings $blog_settings)
|
public static function adminBlogPreferencesForm(dcSettings $blog_settings)
|
||||||
{
|
{
|
||||||
$s_active = (boolean) $blog_settings->periodical->periodical_active;
|
$s_active = (bool) $blog_settings->periodical->periodical_active;
|
||||||
$s_upddate = (boolean) $blog_settings->periodical->periodical_upddate;
|
$s_upddate = (bool) $blog_settings->periodical->periodical_upddate;
|
||||||
$s_updurl = (boolean) $blog_settings->periodical->periodical_updurl;
|
$s_updurl = (bool) $blog_settings->periodical->periodical_updurl;
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<div class="fieldset"><h4 id="periodical_params">' . __('Periodical') . '</h4>' .
|
'<div class="fieldset"><h4 id="periodical_params">' . __('Periodical') . '</h4>' .
|
||||||
|
@ -171,8 +170,8 @@ class adminPeriodical
|
||||||
'pub_int' => [true, __('Frequency')],
|
'pub_int' => [true, __('Frequency')],
|
||||||
'pub_nb' => [true, __('Entries per update')],
|
'pub_nb' => [true, __('Entries per update')],
|
||||||
'nbposts' => [true, __('Entries')],
|
'nbposts' => [true, __('Entries')],
|
||||||
'enddt' => [true, __('End date')]
|
'enddt' => [true, __('End date')],
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$cols['posts'][1]['period'] = [true, __('Period')];
|
$cols['posts'][1]['period'] = [true, __('Period')];
|
||||||
|
@ -190,7 +189,7 @@ class adminPeriodical
|
||||||
self::sortbyCombo(),
|
self::sortbyCombo(),
|
||||||
'periodical_curdt',
|
'periodical_curdt',
|
||||||
'desc',
|
'desc',
|
||||||
[__('periods per page'), 10]
|
[__('periods per page'), 10],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +231,7 @@ class adminPeriodical
|
||||||
/**
|
/**
|
||||||
* Favorites.
|
* Favorites.
|
||||||
*
|
*
|
||||||
* @param arrayObject $favs Array of favorites
|
* @param dcFavorites $favs Array of favorites
|
||||||
*/
|
*/
|
||||||
public static function adminDashboardFavorites(dcFavorites $favs)
|
public static function adminDashboardFavorites(dcFavorites $favs)
|
||||||
{
|
{
|
||||||
|
@ -241,7 +240,8 @@ class adminPeriodical
|
||||||
'url' => 'plugin.php?p=periodical',
|
'url' => 'plugin.php?p=periodical',
|
||||||
'small-icon' => 'index.php?pf=periodical/icon.png',
|
'small-icon' => 'index.php?pf=periodical/icon.png',
|
||||||
'large-icon' => 'index.php?pf=periodical/icon-big.png',
|
'large-icon' => 'index.php?pf=periodical/icon-big.png',
|
||||||
'permissions' => dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
'permissions' => dcCore::app()->auth->check(
|
||||||
|
dcCore::app()->auth->makePermissions([
|
||||||
dcAuth::PERMISSION_USAGE,
|
dcAuth::PERMISSION_USAGE,
|
||||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||||
]),
|
]),
|
||||||
|
@ -249,8 +249,8 @@ class adminPeriodical
|
||||||
),
|
),
|
||||||
'active_cb' => [
|
'active_cb' => [
|
||||||
'adminPeriodical',
|
'adminPeriodical',
|
||||||
'adminDashboardFavoritesActive'
|
'adminDashboardFavoritesActive',
|
||||||
]
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ class adminPeriodical
|
||||||
/**
|
/**
|
||||||
* Add actions to posts page combo
|
* Add actions to posts page combo
|
||||||
*
|
*
|
||||||
* @param dcPostsActions $ap dcPostsActions instance
|
* @param dcPostsActions $pa dcPostsActions instance
|
||||||
*/
|
*/
|
||||||
public static function adminPostsActions(dcPostsActions $pa)
|
public static function adminPostsActions(dcPostsActions $pa)
|
||||||
{
|
{
|
||||||
|
@ -372,11 +372,11 @@ class adminPeriodical
|
||||||
# Display form
|
# Display form
|
||||||
else {
|
else {
|
||||||
$pa->beginPage(
|
$pa->beginPage(
|
||||||
dcPage::breadcrumb(array(
|
dcPage::breadcrumb([
|
||||||
html::escapeHTML(dcCore::app()->blog->name) => '',
|
html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||||
$pa->getCallerTitle() => $pa->getRedirection(true),
|
$pa->getCallerTitle() => $pa->getRedirection(true),
|
||||||
__('Add a period to this selection') => ''
|
__('Add a period to this selection') => '',
|
||||||
))
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
@ -413,8 +413,7 @@ class adminPeriodical
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set linked period form items
|
# Set linked period form items
|
||||||
$sidebar_items['options-box']['items']['period'] =
|
$sidebar_items['options-box']['items']['period'] = self::formPeriod($period);
|
||||||
self::formPeriod($period);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -440,7 +439,7 @@ class adminPeriodical
|
||||||
* Posts period form field
|
* Posts period form field
|
||||||
*
|
*
|
||||||
* @param string $period Period
|
* @param string $period Period
|
||||||
* @return string Period form content
|
* @return null|string Period form content
|
||||||
*/
|
*/
|
||||||
protected static function formPeriod($period = '')
|
protected static function formPeriod($period = '')
|
||||||
{
|
{
|
||||||
|
@ -466,17 +465,16 @@ class adminPeriodical
|
||||||
{
|
{
|
||||||
if (adminPeriodical::$combo_period === null) {
|
if (adminPeriodical::$combo_period === null) {
|
||||||
$periods = self::period()->getPeriods();
|
$periods = self::period()->getPeriods();
|
||||||
|
|
||||||
if ($periods->isEmpty()) {
|
|
||||||
adminPeriodical::$combo_period = [];
|
adminPeriodical::$combo_period = [];
|
||||||
} else {
|
|
||||||
|
if (!$periods->isEmpty()) {
|
||||||
$combo = ['-' => ''];
|
$combo = ['-' => ''];
|
||||||
while ($periods->fetch()) {
|
while ($periods->fetch()) {
|
||||||
$combo[html::escapeHTML($periods->periodical_title)] = $periods->periodical_id;
|
$combo[html::escapeHTML($periods->periodical_title)] = $periods->periodical_id;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
adminPeriodical::$combo_period = $combo;
|
adminPeriodical::$combo_period = $combo;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return adminPeriodical::$combo_period;
|
return adminPeriodical::$combo_period;
|
||||||
}
|
}
|
||||||
|
@ -492,7 +490,7 @@ class adminPeriodical
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_id = (integer) $post_id;
|
$post_id = (int) $post_id;
|
||||||
self::period()->delPost($post_id);
|
self::period()->delPost($post_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,7 +515,7 @@ class adminPeriodical
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_id = (integer) $post_id;
|
$post_id = (int) $post_id;
|
||||||
|
|
||||||
# Add relation
|
# Add relation
|
||||||
self::period()->addPost($period->periodical_id, $post_id);
|
self::period()->addPost($period->periodical_id, $post_id);
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +31,7 @@ $this->registerModule(
|
||||||
'details' => 'https://plugins.dotaddict.org/dc2/details/periodical',
|
'details' => 'https://plugins.dotaddict.org/dc2/details/periodical',
|
||||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/periodical/master/dcstore.xml',
|
'repository' => 'https://raw.githubusercontent.com/JcDenis/periodical/master/dcstore.xml',
|
||||||
'settings' => [
|
'settings' => [
|
||||||
'blog' => '#params.periodical_params'
|
'blog' => '#params.periodical_params',
|
||||||
]
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
|
@ -10,7 +10,6 @@
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +28,9 @@ try {
|
||||||
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)
|
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)
|
||||||
) {
|
) {
|
||||||
throw new Exception(sprintf(
|
throw new Exception(sprintf(
|
||||||
'%s requires Dotclear %s', 'periodical', $dc_min
|
'%s requires Dotclear %s',
|
||||||
|
'periodical',
|
||||||
|
$dc_min
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +34,6 @@ class publicPeriodical
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Publish periodical
|
* Publish periodical
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public static function publicBeforeDocument()
|
public static function publicBeforeDocument()
|
||||||
{
|
{
|
||||||
|
@ -78,6 +76,7 @@ class publicPeriodical
|
||||||
# Calculate nb of posts to get
|
# Calculate nb of posts to get
|
||||||
$loop_tz = $cur_tz;
|
$loop_tz = $cur_tz;
|
||||||
$limit = 0;
|
$limit = 0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while (1) {
|
while (1) {
|
||||||
if ($loop_tz > $max_tz) {
|
if ($loop_tz > $max_tz) {
|
||||||
|
@ -139,7 +138,6 @@ class publicPeriodical
|
||||||
|
|
||||||
# --BEHAVIOR-- periodicalAfterPublishedPeriodicalEntry
|
# --BEHAVIOR-- periodicalAfterPublishedPeriodicalEntry
|
||||||
dcCore::app()->callBehavior('periodicalAfterPublishedPeriodicalEntry', $posts, $periods);
|
dcCore::app()->callBehavior('periodicalAfterPublishedPeriodicalEntry', $posts, $periods);
|
||||||
|
|
||||||
}
|
}
|
||||||
dcCore::app()->blog->triggerBlog();
|
dcCore::app()->blog->triggerBlog();
|
||||||
}
|
}
|
||||||
|
@ -156,7 +154,9 @@ class publicPeriodical
|
||||||
}
|
}
|
||||||
$per->unlockUpdate();
|
$per->unlockUpdate();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
if (isset($per)) {
|
||||||
$per->unlockUpdate();
|
$per->unlockUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -47,8 +46,7 @@ class periodical
|
||||||
if (!empty($params['columns']) && is_array($params['columns'])) {
|
if (!empty($params['columns']) && is_array($params['columns'])) {
|
||||||
$q .= implode(', ', $params['columns']) . ', ';
|
$q .= implode(', ', $params['columns']) . ', ';
|
||||||
}
|
}
|
||||||
$q .=
|
$q .= 'T.periodical_title, T.periodical_tz, ' .
|
||||||
'T.periodical_title, T.periodical_tz, ' .
|
|
||||||
'T.periodical_curdt, T.periodical_enddt, ' .
|
'T.periodical_curdt, T.periodical_enddt, ' .
|
||||||
'T.periodical_pub_int, T.periodical_pub_nb ';
|
'T.periodical_pub_int, T.periodical_pub_nb ';
|
||||||
}
|
}
|
||||||
|
@ -73,7 +71,7 @@ class periodical
|
||||||
if (is_array($params['periodical_id'])) {
|
if (is_array($params['periodical_id'])) {
|
||||||
array_walk($params['periodical_id'], create_function('&$v,$k', 'if($v!==null){$v=(integer)$v;}'));
|
array_walk($params['periodical_id'], create_function('&$v,$k', 'if($v!==null){$v=(integer)$v;}'));
|
||||||
} else {
|
} else {
|
||||||
$params['periodical_id'] = [(integer) $params['periodical_id']];
|
$params['periodical_id'] = [(int) $params['periodical_id']];
|
||||||
}
|
}
|
||||||
$q .= 'AND T.periodical_id ' . $this->con->in($params['periodical_id']);
|
$q .= 'AND T.periodical_id ' . $this->con->in($params['periodical_id']);
|
||||||
}
|
}
|
||||||
|
@ -117,14 +115,16 @@ class periodical
|
||||||
$this->con->unlock();
|
$this->con->unlock();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->con->unlock();
|
$this->con->unlock();
|
||||||
|
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $cur->periodical_id;
|
return $cur->periodical_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updPeriod($period_id, $cur)
|
public function updPeriod($period_id, $cur)
|
||||||
{
|
{
|
||||||
$period_id = (integer) $period_id;
|
$period_id = (int) $period_id;
|
||||||
|
|
||||||
if ($cur->periodical_tz == ''
|
if ($cur->periodical_tz == ''
|
||||||
&& ($cur->periodical_curdt != '' || $cur->periodical_enddt != '')) {
|
&& ($cur->periodical_curdt != '' || $cur->periodical_enddt != '')) {
|
||||||
|
@ -132,14 +132,14 @@ class periodical
|
||||||
}
|
}
|
||||||
$cur->update(
|
$cur->update(
|
||||||
"WHERE blog_id = '" . $this->blog . "' " .
|
"WHERE blog_id = '" . $this->blog . "' " .
|
||||||
"AND periodical_id = " . $period_id . " "
|
'AND periodical_id = ' . $period_id . ' '
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Delete a period
|
# Delete a period
|
||||||
public function delPeriod($period_id)
|
public function delPeriod($period_id)
|
||||||
{
|
{
|
||||||
$period_id = (integer) $period_id;
|
$period_id = (int) $period_id;
|
||||||
|
|
||||||
$params = [];
|
$params = [];
|
||||||
$params['periodical_id'] = $period_id;
|
$params['periodical_id'] = $period_id;
|
||||||
|
@ -153,7 +153,7 @@ class periodical
|
||||||
$this->con->execute(
|
$this->con->execute(
|
||||||
'DELETE FROM ' . $this->table . ' ' .
|
'DELETE FROM ' . $this->table . ' ' .
|
||||||
"WHERE blog_id = '" . $this->blog . "' " .
|
"WHERE blog_id = '" . $this->blog . "' " .
|
||||||
"AND periodical_id = " . $period_id . " "
|
'AND periodical_id = ' . $period_id . ' '
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ class periodical
|
||||||
{
|
{
|
||||||
$params = [];
|
$params = [];
|
||||||
$params['post_status'] = '';
|
$params['post_status'] = '';
|
||||||
$params['periodical_id'] = (integer) $period_id;
|
$params['periodical_id'] = (int) $period_id;
|
||||||
|
|
||||||
$rs = $this->getPosts($params);
|
$rs = $this->getPosts($params);
|
||||||
|
|
||||||
|
@ -170,9 +170,8 @@ class periodical
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ids = array();
|
$ids = [];
|
||||||
while($rs->fetch())
|
while ($rs->fetch()) {
|
||||||
{
|
|
||||||
$ids[] = $rs->post_id;
|
$ids[] = $rs->post_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +182,7 @@ class periodical
|
||||||
$this->con->execute(
|
$this->con->execute(
|
||||||
'DELETE FROM ' . dcCore::app()->prefix . 'meta ' .
|
'DELETE FROM ' . dcCore::app()->prefix . 'meta ' .
|
||||||
"WHERE meta_type = 'periodical' " .
|
"WHERE meta_type = 'periodical' " .
|
||||||
"AND post_id " . $this->con->in($ids)
|
'AND post_id ' . $this->con->in($ids)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,9 +219,9 @@ class periodical
|
||||||
|
|
||||||
if (!empty($params['periodical_id'])) {
|
if (!empty($params['periodical_id'])) {
|
||||||
if (is_array($params['periodical_id'])) {
|
if (is_array($params['periodical_id'])) {
|
||||||
array_walk($params['periodical_id'], function ($v) { if ($v !== null) { $v = (integer) $v; } });
|
array_walk($params['periodical_id'], function ($v) { if ($v !== null) { $v = (int) $v; } });
|
||||||
} else {
|
} else {
|
||||||
$params['periodical_id'] = [(integer) $params['periodical_id']];
|
$params['periodical_id'] = [(int) $params['periodical_id']];
|
||||||
}
|
}
|
||||||
$params['sql'] .= 'AND T.periodical_id ' . $this->con->in($params['periodical_id']);
|
$params['sql'] .= 'AND T.periodical_id ' . $this->con->in($params['periodical_id']);
|
||||||
unset($params['periodical_id']);
|
unset($params['periodical_id']);
|
||||||
|
@ -230,7 +229,7 @@ class periodical
|
||||||
if (dcCore::app()->auth->check('admin', dcCore::app()->blog->id)) {
|
if (dcCore::app()->auth->check('admin', dcCore::app()->blog->id)) {
|
||||||
if (isset($params['post_status'])) {
|
if (isset($params['post_status'])) {
|
||||||
if ($params['post_status'] != '') {
|
if ($params['post_status'] != '') {
|
||||||
$params['sql'] .= 'AND P.post_status = ' . (integer) $params['post_status'] . ' ';
|
$params['sql'] .= 'AND P.post_status = ' . (int) $params['post_status'] . ' ';
|
||||||
}
|
}
|
||||||
unset($params['post_status']);
|
unset($params['post_status']);
|
||||||
}
|
}
|
||||||
|
@ -247,11 +246,11 @@ class periodical
|
||||||
# Add post to periodical
|
# Add post to periodical
|
||||||
public function addPost($period_id, $post_id)
|
public function addPost($period_id, $post_id)
|
||||||
{
|
{
|
||||||
$period_id = (integer) $period_id;
|
$period_id = (int) $period_id;
|
||||||
$post_id = (integer) $post_id;
|
$post_id = (int) $post_id;
|
||||||
|
|
||||||
# Check if exists
|
# Check if exists
|
||||||
$rs = $this->getPosts(array('post_id' => $post_id, 'periodical_id' => $period_id));
|
$rs = $this->getPosts(['post_id' => $post_id, 'periodical_id' => $period_id]);
|
||||||
if (!$rs->isEmpty()) {
|
if (!$rs->isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -267,6 +266,7 @@ class periodical
|
||||||
$this->con->unlock();
|
$this->con->unlock();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->con->unlock();
|
$this->con->unlock();
|
||||||
|
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,13 +274,14 @@ class periodical
|
||||||
# Delete post from periodical
|
# Delete post from periodical
|
||||||
public function delPost($post_id)
|
public function delPost($post_id)
|
||||||
{
|
{
|
||||||
$post_id = (integer) $post_id;
|
$post_id = (int) $post_id;
|
||||||
|
|
||||||
$this->con->execute(
|
$this->con->execute(
|
||||||
'DELETE FROM ' . dcCore::app()->prefix . 'meta ' .
|
'DELETE FROM ' . dcCore::app()->prefix . 'meta ' .
|
||||||
"WHERE meta_type = 'periodical' " .
|
"WHERE meta_type = 'periodical' " .
|
||||||
"AND post_id = '" . $post_id . "' "
|
"AND post_id = '" . $post_id . "' "
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +292,7 @@ class periodical
|
||||||
$params['post_status'] = '';
|
$params['post_status'] = '';
|
||||||
$params['sql'] = 'AND post_status != -2 ';
|
$params['sql'] = 'AND post_status != -2 ';
|
||||||
if ($period_id !== null) {
|
if ($period_id !== null) {
|
||||||
$params['periodical_id'] = (integer) $period_id;
|
$params['periodical_id'] = (int) $period_id;
|
||||||
}
|
}
|
||||||
$rs = $this->getPosts($params);
|
$rs = $this->getPosts($params);
|
||||||
|
|
||||||
|
@ -299,7 +300,7 @@ class periodical
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ids = array();
|
$ids = [];
|
||||||
while ($rs->fetch()) {
|
while ($rs->fetch()) {
|
||||||
$ids[] = $rs->post_id;
|
$ids[] = $rs->post_id;
|
||||||
}
|
}
|
||||||
|
@ -311,7 +312,7 @@ class periodical
|
||||||
$this->con->execute(
|
$this->con->execute(
|
||||||
'DELETE FROM ' . dcCore::app()->prefix . 'meta ' .
|
'DELETE FROM ' . dcCore::app()->prefix . 'meta ' .
|
||||||
"WHERE meta_type = 'periodical' " .
|
"WHERE meta_type = 'periodical' " .
|
||||||
"AND post_id " . $this->con->in($ids)
|
'AND post_id ' . $this->con->in($ids)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,41 +323,48 @@ class periodical
|
||||||
__('twice a day') => 'halfday',
|
__('twice a day') => 'halfday',
|
||||||
__('Daily') => 'day',
|
__('Daily') => 'day',
|
||||||
__('Weekly') => 'week',
|
__('Weekly') => 'week',
|
||||||
__('Monthly') => 'month'
|
__('Monthly') => 'month',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getNextTime($ts, $period)
|
public static function getNextTime($ts, $period)
|
||||||
{
|
{
|
||||||
$ts = (integer) $ts;
|
$ts = (int) $ts;
|
||||||
$e = explode(',', date('H,i,s,n,j,Y', $ts));
|
$e = explode(',', date('H,i,s,n,j,Y', $ts));
|
||||||
switch($period)
|
switch($period) {
|
||||||
{
|
|
||||||
case 'hour':
|
case 'hour':
|
||||||
$new_ts = mktime($e[0] + 1, $e[1], $e[2], $e[3], $e[4], $e[5]);
|
$new_ts = mktime($e[0] + 1, $e[1], $e[2], $e[3], $e[4], $e[5]);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'halfday':
|
case 'halfday':
|
||||||
$new_ts = mktime($e[0] + 12, $e[1], $e[2], $e[3], $e[4], $e[5]);
|
$new_ts = mktime($e[0] + 12, $e[1], $e[2], $e[3], $e[4], $e[5]);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'day':
|
case 'day':
|
||||||
$new_ts = mktime($e[0], $e[1], $e[2], $e[3], $e[4] + 1, $e[5]);
|
$new_ts = mktime($e[0], $e[1], $e[2], $e[3], $e[4] + 1, $e[5]);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'week':
|
case 'week':
|
||||||
$new_ts = mktime($e[0], $e[1], $e[2], $e[3], $e[4] + 7, $e[5]);
|
$new_ts = mktime($e[0], $e[1], $e[2], $e[3], $e[4] + 7, $e[5]);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'month':
|
case 'month':
|
||||||
$new_ts = mktime($e[0], $e[1], $e[2], $e[3] + 1, $e[4], $e[5]);
|
$new_ts = mktime($e[0], $e[1], $e[2], $e[3] + 1, $e[4], $e[5]);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$new_ts = 0;
|
$new_ts = 0;
|
||||||
|
|
||||||
throw new Exception(__('Unknow frequence'));
|
throw new Exception(__('Unknow frequence'));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $new_ts;
|
return $new_ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,7 +374,7 @@ class periodical
|
||||||
try {
|
try {
|
||||||
# Need flock function
|
# Need flock function
|
||||||
if (!function_exists('flock')) {
|
if (!function_exists('flock')) {
|
||||||
throw New Exception("Can't call php function named flock");
|
throw new Exception("Can't call php function named flock");
|
||||||
}
|
}
|
||||||
# Cache writable ?
|
# Cache writable ?
|
||||||
if (!is_writable(DC_TPL_CACHE)) {
|
if (!is_writable(DC_TPL_CACHE)) {
|
||||||
|
@ -392,24 +400,26 @@ class periodical
|
||||||
if (!file_exists($cached_file)) {
|
if (!file_exists($cached_file)) {
|
||||||
!$fp = @fopen($cached_file, 'w');
|
!$fp = @fopen($cached_file, 'w');
|
||||||
if ($fp === false) {
|
if ($fp === false) {
|
||||||
throw New Exception("Can't create file");
|
throw new Exception("Can't create file");
|
||||||
}
|
}
|
||||||
fwrite($fp, '1', strlen('1'));
|
fwrite($fp, '1', strlen('1'));
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
# Open file
|
# Open file
|
||||||
if (!($fp = @fopen($cached_file, 'r+'))) {
|
if (!($fp = @fopen($cached_file, 'r+'))) {
|
||||||
throw New Exception("Can't open file");
|
throw new Exception("Can't open file");
|
||||||
}
|
}
|
||||||
# Lock file
|
# Lock file
|
||||||
if (!flock($fp, LOCK_EX)) {
|
if (!flock($fp, LOCK_EX)) {
|
||||||
throw New Exception("Can't lock file");
|
throw new Exception("Can't lock file");
|
||||||
}
|
}
|
||||||
$this->lock = $fp;
|
$this->lock = $fp;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +20,7 @@ dcPage::check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_USAGE, dc
|
||||||
$per = new periodical();
|
$per = new periodical();
|
||||||
|
|
||||||
# Default values
|
# Default values
|
||||||
$action = isset($_POST['action']) ? $_POST['action'] : '';
|
$action = $_POST['action'] ?? '';
|
||||||
|
|
||||||
$starting_script = '';
|
$starting_script = '';
|
||||||
|
|
||||||
|
@ -38,7 +37,7 @@ $bad_period_enddt = false;
|
||||||
# Get period
|
# Get period
|
||||||
if (!empty($_REQUEST['period_id'])) {
|
if (!empty($_REQUEST['period_id'])) {
|
||||||
$rs = $per->getPeriods([
|
$rs = $per->getPeriods([
|
||||||
'periodical_id' => $_REQUEST['period_id']
|
'periodical_id' => $_REQUEST['period_id'],
|
||||||
]);
|
]);
|
||||||
if ($rs->isEmpty()) {
|
if ($rs->isEmpty()) {
|
||||||
dcCore::app()->error->add(__('This period does not exist.'));
|
dcCore::app()->error->add(__('This period does not exist.'));
|
||||||
|
@ -60,7 +59,7 @@ if ($action == 'setperiod') {
|
||||||
$period_title = $_POST['period_title'];
|
$period_title = $_POST['period_title'];
|
||||||
}
|
}
|
||||||
if (!empty($_POST['period_pub_nb'])) {
|
if (!empty($_POST['period_pub_nb'])) {
|
||||||
$period_pub_nb = abs((integer) $_POST['period_pub_nb']);
|
$period_pub_nb = abs((int) $_POST['period_pub_nb']);
|
||||||
}
|
}
|
||||||
if (!empty($_POST['period_pub_int'])
|
if (!empty($_POST['period_pub_int'])
|
||||||
&& in_array($_POST['period_pub_int'], $per->getTimesCombo())
|
&& in_array($_POST['period_pub_int'], $per->getTimesCombo())
|
||||||
|
@ -96,7 +95,7 @@ if ($action == 'setperiod') {
|
||||||
|
|
||||||
# Check period title and dates
|
# Check period title and dates
|
||||||
$old_titles = $per->getPeriods([
|
$old_titles = $per->getPeriods([
|
||||||
'periodical_title' => $period_title
|
'periodical_title' => $period_title,
|
||||||
]);
|
]);
|
||||||
if (!$old_titles->isEmpty()) {
|
if (!$old_titles->isEmpty()) {
|
||||||
while ($old_titles->fetch()) {
|
while ($old_titles->fetch()) {
|
||||||
|
@ -151,7 +150,7 @@ if (!dcCore::app()->error->flag() && $period_id && $action && !empty($_POST['per
|
||||||
if ($action == 'publish') {
|
if ($action == 'publish') {
|
||||||
try {
|
try {
|
||||||
foreach ($_POST['periodical_entries'] as $id) {
|
foreach ($_POST['periodical_entries'] as $id) {
|
||||||
$id = (integer) $id;
|
$id = (int) $id;
|
||||||
dcCore::app()->blog->updPostStatus($id, 1);
|
dcCore::app()->blog->updPostStatus($id, 1);
|
||||||
$per->delPost($id);
|
$per->delPost($id);
|
||||||
}
|
}
|
||||||
|
@ -174,7 +173,7 @@ if (!dcCore::app()->error->flag() && $period_id && $action && !empty($_POST['per
|
||||||
if ($action == 'unpublish') {
|
if ($action == 'unpublish') {
|
||||||
try {
|
try {
|
||||||
foreach ($_POST['periodical_entries'] as $id) {
|
foreach ($_POST['periodical_entries'] as $id) {
|
||||||
$id = (integer) $id;
|
$id = (int) $id;
|
||||||
dcCore::app()->blog->updPostStatus($id, 0);
|
dcCore::app()->blog->updPostStatus($id, 0);
|
||||||
$per->delPost($id);
|
$per->delPost($id);
|
||||||
}
|
}
|
||||||
|
@ -197,7 +196,7 @@ if (!dcCore::app()->error->flag() && $period_id && $action && !empty($_POST['per
|
||||||
if ($action == 'remove_post_periodical') {
|
if ($action == 'remove_post_periodical') {
|
||||||
try {
|
try {
|
||||||
foreach ($_POST['periodical_entries'] as $id) {
|
foreach ($_POST['periodical_entries'] as $id) {
|
||||||
$id = (integer) $id;
|
$id = (int) $id;
|
||||||
$per->delPost($id);
|
$per->delPost($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,8 +234,7 @@ if ($period_id) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$starting_script =
|
$starting_script = dcPage::jsLoad(dcPage::getPF('periodical/js/checkbox.js')) .
|
||||||
dcPage::jsLoad(dcPage::getPF('periodical/js/checkbox.js')) .
|
|
||||||
$post_filter->js(dcCore::app()->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');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +252,7 @@ echo
|
||||||
dcPage::breadcrumb([
|
dcPage::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
__('Periodical') => dcCore::app()->admin->getPageURL() . '&part=periods',
|
__('Periodical') => dcCore::app()->admin->getPageURL() . '&part=periods',
|
||||||
(null === $period_id ? __('New period') : __('Edit period')) => ''
|
(null === $period_id ? __('New period') : __('Edit period')) => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices();
|
dcPage::notices();
|
||||||
|
|
||||||
|
@ -301,8 +299,7 @@ form::hidden(['part'], 'period') .'
|
||||||
</form>
|
</form>
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
if ($period_id && !dcCore::app()->error->flag()) {
|
if ($period_id && isset($post_filter) && isset($post_list) && !dcCore::app()->error->flag()) {
|
||||||
|
|
||||||
# Actions combo box
|
# Actions combo box
|
||||||
$combo_action = [];
|
$combo_action = [];
|
||||||
$combo_action[__('Entries')][__('Publish')] = 'publish';
|
$combo_action[__('Entries')][__('Publish')] = 'publish';
|
||||||
|
@ -329,15 +326,18 @@ if ($period_id && !dcCore::app()->error->flag()) {
|
||||||
<div id="posts"><h3>' . __('Entries linked to this period') . '</h3>';
|
<div id="posts"><h3>' . __('Entries linked to this period') . '</h3>';
|
||||||
|
|
||||||
# Filters
|
# Filters
|
||||||
$post_filter->display(['admin.plugin.periodical', '#posts'],
|
$post_filter->display(
|
||||||
|
['admin.plugin.periodical', '#posts'],
|
||||||
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.periodical', [
|
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.periodical', [
|
||||||
'period_id' => $period_id,
|
'period_id' => $period_id,
|
||||||
'part' => 'period'
|
'part' => 'period',
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
# Posts list
|
# Posts list
|
||||||
$post_list->postDisplay($post_filter, $base_url,
|
$post_list->postDisplay(
|
||||||
|
$post_filter,
|
||||||
|
$base_url,
|
||||||
'<form action="' . dcCore::app()->admin->getPageURL() . '" method="post" id="form-entries">' .
|
'<form action="' . dcCore::app()->admin->getPageURL() . '" method="post" id="form-entries">' .
|
||||||
|
|
||||||
'%s' .
|
'%s' .
|
||||||
|
@ -350,7 +350,7 @@ if ($period_id && !dcCore::app()->error->flag()) {
|
||||||
'<input type="submit" value="' . __('ok') . '" /></p>' .
|
'<input type="submit" value="' . __('ok') . '" /></p>' .
|
||||||
dcCore::app()->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,
|
'period_id' => $period_id,
|
||||||
'redir' => sprintf($base_url, $post_filter->page)
|
'redir' => sprintf($base_url, $post_filter->page),
|
||||||
])) .
|
])) .
|
||||||
dcCore::app()->formNonce() .
|
dcCore::app()->formNonce() .
|
||||||
'</div>' .
|
'</div>' .
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -21,13 +20,13 @@ dcPage::check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_USAGE, dc
|
||||||
$per = new periodical();
|
$per = new periodical();
|
||||||
|
|
||||||
# Default values
|
# Default values
|
||||||
$action = isset($_POST['action']) ? $_POST['action'] : '';
|
$action = $_POST['action'] ?? '';
|
||||||
|
|
||||||
# Delete periods and related posts links
|
# Delete periods and related posts links
|
||||||
if ($action == 'deleteperiods' && !empty($_POST['periods'])) {
|
if ($action == 'deleteperiods' && !empty($_POST['periods'])) {
|
||||||
try {
|
try {
|
||||||
foreach ($_POST['periods'] as $id) {
|
foreach ($_POST['periods'] as $id) {
|
||||||
$id = (integer) $id;
|
$id = (int) $id;
|
||||||
$per->delPeriodPosts($id);
|
$per->delPeriodPosts($id);
|
||||||
$per->delPeriod($id);
|
$per->delPeriod($id);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +48,7 @@ if ($action == 'deleteperiods' && !empty($_POST['periods'])) {
|
||||||
if ($action == 'emptyperiods' && !empty($_POST['periods'])) {
|
if ($action == 'emptyperiods' && !empty($_POST['periods'])) {
|
||||||
try {
|
try {
|
||||||
foreach ($_POST['periods'] as $id) {
|
foreach ($_POST['periods'] as $id) {
|
||||||
$id = (integer) $id;
|
$id = (int) $id;
|
||||||
$per->delPeriodPosts($id);
|
$per->delPeriodPosts($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +68,7 @@ if ($action == 'emptyperiods' && !empty($_POST['periods'])) {
|
||||||
|
|
||||||
$combo_action = [
|
$combo_action = [
|
||||||
__('empty periods') => 'emptyperiods',
|
__('empty periods') => 'emptyperiods',
|
||||||
__('delete periods') => 'deleteperiods'
|
__('delete periods') => 'deleteperiods',
|
||||||
];
|
];
|
||||||
|
|
||||||
# Filters
|
# Filters
|
||||||
|
@ -97,7 +96,7 @@ $p_filter->js(dcCore::app()->adminurl->get('admin.plugin.periodical', ['part' =>
|
||||||
|
|
||||||
dcPage::breadcrumb([
|
dcPage::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
__('Periodical') => ''
|
__('Periodical') => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
dcPage::notices() .
|
||||||
|
|
||||||
|
@ -105,11 +104,13 @@ dcPage::notices() .
|
||||||
<a class="button add" href="' . dcCore::app()->admin->getPageURL() . '&part=period">' . __('New period') . '</a>
|
<a class="button add" href="' . dcCore::app()->admin->getPageURL() . '&part=period">' . __('New period') . '</a>
|
||||||
</p>';
|
</p>';
|
||||||
|
|
||||||
|
if (isset($period_list)) {
|
||||||
# Filters
|
# Filters
|
||||||
$p_filter->display('admin.plugin.periodical', form::hidden('p', 'periodical') . form::hidden('part', 'periods'));
|
$p_filter->display('admin.plugin.periodical', form::hidden('p', 'periodical') . form::hidden('part', 'periods'));
|
||||||
|
|
||||||
# Periods list
|
# Periods list
|
||||||
$period_list->periodDisplay($p_filter,
|
$period_list->periodDisplay(
|
||||||
|
$p_filter,
|
||||||
'<form action="' . dcCore::app()->admin->getPageURL() . '" method="post" id="form-periods">' .
|
'<form action="' . dcCore::app()->admin->getPageURL() . '" method="post" id="form-periods">' .
|
||||||
|
|
||||||
'%s' .
|
'%s' .
|
||||||
|
@ -125,7 +126,7 @@ $period_list->periodDisplay($p_filter,
|
||||||
'</div>' .
|
'</div>' .
|
||||||
'</form>'
|
'</form>'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
dcPage::helpBlock('periodical');
|
dcPage::helpBlock('periodical');
|
||||||
|
|
||||||
echo '</body></html>';
|
echo '</body></html>';
|
|
@ -10,7 +10,6 @@
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -40,11 +39,12 @@ class adminPeriodicalList extends adminGenericList
|
||||||
$periods = [];
|
$periods = [];
|
||||||
if (isset($_REQUEST['periods'])) {
|
if (isset($_REQUEST['periods'])) {
|
||||||
foreach ($_REQUEST['periods'] as $v) {
|
foreach ($_REQUEST['periods'] as $v) {
|
||||||
$periods[(integer) $v] = true;
|
$periods[(int) $v] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$html_block = '<div class="table-outer"><table><caption>' . ($filter->show() ?
|
$html_block = '<div class="table-outer"><table><caption>' . (
|
||||||
|
$filter->show() ?
|
||||||
sprintf(__('List of %s periods matching the filter.'), $this->rs_count) :
|
sprintf(__('List of %s periods matching the filter.'), $this->rs_count) :
|
||||||
sprintf(__('List of %s periods.'), $this->rs_count)
|
sprintf(__('List of %s periods.'), $this->rs_count)
|
||||||
) . '</caption>';
|
) . '</caption>';
|
||||||
|
@ -55,7 +55,7 @@ class adminPeriodicalList extends adminGenericList
|
||||||
'pub_int' => '<th scope="col" class="nowrap">' . __('Frequency') . '</th>',
|
'pub_int' => '<th scope="col" class="nowrap">' . __('Frequency') . '</th>',
|
||||||
'pub_nb' => '<th scope="col" class="nowrap">' . __('Entries per update') . '</th>',
|
'pub_nb' => '<th scope="col" class="nowrap">' . __('Entries per update') . '</th>',
|
||||||
'nbposts' => '<th scope="col" class="nowrap">' . __('Entries') . '</th>',
|
'nbposts' => '<th scope="col" class="nowrap">' . __('Entries') . '</th>',
|
||||||
'enddt' => '<th scope="col" class="nowrap">' . __('End date') . '</th>'
|
'enddt' => '<th scope="col" class="nowrap">' . __('End date') . '</th>',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->userColumns('periodical', $cols);
|
$this->userColumns('periodical', $cols);
|
||||||
|
@ -97,7 +97,7 @@ class adminPeriodicalList extends adminGenericList
|
||||||
'pub_int' => '<td class="nowrap">' . $interval . '</td>',
|
'pub_int' => '<td class="nowrap">' . $interval . '</td>',
|
||||||
'pub_nb' => '<td class="nowrap count">' . $this->rs->periodical_pub_nb . '</td>',
|
'pub_nb' => '<td class="nowrap count">' . $this->rs->periodical_pub_nb . '</td>',
|
||||||
'nbposts' => '<td class="nowrap count">' . $posts . '</td>',
|
'nbposts' => '<td class="nowrap count">' . $posts . '</td>',
|
||||||
'enddt' => '<td class="nowrap count">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->periodical_enddt) . '</td>'
|
'enddt' => '<td class="nowrap count">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->periodical_enddt) . '</td>',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->userColumns('periodical', $cols);
|
$this->userColumns('periodical', $cols);
|
||||||
|
@ -125,7 +125,7 @@ class adminPeriodicalList extends adminGenericList
|
||||||
$periodical_entries = [];
|
$periodical_entries = [];
|
||||||
if (isset($_REQUEST['periodical_entries'])) {
|
if (isset($_REQUEST['periodical_entries'])) {
|
||||||
foreach ($_REQUEST['periodical_entries'] as $v) {
|
foreach ($_REQUEST['periodical_entries'] as $v) {
|
||||||
$periodical_entries[(integer) $v] = true;
|
$periodical_entries[(int) $v] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,11 +135,11 @@ class adminPeriodicalList extends adminGenericList
|
||||||
'category' => '<th scope="col">' . __('Category') . '</th>',
|
'category' => '<th scope="col">' . __('Category') . '</th>',
|
||||||
'author' => '<th scope="col">' . __('Author') . '</th>',
|
'author' => '<th scope="col">' . __('Author') . '</th>',
|
||||||
'status' => '<th scope="col">' . __('Status') . '</th>',
|
'status' => '<th scope="col">' . __('Status') . '</th>',
|
||||||
'create' => '<th scope="col" class="nowrap">' . __('Create date') . '</th>'
|
'create' => '<th scope="col" class="nowrap">' . __('Create date') . '</th>',
|
||||||
];
|
];
|
||||||
|
|
||||||
$html_block =
|
$html_block = '<div class="table-outer"><table><caption>' . (
|
||||||
'<div class="table-outer"><table><caption>' . ($filter->show() ?
|
$filter->show() ?
|
||||||
sprintf(__('List of %s entries matching the filter.'), $this->rs_count) :
|
sprintf(__('List of %s entries matching the filter.'), $this->rs_count) :
|
||||||
sprintf(__('List of %s entries.'), $this->rs_count)
|
sprintf(__('List of %s entries.'), $this->rs_count)
|
||||||
) . '</caption><tr>' . implode($cols) . '</tr>%s</table>%s</div>';
|
) . '</caption><tr>' . implode($cols) . '</tr>%s</table>%s</div>';
|
||||||
|
@ -188,23 +188,27 @@ class adminPeriodicalList extends adminGenericList
|
||||||
$cat_title = __('None');
|
$cat_title = __('None');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$img_status = '';
|
||||||
$img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
|
$img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
|
||||||
switch ($this->rs->post_status)
|
switch ($this->rs->post_status) {
|
||||||
{
|
|
||||||
case 1:
|
case 1:
|
||||||
$img_status = sprintf($img, __('published'), 'check-on.png');
|
$img_status = sprintf($img, __('published'), 'check-on.png');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
$img_status = sprintf($img, __('unpublished'), 'check-off.png');
|
$img_status = sprintf($img, __('unpublished'), 'check-off.png');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case -1:
|
case -1:
|
||||||
$img_status = sprintf($img, __('scheduled'), 'scheduled.png');
|
$img_status = sprintf($img, __('scheduled'), 'scheduled.png');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case -2:
|
case -2:
|
||||||
$img_status = sprintf($img, __('pending'), 'check-wrn.png');
|
$img_status = sprintf($img, __('pending'), 'check-wrn.png');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,15 +231,16 @@ class adminPeriodicalList extends adminGenericList
|
||||||
|
|
||||||
$cols = [
|
$cols = [
|
||||||
'check' => '<td class="minimal">' . form::checkbox(['periodical_entries[]'], $this->rs->post_id, ['checked' => $checked]) . '</td>',
|
'check' => '<td class="minimal">' . form::checkbox(['periodical_entries[]'], $this->rs->post_id, ['checked' => $checked]) . '</td>',
|
||||||
'title' => '<td class="maximal"><a href="' . $this->rs->core->getPostAdminURL($this->rs->post_type, $this->rs->post_id) . '" ' .
|
'title' => '<td class="maximal"><a href="' . dcCore::app()->getPostAdminURL($this->rs->post_type, $this->rs->post_id) . '" ' .
|
||||||
'title="' . html::escapeHTML($this->rs->getURL()) . '">' . html::escapeHTML($this->rs->post_title) . '</a></td>',
|
'title="' . html::escapeHTML($this->rs->getURL()) . '">' . html::escapeHTML($this->rs->post_title) . '</a></td>',
|
||||||
'date' => '<td class="nowrap">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->post_dt) . '</td>',
|
'date' => '<td class="nowrap">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->post_dt) . '</td>',
|
||||||
'category' => '<td class="nowrap">' . $cat_title . '</td>',
|
'category' => '<td class="nowrap">' . $cat_title . '</td>',
|
||||||
'author' => '<td class="nowrap">' . $this->rs->user_id . '</td>',
|
'author' => '<td class="nowrap">' . $this->rs->user_id . '</td>',
|
||||||
'status' => '<td class="nowrap status">' . $img_status . ' ' . $selected . ' ' . $protected . ' ' . $attach . '</td>',
|
'status' => '<td class="nowrap status">' . $img_status . ' ' . $selected . ' ' . $protected . ' ' . $attach . '</td>',
|
||||||
'create' => '<td class="nowrap">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->post_creadt, $this->rs->core->auth->getInfo('user_tz')) . '</td>'
|
'create' => '<td class="nowrap">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->post_creadt, dcCore::app()->auth->getInfo('user_tz')) . '</td>',
|
||||||
];
|
];
|
||||||
|
|
||||||
return '<tr class="line">' . implode($cols) . '</tr>';;
|
return '<tr class="line">' . implode($cols) . '</tr>';
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -10,7 +10,6 @@
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||||
#
|
#
|
||||||
# This file is part of periodical, a plugin for Dotclear 2.
|
# This file is part of periodical, a plugin for Dotclear 2.
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||||
#
|
#
|
||||||
# This file is part of periodical, a plugin for Dotclear 2.
|
# This file is part of periodical, a plugin for Dotclear 2.
|
||||||
|
|
Loading…
Reference in a new issue