From 7c90aea074b38ad2b97f383a8c4bdf57737630ba Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 10 Dec 2022 23:02:38 +0100 Subject: [PATCH] fix from phpstan and php-cs-fixer --- _admin.php | 4 +-- _init.php | 2 +- _install.php | 2 +- inc/class.zcfspublicbehaviors.php | 2 +- inc/class.zcfsrsextposts.php | 4 +-- inc/class.zcfsurlhandler.php | 4 +-- inc/class.zoneclearfeedserver.php | 12 ++++--- index.php | 57 ++++++++++++++++--------------- 8 files changed, 45 insertions(+), 42 deletions(-) diff --git a/_admin.php b/_admin.php index c480776..aa2008c 100644 --- a/_admin.php +++ b/_admin.php @@ -48,9 +48,7 @@ if (dcCore::app()->blog->settings->__get(basename(__DIR__))->zoneclearFeedServer } # Take care about tweakurls (thanks Mathieu M.) - if (version_compare(dcCore::app()->plugins->moduleInfo('tweakurls', 'version'), '0.8', '>=')) { - dcCore::app()->addbehavior('zcfsAfterPostCreate', ['zoneclearFeedServer', 'tweakurlsAfterPostCreate']); - } + dcCore::app()->addbehavior('zcfsAfterPostCreate', ['zoneclearFeedServer', 'tweakurlsAfterPostCreate']); } # Delete related info about feed post in meta table diff --git a/_init.php b/_init.php index 6ea85cd..9fb8fb3 100644 --- a/_init.php +++ b/_init.php @@ -16,5 +16,5 @@ if (!defined('DC_RC_PATH')) { class initZoneclearFeedServer { - public const TABLE_NAME = 'zc_feed'; + public const TABLE_NAME = 'zc_feed'; } diff --git a/_install.php b/_install.php index 0c6bed5..504ecb2 100644 --- a/_install.php +++ b/_install.php @@ -17,7 +17,7 @@ if (!defined('DC_CONTEXT_ADMIN')) { try { # Check module version if (!dcCore::app()->newVersion( - basename(__DIR__), + basename(__DIR__), dcCore::app()->plugins->moduleInfo(basename(__DIR__), 'version') )) { return null; diff --git a/inc/class.zcfspublicbehaviors.php b/inc/class.zcfspublicbehaviors.php index 0a4bf10..8a25212 100644 --- a/inc/class.zcfspublicbehaviors.php +++ b/inc/class.zcfspublicbehaviors.php @@ -43,7 +43,7 @@ class zcfsPublicBehaviors return null; } - self::publicDocument(); + self::publicDocumentV2(); } /** diff --git a/inc/class.zcfsrsextposts.php b/inc/class.zcfsrsextposts.php index 894952a..4d803bc 100644 --- a/inc/class.zcfsrsextposts.php +++ b/inc/class.zcfsrsextposts.php @@ -56,7 +56,7 @@ class zcfsRsExtPosts extends rsExtPost $ext = dcCore::app()->__get('beforeZcFeedRsExt'); if (null !== $ext && !empty($ext[$type])) { $func = $ext[$type]; - } elseif (is_callable('rsExtPostPublic', $type)) { + } elseif (is_callable(['rsExtPostPublic', $type])) { $func = ['rsExtPostPublic', $type]; } else { $func = ['rsExtPost', $type]; @@ -117,7 +117,7 @@ class zcfsRsExtPosts extends rsExtPost /** * Get post content from post to feed. * - * @param record $rs record instance + * @param dcRecord $rs record instance * @return string Post content */ public static function getContent(dcRecord $rs, bool $absolute_urls = false): string diff --git a/inc/class.zcfsurlhandler.php b/inc/class.zcfsurlhandler.php index b05eb3d..4e72f76 100644 --- a/inc/class.zcfsurlhandler.php +++ b/inc/class.zcfsurlhandler.php @@ -46,7 +46,7 @@ class zcfsUrlHandler extends dcUrlHandlers $zc = new zoneclearFeedServer(); if ($zc->checkFeedsUpdate()) { $msg = sprintf( - '%ss%', + '%s%s', 'ok', 'Feeds updated successfully' ); @@ -56,7 +56,7 @@ class zcfsUrlHandler extends dcUrlHandlers } if (empty($msg)) { $msg = sprintf( - '%ss%', + '%s%s', 'failed', 'Failed to update feeds' ); diff --git a/inc/class.zoneclearfeedserver.php b/inc/class.zoneclearfeedserver.php index ceeaf88..8212692 100644 --- a/inc/class.zoneclearfeedserver.php +++ b/inc/class.zoneclearfeedserver.php @@ -709,7 +709,7 @@ class zoneclearFeedServer # Enable if ($enable) { $this->user = dcCore::app()->auth->userID(); - if (!dcCore::app()->auth->checkUser($enable)) { + if (!dcCore::app()->auth->checkUser($this->user ?? '')) { throw new Exception('Unable to set user'); } # Disable @@ -724,7 +724,7 @@ class zoneclearFeedServer * Read and parse external feeds. * * @param string $f Feed URL - * @return arrayObject Parsed feed + * @return feedParser|false Parsed feed */ public static function readFeed($f) { @@ -737,7 +737,7 @@ class zoneclearFeedServer return $feed_reader->parse($f); } catch (Exception $e) { - return null; + return false; } } @@ -909,7 +909,9 @@ class zoneclearFeedServer */ public static function tweakurlsAfterPostCreate(cursor $cur, $id) { - $cur->post_url = tweakUrls::tweakBlogURL($cur->post_url); - dcCore::app()->auth->sudo([dcCore::app()->blog, 'updPost'], $id, $cur); + if (version_compare(dcCore::app()->plugins->moduleInfo('tweakurls', 'version'), '0.8', '>=')) { + $cur->post_url = tweakUrls::tweakBlogURL($cur->post_url); + dcCore::app()->auth->sudo([dcCore::app()->blog, 'updPost'], $id, $cur); + } } } diff --git a/index.php b/index.php index e22b0bb..9647211 100644 --- a/index.php +++ b/index.php @@ -308,7 +308,7 @@ if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->zoneclearFeedServe # display echo '' . __('Feeds server') . '' . - ($feed_id && !dcCore::app()->error->flag() ? + ($feed_id && isset($post_filter) && !dcCore::app()->error->flag() ? $post_filter->js(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__), ['part' => 'feed', 'feed_id' => $feed_id], '&') . '#entries') . dcPage::jsLoad(dcPage::getPF(basename(__DIR__) . '/js/list.js')) : '') . @@ -438,7 +438,7 @@ if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->zoneclearFeedServe } # entries - if ($feed_id && $can_view_page && !dcCore::app()->error->flag()) { + if ($feed_id && $can_view_page && isset($post_filter) && isset($post_list) && isset($posts_actions_page) && !dcCore::app()->error->flag()) { echo '
'; # show filters @@ -531,34 +531,37 @@ if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->zoneclearFeedServe __('Plugins') => '', __('Feeds server') => '', ]) . - dcPage::notices() . + dcPage::notices(); - '

