clean up code

This commit is contained in:
Jean-Christian Paul Denis 2021-09-02 14:56:02 +02:00
parent a2663368ed
commit 517a395d81
15 changed files with 189 additions and 161 deletions

View File

@ -1,42 +1,45 @@
periodical 2021.08.xx xxxx.xx.xx
* update license - [x] update php headers to phpdoc style
* update php code to PSR-2 style and short array
* move settings to blog pref
periodical 2013.11.11 2021.08.23
* Switch to Dotclear 2.6 - update license
- update php code to PSR-2 style and short array
- move settings to blog pref
periodical 2013.06.30 2013.11.11
* Small fix and typo - Switch to Dotclear 2.6
periodical 0.5 - 2011-01-30 2013.06.30
* Fixed install on nightly buid - Small fix and typo
* Fixed call to blog object on prepend
* Removed mesenger fonctions (this is to another plugin to do that)
* Added behavior on post update
* Added periodical to plugin soCialMe
* New year copyright
periodical 0.4 - 2010-09-09 0.5 - 2011-01-30
* Removed old Twitter functions - Fixed install on nightly buid
* Added StatusNet small functions (Identica) - Fixed call to blog object on prepend
* Required plugin Tac for Twitter ability - Removed mesenger fonctions (this is to another plugin to do that)
- Added behavior on post update
- Added periodical to plugin soCialMe
- New year copyright
periodical 0.3.1 - 2010-06-25 0.4 - 2010-09-09
* Fixed postgreSQL compatibility - Removed old Twitter functions
* Fixed php 5.3 compatibility on post action combo - Added StatusNet small functions (Identica)
* Fixed admin crash on non DC 2.2 - Required plugin Tac for Twitter ability
* Fixed users rights
periodical 0.3 - 2010-06-08 0.3.1 - 2010-06-25
* Switched to DC 2.2 - Fixed postgreSQL compatibility
* Fixed simultaneous updates (uses flock) - Fixed php 5.3 compatibility on post action combo
* Added twitter option when posts are published - Fixed admin crash on non DC 2.2
- Fixed users rights
periodical 0.2 - 2010-04-11 0.3 - 2010-06-08
* Fixed some bugs - Switched to DC 2.2
* Added DC 2.2 compatibility (new setting) - Fixed simultaneous updates (uses flock)
* closes #415 - Added twitter option when posts are published
periodical 0.1 - 2010-04-05 0.2 - 2010-04-11
* First lab release - Fixed some bugs
- Added DC 2.2 compatibility (new setting)
- closes #415
0.1 - 2010-04-05
- First lab release

View File

