prepare to DC 2.24, fix feed update
This commit is contained in:
parent
e55c5c5661
commit
9be9f44757
14 changed files with 441 additions and 462 deletions
105
_admin.php
105
_admin.php
|
@ -14,39 +14,38 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||
return null;
|
||||
}
|
||||
|
||||
$core->blog->settings->addNamespace('zoneclearFeedServer');
|
||||
dcCore::app()->blog->settings->addNamespace('zoneclearFeedServer');
|
||||
|
||||
require_once dirname(__FILE__) . '/_widgets.php';
|
||||
require_once __DIR__ . '/_widgets.php';
|
||||
|
||||
$_menu['Plugins']->addItem(
|
||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||
__('Feeds server'),
|
||||
$core->adminurl->get('admin.plugin.zoneclearFeedServer'),
|
||||
dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer'),
|
||||
dcPage::getPF('zoneclearFeedServer/icon.png'),
|
||||
preg_match(
|
||||
'/' . preg_quote($core->adminurl->get('admin.plugin.zoneclearFeedServer')) . '(&.*)?$/',
|
||||
'/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer')) . '(&.*)?$/',
|
||||
$_SERVER['REQUEST_URI']
|
||||
),
|
||||
$core->auth->check('admin', $core->blog->id)
|
||||
dcCore::app()->auth->check('admin', dcCore::app()->blog->id)
|
||||
);
|
||||
|
||||
# Delete related info about feed post in meta table
|
||||
$core->addBehavior('adminBeforePostDelete', ['zcfsAdminBehaviors', 'adminBeforePostDelete']);
|
||||
|
||||
if ($core->auth->check('admin', $core->blog->id)) {
|
||||
dcCore::app()->addBehavior('adminBeforePostDelete', ['zcfsAdminBehaviors', 'adminBeforePostDelete']);
|
||||
|
||||
if (dcCore::app()->auth->check('admin', dcCore::app()->blog->id)) {
|
||||
# Dashboard icon
|
||||
$core->addBehavior('adminDashboardFavorites', ['zcfsAdminBehaviors', 'adminDashboardFavorites']);
|
||||
dcCore::app()->addBehavior('adminDashboardFavoritesV2', ['zcfsAdminBehaviors', 'adminDashboardFavorites']);
|
||||
# User pref
|
||||
$core->addBehavior('adminColumnsLists', ['zcfsAdminBehaviors', 'adminColumnsLists']);
|
||||
$core->addBehavior('adminFiltersLists', ['zcfsAdminBehaviors', 'adminFiltersLists']);
|
||||
dcCore::app()->addBehavior('adminColumnsListsV2', ['zcfsAdminBehaviors', 'adminColumnsLists']);
|
||||
dcCore::app()->addBehavior('adminFiltersListsV2', ['zcfsAdminBehaviors', 'adminFiltersLists']);
|
||||
# Add info about feed on post page sidebar
|
||||
$core->addBehavior('adminPostHeaders', ['zcfsAdminBehaviors', 'adminPostHeaders']);
|
||||
$core->addBehavior('adminPostFormItems', ['zcfsAdminBehaviors', 'adminPostFormItems']);
|
||||
dcCore::app()->addBehavior('adminPostHeaders', ['zcfsAdminBehaviors', 'adminPostHeaders']);
|
||||
dcCore::app()->addBehavior('adminPostFormItems', ['zcfsAdminBehaviors', 'adminPostFormItems']);
|
||||
}
|
||||
|
||||
# Take care about tweakurls (thanks Mathieu M.)
|
||||
if (version_compare($core->plugins->moduleInfo('tweakurls', 'version'), '0.8', '>=')) {
|
||||
$core->addbehavior('zcfsAfterPostCreate', ['zoneclearFeedServer', 'tweakurlsAfterPostCreate']);
|
||||
if (version_compare(dcCore::app()->plugins->moduleInfo('tweakurls', 'version'), '0.8', '>=')) {
|
||||
dcCore::app()->addbehavior('zcfsAfterPostCreate', ['zoneclearFeedServer', 'tweakurlsAfterPostCreate']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +62,7 @@ class zcfsAdminBehaviors
|
|||
__('Name') => 'lowername',
|
||||
__('Frequency') => 'feed_upd_int',
|
||||
__('Update date') => 'feed_upd_last',
|
||||
__('Status') => 'feed_status'
|
||||
__('Status') => 'feed_status',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -74,26 +73,25 @@ class zcfsAdminBehaviors
|
|||
__('Title') => 'post_title',
|
||||
__('Category') => 'cat_title',
|
||||
__('Author') => 'user_id',
|
||||
__('Status') => 'post_status'
|
||||
__('Status') => 'post_status',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Favorites.
|
||||
*
|
||||
* @param dcCore $core dcCore instance
|
||||
* @param arrayObject $favs Array of favorites
|
||||
* @param dcFavorites $favs Array of favorites
|
||||
*/
|
||||
public static function adminDashboardFavorites(dcCore $core, dcFavorites $favs)
|
||||
public static function adminDashboardFavorites(dcFavorites $favs)
|
||||
{
|
||||
$favs->register('zcfs', [
|
||||
'title' => __('Feeds server'),
|
||||
'url' => $core->adminurl->get('admin.plugin.zoneclearFeedServer'),
|
||||
'url' => dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer'),
|
||||
'small-icon' => dcPage::getPF('zoneclearFeedServer/icon.png'),
|
||||
'large-icon' => dcPage::getPF('zoneclearFeedServer/icon-big.png'),
|
||||
'permissions' => 'usage,contentadmin',
|
||||
'active_cb' => ['zcfsAdminBehaviors', 'adminDashboardFavoritesActive'],
|
||||
'dashboard_cb' => ['zcfsAdminBehaviors', 'adminDashboardFavoritesCallback']
|
||||
'dashboard_cb' => ['zcfsAdminBehaviors', 'adminDashboardFavoritesCallback'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -113,12 +111,11 @@ class zcfsAdminBehaviors
|
|||
/**
|
||||
* Favorites hack.
|
||||
*
|
||||
* @param dcCore $core dcCore instance
|
||||
* @param arrayObject $fav Fav attributes
|
||||
*/
|
||||
public static function adminDashboardFavoritesCallback(dcCore $core, $fav)
|
||||
public static function adminDashboardFavoritesCallback($fav)
|
||||
{
|
||||
$zcfs = new zoneclearFeedServer($core);
|
||||
$zcfs = new zoneclearFeedServer();
|
||||
|
||||
$count = $zcfs->getFeeds(['feed_status' => '0'], true)->f(0);
|
||||
if (!$count) {
|
||||
|
@ -127,7 +124,7 @@ class zcfsAdminBehaviors
|
|||
|
||||
$fav['title'] .= '<br />' . sprintf(__('%s feed disabled', '%s feeds disabled', $count), $count);
|
||||
$fav['large-icon'] = dcPage::getPF('zoneclearFeedServer/icon-big-update.png');
|
||||
$fav['url'] = $core->adminurl->get(
|
||||
$fav['url'] = dcCore::app()->adminurl->get(
|
||||
'admin.plugin.zoneclearFeedServer',
|
||||
['part' => 'feeds', 'sortby' => 'feed_status', 'order' => 'asc']
|
||||
);
|
||||
|
@ -136,10 +133,9 @@ class zcfsAdminBehaviors
|
|||
/**
|
||||
* User pref columns lists.
|
||||
*
|
||||
* @param dcCore $core dcCore instance
|
||||
* @param arrayObject $cols Columns
|
||||
*/
|
||||
public static function adminColumnsLists(dcCore $core, $cols)
|
||||
public static function adminColumnsLists($cols)
|
||||
{
|
||||
$cols['zcfs_feeds'] = [
|
||||
__('Feeds server: Feeds'),
|
||||
|
@ -147,40 +143,39 @@ class zcfsAdminBehaviors
|
|||
'desc' => [true, __('Feed')],
|
||||
'period' => [true, __('Frequency')],
|
||||
'update' => [true, __('Last update')],
|
||||
'entries' => [true, __('Entries')]
|
||||
]
|
||||
'entries' => [true, __('Entries')],
|
||||
],
|
||||
];
|
||||
$cols['zcfs_entries'] = [
|
||||
__('Feeds server: Entries'),
|
||||
[
|
||||
'date' => [true, __('Date')],
|
||||
'category' => [true, __('Category')],
|
||||
'author' => [true, __('Author')]
|
||||
]
|
||||
'author' => [true, __('Author')],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* User pref filters options.
|
||||
*
|
||||
* @param dcCore $core dcCore instance
|
||||
* @param arrayObject $sorts Sort options
|
||||
*/
|
||||
public static function adminFiltersLists(dcCore $core, $sorts)
|
||||
public static function adminFiltersLists($sorts)
|
||||
{
|
||||
$sorts['zcfs_feeds'] = [
|
||||
__('Feeds server: Feeds'),
|
||||
self::feedsSortbyCombo(),
|
||||
'lowername',
|
||||
'asc',
|
||||
[__('feeds per page'), 30]
|
||||
[__('feeds per page'), 30],
|
||||
];
|
||||
$sorts['zcfs_entries'] = [
|
||||
__('Feeds server: Entries'),
|
||||
self::entriesSortbyCombo(),
|
||||
'post_dt',
|
||||
'desc',
|
||||
[__('entries per page'), 30]
|
||||
[__('entries per page'), 30],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -207,50 +202,48 @@ class zcfsAdminBehaviors
|
|||
return null;
|
||||
}
|
||||
|
||||
global $core;
|
||||
|
||||
$url = $core->meta->getMetadata([
|
||||
$url = dcCore::app()->meta->getMetadata([
|
||||
'post_id' => $post->post_id,
|
||||
'meta_type' => 'zoneclearfeed_url',
|
||||
'limit' => 1
|
||||
'limit' => 1,
|
||||
]);
|
||||
$url = $url->isEmpty() ? '' : $url->meta_id;
|
||||
if (!$url) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$author = $core->meta->getMetadata([
|
||||
$author = dcCore::app()->meta->getMetadata([
|
||||
'post_id' => $post->post_id,
|
||||
'meta_type' => 'zoneclearfeed_author',
|
||||
'limit' => 1
|
||||
'limit' => 1,
|
||||
]);
|
||||
$author = $author->isEmpty() ? '' : $author->meta_id;
|
||||
|
||||
$site = $core->meta->getMetadata([
|
||||
$site = dcCore::app()->meta->getMetadata([
|
||||
'post_id' => $post->post_id,
|
||||
'meta_type' => 'zoneclearfeed_site',
|
||||
'limit' => 1
|
||||
'limit' => 1,
|
||||
]);
|
||||
$site = $site->isEmpty() ? '' : $site->meta_id;
|
||||
|
||||
$sitename = $core->meta->getMetadata([
|
||||
$sitename = dcCore::app()->meta->getMetadata([
|
||||
'post_id' => $post->post_id,
|
||||
'meta_type' => 'zoneclearfeed_sitename',
|
||||
'limit' => 1
|
||||
'limit' => 1,
|
||||
]);
|
||||
$sitename = $sitename->isEmpty() ? '' : $sitename->meta_id;
|
||||
|
||||
$edit = '';
|
||||
if ($core->auth->check('admin', $core->blog->id)) {
|
||||
$fid = $core->meta->getMetadata([
|
||||
if (dcCore::app()->auth->check(dcAuth::PERMISSION_CONTENT_ADMIN, dcCore::app()->blog->id)) {
|
||||
$fid = dcCore::app()->meta->getMetadata([
|
||||
'post_id' => $post->post_id,
|
||||
'meta_type' => 'zoneclearfeed_id',
|
||||
'limit' => 1
|
||||
'limit' => 1,
|
||||
]);
|
||||
if (!$fid->isEmpty()) {
|
||||
$edit = sprintf(
|
||||
'<p><a href="%s">%s</a></p>',
|
||||
$core->adminurl->get(
|
||||
dcCore::app()->adminurl->get(
|
||||
'admin.plugin.zoneclearFeedServer',
|
||||
['part' => 'feed', 'feed_id' => $fid->meta_id]
|
||||
),
|
||||
|
@ -276,17 +269,15 @@ class zcfsAdminBehaviors
|
|||
*/
|
||||
public static function adminBeforePostDelete($post_id)
|
||||
{
|
||||
global $core;
|
||||
|
||||
$core->con->execute(
|
||||
'DELETE FROM ' . $core->prefix . 'meta ' .
|
||||
dcCore::app()->con->execute(
|
||||
'DELETE FROM ' . dcCore::app()->prefix . dcMeta::META_TABLE_NAME . ' ' .
|
||||
'WHERE post_id = ' . ((int) $post_id) . ' ' .
|
||||
'AND meta_type ' . $core->con->in([
|
||||
'AND meta_type ' . dcCore::app()->con->in([
|
||||
'zoneclearfeed_url',
|
||||
'zoneclearfeed_author',
|
||||
'zoneclearfeed_site',
|
||||
'zoneclearfeed_sitename',
|
||||
'zoneclearfeed_id'
|
||||
'zoneclearfeed_id',
|
||||
]) . ' '
|
||||
);
|
||||
}
|
||||
|
|
32
_config.php
32
_config.php
|
@ -14,11 +14,11 @@ if (!defined('DC_CONTEXT_MODULE')) {
|
|||
return null;
|
||||
}
|
||||
|
||||
$redir = empty($_REQUEST['redir']) ? $list->getURL() . '#plugins' : $_REQUEST['redir'];
|
||||
$redir = empty($_REQUEST['redir']) ? dcCore::app()->admin->list->getURL() . '#plugins' : $_REQUEST['redir'];
|
||||
|
||||
# -- Get settings --
|
||||
$core->blog->settings->addNamespace('zoneclearFeedServer');
|
||||
$s = $core->blog->settings->zoneclearFeedServer;
|
||||
dcCore::app()->blog->settings->addNamespace('zoneclearFeedServer');
|
||||
$s = dcCore::app()->blog->settings->zoneclearFeedServer;
|
||||
|
||||
$active = (bool) $s->zoneclearFeedServer_active;
|
||||
$pub_active = (bool) $s->zoneclearFeedServer_pub_active;
|
||||
|
@ -41,7 +41,7 @@ if (!is_array($post_title_redir)) {
|
|||
$post_title_redir = [];
|
||||
}
|
||||
|
||||
$zc = new zoneclearFeedServer($core);
|
||||
$zc = new zoneclearFeedServer();
|
||||
|
||||
# -- Set settings --
|
||||
if (!empty($_POST['save'])) {
|
||||
|
@ -72,17 +72,17 @@ if (!empty($_POST['save'])) {
|
|||
$s->put('zoneclearFeedServer_post_title_redir', serialize($post_title_redir));
|
||||
$s->put('zoneclearFeedServer_user', $feeduser);
|
||||
|
||||
$core->blog->triggerBlog();
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
dcAdminNotices::addSuccessNotice(
|
||||
__('Configuration successfully updated.')
|
||||
);
|
||||
$core->adminurl->redirect(
|
||||
dcCore::app()->adminurl->redirect(
|
||||
'admin.plugins',
|
||||
['module' => 'zoneclearFeedServer', 'conf' => 1, 'redir' => $list->getRedir()]
|
||||
['module' => 'zoneclearFeedServer', 'conf' => 1, 'redir' => dcCore::app()->admin->list->getRedir()]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,20 +92,20 @@ $combo_pubupd = [
|
|||
__('Disable') => 0,
|
||||
__('Before display') => 1,
|
||||
__('After display') => 2,
|
||||
__('Through Ajax') => 3
|
||||
__('Through Ajax') => 3,
|
||||
];
|
||||
$combo_status = [
|
||||
__('Unpublished') => 0,
|
||||
__('Published') => 1
|
||||
__('Published') => 1,
|
||||
];
|
||||
$combo_tagcase = [
|
||||
__('Keep source case') => 0,
|
||||
__('First upper case') => 1,
|
||||
__('All lower case') => 2,
|
||||
__('All upper case') => 3
|
||||
__('All upper case') => 3,
|
||||
];
|
||||
|
||||
$pub_page_url = $core->blog->url . $core->url->getBase('zoneclearFeedsPage');
|
||||
$pub_page_url = dcCore::app()->blog->url . dcCore::app()->url->getBase('zoneclearFeedsPage');
|
||||
|
||||
# -- Display form --
|
||||
|
||||
|
@ -124,7 +124,7 @@ __('Enable plugin') . '</label></p>
|
|||
|
||||
<div class="fieldset">';
|
||||
|
||||
if ($core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_pub_active) {
|
||||
if (dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_pub_active) {
|
||||
echo sprintf(
|
||||
'<p><a class="onblog_link outgoing" href="%s" title="%s">%s <img alt="" src="images/outgoing-link.svg"></a></p>',
|
||||
$pub_page_url,
|
||||
|
@ -168,7 +168,7 @@ form::checkbox('pub_active', 1, $pub_active) . __('Enable public page') . '</lab
|
|||
|
||||
<p>' . __('Redirect to original post on:') . '</p><ul>';
|
||||
|
||||
foreach ($zc->getPublicUrlTypes($core) as $k => $v) {
|
||||
foreach ($zc->getPublicUrlTypes() as $k => $v) {
|
||||
echo sprintf(
|
||||
'<li><label for="post_title_redir_%s">%s%s</label></li>',
|
||||
$v,
|
||||
|
@ -183,7 +183,7 @@ echo '
|
|||
|
||||
<p>' . __('Show full content on:') . '</p><ul>';
|
||||
|
||||
foreach ($zc->getPublicUrlTypes($core) as $k => $v) {
|
||||
foreach ($zc->getPublicUrlTypes() as $k => $v) {
|
||||
echo sprintf(
|
||||
'<li><label for="post_full_tpl_%s">%s%s</label></li>',
|
||||
$v,
|
||||
|
|
|
@ -18,13 +18,13 @@ $this->registerModule(
|
|||
'Feeds server',
|
||||
'Mix your blog with a feeds planet',
|
||||
'Jean-Christian Denis, BG, Pierre Van Glabeke',
|
||||
'2022.02.13',
|
||||
'2022.11.12',
|
||||
[
|
||||
'requires' => [['core', '2.21']],
|
||||
'permissions' => 'admin',
|
||||
'requires' => [['core', '2.24']],
|
||||
'permissions' => dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
'type' => 'plugin',
|
||||
'support' => 'https://github.com/JcDenis/zoneclearFeedServer',
|
||||
'details' => 'https://plugins.dotaddict.org/dc2/details/pacKman',
|
||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/zoneclearFeedServer/master/dcstore.xml'
|
||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/zoneclearFeedServer/master/dcstore.xml',
|
||||
]
|
||||
);
|
||||
|
|
14
_install.php
14
_install.php
|
@ -20,7 +20,7 @@ $dc_min = $this->modules[$mod_id]['requires'][0][1];
|
|||
try {
|
||||
# Check module version
|
||||
if (version_compare(
|
||||
$core->getVersion($mod_id),
|
||||
dcCore::app()->getVersion($mod_id),
|
||||
$this->moduleInfo($mod_id, 'version'),
|
||||
'>='
|
||||
)) {
|
||||
|
@ -39,7 +39,7 @@ try {
|
|||
}
|
||||
|
||||
# Tables
|
||||
$t = new dbStruct($core->con, $core->prefix);
|
||||
$t = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
|
||||
$t->zc_feed
|
||||
->feed_id('bigint', 0, false)
|
||||
->feed_creadt('timestamp', 0, false, 'now()')
|
||||
|
@ -66,12 +66,12 @@ try {
|
|||
->index('idx_zcfs_type', 'btree', 'feed_type')
|
||||
->index('idx_zcfs_blog', 'btree', 'blog_id');
|
||||
|
||||
$ti = new dbStruct($core->con, $core->prefix);
|
||||
$ti = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
|
||||
$changes = $ti->synchronize($t);
|
||||
|
||||
# Settings
|
||||
$core->blog->settings->addNamespace('zoneclearFeedServer');
|
||||
$s = $core->blog->settings->zoneclearFeedServer;
|
||||
dcCore::app()->blog->settings->addNamespace('zoneclearFeedServer');
|
||||
$s = dcCore::app()->blog->settings->zoneclearFeedServer;
|
||||
$s->put('zoneclearFeedServer_active', false, 'boolean', 'Enable zoneclearBlogServer', false, true);
|
||||
$s->put('zoneclearFeedServer_pub_active', false, 'boolean', 'Enable public page of list of feeds', false, true);
|
||||
$s->put('zoneclearFeedServer_post_status_new', true, 'boolean', 'Enable auto publish new posts', false, true);
|
||||
|
@ -84,14 +84,14 @@ try {
|
|||
$s->put('zoneclearFeedServer_post_title_redir', serialize(['feed']), 'string', 'List of templates types for redirection to original post', false, true);
|
||||
|
||||
# Set module version
|
||||
$core->setVersion(
|
||||
dcCore::app()->setVersion(
|
||||
$mod_id,
|
||||
$this->moduleInfo($mod_id, 'version')
|
||||
);
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
18
_prepend.php
18
_prepend.php
|
@ -14,17 +14,15 @@ if (!defined('DC_RC_PATH')) {
|
|||
return null;
|
||||
}
|
||||
|
||||
$d = dirname(__FILE__) . '/inc/';
|
||||
|
||||
$__autoload['zoneclearFeedServer'] = $d . 'class.zoneclear.feed.server.php';
|
||||
$__autoload['zcfsFeedsList'] = $d . 'lib.zcfs.list.php';
|
||||
$__autoload['zcfsEntriesList'] = $d . 'lib.zcfs.list.php';
|
||||
$__autoload['adminZcfsPostFilter'] = $d . 'lib.zcfs.list.php';
|
||||
$__autoload['zcfsFeedsActionsPage'] = $d . 'class.zcfs.feedsactions.php';
|
||||
$__autoload['zcfsDefaultFeedsActions'] = $d . 'class.zcfs.feedsactions.php';
|
||||
Clearbricks::lib()->autoload(['zoneclearFeedServer' => __DIR__ . '/inc/class.zoneclear.feed.server.php']);
|
||||
Clearbricks::lib()->autoload(['zcfsFeedsList' => __DIR__ . '/inc/lib.zcfs.list.php']);
|
||||
Clearbricks::lib()->autoload(['zcfsEntriesList' => __DIR__ . '/inc/lib.zcfs.list.php']);
|
||||
Clearbricks::lib()->autoload(['adminZcfsPostFilter' => __DIR__ . '/inc/lib.zcfs.list.php']);
|
||||
Clearbricks::lib()->autoload(['zcfsFeedsActionsPage' => __DIR__ . '/inc/class.zcfs.feedsactions.php']);
|
||||
Clearbricks::lib()->autoload(['zcfsDefaultFeedsActions' => __DIR__ . '/inc/class.zcfs.feedsactions.php']);
|
||||
|
||||
// public url for page of description of the flux
|
||||
$core->url->register(
|
||||
dcCore::app()->url->register(
|
||||
'zoneclearFeedsPage',
|
||||
'zcfeeds',
|
||||
'^zcfeeds(.*?)$',
|
||||
|
@ -33,5 +31,5 @@ $core->url->register(
|
|||
|
||||
// Add to report on plugin activityReport
|
||||
if (defined('ACTIVITY_REPORT')) {
|
||||
require_once $d . 'lib.zcfs.activityreport.php';
|
||||
require_once __DIR__ . '/inc/lib.zcfs.activityreport.php';
|
||||
}
|
||||
|
|
205
_public.php
205
_public.php
|
@ -15,28 +15,28 @@ if (!defined('DC_RC_PATH')) {
|
|||
}
|
||||
|
||||
# Namespace for settings
|
||||
$core->blog->settings->addNamespace('zoneclearFeedServer');
|
||||
$s = $core->blog->settings->zoneclearFeedServer;
|
||||
dcCore::app()->blog->settings->addNamespace('zoneclearFeedServer');
|
||||
$s = dcCore::app()->blog->settings->zoneclearFeedServer;
|
||||
|
||||
# Widgets
|
||||
require_once dirname(__FILE__) . '/_widgets.php';
|
||||
require_once __DIR__ . '/_widgets.php';
|
||||
|
||||
$core->addBehavior('coreBlogGetPosts', ['zcfsPublicBehaviors', 'coreBlogGetPosts']);
|
||||
dcCore::app()->addBehavior('coreBlogGetPosts', ['zcfsPublicBehaviors', 'coreBlogGetPosts']);
|
||||
|
||||
if (!$s->zoneclearFeedServer_active) {
|
||||
return null;
|
||||
}
|
||||
if (1 == $s->zoneclearFeedServer_bhv_pub_upd) {
|
||||
$core->addBehavior('publicBeforeDocument', ['zcfsPublicBehaviors', 'publicDocument']);
|
||||
dcCore::app()->addBehavior('publicBeforeDocument', ['zcfsPublicBehaviors', 'publicDocument']);
|
||||
} elseif (2 == $s->zoneclearFeedServer_bhv_pub_upd) {
|
||||
$core->addBehavior('publicAfterDocument', ['zcfsPublicBehaviors', 'publicAfterDocument']);
|
||||
dcCore::app()->addBehavior('publicAfterDocument', ['zcfsPublicBehaviors', 'publicAfterDocument']);
|
||||
} elseif (3 == $s->zoneclearFeedServer_bhv_pub_upd) {
|
||||
$core->addBehavior('publicHeadContent', ['zcfsPublicBehaviors', 'publicHeadContent']);
|
||||
dcCore::app()->addBehavior('publicHeadContent', ['zcfsPublicBehaviors', 'publicHeadContent']);
|
||||
}
|
||||
|
||||
# Take care about tweakurls (thanks Mathieu M.)
|
||||
if (version_compare($core->plugins->moduleInfo('tweakurls', 'version'), '0.8', '>=')) {
|
||||
$core->addbehavior('zoneclearFeedServerAfterPostCreate', ['zoneclearFeedServer', 'tweakurlsAfterPostCreate']);
|
||||
if (version_compare(dcCore::app()->plugins->moduleInfo('tweakurls', 'version'), '0.8', '>=')) {
|
||||
dcCore::app()->addbehavior('zoneclearFeedServerAfterPostCreate', ['zoneclearFeedServer', 'tweakurlsAfterPostCreate']);
|
||||
}
|
||||
|
||||
# Register tempalte blocks
|
||||
|
@ -44,10 +44,10 @@ $tpl_blocks = [
|
|||
'Feeds',
|
||||
'FeedsFooter',
|
||||
'FeedsHeader',
|
||||
'FeedIf'
|
||||
'FeedIf',
|
||||
];
|
||||
foreach ($tpl_blocks as $v) {
|
||||
$core->tpl->addBlock('zc' . $v, ['zcfsTemplate', $v]);
|
||||
dcCore::app()->tpl->addBlock('zc' . $v, ['zcfsTemplate', $v]);
|
||||
}
|
||||
|
||||
# Register tempalte values
|
||||
|
@ -67,10 +67,10 @@ $tpl_values = [
|
|||
'FeedOwner',
|
||||
'FeedDesc',
|
||||
'FeedSiteURL',
|
||||
'FeedFeedURL'
|
||||
'FeedFeedURL',
|
||||
];
|
||||
foreach ($tpl_values as $v) {
|
||||
$core->tpl->addValue('zc' . $v, ['zcfsTemplate', $v]);
|
||||
dcCore::app()->tpl->addValue('zc' . $v, ['zcfsTemplate', $v]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,9 +83,9 @@ class zcfsPublicBehaviors
|
|||
/**
|
||||
* Remember others post extension.
|
||||
*
|
||||
* @param record $rs record instance
|
||||
* @param dcRecord $rs record instance
|
||||
*/
|
||||
public static function coreBlogGetPosts(record $rs)
|
||||
public static function coreBlogGetPosts(dcRecord $rs)
|
||||
{
|
||||
$GLOBALS['beforeZcFeedRsExt'] = $rs->extensions();
|
||||
$rs->extend('zcfsRsExtPosts');
|
||||
|
@ -94,29 +94,25 @@ class zcfsPublicBehaviors
|
|||
/**
|
||||
* Update feeds after contents.
|
||||
*
|
||||
* @param dcCore $core dcCore instance
|
||||
* @return string Document
|
||||
*/
|
||||
public static function publicAfterDocument(dcCore $core)
|
||||
public static function publicAfterDocument()
|
||||
{
|
||||
# Limit feeds update to home page et feed page
|
||||
# Like publishScheduledEntries
|
||||
if (!in_array($core->url->type, ['default', 'feed'])) {
|
||||
if (!in_array(dcCore::app()->url->type, ['default', 'feed'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
self::publicDocument($core);
|
||||
self::publicDocument();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic behavior for before and after public content.
|
||||
*
|
||||
* @param dcCore $core dcCore instance
|
||||
* @return null NULL
|
||||
*/
|
||||
public static function publicDocument(dcCore $core)
|
||||
public static function publicDocument()
|
||||
{
|
||||
$zc = new zoneclearFeedServer($core);
|
||||
$zc = new zoneclearFeedServer();
|
||||
$zc->checkFeedsUpdate();
|
||||
|
||||
return null;
|
||||
|
@ -124,28 +120,24 @@ class zcfsPublicBehaviors
|
|||
|
||||
/**
|
||||
* Update feeds by an Ajax request (background).
|
||||
*
|
||||
* @param dcCore $core dcCore instance
|
||||
* @param context $_ctx context instance
|
||||
* @return string HTML content
|
||||
*/
|
||||
public static function publicHeadContent(dcCore $core, context $_ctx)
|
||||
public static function publicHeadContent()
|
||||
{
|
||||
# Limit update to home page
|
||||
if ($core->url->type != 'default') {
|
||||
if (dcCore::app()->url->type != 'default') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$blog_url = html::escapeJS(
|
||||
$core->blog->url .
|
||||
$core->url->getBase('zoneclearFeedsPage') .
|
||||
dcCore::app()->blog->url .
|
||||
dcCore::app()->url->getBase('zoneclearFeedsPage') .
|
||||
'/zcfsupd'
|
||||
);
|
||||
$blog_id = html::escapeJS($core->blog->id);
|
||||
$blog_id = html::escapeJS(dcCore::app()->blog->id);
|
||||
|
||||
echo
|
||||
"\n<!-- JS for zoneclearFeedServer --> \n" .
|
||||
dcutils::jsLoad($core->blog->url . $core->url->getBase('zoneclearFeedsPage') . '/zcfsupd.js') .
|
||||
dcUtils::jsLoad(dcCore::app()->blog->url . dcCore::app()->url->getBase('zoneclearFeedsPage') . '/zcfsupd.js') .
|
||||
"<script type=\"text/javascript\"> \n//<![CDATA[\n" .
|
||||
' $(function(){if(!document.getElementById){return;} ' .
|
||||
" $('body').zoneclearFeedServer({blog_url:'" .
|
||||
|
@ -162,19 +154,24 @@ class zcfsPublicBehaviors
|
|||
*/
|
||||
class zcfsRsExtPosts extends rsExtPost
|
||||
{
|
||||
public static function zc()
|
||||
{
|
||||
return new zonclearFeedServer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get feed meta.
|
||||
*
|
||||
* @param record $rs record instance
|
||||
* @param dcRecord $rs record instance
|
||||
* @param string $info Feed info key
|
||||
* @return string Feed info value
|
||||
*/
|
||||
public static function zcFeed($rs, $info)
|
||||
{
|
||||
$meta = $rs->core->meta->getMetadata([
|
||||
$meta = dcCore::app()->meta->getMetadata([
|
||||
'post_id' => $rs->post_id,
|
||||
'meta_type' => 'zoneclearfeed_' . $info,
|
||||
'limit' => 1
|
||||
'limit' => 1,
|
||||
]);
|
||||
|
||||
return $meta->isEmpty() ? null : $meta->meta_id;
|
||||
|
@ -203,10 +200,10 @@ class zcfsRsExtPosts extends rsExtPost
|
|||
/**
|
||||
* Get author link from post to feed.
|
||||
*
|
||||
* @param record $rs record instance
|
||||
* @param dcRecord $rs record instance
|
||||
* @return string Author link
|
||||
*/
|
||||
public static function getAuthorLink($rs)
|
||||
public static function getAuthorLink(dcRecord $rs): string
|
||||
{
|
||||
$author = $rs->zcFeed('author');
|
||||
$site = $rs->zcFeed('site');
|
||||
|
@ -220,10 +217,10 @@ class zcfsRsExtPosts extends rsExtPost
|
|||
/**
|
||||
* Get author CN from post to feed.
|
||||
*
|
||||
* @param record $rs record instance
|
||||
* @param dcRecord $rs record instance
|
||||
* @return string Author CN
|
||||
*/
|
||||
public static function getAuthorCN($rs)
|
||||
public static function getAuthorCN(dcRecord $rs): string
|
||||
{
|
||||
$author = $rs->zcFeed('author');
|
||||
|
||||
|
@ -235,14 +232,14 @@ class zcfsRsExtPosts extends rsExtPost
|
|||
/**
|
||||
* Get post link from post to feed.
|
||||
*
|
||||
* @param record $rs record instance
|
||||
* @param dcRecord $rs record instance
|
||||
* @return string Post link
|
||||
*/
|
||||
public static function getURL($rs)
|
||||
public static function getURL(dcRecord $rs): string
|
||||
{
|
||||
$url = $rs->zcFeed('url');
|
||||
$types = @unserialize($rs->core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_post_title_redir);
|
||||
$full = is_array($types) && in_array($rs->core->url->type, $types);
|
||||
$types = @unserialize(dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_post_title_redir);
|
||||
$full = is_array($types) && in_array(dcCore::app()->url->type, $types);
|
||||
|
||||
return $url && $full ?
|
||||
zoneclearFeedServer::absoluteURL($rs->zcFeed('site'), $url) :
|
||||
|
@ -255,16 +252,16 @@ class zcfsRsExtPosts extends rsExtPost
|
|||
* @param record $rs record instance
|
||||
* @return string Post content
|
||||
*/
|
||||
public static function getContent($rs, $absolute_urls = false)
|
||||
public static function getContent(dcRecord $rs, bool $absolute_urls = false): string
|
||||
{
|
||||
$url = $rs->zcFeed('url');
|
||||
$sitename = $rs->zcFeed('sitename');
|
||||
$content = self::zcFeedBrother('getContent', [&$rs, $absolute_urls]);
|
||||
|
||||
if ($url && $sitename && $rs->post_type == 'post') {
|
||||
$types = @unserialize($rs->core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_post_full_tpl);
|
||||
$types = @unserialize(dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_post_full_tpl);
|
||||
|
||||
if (is_array($types) && in_array($rs->core->url->type, $types)) {
|
||||
if (is_array($types) && in_array(dcCore::app()->url->type, $types)) {
|
||||
return $content . sprintf(
|
||||
'<p class="zoneclear-original"><em>%s</em></p>',
|
||||
sprintf(__('Original post on <a href="%s">%s</a>'), $url, $sitename)
|
||||
|
@ -302,8 +299,7 @@ class zcfsUrlHandler extends dcUrlHandlers
|
|||
*/
|
||||
public static function zcFeedsPage($args)
|
||||
{
|
||||
global $core, $_ctx;
|
||||
$s = $core->blog->settings->zoneclearFeedServer;
|
||||
$s = dcCore::app()->blog->settings->zoneclearFeedServer;
|
||||
|
||||
# Not active
|
||||
if (!$s->zoneclearFeedServer_active) {
|
||||
|
@ -315,9 +311,9 @@ class zcfsUrlHandler extends dcUrlHandlers
|
|||
# Update feeds (from ajax or other post resquest)
|
||||
if ($args == '/zcfsupd' && 3 == $s->zoneclearFeedServer_bhv_pub_upd) {
|
||||
$msg = '';
|
||||
if (!empty($_POST['blogId']) && html::escapeJS($core->blog->id) == $_POST['blogId']) {
|
||||
if (!empty($_POST['blogId']) && html::escapeJS(dcCore::app()->blog->id) == $_POST['blogId']) {
|
||||
try {
|
||||
$zc = new zoneclearFeedServer($core);
|
||||
$zc = new zoneclearFeedServer();
|
||||
if ($zc->checkFeedsUpdate()) {
|
||||
$msg = sprintf(
|
||||
'<status>%s</status><message>s%</message>',
|
||||
|
@ -347,7 +343,7 @@ class zcfsUrlHandler extends dcUrlHandlers
|
|||
|
||||
# Server js
|
||||
} elseif ($args == '/zcfsupd.js' && 3 == $s->zoneclearFeedServer_bhv_pub_upd) {
|
||||
$core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__) . '/default-templates');
|
||||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), __DIR__ . '/default-templates');
|
||||
self::serveDocument(
|
||||
'zcfsupd.js',
|
||||
'text/javascript',
|
||||
|
@ -357,12 +353,12 @@ class zcfsUrlHandler extends dcUrlHandlers
|
|||
|
||||
# Server feeds description page
|
||||
} elseif (in_array($args, ['', '/']) && $s->zoneclearFeedServer_pub_active) {
|
||||
$tplset = $core->themes->moduleInfo($core->blog->settings->system->theme, 'tplset');
|
||||
$path = dirname(__FILE__) . '/default-templates/';
|
||||
$tplset = dcCore::app()->themes->moduleInfo(dcCore::app()->blog->settings->system->theme, 'tplset');
|
||||
$path = __DIR__ . '/default-templates/';
|
||||
if (!empty($tplset) && is_dir($path . $tplset)) {
|
||||
$core->tpl->setPath($core->tpl->getPath(), $path . $tplset);
|
||||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), $path . $tplset);
|
||||
} else {
|
||||
$core->tpl->setPath($core->tpl->getPath(), $path . DC_DEFAULT_TPLSET);
|
||||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), $path . DC_DEFAULT_TPLSET);
|
||||
}
|
||||
self::serveDocument('zcfeeds.html');
|
||||
}
|
||||
|
@ -417,19 +413,19 @@ class zcfsTemplate
|
|||
switch ($a['sortby']) {
|
||||
case 'name': $sortby = 'lowername';
|
||||
|
||||
break;
|
||||
break;
|
||||
case 'owner': $sortby = 'feed_owner';
|
||||
|
||||
break;
|
||||
break;
|
||||
case 'date': $sortby = 'feed_dt';
|
||||
|
||||
break;
|
||||
break;
|
||||
case 'update': $sortby = 'feed_upddt';
|
||||
|
||||
break;
|
||||
break;
|
||||
case 'id': $sortby = 'feed_id';
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isset($a['order']) && preg_match('/^(desc|asc)$/i', $a['order'])) {
|
||||
|
@ -439,12 +435,12 @@ break;
|
|||
|
||||
return
|
||||
'<?php ' . $p .
|
||||
'$_ctx->feeds_params = $zcfs_params;' . "\n" .
|
||||
'$zcfs = new zoneclearFeedServer($core);' . "\n" .
|
||||
'$_ctx->feeds = $zcfs->getFeeds($zcfs_params); unset($zcfs_params,$zcfs);' . "\n" .
|
||||
'dcCore::app()->ctx->feeds_params = $zcfs_params;' . "\n" .
|
||||
'$zcfs = new zoneclearFeedServer();' . "\n" .
|
||||
'dcCore::app()->ctx->feeds = $zcfs->getFeeds($zcfs_params); unset($zcfs_params,$zcfs);' . "\n" .
|
||||
"?>\n" .
|
||||
'<?php while ($_ctx->feeds->fetch()) : ?>' . $c . '<?php endwhile; ' .
|
||||
'$_ctx->feeds = null; $_ctx->feeds_params = null; ?>';
|
||||
'<?php while (dcCore::app()->ctx->feeds->fetch()) : ?>' . $c . '<?php endwhile; ' .
|
||||
'dcCore::app()->ctx->feeds = null; dcCore::app()->ctx->feeds_params = null; ?>';
|
||||
}
|
||||
|
||||
public static function FeedIf($a, $c)
|
||||
|
@ -456,50 +452,50 @@ break;
|
|||
if (isset($a['type'])) {
|
||||
$type = trim($a['type']);
|
||||
$type = !empty($type) ? $type : 'feed';
|
||||
$if[] = '$_ctx->feeds->feed_type == "' . addslashes($type) . '"';
|
||||
$if[] = 'dcCore::app()->ctx->feeds->feed_type == "' . addslashes($type) . '"';
|
||||
}
|
||||
if (isset($a['site_url'])) {
|
||||
$url = trim($a['feed_url']);
|
||||
if (substr($url, 0, 1) == '!') {
|
||||
$url = substr($url, 1);
|
||||
$if[] = '$_ctx->feeds->feed_url != "' . addslashes($url) . '"';
|
||||
$if[] = 'dcCore::app()->ctx->feeds->feed_url != "' . addslashes($url) . '"';
|
||||
} else {
|
||||
$if[] = '$_ctx->feeds->feed_url == "' . addslashes($url) . '"';
|
||||
$if[] = 'dcCore::app()->ctx->feeds->feed_url == "' . addslashes($url) . '"';
|
||||
}
|
||||
}
|
||||
if (isset($a['feed_url'])) {
|
||||
$url = trim($a['feed_feed']);
|
||||
if (substr($url, 0, 1) == '!') {
|
||||
$url = substr($url, 1);
|
||||
$if[] = '$_ctx->feeds->feed_feed != "' . addslashes($url) . '"';
|
||||
$if[] = 'dcCore::app()->ctx->feeds->feed_feed != "' . addslashes($url) . '"';
|
||||
} else {
|
||||
$if[] = '$_ctx->feeds->feed_feed == "' . addslashes($url) . '"';
|
||||
$if[] = 'dcCore::app()->ctx->feeds->feed_feed == "' . addslashes($url) . '"';
|
||||
}
|
||||
}
|
||||
if (isset($a['category'])) {
|
||||
$category = addslashes(trim($a['category']));
|
||||
if (substr($category, 0, 1) == '!') {
|
||||
$category = substr($category, 1);
|
||||
$if[] = '($_ctx->feeds->cat_url != "' . $category . '")';
|
||||
$if[] = '(dcCore::app()->ctx->feeds->cat_url != "' . $category . '")';
|
||||
} else {
|
||||
$if[] = '($_ctx->feeds->cat_url == "' . $category . '")';
|
||||
$if[] = '(dcCore::app()->ctx->feeds->cat_url == "' . $category . '")';
|
||||
}
|
||||
}
|
||||
if (isset($a['first'])) {
|
||||
$sign = (bool) $a['first'] ? '=' : '!';
|
||||
$if[] = '$_ctx->feeds->index() ' . $sign . '= 0';
|
||||
$if[] = 'dcCore::app()->ctx->feeds->index() ' . $sign . '= 0';
|
||||
}
|
||||
if (isset($a['odd'])) {
|
||||
$sign = (bool) $a['odd'] ? '=' : '!';
|
||||
$if[] = '($_ctx->feeds->index()+1)%2 ' . $sign . ' = 1';
|
||||
$if[] = '(dcCore::app()->ctx->feeds->index()+1)%2 ' . $sign . ' = 1';
|
||||
}
|
||||
if (isset($a['has_category'])) {
|
||||
$sign = (bool) $a['has_category'] ? '' : '!';
|
||||
$if[] = $sign . '$_ctx->feeds->cat_id';
|
||||
$if[] = $sign . 'dcCore::app()->ctx->feeds->cat_id';
|
||||
}
|
||||
if (isset($a['has_description'])) {
|
||||
$sign = (bool) $a['has_description'] ? '' : '!';
|
||||
$if[] = $sign . '$_ctx->feeds->feed_desc';
|
||||
$if[] = $sign . 'dcCore::app()->ctx->feeds->feed_desc';
|
||||
}
|
||||
|
||||
return empty($if) ?
|
||||
|
@ -513,7 +509,7 @@ break;
|
|||
$ret = html::escapeHTML($ret);
|
||||
|
||||
return
|
||||
'<?php if ($_ctx->feeds->index() == 0) { ' .
|
||||
'<?php if (dcCore::app()->ctx->feeds->index() == 0) { ' .
|
||||
"echo '" . addslashes($ret) . "'; } ?>";
|
||||
}
|
||||
|
||||
|
@ -523,79 +519,79 @@ break;
|
|||
$ret = html::escapeHTML($ret);
|
||||
|
||||
return
|
||||
'<?php if (($_ctx->feeds->index()+1)%2 == 1) { ' .
|
||||
'<?php if ((dcCore::app()->ctx->feeds->index()+1)%2 == 1) { ' .
|
||||
"echo '" . addslashes($ret) . "'; } ?>";
|
||||
}
|
||||
|
||||
public static function FeedDesc($a)
|
||||
{
|
||||
return self::getValue($a, '$_ctx->feeds->feed_desc');
|
||||
return self::getValue($a, 'dcCore::app()->ctx->feeds->feed_desc');
|
||||
}
|
||||
|
||||
public static function FeedOwner($a)
|
||||
{
|
||||
return self::getValue($a, '$_ctx->feeds->feed_owner');
|
||||
return self::getValue($a, 'dcCore::app()->ctx->feeds->feed_owner');
|
||||
}
|
||||
|
||||
public static function FeedCategory($a)
|
||||
{
|
||||
return self::getValue($a, '$_ctx->feeds->cat_title');
|
||||
return self::getValue($a, 'dcCore::app()->ctx->feeds->cat_title');
|
||||
}
|
||||
|
||||
public static function FeedCategoryID($a)
|
||||
{
|
||||
return self::getValue($a, '$_ctx->feeds->cat_id');
|
||||
return self::getValue($a, 'dcCore::app()->ctx->feeds->cat_id');
|
||||
}
|
||||
|
||||
public static function FeedCategoryURL($a)
|
||||
{
|
||||
return self::getValue($a, '$core->blog->url.$core->url->getBase(\'category\').\'/\'.html::sanitizeURL($_ctx->feeds->cat_url)');
|
||||
return self::getValue($a, 'dcCore::app()->blog->url.dcCore::app()->url->getBase(\'category\').\'/\'.html::sanitizeURL(dcCore::app()->ctx->feeds->cat_url)');
|
||||
}
|
||||
|
||||
public static function FeedCategoryShortURL($a)
|
||||
{
|
||||
return self::getValue($a, '$_ctx->feeds->cat_url');
|
||||
return self::getValue($a, 'dcCore::app()->ctx->feeds->cat_url');
|
||||
}
|
||||
|
||||
public static function FeedID($a)
|
||||
{
|
||||
return self::getValue($a, '$_ctx->feeds->feed_id');
|
||||
return self::getValue($a, 'dcCore::app()->ctx->feeds->feed_id');
|
||||
}
|
||||
|
||||
public static function FeedLang($a)
|
||||
{
|
||||
$f = $GLOBALS['core']->tpl->getFilters($a);
|
||||
$f = dcCore::app()->tpl->getFilters($a);
|
||||
|
||||
return empty($a['full']) ?
|
||||
'<?php echo ' . sprintf($f, '$_ctx->feeds->feed_lang') . '; ?>' :
|
||||
'<?php $langs = l10n::getISOcodes(); if (isset($langs[$_ctx->feeds->feed_lang])) { echo ' .
|
||||
sprintf($f, '$langs[$_ctx->feeds->feed_lang]') . '; } else { echo ' .
|
||||
sprintf($f, '$_ctx->feeds->feed_lang') . '; } unset($langs); ?>';
|
||||
'<?php echo ' . sprintf($f, 'dcCore::app()->ctx->feeds->feed_lang') . '; ?>' :
|
||||
'<?php $langs = l10n::getISOcodes(); if (isset($langs[dcCore::app()->ctx->feeds->feed_lang])) { echo ' .
|
||||
sprintf($f, '$langs[dcCore::app()->ctx->feeds->feed_lang]') . '; } else { echo ' .
|
||||
sprintf($f, 'dcCore::app()->ctx->feeds->feed_lang') . '; } unset($langs); ?>';
|
||||
}
|
||||
|
||||
public static function FeedName($a)
|
||||
{
|
||||
return self::getValue($a, '$_ctx->feeds->feed_name');
|
||||
return self::getValue($a, 'dcCore::app()->ctx->feeds->feed_name');
|
||||
}
|
||||
|
||||
public static function FeedSiteURL($a)
|
||||
{
|
||||
return self::getValue($a, '$_ctx->feeds->feed_url');
|
||||
return self::getValue($a, 'dcCore::app()->ctx->feeds->feed_url');
|
||||
}
|
||||
|
||||
public static function FeedFeedURL($a)
|
||||
{
|
||||
return self::getValue($a, '$_ctx->feeds->feed_feed');
|
||||
return self::getValue($a, 'dcCore::app()->ctx->feeds->feed_feed');
|
||||
}
|
||||
|
||||
public static function FeedsHeader($a, $c)
|
||||
{
|
||||
return '<?php if ($_ctx->feeds->isStart()) : ?>' . $c . '<?php endif; ?>';
|
||||
return '<?php if (dcCore::app()->ctx->feeds->isStart()) : ?>' . $c . '<?php endif; ?>';
|
||||
}
|
||||
|
||||
public static function FeedsFooter($a, $c)
|
||||
{
|
||||
return '<?php if ($_ctx->feeds->isEnd()) : ?>' . $c . '<?php endif; ?>';
|
||||
return '<?php if (dcCore::app()->ctx->feeds->isEnd()) : ?>' . $c . '<?php endif; ?>';
|
||||
}
|
||||
|
||||
public static function FeedsCount($a)
|
||||
|
@ -615,7 +611,7 @@ break;
|
|||
}
|
||||
|
||||
return
|
||||
"<?php \$fcount = \$_ctx->feeds->count(); \n" .
|
||||
"<?php \$fcount = dcCore::app()->ctx->feeds->count(); \n" .
|
||||
"if (\$fcount == 0) {\n" .
|
||||
" printf(__('" . $none . "'),\$fcount);\n" .
|
||||
"} elseif (\$fcount == 1) {\n" .
|
||||
|
@ -642,10 +638,12 @@ break;
|
|||
}
|
||||
|
||||
return
|
||||
"<?php \$fcount = 0; \$allfeeds = \$_ctx->feeds->zc->getFeeds(); \n" .
|
||||
"<?php \$fcount = 0; \n" .
|
||||
'$zc = new zoneclearFeedServer();' . "\n" .
|
||||
"\$allfeeds = \$zc->getFeeds(); \n" .
|
||||
"if (!\$allfeeds->isEmpty()) { \n" .
|
||||
' while ($allfeeds->fetch()) { ' .
|
||||
" \$fcount += (integer) \$_ctx->feeds->zc->getPostsByFeed(array('feed_id'=>\$allfeeds->feed_id),true)->f(0); " .
|
||||
" \$fcount += (integer) \$zc->getPostsByFeed(array('feed_id'=>\$allfeeds->feed_id),true)->f(0); " .
|
||||
" } \n" .
|
||||
"} \n" .
|
||||
"if (\$fcount == 0) {\n" .
|
||||
|
@ -674,7 +672,8 @@ break;
|
|||
}
|
||||
|
||||
return
|
||||
"<?php \$fcount = \$_ctx->feeds->zc->getPostsByFeed(array('feed_id'=>\$_ctx->feeds->feed_id),true)->f(0); \n" .
|
||||
"<?php \$zcfs = new zoneclearFeedServer(); \n" .
|
||||
"\$fcount = \$zc->getPostsByFeed(array('feed_id'=>dcCore::app()->ctx->feeds->feed_id),true)->f(0); \n" .
|
||||
"if (\$fcount == 0) {\n" .
|
||||
" printf(__('" . $none . "'),\$fcount);\n" .
|
||||
"} elseif (\$fcount == 1) {\n" .
|
||||
|
@ -686,7 +685,7 @@ break;
|
|||
|
||||
protected static function getValue($a, $v)
|
||||
{
|
||||
return '<?php echo ' . sprintf($GLOBALS['core']->tpl->getFilters($a), $v) . '; ?>';
|
||||
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($a), $v) . '; ?>';
|
||||
}
|
||||
|
||||
protected static function getOperator($op)
|
||||
|
@ -703,7 +702,7 @@ break;
|
|||
}
|
||||
}
|
||||
|
||||
$core->addBehavior('publicBreadcrumb', ['extZcfeeds', 'publicBreadcrumb']);
|
||||
dcCore::app()->addBehavior('publicBreadcrumb', ['extZcfeeds', 'publicBreadcrumb']);
|
||||
|
||||
class extZcfeeds
|
||||
{
|
||||
|
|
|
@ -104,7 +104,7 @@ $this->addDirectCallback(
|
|||
'delete feeds relations'
|
||||
);
|
||||
|
||||
function zoneclearfeedServerUninstall($core, $id)
|
||||
function zoneclearfeedServerUninstall($id)
|
||||
{
|
||||
if ($id != 'zoneclearFeedServer') {
|
||||
return null;
|
||||
|
|
40
_widgets.php
40
_widgets.php
|
@ -14,11 +14,11 @@ if (!defined('DC_RC_PATH')) {
|
|||
return null;
|
||||
}
|
||||
|
||||
$core->addBehavior(
|
||||
dcCore::app()->addBehavior(
|
||||
'initWidgets',
|
||||
['zoneclearFeedServerWidget', 'adminSource']
|
||||
);
|
||||
$core->addBehavior(
|
||||
dcCore::app()->addBehavior(
|
||||
'initWidgets',
|
||||
['zoneclearFeedServerWidget', 'adminNumber']
|
||||
);
|
||||
|
@ -33,7 +33,7 @@ class zoneclearFeedServerWidget
|
|||
/**
|
||||
* Widget configuration for sources list.
|
||||
*
|
||||
* @param dcWidget $w dcWidget instance
|
||||
* @param dcWidgets $w dcWidgets instance
|
||||
*/
|
||||
public static function adminSource($w)
|
||||
{
|
||||
|
@ -56,7 +56,7 @@ class zoneclearFeedServerWidget
|
|||
[
|
||||
__('Last update') => 'feed_upd_last',
|
||||
__('Name') => 'lowername',
|
||||
__('Create date') => 'feed_creadt'
|
||||
__('Create date') => 'feed_creadt',
|
||||
]
|
||||
)
|
||||
->setting(
|
||||
|
@ -66,7 +66,7 @@ class zoneclearFeedServerWidget
|
|||
'combo',
|
||||
[
|
||||
__('Ascending') => 'asc',
|
||||
__('Descending') => 'desc'
|
||||
__('Descending') => 'desc',
|
||||
]
|
||||
)
|
||||
->setting(
|
||||
|
@ -90,7 +90,7 @@ class zoneclearFeedServerWidget
|
|||
/**
|
||||
* Widget configuration for feeds info.
|
||||
*
|
||||
* @param dcWidget $w dcWidget instance
|
||||
* @param dcWidgets $w dcWidgets instance
|
||||
*/
|
||||
public static function adminNumber($w)
|
||||
{
|
||||
|
@ -148,15 +148,13 @@ class zoneclearFeedServerWidget
|
|||
*/
|
||||
public static function publicSource($w)
|
||||
{
|
||||
global $core;
|
||||
|
||||
if ($w->offline) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!$core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active
|
||||
|| $w->homeonly == 1 && !$core->url->isHome($core->url->type)
|
||||
|| $w->homeonly == 2 && $core->url->isHome($core->url->type)
|
||||
if (!dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active
|
||||
|| $w->homeonly == 1 && !dcCore::app()->url->isHome(dcCore::app()->url->type)
|
||||
|| $w->homeonly == 2 && dcCore::app()->url->isHome(dcCore::app()->url->type)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
@ -168,7 +166,7 @@ class zoneclearFeedServerWidget
|
|||
$p['limit'] = abs((int) $w->limit);
|
||||
$p['feed_status'] = 1;
|
||||
|
||||
$zc = new zoneclearFeedServer($core);
|
||||
$zc = new zoneclearFeedServer();
|
||||
$rs = $zc->getFeeds($p);
|
||||
|
||||
if ($rs->isEmpty()) {
|
||||
|
@ -187,10 +185,10 @@ class zoneclearFeedServerWidget
|
|||
$i++;
|
||||
}
|
||||
$pub = '';
|
||||
if ($w->pagelink && $core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_pub_active) {
|
||||
if ($w->pagelink && dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_pub_active) {
|
||||
$pub = sprintf(
|
||||
'<p><strong><a href="%s">%s</a></strong></p>',
|
||||
$core->blog->url . $core->url->getBase('zoneclearFeedsPage'),
|
||||
dcCore::app()->blog->url . dcCore::app()->url->getBase('zoneclearFeedsPage'),
|
||||
html::escapeHTML($w->pagelink)
|
||||
);
|
||||
}
|
||||
|
@ -211,20 +209,18 @@ class zoneclearFeedServerWidget
|
|||
*/
|
||||
public static function publicNumber($w)
|
||||
{
|
||||
global $core;
|
||||
|
||||
if ($w->offline) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active
|
||||
|| $w->homeonly == 1 && !$core->url->isHome($core->url->type)
|
||||
|| $w->homeonly == 2 && $core->url->isHome($core->url->type)
|
||||
if (!dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active
|
||||
|| $w->homeonly == 1 && !dcCore::app()->url->isHome(dcCore::app()->url->type)
|
||||
|| $w->homeonly == 2 && dcCore::app()->url->isHome(dcCore::app()->url->type)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$zc = new zoneclearFeedServer($core);
|
||||
$zc = new zoneclearFeedServer();
|
||||
$content = '';
|
||||
|
||||
# Feed
|
||||
|
@ -238,10 +234,10 @@ class zoneclearFeedServerWidget
|
|||
|
||||
$text = $count ? sprintf(__('one source', '%d sources', $count), $count) : __('no sources');
|
||||
|
||||
if ($core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_pub_active) {
|
||||
if (dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_pub_active) {
|
||||
$text = sprintf(
|
||||
'<a href="%s">%s</a>',
|
||||
$core->blog->url . $core->url->getBase('zoneclearFeedsPage'),
|
||||
dcCore::app()->blog->url . dcCore::app()->url->getBase('zoneclearFeedsPage'),
|
||||
$text
|
||||
);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
$opts = getopt('d:c:b:u:h');
|
||||
|
||||
function help($status = 0)
|
||||
function zchelp($status = 0)
|
||||
{
|
||||
echo
|
||||
"Options: \n" .
|
||||
|
@ -20,7 +20,7 @@ function help($status = 0)
|
|||
}
|
||||
|
||||
if (isset($opts['h'])) {
|
||||
help();
|
||||
zchelp();
|
||||
}
|
||||
|
||||
$dc_root = null;
|
||||
|
@ -47,17 +47,17 @@ if (isset($opts['b'])) {
|
|||
|
||||
if (!$dc_root || !is_dir($dc_root)) {
|
||||
fwrite(STDERR, "DotClear root path is not defined\n\n");
|
||||
help(1);
|
||||
zchelp(1);
|
||||
}
|
||||
|
||||
if (!$dc_conf || !is_readable($dc_conf)) {
|
||||
fwrite(STDERR, "DotClear configuration not found\n\n");
|
||||
help(1);
|
||||
zchelp(1);
|
||||
}
|
||||
|
||||
if (!$blog_id) {
|
||||
fwrite(STDERR, "Blog ID is not defined\n\n");
|
||||
help(1);
|
||||
zchelp(1);
|
||||
}
|
||||
|
||||
$_SERVER['DC_RC_PATH'] = $dc_conf;
|
||||
|
@ -69,23 +69,23 @@ unset($blog_id);
|
|||
require $dc_root . '/inc/prepend.php';
|
||||
unset($dc_root);
|
||||
|
||||
$core->setBlog(DC_BLOG_ID);
|
||||
if ($core->blog->id == null) {
|
||||
dcCore::app()->setBlog(DC_BLOG_ID);
|
||||
if (dcCore::app()->blog->id == null) {
|
||||
fwrite(STDERR, "Blog is not defined\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!isset($opts['u']) || !$core->auth->checkUser($opts['u'])) {
|
||||
if (!isset($opts['u']) || !dcCore::app()->auth->checkUser($opts['u'])) {
|
||||
fwrite(STDERR, "Unable to set user\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$core->plugins->loadModules(DC_PLUGINS_ROOT);
|
||||
dcCore::app()->plugins->loadModules(DC_PLUGINS_ROOT);
|
||||
|
||||
$core->blog->settings->addNamespace('zoneclearFeedServer');
|
||||
dcCore::app()->blog->settings->addNamespace('zoneclearFeedServer');
|
||||
|
||||
try {
|
||||
$zc = new zoneclearFeedServer($core);
|
||||
$zc = new zoneclearFeedServer();
|
||||
$zc->checkFeedsUpdate();
|
||||
} catch (Exception $e) {
|
||||
fwrite(STDERR, $e->getMessage() . "\n");
|
||||
|
|
|
@ -10,17 +10,17 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class zcfsFeedsActionsPage extends dcActionsPage
|
||||
class zcfsFeedsActionsPage extends dcActions
|
||||
{
|
||||
public $zcfs;
|
||||
|
||||
public function __construct(dcCore $core, $uri, $redirect_args = [])
|
||||
public function __construct($uri, $redirect_args = [])
|
||||
{
|
||||
$this->zcfs = new zoneclearFeedServer($core);
|
||||
$this->zcfs = new zoneclearFeedServer();
|
||||
|
||||
parent::__construct($core, $uri, $redirect_args);
|
||||
parent::__construct($uri, $redirect_args);
|
||||
$this->redirect_fields = [
|
||||
'sortby', 'order', 'page', 'nb'
|
||||
'sortby', 'order', 'page', 'nb',
|
||||
];
|
||||
$this->field_entries = 'feeds';
|
||||
$this->caller_title = __('Feeds');
|
||||
|
@ -29,8 +29,8 @@ class zcfsFeedsActionsPage extends dcActionsPage
|
|||
|
||||
protected function loadDefaults()
|
||||
{
|
||||
zcfsDefaultFeedsActions::zcfsFeedsActionsPage($this->core, $this);
|
||||
$this->core->callBehavior('zcfsFeedsActionsPage', $this->core, $this);
|
||||
zcfsDefaultFeedsActions::zcfsFeedsActionsPage($this);
|
||||
dcCore::app()->callBehavior('zcfsFeedsActionsPage', $this);
|
||||
}
|
||||
|
||||
public function beginPage($breadcrumb = '', $head = '')
|
||||
|
@ -52,12 +52,12 @@ class zcfsFeedsActionsPage extends dcActionsPage
|
|||
|
||||
public function error(Exception $e)
|
||||
{
|
||||
$this->core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
$this->beginPage(
|
||||
dcPage::breadcrumb([
|
||||
html::escapeHTML($this->core->blog->name) => '',
|
||||
$this->getCallerTitle() => $this->getRedirection(true),
|
||||
__('Feeds actions') => ''
|
||||
html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||
$this->getCallerTitle() => $this->getRedirection(true),
|
||||
__('Feeds actions') => '',
|
||||
])
|
||||
);
|
||||
$this->endPage();
|
||||
|
@ -74,8 +74,8 @@ class zcfsFeedsActionsPage extends dcActionsPage
|
|||
}
|
||||
$this->rs = $feeds;
|
||||
} else {
|
||||
$this->rs = $this->core->con->select(
|
||||
'SELECT blog_id FROM ' . $this->core->prefix . 'blog WHERE false'
|
||||
$this->rs = dcCore::app()->con->select(
|
||||
'SELECT blog_id FROM ' . dcCore::app()->prefix . 'blog WHERE false'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class zcfsFeedsActionsPage extends dcActionsPage
|
|||
*/
|
||||
class zcfsDefaultFeedsActions
|
||||
{
|
||||
public static function zcfsFeedsActionsPage(dcCore $core, zcfsFeedsActionsPage $ap)
|
||||
public static function zcfsFeedsActionsPage(zcfsFeedsActionsPage $ap)
|
||||
{
|
||||
$ap->addAction(
|
||||
[__('Change category') => 'changecat'],
|
||||
|
@ -125,7 +125,7 @@ class zcfsDefaultFeedsActions
|
|||
);
|
||||
}
|
||||
|
||||
public static function doEnableFeed(dcCore $core, zcfsFeedsActionsPage $ap, $post)
|
||||
public static function doEnableFeed(zcfsFeedsActionsPage $ap, $post)
|
||||
{
|
||||
$enable = $ap->getAction() == 'enablefeed';
|
||||
$ids = $ap->getIDs();
|
||||
|
@ -138,7 +138,7 @@ class zcfsDefaultFeedsActions
|
|||
$ap->zcfs->enableFeed($id, $enable);
|
||||
}
|
||||
|
||||
dcPage::addSuccessNotice(sprintf(
|
||||
dcAdminNotices::addSuccessNotice(sprintf(
|
||||
$enable ?
|
||||
__(
|
||||
'%d feed has been successfully enabled.',
|
||||
|
@ -156,14 +156,14 @@ class zcfsDefaultFeedsActions
|
|||
$ap->redirect(true);
|
||||
}
|
||||
|
||||
public static function doDeletePost(dcCore $core, zcfsFeedsActionsPage $ap, $post)
|
||||
public static function doDeletePost(zcfsFeedsActionsPage $ap, $post)
|
||||
{
|
||||
$types = [
|
||||
'zoneclearfeed_url',
|
||||
'zoneclearfeed_author',
|
||||
'zoneclearfeed_site',
|
||||
'zoneclearfeed_sitename',
|
||||
'zoneclearfeed_id'
|
||||
'zoneclearfeed_id',
|
||||
];
|
||||
|
||||
$ids = $ap->getIDs();
|
||||
|
@ -174,26 +174,26 @@ class zcfsDefaultFeedsActions
|
|||
|
||||
foreach ($ids as $id) {
|
||||
$posts = $ap->zcfs->getPostsByFeed([
|
||||
'feed_id' => $id
|
||||
'feed_id' => $id,
|
||||
]);
|
||||
|
||||
while ($posts->fetch()) {
|
||||
$core->blog->delPost($posts->post_id);
|
||||
$core->con->execute(
|
||||
'DELETE FROM ' . $core->prefix . 'meta ' .
|
||||
dcCore::app()->blog->delPost($posts->post_id);
|
||||
dcCore::app()->con->execute(
|
||||
'DELETE FROM ' . dcCore::app()->prefix . dcMeta::META_TABLE_NAME . ' ' .
|
||||
'WHERE post_id = ' . $posts->post_id . ' ' .
|
||||
'AND meta_type ' . $core->con->in($types) . ' '
|
||||
'AND meta_type ' . dcCore::app()->con->in($types) . ' '
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
dcAdminNotices::addSuccessNotice(
|
||||
__('Entries have been successfully deleted.')
|
||||
);
|
||||
$ap->redirect(true);
|
||||
}
|
||||
|
||||
public static function doDeleteFeed(dcCore $core, zcfsFeedsActionsPage $ap, $post)
|
||||
public static function doDeleteFeed(zcfsFeedsActionsPage $ap, $post)
|
||||
{
|
||||
$ids = $ap->getIDs();
|
||||
|
||||
|
@ -205,7 +205,7 @@ class zcfsDefaultFeedsActions
|
|||
$ap->zcfs->delFeed($id);
|
||||
}
|
||||
|
||||
dcPage::addSuccessNotice(sprintf(
|
||||
dcAdminNotices::addSuccessNotice(sprintf(
|
||||
__(
|
||||
'%d feed has been successfully deleted.',
|
||||
'%d feeds have been successfully deleted.',
|
||||
|
@ -216,7 +216,7 @@ class zcfsDefaultFeedsActions
|
|||
$ap->redirect(true);
|
||||
}
|
||||
|
||||
public static function doUpdateFeed(dcCore $core, zcfsFeedsActionsPage $ap, $post)
|
||||
public static function doUpdateFeed(zcfsFeedsActionsPage $ap, $post)
|
||||
{
|
||||
$ids = $ap->getIDs();
|
||||
|
||||
|
@ -228,7 +228,7 @@ class zcfsDefaultFeedsActions
|
|||
$ap->zcfs->checkFeedsUpdate($id, true);
|
||||
}
|
||||
|
||||
dcPage::addSuccessNotice(sprintf(
|
||||
dcAdminNotices::addSuccessNotice(sprintf(
|
||||
__(
|
||||
'%d feed has been successfully updated.',
|
||||
'%d feeds have been successfully updated.',
|
||||
|
@ -239,7 +239,7 @@ class zcfsDefaultFeedsActions
|
|||
$ap->redirect(true);
|
||||
}
|
||||
|
||||
public static function doResetUpdate(dcCore $core, zcfsFeedsActionsPage $ap, $post)
|
||||
public static function doResetUpdate(zcfsFeedsActionsPage $ap, $post)
|
||||
{
|
||||
$ids = $ap->getIDs();
|
||||
|
||||
|
@ -254,7 +254,7 @@ class zcfsDefaultFeedsActions
|
|||
$ap->zcfs->checkFeedsUpdate($id, true);
|
||||
}
|
||||
|
||||
dcPage::addSuccessNotice(sprintf(
|
||||
dcAdminNotices::addSuccessNotice(sprintf(
|
||||
__(
|
||||
'Last update of %s feed successfully reseted.',
|
||||
'Last update of %s feeds successfully reseted.',
|
||||
|
@ -265,7 +265,7 @@ class zcfsDefaultFeedsActions
|
|||
$ap->redirect(true);
|
||||
}
|
||||
|
||||
public static function doChangeCategory(dcCore $core, zcfsFeedsActionsPage $ap, $post)
|
||||
public static function doChangeCategory(zcfsFeedsActionsPage $ap, $post)
|
||||
{
|
||||
if (isset($post['upd_cat_id'])) {
|
||||
$ids = $ap->getIDs();
|
||||
|
@ -282,7 +282,7 @@ class zcfsDefaultFeedsActions
|
|||
$ap->zcfs->updFeed($id, $cur);
|
||||
}
|
||||
|
||||
dcPage::addSuccessNotice(sprintf(
|
||||
dcAdminNotices::addSuccessNotice(sprintf(
|
||||
__(
|
||||
'Category of %s feed successfully changed.',
|
||||
'Category of %s feeds successfully changed.',
|
||||
|
@ -293,15 +293,15 @@ class zcfsDefaultFeedsActions
|
|||
$ap->redirect(true);
|
||||
} else {
|
||||
$categories_combo = dcAdminCombos::getCategoriesCombo(
|
||||
$core->blog->getCategories()
|
||||
dcCore::app()->blog->getCategories()
|
||||
);
|
||||
|
||||
$ap->beginPage(
|
||||
dcPage::breadcrumb([
|
||||
html::escapeHTML($core->blog->name) => '',
|
||||
__('Feeds server') => '',
|
||||
$ap->getCallerTitle() => $ap->getRedirection(true),
|
||||
__('Change category for this selection') => ''
|
||||
html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||
__('Feeds server') => '',
|
||||
$ap->getCallerTitle() => $ap->getRedirection(true),
|
||||
__('Change category for this selection') => '',
|
||||
])
|
||||
);
|
||||
|
||||
|
@ -310,7 +310,7 @@ class zcfsDefaultFeedsActions
|
|||
$ap->getCheckboxes() .
|
||||
'<p><label for="upd_cat_id" class="classic">' . __('Category:') . '</label> ' .
|
||||
form::combo(['upd_cat_id'], $categories_combo, '') .
|
||||
$core->formNonce() .
|
||||
dcCore::app()->formNonce() .
|
||||
$ap->getHiddenFields() .
|
||||
form::hidden(['action'], 'changecat') .
|
||||
'<input type="submit" value="' . __('Save') . '" /></p>' .
|
||||
|
@ -320,7 +320,7 @@ class zcfsDefaultFeedsActions
|
|||
}
|
||||
}
|
||||
|
||||
public static function doChangeInterval(dcCore $core, zcfsFeedsActionsPage $ap, $post)
|
||||
public static function doChangeInterval(zcfsFeedsActionsPage $ap, $post)
|
||||
{
|
||||
if (isset($post['upd_upd_int'])) {
|
||||
$ids = $ap->getIDs();
|
||||
|
@ -337,7 +337,7 @@ class zcfsDefaultFeedsActions
|
|||
$ap->zcfs->updFeed($id, $cur);
|
||||
}
|
||||
|
||||
dcPage::addSuccessNotice(sprintf(
|
||||
dcAdminNotices::addSuccessNotice(sprintf(
|
||||
__(
|
||||
'Update frequency of %s feed successfully changed.',
|
||||
'Update frequency of %s feeds successfully changed.',
|
||||
|
@ -350,10 +350,10 @@ class zcfsDefaultFeedsActions
|
|||
$ap->beginPage(
|
||||
dcPage::breadcrumb(
|
||||
[
|
||||
html::escapeHTML($core->blog->name) => '',
|
||||
html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||
__('Feeds server') => '',
|
||||
$ap->getCallerTitle() => $ap->getRedirection(true),
|
||||
__('Change update frequency for this selection') => ''
|
||||
__('Change update frequency for this selection') => '',
|
||||
]
|
||||
)
|
||||
);
|
||||
|
@ -363,7 +363,7 @@ class zcfsDefaultFeedsActions
|
|||
$ap->getCheckboxes() .
|
||||
'<p><label for="upd_upd_int" class="classic">' . __('Frequency:') . '</label> ' .
|
||||
form::combo(['upd_upd_int'], $ap->zcfs->getAllUpdateInterval(), '') .
|
||||
$core->formNonce() .
|
||||
dcCore::app()->formNonce() .
|
||||
$ap->getHiddenFields() .
|
||||
form::hidden(['action'], 'changeint') .
|
||||
'<input type="submit" value="' . __('Save') . '" /></p>' .
|
||||
|
|
|
@ -25,23 +25,20 @@ class zoneclearFeedServer
|
|||
public static $nethttp_agent = 'zoneclearFeedServer - http://zoneclear.org';
|
||||
public static $nethttp_maxredirect = 2;
|
||||
|
||||
public $core;
|
||||
public $con;
|
||||
private $blog;
|
||||
private $table;
|
||||
private $lock = null;
|
||||
private $user = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param dcCore $core dcCore instance
|
||||
*/
|
||||
public function __construct(dcCore $core)
|
||||
public function __construct()
|
||||
{
|
||||
$this->core = $core;
|
||||
$this->con = $core->con;
|
||||
$this->blog = $core->con->escape($core->blog->id);
|
||||
$this->table = $core->prefix . 'zc_feed';
|
||||
$this->con = dcCore::app()->con;
|
||||
$this->blog = dcCore::app()->con->escape(dcCore::app()->blog->id);
|
||||
$this->table = dcCore::app()->prefix . 'zc_feed';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,7 +84,7 @@ class zoneclearFeedServer
|
|||
}
|
||||
|
||||
# --BEHAVIOR-- zoneclearFeedServerAfterUpdFeed
|
||||
$this->core->callBehavior('zoneclearFeedServerAfterUpdFeed', $cur, $id);
|
||||
dcCore::app()->callBehavior('zoneclearFeedServerAfterUpdFeed', $cur, $id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,7 +114,7 @@ class zoneclearFeedServer
|
|||
}
|
||||
|
||||
# --BEHAVIOR-- zoneclearFeedServerAfterAddFeed
|
||||
$this->core->callBehavior('zoneclearFeedServerAfterAddFeed', $cur);
|
||||
dcCore::app()->callBehavior('zoneclearFeedServerAfterAddFeed', $cur);
|
||||
|
||||
return $cur->feed_id;
|
||||
}
|
||||
|
@ -161,7 +158,7 @@ class zoneclearFeedServer
|
|||
}
|
||||
|
||||
# --BEHAVIOR-- zoneclearFeedServerAfterEnableFeed
|
||||
$this->core->callBehavior('zoneclearFeedServerAfterEnableFeed', $id, $enable, $time);
|
||||
dcCore::app()->callBehavior('zoneclearFeedServerAfterEnableFeed', $id, $enable, $time);
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -179,7 +176,7 @@ class zoneclearFeedServer
|
|||
}
|
||||
|
||||
# --BEHAVIOR-- zoneclearFeedServerBeforeDelFeed
|
||||
$this->core->callBehavior('zoneclearFeedServerBeforeDelFeed', $id);
|
||||
dcCore::app()->callBehavior('zoneclearFeedServerBeforeDelFeed', $id);
|
||||
|
||||
$this->con->execute(sprintf(
|
||||
"DELETE FROM %s WHERE feed_id = %s AND blog_id = '%s' ",
|
||||
|
@ -195,7 +192,7 @@ class zoneclearFeedServer
|
|||
*
|
||||
* @param array $params Query params
|
||||
* @param boolean $count_only Return only result count
|
||||
* @return record record instance
|
||||
* @return null|dcRecord record instance
|
||||
*/
|
||||
public function getPostsByFeed($params = [], $count_only = false)
|
||||
{
|
||||
|
@ -203,10 +200,11 @@ class zoneclearFeedServer
|
|||
return null;
|
||||
}
|
||||
|
||||
$sql = new dcSelectStatement($this->core, 'zcfs');
|
||||
$sql->join((new dcJoinStatement($this->core, 'zcfs'))
|
||||
$sql = new dcSelectStatement();
|
||||
$sql->join(
|
||||
(new dcJoinStatement())
|
||||
->type('LEFT')
|
||||
->from($this->core->prefix . 'meta F')
|
||||
->from(dcCore::app()->prefix . dcMeta::META_TABLE_NAME . ' F')
|
||||
->on('P.post_id = F.post_id')
|
||||
->statement()
|
||||
);
|
||||
|
@ -217,7 +215,7 @@ class zoneclearFeedServer
|
|||
|
||||
unset($params['feed_id']);
|
||||
|
||||
return $this->core->blog->getPosts($params, $count_only, $sql);
|
||||
return dcCore::app()->blog->getPosts($params, $count_only, $sql);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -225,7 +223,7 @@ class zoneclearFeedServer
|
|||
*
|
||||
* @param array $params Query params
|
||||
* @param boolean $count_only Return only result count
|
||||
* @return record record instance
|
||||
* @return dcRecord record instance
|
||||
*/
|
||||
public function getFeeds($params = [], $count_only = false)
|
||||
{
|
||||
|
@ -249,7 +247,7 @@ class zoneclearFeedServer
|
|||
}
|
||||
|
||||
$strReq .= 'FROM ' . $this->table . ' Z ' .
|
||||
'LEFT OUTER JOIN ' . $this->core->prefix . 'category C ON Z.cat_id = C.cat_id ';
|
||||
'LEFT OUTER JOIN ' . dcCore::app()->prefix . 'category C ON Z.cat_id = C.cat_id ';
|
||||
|
||||
if (!empty($params['from'])) {
|
||||
$strReq .= $params['from'] . ' ';
|
||||
|
@ -304,7 +302,6 @@ class zoneclearFeedServer
|
|||
}
|
||||
|
||||
$rs = $this->con->select($strReq);
|
||||
$rs->zc = $this;
|
||||
|
||||
return $rs;
|
||||
}
|
||||
|
@ -312,7 +309,7 @@ class zoneclearFeedServer
|
|||
/**
|
||||
* Get next table id.
|
||||
*
|
||||
* @return record record instance
|
||||
* @return integer Next id
|
||||
*/
|
||||
private function getNextId()
|
||||
{
|
||||
|
@ -409,9 +406,9 @@ class zoneclearFeedServer
|
|||
return false;
|
||||
}
|
||||
|
||||
dt::setTZ($this->core->blog->settings->system->blog_timezone);
|
||||
dt::setTZ(dcCore::app()->blog->settings->system->blog_timezone);
|
||||
$time = time();
|
||||
$s = $this->core->blog->settings->zoneclearFeedServer;
|
||||
$s = dcCore::app()->blog->settings->zoneclearFeedServer;
|
||||
|
||||
# All feeds or only one (from admin)
|
||||
$f = !$id ?
|
||||
|
@ -435,13 +432,13 @@ class zoneclearFeedServer
|
|||
}
|
||||
$i = 0;
|
||||
|
||||
$cur_post = $this->con->openCursor($this->core->prefix . 'post');
|
||||
$cur_meta = $this->con->openCursor($this->core->prefix . 'meta');
|
||||
$cur_post = $this->con->openCursor(dcCore::app()->prefix . dcBlog::POST_TABLE_NAME);
|
||||
$cur_meta = $this->con->openCursor(dcCore::app()->prefix . dcMeta::META_TABLE_NAME);
|
||||
|
||||
while ($f->fetch()) {
|
||||
# Check if feed need update
|
||||
if ($id || $i < $limit && $f->feed_status == 1
|
||||
&& $time > $f->feed_upd_last + $f->feed_upd_int
|
||||
&& $time > $f->feed_upd_last + $f->feed_upd_int
|
||||
) {
|
||||
$i++;
|
||||
$feed = self::readFeed($f->feed_feed);
|
||||
|
@ -501,8 +498,8 @@ class zoneclearFeedServer
|
|||
# Check if entry exists
|
||||
$old_post = $this->con->select(
|
||||
'SELECT P.post_id, P.post_status ' .
|
||||
'FROM ' . $this->core->prefix . 'post P ' .
|
||||
'INNER JOIN ' . $this->core->prefix . 'meta M ' .
|
||||
'FROM ' . dcCore::app()->prefix . dcBlog::POST_TABLE_NAME . ' P ' .
|
||||
'INNER JOIN ' . dcCore::app()->prefix . dcMeta::META_TABLE_NAME . ' M ' .
|
||||
'ON P.post_id = M.post_id ' .
|
||||
"WHERE blog_id='" . $this->blog . "' " .
|
||||
"AND meta_type = 'zoneclearfeed_url' " .
|
||||
|
@ -516,6 +513,7 @@ class zoneclearFeedServer
|
|||
$cur_post->cat_id = $f->cat_id;
|
||||
}
|
||||
$post_content = $item->content ? $item->content : $item->description;
|
||||
$cur_post->post_format = 'xhtml';
|
||||
$cur_post->post_content = html::absoluteURLs($post_content, $feed->link);
|
||||
$cur_post->post_title = $item->title ? $item->title : text::cutString(html::clean($cur_post->post_content), 60);
|
||||
$creator = $item->creator ? $item->creator : $f->feed_owner;
|
||||
|
@ -524,25 +522,25 @@ class zoneclearFeedServer
|
|||
# Create entry
|
||||
if ($old_post->isEmpty()) {
|
||||
# Post
|
||||
$cur_post->user_id = $this->core->auth->userID();
|
||||
$cur_post->user_id = dcCore::app()->auth->userID();
|
||||
$cur_post->post_format = 'xhtml';
|
||||
$cur_post->post_status = (int) $s->zoneclearFeedServer_post_status_new;
|
||||
$cur_post->post_open_comment = 0;
|
||||
$cur_post->post_open_tb = 0;
|
||||
|
||||
# --BEHAVIOR-- zoneclearFeedServerBeforePostCreate
|
||||
$this->core->callBehavior(
|
||||
dcCore::app()->callBehavior(
|
||||
'zoneclearFeedServerBeforePostCreate',
|
||||
$cur_post
|
||||
);
|
||||
|
||||
$post_id = $this->core->auth->sudo(
|
||||
[$this->core->blog, 'addPost'],
|
||||
$post_id = dcCore::app()->auth->sudo(
|
||||
[dcCore::app()->blog, 'addPost'],
|
||||
$cur_post
|
||||
);
|
||||
|
||||
# --BEHAVIOR-- zoneclearFeedServerAfterPostCreate
|
||||
$this->core->callBehavior(
|
||||
dcCore::app()->callBehavior(
|
||||
'zoneclearFeedServerAfterPostCreate',
|
||||
$cur_post,
|
||||
$post_id
|
||||
|
@ -553,38 +551,39 @@ class zoneclearFeedServer
|
|||
$is_new_published_entry = true;
|
||||
}
|
||||
|
||||
# Update entry
|
||||
# Update entry
|
||||
} else {
|
||||
$post_id = $old_post->post_id;
|
||||
|
||||
# --BEHAVIOR-- zoneclearFeedServerBeforePostUpdate
|
||||
$this->core->callBehavior(
|
||||
dcCore::app()->callBehavior(
|
||||
'zoneclearFeedServerBeforePostUpdate',
|
||||
$cur_post,
|
||||
$post_id
|
||||
);
|
||||
|
||||
$this->core->auth->sudo(
|
||||
[$this->core->blog, 'updPost'],
|
||||
dcCore::app()->auth->sudo(
|
||||
[dcCore::app()->blog, 'updPost'],
|
||||
$post_id,
|
||||
$cur_post
|
||||
);
|
||||
|
||||
# Quick delete old meta
|
||||
$this->con->execute(
|
||||
'DELETE FROM ' . $this->core->prefix . 'meta ' .
|
||||
'DELETE FROM ' . dcCore::app()->prefix . dcMeta::META_TABLE_NAME . ' ' .
|
||||
'WHERE post_id = ' . $post_id . ' ' .
|
||||
"AND meta_type LIKE 'zoneclearfeed_%' "
|
||||
);
|
||||
|
||||
# Delete old tags
|
||||
$this->core->auth->sudo(
|
||||
[$this->core->meta, 'delPostMeta'],
|
||||
dcCore::app()->auth->sudo(
|
||||
[dcCore::app()->meta, 'delPostMeta'],
|
||||
$post_id,
|
||||
'tag'
|
||||
);
|
||||
|
||||
# --BEHAVIOR-- zoneclearFeedServerAfterPostUpdate
|
||||
$this->core->callBehavior(
|
||||
dcCore::app()->callBehavior(
|
||||
'zoneclearFeedServerAfterPostUpdate',
|
||||
$cur_post,
|
||||
$post_id
|
||||
|
@ -598,64 +597,68 @@ class zoneclearFeedServer
|
|||
$cur_meta->clean();
|
||||
$cur_meta->post_id = $post_id;
|
||||
$cur_meta->meta_type = 'zoneclearfeed_url';
|
||||
$cur_meta->meta_id = $meta->url = $item_link;
|
||||
$cur_meta->meta_id = $meta->url = $item_link;
|
||||
$cur_meta->insert();
|
||||
|
||||
$cur_meta->clean();
|
||||
$cur_meta->post_id = $post_id;
|
||||
$cur_meta->meta_type = 'zoneclearfeed_author';
|
||||
$cur_meta->meta_id = $meta->author = $creator;
|
||||
$cur_meta->meta_id = $meta->author = $creator;
|
||||
$cur_meta->insert();
|
||||
|
||||
$cur_meta->clean();
|
||||
$cur_meta->post_id = $post_id;
|
||||
$cur_meta->meta_type = 'zoneclearfeed_site';
|
||||
$cur_meta->meta_id = $meta->site = $f->feed_url;
|
||||
$cur_meta->meta_id = $meta->site = $f->feed_url;
|
||||
$cur_meta->insert();
|
||||
|
||||
$cur_meta->clean();
|
||||
$cur_meta->post_id = $post_id;
|
||||
$cur_meta->meta_type = 'zoneclearfeed_sitename';
|
||||
$cur_meta->meta_id = $meta->sitename = $f->feed_name;
|
||||
$cur_meta->meta_id = $meta->sitename = $f->feed_name;
|
||||
$cur_meta->insert();
|
||||
|
||||
$cur_meta->clean();
|
||||
$cur_meta->post_id = $post_id;
|
||||
$cur_meta->meta_type = 'zoneclearfeed_id';
|
||||
$cur_meta->meta_id = $meta->id = $f->feed_id;
|
||||
$cur_meta->meta_id = $meta->id = $f->feed_id;
|
||||
$cur_meta->insert();
|
||||
|
||||
# Add new tags
|
||||
$tags = $this->core->meta->splitMetaValues($f->feed_tags);
|
||||
$tags = dcCore::app()->meta->splitMetaValues($f->feed_tags);
|
||||
if ($f->feed_get_tags) {
|
||||
|
||||
# Some feed subjects contains more than one tag
|
||||
foreach ($item->subject as $subjects) {
|
||||
$tmp = $this->core->meta->splitMetaValues($subjects);
|
||||
$tmp = dcCore::app()->meta->splitMetaValues($subjects);
|
||||
$tags = array_merge($tags, $tmp);
|
||||
}
|
||||
$tags = array_unique($tags);
|
||||
}
|
||||
$formated_tags = [];
|
||||
foreach ($tags as $tag) {
|
||||
|
||||
# Change tags case
|
||||
switch ((int) $s->zoneclearFeedServer_tag_case) {
|
||||
case 3: $tag = strtoupper($tag);
|
||||
|
||||
break;
|
||||
break;
|
||||
case 2: $tag = strtolower($tag);
|
||||
|
||||
break;
|
||||
break;
|
||||
case 1: $tag = ucfirst(strtolower($tag));
|
||||
|
||||
break;
|
||||
break;
|
||||
default: /* do nothing */ break;
|
||||
}
|
||||
if (!in_array($tag, $formated_tags)) {
|
||||
$formated_tags[] = $tag;
|
||||
$this->core->auth->sudo(
|
||||
[$this->core->meta, 'setPostMeta'],
|
||||
dcCore::app()->auth->sudo(
|
||||
[dcCore::app()->meta, 'delPostMeta'],
|
||||
$post_id,
|
||||
'tag',
|
||||
dcMeta::sanitizeMetaID($tag)
|
||||
);
|
||||
dcCore::app()->auth->sudo(
|
||||
[dcCore::app()->meta, 'setPostMeta'],
|
||||
$post_id,
|
||||
'tag',
|
||||
dcMeta::sanitizeMetaID($tag)
|
||||
|
@ -665,9 +668,8 @@ break;
|
|||
$meta->tags = $formated_tags;
|
||||
|
||||
# --BEHAVIOR-- zoneclearFeedServerAfterFeedUpdate
|
||||
$this->core->callBehavior(
|
||||
dcCore::app()->callBehavior(
|
||||
'zoneclearFeedServerAfterFeedUpdate',
|
||||
$this->core,
|
||||
$is_new_published_entry,
|
||||
$cur_post,
|
||||
$meta
|
||||
|
@ -700,13 +702,15 @@ break;
|
|||
{
|
||||
# Enable
|
||||
if ($enable) {
|
||||
if (!$this->core->auth->checkUser($enable)) {
|
||||
$this->user = dcCore::app()->auth->userID();
|
||||
if (!dcCore::app()->auth->checkUser($enable)) {
|
||||
throw new Exception('Unable to set user');
|
||||
}
|
||||
# Disable
|
||||
# Disable
|
||||
} else {
|
||||
$this->core->auth = null;
|
||||
$this->core->auth = new dcAuth($this->core);
|
||||
dcCore::app()->auth = null;
|
||||
dcCore::app()->auth = new dcAuth();
|
||||
dcCore::app()->auth->checkUser($this->user);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -736,7 +740,7 @@ break;
|
|||
*/
|
||||
private function trigger()
|
||||
{
|
||||
$this->core->blog->triggerBlog();
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -794,7 +798,7 @@ break;
|
|||
{
|
||||
return [
|
||||
__('Disabled') => '0',
|
||||
__('Enabled') => '1'
|
||||
__('Enabled') => '1',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -811,7 +815,7 @@ break;
|
|||
__('Two times per day') => 43200,
|
||||
__('Every day') => 86400,
|
||||
__('Every two days') => 172800,
|
||||
__('Every week') => 604800
|
||||
__('Every week') => 604800,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -827,7 +831,7 @@ break;
|
|||
# Get super admins
|
||||
$rs = $this->con->select(
|
||||
'SELECT user_id, user_super, user_name, user_firstname, user_displayname ' .
|
||||
'FROM ' . $this->con->escapeSystem($this->core->prefix . 'user') . ' ' .
|
||||
'FROM ' . $this->con->escapeSystem(dcCore::app()->prefix . 'user') . ' ' .
|
||||
'WHERE user_super = 1 AND user_status = 1 '
|
||||
);
|
||||
|
||||
|
@ -846,8 +850,8 @@ break;
|
|||
# Get admins
|
||||
$rs = $this->con->select(
|
||||
'SELECT U.user_id, U.user_super, U.user_name, U.user_firstname, U.user_displayname ' .
|
||||
'FROM ' . $this->con->escapeSystem($this->core->prefix . 'user') . ' U ' .
|
||||
'LEFT JOIN ' . $this->con->escapeSystem($this->core->prefix . 'permissions') . ' P ' .
|
||||
'FROM ' . $this->con->escapeSystem(dcCore::app()->prefix . 'user') . ' U ' .
|
||||
'LEFT JOIN ' . $this->con->escapeSystem(dcCore::app()->prefix . 'permissions') . ' P ' .
|
||||
'ON U.user_id=P.user_id ' .
|
||||
'WHERE U.user_status = 1 ' .
|
||||
"AND P.blog_id = '" . $this->blog . "' " .
|
||||
|
@ -872,15 +876,14 @@ break;
|
|||
/**
|
||||
* Get list of urls where entries could be hacked.
|
||||
*
|
||||
* @param dcCore $core dcCore instance
|
||||
* @return array List of names/types of URLs
|
||||
*/
|
||||
public static function getPublicUrlTypes(dcCore $core)
|
||||
public static function getPublicUrlTypes()
|
||||
{
|
||||
$types = [];
|
||||
|
||||
# --BEHAVIOR-- zoneclearFeedServerPublicUrlTypes
|
||||
$core->callBehavior('zoneclearFeedServerPublicUrlTypes', $types);
|
||||
dcCore::app()->callBehavior('zoneclearFeedServerPublicUrlTypes', $types);
|
||||
|
||||
$types[__('Home page')] = 'default';
|
||||
$types[__('Entries pages')] = 'post';
|
||||
|
@ -900,8 +903,7 @@ break;
|
|||
*/
|
||||
public static function tweakurlsAfterPostCreate(cursor $cur, $id)
|
||||
{
|
||||
global $core;
|
||||
$cur->post_url = tweakUrls::tweakBlogURL($cur->post_url);
|
||||
$core->auth->sudo([$core->blog, 'updPost'], $id, $cur);
|
||||
dcCore::app()->auth->sudo([dcCore::app()->blog, 'updPost'], $id, $cur);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,13 +15,13 @@ if (!defined('DC_RC_PATH')) {
|
|||
}
|
||||
|
||||
# This file is used with plugin activityReport
|
||||
$core->activityReport->addGroup(
|
||||
dcCore::app()->activityReport->addGroup(
|
||||
'zoneclearFeedServer',
|
||||
__('Plugin zoneclearFeedServer')
|
||||
);
|
||||
|
||||
# from BEHAVIOR zoneclearFeedServerAfterAddFeed in zoneclearFeedServer/inc/class.zoneclear.feed.server.php
|
||||
$core->activityReport->addAction(
|
||||
dcCore::app()->activityReport->addAction(
|
||||
'zoneclearFeedServer',
|
||||
'create',
|
||||
__('feed creation'),
|
||||
|
@ -30,7 +30,7 @@ $core->activityReport->addAction(
|
|||
['zoneclearFeedServerActivityReportBehaviors', 'addFeed']
|
||||
);
|
||||
# from BEHAVIOR zoneclearFeedServerAfterUpdFeed in in zoneclearFeedServer/inc/class.zoneclear.feed.server.php
|
||||
$core->activityReport->addAction(
|
||||
dcCore::app()->activityReport->addAction(
|
||||
'zoneclearFeedServer',
|
||||
'updatefeedinfo',
|
||||
__('updating feed info'),
|
||||
|
@ -39,7 +39,7 @@ $core->activityReport->addAction(
|
|||
['zoneclearFeedServerActivityReportBehaviors', 'updFeedInfo']
|
||||
);
|
||||
# from BEHAVIOR zoneclearFeedServerAfterUpdFeed in in zoneclearFeedServer/inc/class.zoneclear.feed.server.php
|
||||
$core->activityReport->addAction(
|
||||
dcCore::app()->activityReport->addAction(
|
||||
'zoneclearFeedServer',
|
||||
'updatefeedrecords',
|
||||
__('updating feed records'),
|
||||
|
@ -48,7 +48,7 @@ $core->activityReport->addAction(
|
|||
['zoneclearFeedServerActivityReportBehaviors', 'updFeedRecord']
|
||||
);
|
||||
# from BEHAVIOR zoneclearFeedServerAfterDelFeed in in zoneclearFeedServer/inc/class.zoneclear.feed.server.php
|
||||
$core->activityReport->addAction(
|
||||
dcCore::app()->activityReport->addAction(
|
||||
'zoneclearFeedServer',
|
||||
'delete',
|
||||
__('feed deletion'),
|
||||
|
@ -57,7 +57,7 @@ $core->activityReport->addAction(
|
|||
['zoneclearFeedServerActivityReportBehaviors', 'delFeed']
|
||||
);
|
||||
# from BEHAVIOR zoneclearFeedServerAfterEnableFeed in in zoneclearFeedServer/inc/class.zoneclear.feed.server.php
|
||||
$core->activityReport->addAction(
|
||||
dcCore::app()->activityReport->addAction(
|
||||
'zoneclearFeedServer',
|
||||
'status',
|
||||
__('feed status'),
|
||||
|
@ -70,15 +70,13 @@ class zoneclearFeedServerActivityReportBehaviors
|
|||
{
|
||||
public static function addFeed($cur)
|
||||
{
|
||||
global $core;
|
||||
|
||||
$logs = [
|
||||
$cur->feed_name,
|
||||
$cur->feed_feed,
|
||||
$core->auth->getInfo('user_cn')
|
||||
dcCore::app()->auth->getInfo('user_cn'),
|
||||
];
|
||||
|
||||
$core->activityReport->addLog(
|
||||
dcCore::app()->activityReport->addLog(
|
||||
'zoneclearFeedServer',
|
||||
'create',
|
||||
$logs
|
||||
|
@ -88,17 +86,16 @@ class zoneclearFeedServerActivityReportBehaviors
|
|||
public static function updFeedInfo($cur, $id)
|
||||
{
|
||||
if (defined('DC_CONTEXT_ADMIN')) {
|
||||
global $core;
|
||||
$zc = new zoneclearFeedServer($core);
|
||||
$zc = new zoneclearFeedServer();
|
||||
$rs = $zc->getFeeds(['feed_id' => $id]);
|
||||
|
||||
$logs = [
|
||||
$rs->feed_name,
|
||||
$rs->feed_feed,
|
||||
$core->auth->getInfo('user_cn')
|
||||
dcCore::app()->auth->getInfo('user_cn'),
|
||||
];
|
||||
|
||||
$core->activityReport->addLog(
|
||||
dcCore::app()->activityReport->addLog(
|
||||
'zoneclearFeedServer',
|
||||
'updatefeedinfo',
|
||||
$logs
|
||||
|
@ -109,15 +106,14 @@ class zoneclearFeedServerActivityReportBehaviors
|
|||
public static function updFeedRecord($cur, $id)
|
||||
{
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
global $core;
|
||||
$zc = new zoneclearFeedServer($core);
|
||||
$zc = new zoneclearFeedServer();
|
||||
$rs = $zc->getFeeds(['feed_id' => $id]);
|
||||
|
||||
$logs = [
|
||||
$rs->feed_name
|
||||
$rs->feed_name,
|
||||
];
|
||||
|
||||
$core->activityReport->addLog(
|
||||
dcCore::app()->activityReport->addLog(
|
||||
'zoneclearFeedServer',
|
||||
'updatefeedrecords',
|
||||
$logs
|
||||
|
@ -127,18 +123,16 @@ class zoneclearFeedServerActivityReportBehaviors
|
|||
|
||||
public static function delFeed($id)
|
||||
{
|
||||
global $core;
|
||||
|
||||
$zc = new zoneclearFeedServer($core);
|
||||
$zc = new zoneclearFeedServer();
|
||||
$rs = $zc->getFeeds(['feed_id' => $id]);
|
||||
|
||||
$logs = [
|
||||
$rs->feed_name,
|
||||
$rs->feed_feed,
|
||||
$core->auth->getInfo('user_cn')
|
||||
dcCore::app()->auth->getInfo('user_cn'),
|
||||
];
|
||||
|
||||
$core->activityReport->addLog(
|
||||
dcCore::app()->activityReport->addLog(
|
||||
'zoneclearFeedServer',
|
||||
'delete',
|
||||
$logs
|
||||
|
@ -147,18 +141,16 @@ class zoneclearFeedServerActivityReportBehaviors
|
|||
|
||||
public static function enableFeed($id, $enable, $time)
|
||||
{
|
||||
global $core;
|
||||
|
||||
$zc = new zoneclearFeedServer($core);
|
||||
$zc = new zoneclearFeedServer();
|
||||
$rs = $zc->getFeeds(['feed_id' => $id]);
|
||||
|
||||
$logs = [
|
||||
$rs->feed_name,
|
||||
$rs->feed_feed,
|
||||
$enable ? 'enable' : 'disable'
|
||||
$enable ? 'enable' : 'disable',
|
||||
];
|
||||
|
||||
$core->activityReport->addLog(
|
||||
dcCore::app()->activityReport->addLog(
|
||||
'zoneclearFeedServer',
|
||||
'status',
|
||||
$logs
|
||||
|
|
|
@ -22,6 +22,8 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||
*/
|
||||
class zcfsFeedsList extends adminGenericList
|
||||
{
|
||||
private $zc = null;
|
||||
|
||||
public function feedsDisplay($page, $nb_per_page, $enclose_block = '', $filter = false)
|
||||
{
|
||||
if ($this->rs->isEmpty()) {
|
||||
|
@ -31,8 +33,9 @@ class zcfsFeedsList extends adminGenericList
|
|||
echo '<p><strong>' . __('No feeds') . '</strong></p>';
|
||||
}
|
||||
} else {
|
||||
$pager = new dcPager($page, $this->rs_count, $nb_per_page, 10);
|
||||
$entries = [];
|
||||
$this->zc = new zoneclearFeedServer();
|
||||
$pager = new dcPager($page, $this->rs_count, $nb_per_page, 10);
|
||||
$entries = [];
|
||||
if (isset($_REQUEST['feeds'])) {
|
||||
foreach ($_REQUEST['feeds'] as $v) {
|
||||
$entries[(int) $v] = true;
|
||||
|
@ -52,11 +55,11 @@ class zcfsFeedsList extends adminGenericList
|
|||
'period' => '<th scope="col">' . __('Frequency') . '</th>',
|
||||
'update' => '<th scope="col">' . __('Last update') . '</th>',
|
||||
'entries' => '<th scope="col">' . __('Entries') . '</th>',
|
||||
'status' => '<th scope="col">' . __('Status') . '</th>'
|
||||
'status' => '<th scope="col">' . __('Status') . '</th>',
|
||||
];
|
||||
$cols = new ArrayObject($cols);
|
||||
|
||||
$this->core->callBehavior('adminZcfsFeedsListHeader', $this->core, $this->rs, $cols);
|
||||
dcCore::app()->callBehavior('adminZcfsFeedsListHeader', $this->rs, $cols);
|
||||
|
||||
$this->userColumns('zcfs_feeds', $cols);
|
||||
|
||||
|
@ -89,7 +92,7 @@ class zcfsFeedsList extends adminGenericList
|
|||
'<img src="images/check-on.png" alt="enable" />' :
|
||||
'<img src="images/check-off.png" alt="disable" />';
|
||||
|
||||
$entries_count = $this->rs->zc->getPostsByFeed(['feed_id' => $this->rs->feed_id], true)->f(0);
|
||||
$entries_count = $this->zc->getPostsByFeed(['feed_id' => $this->rs->feed_id], true)->f(0);
|
||||
$shunk_feed = $this->rs->feed_feed;
|
||||
if (strlen($shunk_feed) > 83) {
|
||||
$shunk_feed = substr($shunk_feed, 0, 50) . '...' . substr($shunk_feed, -20);
|
||||
|
@ -114,7 +117,7 @@ class zcfsFeedsList extends adminGenericList
|
|||
(
|
||||
$this->rs->feed_upd_last < 1 ?
|
||||
__('never') :
|
||||
dt::str(__('%Y-%m-%d %H:%M'), $this->rs->feed_upd_last, $this->rs->zc->core->auth->getInfo('user_tz'))
|
||||
dt::str(__('%Y-%m-%d %H:%M'), (int) $this->rs->feed_upd_last, dcCore::app()->auth->getInfo('user_tz'))
|
||||
) . '</td>',
|
||||
'entries' => '<td class="nowrap minimal count">' .
|
||||
(
|
||||
|
@ -122,11 +125,11 @@ class zcfsFeedsList extends adminGenericList
|
|||
'<a href="' . $url . '#entries" title="' . __('View entries') . '">' . $entries_count . '</a>' :
|
||||
$entries_count
|
||||
) . '</td>',
|
||||
'status' => '<td class="nowrap minimal status">' . $status . '</td>'
|
||||
'status' => '<td class="nowrap minimal status">' . $status . '</td>',
|
||||
];
|
||||
|
||||
$cols = new ArrayObject($cols);
|
||||
$this->core->callBehavior('adminZcfsFeedsListValue', $this->core, $this->rs, $cols);
|
||||
dcCore::app()->callBehavior('adminZcfsFeedsListValue', $this->rs, $cols);
|
||||
|
||||
$this->userColumns('zcfs_feeds', $cols);
|
||||
|
||||
|
@ -177,11 +180,11 @@ class zcfsEntriesList extends adminGenericList
|
|||
'date' => '<th scope="col">' . __('Date') . '</th>',
|
||||
'author' => '<th scope="col">' . __('Author') . '</th>',
|
||||
'category' => '<th scope="col">' . __('Category') . '</th>',
|
||||
'status' => '<th scope="col">' . __('Status') . '</th>'
|
||||
'status' => '<th scope="col">' . __('Status') . '</th>',
|
||||
];
|
||||
|
||||
$cols = new ArrayObject($cols);
|
||||
$this->core->callBehavior('adminZcfsPostListHeader', $this->core, $this->rs, $cols);
|
||||
dcCore::app()->callBehavior('adminZcfsPostListHeader', $this->rs, $cols);
|
||||
|
||||
$this->userColumns('zcfs_entries', $cols);
|
||||
|
||||
|
@ -197,7 +200,7 @@ class zcfsEntriesList extends adminGenericList
|
|||
echo $blocks[0];
|
||||
|
||||
while ($this->rs->fetch()) {
|
||||
echo $this->postLine(isset($entries[$this->rs->post_id]));
|
||||
echo $this->postLine();
|
||||
}
|
||||
|
||||
echo $blocks[1];
|
||||
|
@ -208,7 +211,7 @@ class zcfsEntriesList extends adminGenericList
|
|||
|
||||
private function postLine()
|
||||
{
|
||||
$cat_link = $this->core->auth->check('categories', $this->core->blog->id) ?
|
||||
$cat_link = dcCore::app()->auth->check('categories', dcCore::app()->blog->id) ?
|
||||
'<a href="category.php?id=%s" title="' . __('Edit category') . '">%s</a>'
|
||||
: '%2$s';
|
||||
|
||||
|
@ -249,17 +252,17 @@ class zcfsEntriesList extends adminGenericList
|
|||
'check' => '<td class="nowrap minimal">' .
|
||||
form::checkbox(['entries[]'], $this->rs->post_id, '', '', '', !$this->rs->isEditable()) . '</td>',
|
||||
'title' => '<td scope="row" class="maximal"><a href="' .
|
||||
$this->core->getPostAdminURL($this->rs->post_type, $this->rs->post_id) . '" ' .
|
||||
dcCore::app()->getPostAdminURL($this->rs->post_type, $this->rs->post_id) . '" ' .
|
||||
'title="' . html::escapeHTML($this->rs->getURL()) . '">' .
|
||||
html::escapeHTML(trim(html::clean($this->rs->post_title))) . '</a></td>',
|
||||
'date' => '<td class="nowrap count">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->post_dt) . '</td>',
|
||||
'author' => '<td class="nowrap">' . html::escapeHTML($this->rs->user_id) . '</td>',
|
||||
'category' => '<td class="nowrap">' . $cat_title . '</td>',
|
||||
'status' => '<td class="nowrap status">' . $img_status . '</td>'
|
||||
'status' => '<td class="nowrap status">' . $img_status . '</td>',
|
||||
];
|
||||
|
||||
$cols = new ArrayObject($cols);
|
||||
$this->core->callBehavior('adminZcfsPostListValue', $this->core, $this->rs, $cols);
|
||||
dcCore::app()->callBehavior('adminZcfsPostListValue', $this->rs, $cols);
|
||||
|
||||
$this->userColumns('zcfs_entries', $cols);
|
||||
|
||||
|
@ -278,20 +281,20 @@ class zcfsEntriesList extends adminGenericList
|
|||
*/
|
||||
class adminZcfsPostFilter extends adminGenericFilter
|
||||
{
|
||||
public function __construct(dcCore $core)
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($core, 'zcfs_entries');
|
||||
parent::__construct(dcCore::app(), 'zcfs_entries');
|
||||
|
||||
$filters = new arrayObject([
|
||||
dcAdminFilters::getPageFilter(),
|
||||
$this->getPostUserFilter(),
|
||||
$this->getPostCategoriesFilter(),
|
||||
$this->getPostStatusFilter(),
|
||||
$this->getPostMonthFilter()
|
||||
$this->getPostMonthFilter(),
|
||||
]);
|
||||
|
||||
# --BEHAVIOR-- adminPostFilter
|
||||
$core->callBehavior('adminZcfsPostFilter', $core, $filters);
|
||||
dcCore::app()->callBehavior('adminZcfsPostFilter', $filters);
|
||||
|
||||
$filters = $filters->getArrayCopy();
|
||||
|
||||
|
@ -306,12 +309,12 @@ class adminZcfsPostFilter extends adminGenericFilter
|
|||
$users = null;
|
||||
|
||||
try {
|
||||
$users = $this->core->blog->getPostsUsers();
|
||||
$users = dcCore::app()->blog->getPostsUsers();
|
||||
if ($users->isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -337,19 +340,19 @@ class adminZcfsPostFilter extends adminGenericFilter
|
|||
$categories = null;
|
||||
|
||||
try {
|
||||
$categories = $this->core->blog->getCategories();
|
||||
$categories = dcCore::app()->blog->getCategories();
|
||||
if ($categories->isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$combo = [
|
||||
'-' => '',
|
||||
__('(No cat)') => 'NULL'
|
||||
__('(No cat)') => 'NULL',
|
||||
];
|
||||
while ($categories->fetch()) {
|
||||
$combo[
|
||||
|
@ -387,12 +390,12 @@ class adminZcfsPostFilter extends adminGenericFilter
|
|||
$dates = null;
|
||||
|
||||
try {
|
||||
$dates = $this->core->blog->getDates(['type' => 'month']);
|
||||
$dates = dcCore::app()->blog->getDates(['type' => 'month']);
|
||||
if ($dates->isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
122
index.php
122
index.php
|
@ -14,14 +14,14 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||
return null;
|
||||
}
|
||||
|
||||
if ($core->getVersion('zoneclearFeedServer') != $core->plugins->moduleInfo('zoneclearFeedServer', 'version')
|
||||
if (dcCore::app()->getVersion('zoneclearFeedServer') != dcCore::app()->plugins->moduleInfo('zoneclearFeedServer', 'version')
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
dcPage::check('admin');
|
||||
|
||||
$zcfs = new zoneclearFeedServer($core);
|
||||
$zcfs = new zoneclearFeedServer();
|
||||
|
||||
############################################################
|
||||
#
|
||||
|
@ -37,7 +37,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
$feed_tweeter = '';
|
||||
$feed_url = '';
|
||||
$feed_feed = '';
|
||||
$feed_lang = $core->auth->getInfo('user_lang');
|
||||
$feed_lang = dcCore::app()->auth->getInfo('user_lang');
|
||||
$feed_tags = '';
|
||||
$feed_get_tags = '0';
|
||||
$feed_cat_id = '';
|
||||
|
@ -46,8 +46,8 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
|
||||
$can_view_page = true;
|
||||
|
||||
$feed_headlink = '<link rel="%s" title="%s" href="' . $p_url . '&part=feed&feed_id=%s" />';
|
||||
$feed_link = '<a href="' . $p_url . '&part=feed&feed_id=%s" title="%s">%s</a>';
|
||||
$feed_headlink = '<link rel="%s" title="%s" href="' . dcCore::app()->admin->getPageURL() . '&part=feed&feed_id=%s" />';
|
||||
$feed_link = '<a href="' . dcCore::app()->admin->getPageURL() . '&part=feed&feed_id=%s" title="%s">%s</a>';
|
||||
|
||||
$next_link = $prev_link = $next_headlink = $prev_headlink = null;
|
||||
|
||||
|
@ -58,7 +58,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
$combo_categories = ['-' => ''];
|
||||
|
||||
try {
|
||||
$categories = $core->blog->getCategories(['post_type' => 'post']);
|
||||
$categories = dcCore::app()->blog->getCategories(['post_type' => 'post']);
|
||||
while ($categories->fetch()) {
|
||||
$combo_categories[
|
||||
str_repeat(' ', $categories->level - 1) .
|
||||
|
@ -66,7 +66,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
] = $categories->cat_id;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
# Get entry informations
|
||||
|
@ -74,7 +74,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
$feed = $zcfs->getFeeds(['feed_id' => $_REQUEST['feed_id']]);
|
||||
|
||||
if ($feed->isEmpty()) {
|
||||
$core->error->add(__('This feed does not exist.'));
|
||||
dcCore::app()->error->add(__('This feed does not exist.'));
|
||||
$can_view_page = false;
|
||||
} else {
|
||||
$feed_id = $feed->feed_id;
|
||||
|
@ -93,12 +93,12 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
|
||||
$next_params = [
|
||||
'sql' => 'AND feed_id < ' . $feed_id . ' ',
|
||||
'limit' => 1
|
||||
'limit' => 1,
|
||||
];
|
||||
$next_rs = $zcfs->getFeeds($next_params);
|
||||
$prev_params = [
|
||||
'sql' => 'AND feed_id > ' . $feed_id . ' ',
|
||||
'limit' => 1
|
||||
'limit' => 1,
|
||||
];
|
||||
$prev_rs = $zcfs->getFeeds($prev_params);
|
||||
|
||||
|
@ -170,16 +170,16 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
if (!zoneclearFeedServer::validateURL($feed_feed)) {
|
||||
throw new Exception(__('You must provide valid feed URL.'));
|
||||
}
|
||||
$get_feed_cat_id = $core->blog->getCategory($feed_cat_id);
|
||||
$get_feed_cat_id = dcCore::app()->blog->getCategory($feed_cat_id);
|
||||
if ($feed_cat_id != '' && !$get_feed_cat_id) {
|
||||
throw new Exception(__('You must provide valid category.'));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_POST['action']) && $_POST['action'] == 'savefeed' && !$core->error->flag()) {
|
||||
if (!empty($_POST['action']) && $_POST['action'] == 'savefeed' && !dcCore::app()->error->flag()) {
|
||||
$cur = $zcfs->openCursor();
|
||||
$cur->feed_name = $feed_name;
|
||||
$cur->feed_desc = $feed_desc;
|
||||
|
@ -198,42 +198,42 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
if ($feed_id) {
|
||||
try {
|
||||
# --BEHAVIOR-- adminBeforeZoneclearFeedServerFeedUpdate
|
||||
$core->callBehavior('adminBeforeZoneclearFeedServerFeedUpdate', $cur, $feed_id);
|
||||
dcCore::app()->callBehavior('adminBeforeZoneclearFeedServerFeedUpdate', $cur, $feed_id);
|
||||
|
||||
$zcfs->updFeed($feed_id, $cur);
|
||||
|
||||
# --BEHAVIOR-- adminAfterZoneclearFeedServerFeedUpdate
|
||||
$core->callBehavior('adminAfterZoneclearFeedServerFeedUpdate', $cur, $feed_id);
|
||||
dcCore::app()->callBehavior('adminAfterZoneclearFeedServerFeedUpdate', $cur, $feed_id);
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
dcAdminNotices::addSuccessNotice(
|
||||
__('Feed successfully updated.')
|
||||
);
|
||||
$core->adminurl->redirect(
|
||||
dcCore::app()->adminurl->redirect(
|
||||
'admin.plugin.zoneclearFeedServer',
|
||||
['part' => 'feed', 'feed_id' => $feed_id]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
# --BEHAVIOR-- adminBeforeZoneclearFeedServerFeedCreate
|
||||
$core->callBehavior('adminBeforeZoneclearFeedServerFeedCreate', $cur);
|
||||
dcCore::app()->callBehavior('adminBeforeZoneclearFeedServerFeedCreate', $cur);
|
||||
|
||||
$return_id = $zcfs->addFeed($cur);
|
||||
|
||||
# --BEHAVIOR-- adminAfterZoneclearFeedServerFeedCreate
|
||||
$core->callBehavior('adminAfterZoneclearFeedServerFeedCreate', $cur, $return_id);
|
||||
dcCore::app()->callBehavior('adminAfterZoneclearFeedServerFeedCreate', $cur, $return_id);
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
dcAdminNotices::addSuccessNotice(
|
||||
__('Feed successfully created.')
|
||||
);
|
||||
$core->adminurl->redirect(
|
||||
dcCore::app()->adminurl->redirect(
|
||||
'admin.plugin.zoneclearFeedServer',
|
||||
['part' => 'feed', 'feed_id' => $return_id]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -241,14 +241,13 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
# Prepared entries list
|
||||
if ($feed_id && $can_view_page) {
|
||||
# action
|
||||
$posts_actions_page = new dcPostsActionsPage(
|
||||
$core,
|
||||
$posts_actions_page = new dcPostsActions(
|
||||
'plugin.php',
|
||||
[
|
||||
'p' => 'zoneclearFeedServer',
|
||||
'part' => 'feed',
|
||||
'feed_id' => $feed_id,
|
||||
'_ANCHOR' => 'entries'
|
||||
'_ANCHOR' => 'entries',
|
||||
]
|
||||
);
|
||||
if ($posts_actions_page->process()) {
|
||||
|
@ -256,7 +255,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
}
|
||||
|
||||
# filters
|
||||
$post_filter = new adminZcfsPostFilter($core);
|
||||
$post_filter = new adminZcfsPostFilter();
|
||||
$post_filter->add('part', 'feed');
|
||||
$post_filter->add('feed_id', $feed_id);
|
||||
$params = $post_filter->params();
|
||||
|
@ -266,15 +265,15 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
// key in sorty_combo (see above) => field in SQL request
|
||||
'post_title' => 'post_title',
|
||||
'cat_title' => 'cat_title',
|
||||
'user_id' => 'P.user_id'];
|
||||
'user_id' => 'P.user_id', ];
|
||||
|
||||
# --BEHAVIOR-- adminPostsSortbyLexCombo
|
||||
$core->callBehavior('adminPostsSortbyLexCombo', [& $sortby_lex]);
|
||||
dcCore::app()->callBehavior('adminPostsSortbyLexCombo', [& $sortby_lex]);
|
||||
|
||||
$params['no_content'] = true;
|
||||
$params['feed_id'] = $feed_id;
|
||||
$params['order'] = (array_key_exists($post_filter->sortby, $sortby_lex) ?
|
||||
$core->con->lexFields($sortby_lex[$post_filter->sortby]) :
|
||||
dcCore::app()->con->lexFields($sortby_lex[$post_filter->sortby]) :
|
||||
$post_filter->sortby) . ' ' . $post_filter->order;
|
||||
|
||||
# posts
|
||||
|
@ -282,34 +281,34 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
$posts = $zcfs->getPostsByFeed($params);
|
||||
$counter = $zcfs->getPostsByFeed($params, true);
|
||||
$post_list = new zcfsEntriesList(
|
||||
$core,
|
||||
dcCore::app(),
|
||||
$posts,
|
||||
$counter->f(0)
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
# display
|
||||
echo
|
||||
'<html><head><title>' . __('Feeds server') . '</title>' .
|
||||
($feed_id && !$core->error->flag() ?
|
||||
$post_filter->js($core->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feed', 'feed_id' => $feed_id], '&') . '#entries') .
|
||||
($feed_id && !dcCore::app()->error->flag() ?
|
||||
$post_filter->js(dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feed', 'feed_id' => $feed_id], '&') . '#entries') .
|
||||
dcPage::jsLoad(dcPage::getPF('zoneclearFeedServer/js/list.js'))
|
||||
: '') .
|
||||
dcPage::jsPageTabs() .
|
||||
$next_headlink . "\n" . $prev_headlink .
|
||||
|
||||
# --BEHAVIOR-- adminZoneclearFeedServerHeader
|
||||
$core->callBehavior('adminZoneclearFeedServerHeader', $core) .
|
||||
dcCore::app()->callBehavior('adminZoneclearFeedServerHeader') .
|
||||
|
||||
'</head><body>' .
|
||||
|
||||
dcPage::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
__('Feeds server') => $p_url,
|
||||
($feed_id ? __('Edit feed') : __('New feed')) => ''
|
||||
__('Feeds server') => dcCore::app()->admin->getPageURL(),
|
||||
($feed_id ? __('Edit feed') : __('New feed')) => '',
|
||||
]) .
|
||||
dcPage::notices() .
|
||||
($feed_id ? '<h3>' . sprintf(__('Edit feed "%s"'), $feed_name) . '</h3>' : '');
|
||||
|
@ -379,7 +378,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
'</p>' .
|
||||
|
||||
# --BEHAVIOR-- adminZoneclearFeedServerFeedForm
|
||||
$core->callBehavior('adminZoneclearFeedServerFeedForm', $core, $feed_id) .
|
||||
dcCore::app()->callBehavior('adminZoneclearFeedServerFeedForm', $feed_id) .
|
||||
|
||||
'</div>' .
|
||||
|
||||
|
@ -412,27 +411,27 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
|
||||
'<p class="clear">
|
||||
<input type="submit" name="save" value="' . __('Save') . ' (s)" accesskey="s"/>' .
|
||||
$core->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', [
|
||||
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', [
|
||||
'part' => 'feed',
|
||||
'feed_id' => $feed_id,
|
||||
'action' => 'savefeed'
|
||||
'action' => 'savefeed',
|
||||
]) .
|
||||
$core->formNonce() .
|
||||
dcCore::app()->formNonce() .
|
||||
'</p>
|
||||
</form>
|
||||
</div>';
|
||||
}
|
||||
|
||||
# entries
|
||||
if ($feed_id && $can_view_page && !$core->error->flag()) {
|
||||
if ($feed_id && $can_view_page && !dcCore::app()->error->flag()) {
|
||||
echo '<div class="multi-part" title="' . __('Entries') . '" id="entries">';
|
||||
|
||||
# show filters
|
||||
$post_filter->display(
|
||||
['admin.plugin.zoneclearFeedServer','#entries'],
|
||||
$core->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', [
|
||||
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', [
|
||||
'part' => 'feed',
|
||||
'feed_id' => $feed_id
|
||||
'feed_id' => $feed_id,
|
||||
])
|
||||
);
|
||||
|
||||
|
@ -445,8 +444,8 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
$post_list->display(
|
||||
$post_filter->page,
|
||||
$post_filter->nb,
|
||||
$core->adminurl->get('admin.plugin.zoneclearFeedServer', $args, '&') . '#entries',
|
||||
'<form action="' . $core->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feed']) . '#entries" method="post" id="form-entries">' .
|
||||
dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer', $args, '&') . '#entries',
|
||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feed']) . '#entries" method="post" id="form-entries">' .
|
||||
'%s' .
|
||||
|
||||
'<div class="two-cols">' .
|
||||
|
@ -455,9 +454,9 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
'<p class="col right">' . __('Selected entries action:') . ' ' .
|
||||
form::combo('action', $posts_actions_page->getCombo()) .
|
||||
'<input type="submit" name="save" value="' . __('ok') . '" /></p>' .
|
||||
$core->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', $post_filter->values()) .
|
||||
form::hidden('redir', $core->adminurl->get('admin.plugin.zoneclearFeedServer', $post_filter->values())) .
|
||||
$core->formNonce() .
|
||||
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', $post_filter->values()) .
|
||||
form::hidden('redir', dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer', $post_filter->values())) .
|
||||
dcCore::app()->formNonce() .
|
||||
'</div>' .
|
||||
'</form>',
|
||||
$post_filter->show()
|
||||
|
@ -466,7 +465,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
echo '</div>';
|
||||
}
|
||||
|
||||
############################################################
|
||||
############################################################
|
||||
#
|
||||
# All feeds
|
||||
#
|
||||
|
@ -474,7 +473,6 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
} else {
|
||||
# actions
|
||||
$feeds_actions_page = new zcfsFeedsActionsPage(
|
||||
$core,
|
||||
'plugin.php',
|
||||
['p' => 'zoneclearFeedServer', 'part' => 'feeds']
|
||||
);
|
||||
|
@ -483,7 +481,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
}
|
||||
|
||||
# filters
|
||||
$feeds_filter = new adminGenericFilter($core, 'zcfs_feeds');
|
||||
$feeds_filter = new adminGenericFilter(dcCore::app(), 'zcfs_feeds');
|
||||
$feeds_filter->add('part', 'feeds');
|
||||
$feeds_filter->add(dcAdminFilters::getPageFilter());
|
||||
$feeds_filter->add(dcAdminFilters::getSearchFilter());
|
||||
|
@ -494,53 +492,53 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
|||
$feeds = $zcfs->getFeeds($params);
|
||||
$feeds_counter = $zcfs->getFeeds($params, true)->f(0);
|
||||
$feeds_list = new zcfsFeedsList(
|
||||
$core,
|
||||
dcCore::app(),
|
||||
$feeds,
|
||||
$feeds_counter
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
# display
|
||||
echo
|
||||
'<html><head><title>' . __('Feeds server') . '</title>' .
|
||||
$feeds_filter->js($core->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feeds'], '&')) .
|
||||
$feeds_filter->js(dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feeds'], '&')) .
|
||||
dcPage::jsLoad(dcPage::getPF('zoneclearFeedServer/js/list.js')) .
|
||||
dcPage::jsPageTabs() .
|
||||
|
||||
# --BEHAVIOR-- adminZoneclearFeedServerHeader
|
||||
$core->callBehavior('adminZoneclearFeedServerHeader', $core) .
|
||||
dcCore::app()->callBehavior('adminZoneclearFeedServerHeader') .
|
||||
|
||||
'</head><body>' .
|
||||
|
||||
dcPage::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
__('Feeds server') => ''
|
||||
__('Feeds server') => '',
|
||||
]) .
|
||||
dcPage::notices() .
|
||||
|
||||
'<p class="top-add">' .
|
||||
'<a class="button add" href="' . $core->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feed']) . '">' .
|
||||
'<a class="button add" href="' . dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feed']) . '">' .
|
||||
__('New feed') . '</a></p>';
|
||||
|
||||
$feeds_filter->display(
|
||||
'admin.plugin.zoneclearFeedServer',
|
||||
$core->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', ['part', 'feeds'])
|
||||
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', ['part' => 'feeds'])
|
||||
);
|
||||
|
||||
$feeds_list->feedsDisplay(
|
||||
$feeds_filter->page,
|
||||
$feeds_filter->nb,
|
||||
'<form action="' . $core->adminurl->get('admin.plugin.zoneclearFeedServer', ['part', 'feeds']) . '" method="post" id="form-actions">' .
|
||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feeds']) . '" method="post" id="form-actions">' .
|
||||
'%s' .
|
||||
'<div class="two-cols">' .
|
||||
'<p class="col checkboxes-helpers"></p>' .
|
||||
'<p class="col right">' . __('Selected feeds action:') . ' ' .
|
||||
form::combo(['action'], $feeds_actions_page->getCombo()) .
|
||||
'<input type="submit" value="' . __('ok') . '" />' .
|
||||
$core->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', $feeds_filter->values(true)) .
|
||||
$core->formNonce() .
|
||||
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', $feeds_filter->values(true)) .
|
||||
dcCore::app()->formNonce() .
|
||||
'</p>' .
|
||||
'</div>' .
|
||||
'</form>',
|
||||
|
|
Loading…
Reference in a new issue