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 - [ ] fix disallow self blog feeds
- [ ] add plugin muppet support (request Mathieu M.) - [ ] add plugin muppet support (request Mathieu M.)
- [ ] add log for errors - [ ] add log for errors
- add generic filters - add generic filters (dc 2.20)
- add user pref for columns and filters options - add user pref for columns and filters options (dc 2.20)
- fix redirections, page title, posts feed form - fix redirections, page title, posts feed form
- update translation - update translation
- update to PSR12
2021.09.16 2021.09.16
- fix Dotclear 2.19 compatibility - fix Dotclear 2.19 compatibility

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
@ -31,7 +30,7 @@ $_menu['Plugins']->addItem(
); );
# Delete related info about feed post in meta table # 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)) { 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.) # Take care about tweakurls (thanks Mathieu M.)
if (version_compare($core->plugins->moduleInfo('tweakurls', 'version'), '0.8', '>=')) { if (version_compare($core->plugins->moduleInfo('tweakurls', 'version'), '0.8', '>=')) {
$core->addbehavior('zcfsAfterPostCreate', ['zoneclearFeedServer', 'tweakurlsAfterPostCreate']); $core->addbehavior('zcfsAfterPostCreate', ['zoneclearFeedServer', 'tweakurlsAfterPostCreate']);
} }
@ -127,7 +125,7 @@ class zcfsAdminBehaviors
return null; 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['large-icon'] = dcPage::getPF('zoneclearFeedServer/icon-big-update.png');
$fav['url'] = $core->adminurl->get( $fav['url'] = $core->adminurl->get(
'admin.plugin.zoneclearFeedServer', 'admin.plugin.zoneclearFeedServer',
@ -261,8 +259,7 @@ class zcfsAdminBehaviors
} }
} }
$sidebar_items['options-box']['items']['zcfs'] = $sidebar_items['options-box']['items']['zcfs'] = '<div id="zcfs">' .
'<div id="zcfs">'.
'<h5>' . __('Feed source') . '</h5>' . '<h5>' . __('Feed source') . '</h5>' .
'<p>' . '<p>' .
'<a href="' . $url . '" title="' . $author . ' - ' . $url . '">' . __('feed URL') . '</a> - ' . '<a href="' . $url . '" title="' . $author . ' - ' . $url . '">' . __('feed URL') . '</a> - ' .
@ -283,14 +280,14 @@ class zcfsAdminBehaviors
$core->con->execute( $core->con->execute(
'DELETE FROM ' . $core->prefix . 'meta ' . 'DELETE FROM ' . $core->prefix . 'meta ' .
'WHERE post_id = ' . ((integer) $post_id) . ' ' . 'WHERE post_id = ' . ((int) $post_id) . ' ' .
'AND meta_type ' . $core->con->in([ 'AND meta_type ' . $core->con->in([
'zoneclearfeed_url', 'zoneclearfeed_url',
'zoneclearfeed_author', 'zoneclearfeed_author',
'zoneclearfeed_site', 'zoneclearfeed_site',
'zoneclearfeed_sitename', 'zoneclearfeed_sitename',
'zoneclearfeed_id' 'zoneclearfeed_id'
]).' ' ]) . ' '
); );
} }
} }

View File

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

View File

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

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
@ -33,7 +32,9 @@ try {
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false) || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)
) { ) {
throw new Exception(sprintf( throw new Exception(sprintf(
'%s requires Dotclear %s', $mod_id, $dc_min '%s requires Dotclear %s',
$mod_id,
$dc_min
)); ));
} }
@ -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_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_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_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_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_full_tpl', serialize(['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_post_title_redir', serialize(['feed']), 'string', 'List of templates types for redirection to original post', false, true);
# Set module version # Set module version
$core->setVersion( $core->setVersion(
$mod_id, $mod_id,
$this->moduleInfo($mod_id, 'version') $this->moduleInfo($mod_id, 'version')
); );
return true; return true;
} catch (Exception $e) { } catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());

View File

