update license and fix PSR2 codding style

This commit is contained in:
Jean-Christian Paul Denis 2021-08-20 21:36:46 +02:00
parent 16ffcf67d3
commit e7a3cb0fa1
7 changed files with 681 additions and 709 deletions

View File

@ -1,53 +1,45 @@
postExpired xxxx.xx.xx
===========================================================
* Not fix: Wrong timezone on admin vs public expired date
postExpired 2021.08.19
* update license and fix PSR2 coding style
postExpired 2013.11.13
===========================================================
* Fixed wrong field name for category
postExpired 2013.11.03
===========================================================
* Switch to Dotclear 2.6
* Use new posts actions
* Save all options in one meta
* Limit plugin to contentadmin
postExpired 2013.06.30
===========================================================
* Fixed post_type and posts_actions
postExpired 0.5 - 2010-08-17
===========================================================
* Added compatibility with plugins 'pages' and 'muppet'
postExpired 0.4 - 2010-08-03
===========================================================
* Added actions (comments, trackbacks) (closes #525)
* Speed up public part (less sql resquests)
* Fixed typo
postExpired 0.3.1 - 2010-06-21
===========================================================
* Fixed user rights
* Fixed (again) PHP 5.3 compatibility
* Fixed typo
postExpired 0.3 - 2010-06-08
===========================================================
* Switched to DC 2.2 (settings,meta)
postExpired 0.2.1 - 2010-05-28
===========================================================
* Fixed DC 2.1.7 settings bugs
postExpired 0.2 - 2010-04-14
===========================================================
* Added actions choice (status,category,selected)
* Added template block and value
* Added behaviors to open choices
* Enhanced db resquest on public side
postExpired 0.1 - 2010-04-10
===========================================================
* First lab release

View File

@ -30,3 +30,9 @@ Notes:
* Only one expired date per post is supported
* Expired dates are checked from public home page and feed page
## MORE
* License : GNU GPL v2
* Source & contribution : [GitHub Page](https://github.com/JcDenis/postExpired)
* Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/postExpired)

View File

@ -3,8 +3,7 @@
#
# This file is part of postExpired, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
@ -13,70 +12,67 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
# Check plugin version
if ($core->getVersion('postExpired') != $core->plugins->moduleInfo('postExpired', 'version')) {
return null;
}
# Check user right
if (!$core->auth->check('contentadmin', $core->blog->id)) {
return null;
}
# Admin behaviors
$core->addBehavior(
'adminPostsActionsPage',
array('adminBehaviorPostExpired', 'adminPostsActionsPage')
['adminBehaviorPostExpired', 'adminPostsActionsPage']
);
$core->addBehavior(
'adminPagesActionsPage',
array('adminBehaviorPostExpired', 'adminPostsActionsPage')
['adminBehaviorPostExpired', 'adminPostsActionsPage']
);
$core->addBehavior(
'adminPostHeaders',
array('adminBehaviorPostExpired', 'adminPostHeaders')
['adminBehaviorPostExpired', 'adminPostHeaders']
);
$core->addBehavior(
'adminPageHeaders',
array('adminBehaviorPostExpired', 'adminPostHeaders')
['adminBehaviorPostExpired', 'adminPostHeaders']
);
$core->addBehavior(
'adminPostFormItems',
array('adminBehaviorPostExpired', 'adminPostFormItems')
['adminBehaviorPostExpired', 'adminPostFormItems']
);
$core->addBehavior(
'adminPageFormItems',
array('adminBehaviorPostExpired', 'adminPostFormItems')
['adminBehaviorPostExpired', 'adminPostFormItems']
);
$core->addBehavior(
'adminBeforePostDelete',
array('adminBehaviorPostExpired', 'adminBeforePostDelete')
['adminBehaviorPostExpired', 'adminBeforePostDelete']
);
$core->addBehavior(
'adminBeforePageDelete',
array('adminBehaviorPostExpired', 'adminBeforePostDelete')
['adminBehaviorPostExpired', 'adminBeforePostDelete']
);
$core->addBehavior(
'adminAfterPostUpdate',
array('adminBehaviorPostExpired', 'adminAfterPostSave')
['adminBehaviorPostExpired', 'adminAfterPostSave']
);
$core->addBehavior(
'adminAfterPageUpdate',
array('adminBehaviorPostExpired', 'adminAfterPostSave')
['adminBehaviorPostExpired', 'adminAfterPostSave']
);
$core->addBehavior(
'adminAfterPostCreate',
array('adminBehaviorPostExpired', 'adminAfterPostSave')
['adminBehaviorPostExpired', 'adminAfterPostSave']
);
$core->addBehavior(
'adminAfterPageCreate',
array('adminBehaviorPostExpired', 'adminAfterPostSave')
['adminBehaviorPostExpired', 'adminAfterPostSave']
);
/**
@ -133,7 +129,6 @@ class adminBehaviorPostExpired
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, $post)
{
if ($post === null) {
return null;
}
@ -174,8 +169,7 @@ class adminBehaviorPostExpired
|| !empty($_POST['post_expired_category'])
|| !empty($_POST['post_expired_selected'])
|| !empty($_POST['post_expired_comment'])
|| !empty($_POST['post_expired_trackback']))
) {
|| !empty($_POST['post_expired_trackback']))) {
self::setPostExpired($core, $post_id, $_POST);
}
}
@ -201,8 +195,7 @@ class adminBehaviorPostExpired
|| !empty($post['post_expired_category'])
|| !empty($post['post_expired_selected'])
|| !empty($post['post_expired_comment'])
|| !empty($post['post_expired_trackback']))
) {
|| !empty($post['post_expired_trackback']))) {
foreach($posts_ids as $post_id) {
self::delPostExpired($core, $post_id);
self::setPostExpired($core, $post_id, $post);
@ -210,10 +203,9 @@ class adminBehaviorPostExpired
dcPage::addSuccessNotice(__('Expired date added.'));
$pa->redirect(true);
}
# Display form
else {
} else {
# Get records to know post type
$posts = $pa->getRS();
@ -447,9 +439,7 @@ class adminBehaviorPostExpired
'!'.$categories->cat_id
);
}
}
catch (Exception $e) {
} catch (Exception $e) {
return array();
}

View File

@ -3,8 +3,7 @@
#
# This file is part of postExpired, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
@ -12,23 +11,20 @@
#
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')){return;}
if (!defined('DC_RC_PATH')) {
return null;
}
$this->registerModule(
/* Name */
"Expired entries",
/* Description*/
"Change entries options at a given date",
/* Author */
"Jean-Christian Denis",
/* Version */
'2013.11.13',
/* Properies */
array(
'Expired entries',
'Change entries options at a given date',
'Jean-Christian Denis and Contributors',
'2021.08.19',
[
'permissions' => 'usage,contentadmin',
'type' => 'plugin',
'dc_min' => '2.6',
'support' => 'http://jcd.lv/q=postExpired',
'details' => 'http://plugins.dotaddict.org/dc2/details/postExpired'
)
'dc_min' => '2.18',
'support' => 'https://github.com/JcDenis/postExpired',
'details' => 'https://plugins.dotaddict.org/dc2/details/postExpired'
]
);

