move php code to PSR2 and short array

This commit is contained in:
Jean-Christian Denis 2021-08-24 00:52:29 +02:00
parent b47931de50
commit 7ed5a1542c
15 changed files with 1916 additions and 1981 deletions

View file

@ -1,5 +1,6 @@
periodical 2021.08.xx periodical 2021.08.xx
* update license * update license
* update php code to PSR-2 style and short array
periodical 2013.11.11 periodical 2013.11.11
* Switch to Dotclear 2.6 * Switch to Dotclear 2.6

View file

@ -12,7 +12,6 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
@ -33,33 +32,33 @@ if ($core->blog->settings->periodical->periodical_active) {
$core->addBehavior( $core->addBehavior(
'adminDashboardFavorites', 'adminDashboardFavorites',
array('adminPeriodical', 'adminDashboardFavorites') ['adminPeriodical', 'adminDashboardFavorites']
); );
$core->addBehavior( $core->addBehavior(
'adminPostHeaders', 'adminPostHeaders',
array('adminPeriodical', 'adminPostHeaders') ['adminPeriodical', 'adminPostHeaders']
); );
$core->addBehavior( $core->addBehavior(
'adminPostsActionsPage', 'adminPostsActionsPage',
array('adminPeriodical', 'adminPostsActionsPage') ['adminPeriodical', 'adminPostsActionsPage']
); );
$core->addBehavior( $core->addBehavior(
'adminPostFormItems', 'adminPostFormItems',
array('adminPeriodical', 'adminPostFormItems') ['adminPeriodical', 'adminPostFormItems']
); );
$core->addBehavior( $core->addBehavior(
'adminAfterPostUpdate', 'adminAfterPostUpdate',
array('adminPeriodical', 'adminAfterPostSave') ['adminPeriodical', 'adminAfterPostSave']
); );
$core->addBehavior( $core->addBehavior(
'adminAfterPostCreate', 'adminAfterPostCreate',
array('adminPeriodical', 'adminAfterPostSave') ['adminPeriodical', 'adminAfterPostSave']
); );
} }
$core->addBehavior( $core->addBehavior(
'adminBeforePostDelete', 'adminBeforePostDelete',
array('adminPeriodical', 'adminBeforePostDelete') ['adminPeriodical', 'adminBeforePostDelete']
); );
/** /**
@ -79,7 +78,7 @@ class adminPeriodical
*/ */
public static function adminDashboardFavorites(dcCore $core, $favs) public static function adminDashboardFavorites(dcCore $core, $favs)
{ {
$favs->register('periodical', array( $favs->register('periodical', [
'title' => __('Periodical'), 'title' => __('Periodical'),
'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',
@ -88,11 +87,11 @@ class adminPeriodical
'usage,contentadmin', 'usage,contentadmin',
$core->blog->id $core->blog->id
), ),
'active_cb' => array( 'active_cb' => [
'adminPeriodical', 'adminPeriodical',
'adminDashboardFavoritesActive' 'adminDashboardFavoritesActive'
) ]
)); ]);
} }
/** /**
@ -137,25 +136,16 @@ class adminPeriodical
public static function adminPostsActionsPage(dcCore $core, dcPostsActionsPage $pa) public static function adminPostsActionsPage(dcCore $core, dcPostsActionsPage $pa)
{ {
$pa->addAction( $pa->addAction(
array( [__('Periodical') => [__('Add to periodical') => 'periodical_add']],
__('Periodical') => array( ['adminPeriodical', 'callbackAdd']
__('Add to periodical') => 'periodical_add'
)
),
array('adminPeriodical', 'callbackAdd')
); );
if (!$core->auth->check('delete,contentadmin', $core->blog->id)) { if (!$core->auth->check('delete,contentadmin', $core->blog->id)) {
return null; return null;
} }
$pa->addAction( $pa->addAction(
array( [__('Periodical') => [__('Remove from periodical') => 'periodical_remove']],
__('Periodical') => array( ['adminPeriodical', 'callbackRemove']
__('Remove from periodical') => 'periodical_remove'
)
),
array('adminPeriodical', 'callbackRemove')
); );
} }
@ -235,7 +225,7 @@ class adminPeriodical
'<p>'. '<p>'.
$core->formNonce() . $core->formNonce() .
$pa->getHiddenFields() . $pa->getHiddenFields() .
form::hidden(array('action'), 'periodical_add'). form::hidden(['action'], 'periodical_add') .
'<input type="submit" value="' . __('Save') . '" /></p>' . '<input type="submit" value="' . __('Save') . '" /></p>' .
'</form>'; '</form>';
@ -258,7 +248,7 @@ class adminPeriodical
$period = ''; $period = '';
if ($post) { if ($post) {
$per = new periodical($core); $per = new periodical($core);
$rs = $per->getPosts(array('post_id' => $post->post_id)); $rs = $per->getPosts(['post_id' => $post->post_id]);
$period = $rs->isEmpty() ? '' : $rs->periodical_id; $period = $rs->isEmpty() ? '' : $rs->periodical_id;
} }
@ -278,7 +268,6 @@ class adminPeriodical
global $core; global $core;
if (!isset($_POST['periodical'])) { if (!isset($_POST['periodical'])) {
return null; return null;
} }
@ -301,7 +290,6 @@ class adminPeriodical
$combo = self::comboPeriod($core); $combo = self::comboPeriod($core);
if (empty($combo)) { if (empty($combo)) {
return null; return null;
} }
@ -326,11 +314,9 @@ class adminPeriodical
$periods = $per->getPeriods(); $periods = $per->getPeriods();
if ($periods->isEmpty()) { if ($periods->isEmpty()) {
adminPeriodical::$combo_period = [];
adminPeriodical::$combo_period = array(); } else {
} $combo = ['-' => ''];
else {
$combo = array('-' => '');
while ($periods->fetch()) { while ($periods->fetch()) {
$combo[html::escapeHTML($periods->periodical_title)] = $periods->periodical_id; $combo[html::escapeHTML($periods->periodical_title)] = $periods->periodical_id;
} }
@ -350,7 +336,6 @@ class adminPeriodical
protected static function delPeriod(dcCore $core, $post_id) protected static function delPeriod(dcCore $core, $post_id)
{ {
if ($post_id === null) { if ($post_id === null) {
return null; return null;
} }
@ -370,7 +355,6 @@ class adminPeriodical
{ {
# Not saved # Not saved
if ($post_id === null || empty($period)) { if ($post_id === null || empty($period)) {
return null; return null;
} }
@ -378,11 +362,10 @@ class adminPeriodical
$per = new periodical($core); $per = new periodical($core);
# Get periods # Get periods
$period = $per->getPeriods(array('periodical_id' => $period)); $period = $per->getPeriods(['periodical_id' => $period]);
# No period # No period
if ($period->isEmpty()) { if ($period->isEmpty()) {
return null; return null;
} }

View file

@ -12,7 +12,6 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_MODULE')) { if (!defined('DC_CONTEXT_MODULE')) {
return null; return null;
} }
@ -20,15 +19,15 @@ $redir = empty($_REQUEST['redir']) ?
$list->getURL() . '#plugins' : $_REQUEST['redir']; $list->getURL() . '#plugins' : $_REQUEST['redir'];
# -- Combos -- # -- Combos --
$sortby_combo = array( $sortby_combo = [
__('Create date') => 'post_creadt', __('Create date') => 'post_creadt',
__('Date') => 'post_dt', __('Date') => 'post_dt',
__('Id') => 'post_id' __('Id') => 'post_id'
); ];
$order_combo = array( $order_combo = [
__('Descending') => 'desc', __('Descending') => 'desc',
__('Ascending') => 'asc' __('Ascending') => 'asc'
); ];
# -- Get settings -- # -- Get settings --
$core->blog->settings->addNamespace('periodical'); $core->blog->settings->addNamespace('periodical');
@ -44,7 +43,6 @@ $s_order = isset($e_order[1]) && strtolower($e_order[1]) == 'desc' ? 'desc' : '
# -- Set settings -- # -- Set settings --
if (!empty($_POST['save'])) { if (!empty($_POST['save'])) {
try { try {
$s_active = !empty($_POST['s_active']); $s_active = !empty($_POST['s_active']);
$s_upddate = !empty($_POST['s_upddate']); $s_upddate = !empty($_POST['s_upddate']);
@ -62,12 +60,10 @@ if (!empty($_POST['save'])) {
dcPage::addSuccessNotice( dcPage::addSuccessNotice(
__('Configuration has been successfully updated.') __('Configuration has been successfully updated.')
); );
http::redirect( http::redirect($list->getURL(
$list->getURL('module=periodical&conf=1&redir='. 'module=periodical&conf=1&redir=' . $list->getRedir()
$list->getRedir()) ));
); } catch (Exception $e) {
}
catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
} }
} }

View file

@ -11,23 +11,20 @@
# #
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')){return;} if (!defined('DC_RC_PATH')) {
return null;
}
$this->registerModule( $this->registerModule(
/* Name */ 'Periodical',
"Periodical", 'Published periodically entries',
/* Description*/ 'Jean-Christian Denis and contributors',
"Published periodically entries", '2021.08.20',
/* Author */ [
"Jean-Christian Denis",
/* Version */
'2013.11.11',
/* Properies */
array(
'permissions' => 'usage,contentadmin', 'permissions' => 'usage,contentadmin',
'type' => 'plugin', 'type' => 'plugin',
'dc_min' => '2.6', 'dc_min' => '2.19',
'support' => 'http://jcd.lv/q=periodical', 'support' => 'https://github.com/JcDenis/periodical',
'details' => 'http://plugins.dotaddict.org/dc2/details/periodical' 'details' => 'https://plugins.dotaddict.org/dc2/details/periodical'
) ]
); );

