prepare to DC 2.24
This commit is contained in:
parent
81f2a3f967
commit
947b0cf339
100
_admin.php
100
_admin.php
@ -16,61 +16,64 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Check plugin version
|
# Check plugin version
|
||||||
if ($core->getVersion('postExpired') != $core->plugins->moduleInfo('postExpired', 'version')) {
|
if (dcCore::app()->getVersion('postExpired') != dcCore::app()->plugins->moduleInfo('postExpired', 'version')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check user right
|
# Check user right
|
||||||
if (!$core->auth->check('contentadmin', $core->blog->id)) {
|
if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||||
|
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||||
|
]), dcCore::app()->blog->id)
|
||||||
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Admin behaviors
|
# Admin behaviors
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'adminPostsActionsPage',
|
'adminPostsActions',
|
||||||
['adminBehaviorPostExpired', 'adminPostsActionsPage']
|
['adminBehaviorPostExpired', 'adminPostsActions']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'adminPagesActionsPage',
|
'adminPagesActions',
|
||||||
['adminBehaviorPostExpired', 'adminPostsActionsPage']
|
['adminBehaviorPostExpired', 'adminPostsActions']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'adminPostHeaders',
|
'adminPostHeaders',
|
||||||
['adminBehaviorPostExpired', 'adminPostHeaders']
|
['adminBehaviorPostExpired', 'adminPostHeaders']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'adminPageHeaders',
|
'adminPageHeaders',
|
||||||
['adminBehaviorPostExpired', 'adminPostHeaders']
|
['adminBehaviorPostExpired', 'adminPostHeaders']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'adminPostFormItems',
|
'adminPostFormItems',
|
||||||
['adminBehaviorPostExpired', 'adminPostFormItems']
|
['adminBehaviorPostExpired', 'adminPostFormItems']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'adminPageFormItems',
|
'adminPageFormItems',
|
||||||
['adminBehaviorPostExpired', 'adminPostFormItems']
|
['adminBehaviorPostExpired', 'adminPostFormItems']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'adminBeforePostDelete',
|
'adminBeforePostDelete',
|
||||||
['adminBehaviorPostExpired', 'adminBeforePostDelete']
|
['adminBehaviorPostExpired', 'adminBeforePostDelete']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'adminBeforePageDelete',
|
'adminBeforePageDelete',
|
||||||
['adminBehaviorPostExpired', 'adminBeforePostDelete']
|
['adminBehaviorPostExpired', 'adminBeforePostDelete']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'adminAfterPostUpdate',
|
'adminAfterPostUpdate',
|
||||||
['adminBehaviorPostExpired', 'adminAfterPostSave']
|
['adminBehaviorPostExpired', 'adminAfterPostSave']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'adminAfterPageUpdate',
|
'adminAfterPageUpdate',
|
||||||
['adminBehaviorPostExpired', 'adminAfterPostSave']
|
['adminBehaviorPostExpired', 'adminAfterPostSave']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'adminAfterPostCreate',
|
'adminAfterPostCreate',
|
||||||
['adminBehaviorPostExpired', 'adminAfterPostSave']
|
['adminBehaviorPostExpired', 'adminAfterPostSave']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'adminAfterPageCreate',
|
'adminAfterPageCreate',
|
||||||
['adminBehaviorPostExpired', 'adminAfterPostSave']
|
['adminBehaviorPostExpired', 'adminAfterPostSave']
|
||||||
);
|
);
|
||||||
@ -85,10 +88,9 @@ class adminBehaviorPostExpired
|
|||||||
/**
|
/**
|
||||||
* Add actions to posts page combo
|
* Add actions to posts page combo
|
||||||
*
|
*
|
||||||
* @param dcCore $core dcCore instance
|
|
||||||
* @param dcPostsActionsPage $ap dcPostsActionsPage instance
|
* @param dcPostsActionsPage $ap dcPostsActionsPage instance
|
||||||
*/
|
*/
|
||||||
public static function adminPostsActionsPage(dcCore $core, dcPostsActionsPage $pa)
|
public static function adminPostsActions(dcPostsActions $pa)
|
||||||
{
|
{
|
||||||
$pa->addAction(
|
$pa->addAction(
|
||||||
array(
|
array(
|
||||||
@ -135,7 +137,6 @@ class adminBehaviorPostExpired
|
|||||||
$sidebar_items['post_expired'] = array(
|
$sidebar_items['post_expired'] = array(
|
||||||
'title' => __('Expired date'),
|
'title' => __('Expired date'),
|
||||||
'items' => self::fieldsPostExpired(
|
'items' => self::fieldsPostExpired(
|
||||||
$GLOBALS['core'],
|
|
||||||
$post->post_type,
|
$post->post_type,
|
||||||
$post->post_id
|
$post->post_id
|
||||||
)
|
)
|
||||||
@ -149,7 +150,7 @@ class adminBehaviorPostExpired
|
|||||||
*/
|
*/
|
||||||
public static function adminBeforePostDelete($post_id)
|
public static function adminBeforePostDelete($post_id)
|
||||||
{
|
{
|
||||||
self::delPostExpired($GLOBALS['core'], $post_id);
|
self::delPostExpired($post_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -160,9 +161,7 @@ class adminBehaviorPostExpired
|
|||||||
*/
|
*/
|
||||||
public static function adminAfterPostSave(cursor $cur, $post_id)
|
public static function adminAfterPostSave(cursor $cur, $post_id)
|
||||||
{
|
{
|
||||||
global $core;
|
self::delPostExpired($post_id);
|
||||||
|
|
||||||
self::delPostExpired($core, $post_id);
|
|
||||||
|
|
||||||
if (!empty($_POST['post_expired_date'])
|
if (!empty($_POST['post_expired_date'])
|
||||||
&& (!empty($_POST['post_expired_status'])
|
&& (!empty($_POST['post_expired_status'])
|
||||||
@ -170,18 +169,17 @@ class adminBehaviorPostExpired
|
|||||||
|| !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($post_id, $_POST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Posts actions callback to add expired date
|
* Posts actions callback to add expired date
|
||||||
*
|
*
|
||||||
* @param dcCore $core dcCore instance
|
* @param dcPostsActions $pa dcPostsActions instance
|
||||||
* @param dcPostsActionsPage $pa dcPostsActionsPage instance
|
|
||||||
* @param ArrayObject $post _POST actions
|
* @param ArrayObject $post _POST actions
|
||||||
*/
|
*/
|
||||||
public static function callbackAdd(dcCore $core, dcPostsActionsPage $pa, ArrayObject $post)
|
public static function callbackAdd(dcPostsActions $pa, ArrayObject $post)
|
||||||
{
|
{
|
||||||
# No entry
|
# No entry
|
||||||
$posts_ids = $pa->getIDs();
|
$posts_ids = $pa->getIDs();
|
||||||
@ -197,11 +195,11 @@ class adminBehaviorPostExpired
|
|||||||
|| !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($post_id);
|
||||||
self::setPostExpired($core, $post_id, $post);
|
self::setPostExpired($post_id, $post);
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::addSuccessNotice(__('Expired date added.'));
|
dcAdminNotices::addSuccessNotice(__('Expired date added.'));
|
||||||
$pa->redirect(true);
|
$pa->redirect(true);
|
||||||
|
|
||||||
# Display form
|
# Display form
|
||||||
@ -211,7 +209,7 @@ class adminBehaviorPostExpired
|
|||||||
|
|
||||||
$pa->beginPage(
|
$pa->beginPage(
|
||||||
dcPage::breadcrumb(array(
|
dcPage::breadcrumb(array(
|
||||||
html::escapeHTML($core->blog->name) => '',
|
html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||||
$pa->getCallerTitle() => $pa->getRedirection(true),
|
$pa->getCallerTitle() => $pa->getRedirection(true),
|
||||||
__('Add expired date to this selection') => ''
|
__('Add expired date to this selection') => ''
|
||||||
)),
|
)),
|
||||||
@ -223,9 +221,9 @@ class adminBehaviorPostExpired
|
|||||||
'<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($posts->post_type)) .
|
||||||
|
|
||||||
$core->formNonce() .
|
dcCore::app()->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>' .
|
||||||
@ -238,11 +236,10 @@ class adminBehaviorPostExpired
|
|||||||
/**
|
/**
|
||||||
* Posts actions callback to add expired date
|
* Posts actions callback to add expired date
|
||||||
*
|
*
|
||||||
* @param dcCore $core dcCore instance
|
* @param dcPostsActions $pa dcPostsActions instance
|
||||||
* @param dcPostsActionsPage $pa dcPostsActionsPage instance
|
|
||||||
* @param ArrayObject $post _POST actions
|
* @param ArrayObject $post _POST actions
|
||||||
*/
|
*/
|
||||||
public static function callbackRemove(dcCore $core, dcPostsActionsPage $pa, ArrayObject $post)
|
public static function callbackRemove(dcPostsActions $pa, ArrayObject $post)
|
||||||
{
|
{
|
||||||
# No entry
|
# No entry
|
||||||
$posts_ids = $pa->getIDs();
|
$posts_ids = $pa->getIDs();
|
||||||
@ -252,32 +249,30 @@ class adminBehaviorPostExpired
|
|||||||
|
|
||||||
# Delete expired date
|
# Delete expired date
|
||||||
foreach($posts_ids as $post_id) {
|
foreach($posts_ids as $post_id) {
|
||||||
self::delPostExpired($core, $post_id);
|
self::delPostExpired($post_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::addSuccessNotice(__('Expired date deleted.'));
|
dcAdminNotices::addSuccessNotice(__('Expired date deleted.'));
|
||||||
$pa->redirect(true);
|
$pa->redirect(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete expired date
|
* Delete expired date
|
||||||
*
|
*
|
||||||
* @param dcCore $core dcCore instance
|
|
||||||
* @param integer $post_id Post id
|
* @param integer $post_id Post id
|
||||||
*/
|
*/
|
||||||
protected static function delPostExpired(dcCore $core, $post_id)
|
protected static function delPostExpired($post_id)
|
||||||
{
|
{
|
||||||
$core->meta->delPostMeta($post_id, 'post_expired');
|
dcCore::app()->meta->delPostMeta($post_id, 'post_expired');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save expired date
|
* Save expired date
|
||||||
*
|
*
|
||||||
* @param dcCore $core dcCore instance
|
|
||||||
* @param integer $post_id Post id
|
* @param integer $post_id Post id
|
||||||
* @param array $post _POST fields
|
* @param array $post _POST fields
|
||||||
*/
|
*/
|
||||||
protected static function setPostExpired(dcCore $core, $post_id, $post)
|
protected static function setPostExpired($post_id, $post)
|
||||||
{
|
{
|
||||||
$post_expired = array(
|
$post_expired = array(
|
||||||
'status'=> '',
|
'status'=> '',
|
||||||
@ -312,7 +307,7 @@ class adminBehaviorPostExpired
|
|||||||
(string) $post['post_expired_trackback'];
|
(string) $post['post_expired_trackback'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$core->meta->setPostMeta(
|
dcCore::app()->meta->setPostMeta(
|
||||||
$post_id,
|
$post_id,
|
||||||
'post_expired',
|
'post_expired',
|
||||||
encodePostExpired($post_expired)
|
encodePostExpired($post_expired)
|
||||||
@ -322,17 +317,16 @@ class adminBehaviorPostExpired
|
|||||||
/**
|
/**
|
||||||
* Expired date form fields
|
* Expired date form fields
|
||||||
*
|
*
|
||||||
* @param dcCore $core dcCore instance
|
|
||||||
* @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($post_type, $post_id = null)
|
||||||
{
|
{
|
||||||
$fields = $post_expired = array();
|
$fields = $post_expired = array();
|
||||||
|
|
||||||
if ($post_id) {
|
if ($post_id) {
|
||||||
|
|
||||||
$rs = $core->meta->getMetadata([
|
$rs = dcCore::app()->meta->getMetadata([
|
||||||
'meta_type' => 'post_expired',
|
'meta_type' => 'post_expired',
|
||||||
'post_id' => $post_id,
|
'post_id' => $post_id,
|
||||||
'limit' => 1
|
'limit' => 1
|
||||||
@ -371,7 +365,7 @@ class adminBehaviorPostExpired
|
|||||||
form::combo(
|
form::combo(
|
||||||
'post_expired_category',
|
'post_expired_category',
|
||||||
self::categoriesCombo(
|
self::categoriesCombo(
|
||||||
$core->blog->getCategories(
|
dcCore::app()->blog->getCategories(
|
||||||
array('post_type' => 'post')
|
array('post_type' => 'post')
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@ -416,10 +410,10 @@ class adminBehaviorPostExpired
|
|||||||
/**
|
/**
|
||||||
* Custom categories combo
|
* Custom categories combo
|
||||||
*
|
*
|
||||||
* @param record $categories Categories recordset
|
* @param dcRecord $categories Categories recordset
|
||||||
* @return array Categorires combo
|
* @return array Categorires combo
|
||||||
*/
|
*/
|
||||||
protected static function categoriesCombo(record $categories)
|
protected static function categoriesCombo(dcRecord $categories)
|
||||||
{
|
{
|
||||||
# Getting categories
|
# Getting categories
|
||||||
$categories_combo = array(
|
$categories_combo = array(
|
||||||
@ -427,7 +421,7 @@ class adminBehaviorPostExpired
|
|||||||
__('Uncategorized') => '!'
|
__('Uncategorized') => '!'
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
$categories = $GLOBALS['core']->blog->getCategories(
|
$categories = dcCore::app()->blog->getCategories(
|
||||||
array('post_type' => 'post')
|
array('post_type' => 'post')
|
||||||
);
|
);
|
||||||
while ($categories->fetch()) {
|
while ($categories->fetch()) {
|
||||||
|
@ -19,10 +19,13 @@ $this->registerModule(
|
|||||||
'Expired entries',
|
'Expired entries',
|
||||||
'Change entries options at a given date',
|
'Change entries options at a given date',
|
||||||
'Jean-Christian Denis and Contributors',
|
'Jean-Christian Denis and Contributors',
|
||||||
'2022.04.27',
|
'2022.11.12',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.21']],
|
'requires' => [['core', '2.24']],
|
||||||
'permissions' => 'usage,contentadmin',
|
'permissions' => dcCore::app()->auth->makePermissions([
|
||||||
|
dcAuth::PERMISSION_USAGE,
|
||||||
|
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||||
|
]),
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'https://github.com/JcDenis/postExpired',
|
'support' => 'https://github.com/JcDenis/postExpired',
|
||||||
'details' => 'https://plugins.dotaddict.org/dc2/details/postExpired',
|
'details' => 'https://plugins.dotaddict.org/dc2/details/postExpired',
|
||||||
|
12
_install.php
12
_install.php
@ -16,15 +16,15 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# -- Module specs --
|
# -- Module specs --
|
||||||
$dc_min = '2.21';
|
$dc_min = '2.24';
|
||||||
$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),
|
dcCore::app()->getVersion($mod_id),
|
||||||
$core->plugins->moduleInfo($mod_id, 'version'),
|
dcCore::app()->plugins->moduleInfo($mod_id, 'version'),
|
||||||
'>='
|
'>='
|
||||||
)) {
|
)) {
|
||||||
return null;
|
return null;
|
||||||
@ -39,14 +39,14 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Set module version
|
# Set module version
|
||||||
$core->setVersion(
|
dcCore::app()->setVersion(
|
||||||
$mod_id,
|
$mod_id,
|
||||||
$core->plugins->moduleInfo($mod_id, 'version')
|
dcCore::app()->plugins->moduleInfo($mod_id, 'version')
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$core->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
67
_public.php
67
_public.php
@ -15,7 +15,7 @@ if (!defined('DC_RC_PATH')) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($core->getVersion('postExpired') != $core->plugins->moduleInfo('postExpired', 'version')) {
|
if (dcCore::app()->getVersion('postExpired') != dcCore::app()->plugins->moduleInfo('postExpired', 'version')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,25 +23,25 @@ __('Expired on');
|
|||||||
__('This entry has no expiration date');
|
__('This entry has no expiration date');
|
||||||
|
|
||||||
# launch update only on public home page and feed
|
# launch update only on public home page and feed
|
||||||
if (in_array($core->url->type, array('default', 'feed'))) {
|
if (in_array(dcCore::app()->url->type, array('default', 'feed'))) {
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'publicBeforeDocument',
|
'publicBeforeDocumentV2',
|
||||||
['publicBehaviorPostExpired', 'publicBeforeDocument']
|
['publicBehaviorPostExpired', 'publicBeforeDocument']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'coreBlogGetPosts',
|
'coreBlogGetPosts',
|
||||||
['publicBehaviorPostExpired', 'coreBlogGetPosts']
|
['publicBehaviorPostExpired', 'coreBlogGetPosts']
|
||||||
);
|
);
|
||||||
$core->tpl->addBlock(
|
dcCore::app()->tpl->addBlock(
|
||||||
'EntryExpiredIf',
|
'EntryExpiredIf',
|
||||||
['tplPostExpired', 'EntryExpiredIf']
|
['tplPostExpired', 'EntryExpiredIf']
|
||||||
);
|
);
|
||||||
$core->tpl->addValue(
|
dcCore::app()->tpl->addValue(
|
||||||
'EntryExpiredDate',
|
'EntryExpiredDate',
|
||||||
['tplPostExpired', 'EntryExpiredDate']
|
['tplPostExpired', 'EntryExpiredDate']
|
||||||
);
|
);
|
||||||
$core->tpl->addValue(
|
dcCore::app()->tpl->addValue(
|
||||||
'EntryExpiredTime',
|
'EntryExpiredTime',
|
||||||
['tplPostExpired', 'EntryExpiredTime']
|
['tplPostExpired', 'EntryExpiredTime']
|
||||||
);
|
);
|
||||||
@ -56,17 +56,16 @@ class publicBehaviorPostExpired
|
|||||||
/**
|
/**
|
||||||
* Check if there are expired dates
|
* Check if there are expired dates
|
||||||
*
|
*
|
||||||
* @param dcCore $core dcCore instance
|
|
||||||
*/
|
*/
|
||||||
public static function publicBeforeDocument(dcCore $core)
|
public static function publicBeforeDocument()
|
||||||
{
|
{
|
||||||
# Get expired dates and post_id
|
# Get expired dates and post_id
|
||||||
$posts = $core->con->select(
|
$posts = dcCore::app()->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 ' . dcCore::app()->prefix . 'post P ' .
|
||||||
'INNER JOIN ' . $core->prefix . 'meta META ' .
|
'INNER JOIN ' . dcCore::app()->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 = '" . dcCore::app()->con->escape(dcCore::app()->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' "
|
||||||
@ -81,7 +80,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 = dcCore::app()->con->openCursor(dcCore::app()->prefix . 'post');
|
||||||
|
|
||||||
# Loop through marked posts
|
# Loop through marked posts
|
||||||
$updated = false;
|
$updated = false;
|
||||||
@ -95,8 +94,8 @@ class publicBehaviorPostExpired
|
|||||||
$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(
|
dcCore::app()->auth->sudo(
|
||||||
array($core->meta, 'delPostMeta'),
|
array(dcCore::app()->meta, 'delPostMeta'),
|
||||||
$posts->post_id,
|
$posts->post_id,
|
||||||
'post_expired'
|
'post_expired'
|
||||||
);
|
);
|
||||||
@ -142,7 +141,7 @@ 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 = '" . dcCore::app()->con->escape(dcCore::app()->blog->id) . "' "
|
||||||
);
|
);
|
||||||
|
|
||||||
$updated = true;
|
$updated = true;
|
||||||
@ -151,16 +150,16 @@ class publicBehaviorPostExpired
|
|||||||
|
|
||||||
# Say blog is updated
|
# Say blog is updated
|
||||||
if ($updated) {
|
if ($updated) {
|
||||||
$core->blog->triggerBlog();
|
dcCore::app()->blog->triggerBlog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends posts record with expired date
|
* Extends posts record with expired date
|
||||||
*
|
*
|
||||||
* @param record $rs Post recordset
|
* @param dcRecord $rs Post recordset
|
||||||
*/
|
*/
|
||||||
public static function coreBlogGetPosts(record $rs)
|
public static function coreBlogGetPosts(dcRecord $rs)
|
||||||
{
|
{
|
||||||
$rs->extend('rsExtPostExpiredPublic');
|
$rs->extend('rsExtPostExpiredPublic');
|
||||||
}
|
}
|
||||||
@ -179,7 +178,7 @@ class rsExtPostExpiredPublic extends rsExtPost
|
|||||||
* @param record $rs Post recordset
|
* @param record $rs Post recordset
|
||||||
* @return string Expired date or null
|
* @return string Expired date or null
|
||||||
*/
|
*/
|
||||||
public static function postExpiredDate(record $rs)
|
public static function postExpiredDate(dcRecord $rs)
|
||||||
{
|
{
|
||||||
if (!$rs->postexpired[$rs->post_id]) { //memory
|
if (!$rs->postexpired[$rs->post_id]) { //memory
|
||||||
$rs_date = $rs->core->meta->getMetadata([
|
$rs_date = $rs->core->meta->getMetadata([
|
||||||
@ -221,9 +220,9 @@ 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 . '== dcCore::app()->ctx->posts->postExpiredDate())';
|
||||||
} else {
|
} else {
|
||||||
$if[] = '(null !== $_ctx->posts->postExpiredDate())';
|
$if[] = '(null !== dcCore::app()->ctx->posts->postExpiredDate())';
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -241,19 +240,19 @@ class tplPostExpired
|
|||||||
{
|
{
|
||||||
$format = !empty($attr['format']) ?
|
$format = !empty($attr['format']) ?
|
||||||
addslashes($attr['format']) : '';
|
addslashes($attr['format']) : '';
|
||||||
$f = $GLOBALS['core']->tpl->getFilters($attr);
|
$f = dcCore::app()->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(dcCore::app()->ctx->posts->postExpiredDate()),dcCore::app()->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(dcCore::app()->ctx->posts->postExpiredDate(),dcCore::app()->ctx->posts->post_tz)");
|
||||||
} elseif ($format) {
|
} elseif ($format) {
|
||||||
$res = sprintf($f, "dt::dt2str('" . $format . "',\$_ctx->posts->postExpiredDate())");
|
$res = sprintf($f, "dt::dt2str('" . $format . "',dcCore::app()->ctx->posts->postExpiredDate())");
|
||||||
} else {
|
} else {
|
||||||
$res = sprintf($f, "dt::dt2str(\$core->blog->settings->system->date_format,\$_ctx->posts->postExpiredDate())");
|
$res = sprintf($f, "dt::dt2str(dcCore::app()->blog->settings->system->date_format,dcCore::app()->ctx->posts->postExpiredDate())");
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<?php if (null !== $_ctx->posts->postExpiredDate()) { echo ' . $res . '; } ?>';
|
return '<?php if (null !== dcCore::app()->ctx->posts->postExpiredDate()) { echo ' . $res . '; } ?>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -264,11 +263,11 @@ class tplPostExpired
|
|||||||
public static function EntryExpiredTime($attr)
|
public static function EntryExpiredTime($attr)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
'<?php if (null !== $_ctx->posts->postExpiredDate()) { echo ' . sprintf(
|
'<?php if (null !== dcCore::app()->ctx->posts->postExpiredDate()) { echo ' . sprintf(
|
||||||
$GLOBALS['core']->tpl->getFilters($attr), "dt::dt2str(" .
|
dcCore::app()->tpl->getFilters($attr), "dt::dt2str(" .
|
||||||
(!empty($attr['format']) ?
|
(!empty($attr['format']) ?
|
||||||
"'" . addslashes($attr['format']) . "'" : "\$core->blog->settings->system->time_format"
|
"'" . addslashes($attr['format']) . "'" : "dcCore::app()->blog->settings->system->time_format"
|
||||||
) . ",\$_ctx->posts->postExpiredDate())"
|
) . ",dcCore::app()->ctx->posts->postExpiredDate())"
|
||||||
) . '; } ?>';
|
) . '; } ?>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user