diff --git a/CHANGELOG.md b/CHANGELOG.md index e4f7ff1..067a149 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/_admin.php b/_admin.php index 31a49b7..3e552de 100644 --- a/_admin.php +++ b/_admin.php @@ -1,16 +1,15 @@ addItem( $core->adminurl->get('admin.plugin.zoneclearFeedServer'), dcPage::getPF('zoneclearFeedServer/icon.png'), preg_match( - '/' . preg_quote($core->adminurl->get('admin.plugin.zoneclearFeedServer')) . '(&.*)?$/', + '/' . preg_quote($core->adminurl->get('admin.plugin.zoneclearFeedServer')) . '(&.*)?$/', $_SERVER['REQUEST_URI'] ), $core->auth->check('admin', $core->blog->id) ); # 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']); } @@ -107,8 +105,8 @@ class zcfsAdminBehaviors */ public static function adminDashboardFavoritesActive($request, $params) { - return $request == 'plugin.php' - && isset($params['p']) + return $request == 'plugin.php' + && isset($params['p']) && $params['p'] == 'zoneclearFeedServer'; } @@ -127,10 +125,10 @@ class zcfsAdminBehaviors return null; } - $fav['title'] .= '
'.sprintf(__('%s feed disabled', '%s feeds disabled', $count), $count); + $fav['title'] .= '
' . 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', + $fav['url'] = $core->adminurl->get( + 'admin.plugin.zoneclearFeedServer', ['part' => 'feeds', 'sortby' => 'feed_status', 'order' => 'asc'] ); } @@ -146,18 +144,18 @@ class zcfsAdminBehaviors $cols['zcfs_feeds'] = [ __('Feeds server: Feeds'), [ - 'desc' => [true, __('Feed')], - 'period' => [true, __('Frequency')], - 'update' => [true, __('Last update')], - 'entries' => [true, __('Entries')] + 'desc' => [true, __('Feed')], + 'period' => [true, __('Frequency')], + 'update' => [true, __('Last update')], + 'entries' => [true, __('Entries')] ] ]; $cols['zcfs_entries'] = [ __('Feeds server: Entries'), [ - 'date' => [true, __('Date')], - 'category' => [true, __('Category')], - 'author' => [true, __('Author')] + 'date' => [true, __('Date')], + 'category' => [true, __('Category')], + 'author' => [true, __('Author')] ] ]; } @@ -188,7 +186,7 @@ class zcfsAdminBehaviors /** * Add javascript for toggle to post edition page header. - * + * * @return string Page header */ public static function adminPostHeaders() @@ -198,7 +196,7 @@ class zcfsAdminBehaviors /** * Add form to post sidebar. - * + * * @param ArrayObject $main_items Main items * @param ArrayObject $sidebar_items Sidebar items * @param record $post Post record or null @@ -253,7 +251,7 @@ class zcfsAdminBehaviors $edit = sprintf( '

%s

', $core->adminurl->get( - 'admin.plugin.zoneclearFeedServer', + 'admin.plugin.zoneclearFeedServer', ['part' => 'feed', 'feed_id' => $fid->meta_id] ), __('Edit this feed') @@ -261,8 +259,7 @@ class zcfsAdminBehaviors } } - $sidebar_items['options-box']['items']['zcfs'] = - '
'. + $sidebar_items['options-box']['items']['zcfs'] = '
' . '
' . __('Feed source') . '
' . '

' . '' . __('feed URL') . ' - ' . @@ -274,7 +271,7 @@ class zcfsAdminBehaviors /** * Delete related info about feed post in meta table. - * + * * @param integer $post_id Post id */ public static function adminBeforePostDelete($post_id) @@ -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' - ]).' ' + ]) . ' ' ); } -} \ No newline at end of file +} diff --git a/_config.php b/_config.php index 703594a..8efce9a 100644 --- a/_config.php +++ b/_config.php @@ -1,16 +1,15 @@ getURL() . '#plugins' : $_REQUEST['r $core->blog->settings->addNamespace('zoneclearFeedServer'); $s = $core->blog->settings->zoneclearFeedServer; -$active = (boolean) $s->zoneclearFeedServer_active; -$pub_active = (boolean) $s->zoneclearFeedServer_pub_active; -$post_status_new = (boolean) $s->zoneclearFeedServer_post_status_new; -$bhv_pub_upd = (integer) $s->zoneclearFeedServer_bhv_pub_upd; -$update_limit = (integer) $s->zoneclearFeedServer_update_limit; -$keep_empty_feed = (boolean) $s->zoneclearFeedServer_keep_empty_feed; -$tag_case = (integer) $s->zoneclearFeedServer_tag_case; -$post_full_tpl = @unserialize($s->zoneclearFeedServer_post_full_tpl); +$active = (bool) $s->zoneclearFeedServer_active; +$pub_active = (bool) $s->zoneclearFeedServer_pub_active; +$post_status_new = (bool) $s->zoneclearFeedServer_post_status_new; +$bhv_pub_upd = (int) $s->zoneclearFeedServer_bhv_pub_upd; +$update_limit = (int) $s->zoneclearFeedServer_update_limit; +$keep_empty_feed = (bool) $s->zoneclearFeedServer_keep_empty_feed; +$tag_case = (int) $s->zoneclearFeedServer_tag_case; +$post_full_tpl = @unserialize($s->zoneclearFeedServer_post_full_tpl); $post_title_redir = @unserialize($s->zoneclearFeedServer_post_title_redir); -$feeduser = (string) $s->zoneclearFeedServer_user; +$feeduser = (string) $s->zoneclearFeedServer_user; if ($update_limit < 1) { $update_limit = 10; @@ -47,16 +46,16 @@ $zc = new zoneclearFeedServer($core); # -- Set settings -- if (!empty($_POST['save'])) { try { - $active = !empty($_POST['active']); - $pub_active = !empty($_POST['pub_active']); - $post_status_new = !empty($_POST['post_status_new']); - $bhv_pub_upd = (integer) $_POST['bhv_pub_upd']; - $limit = abs((integer) $_POST['update_limit']); - $keep_empty_feed = !empty($_POST['keep_empty_feed']); - $tag_case = (integer) $_POST['tag_case']; - $post_full_tpl = $_POST['post_full_tpl']; + $active = !empty($_POST['active']); + $pub_active = !empty($_POST['pub_active']); + $post_status_new = !empty($_POST['post_status_new']); + $bhv_pub_upd = (int) $_POST['bhv_pub_upd']; + $limit = abs((int) $_POST['update_limit']); + $keep_empty_feed = !empty($_POST['keep_empty_feed']); + $tag_case = (int) $_POST['tag_case']; + $post_full_tpl = $_POST['post_full_tpl']; $post_title_redir = $_POST['post_title_redir']; - $feeduser = (string) $_POST['feeduser']; + $feeduser = (string) $_POST['feeduser']; if ($limit < 1) { $limit = 10; @@ -79,7 +78,7 @@ if (!empty($_POST['save'])) { __('Configuration successfully updated.') ); $core->adminurl->redirect( - 'admin.plugins', + 'admin.plugins', ['module' => 'zoneclearFeedServer', 'conf' => 1, 'redir' => $list->getRedir()] ); } catch (Exception $e) { @@ -111,8 +110,8 @@ $pub_page_url = $core->blog->url . $core->url->getBase('zoneclearFeedsPage'); # -- Display form -- if (!is_writable(DC_TPL_CACHE)) { - echo '

