update license and fix PSR2 codding style
This commit is contained in:
parent
16ffcf67d3
commit
e7a3cb0fa1
7 changed files with 681 additions and 709 deletions
|
@ -1,53 +1,45 @@
|
||||||
postExpired xxxx.xx.xx
|
postExpired xxxx.xx.xx
|
||||||
===========================================================
|
|
||||||
* Not fix: Wrong timezone on admin vs public expired date
|
* 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
|
postExpired 2013.11.13
|
||||||
===========================================================
|
|
||||||
* Fixed wrong field name for category
|
* Fixed wrong field name for category
|
||||||
|
|
||||||
postExpired 2013.11.03
|
postExpired 2013.11.03
|
||||||
===========================================================
|
|
||||||
* Switch to Dotclear 2.6
|
* Switch to Dotclear 2.6
|
||||||
* Use new posts actions
|
* Use new posts actions
|
||||||
* Save all options in one meta
|
* Save all options in one meta
|
||||||
* Limit plugin to contentadmin
|
* Limit plugin to contentadmin
|
||||||
|
|
||||||
postExpired 2013.06.30
|
postExpired 2013.06.30
|
||||||
===========================================================
|
|
||||||
* Fixed post_type and posts_actions
|
* Fixed post_type and posts_actions
|
||||||
|
|
||||||
postExpired 0.5 - 2010-08-17
|
postExpired 0.5 - 2010-08-17
|
||||||
===========================================================
|
|
||||||
* Added compatibility with plugins 'pages' and 'muppet'
|
* Added compatibility with plugins 'pages' and 'muppet'
|
||||||
|
|
||||||
postExpired 0.4 - 2010-08-03
|
postExpired 0.4 - 2010-08-03
|
||||||
===========================================================
|
|
||||||
* Added actions (comments, trackbacks) (closes #525)
|
* Added actions (comments, trackbacks) (closes #525)
|
||||||
* Speed up public part (less sql resquests)
|
* Speed up public part (less sql resquests)
|
||||||
* Fixed typo
|
* Fixed typo
|
||||||
|
|
||||||
postExpired 0.3.1 - 2010-06-21
|
postExpired 0.3.1 - 2010-06-21
|
||||||
===========================================================
|
|
||||||
* Fixed user rights
|
* Fixed user rights
|
||||||
* Fixed (again) PHP 5.3 compatibility
|
* Fixed (again) PHP 5.3 compatibility
|
||||||
* Fixed typo
|
* Fixed typo
|
||||||
|
|
||||||
postExpired 0.3 - 2010-06-08
|
postExpired 0.3 - 2010-06-08
|
||||||
===========================================================
|
|
||||||
* Switched to DC 2.2 (settings,meta)
|
* Switched to DC 2.2 (settings,meta)
|
||||||
|
|
||||||
postExpired 0.2.1 - 2010-05-28
|
postExpired 0.2.1 - 2010-05-28
|
||||||
===========================================================
|
|
||||||
* Fixed DC 2.1.7 settings bugs
|
* Fixed DC 2.1.7 settings bugs
|
||||||
|
|
||||||
postExpired 0.2 - 2010-04-14
|
postExpired 0.2 - 2010-04-14
|
||||||
===========================================================
|
|
||||||
* Added actions choice (status,category,selected)
|
* Added actions choice (status,category,selected)
|
||||||
* Added template block and value
|
* Added template block and value
|
||||||
* Added behaviors to open choices
|
* Added behaviors to open choices
|
||||||
* Enhanced db resquest on public side
|
* Enhanced db resquest on public side
|
||||||
|
|
||||||
postExpired 0.1 - 2010-04-10
|
postExpired 0.1 - 2010-04-10
|
||||||
===========================================================
|
|
||||||
* First lab release
|
* First lab release
|
|
@ -30,3 +30,9 @@ Notes:
|
||||||
|
|
||||||
* Only one expired date per post is supported
|
* Only one expired date per post is supported
|
||||||
* Expired dates are checked from public home page and feed page
|
* 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)
|
112
_admin.php
112
_admin.php
|
@ -3,8 +3,7 @@
|
||||||
#
|
#
|
||||||
# This file is part of postExpired, a plugin for Dotclear 2.
|
# This file is part of postExpired, a plugin for Dotclear 2.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||||
# contact@jcdenis.fr http://jcd.lv
|
|
||||||
#
|
#
|
||||||
# Licensed under the GPL version 2.0 license.
|
# Licensed under the GPL version 2.0 license.
|
||||||
# A copy of this license is available in LICENSE file or at
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
@ -13,70 +12,67 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check plugin version
|
# Check plugin version
|
||||||
if ($core->getVersion('postExpired') != $core->plugins->moduleInfo('postExpired', 'version')) {
|
if ($core->getVersion('postExpired') != $core->plugins->moduleInfo('postExpired', 'version')) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check user right
|
# Check user right
|
||||||
if (!$core->auth->check('contentadmin', $core->blog->id)) {
|
if (!$core->auth->check('contentadmin', $core->blog->id)) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Admin behaviors
|
# Admin behaviors
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'adminPostsActionsPage',
|
'adminPostsActionsPage',
|
||||||
array('adminBehaviorPostExpired', 'adminPostsActionsPage')
|
['adminBehaviorPostExpired', 'adminPostsActionsPage']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'adminPagesActionsPage',
|
'adminPagesActionsPage',
|
||||||
array('adminBehaviorPostExpired', 'adminPostsActionsPage')
|
['adminBehaviorPostExpired', 'adminPostsActionsPage']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'adminPostHeaders',
|
'adminPostHeaders',
|
||||||
array('adminBehaviorPostExpired', 'adminPostHeaders')
|
['adminBehaviorPostExpired', 'adminPostHeaders']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'adminPageHeaders',
|
'adminPageHeaders',
|
||||||
array('adminBehaviorPostExpired', 'adminPostHeaders')
|
['adminBehaviorPostExpired', 'adminPostHeaders']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'adminPostFormItems',
|
'adminPostFormItems',
|
||||||
array('adminBehaviorPostExpired', 'adminPostFormItems')
|
['adminBehaviorPostExpired', 'adminPostFormItems']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'adminPageFormItems',
|
'adminPageFormItems',
|
||||||
array('adminBehaviorPostExpired', 'adminPostFormItems')
|
['adminBehaviorPostExpired', 'adminPostFormItems']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'adminBeforePostDelete',
|
'adminBeforePostDelete',
|
||||||
array('adminBehaviorPostExpired', 'adminBeforePostDelete')
|
['adminBehaviorPostExpired', 'adminBeforePostDelete']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'adminBeforePageDelete',
|
'adminBeforePageDelete',
|
||||||
array('adminBehaviorPostExpired', 'adminBeforePostDelete')
|
['adminBehaviorPostExpired', 'adminBeforePostDelete']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'adminAfterPostUpdate',
|
'adminAfterPostUpdate',
|
||||||
array('adminBehaviorPostExpired', 'adminAfterPostSave')
|
['adminBehaviorPostExpired', 'adminAfterPostSave']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'adminAfterPageUpdate',
|
'adminAfterPageUpdate',
|
||||||
array('adminBehaviorPostExpired', 'adminAfterPostSave')
|
['adminBehaviorPostExpired', 'adminAfterPostSave']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'adminAfterPostCreate',
|
'adminAfterPostCreate',
|
||||||
array('adminBehaviorPostExpired', 'adminAfterPostSave')
|
['adminBehaviorPostExpired', 'adminAfterPostSave']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'adminAfterPageCreate',
|
'adminAfterPageCreate',
|
||||||
array('adminBehaviorPostExpired', 'adminAfterPostSave')
|
['adminBehaviorPostExpired', 'adminAfterPostSave']
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,7 +129,6 @@ class adminBehaviorPostExpired
|
||||||
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, $post)
|
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, $post)
|
||||||
{
|
{
|
||||||
if ($post === null) {
|
if ($post === null) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,8 +169,7 @@ class adminBehaviorPostExpired
|
||||||
|| !empty($_POST['post_expired_category'])
|
|| !empty($_POST['post_expired_category'])
|
||||||
|| !empty($_POST['post_expired_selected'])
|
|| !empty($_POST['post_expired_selected'])
|
||||||
|| !empty($_POST['post_expired_comment'])
|
|| !empty($_POST['post_expired_comment'])
|
||||||
|| !empty($_POST['post_expired_trackback']))
|
|| !empty($_POST['post_expired_trackback']))) {
|
||||||
) {
|
|
||||||
self::setPostExpired($core, $post_id, $_POST);
|
self::setPostExpired($core, $post_id, $_POST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,8 +195,7 @@ class adminBehaviorPostExpired
|
||||||
|| !empty($post['post_expired_category'])
|
|| !empty($post['post_expired_category'])
|
||||||
|| !empty($post['post_expired_selected'])
|
|| !empty($post['post_expired_selected'])
|
||||||
|| !empty($post['post_expired_comment'])
|
|| !empty($post['post_expired_comment'])
|
||||||
|| !empty($post['post_expired_trackback']))
|
|| !empty($post['post_expired_trackback']))) {
|
||||||
) {
|
|
||||||
foreach($posts_ids as $post_id) {
|
foreach($posts_ids as $post_id) {
|
||||||
self::delPostExpired($core, $post_id);
|
self::delPostExpired($core, $post_id);
|
||||||
self::setPostExpired($core, $post_id, $post);
|
self::setPostExpired($core, $post_id, $post);
|
||||||
|
@ -210,10 +203,9 @@ class adminBehaviorPostExpired
|
||||||
|
|
||||||
dcPage::addSuccessNotice(__('Expired date added.'));
|
dcPage::addSuccessNotice(__('Expired date added.'));
|
||||||
$pa->redirect(true);
|
$pa->redirect(true);
|
||||||
}
|
|
||||||
|
|
||||||
# Display form
|
# Display form
|
||||||
else {
|
} else {
|
||||||
# Get records to know post type
|
# Get records to know post type
|
||||||
$posts = $pa->getRS();
|
$posts = $pa->getRS();
|
||||||
|
|
||||||
|
@ -223,20 +215,20 @@ class adminBehaviorPostExpired
|
||||||
$pa->getCallerTitle() => $pa->getRedirection(true),
|
$pa->getCallerTitle() => $pa->getRedirection(true),
|
||||||
__('Add expired date to this selection') => ''
|
__('Add expired date to this selection') => ''
|
||||||
)),
|
)),
|
||||||
dcPage::jsDatePicker().
|
dcPage::jsDatePicker() .
|
||||||
self::adminPostHeaders()
|
self::adminPostHeaders()
|
||||||
);
|
);
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<form action="'.$pa->getURI().'" method="post">'.
|
'<form action="' . $pa->getURI() . '" method="post">' .
|
||||||
$pa->getCheckboxes().
|
$pa->getCheckboxes() .
|
||||||
|
|
||||||
implode('', self::fieldsPostExpired($core, $posts->post_type)).
|
implode('', self::fieldsPostExpired($core, $posts->post_type)) .
|
||||||
|
|
||||||
$core->formNonce().
|
$core->formNonce() .
|
||||||
$pa->getHiddenFields().
|
$pa->getHiddenFields() .
|
||||||
form::hidden(array('action'), 'post_expired_add').
|
form::hidden(array('action'), 'post_expired_add') .
|
||||||
'<input type="submit" value="'.__('Save').'" /></p>'.
|
'<input type="submit" value="' . __('Save') . '" /></p>' .
|
||||||
'</form>';
|
'</form>';
|
||||||
|
|
||||||
$pa->endPage();
|
$pa->endPage();
|
||||||
|
@ -288,12 +280,12 @@ class adminBehaviorPostExpired
|
||||||
protected static function setPostExpired(dcCore $core, $post_id, $post)
|
protected static function setPostExpired(dcCore $core, $post_id, $post)
|
||||||
{
|
{
|
||||||
$post_expired = array(
|
$post_expired = array(
|
||||||
'status' => '',
|
'status'=> '',
|
||||||
'category' => '',
|
'category'=> '',
|
||||||
'selected' => '',
|
'selected'=> '',
|
||||||
'comment' => '',
|
'comment'=> '',
|
||||||
'trackback' => '',
|
'trackback' => '',
|
||||||
'date' => date(
|
'date'=> date(
|
||||||
'Y-m-d H:i:00',
|
'Y-m-d H:i:00',
|
||||||
strtotime($post['post_expired_date'])
|
strtotime($post['post_expired_date'])
|
||||||
)
|
)
|
||||||
|
@ -334,7 +326,7 @@ class adminBehaviorPostExpired
|
||||||
* @param string $post_type Posts type
|
* @param string $post_type Posts type
|
||||||
* @return array Array of HTML form fields
|
* @return array Array of HTML form fields
|
||||||
*/
|
*/
|
||||||
protected static function fieldsPostExpired(dcCore $core, $post_type, $post_id=null)
|
protected static function fieldsPostExpired(dcCore $core, $post_type, $post_id = null)
|
||||||
{
|
{
|
||||||
$fields = $post_expired = array();
|
$fields = $post_expired = array();
|
||||||
|
|
||||||
|
@ -353,32 +345,32 @@ class adminBehaviorPostExpired
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields['post_expired_date'] =
|
$fields['post_expired_date'] =
|
||||||
'<p><label for="post_expired_date">'.
|
'<p><label for="post_expired_date">' .
|
||||||
__('Date:').'</label>'.
|
__('Date:') . '</label>' .
|
||||||
form::field(
|
form::field(
|
||||||
'post_expired_date',
|
'post_expired_date',
|
||||||
16,
|
16,
|
||||||
16,
|
16,
|
||||||
empty($post_expired['date']) ?
|
empty($post_expired['date']) ?
|
||||||
'' : $post_expired['date']
|
'' : $post_expired['date']
|
||||||
).'</p>';
|
) . '</p>';
|
||||||
|
|
||||||
$fields['post_expired_status'] =
|
$fields['post_expired_status'] =
|
||||||
'<h5>'.__('On this date, change:').'</h5>'.
|
'<h5>' . __('On this date, change:') . '</h5>' .
|
||||||
'<p><label for="post_expired_status">'.
|
'<p><label for="post_expired_status">' .
|
||||||
__('Status:').'</label>'.
|
__('Status:') . '</label>' .
|
||||||
form::combo(
|
form::combo(
|
||||||
'post_expired_status',
|
'post_expired_status',
|
||||||
self::statusCombo(),
|
self::statusCombo(),
|
||||||
empty($post_expired['status']) ?
|
empty($post_expired['status']) ?
|
||||||
'' : $post_expired['status']
|
'' : $post_expired['status']
|
||||||
).'</p>';
|
) . '</p>';
|
||||||
|
|
||||||
if ($post_type == 'post') {
|
if ($post_type == 'post') {
|
||||||
|
|
||||||
$fields['post_expired_category'] =
|
$fields['post_expired_category'] =
|
||||||
'<p><label for="post_expired_category">'.
|
'<p><label for="post_expired_category">' .
|
||||||
__('Category:').'</label>'.
|
__('Category:') . '</label>' .
|
||||||
form::combo(
|
form::combo(
|
||||||
'post_expired_category',
|
'post_expired_category',
|
||||||
self::categoriesCombo(
|
self::categoriesCombo(
|
||||||
|
@ -388,38 +380,38 @@ class adminBehaviorPostExpired
|
||||||
),
|
),
|
||||||
empty($post_expired['category']) ?
|
empty($post_expired['category']) ?
|
||||||
'' : $post_expired['category']
|
'' : $post_expired['category']
|
||||||
).'</p>';
|
) . '</p>';
|
||||||
|
|
||||||
$fields['post_expired_selected'] =
|
$fields['post_expired_selected'] =
|
||||||
'<p><label for="post_expired_selected">'.
|
'<p><label for="post_expired_selected">' .
|
||||||
__('Selection:').'</label>'.
|
__('Selection:') . '</label>' .
|
||||||
form::combo(
|
form::combo(
|
||||||
'post_expired_selected',
|
'post_expired_selected',
|
||||||
self::selectedCombo(),
|
self::selectedCombo(),
|
||||||
empty($post_expired['selected']) ?
|
empty($post_expired['selected']) ?
|
||||||
'' : $post_expired['selected']
|
'' : $post_expired['selected']
|
||||||
).'</p>';
|
) . '</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields['post_expired_comment'] =
|
$fields['post_expired_comment'] =
|
||||||
'<p><label for="post_expired_comment">'.
|
'<p><label for="post_expired_comment">' .
|
||||||
__('Comments status:').'</label>'.
|
__('Comments status:') . '</label>' .
|
||||||
form::combo(
|
form::combo(
|
||||||
'post_expired_comment',
|
'post_expired_comment',
|
||||||
self::commentCombo(),
|
self::commentCombo(),
|
||||||
empty($post_expired['comment']) ?
|
empty($post_expired['comment']) ?
|
||||||
'' : $post_expired['comment']
|
'' : $post_expired['comment']
|
||||||
).'</p>';
|
) . '</p>';
|
||||||
|
|
||||||
$fields['post_expired_trackback'] =
|
$fields['post_expired_trackback'] =
|
||||||
'<p><label for="post_expired_trackback">'.
|
'<p><label for="post_expired_trackback">' .
|
||||||
__('Trackbacks status:').'</label>'.
|
__('Trackbacks status:') . '</label>' .
|
||||||
form::combo(
|
form::combo(
|
||||||
'post_expired_trackback',
|
'post_expired_trackback',
|
||||||
self::trackbackCombo(),
|
self::trackbackCombo(),
|
||||||
empty($post_expired['trackback']) ?
|
empty($post_expired['trackback']) ?
|
||||||
'' : $post_expired['trackback']
|
'' : $post_expired['trackback']
|
||||||
).'</p>';
|
) . '</p>';
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
@ -443,13 +435,11 @@ class adminBehaviorPostExpired
|
||||||
);
|
);
|
||||||
while ($categories->fetch()) {
|
while ($categories->fetch()) {
|
||||||
$categories_combo[] = new formSelectOption(
|
$categories_combo[] = new formSelectOption(
|
||||||
str_repeat(' ', $categories->level-1).'• '.html::escapeHTML($categories->cat_title),
|
str_repeat(' ', $categories->level - 1) . '• '. html::escapeHTML($categories->cat_title),
|
||||||
'!'.$categories->cat_id
|
'!'.$categories->cat_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e) {
|
|
||||||
|
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
30
_define.php
30
_define.php
|
@ -3,8 +3,7 @@
|
||||||
#
|
#
|
||||||
# This file is part of postExpired, a plugin for Dotclear 2.
|
# This file is part of postExpired, a plugin for Dotclear 2.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||||
# contact@jcdenis.fr http://jcd.lv
|
|
||||||
#
|
#
|
||||||
# Licensed under the GPL version 2.0 license.
|
# Licensed under the GPL version 2.0 license.
|
||||||
# A copy of this license is available in LICENSE file or at
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
@ -12,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 */
|
'Expired entries',
|
||||||
"Expired entries",
|
'Change entries options at a given date',
|
||||||
/* Description*/
|
'Jean-Christian Denis and Contributors',
|
||||||
"Change entries options at a given date",
|
'2021.08.19',
|
||||||
/* Author */
|
[
|
||||||
"Jean-Christian Denis",
|
|
||||||
/* Version */
|
|
||||||
'2013.11.13',
|
|
||||||
/* Properies */
|
|
||||||
array(
|
|
||||||
'permissions' => 'usage,contentadmin',
|
'permissions' => 'usage,contentadmin',
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'dc_min' => '2.6',
|
'dc_min' => '2.18',
|
||||||
'support' => 'http://jcd.lv/q=postExpired',
|
'support' => 'https://github.com/JcDenis/postExpired',
|
||||||
'details' => 'http://plugins.dotaddict.org/dc2/details/postExpired'
|
'details' => 'https://plugins.dotaddict.org/dc2/details/postExpired'
|
||||||
)
|
]
|
||||||
);
|
);
|
15
_install.php
15
_install.php
|
@ -3,8 +3,7 @@
|
||||||
#
|
#
|
||||||
# This file is part of postExpired, a plugin for Dotclear 2.
|
# This file is part of postExpired, a plugin for Dotclear 2.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||||
# contact@jcdenis.fr http://jcd.lv
|
|
||||||
#
|
#
|
||||||
# Licensed under the GPL version 2.0 license.
|
# Licensed under the GPL version 2.0 license.
|
||||||
# A copy of this license is available in LICENSE file or at
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
@ -13,26 +12,21 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# -- Module specs --
|
# -- Module specs --
|
||||||
|
$dc_min = '2.18';
|
||||||
$dc_min = '2.6';
|
|
||||||
$mod_id = 'postExpired';
|
$mod_id = 'postExpired';
|
||||||
|
|
||||||
# -- Nothing to change below --
|
# -- Nothing to change below --
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
# Check module version
|
# Check module version
|
||||||
if (version_compare(
|
if (version_compare(
|
||||||
$core->getVersion($mod_id),
|
$core->getVersion($mod_id),
|
||||||
$core->plugins->moduleInfo($mod_id, 'version'),
|
$core->plugins->moduleInfo($mod_id, 'version'),
|
||||||
'>='
|
'>='
|
||||||
)) {
|
)) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,11 +45,8 @@ try {
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e) {
|
|
||||||
$core->error->add($e->getMessage());
|
$core->error->add($e->getMessage());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -3,8 +3,7 @@
|
||||||
#
|
#
|
||||||
# This file is part of postExpired, a plugin for Dotclear 2.
|
# This file is part of postExpired, a plugin for Dotclear 2.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||||
# contact@jcdenis.fr http://jcd.lv
|
|
||||||
#
|
#
|
||||||
# Licensed under the GPL version 2.0 license.
|
# Licensed under the GPL version 2.0 license.
|
||||||
# A copy of this license is available in LICENSE file or at
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
@ -13,7 +12,6 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +28,7 @@ function encodePostExpired($in)
|
||||||
{
|
{
|
||||||
$out = array();
|
$out = array();
|
||||||
foreach($in as $k => $v) {
|
foreach($in as $k => $v) {
|
||||||
$out[] = $k.'|'.$v;
|
$out[] = $k . '|' . $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode(';', $out);
|
return implode(';', $out);
|
||||||
|
|
81
_public.php
81
_public.php
|
@ -3,8 +3,7 @@
|
||||||
#
|
#
|
||||||
# This file is part of postExpired, a plugin for Dotclear 2.
|
# This file is part of postExpired, a plugin for Dotclear 2.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||||
# contact@jcdenis.fr http://jcd.lv
|
|
||||||
#
|
#
|
||||||
# Licensed under the GPL version 2.0 license.
|
# Licensed under the GPL version 2.0 license.
|
||||||
# A copy of this license is available in LICENSE file or at
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
@ -13,12 +12,10 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($core->getVersion('postExpired') != $core->plugins->moduleInfo('postExpired', 'version')) {
|
if ($core->getVersion('postExpired') != $core->plugins->moduleInfo('postExpired', 'version')) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,24 +26,24 @@ __('This entry has no expiration date');
|
||||||
if (in_array($core->url->type, array('default', 'feed'))) {
|
if (in_array($core->url->type, array('default', 'feed'))) {
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'publicBeforeDocument',
|
'publicBeforeDocument',
|
||||||
array('publicBehaviorPostExpired', 'publicBeforeDocument')
|
['publicBehaviorPostExpired', 'publicBeforeDocument']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'coreBlogGetPosts',
|
'coreBlogGetPosts',
|
||||||
array('publicBehaviorPostExpired', 'coreBlogGetPosts')
|
['publicBehaviorPostExpired', 'coreBlogGetPosts']
|
||||||
);
|
);
|
||||||
$core->tpl->addBlock(
|
$core->tpl->addBlock(
|
||||||
'EntryExpiredIf',
|
'EntryExpiredIf',
|
||||||
array('tplPostExpired', 'EntryExpiredIf')
|
['tplPostExpired', 'EntryExpiredIf']
|
||||||
);
|
);
|
||||||
$core->tpl->addValue(
|
$core->tpl->addValue(
|
||||||
'EntryExpiredDate',
|
'EntryExpiredDate',
|
||||||
array('tplPostExpired', 'EntryExpiredDate')
|
['tplPostExpired', 'EntryExpiredDate']
|
||||||
);
|
);
|
||||||
$core->tpl->addValue(
|
$core->tpl->addValue(
|
||||||
'EntryExpiredTime',
|
'EntryExpiredTime',
|
||||||
array('tplPostExpired', 'EntryExpiredTime')
|
['tplPostExpired', 'EntryExpiredTime']
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,19 +62,18 @@ class publicBehaviorPostExpired
|
||||||
{
|
{
|
||||||
# Get expired dates and post_id
|
# Get expired dates and post_id
|
||||||
$posts = $core->con->select(
|
$posts = $core->con->select(
|
||||||
'SELECT P.post_id, P.post_tz, META.meta_id '.
|
'SELECT P.post_id, P.post_tz, META.meta_id ' .
|
||||||
'FROM '.$core->prefix.'post P '.
|
'FROM ' . $core->prefix . 'post P ' .
|
||||||
'INNER JOIN '.$core->prefix.'meta META '.
|
'INNER JOIN ' . $core->prefix . 'meta META ' .
|
||||||
'ON META.post_id = P.post_id '.
|
'ON META.post_id = P.post_id ' .
|
||||||
"WHERE blog_id = '".$core->con->escape($core->blog->id)."' ".
|
"WHERE blog_id = '" . $core->con->escape($core->blog->id) . "' " .
|
||||||
// Removed for quick compatibility with some plugins
|
// Removed for quick compatibility with some plugins
|
||||||
//"AND P.post_type = 'post' ".
|
//"AND P.post_type = 'post' " .
|
||||||
"AND META.meta_type = 'post_expired' "
|
"AND META.meta_type = 'post_expired' "
|
||||||
);
|
);
|
||||||
|
|
||||||
# No expired date
|
# No expired date
|
||||||
if ($posts->isEmpty()) {
|
if ($posts->isEmpty()) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +81,7 @@ class publicBehaviorPostExpired
|
||||||
$now = dt::toUTC(time());
|
$now = dt::toUTC(time());
|
||||||
|
|
||||||
# Prepared post cursor
|
# Prepared post cursor
|
||||||
$post_cur = $core->con->openCursor($core->prefix.'post');
|
$post_cur = $core->con->openCursor($core->prefix . 'post');
|
||||||
|
|
||||||
# Loop through marked posts
|
# Loop through marked posts
|
||||||
$updated = false;
|
$updated = false;
|
||||||
|
@ -97,8 +93,7 @@ class publicBehaviorPostExpired
|
||||||
# Check if post is outdated
|
# Check if post is outdated
|
||||||
$now_tz = $now + dt::getTimeOffset($posts->post_tz, $now);
|
$now_tz = $now + dt::getTimeOffset($posts->post_tz, $now);
|
||||||
$meta_tz = strtotime($post_expired['date']);
|
$meta_tz = strtotime($post_expired['date']);
|
||||||
if ($now_tz > $meta_tz)
|
if ($now_tz > $meta_tz) {
|
||||||
{
|
|
||||||
# Delete meta for expired date
|
# Delete meta for expired date
|
||||||
$core->auth->sudo(
|
$core->auth->sudo(
|
||||||
array($core->meta, 'delPostMeta'),
|
array($core->meta, 'delPostMeta'),
|
||||||
|
@ -111,8 +106,7 @@ class publicBehaviorPostExpired
|
||||||
$post_cur->post_upddt = date('Y-m-d H:i:s', $now_tz);
|
$post_cur->post_upddt = date('Y-m-d H:i:s', $now_tz);
|
||||||
|
|
||||||
# Loop through actions
|
# Loop through actions
|
||||||
foreach($post_expired as $k => $v)
|
foreach($post_expired as $k => $v) {
|
||||||
{
|
|
||||||
if (empty($v)) {
|
if (empty($v)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -147,8 +141,8 @@ class publicBehaviorPostExpired
|
||||||
|
|
||||||
# Update post
|
# Update post
|
||||||
$post_cur->update(
|
$post_cur->update(
|
||||||
'WHERE post_id = '.$posts->post_id.' '.
|
'WHERE post_id = ' . $posts->post_id . ' ' .
|
||||||
"AND blog_id = '".$core->con->escape($core->blog->id)."' "
|
"AND blog_id = '" . $core->con->escape($core->blog->id) . "' "
|
||||||
);
|
);
|
||||||
|
|
||||||
$updated = true;
|
$updated = true;
|
||||||
|
@ -190,12 +184,11 @@ class rsExtPostExpiredPublic extends rsExtPost
|
||||||
if (!$rs->postexpired[$rs->post_id]) { //memory
|
if (!$rs->postexpired[$rs->post_id]) { //memory
|
||||||
$rs_date = $rs->core->meta->getMetadata(array(
|
$rs_date = $rs->core->meta->getMetadata(array(
|
||||||
'meta_type' => 'post_expired',
|
'meta_type' => 'post_expired',
|
||||||
'post_id' => $rs->post_id,
|
'post_id'=> $rs->post_id,
|
||||||
'limit' => 1
|
'limit'=> 1
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($rs_date->isEmpty()) {
|
if ($rs_date->isEmpty()) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,15 +221,14 @@ class tplPostExpired
|
||||||
|
|
||||||
if (isset($attr['has_date'])) {
|
if (isset($attr['has_date'])) {
|
||||||
$sign = (boolean) $attr['has_date'] ? '!' : '=';
|
$sign = (boolean) $attr['has_date'] ? '!' : '=';
|
||||||
$if[] = '(null '.$sign.'== $_ctx->posts->postExpiredDate())';
|
$if[] = '(null ' . $sign . '== $_ctx->posts->postExpiredDate())';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$if[] = '(null !== $_ctx->posts->postExpiredDate())';
|
$if[] = '(null !== $_ctx->posts->postExpiredDate())';
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
"<?php if(".implode(' '.$operator.' ', $if).") : ?>\n".
|
"<?php if(" . implode(' ' . $operator . ' ', $if) . ") : ?>\n" .
|
||||||
$content.
|
$content .
|
||||||
"<?php endif; ?>\n";
|
"<?php endif; ?>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,16 +243,17 @@ class tplPostExpired
|
||||||
addslashes($attr['format']) : '';
|
addslashes($attr['format']) : '';
|
||||||
$f = $GLOBALS['core']->tpl->getFilters($attr);
|
$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)");
|
$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)");
|
$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())");
|
$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())");
|
$res = sprintf($f, "dt::dt2str(\$core->blog->settings->system->date_format,\$_ctx->posts->postExpiredDate())");
|
||||||
|
}
|
||||||
|
|
||||||
return '<?php if (null !== $_ctx->posts->postExpiredDate()) { echo '.$res.'; } ?>';
|
return '<?php if (null !== $_ctx->posts->postExpiredDate()) { echo ' . $res . '; } ?>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -270,7 +263,13 @@ class tplPostExpired
|
||||||
*/
|
*/
|
||||||
public static function EntryExpiredTime($attr)
|
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())"
|
||||||
|
) . '; } ?>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue