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,7 +125,7 @@ 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(
'admin.plugin.zoneclearFeedServer',
@ -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,13 +20,13 @@ $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;
$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;
@ -50,10 +49,10 @@ if (!empty($_POST['save'])) {
$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']);
$bhv_pub_upd = (int) $_POST['bhv_pub_upd'];
$limit = abs((int) $_POST['update_limit']);
$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_title_redir = $_POST['post_title_redir'];
$feeduser = (string) $_POST['feeduser'];
@ -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
));
}
@ -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,12 +10,11 @@
* @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';
@ -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]);
@ -265,12 +265,11 @@ class zcfsRsExtPosts extends rsExtPost
$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(
'<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);
@ -283,10 +282,9 @@ class zcfsRsExtPosts extends rsExtPost
__('Continue reading')
);
}
} else {
return $content;
}
}
}
/**
@ -327,8 +325,8 @@ class zcfsUrlHandler extends dcUrlHandlers
'Feeds updated successfully'
);
}
} catch (Exception $e) {
}
catch (Exception $e) {}
}
if (empty($msg)) {
$msg = sprintf(
@ -389,7 +387,7 @@ class zcfsTemplate
$lastn = -1;
$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";
}
@ -417,17 +415,27 @@ class zcfsTemplate
$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 .
@ -478,19 +486,19 @@ class zcfsTemplate
}
}
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,12 +590,12 @@ 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)
@ -614,7 +622,7 @@ class zcfsTemplate
" printf(__('" . $one . "'),\$fcount);\n" .
"} else {\n" .
" printf(__('" . $more . "'),\$fcount);\n" .
"} unset(\$fcount); ?>";
'} unset($fcount); ?>';
}
public static function FeedsEntriesCount($a)
@ -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,7 +654,7 @@ class zcfsTemplate
" printf(__('" . $one . "'),\$fcount);\n" .
"} else {\n" .
" printf(__('" . $more . "'),\$fcount);\n" .
"} unset(\$allfeeds,\$fcount); ?>";
'} unset($allfeeds,$fcount); ?>';
}
public static function FeedEntriesCount($a)
@ -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;
}
@ -108,8 +107,8 @@ class zoneclearFeedServerWidget
)
->setting(
'title',
__('Title:')
,__('Feeds numbers'),
__('Title:'),
__('Feeds numbers'),
'text'
)
->setting(
@ -166,7 +165,7 @@ class zoneclearFeedServerWidget
$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);
@ -178,7 +177,7 @@ class zoneclearFeedServerWidget
$lines = [];
$i = 1;
while($rs->fetch()) {
while ($rs->fetch()) {
$lines[] = sprintf(
'<li><a href="%s" title="%s">%s</a></li>',
$rs->feed_url,
@ -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;
@ -76,7 +75,7 @@ class zcfsFeedsActionsPage extends dcActionsPage
$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'
);
}
}
@ -135,7 +134,7 @@ class zcfsDefaultFeedsActions
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 ' .
@ -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,7 +247,7 @@ class zcfsDefaultFeedsActions
throw new Exception(__('No feeds selected'));
}
foreach($ids as $id) {
foreach ($ids as $id) {
$cur = $ap->zcfs->openCursor();
$cur->feed_upd_last = 0;
$ap->zcfs->updFeed($id, $cur);
@ -278,9 +274,9 @@ 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) {
foreach ($ids as $id) {
$cur = $ap->zcfs->openCursor();
$cur->cat_id = $cat_id == 0 ? null : $cat_id;
$ap->zcfs->updFeed($id, $cur);
@ -306,7 +302,8 @@ class zcfsDefaultFeedsActions
__('Feeds server') => '',
$ap->getCallerTitle() => $ap->getRedirection(true),
__('Change category for this selection') => ''
]));
])
);
echo
'<form action="' . $ap->getURI() . '" method="post">' .
@ -332,9 +329,9 @@ 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) {
foreach ($ids as $id) {
$cur = $ap->zcfs->openCursor();
$cur->feed_upd_int = $upd_int;
$ap->zcfs->updFeed($id, $cur);
@ -349,9 +346,7 @@ class zcfsDefaultFeedsActions
count($ids)
));
$ap->redirect(true);
}
else {
} else {
$ap->beginPage(
dcPage::breadcrumb(
[
@ -359,7 +354,9 @@ class zcfsDefaultFeedsActions
__('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;
}
@ -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;
}
@ -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'));
@ -141,9 +142,9 @@ class zoneclearFeedServer
$this->con->writeLock($this->table);
$cur->feed_upddt = date('Y-m-d H:i:s');
$cur->feed_status = (integer) $enable;
$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'])) {
@ -327,7 +325,7 @@ 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)) {
@ -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()
{
@ -426,7 +423,7 @@ class zoneclearFeedServer
$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
@ -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' " .
@ -513,7 +510,7 @@ class zoneclearFeedServer
$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_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;
@ -523,7 +520,7 @@ class zoneclearFeedServer
# 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->post_status = (int) $s->zoneclearFeedServer_post_status_new;
$cur_post->post_open_comment = 0;
$cur_post->post_open_tb = 0;
@ -627,7 +624,7 @@ class zoneclearFeedServer
if ($f->feed_get_tags) {
# Some feed subjects contains more than one tag
foreach($item->subject as $subjects) {
foreach ($item->subject as $subjects) {
$tmp = $this->core->meta->splitMetaValues($subjects);
$tags = array_merge($tags, $tmp);
}
@ -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;
@ -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>';
@ -93,7 +92,7 @@ class zcfsFeedsList extends adminGenericList
$entries_count = $this->rs->zc->getPostsByFeed(['feed_id' => $this->rs->feed_id], true)->f(0);
$shunk_feed = $this->rs->feed_feed;
if (strlen($shunk_feed) > 83) {
$shunk_feed = substr($shunk_feed,0,50).'...'.substr($shunk_feed,-20);
$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;
@ -106,18 +105,20 @@ class zcfsFeedsList extends adminGenericList
'<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>'.
'<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) .
array_search($this->rs->feed_upd_int, $combo_upd_int) .
'</td>',
'update' => '<td class="nowrap minimal count">' .
($this->rs->feed_upd_last < 1 ?
(
$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_count ?
'<a href="' . $url . '#entries" title="' . __('View entries') . '">' . $entries_count . '</a>' :
$entries_count
) . '</td>',
@ -147,7 +148,8 @@ 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>';
@ -158,13 +160,14 @@ class zcfsEntriesList 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 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>',
'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,6 +343,7 @@ class adminZcfsPostFilter extends adminGenericFilter
}
} catch (Exception $e) {
$this->core->error->add($e->getMessage());
return null;
}
@ -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(
['-' => ''],

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;
}
@ -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;
}
@ -92,29 +91,45 @@ 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(
$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
);
}
}
}
@ -133,12 +148,12 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
$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.'));
@ -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());
@ -263,7 +280,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
# posts
try {
$posts = $zcfs->getPostsByFeed($params);
$counter = $zcfs->getPostsByFeed($params,true);
$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() .
@ -293,9 +310,9 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == '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,7 +411,7 @@ 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,
@ -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(
@ -500,7 +517,7 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
dcPage::breadcrumb([
__('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';
}