update to PSR12

This commit is contained in:
Jean-Christian Paul Denis 2021-11-06 16:30:19 +01:00
parent b0e2547f1d
commit 92521cdbf9
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
17 changed files with 625 additions and 566 deletions

View File

@ -2,10 +2,11 @@
- [ ] fix disallow self blog feeds
- [ ] add plugin muppet support (request Mathieu M.)
- [ ] add log for errors
- add generic filters
- add user pref for columns and filters options
- add generic filters (dc 2.20)
- add user pref for columns and filters options (dc 2.20)
- fix redirections, page title, posts feed form
- update translation
- update to PSR12
2021.09.16
- fix Dotclear 2.19 compatibility

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
@ -31,7 +30,7 @@ $_menu['Plugins']->addItem(
);
# Delete related info about feed post in meta table
$core->addBehavior('adminBeforePostDelete',['zcfsAdminBehaviors', 'adminBeforePostDelete']);
$core->addBehavior('adminBeforePostDelete', ['zcfsAdminBehaviors', 'adminBeforePostDelete']);
if ($core->auth->check('admin', $core->blog->id)) {
@ -47,7 +46,6 @@ if ($core->auth->check('admin', $core->blog->id)) {
# Take care about tweakurls (thanks Mathieu M.)
if (version_compare($core->plugins->moduleInfo('tweakurls', 'version'), '0.8', '>=')) {
$core->addbehavior('zcfsAfterPostCreate', ['zoneclearFeedServer', 'tweakurlsAfterPostCreate']);
}
@ -127,9 +125,9 @@ class zcfsAdminBehaviors
return null;
}
$fav['title'] .= '<br />'.sprintf(__('%s feed disabled', '%s feeds disabled', $count), $count);
$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'] = $core->adminurl->get(
'admin.plugin.zoneclearFeedServer',
['part' => 'feeds', 'sortby' => 'feed_status', 'order' => 'asc']
);
@ -146,18 +144,18 @@ class zcfsAdminBehaviors
$cols['zcfs_feeds'] = [
__('Feeds server: Feeds'),
[
'desc' => [true, __('Feed')],
'period' => [true, __('Frequency')],
'update' => [true, __('Last update')],
'entries' => [true, __('Entries')]
'desc' => [true, __('Feed')],
'period' => [true, __('Frequency')],
'update' => [true, __('Last update')],
'entries' => [true, __('Entries')]
]
];
$cols['zcfs_entries'] = [
__('Feeds server: Entries'),
[
'date' => [true, __('Date')],
'category' => [true, __('Category')],
'author' => [true, __('Author')]
'date' => [true, __('Date')],
'category' => [true, __('Category')],
'author' => [true, __('Author')]
]
];
}
@ -261,8 +259,7 @@ class zcfsAdminBehaviors
}
}
$sidebar_items['options-box']['items']['zcfs'] =
'<div id="zcfs">'.
$sidebar_items['options-box']['items']['zcfs'] = '<div id="zcfs">' .
'<h5>' . __('Feed source') . '</h5>' .
'<p>' .
'<a href="' . $url . '" title="' . $author . ' - ' . $url . '">' . __('feed URL') . '</a> - ' .
@ -283,14 +280,14 @@ class zcfsAdminBehaviors
$core->con->execute(
'DELETE FROM ' . $core->prefix . 'meta ' .
'WHERE post_id = ' . ((integer) $post_id) . ' ' .
'WHERE post_id = ' . ((int) $post_id) . ' ' .
'AND meta_type ' . $core->con->in([
'zoneclearfeed_url',
'zoneclearfeed_author',
'zoneclearfeed_site',
'zoneclearfeed_sitename',
'zoneclearfeed_id'
]).' '
]) . ' '
);
}
}

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_MODULE')) {
return null;
}
@ -21,16 +20,16 @@ $redir = empty($_REQUEST['redir']) ? $list->getURL() . '#plugins' : $_REQUEST['r
$core->blog->settings->addNamespace('zoneclearFeedServer');
$s = $core->blog->settings->zoneclearFeedServer;
$active = (boolean) $s->zoneclearFeedServer_active;
$pub_active = (boolean) $s->zoneclearFeedServer_pub_active;
$post_status_new = (boolean) $s->zoneclearFeedServer_post_status_new;
$bhv_pub_upd = (integer) $s->zoneclearFeedServer_bhv_pub_upd;
$update_limit = (integer) $s->zoneclearFeedServer_update_limit;
$keep_empty_feed = (boolean) $s->zoneclearFeedServer_keep_empty_feed;
$tag_case = (integer) $s->zoneclearFeedServer_tag_case;
$post_full_tpl = @unserialize($s->zoneclearFeedServer_post_full_tpl);
$active = (bool) $s->zoneclearFeedServer_active;
$pub_active = (bool) $s->zoneclearFeedServer_pub_active;
$post_status_new = (bool) $s->zoneclearFeedServer_post_status_new;
$bhv_pub_upd = (int) $s->zoneclearFeedServer_bhv_pub_upd;
$update_limit = (int) $s->zoneclearFeedServer_update_limit;
$keep_empty_feed = (bool) $s->zoneclearFeedServer_keep_empty_feed;
$tag_case = (int) $s->zoneclearFeedServer_tag_case;
$post_full_tpl = @unserialize($s->zoneclearFeedServer_post_full_tpl);
$post_title_redir = @unserialize($s->zoneclearFeedServer_post_title_redir);
$feeduser = (string) $s->zoneclearFeedServer_user;
$feeduser = (string) $s->zoneclearFeedServer_user;
if ($update_limit < 1) {
$update_limit = 10;
@ -47,16 +46,16 @@ $zc = new zoneclearFeedServer($core);
# -- Set settings --
if (!empty($_POST['save'])) {
try {
$active = !empty($_POST['active']);
$pub_active = !empty($_POST['pub_active']);
$post_status_new = !empty($_POST['post_status_new']);
$bhv_pub_upd = (integer) $_POST['bhv_pub_upd'];
$limit = abs((integer) $_POST['update_limit']);
$keep_empty_feed = !empty($_POST['keep_empty_feed']);
$tag_case = (integer) $_POST['tag_case'];
$post_full_tpl = $_POST['post_full_tpl'];
$active = !empty($_POST['active']);
$pub_active = !empty($_POST['pub_active']);
$post_status_new = !empty($_POST['post_status_new']);
$bhv_pub_upd = (int) $_POST['bhv_pub_upd'];
$limit = abs((int) $_POST['update_limit']);
$keep_empty_feed = !empty($_POST['keep_empty_feed']);
$tag_case = (int) $_POST['tag_case'];
$post_full_tpl = $_POST['post_full_tpl'];
$post_title_redir = $_POST['post_title_redir'];
$feeduser = (string) $_POST['feeduser'];
$feeduser = (string) $_POST['feeduser'];
if ($limit < 1) {
$limit = 10;
@ -111,8 +110,8 @@ $pub_page_url = $core->blog->url . $core->url->getBase('zoneclearFeedsPage');
# -- Display form --
if (!is_writable(DC_TPL_CACHE)) {
echo '<p class="error">'. __('Dotclear cache is not writable or not well configured!') . '</p>';
}
echo '<p class="error">' . __('Dotclear cache is not writable or not well configured!') . '</p>';
}
echo '
<div class="fieldset">
@ -142,7 +141,7 @@ echo '
<p><label for="post_status_new">' . __('Status of new posts:') . '</label>' .
form::combo('post_status_new', $combo_status, $post_status_new) . '</p>
<p><label for="feeduser">'.
<p><label for="feeduser">' .
__('Owner of entries created by zoneclearFeedServer:') . '</label>' .
form::combo('feeduser', $combo_admins, $feeduser) . '</p>
@ -154,8 +153,10 @@ form::combo('tag_case', $combo_tagcase, $tag_case) . '</p>
<p><label for="bhv_pub_upd">' . __('Update feeds on public side:') . '</label>' .
form::combo('bhv_pub_upd', $combo_pubupd, $bhv_pub_upd) . '</p>
<p class="classic"><label for="update_limit" class="ib">' . sprintf(__('Update %s feed(s) at a time.'),
form::number('update_limit', ['min' => 0, 'max' => 20, 'default' => $update_limit])) . '</label></p>
<p class="classic"><label for="update_limit" class="ib">' . sprintf(
__('Update %s feed(s) at a time.'),
form::number('update_limit', ['min' => 0, 'max' => 20, 'default' => $update_limit])
) . '</label></p>
<p><label for="keep_empty_feed">' .
form::checkbox('keep_empty_feed', 1, $keep_empty_feed) . __('Keep active empty feeds') . '</label></p>
@ -167,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($core) as $k => $v) {
echo sprintf(
'<li><label for="post_title_redir_%s">%s%s</label></li>',
$v,
@ -182,7 +183,7 @@ echo '
<p>' . __('Show full content on:') . '</p><ul>';
foreach($zc->getPublicUrlTypes($core) as $k => $v) {
foreach ($zc->getPublicUrlTypes($core) as $k => $v) {
echo sprintf(
'<li><label for="post_full_tpl_%s">%s%s</label></li>',
$v,

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
@ -33,7 +32,9 @@ try {
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)
) {
throw new Exception(sprintf(
'%s requires Dotclear %s', $mod_id, $dc_min
'%s requires Dotclear %s',
$mod_id,
$dc_min
));
}
@ -65,7 +66,7 @@ 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($core->con, $core->prefix);
$changes = $ti->synchronize($t);
# Settings
@ -78,15 +79,16 @@ try {
$s->put('zoneclearFeedServer_update_limit', 1, 'integer', 'Number of feeds to update at one time', false, true);
$s->put('zoneclearFeedServer_keep_empty_feed', false, 'boolean', 'Keep active empty feeds', false, true);
$s->put('zoneclearFeedServer_tag_case', 0, 'integer', 'How to transform imported tags', false, true);
$s->put('zoneclearFeedServer_user', '', 'string','User id that has right on post', false, true);
$s->put('zoneclearFeedServer_post_full_tpl', serialize(array('post', 'category', 'tag', 'archive')), 'string', 'List of templates types for full feed', false, true);
$s->put('zoneclearFeedServer_post_title_redir', serialize(array('feed')), 'string', 'List of templates types for redirection to original post', false, true);
$s->put('zoneclearFeedServer_user', '', 'string', 'User id that has right on post', false, true);
$s->put('zoneclearFeedServer_post_full_tpl', serialize(['post', 'category', 'tag', 'archive']), 'string', 'List of templates types for full feed', false, true);
$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(
$mod_id,
$this->moduleInfo($mod_id, 'version')
);
return true;
} catch (Exception $e) {
$core->error->add($e->getMessage());

View File

@ -10,18 +10,17 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
$d = dirname(__FILE__).'/inc/';
$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['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';
// public url for page of description of the flux
@ -34,5 +33,5 @@ $core->url->register(
// Add to report on plugin activityReport
if (defined('ACTIVITY_REPORT')) {
require_once $d .'lib.zcfs.activityreport.php';
require_once $d . 'lib.zcfs.activityreport.php';
}

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
@ -47,8 +46,8 @@ $tpl_blocks = [
'FeedsHeader',
'FeedIf'
];
foreach($tpl_blocks as $v) {
$core->tpl->addBlock('zc' .$v, ['zcfsTemplate', $v]);
foreach ($tpl_blocks as $v) {
$core->tpl->addBlock('zc' . $v, ['zcfsTemplate', $v]);
}
# Register tempalte values
@ -70,7 +69,7 @@ $tpl_values = [
'FeedSiteURL',
'FeedFeedURL'
];
foreach($tpl_values as $v) {
foreach ($tpl_values as $v) {
$core->tpl->addValue('zc' . $v, ['zcfsTemplate', $v]);
}
@ -148,7 +147,7 @@ class zcfsPublicBehaviors
"\n<!-- JS for zoneclearFeedServer --> \n" .
dcutils::jsLoad($core->blog->url . $core->url->getBase('zoneclearFeedsPage') . '/zcfsupd.js') .
"<script type=\"text/javascript\"> \n//<![CDATA[\n" .
" \$(function(){if(!document.getElementById){return;} " .
' $(function(){if(!document.getElementById){return;} ' .
" $('body').zoneclearFeedServer({blog_url:'" .
$blog_url . "',blog_id:'" . $blog_id . "'}); " .
" })\n" .
@ -227,6 +226,7 @@ class zcfsRsExtPosts extends rsExtPost
public static function getAuthorCN($rs)
{
$author = $rs->zcFeed('author');
return $author ?
$author :
self::zcFeedBrother('getAuthorCN', [&$rs]);
@ -240,9 +240,9 @@ class zcfsRsExtPosts extends rsExtPost
*/
public static function getURL($rs)
{
$url = $rs->zcFeed('url');
$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);
$full = is_array($types) && in_array($rs->core->url->type, $types);
return $url && $full ?
zoneclearFeedServer::absoluteURL($rs->zcFeed('site'), $url) :
@ -257,35 +257,33 @@ class zcfsRsExtPosts extends rsExtPost
*/
public static function getContent($rs, $absolute_urls = false)
{
$url = $rs->zcFeed('url');
$url = $rs->zcFeed('url');
$sitename = $rs->zcFeed('sitename');
$content = self::zcFeedBrother('getContent', [&$rs, $absolute_urls]);
$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);
if (is_array($types) && in_array($rs->core->url->type, $types)) {
return $content . sprintf(
return $content . sprintf(
'<p class="zoneclear-original"><em>%s</em></p>',
sprintf(__('Original post on <a href="%s">%s</a>'), $url, $sitename)
);
} else {
$content = context::remove_html($content);
$content = context::cut_string($content, 350);
$content = html::escapeHTML($content);
return sprintf(
'<p>%s... <em><a href="%s" title="%s">%s</a></em></p>',
$content,
self::getURL($rs),
__('Read more details about this feed'),
__('Continue reading')
);
}
} else {
return $content;
$content = context::remove_html($content);
$content = context::cut_string($content, 350);
$content = html::escapeHTML($content);
return sprintf(
'<p>%s... <em><a href="%s" title="%s">%s</a></em></p>',
$content,
self::getURL($rs),
__('Read more details about this feed'),
__('Continue reading')
);
}
return $content;
}
}
@ -327,8 +325,8 @@ class zcfsUrlHandler extends dcUrlHandlers
'Feeds updated successfully'
);
}
} catch (Exception $e) {
}
catch (Exception $e) {}
}
if (empty($msg)) {
$msg = sprintf(
@ -360,7 +358,7 @@ 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/';
$path = dirname(__FILE__) . '/default-templates/';
if (!empty($tplset) && is_dir($path . $tplset)) {
$core->tpl->setPath($core->tpl->getPath(), $path . $tplset);
} else {
@ -387,9 +385,9 @@ class zcfsTemplate
public static function Feeds($a, $c)
{
$lastn = -1;
$p = '';
$p = '';
if (isset($a['lastn'])) {
$lastn = abs((integer) $a['lastn']) +0;
$lastn = abs((int) $a['lastn']) + 0;
$p .= "\$zcfs_params['limit'] = " . $lastn . ";\n";
}
if (isset($a['cat_id'])) {
@ -402,7 +400,7 @@ class zcfsTemplate
$p .= "\$zcfs_params['feed_url'] = '" . addslashes($a['site_url']) . "';\n";
}
if (isset($a['feed_status'])) {
$p .= "\$zcfs_params['feed_status'] = " . ((integer) $a['feed_status']) . ";\n";
$p .= "\$zcfs_params['feed_status'] = " . ((int) $a['feed_status']) . ";\n";
} else {
$p .= "\$zcfs_params['feed_status'] = 1;\n";
}
@ -414,20 +412,30 @@ class zcfsTemplate
}
$sortby = 'feed_creadt';
$order = 'desc';
$order = 'desc';
if (isset($a['sortby'])) {
switch ($a['sortby']) {
case 'name': $sortby = 'lowername'; break;
case 'owner' : $sortby = 'feed_owner'; break;
case 'date' : $sortby = 'feed_dt'; break;
case 'update' : $sortby = 'feed_upddt'; break;
case 'id' : $sortby = 'feed_id'; break;
case 'name': $sortby = 'lowername';
break;
case 'owner': $sortby = 'feed_owner';
break;
case 'date': $sortby = 'feed_dt';
break;
case 'update': $sortby = 'feed_upddt';
break;
case 'id': $sortby = 'feed_id';
break;
}
}
if (isset($a['order']) && preg_match('/^(desc|asc)$/i', $a['order'])) {
$order = $a['order'];
}
$p .= "\$zcfs_params['order'] = '" . $sortby . " " . $order . "';\n";
$p .= "\$zcfs_params['order'] = '" . $sortby . ' ' . $order . "';\n";
return
'<?php ' . $p .
@ -453,7 +461,7 @@ class zcfsTemplate
if (isset($a['site_url'])) {
$url = trim($a['feed_url']);
if (substr($url, 0, 1) == '!') {
$url = substr($url, 1);
$url = substr($url, 1);
$if[] = '$_ctx->feeds->feed_url != "' . addslashes($url) . '"';
} else {
$if[] = '$_ctx->feeds->feed_url == "' . addslashes($url) . '"';
@ -462,7 +470,7 @@ class zcfsTemplate
if (isset($a['feed_url'])) {
$url = trim($a['feed_feed']);
if (substr($url, 0, 1) == '!') {
$url = substr($url, 1);
$url = substr($url, 1);
$if[] = '$_ctx->feeds->feed_feed != "' . addslashes($url) . '"';
} else {
$if[] = '$_ctx->feeds->feed_feed == "' . addslashes($url) . '"';
@ -472,25 +480,25 @@ class zcfsTemplate
$category = addslashes(trim($a['category']));
if (substr($category, 0, 1) == '!') {
$category = substr($category, 1);
$if[] = '($_ctx->feeds->cat_url != "' . $category . '")';
$if[] = '($_ctx->feeds->cat_url != "' . $category . '")';
} else {
$if[] = '($_ctx->feeds->cat_url == "' . $category . '")';
}
}
if (isset($a['first'])) {
$sign = (boolean) $a['first'] ? '=' : '!';
$sign = (bool) $a['first'] ? '=' : '!';
$if[] = '$_ctx->feeds->index() ' . $sign . '= 0';
}
if (isset($a['odd'])) {
$sign = (boolean) $a['odd'] ? '=' : '!';
$if[] = '($_ctx->feeds->index()+1)%2 ' .$sign. ' = 1';
$sign = (bool) $a['odd'] ? '=' : '!';
$if[] = '($_ctx->feeds->index()+1)%2 ' . $sign . ' = 1';
}
if (isset($a['has_category'])) {
$sign = (boolean) $a['has_category'] ? '' : '!';
$sign = (bool) $a['has_category'] ? '' : '!';
$if[] = $sign . '$_ctx->feeds->cat_id';
}
if (isset($a['has_description'])) {
$sign = (boolean) $a['has_description'] ? '' : '!';
$sign = (bool) $a['has_description'] ? '' : '!';
$if[] = $sign . '$_ctx->feeds->feed_desc';
}
@ -501,7 +509,7 @@ class zcfsTemplate
public static function FeedIfFirst($a)
{
$ret = isset($a['return']) ? $a['return'] : 'first';
$ret = $a['return'] ?? 'first';
$ret = html::escapeHTML($ret);
return
@ -511,7 +519,7 @@ class zcfsTemplate
public static function FeedIfOdd($a)
{
$ret = isset($a['return']) ? $a['return'] : 'odd';
$ret = $a['return'] ?? 'odd';
$ret = html::escapeHTML($ret);
return
@ -561,7 +569,7 @@ class zcfsTemplate
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, '$langs[$_ctx->feeds->feed_lang]') . '; } else { echo ' .
sprintf($f, '$_ctx->feeds->feed_lang') . '; } unset($langs); ?>';
}
@ -582,18 +590,18 @@ class zcfsTemplate
public static function FeedsHeader($a, $c)
{
return "<?php if (\$_ctx->feeds->isStart()) : ?>" . $c . "<?php endif; ?>";
return '<?php if ($_ctx->feeds->isStart()) : ?>' . $c . '<?php endif; ?>';
}
public static function FeedsFooter($a, $c)
{
return "<?php if (\$_ctx->feeds->isEnd()) : ?>" . $c . "<?php endif; ?>";
return '<?php if ($_ctx->feeds->isEnd()) : ?>' . $c . '<?php endif; ?>';
}
public static function FeedsCount($a)
{
$none = 'no sources';
$one = 'one source';
$one = 'one source';
$more = '%d sources';
if (isset($a['none'])) {
@ -614,13 +622,13 @@ class zcfsTemplate
" printf(__('" . $one . "'),\$fcount);\n" .
"} else {\n" .
" printf(__('" . $more . "'),\$fcount);\n" .
"} unset(\$fcount); ?>";
'} unset($fcount); ?>';
}
public static function FeedsEntriesCount($a)
{
$none = __('no entries');
$one = __('one entry');
$one = __('one entry');
$more = __('%d entries');
if (isset($a['none'])) {
@ -636,7 +644,7 @@ class zcfsTemplate
return
"<?php \$fcount = 0; \$allfeeds = \$_ctx->feeds->zc->getFeeds(); \n" .
"if (!\$allfeeds->isEmpty()) { \n" .
" while (\$allfeeds->fetch()) { " .
' while ($allfeeds->fetch()) { ' .
" \$fcount += (integer) \$_ctx->feeds->zc->getPostsByFeed(array('feed_id'=>\$allfeeds->feed_id),true)->f(0); " .
" } \n" .
"} \n" .
@ -646,13 +654,13 @@ class zcfsTemplate
" printf(__('" . $one . "'),\$fcount);\n" .
"} else {\n" .
" printf(__('" . $more . "'),\$fcount);\n" .
"} unset(\$allfeeds,\$fcount); ?>";
'} unset($allfeeds,$fcount); ?>';
}
public static function FeedEntriesCount($a)
{
$none = 'no entries';
$one = 'one entry';
$one = 'one entry';
$more = '%d entries';
if (isset($a['none'])) {
@ -666,14 +674,14 @@ class zcfsTemplate
}
return
"<?php \$fcount = \$_ctx->feeds->zc->getPostsByFeed(array('feed_id'=>\$_ctx->feeds->feed_id),true)->f(0); \n".
"<?php \$fcount = \$_ctx->feeds->zc->getPostsByFeed(array('feed_id'=>\$_ctx->feeds->feed_id),true)->f(0); \n" .
"if (\$fcount == 0) {\n" .
" printf(__('" . $none . "'),\$fcount);\n" .
"} elseif (\$fcount == 1) {\n" .
" printf(__('" . $one . "'),\$fcount);\n" .
"} else {\n" .
" printf(__('" . $more . "'),\$fcount);\n" .
"} unset(\$fcount); ?>";
'} unset($fcount); ?>';
}
protected static function getValue($a, $v)
@ -683,8 +691,7 @@ class zcfsTemplate
protected static function getOperator($op)
{
switch (strtolower($op))
{
switch (strtolower($op)) {
case 'or':
case '||':
return '||';

View File

@ -10,72 +10,103 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
$mod_id = 'zoneclearFeedServer';
$this->addUserAction(
/* type */ 'settings',
/* action */ 'delete_all',
/* ns */ $mod_id,
/* desc */ __('delete all settings')
/* type */
'settings',
/* action */
'delete_all',
/* ns */
$mod_id,
/* desc */
__('delete all settings')
);
$this->addUserAction(
/* type */ 'tables',
/* action */ 'delete',
/* ns */ 'zc_feed',
/* desc */ __('delete table')
/* type */
'tables',
/* action */
'delete',
/* ns */
'zc_feed',
/* desc */
__('delete table')
);
$this->addUserAction(
/* type */ 'plugins',
/* action */ 'delete',
/* ns */ $mod_id,
/* desc */ __('delete plugin files')
/* type */
'plugins',
/* action */
'delete',
/* ns */
$mod_id,
/* desc */
__('delete plugin files')
);
$this->addUserAction(
/* type */ 'versions',
/* action */ 'delete',
/* ns */ $mod_id,
/* desc */ __('delete the version number')
/* type */
'versions',
/* action */
'delete',
/* ns */
$mod_id,
/* desc */
__('delete the version number')
);
$this->addDirectAction(
/* type */ 'settings',
/* action */ 'delete_all',
/* ns */ $mod_id,
/* desc */ sprintf(__('delete all %s settings'), $mod_id)
/* type */
'settings',
/* action */
'delete_all',
/* ns */
$mod_id,
/* desc */
sprintf(__('delete all %s settings'), $mod_id)
);
$this->addDirectAction(
/* type */ 'tables',
/* action */ 'delete',
/* ns */ 'zc_feed',
/* desc */ sprintf(__('delete %s table'), $mod_id)
/* type */
'tables',
/* action */
'delete',
/* ns */
'zc_feed',
/* desc */
sprintf(__('delete %s table'), $mod_id)
);
$this->addDirectAction(
/* type */ 'plugins',
/* action */ 'delete',
/* ns */ $mod_id,
/* desc */ sprintf(__('delete %s plugin files'), $mod_id)
/* type */
'plugins',
/* action */
'delete',
/* ns */
$mod_id,
/* desc */
sprintf(__('delete %s plugin files'), $mod_id)
);
$this->addDirectAction(
/* type */ 'versions',
/* action */ 'delete',
/* ns */ $mod_id,
/* desc */ sprintf(__('delete %s version number'), $mod_id)
/* type */
'versions',
/* action */
'delete',
/* ns */
$mod_id,
/* desc */
sprintf(__('delete %s version number'), $mod_id)
);
$this->addDirectCallback(
/* function */ 'zoneclearfeedServerUninstall',
/* desc */ 'delete feeds relations'
/* function */
'zoneclearfeedServerUninstall',
/* desc */
'delete feeds relations'
);
function zoneclearfeedServerUninstall($core, $id)
{
if ($id != 'zoneclearFeedServer') {
return null;
}
//...

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
@ -50,23 +49,23 @@ class zoneclearFeedServerWidget
__('Feeds sources'),
)
->setting(
'sortby',
__('Order by:'),
'feed_upd_last',
'combo',
[
__('Last update') => 'feed_upd_last',
__('Name') => 'lowername',
__('Create date') => 'feed_creadt'
]
)
'sortby',
__('Order by:'),
'feed_upd_last',
'combo',
[
__('Last update') => 'feed_upd_last',
__('Name') => 'lowername',
__('Create date') => 'feed_creadt'
]
)
->setting(
'sort',
__('Sort:'),
'desc',
'combo',
[
__('Ascending') => 'asc',
__('Ascending') => 'asc',
__('Descending') => 'desc'
]
)
@ -108,8 +107,8 @@ class zoneclearFeedServerWidget
)
->setting(
'title',
__('Title:')
,__('Feeds numbers'),
__('Title:'),
__('Feeds numbers'),
'text'
)
->setting(
@ -162,11 +161,11 @@ class zoneclearFeedServerWidget
return null;
}
$p = [];
$p = [];
$p['order'] = ($w->sortby && in_array($w->sortby, ['feed_upd_last', 'lowername', 'feed_creadt'])) ?
$w->sortby . ' ' : 'feed_upd_last ';
$p['order'] .= $w->sort == 'desc' ? 'DESC' : 'ASC';
$p['limit'] = abs((integer) $w->limit);
$p['limit'] = abs((int) $w->limit);
$p['feed_status'] = 1;
$zc = new zoneclearFeedServer($core);
@ -177,8 +176,8 @@ class zoneclearFeedServerWidget
}
$lines = [];
$i = 1;
while($rs->fetch()) {
$i = 1;
while ($rs->fetch()) {
$lines[] = sprintf(
'<li><a href="%s" title="%s">%s</a></li>',
$rs->feed_url,
@ -225,7 +224,7 @@ class zoneclearFeedServerWidget
return null;
}
$zc = new zoneclearFeedServer($core);
$zc = new zoneclearFeedServer($core);
$content = '';
# Feed
@ -257,7 +256,7 @@ class zoneclearFeedServerWidget
if (!$feeds->isEmpty()) {
while ($feeds->fetch()) {
$count += (integer) $zc->getPostsByFeed(['feed_id' => $feeds->feed_id], true)->f(0);
$count += (int) $zc->getPostsByFeed(['feed_id' => $feeds->feed_id], true)->f(0);
}
}
$title = ($w->entry_title ? sprintf(

View File

@ -7,14 +7,14 @@
$opts = getopt('d:c:b:u:h');
function help($status=0)
function help($status = 0)
{
echo
"Options: \n".
" -h shows this help\n".
" -d DotClear root path\n".
" -c DotClear conf path\n".
" -b Blog ID\n".
"Options: \n" .
" -h shows this help\n" .
" -d DotClear root path\n" .
" -c DotClear conf path\n" .
" -b Blog ID\n" .
" -u User ID\n\n";
exit($status);
}
@ -46,37 +46,37 @@ if (isset($opts['b'])) {
}
if (!$dc_root || !is_dir($dc_root)) {
fwrite(STDERR,"DotClear root path is not defined\n\n");
fwrite(STDERR, "DotClear root path is not defined\n\n");
help(1);
}
if (!$dc_conf || !is_readable($dc_conf)) {
fwrite(STDERR,"DotClear configuration not found\n\n");
fwrite(STDERR, "DotClear configuration not found\n\n");
help(1);
}
if (!$blog_id) {
fwrite(STDERR,"Blog ID is not defined\n\n");
fwrite(STDERR, "Blog ID is not defined\n\n");
help(1);
}
$_SERVER['DC_RC_PATH'] = $dc_conf;
unset($dc_conf);
define('DC_BLOG_ID',$blog_id);
define('DC_BLOG_ID', $blog_id);
unset($blog_id);
require $dc_root.'/inc/prepend.php';
require $dc_root . '/inc/prepend.php';
unset($dc_root);
$core->setBlog(DC_BLOG_ID);
if ($core->blog->id == null) {
fwrite(STDERR,"Blog is not defined\n");
fwrite(STDERR, "Blog is not defined\n");
exit(1);
}
if (!isset($opts['u']) || !$core->auth->checkUser($opts['u'])) {
fwrite(STDERR,"Unable to set user\n");
fwrite(STDERR, "Unable to set user\n");
exit(1);
}
@ -88,6 +88,6 @@ try {
$zc = new zoneclearFeedServer($core);
$zc->checkFeedsUpdate();
} catch (Exception $e) {
fwrite(STDERR,$e->getMessage()."\n");
fwrite(STDERR, $e->getMessage() . "\n");
exit(1);
}

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class zcfsFeedsActionsPage extends dcActionsPage
{
public $zcfs;
@ -24,7 +23,7 @@ class zcfsFeedsActionsPage extends dcActionsPage
'sortby', 'order', 'page', 'nb'
];
$this->field_entries = 'feeds';
$this->caller_title = __('Feeds');
$this->caller_title = __('Feeds');
$this->loadDefaults();
}
@ -57,8 +56,8 @@ class zcfsFeedsActionsPage extends dcActionsPage
$this->beginPage(
dcPage::breadcrumb([
html::escapeHTML($this->core->blog->name) => '',
$this->getCallerTitle() => $this->getRedirection(true),
__('Feeds actions') => ''
$this->getCallerTitle() => $this->getRedirection(true),
__('Feeds actions') => ''
])
);
$this->endPage();
@ -70,13 +69,13 @@ class zcfsFeedsActionsPage extends dcActionsPage
$params['feed_id'] = $from['feeds'];
$feeds = $this->zcfs->getFeeds($params);
while ($feeds->fetch()) {
while ($feeds->fetch()) {
$this->entries[$feeds->feed_id] = $feeds->feed_name;
}
$this->rs = $feeds;
} else {
$this->rs = $this->core->con->select(
"SELECT blog_id FROM " . $this->core->prefix . "blog WHERE false"
'SELECT blog_id FROM ' . $this->core->prefix . 'blog WHERE false'
);
}
}
@ -129,13 +128,13 @@ class zcfsDefaultFeedsActions
public static function doEnableFeed(dcCore $core, zcfsFeedsActionsPage $ap, $post)
{
$enable = $ap->getAction() == 'enablefeed';
$ids = $ap->getIDs();
$ids = $ap->getIDs();
if (empty($ids)) {
throw new Exception(__('No feeds selected'));
}
foreach($ids as $id) {
foreach ($ids as $id) {
$ap->zcfs->enableFeed($id, $enable);
}
@ -151,8 +150,7 @@ class zcfsDefaultFeedsActions
'%d feed has been successfully disabled.',
'%d feeds have been successfully disabled.',
count($ids)
)
,
),
count($ids)
));
$ap->redirect(true);
@ -174,14 +172,12 @@ class zcfsDefaultFeedsActions
throw new Exception(__('No feeds selected'));
}
foreach($ids as $id) {
foreach ($ids as $id) {
$posts = $ap->zcfs->getPostsByFeed([
'feed_id' => $id
]);
while($posts->fetch()) {
while ($posts->fetch()) {
$core->blog->delPost($posts->post_id);
$core->con->execute(
'DELETE FROM ' . $core->prefix . 'meta ' .
@ -192,7 +188,7 @@ class zcfsDefaultFeedsActions
}
dcPage::addSuccessNotice(
__('Entries have been successfully deleted.')
__('Entries have been successfully deleted.')
);
$ap->redirect(true);
}
@ -205,7 +201,7 @@ class zcfsDefaultFeedsActions
throw new Exception(__('No feeds selected'));
}
foreach($ids as $id) {
foreach ($ids as $id) {
$ap->zcfs->delFeed($id);
}
@ -228,7 +224,7 @@ class zcfsDefaultFeedsActions
throw new Exception(__('No feeds selected'));
}
foreach($ids as $id) {
foreach ($ids as $id) {
$ap->zcfs->checkFeedsUpdate($id, true);
}
@ -251,8 +247,8 @@ class zcfsDefaultFeedsActions
throw new Exception(__('No feeds selected'));
}
foreach($ids as $id) {
$cur = $ap->zcfs->openCursor();
foreach ($ids as $id) {
$cur = $ap->zcfs->openCursor();
$cur->feed_upd_last = 0;
$ap->zcfs->updFeed($id, $cur);
$ap->zcfs->checkFeedsUpdate($id, true);
@ -278,10 +274,10 @@ class zcfsDefaultFeedsActions
throw new Exception(__('No feeds selected'));
}
$cat_id = abs((integer) $post['upd_cat_id']);
$cat_id = abs((int) $post['upd_cat_id']);
foreach($ids as $id) {
$cur = $ap->zcfs->openCursor();
foreach ($ids as $id) {
$cur = $ap->zcfs->openCursor();
$cur->cat_id = $cat_id == 0 ? null : $cat_id;
$ap->zcfs->updFeed($id, $cur);
}
@ -302,11 +298,12 @@ class zcfsDefaultFeedsActions
$ap->beginPage(
dcPage::breadcrumb([
html::escapeHTML($core->blog->name) => '',
__('Feeds server') => '',
$ap->getCallerTitle() => $ap->getRedirection(true),
__('Change category for this selection') => ''
]));
html::escapeHTML($core->blog->name) => '',
__('Feeds server') => '',
$ap->getCallerTitle() => $ap->getRedirection(true),
__('Change category for this selection') => ''
])
);
echo
'<form action="' . $ap->getURI() . '" method="post">' .
@ -332,10 +329,10 @@ class zcfsDefaultFeedsActions
throw new Exception(__('No feeds selected'));
}
$upd_int = abs((integer) $post['upd_upd_int']);
$upd_int = abs((int) $post['upd_upd_int']);
foreach($ids as $id) {
$cur = $ap->zcfs->openCursor();
foreach ($ids as $id) {
$cur = $ap->zcfs->openCursor();
$cur->feed_upd_int = $upd_int;
$ap->zcfs->updFeed($id, $cur);
}
@ -349,17 +346,17 @@ class zcfsDefaultFeedsActions
count($ids)
));
$ap->redirect(true);
}
else {
} else {
$ap->beginPage(
dcPage::breadcrumb(
[
html::escapeHTML($core->blog->name) => '',
__('Feeds server') => '',
$ap->getCallerTitle() => $ap->getRedirection(true),
html::escapeHTML($core->blog->name) => '',
__('Feeds server') => '',
$ap->getCallerTitle() => $ap->getRedirection(true),
__('Change update frequency for this selection') => ''
]));
]
)
);
echo
'<form action="' . $ap->getURI() . '" method="post">' .

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
@ -22,8 +21,8 @@ if (!defined('DC_RC_PATH')) {
*/
class zoneclearFeedServer
{
public static $nethttp_timeout = 5;
public static $nethttp_agent = 'zoneclearFeedServer - http://zoneclear.org';
public static $nethttp_timeout = 5;
public static $nethttp_agent = 'zoneclearFeedServer - http://zoneclear.org';
public static $nethttp_maxredirect = 2;
public $core;
@ -66,7 +65,7 @@ class zoneclearFeedServer
$this->con->writeLock($this->table);
try {
$id = (integer) $id;
$id = (int) $id;
if ($id < 1) {
throw new Exception(__('No such ID'));
@ -83,6 +82,7 @@ class zoneclearFeedServer
$this->trigger();
} catch (Exception $e) {
$this->con->unlock();
throw $e;
}
@ -100,10 +100,10 @@ class zoneclearFeedServer
$this->con->writeLock($this->table);
try {
$cur->feed_id = $this->getNextId();
$cur->blog_id = $this->blog;
$cur->feed_id = $this->getNextId();
$cur->blog_id = $this->blog;
$cur->feed_creadt = date('Y-m-d H:i:s');
$cur->feed_upddt = date('Y-m-d H:i:s');
$cur->feed_upddt = date('Y-m-d H:i:s');
//add getFeedCursor here
@ -112,6 +112,7 @@ class zoneclearFeedServer
$this->trigger();
} catch (Exception $e) {
$this->con->unlock();
throw $e;
}
@ -131,7 +132,7 @@ class zoneclearFeedServer
public function enableFeed($id, $enable = true, $time = null)
{
try {
$id = (integer) $id;
$id = (int) $id;
if ($id < 1) {
throw new Exception(__('No such ID'));
@ -140,10 +141,10 @@ class zoneclearFeedServer
$cur = $this->openCursor();
$this->con->writeLock($this->table);
$cur->feed_upddt = date('Y-m-d H:i:s');
$cur->feed_status = (integer) $enable;
$cur->feed_upddt = date('Y-m-d H:i:s');
$cur->feed_status = (int) $enable;
if (null !== $time) {
$cur->feed_upd_last = (integer) $time;
$cur->feed_upd_last = (int) $time;
}
$cur->update(sprintf(
@ -155,6 +156,7 @@ class zoneclearFeedServer
$this->trigger();
} catch (Exception $e) {
$this->con->unlock();
throw $e;
}
@ -170,7 +172,7 @@ class zoneclearFeedServer
*/
public function delFeed($id)
{
$id = (integer) $id;
$id = (int) $id;
if ($id < 1) {
throw new Exception(__('No such ID'));
@ -195,17 +197,15 @@ class zoneclearFeedServer
* @param boolean $count_only Return only result count
* @return record record instance
*/
public function getPostsByFeed($params = array(), $count_only = false)
public function getPostsByFeed($params = [], $count_only = false)
{
if (!isset($params['feed_id'])) {
return null;
}
$params['from'] =
'LEFT JOIN ' . $this->core->prefix . 'meta F ' .
$params['from'] = 'LEFT JOIN ' . $this->core->prefix . 'meta F ' .
'ON P.post_id = F.post_id ';
$params['sql'] =
"AND P.blog_id = '" . $this->blog . "' " .
$params['sql'] = "AND P.blog_id = '" . $this->blog . "' " .
"AND F.meta_type = 'zoneclearfeed_id' " .
"AND F.meta_id = '" . $this->con->escape($params['feed_id']) . "' ";
@ -221,7 +221,7 @@ class zoneclearFeedServer
* @param boolean $count_only Return only result count
* @return record record instance
*/
public function getFeeds($params = array(), $count_only = false)
public function getFeeds($params = [], $count_only = false)
{
if ($count_only) {
$strReq = 'SELECT count(Z.feed_id) ';
@ -231,8 +231,7 @@ class zoneclearFeedServer
$content_req .= implode(', ', $params['columns']) . ', ';
}
$strReq =
'SELECT Z.feed_id, Z.feed_creadt, Z.feed_upddt, Z.feed_type, ' .
$strReq = 'SELECT Z.feed_id, Z.feed_creadt, Z.feed_upddt, Z.feed_type, ' .
'Z.blog_id, Z.cat_id, ' .
'Z.feed_upd_int, Z.feed_upd_last, Z.feed_status, ' .
$content_req .
@ -243,8 +242,7 @@ class zoneclearFeedServer
'C.cat_title, C.cat_url, C.cat_desc ';
}
$strReq .=
'FROM ' . $this->table . ' Z ' .
$strReq .= 'FROM ' . $this->table . ' Z ' .
'LEFT OUTER JOIN ' . $this->core->prefix . 'category C ON Z.cat_id = C.cat_id ';
if (!empty($params['from'])) {
@ -261,9 +259,9 @@ class zoneclearFeedServer
if (!empty($params['feed_id'])) {
if (is_array($params['feed_id'])) {
array_walk($params['feed_id'], function(&$v, $k) { if($v !== null) { $v = (integer) $v; }});
array_walk($params['feed_id'], function (&$v, $k) { if ($v !== null) { $v = (int) $v; }});
} else {
$params['feed_id'] = [(integer) $params['feed_id']];
$params['feed_id'] = [(int) $params['feed_id']];
}
$strReq .= 'AND Z.feed_id ' . $this->con->in($params['feed_id']);
}
@ -275,7 +273,7 @@ class zoneclearFeedServer
$strReq .= "AND Z.feed_url = '" . $this->con->escape($params['feed_url']) . "' ";
}
if (isset($params['feed_status'])) {
$strReq .= "AND Z.feed_status = " . ((integer) $params['feed_status']) . " ";
$strReq .= 'AND Z.feed_status = ' . ((int) $params['feed_status']) . ' ';
}
if (!empty($params['q'])) {
@ -299,7 +297,7 @@ class zoneclearFeedServer
$strReq .= $this->con->limit($params['limit']);
}
$rs = $this->con->select($strReq);
$rs = $this->con->select($strReq);
$rs->zc = $this;
return $rs;
@ -327,14 +325,14 @@ class zoneclearFeedServer
try {
# Need flock function
if (!function_exists('flock')) {
throw New Exception("Can't call php function named flock");
throw new Exception("Can't call php function named flock");
}
# Cache writable ?
if (!is_writable(DC_TPL_CACHE)) {
throw new Exception("Can't write in cache fodler");
}
# Set file path
$f_md5 = md5($this->blog);
$f_md5 = md5($this->blog);
$cached_file = sprintf(
'%s/%s/%s/%s/%s.txt',
DC_TPL_CACHE,
@ -353,18 +351,18 @@ class zoneclearFeedServer
if (!file_exists($cached_file)) {
!$fp = @fopen($cached_file, 'w');
if ($fp === false) {
throw New Exception("Can't create file");
throw new Exception("Can't create file");
}
fwrite($fp, '1', strlen('1'));
fclose($fp);
}
# Open file
if (!($fp = @fopen($cached_file, 'r+'))) {
throw New Exception("Can't open file");
throw new Exception("Can't open file");
}
# Lock file
if (!flock($fp, LOCK_EX)) {
throw New Exception("Can't lock file");
throw new Exception("Can't lock file");
}
$this->lock = $fp;
@ -378,7 +376,6 @@ class zoneclearFeedServer
/**
* Unlock file of update process.
*
*/
public function unlockUpdate()
{
@ -408,7 +405,7 @@ class zoneclearFeedServer
dt::setTZ($this->core->blog->settings->system->blog_timezone);
$time = time();
$s = $this->core->blog->settings->zoneclearFeedServer;
$s = $this->core->blog->settings->zoneclearFeedServer;
# All feeds or only one (from admin)
$f = !$id ?
@ -423,10 +420,10 @@ class zoneclearFeedServer
# Set feeds user
$this->enableUser($s->zoneclearFeedServer_user);
$updates = false;
$updates = false;
$loop_mem = [];
$limit = abs((integer) $s->zoneclearFeedServer_update_limit);
$limit = abs((int) $s->zoneclearFeedServer_update_limit);
if ($limit < 1) {
$limit = 10;
}
@ -435,7 +432,7 @@ class zoneclearFeedServer
$cur_post = $this->con->openCursor($this->core->prefix . 'post');
$cur_meta = $this->con->openCursor($this->core->prefix . 'meta');
while($f->fetch()) {
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
@ -481,7 +478,7 @@ class zoneclearFeedServer
continue;
}
$item_link = $this->con->escape($item_link);
$item_link = $this->con->escape($item_link);
$is_new_published_entry = false;
# Not updated since last visit
@ -499,7 +496,7 @@ class zoneclearFeedServer
$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 '.
'INNER JOIN ' . $this->core->prefix . 'meta M ' .
'ON P.post_id = M.post_id ' .
"WHERE blog_id='" . $this->blog . "' " .
"AND meta_type = 'zoneclearfeed_url' " .
@ -512,20 +509,20 @@ class zoneclearFeedServer
if ($f->cat_id) {
$cur_post->cat_id = $f->cat_id;
}
$post_content = $item->content ? $item->content : $item->description;
$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;
$post_content = $item->content ? $item->content : $item->description;
$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;
try {
# Create entry
if ($old_post->isEmpty()) {
# Post
$cur_post->user_id = $this->core->auth->userID();
$cur_post->post_format = 'xhtml';
$cur_post->post_status = (integer) $s->zoneclearFeedServer_post_status_new;
$cur_post->user_id = $this->core->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;
$cur_post->post_open_tb = 0;
# --BEHAVIOR-- zoneclearFeedServerBeforePostCreate
$this->core->callBehavior(
@ -550,7 +547,7 @@ class zoneclearFeedServer
$is_new_published_entry = true;
}
# Update entry
# Update entry
} else {
$post_id = $old_post->post_id;
@ -589,37 +586,37 @@ class zoneclearFeedServer
}
# Quick add new meta
$meta = new ArrayObject();
$meta = new ArrayObject();
$meta->tweeter = $f->feed_tweeter;
$cur_meta->clean();
$cur_meta->post_id = $post_id;
$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->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->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->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->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
@ -627,8 +624,8 @@ class zoneclearFeedServer
if ($f->feed_get_tags) {
# Some feed subjects contains more than one tag
foreach($item->subject as $subjects) {
$tmp = $this->core->meta->splitMetaValues($subjects);
foreach ($item->subject as $subjects) {
$tmp = $this->core->meta->splitMetaValues($subjects);
$tags = array_merge($tags, $tmp);
}
$tags = array_unique($tags);
@ -637,10 +634,16 @@ class zoneclearFeedServer
foreach ($tags as $tag) {
# Change tags case
switch((integer) $s->zoneclearFeedServer_tag_case) {
case 3: $tag = strtoupper($tag); break;
case 2: $tag = strtolower($tag); break;
case 1: $tag = ucfirst(strtolower($tag)); break;
switch ((int) $s->zoneclearFeedServer_tag_case) {
case 3: $tag = strtoupper($tag);
break;
case 2: $tag = strtolower($tag);
break;
case 1: $tag = ucfirst(strtolower($tag));
break;
default: /* do nothing */ break;
}
if (!in_array($tag, $formated_tags)) {
@ -663,11 +666,11 @@ class zoneclearFeedServer
$cur_post,
$meta
);
} catch (Exception $e) {
$this->con->rollback();
$this->enableUser(false);
$this->unlockUpdate();
throw $e;
}
$updates = true;
@ -694,7 +697,7 @@ class zoneclearFeedServer
if (!$this->core->auth->checkUser($enable)) {
throw new Exception('Unable to set user');
}
# Disable
# Disable
} else {
$this->core->auth = null;
$this->core->auth = new dcAuth($this->core);
@ -710,7 +713,7 @@ class zoneclearFeedServer
public static function readFeed($f)
{
try {
$feed_reader = new feedReader;
$feed_reader = new feedReader();
$feed_reader->setCacheDir(DC_TPL_CACHE);
$feed_reader->setTimeout(self::$nethttp_timeout);
$feed_reader->setMaxRedirects(self::$nethttp_maxredirect);
@ -840,8 +843,8 @@ class zoneclearFeedServer
'FROM ' . $this->con->escapeSystem($this->core->prefix . 'user') . ' U ' .
'LEFT JOIN ' . $this->con->escapeSystem($this->core->prefix . 'permissions') . ' P ' .
'ON U.user_id=P.user_id ' .
'WHERE U.user_status = 1 '.
"AND P.blog_id = '" .$this->blog . "' " .
'WHERE U.user_status = 1 ' .
"AND P.blog_id = '" . $this->blog . "' " .
"AND P.permissions LIKE '%|admin|%' "
);
@ -868,7 +871,7 @@ class zoneclearFeedServer
*/
public static function getPublicUrlTypes(dcCore $core)
{
$types = array();
$types = [];
# --BEHAVIOR-- zoneclearFeedServerPublicUrlTypes
$core->callBehavior('zoneclearFeedServerPublicUrlTypes', $types);
@ -893,6 +896,6 @@ class zoneclearFeedServer
{
global $core;
$cur->post_url = tweakUrls::tweakBlogURL($cur->post_url);
$core->auth->sudo(array($core->blog, 'updPost'), $id, $cur);
$core->auth->sudo([$core->blog, 'updPost'], $id, $cur);
}
}

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
@ -107,7 +106,7 @@ class zoneclearFeedServerActivityReportBehaviors
}
}
public static function updFeedRecord($cur,$id)
public static function updFeedRecord($cur, $id)
{
if (!defined('DC_CONTEXT_ADMIN')) {
global $core;

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
@ -36,13 +35,13 @@ class zcfsFeedsList extends adminGenericList
$entries = [];
if (isset($_REQUEST['feeds'])) {
foreach ($_REQUEST['feeds'] as $v) {
$entries[(integer) $v] = true;
$entries[(int) $v] = true;
}
}
$html_block =
'<div class="table-outer">' .
$html_block = '<div class="table-outer">' .
'<table>' .
'<caption>' . ($filter ?
'<caption>' . (
$filter ?
sprintf(__('List of %s feeds matching the filter.'), $this->rs_count) :
sprintf(__('List of feeds (%s)'), $this->rs_count)
) . '</caption>';
@ -84,16 +83,16 @@ class zcfsFeedsList extends adminGenericList
private function feedsLine($checked)
{
$combo_status = zoneclearFeedServer::getAllStatus();
$combo_status = zoneclearFeedServer::getAllStatus();
$combo_upd_int = zoneclearFeedServer::getAllUpdateInterval();
$status = $this->rs->feed_status ?
$status = $this->rs->feed_status ?
'<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);
$shunk_feed = $this->rs->feed_feed;
$shunk_feed = $this->rs->feed_feed;
if (strlen($shunk_feed) > 83) {
$shunk_feed = substr($shunk_feed,0,50).'...'.substr($shunk_feed,-20);
$shunk_feed = substr($shunk_feed, 0, 50) . '...' . substr($shunk_feed, -20);
}
$url = 'plugin.php?p=zoneclearFeedServer&amp;part=feed&amp;feed_id=' . $this->rs->feed_id;
@ -105,23 +104,25 @@ class zcfsFeedsList extends adminGenericList
'title' => '<td class="nowrap" scope="row">' .
'<a href="' . $url . '#feed" title="' . __('Edit') . '">' . html::escapeHTML($this->rs->feed_name) . '</a>' .
'</td>',
'desc' => '<td class="nowrap maximal">' .
'<a href="' . $this->rs->feed_feed . '" title="' . html::escapeHTML($this->rs->feed_desc) . '">' . html::escapeHTML($shunk_feed) . '</a>'.
'desc' => '<td class="nowrap maximal">' .
'<a href="' . $this->rs->feed_feed . '" title="' . html::escapeHTML($this->rs->feed_desc) . '">' . html::escapeHTML($shunk_feed) . '</a>' .
'</td>',
'period' => '<td class="nowrap minimal count">' .
array_search($this->rs->feed_upd_int,$combo_upd_int) .
'period' => '<td class="nowrap minimal count">' .
array_search($this->rs->feed_upd_int, $combo_upd_int) .
'</td>',
'update' => '<td class="nowrap minimal count">' .
($this->rs->feed_upd_last < 1 ?
'update' => '<td class="nowrap minimal count">' .
(
$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'))
) . '</td>',
'entries' => '<td class="nowrap minimal count">' .
($entries_count ?
'entries' => '<td class="nowrap minimal count">' .
(
$entries_count ?
'<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);
@ -147,24 +148,26 @@ class zcfsEntriesList extends adminGenericList
public function display($page, $nb_per_page, $base_url, $enclose_block = '', $filter = false)
{
if ($this->rs->isEmpty()) {
echo '<p><strong>' . ($filter ?
echo '<p><strong>' . (
$filter ?
__('No entries matches the filter') :
__('No entries')
) . '</strong></p>';
) . '</strong></p>';
} else {
$pager = new dcPager($page, $this->rs_count, $nb_per_page, 10);
$pager = new dcPager($page, $this->rs_count, $nb_per_page, 10);
$pager->base_url = $base_url;
$entries = [];
if (isset($_REQUEST['feeds'])) {
foreach ($_REQUEST['feeds'] as $v) {
$entries[(integer) $v] = true;
$entries[(int) $v] = true;
}
}
$html_block = '<div class="table-outer clear">' .
'<table>' .
'<caption>' . ($filter ?
'<caption>' . (
$filter ?
sprintf(__('List of %s entries matching the filter.'), $this->rs_count) :
sprintf(__('List of entries (%s)'), $this->rs_count)
) . '</caption>';
@ -206,11 +209,11 @@ class zcfsEntriesList extends adminGenericList
private function postLine()
{
$cat_link = $this->core->auth->check('categories', $this->core->blog->id) ?
'<a href="category.php?id=%s" title="'.__('Edit category').'">%s</a>'
'<a href="category.php?id=%s" title="' . __('Edit category') . '">%s</a>'
: '%2$s';
$cat_title = $this->rs->cat_title ?
sprintf($cat_link,$this->rs->cat_id, html::escapeHTML($this->rs->cat_title))
sprintf($cat_link, $this->rs->cat_id, html::escapeHTML($this->rs->cat_title))
: __('None');
$img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
@ -243,15 +246,15 @@ class zcfsEntriesList extends adminGenericList
' id="p' . $this->rs->post_id . '">';
$cols = [
'check' => '<td class="nowrap minimal">'.
form::checkbox(array('entries[]'), $this->rs->post_id, '', '', '', !$this->rs->isEditable()).'</td>',
'title' => '<td scope="row" class="maximal"><a href="' .
'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) . '" ' .
'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>',
'category' => '<td class="nowrap">' . $cat_title . '</td>',
'status' => '<td class="nowrap status">' . $img_status . '</td>'
];
@ -301,6 +304,7 @@ class adminZcfsPostFilter extends adminGenericFilter
public function getPostUserFilter(): ?dcAdminFilter
{
$users = null;
try {
$users = $this->core->blog->getPostsUsers();
if ($users->isEmpty()) {
@ -308,6 +312,7 @@ class adminZcfsPostFilter extends adminGenericFilter
}
} catch (Exception $e) {
$this->core->error->add($e->getMessage());
return null;
}
@ -330,6 +335,7 @@ class adminZcfsPostFilter extends adminGenericFilter
public function getPostCategoriesFilter(): ?dcAdminFilter
{
$categories = null;
try {
$categories = $this->core->blog->getCategories();
if ($categories->isEmpty()) {
@ -337,12 +343,13 @@ class adminZcfsPostFilter extends adminGenericFilter
}
} catch (Exception $e) {
$this->core->error->add($e->getMessage());
return null;
}
$combo = [
'-' => '',
__('(No cat)') => 'NULL'
'-' => '',
__('(No cat)') => 'NULL'
];
while ($categories->fetch()) {
$combo[
@ -378,6 +385,7 @@ class adminZcfsPostFilter extends adminGenericFilter
public function getPostMonthFilter(): ?dcAdminFilter
{
$dates = null;
try {
$dates = $this->core->blog->getDates(['type' => 'month']);
if ($dates->isEmpty()) {
@ -385,12 +393,13 @@ class adminZcfsPostFilter extends adminGenericFilter
}
} catch (Exception $e) {
$this->core->error->add($e->getMessage());
return null;
}
return (new dcAdminFilter('month'))
->param('post_month', function($f) { return substr($f[0], 4, 2); })
->param('post_year', function($f) { return substr($f[0], 0, 4); })
->param('post_month', function ($f) { return substr($f[0], 4, 2); })
->param('post_year', function ($f) { return substr($f[0], 0, 4); })
->title(__('Month:'))
->options(array_merge(
['-' => ''],

143
index.php
View File

@ -10,13 +10,11 @@
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
if ($core->getVersion('zoneclearFeedServer') !=
$core->plugins->moduleInfo('zoneclearFeedServer', 'version')
if ($core->getVersion('zoneclearFeedServer') != $core->plugins->moduleInfo('zoneclearFeedServer', 'version')
) {
return null;
}
@ -49,7 +47,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
$can_view_page = true;
$feed_headlink = '<link rel="%s" title="%s" href="' . $p_url . '&amp;part=feed&amp;feed_id=%s" />';
$feed_link = '<a href="' . $p_url . '&amp;part=feed&amp;feed_id=%s" title="%s">%s</a>';
$feed_link = '<a href="' . $p_url . '&amp;part=feed&amp;feed_id=%s" title="%s">%s</a>';
$next_link = $prev_link = $next_headlink = $prev_headlink = null;
@ -58,11 +56,12 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
$combo_status = $zcfs->getAllStatus();
$combo_upd_int = $zcfs->getAllUpdateInterval();
$combo_categories = ['-' => ''];
try {
$categories = $core->blog->getCategories(['post_type' => 'post']);
while ($categories->fetch()) {
$combo_categories[
str_repeat('&nbsp;&nbsp;', $categories->level-1) .
str_repeat('&nbsp;&nbsp;', $categories->level - 1) .
'&bull; ' . html::escapeHTML($categories->cat_title)
] = $categories->cat_id;
}
@ -77,7 +76,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
if ($feed->isEmpty()) {
$core->error->add(__('This feed does not exist.'));
$can_view_page = false;
} else {
} else {
$feed_id = $feed->feed_id;
$feed_name = $feed->feed_name;
$feed_desc = $feed->feed_desc;
@ -92,53 +91,69 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
$feed_status = $feed->feed_status;
$feed_upd_int = $feed->feed_upd_int;
$next_params = array(
$next_params = [
'sql' => 'AND feed_id < ' . $feed_id . ' ',
'limit' => 1
);
$next_rs = $zcfs->getFeeds($next_params);
$prev_params = array(
];
$next_rs = $zcfs->getFeeds($next_params);
$prev_params = [
'sql' => 'AND feed_id > ' . $feed_id . ' ',
'limit' => 1
);
];
$prev_rs = $zcfs->getFeeds($prev_params);
if (!$next_rs->isEmpty()) {
$next_link = sprintf($feed_link, $next_rs->feed_id,
html::escapeHTML($next_rs->feed_name), __('next feed') . '&nbsp;&#187;');
$next_headlink = sprintf($feed_headlink, 'next',
html::escapeHTML($next_rs->feed_name), $next_rs->feed_id);
$next_link = sprintf(
$feed_link,
$next_rs->feed_id,
html::escapeHTML($next_rs->feed_name),
__('next feed') . '&nbsp;&#187;'
);
$next_headlink = sprintf(
$feed_headlink,
'next',
html::escapeHTML($next_rs->feed_name),
$next_rs->feed_id
);
}
if (!$prev_rs->isEmpty()) {
$prev_link = sprintf($feed_link, $prev_rs->feed_id,
html::escapeHTML($prev_rs->feed_name), '&#171;&nbsp;' . __('previous feed'));
$prev_headlink = sprintf($feed_headlink, 'previous',
html::escapeHTML($prev_rs->feed_name), $prev_rs->feed_id);
$prev_link = sprintf(
$feed_link,
$prev_rs->feed_id,
html::escapeHTML($prev_rs->feed_name),
'&#171;&nbsp;' . __('previous feed')
);
$prev_headlink = sprintf(
$feed_headlink,
'previous',
html::escapeHTML($prev_rs->feed_name),
$prev_rs->feed_id
);
}
}
}
if (!empty($_POST['action']) && $_POST['action'] == 'savefeed') {
try {
$feed_name = $_POST['feed_name'];
$feed_desc = $_POST['feed_desc'];
$feed_owner = $_POST['feed_owner'];
$feed_tweeter = $_POST['feed_tweeter'];
$feed_url = $_POST['feed_url'];
$feed_feed = $_POST['feed_feed'];
$feed_lang = $_POST['feed_lang'];
$feed_tags = $_POST['feed_tags'];
$feed_get_tags = empty($_POST['feed_get_tags']) ? 0 : 1;
$feed_cat_id = $_POST['feed_cat_id'];
$feed_upd_int = $_POST['feed_upd_int'];
$feed_name = $_POST['feed_name'];
$feed_desc = $_POST['feed_desc'];
$feed_owner = $_POST['feed_owner'];
$feed_tweeter = $_POST['feed_tweeter'];
$feed_url = $_POST['feed_url'];
$feed_feed = $_POST['feed_feed'];
$feed_lang = $_POST['feed_lang'];
$feed_tags = $_POST['feed_tags'];
$feed_get_tags = empty($_POST['feed_get_tags']) ? 0 : 1;
$feed_cat_id = $_POST['feed_cat_id'];
$feed_upd_int = $_POST['feed_upd_int'];
if (isset($_POST['feed_status'])) {
$feed_status = (integer) $_POST['feed_status'];
$feed_status = (int) $_POST['feed_status'];
}
$testfeed_params['feed_feed'] = $feed_feed;
if ($feed_id) {
$testfeed_params['sql'] ='AND feed_id <> '.$feed_id.' ';
$testfeed_params['sql'] = 'AND feed_id <> ' . $feed_id . ' ';
}
if ($zcfs->getFeeds($testfeed_params, true)->f(0)) {
throw new Exception(__('Record with same feed URL already exists.'));
@ -165,7 +180,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
}
if (!empty($_POST['action']) && $_POST['action'] == 'savefeed' && !$core->error->flag()) {
$cur = $zcfs->openCursor();
$cur = $zcfs->openCursor();
$cur->feed_name = $feed_name;
$cur->feed_desc = $feed_desc;
$cur->feed_owner = $feed_owner;
@ -174,10 +189,10 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
$cur->feed_feed = $feed_feed;
$cur->feed_lang = $feed_lang;
$cur->feed_tags = $feed_tags;
$cur->feed_get_tags = (integer) $feed_get_tags;
$cur->cat_id = $feed_cat_id != '' ? (integer) $feed_cat_id : null;
$cur->feed_status = (integer) $feed_status;
$cur->feed_upd_int = (integer) $feed_upd_int;
$cur->feed_get_tags = (int) $feed_get_tags;
$cur->cat_id = $feed_cat_id != '' ? (int) $feed_cat_id : null;
$cur->feed_status = (int) $feed_status;
$cur->feed_upd_int = (int) $feed_upd_int;
# Update feed
if ($feed_id) {
@ -194,7 +209,8 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
__('Feed successfully updated.')
);
$core->adminurl->redirect(
'admin.plugin.zoneclearFeedServer', ['part' => 'feed', 'feed_id' => $feed_id]
'admin.plugin.zoneclearFeedServer',
['part' => 'feed', 'feed_id' => $feed_id]
);
} catch (Exception $e) {
$core->error->add($e->getMessage());
@ -213,7 +229,8 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
__('Feed successfully created.')
);
$core->adminurl->redirect(
'admin.plugin.zoneclearFeedServer', ['part' => 'feed', 'feed_id' => $return_id]
'admin.plugin.zoneclearFeedServer',
['part' => 'feed', 'feed_id' => $return_id]
);
} catch (Exception $e) {
$core->error->add($e->getMessage());
@ -262,8 +279,8 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
# posts
try {
$posts = $zcfs->getPostsByFeed($params);
$counter = $zcfs->getPostsByFeed($params,true);
$posts = $zcfs->getPostsByFeed($params);
$counter = $zcfs->getPostsByFeed($params, true);
$post_list = new zcfsEntriesList(
$core,
$posts,
@ -278,7 +295,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
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') .
$post_filter->js($core->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feed', 'feed_id' => $feed_id], '&') . '#entries') .
dcPage::jsLoad(dcPage::getPF('zoneclearFeedServer/js/list.js'))
: '') .
dcPage::jsPageTabs() .
@ -290,12 +307,12 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
'</head><body>' .
dcPage::breadcrumb([
__('Plugins') => '',
__('Feeds server') => $p_url,
($feed_id ? __('Edit feed') : __('New feed')) => ''
]).
__('Plugins') => '',
__('Feeds server') => $p_url,
($feed_id ? __('Edit feed') : __('New feed')) => ''
]) .
dcPage::notices() .
($feed_id ? '<h3>' . sprintf(__('Edit feed "%s"'), $feed_name) .'</h3>' : '');
($feed_id ? '<h3>' . sprintf(__('Edit feed "%s"'), $feed_name) . '</h3>' : '');
# Feed
if ($can_view_page) {
@ -394,11 +411,11 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
'</div>' .
'<p class="clear">
<input type="submit" name="save" value="'.__('Save').' (s)" accesskey="s"/>' .
<input type="submit" name="save" value="' . __('Save') . ' (s)" accesskey="s"/>' .
$core->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', [
'part' => 'feed',
'feed_id' => $feed_id,
'action' => 'savefeed'
'part' => 'feed',
'feed_id' => $feed_id,
'action' => 'savefeed'
]) .
$core->formNonce() .
'</p>
@ -408,10 +425,11 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
# entries
if ($feed_id && $can_view_page && !$core->error->flag()) {
echo '<div class="multi-part" title="'.__('Entries').'" id="entries">';
echo '<div class="multi-part" title="' . __('Entries') . '" id="entries">';
# show filters
$post_filter->display(['admin.plugin.zoneclearFeedServer','#entries'],
$post_filter->display(
['admin.plugin.zoneclearFeedServer','#entries'],
$core->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', [
'part' => 'feed',
'feed_id' => $feed_id
@ -428,7 +446,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
$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">'.
'<form action="' . $core->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feed']) . '#entries" method="post" id="form-entries">' .
'%s' .
'<div class="two-cols">' .
@ -448,12 +466,11 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
echo '</div>';
}
############################################################
############################################################
#
# All feeds
#
############################################################
} else {
# actions
$feeds_actions_page = new zcfsFeedsActionsPage(
@ -474,9 +491,9 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
# feeds
try {
$feeds = $zcfs->getFeeds($params);
$feeds = $zcfs->getFeeds($params);
$feeds_counter = $zcfs->getFeeds($params, true)->f(0);
$feeds_list = new zcfsFeedsList(
$feeds_list = new zcfsFeedsList(
$core,
$feeds,
$feeds_counter
@ -498,9 +515,9 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
'</head><body>' .
dcPage::breadcrumb([
__('Plugins') => '',
__('Feeds server') => ''
]).
__('Plugins') => '',
__('Feeds server') => ''
]) .
dcPage::notices() .
'<p class="top-add">' .
@ -512,7 +529,9 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
$core->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', ['part', 'feeds'])
);
$feeds_list->feedsDisplay($feeds_filter->page, $feeds_filter->nb,
$feeds_list->feedsDisplay(
$feeds_filter->page,
$feeds_filter->nb,
'<form action="' . $core->adminurl->get('admin.plugin.zoneclearFeedServer', ['part', 'feeds']) . '" method="post" id="form-actions">' .
'%s' .
'<div class="two-cols">' .

View File

@ -1,17 +1,15 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of zoneclearFeedServer, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
if (!isset($__resources['help']['zoneclearFeedServer']))
{
$__resources['help']['zoneclearFeedServer'] = dirname(__FILE__).'/help/zoneclearFeedServer.html';
/**
* @brief zoneclearFeedServer, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!isset($__resources['help']['zoneclearFeedServer'])) {
$__resources['help']['zoneclearFeedServer'] = dirname(__FILE__) . '/help/zoneclearFeedServer.html';
}

View File

@ -1,17 +1,15 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of zoneclearFeedServer, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
if (!isset($__resources['help']['zoneclearFeedServer']))
{
$__resources['help']['zoneclearFeedServer'] = dirname(__FILE__).'/help/zoneclearFeedServer.html';
/**
* @brief zoneclearFeedServer, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!isset($__resources['help']['zoneclearFeedServer'])) {
$__resources['help']['zoneclearFeedServer'] = dirname(__FILE__) . '/help/zoneclearFeedServer.html';
}