'. __('Dotclear cache is not writable or not well configured!') . '

'; - } + echo '

' . __('Dotclear cache is not writable or not well configured!') . '

'; +} echo '
@@ -142,7 +141,7 @@ echo '

' . form::combo('post_status_new', $combo_status, $post_status_new) . '

-

' . form::combo('feeduser', $combo_admins, $feeduser) . '

@@ -154,8 +153,10 @@ form::combo('tag_case', $combo_tagcase, $tag_case) . '

' . form::combo('bhv_pub_upd', $combo_pubupd, $bhv_pub_upd) . '

-

+

@@ -167,7 +168,7 @@ form::checkbox('pub_active', 1, $pub_active) . __('Enable public page') . '' . __('Redirect to original post on:') . '

    '; -foreach($zc->getPublicUrlTypes($core) as $k => $v) { +foreach ($zc->getPublicUrlTypes($core) as $k => $v) { echo sprintf( '
  • ', $v, @@ -182,7 +183,7 @@ echo '

    ' . __('Show full content on:') . '

      '; -foreach($zc->getPublicUrlTypes($core) as $k => $v) { +foreach ($zc->getPublicUrlTypes($core) as $k => $v) { echo sprintf( '
    • ', $v, @@ -193,4 +194,4 @@ foreach($zc->getPublicUrlTypes($core) as $k => $v) { echo '