View File

@ -3,8 +3,7 @@
#
# This file is part of postExpired, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
@ -13,26 +12,21 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
# -- Module specs --
$dc_min = '2.6';
$dc_min = '2.18';
$mod_id = 'postExpired';
# -- Nothing to change below --
try {
# Check module version
if (version_compare(
$core->getVersion($mod_id),
$core->plugins->moduleInfo($mod_id, 'version'),
'>='
)) {
return null;
}
@ -51,11 +45,8 @@ try {
);
return true;
}
catch (Exception $e) {
} catch (Exception $e) {
$core->error->add($e->getMessage());
return false;
}
?>

View File

@ -3,8 +3,7 @@
#
# This file is part of postExpired, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
@ -13,7 +12,6 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {
return null;
}

View File

@ -3,8 +3,7 @@
#
# This file is part of postExpired, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
@ -13,12 +12,10 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {
return null;
}
if ($core->getVersion('postExpired') != $core->plugins->moduleInfo('postExpired', 'version')) {
return null;
}
@ -29,24 +26,24 @@ __('This entry has no expiration date');
if (in_array($core->url->type, array('default', 'feed'))) {
$core->addBehavior(
'publicBeforeDocument',
array('publicBehaviorPostExpired', 'publicBeforeDocument')
['publicBehaviorPostExpired', 'publicBeforeDocument']
);
}
$core->addBehavior(
'coreBlogGetPosts',
array('publicBehaviorPostExpired', 'coreBlogGetPosts')
['publicBehaviorPostExpired', 'coreBlogGetPosts']
);
$core->tpl->addBlock(
'EntryExpiredIf',
array('tplPostExpired', 'EntryExpiredIf')
['tplPostExpired', 'EntryExpiredIf']
);
$core->tpl->addValue(
'EntryExpiredDate',
array('tplPostExpired', 'EntryExpiredDate')
['tplPostExpired', 'EntryExpiredDate']
);
$core->tpl->addValue(
'EntryExpiredTime',
array('tplPostExpired', 'EntryExpiredTime')
['tplPostExpired', 'EntryExpiredTime']
);
/**
@ -77,7 +74,6 @@ class publicBehaviorPostExpired
# No expired date
if ($posts->isEmpty()) {
return null;
}
@ -97,8 +93,7 @@ class publicBehaviorPostExpired
# Check if post is outdated
$now_tz = $now + dt::getTimeOffset($posts->post_tz, $now);
$meta_tz = strtotime($post_expired['date']);
if ($now_tz > $meta_tz)
{
if ($now_tz > $meta_tz) {
# Delete meta for expired date
$core->auth->sudo(
array($core->meta, 'delPostMeta'),
@ -111,8 +106,7 @@ class publicBehaviorPostExpired
$post_cur->post_upddt = date('Y-m-d H:i:s', $now_tz);
# Loop through actions
foreach($post_expired as $k => $v)
{
foreach($post_expired as $k => $v) {
if (empty($v)) {
continue;
}
@ -195,7 +189,6 @@ class rsExtPostExpiredPublic extends rsExtPost
));
if ($rs_date->isEmpty()) {
return null;
}
@ -229,8 +222,7 @@ class tplPostExpired
if (isset($attr['has_date'])) {
$sign = (boolean) $attr['has_date'] ? '!' : '=';
$if[] = '(null ' . $sign . '== $_ctx->posts->postExpiredDate())';
}
else {
} else {
$if[] = '(null !== $_ctx->posts->postExpiredDate())';
}
@ -251,14 +243,15 @@ class tplPostExpired
addslashes($attr['format']) : '';
$f = $GLOBALS['core']->tpl->getFilters($attr);
if (!empty($attr['rfc822']))
if (!empty($attr['rfc822'])) {
$res = sprintf($f, "dt::rfc822(strtotime(\$_ctx->posts->postExpiredDate()),\$_ctx->posts->post_tz)");
elseif (!empty($attr['iso8601']))
} elseif (!empty($attr['iso8601'])) {
$res = sprintf($f, "dt::iso8601(strtotime(\$_ctx->posts->postExpiredDate(),\$_ctx->posts->post_tz)");
elseif ($format)
} elseif ($format) {
$res = sprintf($f, "dt::dt2str('" . $format . "',\$_ctx->posts->postExpiredDate())");
else
} else {
$res = sprintf($f, "dt::dt2str(\$core->blog->settings->system->date_format,\$_ctx->posts->postExpiredDate())");
}
return '<?php if (null !== $_ctx->posts->postExpiredDate()) { echo ' . $res . '; } ?>';
}
@ -270,7 +263,13 @@ class tplPostExpired
*/
public static function EntryExpiredTime($attr)
{
return '<?php if (null !== $_ctx->posts->postExpiredDate()) { echo '.sprintf($GLOBALS['core']->tpl->getFilters($attr),"dt::dt2str(".(!empty($attr['format']) ? "'".addslashes($attr['format'])."'" : "\$core->blog->settings->system->time_format").",\$_ctx->posts->postExpiredDate())").'; } ?>';
return
'<?php if (null !== $_ctx->posts->postExpiredDate()) { echo ' . sprintf(
$GLOBALS['core']->tpl->getFilters($attr), "dt::dt2str(" .
(!empty($attr['format']) ?
"'" . addslashes($attr['format']) . "'" : "\$core->blog->settings->system->time_format"
) . ",\$_ctx->posts->postExpiredDate())"
) . '; } ?>';
}
/**