' . - '' . - __('New feed') . '

'; + if (isset($feeds_list)) { + echo + '

' . + '' . + __('New feed') . '

'; - $feeds_filter->display( - 'admin.plugin.' . basename(__DIR__), - dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.' . basename(__DIR__), ['part' => 'feeds']) - ); + $feeds_filter->display( + 'admin.plugin.' . basename(__DIR__), + dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.' . basename(__DIR__), ['part' => 'feeds']) + ); - $feeds_list->feedsDisplay( - $feeds_filter->page, - $feeds_filter->nb, - '
' . - '%s' . - '
' . - '

' . - '

' . __('Selected feeds action:') . ' ' . - form::combo(['action'], $feeds_actions_page->getCombo()) . - '' . - dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.' . basename(__DIR__), $feeds_filter->values(true)) . - dcCore::app()->formNonce() . - '

' . - '
' . - '
', - $feeds_filter->show() - ); + $feeds_list->feedsDisplay( + $feeds_filter->page, + $feeds_filter->nb, + '
' . + '%s' . + '
' . + '

' . + '

' . __('Selected feeds action:') . ' ' . + form::combo(['action'], $feeds_actions_page->getCombo()) . + '' . + dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.' . basename(__DIR__), $feeds_filter->values(true)) . + dcCore::app()->formNonce() . + '

' . + '
' . + '
', + $feeds_filter->show() + ); + } } echo '';