'; -dcPage::helpBlock('zoneclearFeedServer'); \ No newline at end of file +dcPage::helpBlock('zoneclearFeedServer'); diff --git a/_define.php b/_define.php index 813f71e..27aae11 100644 --- a/_define.php +++ b/_define.php @@ -1,16 +1,15 @@ registerModule( 'details' => 'https://plugins.dotaddict.org/dc2/details/pacKman', 'repository' => 'https://raw.githubusercontent.com/JcDenis/zoneclearFeedServer/master/dcstore.xml' ] -); \ No newline at end of file +); diff --git a/_install.php b/_install.php index db7c127..481cb2f 100644 --- a/_install.php +++ b/_install.php @@ -1,19 +1,18 @@ modules[$mod_id]['requires'][0][1]; @@ -29,11 +28,13 @@ try { } # Check Dotclear version - if (!method_exists('dcUtils', 'versionsCompare') + if (!method_exists('dcUtils', 'versionsCompare') || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false) ) { throw new Exception(sprintf( - '%s requires Dotclear %s', $mod_id, $dc_min + '%s requires Dotclear %s', + $mod_id, + $dc_min )); } @@ -65,7 +66,7 @@ try { ->index('idx_zcfs_type', 'btree', 'feed_type') ->index('idx_zcfs_blog', 'btree', 'blog_id'); - $ti = new dbStruct($core->con, $core->prefix); + $ti = new dbStruct($core->con, $core->prefix); $changes = $ti->synchronize($t); # Settings @@ -78,18 +79,19 @@ 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()); return false; -} \ No newline at end of file +} diff --git a/_prepend.php b/_prepend.php index 5f7da75..bfd2717 100644 --- a/_prepend.php +++ b/_prepend.php @@ -1,27 +1,26 @@ url->register( // Add to report on plugin activityReport if (defined('ACTIVITY_REPORT')) { - require_once $d .'lib.zcfs.activityreport.php'; -} \ No newline at end of file + require_once $d . 'lib.zcfs.activityreport.php'; +} diff --git a/_public.php b/_public.php index 8c5d763..c234d0a 100644 --- a/_public.php +++ b/_public.php @@ -1,16 +1,15 @@ 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]); } @@ -83,7 +82,7 @@ class zcfsPublicBehaviors { /** * Remember others post extension. - * + * * @param record $rs record instance */ public static function coreBlogGetPosts(record $rs) @@ -94,7 +93,7 @@ class zcfsPublicBehaviors /** * Update feeds after contents. - * + * * @param dcCore $core dcCore instance * @return string Document */ @@ -111,7 +110,7 @@ class zcfsPublicBehaviors /** * Generic behavior for before and after public content. - * + * * @param dcCore $core dcCore instance * @return null NULL */ @@ -125,7 +124,7 @@ class zcfsPublicBehaviors /** * Update feeds by an Ajax request (background). - * + * * @param dcCore $core dcCore instance * @param context $_ctx context instance * @return string HTML content @@ -148,7 +147,7 @@ class zcfsPublicBehaviors "\n \n" . dcutils::jsLoad($core->blog->url . $core->url->getBase('zoneclearFeedsPage') . '/zcfsupd.js') . "