@ -10,12 +10,11 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
$d = dirname(__FILE__).'/inc/'; $d = dirname(__FILE__) . '/inc/';
$__autoload['zoneclearFeedServer'] = $d . 'class.zoneclear.feed.server.php'; $__autoload['zoneclearFeedServer'] = $d . 'class.zoneclear.feed.server.php';
$__autoload['zcfsFeedsList'] = $d . 'lib.zcfs.list.php'; $__autoload['zcfsFeedsList'] = $d . 'lib.zcfs.list.php';
@ -34,5 +33,5 @@ $core->url->register(
// Add to report on plugin activityReport // Add to report on plugin activityReport
if (defined('ACTIVITY_REPORT')) { 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 Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
@ -47,8 +46,8 @@ $tpl_blocks = [
'FeedsHeader', 'FeedsHeader',
'FeedIf' 'FeedIf'
]; ];
foreach($tpl_blocks as $v) { foreach ($tpl_blocks as $v) {
$core->tpl->addBlock('zc' .$v, ['zcfsTemplate', $v]); $core->tpl->addBlock('zc' . $v, ['zcfsTemplate', $v]);
} }
# Register tempalte values # Register tempalte values
@ -70,7 +69,7 @@ $tpl_values = [
'FeedSiteURL', 'FeedSiteURL',
'FeedFeedURL' 'FeedFeedURL'
]; ];
foreach($tpl_values as $v) { foreach ($tpl_values as $v) {
$core->tpl->addValue('zc' . $v, ['zcfsTemplate', $v]); $core->tpl->addValue('zc' . $v, ['zcfsTemplate', $v]);
} }
@ -148,7 +147,7 @@ class zcfsPublicBehaviors
"\n<!-- JS for zoneclearFeedServer --> \n" . "\n<!-- JS for zoneclearFeedServer --> \n" .
dcutils::jsLoad($core->blog->url . $core->url->getBase('zoneclearFeedsPage') . '/zcfsupd.js') . dcutils::jsLoad($core->blog->url . $core->url->getBase('zoneclearFeedsPage') . '/zcfsupd.js') .
"<script type=\"text/javascript\"> \n//<![CDATA[\n" . "<script type=\"text/javascript\"> \n//<![CDATA[\n" .
" \$(function(){if(!document.getElementById){return;} " . ' $(function(){if(!document.getElementById){return;} ' .
" $('body').zoneclearFeedServer({blog_url:'" . " $('body').zoneclearFeedServer({blog_url:'" .
$blog_url . "',blog_id:'" . $blog_id . "'}); " . $blog_url . "',blog_id:'" . $blog_id . "'}); " .
" })\n" . " })\n" .
@ -227,6 +226,7 @@ class zcfsRsExtPosts extends rsExtPost
public static function getAuthorCN($rs) public static function getAuthorCN($rs)
{ {
$author = $rs->zcFeed('author'); $author = $rs->zcFeed('author');
return $author ? return $author ?
$author : $author :
self::zcFeedBrother('getAuthorCN', [&$rs]); self::zcFeedBrother('getAuthorCN', [&$rs]);
@ -265,12 +265,11 @@ class zcfsRsExtPosts extends rsExtPost
$types = @unserialize($rs->core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_post_full_tpl); $types = @unserialize($rs->core->blog->settings->zoneclearFeedServer->zoneclearFeedServer_post_full_tpl);
if (is_array($types) && in_array($rs->core->url->type, $types)) { 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>', '<p class="zoneclear-original"><em>%s</em></p>',
sprintf(__('Original post on <a href="%s">%s</a>'), $url, $sitename) sprintf(__('Original post on <a href="%s">%s</a>'), $url, $sitename)
); );
} else { }
$content = context::remove_html($content); $content = context::remove_html($content);
$content = context::cut_string($content, 350); $content = context::cut_string($content, 350);
$content = html::escapeHTML($content); $content = html::escapeHTML($content);
@ -283,10 +282,9 @@ class zcfsRsExtPosts extends rsExtPost
__('Continue reading') __('Continue reading')
); );
} }
} else {
return $content; return $content;
} }
}
} }
/** /**
@ -327,8 +325,8 @@ class zcfsUrlHandler extends dcUrlHandlers
'Feeds updated successfully' 'Feeds updated successfully'
); );
} }
} catch (Exception $e) {
} }
catch (Exception $e) {}
} }
if (empty($msg)) { if (empty($msg)) {
$msg = sprintf( $msg = sprintf(
@ -389,7 +387,7 @@ class zcfsTemplate
$lastn = -1; $lastn = -1;
$p = ''; $p = '';
if (isset($a['lastn'])) { if (isset($a['lastn'])) {
$lastn = abs((integer) $a['lastn']) +0; $lastn = abs((int) $a['lastn']) + 0;
$p .= "\$zcfs_params['limit'] = " . $lastn . ";\n"; $p .= "\$zcfs_params['limit'] = " . $lastn . ";\n";
} }
if (isset($a['cat_id'])) { if (isset($a['cat_id'])) {
@ -402,7 +400,7 @@ class zcfsTemplate
$p .= "\$zcfs_params['feed_url'] = '" . addslashes($a['site_url']) . "';\n"; $p .= "\$zcfs_params['feed_url'] = '" . addslashes($a['site_url']) . "';\n";
} }
if (isset($a['feed_status'])) { 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 { } else {
$p .= "\$zcfs_params['feed_status'] = 1;\n"; $p .= "\$zcfs_params['feed_status'] = 1;\n";
} }
@ -417,17 +415,27 @@ class zcfsTemplate
$order = 'desc'; $order = 'desc';
if (isset($a['sortby'])) { if (isset($a['sortby'])) {
switch ($a['sortby']) { switch ($a['sortby']) {
case 'name': $sortby = 'lowername'; break; case 'name': $sortby = 'lowername';
case 'owner' : $sortby = 'feed_owner'; break;
case 'date' : $sortby = 'feed_dt'; break; break;
case 'update' : $sortby = 'feed_upddt'; break; case 'owner': $sortby = 'feed_owner';
case 'id' : $sortby = 'feed_id'; break;
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'])) { if (isset($a['order']) && preg_match('/^(desc|asc)$/i', $a['order'])) {
$order = $a['order']; $order = $a['order'];
} }
$p .= "\$zcfs_params['order'] = '" . $sortby . " " . $order . "';\n"; $p .= "\$zcfs_params['order'] = '" . $sortby . ' ' . $order . "';\n";
return return
'<?php ' . $p . '<?php ' . $p .
@ -478,19 +486,19 @@ class zcfsTemplate
} }
} }
if (isset($a['first'])) { if (isset($a['first'])) {
$sign = (boolean) $a['first'] ? '=' : '!'; $sign = (bool) $a['first'] ? '=' : '!';
$if[] = '$_ctx->feeds->index() ' . $sign . '= 0'; $if[] = '$_ctx->feeds->index() ' . $sign . '= 0';
} }
if (isset($a['odd'])) { if (isset($a['odd'])) {
$sign = (boolean) $a['odd'] ? '=' : '!'; $sign = (bool) $a['odd'] ? '=' : '!';
$if[] = '($_ctx->feeds->index()+1)%2 ' .$sign. ' = 1'; $if[] = '($_ctx->feeds->index()+1)%2 ' . $sign . ' = 1';
} }
if (isset($a['has_category'])) { if (isset($a['has_category'])) {
$sign = (boolean) $a['has_category'] ? '' : '!'; $sign = (bool) $a['has_category'] ? '' : '!';
$if[] = $sign . '$_ctx->feeds->cat_id'; $if[] = $sign . '$_ctx->feeds->cat_id';
} }
if (isset($a['has_description'])) { if (isset($a['has_description'])) {
$sign = (boolean) $a['has_description'] ? '' : '!'; $sign = (bool) $a['has_description'] ? '' : '!';
$if[] = $sign . '$_ctx->feeds->feed_desc'; $if[] = $sign . '$_ctx->feeds->feed_desc';
} }
@ -501,7 +509,7 @@ class zcfsTemplate
public static function FeedIfFirst($a) public static function FeedIfFirst($a)
{ {
$ret = isset($a['return']) ? $a['return'] : 'first'; $ret = $a['return'] ?? 'first';
$ret = html::escapeHTML($ret); $ret = html::escapeHTML($ret);
return return
@ -511,7 +519,7 @@ class zcfsTemplate
public static function FeedIfOdd($a) public static function FeedIfOdd($a)
{ {
$ret = isset($a['return']) ? $a['return'] : 'odd'; $ret = $a['return'] ?? 'odd';
$ret = html::escapeHTML($ret); $ret = html::escapeHTML($ret);
return return
@ -561,7 +569,7 @@ class zcfsTemplate
return empty($a['full']) ? return empty($a['full']) ?
'<?php echo ' . sprintf($f, '$_ctx->feeds->feed_lang') . '; ?>' : '<?php echo ' . sprintf($f, '$_ctx->feeds->feed_lang') . '; ?>' :
'<?php $langs = l10n::getISOcodes(); if (isset($langs[$_ctx->feeds->feed_lang])) { echo ' . '<?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); ?>'; sprintf($f, '$_ctx->feeds->feed_lang') . '; } unset($langs); ?>';
} }
@ -582,12 +590,12 @@ class zcfsTemplate
public static function FeedsHeader($a, $c) 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) 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) public static function FeedsCount($a)
@ -614,7 +622,7 @@ class zcfsTemplate
" printf(__('" . $one . "'),\$fcount);\n" . " printf(__('" . $one . "'),\$fcount);\n" .
"} else {\n" . "} else {\n" .
" printf(__('" . $more . "'),\$fcount);\n" . " printf(__('" . $more . "'),\$fcount);\n" .
"} unset(\$fcount); ?>"; '} unset($fcount); ?>';
} }
public static function FeedsEntriesCount($a) public static function FeedsEntriesCount($a)
@ -636,7 +644,7 @@ class zcfsTemplate
return return
"<?php \$fcount = 0; \$allfeeds = \$_ctx->feeds->zc->getFeeds(); \n" . "<?php \$fcount = 0; \$allfeeds = \$_ctx->feeds->zc->getFeeds(); \n" .
"if (!\$allfeeds->isEmpty()) { \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); " . " \$fcount += (integer) \$_ctx->feeds->zc->getPostsByFeed(array('feed_id'=>\$allfeeds->feed_id),true)->f(0); " .
" } \n" . " } \n" .
"} \n" . "} \n" .
@ -646,7 +654,7 @@ class zcfsTemplate
" printf(__('" . $one . "'),\$fcount);\n" . " printf(__('" . $one . "'),\$fcount);\n" .
"} else {\n" . "} else {\n" .
" printf(__('" . $more . "'),\$fcount);\n" . " printf(__('" . $more . "'),\$fcount);\n" .
"} unset(\$allfeeds,\$fcount); ?>"; '} unset($allfeeds,$fcount); ?>';
} }
public static function FeedEntriesCount($a) public static function FeedEntriesCount($a)
@ -666,14 +674,14 @@ class zcfsTemplate
} }
return 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" . "if (\$fcount == 0) {\n" .
" printf(__('" . $none . "'),\$fcount);\n" . " printf(__('" . $none . "'),\$fcount);\n" .
"} elseif (\$fcount == 1) {\n" . "} elseif (\$fcount == 1) {\n" .
" printf(__('" . $one . "'),\$fcount);\n" . " printf(__('" . $one . "'),\$fcount);\n" .
"} else {\n" . "} else {\n" .
" printf(__('" . $more . "'),\$fcount);\n" . " printf(__('" . $more . "'),\$fcount);\n" .
"} unset(\$fcount); ?>"; '} unset($fcount); ?>';
} }
protected static function getValue($a, $v) protected static function getValue($a, $v)
@ -683,8 +691,7 @@ class zcfsTemplate
protected static function getOperator($op) protected static function getOperator($op)
{ {
switch (strtolower($op)) switch (strtolower($op)) {
{
case 'or': case 'or':
case '||': case '||':
return '||'; return '||';

View File

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

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
@ -108,8 +107,8 @@ class zoneclearFeedServerWidget
) )
->setting( ->setting(
'title', 'title',
__('Title:') __('Title:'),
,__('Feeds numbers'), __('Feeds numbers'),
'text' 'text'
) )
->setting( ->setting(
@ -166,7 +165,7 @@ class zoneclearFeedServerWidget
$p['order'] = ($w->sortby && in_array($w->sortby, ['feed_upd_last', 'lowername', 'feed_creadt'])) ? $p['order'] = ($w->sortby && in_array($w->sortby, ['feed_upd_last', 'lowername', 'feed_creadt'])) ?
$w->sortby . ' ' : 'feed_upd_last '; $w->sortby . ' ' : 'feed_upd_last ';
$p['order'] .= $w->sort == 'desc' ? 'DESC' : 'ASC'; $p['order'] .= $w->sort == 'desc' ? 'DESC' : 'ASC';
$p['limit'] = abs((integer) $w->limit); $p['limit'] = abs((int) $w->limit);
$p['feed_status'] = 1; $p['feed_status'] = 1;
$zc = new zoneclearFeedServer($core); $zc = new zoneclearFeedServer($core);
@ -178,7 +177,7 @@ class zoneclearFeedServerWidget
$lines = []; $lines = [];
$i = 1; $i = 1;
while($rs->fetch()) { while ($rs->fetch()) {
$lines[] = sprintf( $lines[] = sprintf(
'<li><a href="%s" title="%s">%s</a></li>', '<li><a href="%s" title="%s">%s</a></li>',
$rs->feed_url, $rs->feed_url,
@ -257,7 +256,7 @@ class zoneclearFeedServerWidget
if (!$feeds->isEmpty()) { if (!$feeds->isEmpty()) {
while ($feeds->fetch()) { 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( $title = ($w->entry_title ? sprintf(

View File

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

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
class zcfsFeedsActionsPage extends dcActionsPage class zcfsFeedsActionsPage extends dcActionsPage
{ {
public $zcfs; public $zcfs;
@ -76,7 +75,7 @@ class zcfsFeedsActionsPage extends dcActionsPage
$this->rs = $feeds; $this->rs = $feeds;
} else { } else {
$this->rs = $this->core->con->select( $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'
); );
} }
} }
@ -135,7 +134,7 @@ class zcfsDefaultFeedsActions
throw new Exception(__('No feeds selected')); throw new Exception(__('No feeds selected'));
} }
foreach($ids as $id) { foreach ($ids as $id) {
$ap->zcfs->enableFeed($id, $enable); $ap->zcfs->enableFeed($id, $enable);
} }
@ -151,8 +150,7 @@ class zcfsDefaultFeedsActions
'%d feed has been successfully disabled.', '%d feed has been successfully disabled.',
'%d feeds have been successfully disabled.', '%d feeds have been successfully disabled.',
count($ids) count($ids)
) ),
,
count($ids) count($ids)
)); ));
$ap->redirect(true); $ap->redirect(true);
@ -174,14 +172,12 @@ class zcfsDefaultFeedsActions
throw new Exception(__('No feeds selected')); throw new Exception(__('No feeds selected'));
} }
foreach($ids as $id) { foreach ($ids as $id) {
$posts = $ap->zcfs->getPostsByFeed([ $posts = $ap->zcfs->getPostsByFeed([
'feed_id' => $id 'feed_id' => $id
]); ]);
while($posts->fetch()) { while ($posts->fetch()) {
$core->blog->delPost($posts->post_id); $core->blog->delPost($posts->post_id);
$core->con->execute( $core->con->execute(
'DELETE FROM ' . $core->prefix . 'meta ' . 'DELETE FROM ' . $core->prefix . 'meta ' .
@ -205,7 +201,7 @@ class zcfsDefaultFeedsActions
throw new Exception(__('No feeds selected')); throw new Exception(__('No feeds selected'));
} }
foreach($ids as $id) { foreach ($ids as $id) {
$ap->zcfs->delFeed($id); $ap->zcfs->delFeed($id);
} }
@ -228,7 +224,7 @@ class zcfsDefaultFeedsActions
throw new Exception(__('No feeds selected')); throw new Exception(__('No feeds selected'));
} }
foreach($ids as $id) { foreach ($ids as $id) {
$ap->zcfs->checkFeedsUpdate($id, true); $ap->zcfs->checkFeedsUpdate($id, true);
} }
@ -251,7 +247,7 @@ class zcfsDefaultFeedsActions
throw new Exception(__('No feeds selected')); throw new Exception(__('No feeds selected'));
} }
foreach($ids as $id) { foreach ($ids as $id) {
$cur = $ap->zcfs->openCursor(); $cur = $ap->zcfs->openCursor();
$cur->feed_upd_last = 0; $cur->feed_upd_last = 0;
$ap->zcfs->updFeed($id, $cur); $ap->zcfs->updFeed($id, $cur);
@ -278,9 +274,9 @@ class zcfsDefaultFeedsActions
throw new Exception(__('No feeds selected')); 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) { foreach ($ids as $id) {
$cur = $ap->zcfs->openCursor(); $cur = $ap->zcfs->openCursor();
$cur->cat_id = $cat_id == 0 ? null : $cat_id; $cur->cat_id = $cat_id == 0 ? null : $cat_id;
$ap->zcfs->updFeed($id, $cur); $ap->zcfs->updFeed($id, $cur);
@ -306,7 +302,8 @@ class zcfsDefaultFeedsActions
__('Feeds server') => '', __('Feeds server') => '',
$ap->getCallerTitle() => $ap->getRedirection(true), $ap->getCallerTitle() => $ap->getRedirection(true),
__('Change category for this selection') => '' __('Change category for this selection') => ''
])); ])
);
echo echo
'<form action="' . $ap->getURI() . '" method="post">' . '<form action="' . $ap->getURI() . '" method="post">' .
@ -332,9 +329,9 @@ class zcfsDefaultFeedsActions
throw new Exception(__('No feeds selected')); 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) { foreach ($ids as $id) {
$cur = $ap->zcfs->openCursor(); $cur = $ap->zcfs->openCursor();
$cur->feed_upd_int = $upd_int; $cur->feed_upd_int = $upd_int;
$ap->zcfs->updFeed($id, $cur); $ap->zcfs->updFeed($id, $cur);
@ -349,9 +346,7 @@ class zcfsDefaultFeedsActions
count($ids) count($ids)
)); ));
$ap->redirect(true); $ap->redirect(true);
} } else {
else {
$ap->beginPage( $ap->beginPage(
dcPage::breadcrumb( dcPage::breadcrumb(
[ [
@ -359,7 +354,9 @@ class zcfsDefaultFeedsActions
__('Feeds server') => '', __('Feeds server') => '',
$ap->getCallerTitle() => $ap->getRedirection(true), $ap->getCallerTitle() => $ap->getRedirection(true),
__('Change update frequency for this selection') => '' __('Change update frequency for this selection') => ''
])); ]
)
);
echo echo
'<form action="' . $ap->getURI() . '" method="post">' . '<form action="' . $ap->getURI() . '" method="post">' .

View File

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
@ -66,7 +65,7 @@ class zoneclearFeedServer
$this->con->writeLock($this->table); $this->con->writeLock($this->table);
try { try {
$id = (integer) $id; $id = (int) $id;
if ($id < 1) { if ($id < 1) {
throw new Exception(__('No such ID')); throw new Exception(__('No such ID'));
@ -83,6 +82,7 @@ class zoneclearFeedServer
$this->trigger(); $this->trigger();
} catch (Exception $e) { } catch (Exception $e) {
$this->con->unlock(); $this->con->unlock();
throw $e; throw $e;
} }
@ -112,6 +112,7 @@ class zoneclearFeedServer
$this->trigger(); $this->trigger();
} catch (Exception $e) { } catch (Exception $e) {
$this->con->unlock(); $this->con->unlock();
throw $e; throw $e;
} }
@ -131,7 +132,7 @@ class zoneclearFeedServer
public function enableFeed($id, $enable = true, $time = null) public function enableFeed($id, $enable = true, $time = null)
{ {
try { try {
$id = (integer) $id; $id = (int) $id;
if ($id < 1) { if ($id < 1) {
throw new Exception(__('No such ID')); throw new Exception(__('No such ID'));
@ -141,9 +142,9 @@ class zoneclearFeedServer
$this->con->writeLock($this->table); $this->con->writeLock($this->table);
$cur->feed_upddt = date('Y-m-d H:i:s'); $cur->feed_upddt = date('Y-m-d H:i:s');
$cur->feed_status = (integer) $enable; $cur->feed_status = (int) $enable;
if (null !== $time) { if (null !== $time) {
$cur->feed_upd_last = (integer) $time; $cur->feed_upd_last = (int) $time;
} }
$cur->update(sprintf( $cur->update(sprintf(
@ -155,6 +156,7 @@ class zoneclearFeedServer
$this->trigger(); $this->trigger();
} catch (Exception $e) { } catch (Exception $e) {
$this->con->unlock(); $this->con->unlock();
throw $e; throw $e;
} }
@ -170,7 +172,7 @@ class zoneclearFeedServer
*/ */
public function delFeed($id) public function delFeed($id)
{ {
$id = (integer) $id; $id = (int) $id;
if ($id < 1) { if ($id < 1) {
throw new Exception(__('No such ID')); throw new Exception(__('No such ID'));
@ -195,17 +197,15 @@ class zoneclearFeedServer
* @param boolean $count_only Return only result count * @param boolean $count_only Return only result count
* @return record record instance * @return record record instance
*/ */
public function getPostsByFeed($params = array(), $count_only = false) public function getPostsByFeed($params = [], $count_only = false)
{ {
if (!isset($params['feed_id'])) { if (!isset($params['feed_id'])) {
return null; return null;
} }
$params['from'] = $params['from'] = 'LEFT JOIN ' . $this->core->prefix . 'meta F ' .
'LEFT JOIN ' . $this->core->prefix . 'meta F ' .
'ON P.post_id = F.post_id '; 'ON P.post_id = F.post_id ';
$params['sql'] = $params['sql'] = "AND P.blog_id = '" . $this->blog . "' " .
"AND P.blog_id = '" . $this->blog . "' " .
"AND F.meta_type = 'zoneclearfeed_id' " . "AND F.meta_type = 'zoneclearfeed_id' " .
"AND F.meta_id = '" . $this->con->escape($params['feed_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 * @param boolean $count_only Return only result count
* @return record record instance * @return record record instance
*/ */
public function getFeeds($params = array(), $count_only = false) public function getFeeds($params = [], $count_only = false)
{ {
if ($count_only) { if ($count_only) {
$strReq = 'SELECT count(Z.feed_id) '; $strReq = 'SELECT count(Z.feed_id) ';
@ -231,8 +231,7 @@ class zoneclearFeedServer
$content_req .= implode(', ', $params['columns']) . ', '; $content_req .= implode(', ', $params['columns']) . ', ';
} }
$strReq = $strReq = 'SELECT Z.feed_id, Z.feed_creadt, Z.feed_upddt, Z.feed_type, ' .
'SELECT Z.feed_id, Z.feed_creadt, Z.feed_upddt, Z.feed_type, ' .
'Z.blog_id, Z.cat_id, ' . 'Z.blog_id, Z.cat_id, ' .
'Z.feed_upd_int, Z.feed_upd_last, Z.feed_status, ' . 'Z.feed_upd_int, Z.feed_upd_last, Z.feed_status, ' .
$content_req . $content_req .
@ -243,8 +242,7 @@ class zoneclearFeedServer
'C.cat_title, C.cat_url, C.cat_desc '; 'C.cat_title, C.cat_url, C.cat_desc ';
} }
$strReq .= $strReq .= 'FROM ' . $this->table . ' Z ' .
'FROM ' . $this->table . ' Z ' .
'LEFT OUTER JOIN ' . $this->core->prefix . 'category C ON Z.cat_id = C.cat_id '; 'LEFT OUTER JOIN ' . $this->core->prefix . 'category C ON Z.cat_id = C.cat_id ';
if (!empty($params['from'])) { if (!empty($params['from'])) {
@ -261,9 +259,9 @@ class zoneclearFeedServer
if (!empty($params['feed_id'])) { if (!empty($params['feed_id'])) {
if (is_array($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 { } 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']); $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']) . "' "; $strReq .= "AND Z.feed_url = '" . $this->con->escape($params['feed_url']) . "' ";
} }
if (isset($params['feed_status'])) { 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'])) { if (!empty($params['q'])) {
@ -327,7 +325,7 @@ class zoneclearFeedServer
try { try {
# Need flock function # Need flock function
if (!function_exists('flock')) { 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 ? # Cache writable ?
if (!is_writable(DC_TPL_CACHE)) { if (!is_writable(DC_TPL_CACHE)) {
@ -353,18 +351,18 @@ class zoneclearFeedServer
if (!file_exists($cached_file)) { if (!file_exists($cached_file)) {
!$fp = @fopen($cached_file, 'w'); !$fp = @fopen($cached_file, 'w');
if ($fp === false) { if ($fp === false) {
throw New Exception("Can't create file"); throw new Exception("Can't create file");
} }
fwrite($fp, '1', strlen('1')); fwrite($fp, '1', strlen('1'));
fclose($fp); fclose($fp);
} }
# Open file # Open file
if (!($fp = @fopen($cached_file, 'r+'))) { if (!($fp = @fopen($cached_file, 'r+'))) {
throw New Exception("Can't open file"); throw new Exception("Can't open file");
} }
# Lock file # Lock file
if (!flock($fp, LOCK_EX)) { if (!flock($fp, LOCK_EX)) {
throw New Exception("Can't lock file"); throw new Exception("Can't lock file");
} }
$this->lock = $fp; $this->lock = $fp;
@ -378,7 +376,6 @@ class zoneclearFeedServer
/** /**
* Unlock file of update process. * Unlock file of update process.
*
*/ */
public function unlockUpdate() public function unlockUpdate()
{ {
@ -426,7 +423,7 @@ class zoneclearFeedServer
$updates = false; $updates = false;
$loop_mem = []; $loop_mem = [];
$limit = abs((integer) $s->zoneclearFeedServer_update_limit); $limit = abs((int) $s->zoneclearFeedServer_update_limit);
if ($limit < 1) { if ($limit < 1) {
$limit = 10; $limit = 10;
} }
@ -435,7 +432,7 @@ class zoneclearFeedServer
$cur_post = $this->con->openCursor($this->core->prefix . 'post'); $cur_post = $this->con->openCursor($this->core->prefix . 'post');
$cur_meta = $this->con->openCursor($this->core->prefix . 'meta'); $cur_meta = $this->con->openCursor($this->core->prefix . 'meta');
while($f->fetch()) { while ($f->fetch()) {
# Check if feed need update # Check if feed need update
if ($id || $i < $limit && $f->feed_status == 1 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
@ -499,7 +496,7 @@ class zoneclearFeedServer
$old_post = $this->con->select( $old_post = $this->con->select(
'SELECT P.post_id, P.post_status ' . 'SELECT P.post_id, P.post_status ' .
'FROM ' . $this->core->prefix . 'post P ' . '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 ' . 'ON P.post_id = M.post_id ' .
"WHERE blog_id='" . $this->blog . "' " . "WHERE blog_id='" . $this->blog . "' " .
"AND meta_type = 'zoneclearfeed_url' " . "AND meta_type = 'zoneclearfeed_url' " .
@ -513,7 +510,7 @@ class zoneclearFeedServer
$cur_post->cat_id = $f->cat_id; $cur_post->cat_id = $f->cat_id;
} }
$post_content = $item->content ? $item->content : $item->description; $post_content = $item->content ? $item->content : $item->description;
$cur_post->post_content = html::absoluteURLs($post_content,$feed->link); $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); $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; $creator = $item->creator ? $item->creator : $f->feed_owner;
@ -523,7 +520,7 @@ class zoneclearFeedServer
# Post # Post
$cur_post->user_id = $this->core->auth->userID(); $cur_post->user_id = $this->core->auth->userID();
$cur_post->post_format = 'xhtml'; $cur_post->post_format = 'xhtml';
$cur_post->post_status = (integer) $s->zoneclearFeedServer_post_status_new; $cur_post->post_status = (int) $s->zoneclearFeedServer_post_status_new;
$cur_post->post_open_comment = 0; $cur_post->post_open_comment = 0;
$cur_post->post_open_tb = 0; $cur_post->post_open_tb = 0;
@ -627,7 +624,7 @@ class zoneclearFeedServer
if ($f->feed_get_tags) { if ($f->feed_get_tags) {
# Some feed subjects contains more than one tag # Some feed subjects contains more than one tag
foreach($item->subject as $subjects) { foreach ($item->subject as $subjects) {
$tmp = $this->core->meta->splitMetaValues($subjects); $tmp = $this->core->meta->splitMetaValues($subjects);
$tags = array_merge($tags, $tmp); $tags = array_merge($tags, $tmp);
} }
@ -637,10 +634,16 @@ class zoneclearFeedServer
foreach ($tags as $tag) { foreach ($tags as $tag) {
# Change tags case # Change tags case
switch((integer) $s->zoneclearFeedServer_tag_case) { switch ((int) $s->zoneclearFeedServer_tag_case) {
case 3: $tag = strtoupper($tag); break; case 3: $tag = strtoupper($tag);
case 2: $tag = strtolower($tag); break;
case 1: $tag = ucfirst(strtolower($tag)); break; break;
case 2: $tag = strtolower($tag);
break;
case 1: $tag = ucfirst(strtolower($tag));
break;
default: /* do nothing */ break; default: /* do nothing */ break;
} }
if (!in_array($tag, $formated_tags)) { if (!in_array($tag, $formated_tags)) {
@ -663,11 +666,11 @@ class zoneclearFeedServer
$cur_post, $cur_post,
$meta $meta
); );
} catch (Exception $e) { } catch (Exception $e) {
$this->con->rollback(); $this->con->rollback();
$this->enableUser(false); $this->enableUser(false);
$this->unlockUpdate(); $this->unlockUpdate();
throw $e; throw $e;
} }
$updates = true; $updates = true;
@ -710,7 +713,7 @@ class zoneclearFeedServer
public static function readFeed($f) public static function readFeed($f)
{ {
try { try {
$feed_reader = new feedReader; $feed_reader = new feedReader();
$feed_reader->setCacheDir(DC_TPL_CACHE); $feed_reader->setCacheDir(DC_TPL_CACHE);
$feed_reader->setTimeout(self::$nethttp_timeout); $feed_reader->setTimeout(self::$nethttp_timeout);
$feed_reader->setMaxRedirects(self::$nethttp_maxredirect); $feed_reader->setMaxRedirects(self::$nethttp_maxredirect);
@ -840,8 +843,8 @@ class zoneclearFeedServer
'FROM ' . $this->con->escapeSystem($this->core->prefix . 'user') . ' U ' . 'FROM ' . $this->con->escapeSystem($this->core->prefix . 'user') . ' U ' .
'LEFT JOIN ' . $this->con->escapeSystem($this->core->prefix . 'permissions') . ' P ' . 'LEFT JOIN ' . $this->con->escapeSystem($this->core->prefix . 'permissions') . ' P ' .
'ON U.user_id=P.user_id ' . 'ON U.user_id=P.user_id ' .
'WHERE U.user_status = 1 '. 'WHERE U.user_status = 1 ' .
"AND P.blog_id = '" .$this->blog . "' " . "AND P.blog_id = '" . $this->blog . "' " .
"AND P.permissions LIKE '%|admin|%' " "AND P.permissions LIKE '%|admin|%' "
); );
@ -868,7 +871,7 @@ class zoneclearFeedServer
*/ */
public static function getPublicUrlTypes(dcCore $core) public static function getPublicUrlTypes(dcCore $core)
{ {
$types = array(); $types = [];
# --BEHAVIOR-- zoneclearFeedServerPublicUrlTypes # --BEHAVIOR-- zoneclearFeedServerPublicUrlTypes
$core->callBehavior('zoneclearFeedServerPublicUrlTypes', $types); $core->callBehavior('zoneclearFeedServerPublicUrlTypes', $types);
@ -893,6 +896,6 @@ class zoneclearFeedServer
{ {
global $core; global $core;
$cur->post_url = tweakUrls::tweakBlogURL($cur->post_url); $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 Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; 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')) { if (!defined('DC_CONTEXT_ADMIN')) {
global $core; global $core;

View File

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

View File

@ -10,13 +10,11 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
if ($core->getVersion('zoneclearFeedServer') != if ($core->getVersion('zoneclearFeedServer') != $core->plugins->moduleInfo('zoneclearFeedServer', 'version')
$core->plugins->moduleInfo('zoneclearFeedServer', 'version')
) { ) {
return null; return null;
} }
@ -58,11 +56,12 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
$combo_status = $zcfs->getAllStatus(); $combo_status = $zcfs->getAllStatus();
$combo_upd_int = $zcfs->getAllUpdateInterval(); $combo_upd_int = $zcfs->getAllUpdateInterval();
$combo_categories = ['-' => '']; $combo_categories = ['-' => ''];
try { try {
$categories = $core->blog->getCategories(['post_type' => 'post']); $categories = $core->blog->getCategories(['post_type' => 'post']);
while ($categories->fetch()) { while ($categories->fetch()) {
$combo_categories[ $combo_categories[
str_repeat('&nbsp;&nbsp;', $categories->level-1) . str_repeat('&nbsp;&nbsp;', $categories->level - 1) .
'&bull; ' . html::escapeHTML($categories->cat_title) '&bull; ' . html::escapeHTML($categories->cat_title)
] = $categories->cat_id; ] = $categories->cat_id;
} }
@ -92,29 +91,45 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
$feed_status = $feed->feed_status; $feed_status = $feed->feed_status;
$feed_upd_int = $feed->feed_upd_int; $feed_upd_int = $feed->feed_upd_int;
$next_params = array( $next_params = [
'sql' => 'AND feed_id < ' . $feed_id . ' ', 'sql' => 'AND feed_id < ' . $feed_id . ' ',
'limit' => 1 'limit' => 1
); ];
$next_rs = $zcfs->getFeeds($next_params); $next_rs = $zcfs->getFeeds($next_params);
$prev_params = array( $prev_params = [
'sql' => 'AND feed_id > ' . $feed_id . ' ', 'sql' => 'AND feed_id > ' . $feed_id . ' ',
'limit' => 1 'limit' => 1
); ];
$prev_rs = $zcfs->getFeeds($prev_params); $prev_rs = $zcfs->getFeeds($prev_params);
if (!$next_rs->isEmpty()) { if (!$next_rs->isEmpty()) {
$next_link = sprintf($feed_link, $next_rs->feed_id, $next_link = sprintf(
html::escapeHTML($next_rs->feed_name), __('next feed') . '&nbsp;&#187;'); $feed_link,
$next_headlink = sprintf($feed_headlink, 'next', $next_rs->feed_id,
html::escapeHTML($next_rs->feed_name), $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()) { if (!$prev_rs->isEmpty()) {
$prev_link = sprintf($feed_link, $prev_rs->feed_id, $prev_link = sprintf(
html::escapeHTML($prev_rs->feed_name), '&#171;&nbsp;' . __('previous feed')); $feed_link,
$prev_headlink = sprintf($feed_headlink, 'previous', $prev_rs->feed_id,
html::escapeHTML($prev_rs->feed_name), $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
);
} }
} }
} }
@ -133,12 +148,12 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
$feed_cat_id = $_POST['feed_cat_id']; $feed_cat_id = $_POST['feed_cat_id'];
$feed_upd_int = $_POST['feed_upd_int']; $feed_upd_int = $_POST['feed_upd_int'];
if (isset($_POST['feed_status'])) { if (isset($_POST['feed_status'])) {
$feed_status = (integer) $_POST['feed_status']; $feed_status = (int) $_POST['feed_status'];
} }
$testfeed_params['feed_feed'] = $feed_feed; $testfeed_params['feed_feed'] = $feed_feed;
if ($feed_id) { 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)) { if ($zcfs->getFeeds($testfeed_params, true)->f(0)) {
throw new Exception(__('Record with same feed URL already exists.')); throw new Exception(__('Record with same feed URL already exists.'));
@ -174,10 +189,10 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
$cur->feed_feed = $feed_feed; $cur->feed_feed = $feed_feed;
$cur->feed_lang = $feed_lang; $cur->feed_lang = $feed_lang;
$cur->feed_tags = $feed_tags; $cur->feed_tags = $feed_tags;
$cur->feed_get_tags = (integer) $feed_get_tags; $cur->feed_get_tags = (int) $feed_get_tags;
$cur->cat_id = $feed_cat_id != '' ? (integer) $feed_cat_id : null; $cur->cat_id = $feed_cat_id != '' ? (int) $feed_cat_id : null;
$cur->feed_status = (integer) $feed_status; $cur->feed_status = (int) $feed_status;
$cur->feed_upd_int = (integer) $feed_upd_int; $cur->feed_upd_int = (int) $feed_upd_int;
# Update feed # Update feed
if ($feed_id) { if ($feed_id) {
@ -194,7 +209,8 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
__('Feed successfully updated.') __('Feed successfully updated.')
); );
$core->adminurl->redirect( $core->adminurl->redirect(
'admin.plugin.zoneclearFeedServer', ['part' => 'feed', 'feed_id' => $feed_id] 'admin.plugin.zoneclearFeedServer',
['part' => 'feed', 'feed_id' => $feed_id]
); );
} catch (Exception $e) { } catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
@ -213,7 +229,8 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
__('Feed successfully created.') __('Feed successfully created.')
); );
$core->adminurl->redirect( $core->adminurl->redirect(
'admin.plugin.zoneclearFeedServer', ['part' => 'feed', 'feed_id' => $return_id] 'admin.plugin.zoneclearFeedServer',
['part' => 'feed', 'feed_id' => $return_id]
); );
} catch (Exception $e) { } catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
@ -263,7 +280,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
# posts # posts
try { try {
$posts = $zcfs->getPostsByFeed($params); $posts = $zcfs->getPostsByFeed($params);
$counter = $zcfs->getPostsByFeed($params,true); $counter = $zcfs->getPostsByFeed($params, true);
$post_list = new zcfsEntriesList( $post_list = new zcfsEntriesList(
$core, $core,
$posts, $posts,
@ -278,7 +295,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
echo echo
'<html><head><title>' . __('Feeds server') . '</title>' . '<html><head><title>' . __('Feeds server') . '</title>' .
($feed_id && !$core->error->flag() ? ($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::jsLoad(dcPage::getPF('zoneclearFeedServer/js/list.js'))
: '') . : '') .
dcPage::jsPageTabs() . dcPage::jsPageTabs() .
@ -293,9 +310,9 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
__('Plugins') => '', __('Plugins') => '',
__('Feeds server') => $p_url, __('Feeds server') => $p_url,
($feed_id ? __('Edit feed') : __('New feed')) => '' ($feed_id ? __('Edit feed') : __('New feed')) => ''
]). ]) .
dcPage::notices() . dcPage::notices() .
($feed_id ? '<h3>' . sprintf(__('Edit feed "%s"'), $feed_name) .'</h3>' : ''); ($feed_id ? '<h3>' . sprintf(__('Edit feed "%s"'), $feed_name) . '</h3>' : '');
# Feed # Feed
if ($can_view_page) { if ($can_view_page) {
@ -394,7 +411,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
'</div>' . '</div>' .
'<p class="clear"> '<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', [ $core->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', [
'part' => 'feed', 'part' => 'feed',
'feed_id' => $feed_id, 'feed_id' => $feed_id,
@ -408,10 +425,11 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
# entries # entries
if ($feed_id && $can_view_page && !$core->error->flag()) { 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 # show filters
$post_filter->display(['admin.plugin.zoneclearFeedServer','#entries'], $post_filter->display(
['admin.plugin.zoneclearFeedServer','#entries'],
$core->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', [ $core->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', [
'part' => 'feed', 'part' => 'feed',
'feed_id' => $feed_id 'feed_id' => $feed_id
@ -428,7 +446,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
$post_filter->page, $post_filter->page,
$post_filter->nb, $post_filter->nb,
$core->adminurl->get('admin.plugin.zoneclearFeedServer', $args, '&') . '#entries', $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' . '%s' .
'<div class="two-cols">' . '<div class="two-cols">' .
@ -448,12 +466,11 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
echo '</div>'; echo '</div>';
} }
############################################################ ############################################################
# #
# All feeds # All feeds
# #
############################################################ ############################################################
} else { } else {
# actions # actions
$feeds_actions_page = new zcfsFeedsActionsPage( $feeds_actions_page = new zcfsFeedsActionsPage(
@ -500,7 +517,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
dcPage::breadcrumb([ dcPage::breadcrumb([
__('Plugins') => '', __('Plugins') => '',
__('Feeds server') => '' __('Feeds server') => ''
]). ]) .
dcPage::notices() . dcPage::notices() .
'<p class="top-add">' . '<p class="top-add">' .
@ -512,7 +529,9 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
$core->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', ['part', 'feeds']) $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">' . '<form action="' . $core->adminurl->get('admin.plugin.zoneclearFeedServer', ['part', 'feeds']) . '" method="post" id="form-actions">' .
'%s' . '%s' .
'<div class="two-cols">' . '<div class="two-cols">' .

View File

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

View File

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