View file

@ -12,16 +12,14 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
$dc_min = '2.6'; $dc_min = '2.19';
$new_version = $core->plugins->moduleInfo('periodical', 'version'); $new_version = $core->plugins->moduleInfo('periodical', 'version');
$old_version = $core->getVersion('periodical'); $old_version = $core->getVersion('periodical');
if (version_compare($old_version, $new_version, '>=')) { if (version_compare($old_version, $new_version, '>=')) {
return null; return null;
} }
@ -67,8 +65,7 @@ try {
$core->setVersion('periodical', $new_version); $core->setVersion('periodical', $new_version);
return true; return true;
} } catch (Exception $e) {
catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
} }

View file

@ -12,14 +12,12 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
# Check Dotclear version # Check Dotclear version
if (!method_exists('dcUtils', 'versionsCompare') if (!method_exists('dcUtils', 'versionsCompare')
|| dcUtils::versionsCompare(DC_VERSION, '2.6', '<', false) || dcUtils::versionsCompare(DC_VERSION, '2.18', '<', false)) {
) {
return null; return null;
} }
@ -35,9 +33,9 @@ $__autoload['periodicalSoCialMeWriter'] = $d.'lib.periodical.socialmewriter.php'
$core->addBehavior( $core->addBehavior(
'soCialMeWriterMarker', 'soCialMeWriterMarker',
array('periodicalSoCialMeWriter', 'soCialMeWriterMarker') ['periodicalSoCialMeWriter', 'soCialMeWriterMarker']
); );
$core->addBehavior( $core->addBehavior(
'periodicalAfterPublishedPeriodicalEntry', 'periodicalAfterPublishedPeriodicalEntry',
array('periodicalSoCialMeWriter', 'periodicalAfterPublishedPeriodicalEntry') ['periodicalSoCialMeWriter', 'periodicalAfterPublishedPeriodicalEntry']
); );

View file