@ -41,4 +41,4 @@ You can also add or remove period to multiple posts from posts actions page.
* License : GNU GPL v2 * License : GNU GPL v2
* Source & contribution : [GitHub Page](https://github.com/JcDenis/periodical) * Source & contribution : [GitHub Page](https://github.com/JcDenis/periodical)
* Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/periodical) * Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/periodical)
* Discuss & help: [Dotclear Forum](https://forum.dotclear.org/viewtopic.php?id=42289) * Discuss & help: [Dotclear Forum](https://forum.dotclear.org/viewtopic.php?id=42289)

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief periodical, a plugin for Dotclear 2
# This file is part of periodical, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief periodical, a plugin for Dotclear 2
# This file is part of periodical, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
@ -21,10 +21,11 @@ $this->registerModule(
'Jean-Christian Denis and contributors', 'Jean-Christian Denis and contributors',
'2021.08.23', '2021.08.23',
[ [
'requires' => [['core', '2.19']],
'permissions' => 'usage,contentadmin', 'permissions' => 'usage,contentadmin',
'type' => 'plugin', 'type' => 'plugin',
'dc_min' => '2.19',
'support' => 'https://github.com/JcDenis/periodical', 'support' => 'https://github.com/JcDenis/periodical',
'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'
] ]
); );

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief periodical, a plugin for Dotclear 2
# This file is part of periodical, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief periodical, a plugin for Dotclear 2
# This file is part of periodical, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief periodical, a plugin for Dotclear 2
# This file is part of periodical, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
@ -74,10 +74,10 @@ class publicPeriodical
$last_nb = 0; $last_nb = 0;
$last_tz = $cur_tz; $last_tz = $cur_tz;
$max_nb = $periods->periodical_pub_nb; $max_nb = $periods->periodical_pub_nb;
$max_tz = $end_tz < $now_tz ? $end_tz : $now_tz; $max_tz = $end_tz < $now_tz ? $end_tz : $now_tz;
# Calculate nb of posts to get # Calculate nb of posts to get
$loop_tz = $cur_tz; $loop_tz = $cur_tz;
$limit = 0; $limit = 0;
@ -107,7 +107,7 @@ class publicPeriodical
if (!$posts->isEmpty()) { if (!$posts->isEmpty()) {
$cur_post = $core->con->openCursor($core->prefix . 'post'); $cur_post = $core->con->openCursor($core->prefix . 'post');
while($posts->fetch()) { while($posts->fetch()) {
# Publish post with right date # Publish post with right date

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief periodical, a plugin for Dotclear 2
# This file is part of periodical, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')){ if (!defined('DC_RC_PATH')){
return; return;
@ -257,7 +257,7 @@ class periodical
$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;
@ -306,7 +306,7 @@ class periodical
if (empty($ids)) { if (empty($ids)) {
return; return;
} }
$this->con->execute( $this->con->execute(
'DELETE FROM ' . $this->core->prefix . 'meta ' . 'DELETE FROM ' . $this->core->prefix . 'meta ' .
"WHERE meta_type = 'periodical' " . "WHERE meta_type = 'periodical' " .
@ -324,7 +324,7 @@ class periodical
__('Monthly') => 'month' __('Monthly') => 'month'
]; ];
} }
public static function getNextTime($ts, $period) public static function getNextTime($ts, $period)
{ {
$ts = (integer) $ts; $ts = (integer) $ts;

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief periodical, a plugin for Dotclear 2
# This file is part of periodical, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
@ -67,7 +67,7 @@ class adminPeriodicalList extends adminGenericList
return $echo; return $echo;
} }
private function periodLine() private function periodLine()
{ {
$nb_posts = $this->rs->periodical->getPosts(['periodical_id' => $this->rs->periodical_id], true); $nb_posts = $this->rs->periodical->getPosts(['periodical_id' => $this->rs->periodical_id], true);
@ -126,11 +126,11 @@ class adminPeriodicalList extends adminGenericList
$blocks = explode('%s', $html_block); $blocks = explode('%s', $html_block);
$echo .= $blocks[0]; $echo .= $blocks[0];
while ($this->rs->fetch()) { while ($this->rs->fetch()) {
$echo .= $this->postLine(); $echo .= $this->postLine();
} }
$echo .= $blocks[1]; $echo .= $blocks[1];
$echo .= $pager->getLinks(); $echo .= $pager->getLinks();
@ -138,7 +138,7 @@ class adminPeriodicalList extends adminGenericList
return $echo; return $echo;
} }
private function postLine() private function postLine()
{ {
if ($this->core->auth->check('categories', $this->core->blog->id)) { if ($this->core->auth->check('categories', $this->core->blog->id)) {
@ -163,15 +163,15 @@ class adminPeriodicalList extends adminGenericList
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;

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief periodical, a plugin for Dotclear 2
# This file is part of periodical, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')){ if (!defined('DC_RC_PATH')){
return; return;

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief periodical, a plugin for Dotclear 2
# This file is part of periodical, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
@ -25,7 +25,6 @@ $per = new periodical($core);
$action = isset($_POST['action']) ? $_POST['action'] : ''; $action = isset($_POST['action']) ? $_POST['action'] : '';
$part = isset($_REQUEST['part']) && $_REQUEST['part'] == 'period' ? 'period' : 'periods'; $part = isset($_REQUEST['part']) && $_REQUEST['part'] == 'period' ? 'period' : 'periods';
############################################################ ############################################################
# #
# One period # One period
@ -392,7 +391,7 @@ if ($part == 'period') {
} else { } else {
$order='desc'; $order='desc';
} }
if ($sortby != 'post_dt' || $order != 'desc') { if ($sortby != 'post_dt' || $order != 'desc') {
$show_filters = true; $show_filters = true;
} }
@ -538,7 +537,7 @@ if ($part == 'period') {
'<p><label for="status" class="ib">' . __('Status:') . '</label> ' . '<p><label for="status" class="ib">' . __('Status:') . '</label> ' .
form::combo('status', $status_combo, $status) . '</p> ' . form::combo('status', $status_combo, $status) . '</p> ' .
'</div>' . '</div>' .
'<div class="cell filters-sibling-cell">' . '<div class="cell filters-sibling-cell">' .
'<p><label for="selected" class="ib">' . __('Selected:') . '</label> ' . '<p><label for="selected" class="ib">' . __('Selected:') . '</label> ' .
form::combo('selected', $selected_combo, $selected) .'</p>' . form::combo('selected', $selected_combo, $selected) .'</p>' .
@ -549,7 +548,7 @@ if ($part == 'period') {
'<p><label for="lang" class="ib">' . __('Lang:') . '</label> ' . '<p><label for="lang" class="ib">' . __('Lang:') . '</label> ' .
form::combo('lang', $lang_combo, $lang) . '</p> ' . form::combo('lang', $lang_combo, $lang) . '</p> ' .
'</div>'. '</div>'.
'<div class="cell filters-options">' . '<div class="cell filters-options">' .
'<h4>' . __('Display options') . '</h4>' . '<h4>' . __('Display options') . '</h4>' .
'<p><label for="sortby" class="ib">' . __('Order by:') . '</label> ' . '<p><label for="sortby" class="ib">' . __('Order by:') . '</label> ' .
@ -694,7 +693,7 @@ if ($part == 'period') {
if ($order !== '' && in_array($order, $order_combo)) { if ($order !== '' && in_array($order, $order_combo)) {
$params['order'] = $sortby . ' ' . $order; $params['order'] = $sortby . ' ' . $order;
} }
if ($sortby != 'periodical_curdt' || $order != 'desc') { if ($sortby != 'periodical_curdt' || $order != 'desc') {
$show_filters = true; $show_filters = true;
} }

View File

@ -1 +1,27 @@
/* -- BEGIN LICENSE BLOCK ---------------------------------- * * This file is part of periodical, a plugin for Dotclear 2. * * Copyright (c) 2009-2013 Jean-Christian Denis and contributors * contact@jcdenis.fr http://jcd.lv * * Licensed under the GPL version 2.0 license. * A copy of this license is available in LICENSE file or at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * -- END LICENSE BLOCK ------------------------------------*/ $(function(){ var periodicalstart=document.getElementById('period_curdt'); if(periodicalstart!=undefined){ var periodicalstart_dtPick=new datePicker(periodicalstart); periodicalstart_dtPick.img_top='1.5em'; periodicalstart_dtPick.draw(); } var periodicalend=document.getElementById('period_enddt'); if(periodicalend!=undefined){ var periodicalend_dtPick=new datePicker(periodicalend); periodicalend_dtPick.img_top='1.5em'; periodicalend_dtPick.draw(); } }); /* -- BEGIN LICENSE BLOCK ----------------------------------
*
* This file is part of periodical, a plugin for Dotclear 2.
*
* Copyright (c) 2009-2013 Jean-Christian Denis and contributors
* contact@jcdenis.fr http://jcd.lv
*
* Licensed under the GPL version 2.0 license.
* A copy of this license is available in LICENSE file or at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* -- END LICENSE BLOCK ------------------------------------*/
$(function(){
var periodicalstart=document.getElementById('period_curdt');
if(periodicalstart!=undefined){
var periodicalstart_dtPick=new datePicker(periodicalstart);
periodicalstart_dtPick.img_top='1.5em';
periodicalstart_dtPick.draw();
}
var periodicalend=document.getElementById('period_enddt');
if(periodicalend!=undefined){
var periodicalend_dtPick=new datePicker(periodicalend);
periodicalend_dtPick.img_top='1.5em';
periodicalend_dtPick.draw();
}
});

View File

@ -16,7 +16,7 @@ $(function(){
$filtersform = $('#filters-form'); $filtersform = $('#filters-form');
$filtersform.before('<p><a id="filter-control" class="form-control" href="plugin.php?p=periodical&amp;part=periods" style="display:inline">'+dotclear.msg.filter_posts_list+'</a></p>') $filtersform.before('<p><a id="filter-control" class="form-control" href="plugin.php?p=periodical&amp;part=periods" style="display:inline">'+dotclear.msg.filter_posts_list+'</a></p>')
if( dotclear.msg.show_filters == 'false' ) { if( dotclear.msg.show_filters == 'false' ) {
$filtersform.hide(); $filtersform.hide();
} else { } else {
@ -24,7 +24,7 @@ $(function(){
.addClass('open') .addClass('open')
.text(dotclear.msg.cancel_the_filter); .text(dotclear.msg.cancel_the_filter);
} }
$('#filter-control').click(function() { $('#filter-control').click(function() {
if( $(this).hasClass('open') ) { if( $(this).hasClass('open') ) {
if( dotclear.msg.show_filters == 'true' ) { if( dotclear.msg.show_filters == 'true' ) {

View File

@ -16,7 +16,7 @@ $(function(){
$filtersform = $('#filters-form'); $filtersform = $('#filters-form');
$filtersform.before('<p><a id="filter-control" class="form-control" href="plugin.php?p=periodical&amp;part=period&amp;period_id='+$('#filters-form input[name=period_id]').val()+'#posts" style="display:inline">'+dotclear.msg.filter_posts_list+'</a></p>') $filtersform.before('<p><a id="filter-control" class="form-control" href="plugin.php?p=periodical&amp;part=period&amp;period_id='+$('#filters-form input[name=period_id]').val()+'#posts" style="display:inline">'+dotclear.msg.filter_posts_list+'</a></p>')
if( dotclear.msg.show_filters == 'false' ) { if( dotclear.msg.show_filters == 'false' ) {
$filtersform.hide(); $filtersform.hide();
} else { } else {
@ -24,7 +24,7 @@ $(function(){
.addClass('open') .addClass('open')
.text(dotclear.msg.cancel_the_filter); .text(dotclear.msg.cancel_the_filter);
} }
$('#filter-control').click(function() { $('#filter-control').click(function() {
if( $(this).hasClass('open') ) { if( $(this).hasClass('open') ) {
if( dotclear.msg.show_filters == 'true' ) { if( dotclear.msg.show_filters == 'true' ) {

View File

@ -180,5 +180,4 @@ $GLOBALS['__l10n']['Selected periods action:'] = 'Action sur les périodes selec
$GLOBALS['__l10n']['Configuration has been successfully updated.'] = 'La configuration a été mise à jour avec succés.'; $GLOBALS['__l10n']['Configuration has been successfully updated.'] = 'La configuration a été mise à jour avec succés.';
$GLOBALS['__l10n']['Published periodically entries'] = 'Publier périodiquement des billets'; $GLOBALS['__l10n']['Published periodically entries'] = 'Publier périodiquement des billets';