@ -12,12 +12,10 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
if (!in_array($core->url->type, array('default', 'feed'))) { if (!in_array($core->url->type, ['default', 'feed'])) {
return null; return null;
} }
@ -25,7 +23,7 @@ $core->blog->settings->addNamespace('periodical');
$core->addBehavior( $core->addBehavior(
'publicBeforeDocument', 'publicBeforeDocument',
array('publicPeriodical', 'publicBeforeDocument') ['publicPeriodical', 'publicBeforeDocument']
); );
/** /**
@ -49,7 +47,7 @@ class publicPeriodical
$per->lockUpdate(); $per->lockUpdate();
# Get periods # Get periods
$periods = $core->auth->sudo(array($per, 'getPeriods')); $periods = $core->auth->sudo([$per, 'getPeriods']);
# No period # No period
if ($periods->isEmpty()) { if ($periods->isEmpty()) {
@ -91,20 +89,21 @@ class publicPeriodical
$loop_tz = $per->getNextTime($loop_tz, $periods->periodical_pub_int); $loop_tz = $per->getNextTime($loop_tz, $periods->periodical_pub_int);
$limit += 1; $limit += 1;
} }
} catch (Exception $e) {
} }
catch (Exception $e) { }
# If period need update # If period need update
if ($limit > 0) { if ($limit > 0) {
# Get posts to publish related to this period # Get posts to publish related to this period
$posts_params = array(); $posts_params = [];
$posts_params['periodical_id'] = $periods->periodical_id; $posts_params['periodical_id'] = $periods->periodical_id;
$posts_params['post_status'] = '-2'; $posts_params['post_status'] = '-2';
$posts_params['order'] = $posts_order; $posts_params['order'] = $posts_order;
$posts_params['limit'] = $limit * $max_nb; $posts_params['limit'] = $limit * $max_nb;
$posts_params['no_content'] = true; $posts_params['no_content'] = true;
$posts = $core->auth->sudo(array($per, 'getPosts'), $posts_params); $posts = $core->auth->sudo([$per, 'getPosts'], $posts_params);
if (!$posts->isEmpty()) { if (!$posts->isEmpty()) {
$cur_post = $core->con->openCursor($core->prefix . 'post'); $cur_post = $core->con->openCursor($core->prefix . 'post');
@ -119,8 +118,7 @@ class publicPeriodical
if ($s->periodical_upddate) { if ($s->periodical_upddate) {
$cur_post->post_dt = date('Y-m-d H:i:s', $last_tz); $cur_post->post_dt = date('Y-m-d H:i:s', $last_tz);
$cur_post->post_tz = $periods->periodical_tz; $cur_post->post_tz = $periods->periodical_tz;
} } else {
else {
$cur_post->post_dt = $posts->post_dt; $cur_post->post_dt = $posts->post_dt;
} }
@ -163,8 +161,7 @@ class publicPeriodical
} }
} }
$per->unlockUpdate(); $per->unlockUpdate();
} } catch (Exception $e) {
catch (Exception $e) {
$per->unlockUpdate(); $per->unlockUpdate();
return null; return null;

View file

@ -11,7 +11,9 @@
# #
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')){return;} if (!defined('DC_RC_PATH')){
return;
}
class periodical class periodical
{ {
@ -37,13 +39,11 @@ class periodical
} }
# Get periods # Get periods
public function getPeriods($params=array(),$count_only=false) public function getPeriods($params = [], $count_only = false)
{ {
if ($count_only) { if ($count_only) {
$q = 'SELECT count(T.periodical_id) '; $q = 'SELECT count(T.periodical_id) ';
} } else {
else
{
$q = 'SELECT T.periodical_id, T.periodical_type, '; $q = 'SELECT T.periodical_id, T.periodical_type, ';
if (!empty($params['columns']) && is_array($params['columns'])) { if (!empty($params['columns']) && is_array($params['columns'])) {
@ -65,20 +65,17 @@ class periodical
if (isset($params['periodical_type'])) { if (isset($params['periodical_type'])) {
if (is_array($params['periodical_type']) && !empty($params['periodical_type'])) { if (is_array($params['periodical_type']) && !empty($params['periodical_type'])) {
$q .= 'AND T.periodical_type ' . $this->con->in($params['periodical_type']); $q .= 'AND T.periodical_type ' . $this->con->in($params['periodical_type']);
} } elseif ($params['periodical_type'] != '') {
elseif ($params['periodical_type'] != '') {
$q .= "AND T.periodical_type = '" . $this->con->escape($params['periodical_type']) . "' "; $q .= "AND T.periodical_type = '" . $this->con->escape($params['periodical_type']) . "' ";
} }
} } else {
else {
$q .= "AND T.periodical_type = 'post' "; $q .= "AND T.periodical_type = 'post' ";
} }
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'], 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'] = array((integer) $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']);
} }
@ -91,8 +88,7 @@ class periodical
if (!$count_only) { if (!$count_only) {
if (!empty($params['order'])) { if (!empty($params['order'])) {
$q .= 'ORDER BY ' . $this->con->escape($params['order']).' '; $q .= 'ORDER BY ' . $this->con->escape($params['order']).' ';
} } else {
else {
$q .= 'ORDER BY T.periodical_id ASC '; $q .= 'ORDER BY T.periodical_id ASC ';
} }
} }
@ -110,8 +106,7 @@ class periodical
{ {
$this->con->writeLock($this->table); $this->con->writeLock($this->table);
try try {
{
$id = $this->con->select( $id = $this->con->select(
'SELECT MAX(periodical_id) FROM ' . $this->table 'SELECT MAX(periodical_id) FROM ' . $this->table
)->f(0) + 1; )->f(0) + 1;
@ -122,9 +117,7 @@ class periodical
$cur->periodical_tz = $this->core->auth->getInfo('user_tz'); $cur->periodical_tz = $this->core->auth->getInfo('user_tz');
$cur->insert(); $cur->insert();
$this->con->unlock(); $this->con->unlock();
} } catch (Exception $e) {
catch (Exception $e)
{
$this->con->unlock(); $this->con->unlock();
throw $e; throw $e;
} }
@ -150,7 +143,7 @@ class periodical
{ {
$period_id = (integer) $period_id; $period_id = (integer) $period_id;
$params = array(); $params = [];
$params['periodical_id'] = $period_id; $params['periodical_id'] = $period_id;
$params['post_status'] = ''; $params['post_status'] = '';
$rs = $this->getPosts($params); $rs = $this->getPosts($params);
@ -169,13 +162,15 @@ class periodical
# Remove all posts related to a period # Remove all posts related to a period
public function delPeriodPosts($period_id) public function delPeriodPosts($period_id)
{ {
$params = array(); $params = [];
$params['post_status'] = ''; $params['post_status'] = '';
$params['periodical_id'] = (integer) $period_id; $params['periodical_id'] = (integer) $period_id;
$rs = $this->getPosts($params); $rs = $this->getPosts($params);
if ($rs->isEmpty()) return; if ($rs->isEmpty()) {
return;
}
$ids = array(); $ids = array();
while($rs->fetch()) while($rs->fetch())
@ -183,7 +178,9 @@ class periodical
$ids[] = $rs->post_id; $ids[] = $rs->post_id;
} }
if (empty($ids)) return; if (empty($ids)) [
return;
}
$this->con->execute( $this->con->execute(
'DELETE FROM ' . $this->core->prefix . 'meta ' . 'DELETE FROM ' . $this->core->prefix . 'meta ' .
@ -193,11 +190,17 @@ class periodical
} }
# Get posts related to periods # Get posts related to periods
public function getPosts($params=array(),$count_only=false) public function getPosts($params = [], $count_only = false)
{ {
if (!isset($params['columns'])) $params['columns'] = array(); if (!isset($params['columns'])) {
if (!isset($params['from'])) $params['from'] = ''; $params['columns'] = [];
if (!isset($params['sql'])) $params['sql'] = ''; }
if (!isset($params['from'])) {
$params['from'] = '';
}
if (!isset($params['sql'])) {
$params['sql'] = '';
}
$params['columns'][] = 'T.periodical_id'; $params['columns'][] = 'T.periodical_id';
$params['columns'][] = 'T.periodical_title'; $params['columns'][] = 'T.periodical_title';
@ -217,9 +220,8 @@ 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'], 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'] = array((integer) $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']);
@ -231,8 +233,7 @@ class periodical
} }
unset($params['post_status']); unset($params['post_status']);
} }
} } else {
else {
$params['sql'] .= 'AND P.post_status = -2 '; $params['sql'] .= 'AND P.post_status = -2 ';
} }
@ -250,21 +251,20 @@ class periodical
# Check if exists # Check if exists
$rs = $this->getPosts(array('post_id' => $post_id, 'periodical_id' => $period_id)); $rs = $this->getPosts(array('post_id' => $post_id, 'periodical_id' => $period_id));
if (!$rs->isEmpty()) return; if (!$rs->isEmpty()) {
return;
}
$cur = $this->con->openCursor($this->core->prefix .'meta'); $cur = $this->con->openCursor($this->core->prefix .'meta');
$this->con->writeLock($this->core->prefix . 'meta'); $this->con->writeLock($this->core->prefix . 'meta');
try try {
{
$cur->post_id = $post_id; $cur->post_id = $post_id;
$cur->meta_id = $period_id; $cur->meta_id = $period_id;
$cur->meta_type = 'periodical'; $cur->meta_type = 'periodical';
$cur->insert(); $cur->insert();
$this->con->unlock(); $this->con->unlock();
} } catch (Exception $e) {
catch (Exception $e)
{
$this->con->unlock(); $this->con->unlock();
throw $e; throw $e;
} }
@ -286,7 +286,7 @@ class periodical
# Remove all posts without pending status from periodical # Remove all posts without pending status from periodical
public function cleanPosts($period_id = null) public function cleanPosts($period_id = null)
{ {
$params = array(); $params = [];
$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) {
@ -294,15 +294,18 @@ class periodical
} }
$rs = $this->getPosts($params); $rs = $this->getPosts($params);
if ($rs->isEmpty()) return; if ($rs->isEmpty()) {
return;
}
$ids = array(); $ids = array();
while($rs->fetch()) while($rs->fetch()) {
{
$ids[] = $rs->post_id; $ids[] = $rs->post_id;
} }
if (empty($ids)) return; if (empty($ids)) {
return;
}
$this->con->execute( $this->con->execute(
'DELETE FROM ' . $this->core->prefix . 'meta ' . 'DELETE FROM ' . $this->core->prefix . 'meta ' .
@ -313,13 +316,13 @@ class periodical
public static function getTimesCombo() public static function getTimesCombo()
{ {
return array( return []
__('Hourly') => 'hour', __('Hourly') => 'hour',
__('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)
@ -359,8 +362,7 @@ class periodical
# Lock a file to see if an update is ongoing # Lock a file to see if an update is ongoing
public function lockUpdate() public function lockUpdate()
{ {
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");
@ -371,7 +373,8 @@ class periodical
} }
# Set file path # Set file path
$f_md5 = md5($this->blog); $f_md5 = md5($this->blog);
$cached_file = sprintf('%s/%s/%s/%s/%s.txt', $cached_file = sprintf(
'%s/%s/%s/%s/%s.txt',
DC_TPL_CACHE, DC_TPL_CACHE,
'periodical', 'periodical',
substr($f_md5, 0, 2), substr($f_md5, 0, 2),
@ -382,7 +385,6 @@ class periodical
$cached_file = path::real($cached_file, false); $cached_file = path::real($cached_file, false);
# Make dir # Make dir
if (!is_dir(dirname($cached_file))) { if (!is_dir(dirname($cached_file))) {
files::makeDir(dirname($cached_file), true); files::makeDir(dirname($cached_file), true);
} }
# Make file # Make file
@ -404,9 +406,7 @@ class periodical
} }
$this->lock = $fp; $this->lock = $fp;
return true; return true;
} } catch (Exception $e) {
catch (Exception $e)
{
throw $e; throw $e;
} }
return false; return false;
@ -418,4 +418,3 @@ class periodical
$this->lock = null; $this->lock = null;
} }
} }
?>

View file

@ -12,7 +12,6 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
@ -28,8 +27,7 @@ class adminPeriodicalList extends adminGenericList
$echo = ''; $echo = '';
if ($this->rs->isEmpty()) { if ($this->rs->isEmpty()) {
$echo .= '<p><strong>' .__('No period') .'</strong></p>'; $echo .= '<p><strong>' .__('No period') .'</strong></p>';
} } else {
else {
$pager = new dcPager($page, $this->rs_count, $nb_per_page, 10); $pager = new dcPager($page, $this->rs_count, $nb_per_page, 10);
$pager->html_prev = $this->html_prev; $pager->html_prev = $this->html_prev;
$pager->html_next = $this->html_next; $pager->html_next = $this->html_next;
@ -72,7 +70,7 @@ class adminPeriodicalList extends adminGenericList
private function periodLine() private function periodLine()
{ {
$nb_posts = $this->rs->periodical->getPosts(array('periodical_id' => $this->rs->periodical_id), true); $nb_posts = $this->rs->periodical->getPosts(['periodical_id' => $this->rs->periodical_id], true);
$nb_posts = $nb_posts->f(0); $nb_posts = $nb_posts->f(0);
$style = !$nb_posts ? ' offline' : ''; $style = !$nb_posts ? ' offline' : '';
$posts_links = !$nb_posts ? $posts_links = !$nb_posts ?
@ -84,8 +82,9 @@ class adminPeriodicalList extends adminGenericList
$res = $res =
'<tr class="line' . $style . '">' . '<tr class="line' . $style . '">' .
'<td class="nowrap">'.form::checkbox(array('periods[]'), $this->rs->periodical_id).'</td>'. '<td class="nowrap">' . form::checkbox(['periods[]'], $this->rs->periodical_id) . '</td>' .
'<td class="maximal"><a href="plugin.php?p=periodical&amp;part=period&amp;period_id='.$this->rs->periodical_id.'#period" title="'.__('edit period').'">'.html::escapeHTML($this->rs->periodical_title).'</a></td>'. '<td class="maximal"><a href="plugin.php?p=periodical&amp;part=period&amp;period_id=' . $this->rs->periodical_id . '#period" title="' .
__('edit period') . '">' . html::escapeHTML($this->rs->periodical_title) . '</a></td>' .
'<td class="nowrap">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->periodical_curdt) . '</td>' . '<td class="nowrap">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->periodical_curdt) . '</td>' .
'<td class="nowrap">' . $pub_int . '</td>' . '<td class="nowrap">' . $pub_int . '</td>' .
'<td class="nowrap">' . $this->rs->periodical_pub_nb .'</td>' . '<td class="nowrap">' . $this->rs->periodical_pub_nb .'</td>' .
@ -101,8 +100,7 @@ class adminPeriodicalList extends adminGenericList
$echo = ''; $echo = '';
if ($this->rs->isEmpty()) { if ($this->rs->isEmpty()) {
$echo .= '<p><strong>' . __('No entry') . '</strong></p>'; $echo .= '<p><strong>' . __('No entry') . '</strong></p>';
} } else {
else {
$pager = new dcPager($page, $this->rs_count, $nb_per_page, 10); $pager = new dcPager($page, $this->rs_count, $nb_per_page, 10);
$pager->html_prev = $this->html_prev; $pager->html_prev = $this->html_prev;
$pager->html_next = $this->html_next; $pager->html_next = $this->html_next;
@ -145,8 +143,7 @@ class adminPeriodicalList extends adminGenericList
{ {
if ($this->core->auth->check('categories', $this->core->blog->id)) { if ($this->core->auth->check('categories', $this->core->blog->id)) {
$cat_link = '<a href="category.php?id=%s">%s</a>'; $cat_link = '<a href="category.php?id=%s">%s</a>';
} } else {
else {
$cat_link = '%2$s'; $cat_link = '%2$s';
} }
@ -156,8 +153,7 @@ class adminPeriodicalList extends adminGenericList
$this->rs->cat_id, $this->rs->cat_id,
html::escapeHTML($this->rs->cat_title) html::escapeHTML($this->rs->cat_title)
); );
} } else {
else {
$cat_title = __('None'); $cat_title = __('None');
} }
@ -200,7 +196,7 @@ class adminPeriodicalList extends adminGenericList
$res = $res =
'<tr class="line">' . '<tr class="line">' .
'<td class="minimal">'.form::checkbox(array('periodical_entries[]'), $this->rs->post_id,0).'</td>'. '<td class="minimal">' . form::checkbox(['periodical_entries[]'], $this->rs->post_id, 0) . '</td>' .
'<td class="maximal"><a href="' . $this->rs->core->getPostAdminURL($this->rs->post_type, $this->rs->post_id) . '" ' . '<td class="maximal"><a href="' . $this->rs->core->getPostAdminURL($this->rs->post_type, $this->rs->post_id) . '" ' .
'title="' . html::escapeHTML($this->rs->getURL()) . '">' . 'title="' . html::escapeHTML($this->rs->getURL()) . '">' .
html::escapeHTML($this->rs->post_title) . '</a></td>' . html::escapeHTML($this->rs->post_title) . '</a></td>' .

View file

@ -11,20 +11,22 @@
# #
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')){return;} if (!defined('DC_RC_PATH')){
return;
}
# Add ability to send social messages when a feed is update # Add ability to send social messages when a feed is update
class periodicalSoCialMeWriter class periodicalSoCialMeWriter
{ {
public static function soCialMeWriterMarker($rs) public static function soCialMeWriterMarker($rs)
{ {
$rs['periodicalcreate'] = array( $rs['periodicalcreate'] = [
'name' => __('New periodical publication'), 'name' => __('New periodical publication'),
'description' => __('When an entry is published on a period'), 'description' => __('When an entry is published on a period'),
'action' => array('Message','Link'), 'action' => ['Message', 'Link'],
'format' => array('Message'), 'format' => ['Message'],
'wildcards' => array('Message' => array('%posttitle%','%posturl%','%shortposturl%','%postauthor%','%sitetitle%','%siteurl%','%shortsiteurl%')) 'wildcards' => ['Message' => ['%posttitle%','%posturl%','%shortposturl%','%postauthor%','%sitetitle%','%siteurl%','%shortsiteurl%']]
); ];
} }
public static function periodicalAfterPublishedPeriodicalEntry($core, $post, $period) public static function periodicalAfterPublishedPeriodicalEntry($core, $post, $period)
@ -32,11 +34,13 @@ class periodicalSoCialMeWriter
$key = 'periodicalcreate'; $key = 'periodicalcreate';
# Is install # Is install
if (!$core->plugins->moduleExists('soCialMe')) return; if (!$core->plugins->moduleExists('soCialMe')) {
return;
}
# Is active # Is active
if (!$core->blog->settings->soCialMeWriter->active) return; if (!$core->blog->settings->soCialMeWriter->active) {
return;
}
# Load services # Load services
$soCialMeWriter = new soCialMeWriter($core); $soCialMeWriter = new soCialMeWriter($core);
@ -54,30 +58,25 @@ class periodicalSoCialMeWriter
$shortsiteurl = $shortsiteurl ? $shortsiteurl : $core->blog->url; $shortsiteurl = $shortsiteurl ? $shortsiteurl : $core->blog->url;
# sendMessage # sendMessage
if (!empty($formats[$key]['Message']) && !empty($actions[$key]['Message'])) if (!empty($formats[$key]['Message']) && !empty($actions[$key]['Message'])) {
{
// parse message // parse message
$message_txt = str_replace( $message_txt = str_replace(
array('%posttitle%','%posturl%','%shortposturl%','%postauthor%','%sitetitle%','%siteurl%','%shortsiteurl%'), ['%posttitle%', '%posturl%', '%shortposturl%', '%postauthor%', '%sitetitle%', '%siteurl%', '%shortsiteurl%'],
array($post->post_title,$post->getURL(),$shortposturl,$post->getUserCN(),$core->blog->name,$core->blog->url,$shortsiteurl), [$post->post_title, $post->getURL(), $shortposturl, $post->getUserCN(), $core->blog->name, $core->blog->url, $shortsiteurl],
$formats[$key]['Message'] $formats[$key]['Message']
); );
// send message // send message
if (!empty($message_txt)) if (!empty($message_txt)) {
{ foreach($actions[$key]['Message'] as $service_id) {
foreach($actions[$key]['Message'] as $service_id)
{
$soCialMeWriter->play($service_id, 'Message', 'Content', $message_txt); $soCialMeWriter->play($service_id, 'Message', 'Content', $message_txt);
} }
} }
} }
# sendLink # sendLink
if (!empty($actions[$key]['Link'])) if (!empty($actions[$key]['Link'])) {
{ foreach($actions[$key]['Link'] as $service_id) {
foreach($actions[$key]['Link'] as $service_id)
{
$soCialMeWriter->play($service_id, 'Link', 'Content', $post->post_title, $shortposturl); $soCialMeWriter->play($service_id, 'Link', 'Content', $post->post_title, $shortposturl);
} }
} }
@ -89,4 +88,3 @@ class periodicalSoCialMeWriter
// not yet implemented // not yet implemented
} }
} }
?>

191
index.php
View file

@ -12,7 +12,6 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
@ -47,14 +46,13 @@ if ($part == 'period') {
# Get period # Get period
if (!empty($_REQUEST['period_id'])) { if (!empty($_REQUEST['period_id'])) {
$rs = $per->getPeriods(array( $rs = $per->getPeriods([
'periodical_id' => $_REQUEST['period_id'] 'periodical_id' => $_REQUEST['period_id']
)); ]);
if ($rs->isEmpty()) { if ($rs->isEmpty()) {
$core->error->add(__('This period does not exist.')); $core->error->add(__('This period does not exist.'));
$period_id = null; $period_id = null;
} } else {
else {
$period_id = $rs->periodical_id; $period_id = $rs->periodical_id;
$period_title = $rs->periodical_title; $period_title = $rs->periodical_title;
$period_pub_nb = $rs->periodical_pub_nb; $period_pub_nb = $rs->periodical_pub_nb;
@ -77,8 +75,7 @@ if ($part == 'period') {
$period_pub_nb = abs((integer) $_POST['period_pub_nb']); $period_pub_nb = abs((integer) $_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())) {
) {
$period_pub_int = $_POST['period_pub_int']; $period_pub_int = $_POST['period_pub_int'];
} }
if (!empty($_POST['period_curdt'])) { if (!empty($_POST['period_curdt'])) {
@ -89,9 +86,9 @@ if ($part == 'period') {
} }
# Check period title and dates # Check period title and dates
$old_titles = $per->getPeriods(array( $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()) {
if (!$period_id || $old_titles->periodical_id != $period_id) { if (!$period_id || $old_titles->periodical_id != $period_id) {
@ -124,9 +121,8 @@ if ($part == 'period') {
dcPage::addSuccessNotice( dcPage::addSuccessNotice(
__('Period successfully updated.') __('Period successfully updated.')
); );
}
# Create period # Create period
else { } else {
$period_id = $per->addPeriod($cur); $period_id = $per->addPeriod($cur);
@ -162,8 +158,7 @@ if ($part == 'period') {
$p_url . '&part=period&period_id=' . $period_id . '#posts' : $p_url . '&part=period&period_id=' . $period_id . '#posts' :
$_POST['redir'] $_POST['redir']
); );
} } catch (Exception $e) {
catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
} }
} }
@ -185,8 +180,7 @@ if ($part == 'period') {
$p_url . '&part=period&period_id=' . $period_id . '#posts' : $p_url . '&part=period&period_id=' . $period_id . '#posts' :
$_POST['redir'] $_POST['redir']
); );
} } catch (Exception $e) {
catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
} }
} }
@ -207,8 +201,7 @@ if ($part == 'period') {
$p_url . '&part=period&period_id=' . $period_id . '#posts' : $p_url . '&part=period&period_id=' . $period_id . '#posts' :
$_POST['redir'] $_POST['redir']
); );
} } catch (Exception $e) {
catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
} }
} }
@ -216,21 +209,19 @@ if ($part == 'period') {
# Prepare combos for posts list # Prepare combos for posts list
if ($period_id) { if ($period_id) {
try { try {
# Getting categories # Getting categories
$categories = $core->blog->getCategories(array('post_type' => 'post')); $categories = $core->blog->getCategories(['post_type' => 'post']);
# Getting authors # Getting authors
$users = $core->blog->getPostsUsers(); $users = $core->blog->getPostsUsers();
# Getting dates # Getting dates
$dates = $core->blog->getDates(array('type' => 'month')); $dates = $core->blog->getDates(['type' => 'month']);
# Getting langs # Getting langs
$langs = $core->blog->getLangs(); $langs = $core->blog->getLangs();
} } catch (Exception $e) {
catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
} }
} }
@ -240,18 +231,19 @@ if ($part == 'period') {
# Users combo # Users combo
$users_combo = array_merge( $users_combo = array_merge(
array('-' => ''), ['-' => ''],
dcAdminCombos::getUsersCombo($users) dcAdminCombos::getUsersCombo($users)
); );
# Categories combo # Categories combo
$categories_combo = array_merge( $categories_combo = array_merge(
array( [
new formSelectOption('-', ''), new formSelectOption('-', ''),
new formSelectOption(__('(No cat)'), 'NULL')), new formSelectOption(__('(No cat)'), 'NULL')
],
dcAdminCombos::getCategoriesCombo($categories, false) dcAdminCombos::getCategoriesCombo($categories, false)
); );
$categories_values = array(); $categories_values = [];
foreach ($categories_combo as $cat) { foreach ($categories_combo as $cat) {
if (isset($cat->value)) { if (isset($cat->value)) {
$categories_values[$cat->value] = true; $categories_values[$cat->value] = true;
@ -260,38 +252,38 @@ if ($part == 'period') {
# Status combo # Status combo
$status_combo = array_merge( $status_combo = array_merge(
array('-' => ''), ['-' => ''],
dcAdminCombos::getPostStatusesCombo() dcAdminCombos::getPostStatusesCombo()
); );
# Selection combo # Selection combo
$selected_combo = array( $selected_combo = [
'-' => '', '-' => '',
__('Selected') => '1', __('Selected') => '1',
__('Not selected') => '0' __('Not selected') => '0'
); ];
# Attachments combo # Attachments combo
$attachment_combo = array( $attachment_combo = [
'-' => '', '-' => '',
__('With attachments') => '1', __('With attachments') => '1',
__('Without attachments') => '0' __('Without attachments') => '0'
); ];
# Months combo # Months combo
$dt_m_combo = array_merge( $dt_m_combo = array_merge(
array('-' => ''), ['-' => ''],
dcAdminCombos::getDatesCombo($dates) dcAdminCombos::getDatesCombo($dates)
); );
# Langs combo # Langs combo
$lang_combo = array_merge( $lang_combo = array_merge(
array('-' => ''), ['-' => ''],
dcAdminCombos::getLangsCombo($langs, false) dcAdminCombos::getLangsCombo($langs, false)
); );
# Sort_by combo # Sort_by combo
$sortby_combo = array( $sortby_combo = [
__('Date') => 'post_dt', __('Date') => 'post_dt',
__('Title') => 'post_title', __('Title') => 'post_title',
__('Category') => 'cat_title', __('Category') => 'cat_title',
@ -300,13 +292,13 @@ if ($part == 'period') {
__('Selected') => 'post_selected', __('Selected') => 'post_selected',
__('Number of comments') => 'nb_comment', __('Number of comments') => 'nb_comment',
__('Number of trackbacks') => 'nb_trackback' __('Number of trackbacks') => 'nb_trackback'
); ];
# order combo # order combo
$order_combo = array( $order_combo = [
__('Descending') => 'desc', __('Descending') => 'desc',
__('Ascending') => 'asc' __('Ascending') => 'asc'
); ];
# parse filters # parse filters
$user_id = !empty($_GET['user_id']) ? $_GET['user_id'] : ''; $user_id = !empty($_GET['user_id']) ? $_GET['user_id'] : '';
@ -331,7 +323,7 @@ if ($part == 'period') {
$nb_per_page = (integer) $_GET['nb']; $nb_per_page = (integer) $_GET['nb'];
} }
$params['limit'] = array((($page-1)*$nb_per_page), $nb_per_page); $params['limit'] = [(($page-1)*$nb_per_page), $nb_per_page];
$params['no_content'] = true; $params['no_content'] = true;
$params['periodical_id'] = $period_id; $params['periodical_id'] = $period_id;
@ -339,8 +331,7 @@ if ($part == 'period') {
if ($user_id !== '' && in_array($user_id, $users_combo)) { if ($user_id !== '' && in_array($user_id, $users_combo)) {
$params['user_id'] = $user_id; $params['user_id'] = $user_id;
$show_filters = true; $show_filters = true;
} } else {
else {
$user_id=''; $user_id='';
} }
@ -348,8 +339,7 @@ if ($part == 'period') {
if ($cat_id !== '' && isset($categories_values[$cat_id])) { if ($cat_id !== '' && isset($categories_values[$cat_id])) {
$params['cat_id'] = $cat_id; $params['cat_id'] = $cat_id;
$show_filters = true; $show_filters = true;
} } else {
else {
$cat_id=''; $cat_id='';
} }
@ -357,8 +347,7 @@ if ($part == 'period') {
if ($status !== '' && in_array($status, $status_combo)) { if ($status !== '' && in_array($status, $status_combo)) {
$params['post_status'] = $status; $params['post_status'] = $status;
$show_filters = true; $show_filters = true;
} } else {
else {
$status=''; $status='';
} }
@ -366,8 +355,7 @@ if ($part == 'period') {
if ($selected !== '' && in_array($selected, $selected_combo)) { if ($selected !== '' && in_array($selected, $selected_combo)) {
$params['post_selected'] = $selected; $params['post_selected'] = $selected;
$show_filters = true; $show_filters = true;
} } else {
else {
$selected=''; $selected='';
} }
@ -376,8 +364,7 @@ if ($part == 'period') {
$params['media'] = $attachment; $params['media'] = $attachment;
$params['link_type'] = 'attachment'; $params['link_type'] = 'attachment';
$show_filters = true; $show_filters = true;
} } else {
else {
$attachment=''; $attachment='';
} }
@ -386,8 +373,7 @@ if ($part == 'period') {
$params['post_month'] = substr($month, 4, 2); $params['post_month'] = substr($month, 4, 2);
$params['post_year'] = substr($month, 0, 4); $params['post_year'] = substr($month, 0, 4);
$show_filters = true; $show_filters = true;
} } else {
else {
$month=''; $month='';
} }
@ -395,8 +381,7 @@ if ($part == 'period') {
if ($lang !== '' && in_array($lang, $lang_combo)) { if ($lang !== '' && in_array($lang, $lang_combo)) {
$params['post_lang'] = $lang; $params['post_lang'] = $lang;
$show_filters = true; $show_filters = true;
} } else {
else {
$lang=''; $lang='';
} }
@ -404,16 +389,14 @@ if ($part == 'period') {
if ($sortby !== '' && in_array($sortby, $sortby_combo)) { if ($sortby !== '' && in_array($sortby, $sortby_combo)) {
if ($order !== '' && in_array($order, $order_combo)) { if ($order !== '' && in_array($order, $order_combo)) {
$params['order'] = $sortby.' '.$order; $params['order'] = $sortby.' '.$order;
} } else {
else {
$order='desc'; $order='desc';
} }
if ($sortby != 'post_dt' || $order != 'desc') { if ($sortby != 'post_dt' || $order != 'desc') {
$show_filters = true; $show_filters = true;
} }
} } else {
else {
$sortby='post_dt'; $sortby='post_dt';
$order='desc'; $order='desc';
} }
@ -423,8 +406,7 @@ if ($part == 'period') {
$posts = $per->getPosts($params); $posts = $per->getPosts($params);
$counter = $per->getPosts($params, true); $counter = $per->getPosts($params, true);
$post_list = new adminPeriodicalList($core, $posts, $counter->f(0)); $post_list = new adminPeriodicalList($core, $posts, $counter->f(0));
} } catch (Exception $e) {
catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
} }
@ -462,11 +444,11 @@ if ($part == 'period') {
echo echo
dcPage::breadcrumb( dcPage::breadcrumb(
array( [
html::escapeHTML($core->blog->name) => '', html::escapeHTML($core->blog->name) => '',
__('Periodical') => $p_url . '&amp;part=periods', __('Periodical') => $p_url . '&amp;part=periods',
(null === $period_id ? __('New period') : __('Edit period')) => '' (null === $period_id ? __('New period') : __('Edit period')) => ''
) ]
) . ) .
dcPage::notices(); dcPage::notices();
@ -501,9 +483,9 @@ if ($part == 'period') {
<div class="clear"> <div class="clear">
<p><input type="submit" name="save" value="' . __('Save') . '" />' . <p><input type="submit" name="save" value="' . __('Save') . '" />' .
$core->formNonce() . $core->formNonce() .
form::hidden(array('action'), 'setperiod'). form::hidden(['action'], 'setperiod') .
form::hidden(array('period_id'), $period_id). form::hidden(['period_id'], $period_id) .
form::hidden(array('part'), 'period').' form::hidden(['part'], 'period') .'
</p> </p>
</div> </div>
</form> </form>
@ -581,9 +563,9 @@ if ($part == 'period') {
'</div>' . '</div>' .
'<p><input type="submit" value="' . __('Apply filters and display options') . '" />' . '<p><input type="submit" value="' . __('Apply filters and display options') . '" />' .
form::hidden(array('p'), 'periodical'). form::hidden(['p'], 'periodical') .
form::hidden(array('part'), 'period'). form::hidden(['part'], 'period') .
form::hidden(array('period_id'), $period_id). form::hidden(['period_id'], $period_id) .
'<br class="clear" /></p>' . //Opera sucks '<br class="clear" /></p>' . //Opera sucks
'</form>'; '</form>';
@ -600,21 +582,21 @@ if ($part == 'period') {
'<p class="col right">' . __('Selected entries action:') . ' ' . '<p class="col right">' . __('Selected entries action:') . ' ' .
form::combo('action', $combo_action) . form::combo('action', $combo_action) .
'<input type="submit" value="' . __('ok') . '" /></p>' . '<input type="submit" value="' . __('ok') . '" /></p>' .
form::hidden(array('period_id'), $period_id). form::hidden(['period_id'], $period_id) .
form::hidden(array('user_id'), $user_id). form::hidden(['user_id'], $user_id) .
form::hidden(array('cat_id'), $cat_id). form::hidden(['cat_id'], $cat_id) .
form::hidden(array('status'), $status). form::hidden(['status'], $status) .
form::hidden(array('selected'), $selected). form::hidden(['selected'], $selected) .
form::hidden(array('attachment'), $attachment). form::hidden(['attachment'], $attachment) .
form::hidden(array('month'), $month). form::hidden(['month'], $month) .
form::hidden(array('lang'), $lang). form::hidden(['lang'], $lang) .
form::hidden(array('sortby'), $sortby). form::hidden(['sortby'], $sortby) .
form::hidden(array('order'), $order). form::hidden(['order'], $order) .
form::hidden(array('page'), $page). form::hidden(['page'], $page) .
form::hidden(array('nb'), $nb_per_page). form::hidden(['nb'], $nb_per_page) .
form::hidden(array('p'), 'periodical'). form::hidden(['p'], 'periodical') .
form::hidden(array('part'), 'period'). form::hidden(['part'], 'period') .
form::hidden(array('redir'), sprintf($base_url, $page)). form::hidden(['redir'], sprintf($base_url, $page)) .
$core->formNonce() . $core->formNonce() .
'</div>' . '</div>' .
'</form>' '</form>'
@ -624,15 +606,13 @@ if ($part == 'period') {
'</div>'; '</div>';
} }
}
############################################################ ############################################################
# #
# All periods # All periods
# #
############################################################ ############################################################
else { } else {
# Delete periods and related posts links # Delete periods and related posts links
if ($action == 'deleteperiods' && !empty($_POST['periods'])) { if ($action == 'deleteperiods' && !empty($_POST['periods'])) {
@ -651,8 +631,7 @@ else {
$p_url.'&part=periods' : $p_url.'&part=periods' :
$_POST['redir'] $_POST['redir']
); );
} } catch (Exception $e) {
catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
} }
} }
@ -672,25 +651,24 @@ else {
$p_url.'&part=periods' : $p_url.'&part=periods' :
$_POST['redir'] $_POST['redir']
); );
} } catch (Exception $e) {
catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
} }
} }
# Combos # Combos
$sortby_combo = array( $sortby_combo = [
__('Next update') => 'periodical_curdt', __('Next update') => 'periodical_curdt',
__('End date') => 'periodical_enddt', __('End date') => 'periodical_enddt',
__('Frequence') => 'periodical_pub_int' __('Frequence') => 'periodical_pub_int'
); ];
$order_combo = array( $order_combo = [
__('Descending') => 'desc', __('Descending') => 'desc',
__('Ascending') => 'asc' __('Ascending') => 'asc'
); ];
$combo_action = array(); $combo_action = [];
$combo_action[__('empty periods')] = 'emptyperiods'; $combo_action[__('empty periods')] = 'emptyperiods';
$combo_action[__('delete periods')] = 'deleteperiods'; $combo_action[__('delete periods')] = 'deleteperiods';
@ -710,7 +688,7 @@ else {
$nb_per_page = (integer) $_GET['nb']; $nb_per_page = (integer) $_GET['nb'];
} }
$params['limit'] = array((($page-1)*$nb_per_page), $nb_per_page); $params['limit'] = [(($page-1)*$nb_per_page), $nb_per_page];
if ($sortby !== '' && in_array($sortby, $sortby_combo)) { if ($sortby !== '' && in_array($sortby, $sortby_combo)) {
if ($order !== '' && in_array($order, $order_combo)) { if ($order !== '' && in_array($order, $order_combo)) {
@ -727,8 +705,7 @@ else {
$periods = $per->getPeriods($params); $periods = $per->getPeriods($params);
$counter = $per->getPeriods($params, true); $counter = $per->getPeriods($params, true);
$period_list = new adminPeriodicalList($core, $periods, $counter->f(0)); $period_list = new adminPeriodicalList($core, $periods, $counter->f(0));
} } catch (Exception $e) {
catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
} }
@ -739,7 +716,7 @@ else {
'index.php?pf=periodical/js/periodsfilter.js' 'index.php?pf=periodical/js/periodsfilter.js'
) . ) .
'<script type="text/javascript">' . "\n" . '<script type="text/javascript">' . "\n" .
"//<![CDATA["."\n". "//<![CDATA[\n" .
dcPage::jsVar( dcPage::jsVar(
'dotclear.msg.show_filters', 'dotclear.msg.show_filters',
$show_filters ? 'true':'false' $show_filters ? 'true':'false'
@ -758,10 +735,10 @@ else {
'<body>' . '<body>' .
dcPage::breadcrumb( dcPage::breadcrumb(
array( [
html::escapeHTML($core->blog->name) => '', html::escapeHTML($core->blog->name) => '',
__('Periodical') => '' __('Periodical') => ''
) ]
) . ) .
dcPage::notices() . dcPage::notices() .
@ -798,8 +775,8 @@ else {
'<p>' . '<p>' .
'<input type="submit" value="' . __('Apply filters and display options') . '" />' . '<input type="submit" value="' . __('Apply filters and display options') . '" />' .
form::hidden(array('p'), 'periodical'). form::hidden(['p'], 'periodical') .
form::hidden(array('part'), 'periods'). form::hidden(['part'], 'periods') .
'<br class="clear" />' . //Opera sucks '<br class="clear" />' . //Opera sucks
'</p>' . '</p>' .
@ -817,12 +794,12 @@ else {
'<p class="col right">' . __('Selected periods action:') . ' ' . '<p class="col right">' . __('Selected periods action:') . ' ' .
form::combo('action', $combo_action) . form::combo('action', $combo_action) .
'<input type="submit" value="' . __('ok') . '" /></p>' . '<input type="submit" value="' . __('ok') . '" /></p>' .
form::hidden(array('sortby'), $sortby). form::hidden(['sortby'], $sortby) .
form::hidden(array('order'), $order). form::hidden(['order'], $order) .
form::hidden(array('page'), $page). form::hidden(['page'], $page) .
form::hidden(array('nb'), $nb_per_page). form::hidden(['nb'], $nb_per_page) .
form::hidden(array('p'), 'periodical'). form::hidden(['p'], 'periodical') .
form::hidden(array('part'), 'periods'). form::hidden(['part'], 'periods') .
$core->formNonce() . $core->formNonce() .
'</div>' . '</div>' .
'</form>' '</form>'

View file

@ -10,9 +10,8 @@
<p>If you want some help or contribute to the plugin periodical, follow these links.</p> <p>If you want some help or contribute to the plugin periodical, follow these links.</p>
<ul> <ul>
<li><a href="http://forum.dotclear.org/viewtopic.php?id=42289">Post on Dotclear's forum</a></li> <li><a href="http://forum.dotclear.org/viewtopic.php?id=42289">Post on Dotclear's forum</a></li>
<li><a href="http://lab.dotclear.org/wiki/plugin/periodical">SVN repository</a></li> <li><a href="https://github.com/JcDenis/periodical">Github repository</a></li>
<li><a href="https://bitbucket.org/JcDenis/periodical">HG repository</a></li> <li><a href="https://plugins.dotaddict.org/dc2/details/periodical">Dotaddict repository</a></li>
<li><a href="http://jcd.lv/q=periodical">Post on author's blog</a></li>
</ul> </ul>
</body> </body>

View file

@ -12,7 +12,6 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }

View file

@ -10,9 +10,8 @@
<p>Si vous souhaitez plus d'aide ou apporter votre contribution à l'extension periodical, voici quelques liens utiles.</p> <p>Si vous souhaitez plus d'aide ou apporter votre contribution à l'extension periodical, voici quelques liens utiles.</p>
<ul> <ul>
<li><a href="http://forum.dotclear.org/viewtopic.php?id=42289">Sujet sur le forum Dotclear</a></li> <li><a href="http://forum.dotclear.org/viewtopic.php?id=42289">Sujet sur le forum Dotclear</a></li>
<li><a href="http://lab.dotclear.org/wiki/plugin/periodical">Dépôt svn</a></li> <li><a href="https://github.com/JcDenis/periodical">Dépôt Github</a></li>
<li><a href="https://bitbucket.org/JcDenis/periodical">Dépôt hg</a></li> <li><a href="https://plugins.dotaddict.org/dc2/details/periodical">Dépôt Dotaddict</a></li>
<li><a href="http://jcd.lv/q=periodical">Billet dédié sur le blog de l'auteur</a></li>
</ul> </ul>
</body> </body>

View file

@ -12,7 +12,6 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }