From a80a5f48a16e7d232168a7aaa68e9a1804235ce1 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 18 Dec 2023 17:59:16 +0100 Subject: Pass PHPStan level 8 (#5946) * Pass PHPStan level 8 And prepare for PHPStan level 9 https://phpstan.org/user-guide/rule-levels * Revert wrong replace in comment * Fix PHPStan level 8 * Update PHPStan and other dev dependencies * Remove obsolete comment * noVariableVariables and towards bleedingEdge https://github.com/phpstan/phpstan-strict-rules https://phpstan.org/blog/what-is-bleeding-edge * More bleedingEdge * A bit more PHPStan level 9 * More PHPStan level 9 * Prepare for booleansInConditions Ignore int and null * Revert wrong line * More fixes * Fix keep_max_n_unread * Stricter attribute functions * Stricter callHooks and more PHPStan level 9 * More typing * A tiny more --- app/views/auth/index.phtml | 28 ++-- app/views/category/update.phtml | 2 +- app/views/configure/archiving.phtml | 52 ++++---- app/views/configure/display.phtml | 94 +++++++------- app/views/configure/integration.phtml | 5 +- app/views/configure/reading.phtml | 148 +++++++++++----------- app/views/configure/shortcut.phtml | 2 +- app/views/configure/system.phtml | 40 +++--- app/views/feed/add.phtml | 2 +- app/views/feed/contentSelectorPreview.phtml | 2 +- app/views/helpers/category/update.phtml | 28 ++-- app/views/helpers/configure/query.phtml | 3 + app/views/helpers/export/opml.phtml | 10 +- app/views/helpers/extension/configure.phtml | 3 + app/views/helpers/extension/details.phtml | 3 + app/views/helpers/feed/update.phtml | 97 +++++++------- app/views/helpers/index/normal/entry_bottom.phtml | 18 +-- app/views/helpers/index/normal/entry_header.phtml | 23 ++-- app/views/helpers/javascript_vars.phtml | 22 ++-- app/views/helpers/stream-footer.phtml | 4 +- app/views/index/about.phtml | 4 +- app/views/index/global.phtml | 6 +- app/views/index/normal.phtml | 35 ++--- app/views/index/reader.phtml | 28 ++-- app/views/index/rss.phtml | 2 +- app/views/stats/idle.phtml | 6 +- app/views/subscription/index.phtml | 6 +- app/views/user/manage.phtml | 2 +- app/views/user/profile.phtml | 8 +- app/views/user/validateEmail.phtml | 4 +- 30 files changed, 358 insertions(+), 329 deletions(-) (limited to 'app/views') diff --git a/app/views/auth/index.phtml b/app/views/auth/index.phtml index 78762c19e..f82adaaae 100644 --- a/app/views/auth/index.phtml +++ b/app/views/auth/index.phtml @@ -15,15 +15,15 @@
- + auth_type, ['form', 'http_auth', 'none'], true)) { ?> - - - +
@@ -32,9 +32,9 @@
@@ -43,8 +43,8 @@
@@ -54,8 +54,8 @@
@@ -66,8 +66,8 @@
diff --git a/app/views/category/update.phtml b/app/views/category/update.phtml index daf4523bb..2ef42d207 100644 --- a/app/views/category/update.phtml +++ b/app/views/category/update.phtml @@ -5,6 +5,6 @@ declare(strict_types=1); if (!Minz_Request::paramBoolean('ajax')) { $this->partial('aside_subscription'); } -if ($this->category) { +if ($this->category !== null) { $this->renderHelper('category/update'); } diff --git a/app/views/configure/archiving.phtml b/app/views/configure/archiving.phtml index 6004cec1b..86b8246e3 100644 --- a/app/views/configure/archiving.phtml +++ b/app/views/configure/archiving.phtml @@ -17,21 +17,21 @@
- ()
@@ -46,10 +46,10 @@
@@ -59,18 +59,18 @@
@@ -81,8 +81,8 @@
@@ -92,8 +92,8 @@
@@ -103,8 +103,8 @@
@@ -114,8 +114,8 @@
diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index b48dcbf71..d373c0bb5 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -16,10 +16,10 @@
- - +
@@ -28,15 +28,15 @@
- timezone, $timezones, true)) { - FreshRSS_Context::$user_conf->timezone = ''; + if (!in_array(FreshRSS_Context::userConf()->timezone, $timezones, true)) { + FreshRSS_Context::userConf()->timezone = ''; } ?> - @@ -49,16 +49,16 @@
    themes); $i = 1; $themeAvailable = false; ?> - themes as $theme) { ?> - theme === $theme['id']) { + themes as $theme) { ?> + theme === $theme['id']) { $checked = 'checked="checked"'; $themeAvailable = true; } else { $checked = ''; } ?> value="" - data-leave-validation="theme === $theme['id']) ? 1 : 0 ?>" /> + data-leave-validation="theme === $theme['id']) ? 1 : 0 ?>" />
  • @@ -98,7 +98,7 @@
    -
    theme)?>
    +
    theme)?>
  • @@ -109,14 +109,14 @@
    - + +
    - content_width; ?> + content_width; ?>
    @@ -137,7 +137,7 @@
    - topline_website; ?> + topline_website; ?>
    @@ -158,7 +158,7 @@
    - topline_thumbnail; ?> + topline_thumbnail; ?>
    @@ -201,50 +201,50 @@ topline_read ? ' checked="checked"' : '' ?> - data-leave-validation="topline_read ?>" /> + FreshRSS_Context::userConf()->topline_read ? ' checked="checked"' : '' ?> + data-leave-validation="topline_read ?>" /> topline_favorite ? ' checked="checked"' : '' ?> - data-leave-validation="topline_favorite ?>" /> + FreshRSS_Context::userConf()->topline_favorite ? ' checked="checked"' : '' ?> + data-leave-validation="topline_favorite ?>" /> topline_summary ? 'checked="checked"' : '' ?> - data-leave-validation="topline_summary ?>" /> + FreshRSS_Context::userConf()->topline_summary ? 'checked="checked"' : '' ?> + data-leave-validation="topline_summary ?>" /> topline_display_authors ? ' checked="checked"' : '' ?> - data-leave-validation="topline_display_authors ?>" /> + FreshRSS_Context::userConf()->topline_display_authors ? ' checked="checked"' : '' ?> + data-leave-validation="topline_display_authors ?>" /> topline_date ? ' checked="checked"' : '' ?> - data-leave-validation="topline_date ?>" /> - topline_link ? ' checked="checked"' : '' ?> - data-leave-validation="topline_link ?>" /> + FreshRSS_Context::userConf()->topline_date ? ' checked="checked"' : '' ?> + data-leave-validation="topline_date ?>" /> + topline_link ? ' checked="checked"' : '' ?> + data-leave-validation="topline_link ?>" /> bottomline_read ? ' checked="checked"' : '' ?> - data-leave-validation="bottomline_read ?>" /> + FreshRSS_Context::userConf()->bottomline_read ? ' checked="checked"' : '' ?> + data-leave-validation="bottomline_read ?>" /> bottomline_favorite ? ' checked="checked"' : '' ?> - data-leave-validation="bottomline_favorite ?>" /> + FreshRSS_Context::userConf()->bottomline_favorite ? ' checked="checked"' : '' ?> + data-leave-validation="bottomline_favorite ?>" /> bottomline_myLabels ? ' checked="checked"' : '' ?> - data-leave-validation="bottomline_myLabels ?>" /> + FreshRSS_Context::userConf()->bottomline_myLabels ? ' checked="checked"' : '' ?> + data-leave-validation="bottomline_myLabels ?>" /> bottomline_tags ? ' checked="checked"' : '' ?> - data-leave-validation="bottomline_tags ?>" /> + FreshRSS_Context::userConf()->bottomline_tags ? ' checked="checked"' : '' ?> + data-leave-validation="bottomline_tags ?>" /> bottomline_sharing ? ' checked="checked"' : '' ?> - data-leave-validation="bottomline_sharing ?>" /> + FreshRSS_Context::userConf()->bottomline_sharing ? ' checked="checked"' : '' ?> + data-leave-validation="bottomline_sharing ?>" /> bottomline_date ? ' checked="checked"' : '' ?> - data-leave-validation="bottomline_date ?>" /> + FreshRSS_Context::userConf()->bottomline_date ? ' checked="checked"' : '' ?> + data-leave-validation="bottomline_date ?>" /> bottomline_link ? ' checked="checked"' : '' ?> - data-leave-validation="bottomline_link ?>" /> + FreshRSS_Context::userConf()->bottomline_link ? ' checked="checked"' : '' ?> + data-leave-validation="bottomline_link ?>" /> @@ -255,8 +255,8 @@
    + FreshRSS_Context::userConf()->html5_notif_timeout ?>" + data-leave-validation="html5_notif_timeout ?>" />
    @@ -264,8 +264,8 @@
    diff --git a/app/views/configure/integration.phtml b/app/views/configure/integration.phtml index fc3cc2a32..973ee128f 100644 --- a/app/views/configure/integration.phtml +++ b/app/views/configure/integration.phtml @@ -57,8 +57,11 @@ sharing as $key => $share_options) { + foreach (FreshRSS_Context::userConf()->sharing as $key => $share_options) { $share = FreshRSS_Share::get($share_options['type']); + if ($share === null) { + continue; + } $share->update($share_options); ?> diff --git a/app/views/configure/reading.phtml b/app/views/configure/reading.phtml index 94cf51977..17fdbe7c3 100644 --- a/app/views/configure/reading.phtml +++ b/app/views/configure/reading.phtml @@ -17,10 +17,10 @@
    - + + +
    @@ -28,10 +28,10 @@
    - + + +
    @@ -40,8 +40,8 @@
    + FreshRSS_Context::userConf()->posts_per_page ?>" min="5" max="500" + data-leave-validation="posts_per_page ?>"/>

    @@ -50,8 +50,8 @@
    @@ -61,9 +61,9 @@
    - + +
    @@ -75,14 +75,14 @@
    -
    @@ -92,8 +92,8 @@
    @@ -104,8 +104,8 @@
    @@ -117,32 +117,32 @@
    - + + +
    - + + + +
    - + + + +
    @@ -150,7 +150,7 @@
    - +

    @@ -162,8 +162,8 @@
    @@ -174,8 +174,8 @@
    @@ -186,8 +186,8 @@
    @@ -201,8 +201,8 @@
    @@ -213,8 +213,8 @@
    @@ -226,8 +226,8 @@
    @@ -237,8 +237,8 @@
    @@ -249,8 +249,8 @@
    @@ -261,8 +261,8 @@
    @@ -273,8 +273,8 @@
    @@ -285,8 +285,8 @@
    @@ -297,10 +297,10 @@
    @@ -312,8 +312,8 @@
    @@ -324,8 +324,8 @@
    @@ -335,10 +335,10 @@
    @@ -351,7 +351,7 @@
    @@ -366,8 +366,8 @@
    diff --git a/app/views/configure/shortcut.phtml b/app/views/configure/shortcut.phtml index e578938cd..0d7ee4cb7 100644 --- a/app/views/configure/shortcut.phtml +++ b/app/views/configure/shortcut.phtml @@ -16,7 +16,7 @@ - shortcuts; ?> + shortcuts; ?>

    diff --git a/app/views/configure/system.phtml b/app/views/configure/system.phtml index d19698932..09d1fe188 100644 --- a/app/views/configure/system.phtml +++ b/app/views/configure/system.phtml @@ -16,16 +16,16 @@

    - +
    - +

    @@ -35,7 +35,7 @@
    pubsubhubbub_enabled && Minz_Request::serverIsPublic(FreshRSS_Context::$system_conf->base_url) ? 'checked="checked"' : '' ?> /> + FreshRSS_Context::systemConf()->pubsubhubbub_enabled && Minz_Request::serverIsPublic(FreshRSS_Context::systemConf()->base_url) ? 'checked="checked"' : '' ?> />

    @@ -44,32 +44,32 @@
    - +
    - +
    - +
    - +

    @@ -80,9 +80,9 @@
    @@ -91,8 +91,8 @@
    - + (= )(= )
    @@ -124,8 +124,8 @@ name="force-email-validation" id="force-email-validation" value="1" - force_email_validation ? 'checked="checked"' : '' ?> - data-leave-validation="force_email_validation ?>" + force_email_validation ? 'checked="checked"' : '' ?> + data-leave-validation="force_email_validation ?>" /> diff --git a/app/views/feed/add.phtml b/app/views/feed/add.phtml index c51289f56..da3bcf844 100644 --- a/app/views/feed/add.phtml +++ b/app/views/feed/add.phtml @@ -1,7 +1,7 @@ feed) { + if ($this->feed !== null) { ?>

    diff --git a/app/views/feed/contentSelectorPreview.phtml b/app/views/feed/contentSelectorPreview.phtml index a5afb10f4..a93e88783 100644 --- a/app/views/feed/contentSelectorPreview.phtml +++ b/app/views/feed/contentSelectorPreview.phtml @@ -4,7 +4,7 @@ FreshRSS::preLayout(); ?> - + diff --git a/app/views/helpers/category/update.phtml b/app/views/helpers/category/update.phtml index 68132ad27..36c0abfe8 100644 --- a/app/views/helpers/category/update.phtml +++ b/app/views/helpers/category/update.phtml @@ -1,6 +1,9 @@ category === null) { + throw new FreshRSS_Context_Exception('Category not initialised!'); + } ?>

    @@ -28,7 +31,7 @@
    - +

    @@ -46,7 +49,7 @@
    - + @@ -90,7 +93,8 @@ category->attributes('archiving'); + $archiving = $this->category->attributeArray('archiving'); + /** @var array<'default'?:bool,'keep_period'?:string,'keep_max'?:int,'keep_min'?:int,'keep_favourites'?:bool,'keep_labels'?:bool,'keep_unreads'?:bool>|null $archiving */ if (empty($archiving)) { $archiving = [ 'default' => true ]; } else { @@ -101,7 +105,7 @@ 'keep_period_count' => '3', 'keep_period_unit' => 'P1M', ]; - if (!empty($archiving['keep_period'])) { + if (!empty($archiving['keep_period']) && is_string($archiving['keep_period'])) { if (preg_match('/^PT?(?P\d+)[YMWDH]$/', $archiving['keep_period'], $matches)) { $volatile['enable_keep_period'] = true; $volatile['keep_period_count'] = $matches['count']; @@ -109,21 +113,21 @@ } } //Defaults - if (!isset($archiving['keep_max'])) { - $archiving['keep_max'] = false; + if (!isset($archiving['keep_max']) || !is_int($archiving['keep_max'])) { + $archiving['keep_max'] = 0; } - if (!isset($archiving['keep_favourites'])) { + if (!isset($archiving['keep_min']) || !is_int($archiving['keep_min'])) { + $archiving['keep_min'] = 50; + } + if (!isset($archiving['keep_favourites']) || !is_bool($archiving['keep_favourites'])) { $archiving['keep_favourites'] = true; } - if (!isset($archiving['keep_labels'])) { + if (!isset($archiving['keep_labels']) || !is_bool($archiving['keep_labels'])) { $archiving['keep_labels'] = true; } - if (!isset($archiving['keep_unreads'])) { + if (!isset($archiving['keep_unreads']) || !is_bool($archiving['keep_unreads'])) { $archiving['keep_unreads'] = false; } - if (!isset($archiving['keep_min'])) { - $archiving['keep_min'] = 50; - } ?>

    diff --git a/app/views/helpers/configure/query.phtml b/app/views/helpers/configure/query.phtml index 0f76bc202..145425271 100644 --- a/app/views/helpers/configure/query.phtml +++ b/app/views/helpers/configure/query.phtml @@ -1,6 +1,9 @@ query === null) { + throw new FreshRSS_Context_Exception('Query not initialised!'); + } ?>

    query->getName() ?>

    diff --git a/app/views/helpers/export/opml.phtml b/app/views/helpers/export/opml.phtml index 2c3e004fc..ce53bfc02 100644 --- a/app/views/helpers/export/opml.phtml +++ b/app/views/helpers/export/opml.phtml @@ -30,7 +30,7 @@ function feedsToOutlines(array $feeds, bool $excludeMutedFeeds = false): array { break; } /** @var array */ - $xPathSettings = $feed->attributes('xpath'); + $xPathSettings = $feed->attributeArray('xpath') ?? []; $outline['frss:xPathItem'] = $xPathSettings['item'] ?? null; $outline['frss:xPathItemTitle'] = $xPathSettings['itemTitle'] ?? null; $outline['frss:xPathItemContent'] = $xPathSettings['itemContent'] ?? null; @@ -56,8 +56,8 @@ function feedsToOutlines(array $feeds, bool $excludeMutedFeeds = false): array { $outline['frss:cssFullContent'] = htmlspecialchars_decode($feed->pathEntries(), ENT_QUOTES); } - if ($feed->attributes('path_entries_filter') != '') { - $outline['frss:cssFullContentFilter'] = $feed->attributes('path_entries_filter'); + if ($feed->attributeString('path_entries_filter') != '') { + $outline['frss:cssFullContentFilter'] = $feed->attributeString('path_entries_filter'); } // Remove null attributes @@ -76,7 +76,7 @@ $opml_array = [ 'frss' => FreshRSS_Export_Service::FRSS_NAMESPACE, ], 'head' => [ - 'title' => FreshRSS_Context::$system_conf->title, + 'title' => FreshRSS_Context::systemConf()->title, 'dateCreated' => new DateTime(), ], 'body' => [], @@ -90,7 +90,7 @@ if (!empty($this->categories)) { ]; if ($cat->kind() === FreshRSS_Category::KIND_DYNAMIC_OPML) { - $outline['frss:opmlUrl'] = $cat->attributes('opml_url'); + $outline['frss:opmlUrl'] = $cat->attributeString('opml_url'); } $opml_array['body'][] = $outline; diff --git a/app/views/helpers/extension/configure.phtml b/app/views/helpers/extension/configure.phtml index 5cf7f9c0a..b714eb553 100644 --- a/app/views/helpers/extension/configure.phtml +++ b/app/views/helpers/extension/configure.phtml @@ -4,6 +4,9 @@ if (!Minz_Request::paramBoolean('ajax')) { $this->partial('aside_configure'); } + if ($this->extension === null) { + throw new FreshRSS_Context_Exception('Extension not initialised!'); + } ?>

    diff --git a/app/views/helpers/extension/details.phtml b/app/views/helpers/extension/details.phtml index b8d0d784f..d1f773020 100644 --- a/app/views/helpers/extension/details.phtml +++ b/app/views/helpers/extension/details.phtml @@ -1,6 +1,9 @@ ext_details === null) { + throw new FreshRSS_Context_Exception('Extension not initialised!'); + } $name_encoded = urlencode($this->ext_details->getName()); $ext_enabled = $this->ext_details->isEnabled(); diff --git a/app/views/helpers/feed/update.phtml b/app/views/helpers/feed/update.phtml index af2503256..5d4f1cc4b 100644 --- a/app/views/helpers/feed/update.phtml +++ b/app/views/helpers/feed/update.phtml @@ -1,6 +1,9 @@ feed === null) { + throw new FreshRSS_Context_Exception('Feed not initialised!'); + } ?>

    feed->name() ?>

    @@ -184,9 +187,9 @@
    @@ -195,12 +198,12 @@
    @@ -210,9 +213,9 @@
    @@ -222,9 +225,9 @@
    @@ -245,7 +248,10 @@
    - +
    @@ -267,7 +273,8 @@

    feed->attributes('archiving'); + $archiving = $this->feed->attributeArray('archiving'); + /** @var array<'default'?:bool,'keep_period'?:string,'keep_max'?:int,'keep_min'?:int,'keep_favourites'?:bool,'keep_labels'?:bool,'keep_unreads'?:bool>|null $archiving */ if (empty($archiving)) { $archiving = [ 'default' => true ]; } else { @@ -278,7 +285,7 @@ 'keep_period_count' => '3', 'keep_period_unit' => 'P1M', ]; - if (!empty($archiving['keep_period'])) { + if (!empty($archiving['keep_period']) && is_string($archiving['keep_period'])) { if (preg_match('/^PT?(?P\d+)[YMWDH]$/', $archiving['keep_period'], $matches)) { $volatile['enable_keep_period'] = true; $volatile['keep_period_count'] = $matches['count']; @@ -286,19 +293,19 @@ } } //Defaults - if (!isset($archiving['keep_max'])) { - $archiving['keep_max'] = false; + if (!isset($archiving['keep_max']) || !is_int($archiving['keep_max'])) { + $archiving['keep_max'] = 0; } - if (!isset($archiving['keep_min'])) { + if (!isset($archiving['keep_min']) || !is_int($archiving['keep_min'])) { $archiving['keep_min'] = 50; } - if (!isset($archiving['keep_favourites'])) { + if (!isset($archiving['keep_favourites']) || !is_bool($archiving['keep_favourites'])) { $archiving['keep_favourites'] = true; } - if (!isset($archiving['keep_labels'])) { + if (!isset($archiving['keep_labels']) || !is_bool($archiving['keep_labels'])) { $archiving['keep_labels'] = true; } - if (!isset($archiving['keep_unreads'])) { + if (!isset($archiving['keep_unreads']) || !is_bool($archiving['keep_unreads'])) { $archiving['keep_unreads'] = false; } ?> @@ -406,7 +413,7 @@
    feed->attributes('xpath'))); + $xpath = Minz_Helper::htmlspecialchars_utf8($this->feed->attributeArray('xpath') ?? []); ?>

    @@ -521,7 +528,7 @@
    feed->attributes('path_entries_filter'))); + $path_entries_filter = Minz_Helper::htmlspecialchars_utf8($this->feed->attributeString('path_entries_filter') ?? ''); ?>
    @@ -537,13 +544,13 @@

    @@ -578,8 +585,8 @@

    @@ -590,8 +597,8 @@

    @@ -609,7 +616,7 @@
    - +
    @@ -617,9 +624,9 @@
    @@ -627,7 +634,7 @@
    diff --git a/app/views/helpers/index/normal/entry_bottom.phtml b/app/views/helpers/index/normal/entry_bottom.phtml index dba0e44a3..e5bfd7fd0 100644 --- a/app/views/helpers/index/normal/entry_bottom.phtml +++ b/app/views/helpers/index/normal/entry_bottom.phtml @@ -1,13 +1,13 @@ bottomline_read; - $bottomline_favorite = FreshRSS_Context::$user_conf->bottomline_favorite; - $bottomline_sharing = FreshRSS_Context::$user_conf->bottomline_sharing && (count(FreshRSS_Context::$user_conf->sharing) > 0); - $bottomline_myLabels = FreshRSS_Context::$user_conf->bottomline_myLabels; - $bottomline_tags = FreshRSS_Context::$user_conf->bottomline_tags; - $bottomline_date = FreshRSS_Context::$user_conf->bottomline_date; - $bottomline_link = FreshRSS_Context::$user_conf->bottomline_link; + $bottomline_read = FreshRSS_Context::userConf()->bottomline_read; + $bottomline_favorite = FreshRSS_Context::userConf()->bottomline_favorite; + $bottomline_sharing = FreshRSS_Context::userConf()->bottomline_sharing && (count(FreshRSS_Context::userConf()->sharing) > 0); + $bottomline_myLabels = FreshRSS_Context::userConf()->bottomline_myLabels; + $bottomline_tags = FreshRSS_Context::userConf()->bottomline_tags; + $bottomline_date = FreshRSS_Context::userConf()->bottomline_date; + $bottomline_link = FreshRSS_Context::userConf()->bottomline_link; ?>
      entry->id(); $link = $this->entry->link(); - $title = $this->entry->title() . ' · ' . $this->feed->name(); - foreach (FreshRSS_Context::$user_conf->sharing as $share_options) { + $title = $this->entry->title() . ' · ' . ($this->feed === null ? '' : $this->feed->name()); + foreach (FreshRSS_Context::userConf()->sharing as $share_options) { $share = FreshRSS_Share::get($share_options['type']); if ($share === null) { continue; diff --git a/app/views/helpers/index/normal/entry_header.phtml b/app/views/helpers/index/normal/entry_header.phtml index 6a693b0a9..b324a5949 100644 --- a/app/views/helpers/index/normal/entry_header.phtml +++ b/app/views/helpers/index/normal/entry_header.phtml @@ -1,15 +1,18 @@ topline_read; - $topline_favorite = FreshRSS_Context::$user_conf->topline_favorite; - $topline_website = FreshRSS_Context::$user_conf->topline_website; - $topline_thumbnail = FreshRSS_Context::$user_conf->topline_thumbnail; - $topline_summary = FreshRSS_Context::$user_conf->topline_summary; - $topline_display_authors = FreshRSS_Context::$user_conf->topline_display_authors; - $topline_date = FreshRSS_Context::$user_conf->topline_date; - $topline_link = FreshRSS_Context::$user_conf->topline_link; - $lazyload = FreshRSS_Context::$user_conf->lazyload; + if ($this->feed === null) { + throw new FreshRSS_Context_Exception('Feed not initialised!'); + } + $topline_read = FreshRSS_Context::userConf()->topline_read; + $topline_favorite = FreshRSS_Context::userConf()->topline_favorite; + $topline_website = FreshRSS_Context::userConf()->topline_website; + $topline_thumbnail = FreshRSS_Context::userConf()->topline_thumbnail; + $topline_summary = FreshRSS_Context::userConf()->topline_summary; + $topline_display_authors = FreshRSS_Context::userConf()->topline_display_authors; + $topline_date = FreshRSS_Context::userConf()->topline_date; + $topline_link = FreshRSS_Context::userConf()->topline_link; + $lazyload = FreshRSS_Context::userConf()->lazyload; ?>
      • - show_favicons && 'name' !== $topline_website): ?>✇feed->name() ?> + show_favicons && 'name' !== $topline_website): ?>✇feed->name() ?>
      • diff --git a/app/views/helpers/javascript_vars.phtml b/app/views/helpers/javascript_vars.phtml index 38a7751ee..29f78e5ee 100644 --- a/app/views/helpers/javascript_vars.phtml +++ b/app/views/helpers/javascript_vars.phtml @@ -1,27 +1,27 @@ mark_when; -$s = FreshRSS_Context::$user_conf->shortcuts; +$mark = FreshRSS_Context::userConf()->mark_when; +$s = FreshRSS_Context::userConf()->shortcuts; $extData = Minz_ExtensionManager::callHook('js_vars', []); echo htmlspecialchars(json_encode(array( 'context' => array( 'anonymous' => !FreshRSS_Auth::hasAccess(), 'auto_remove_article' => !!FreshRSS_Context::isAutoRemoveAvailable(), - 'hide_posts' => !(FreshRSS_Context::$user_conf->display_posts || Minz_Request::actionName() === 'reader'), - 'display_order' => Minz_Request::paramString('order') ?: FreshRSS_Context::$user_conf->sort_order, - 'display_categories' => FreshRSS_Context::$user_conf->display_categories, + 'hide_posts' => !(FreshRSS_Context::userConf()->display_posts || Minz_Request::actionName() === 'reader'), + 'display_order' => Minz_Request::paramString('order') ?: FreshRSS_Context::userConf()->sort_order, + 'display_categories' => FreshRSS_Context::userConf()->display_categories, 'auto_mark_article' => !!$mark['article'], 'auto_mark_site' => !!$mark['site'], 'auto_mark_scroll' => !!$mark['scroll'], 'auto_mark_focus' => !!$mark['focus'], - 'auto_load_more' => !!FreshRSS_Context::$user_conf->auto_load_more, + 'auto_load_more' => !!FreshRSS_Context::userConf()->auto_load_more, 'auto_actualize_feeds' => Minz_Session::paramBoolean('actualize_feeds'), - 'does_lazyload' => !!FreshRSS_Context::$user_conf->lazyload , - 'sides_close_article' => !!FreshRSS_Context::$user_conf->sides_close_article, + 'does_lazyload' => !!FreshRSS_Context::userConf()->lazyload , + 'sides_close_article' => !!FreshRSS_Context::userConf()->sides_close_article, 'sticky_post' => !!FreshRSS_Context::isStickyPostEnabled(), - 'html5_notif_timeout' => FreshRSS_Context::$user_conf->html5_notif_timeout, - 'auth_type' => FreshRSS_Context::$system_conf->auth_type, + 'html5_notif_timeout' => FreshRSS_Context::userConf()->html5_notif_timeout, + 'auth_type' => FreshRSS_Context::systemConf()->auth_type, 'current_view' => Minz_Request::actionName(), 'csrf' => FreshRSS_Auth::csrfToken(), 'mtime' => [ @@ -69,7 +69,7 @@ echo htmlspecialchars(json_encode(array( 'notif_request_failed' => _t('gen.js.feedback.request_failed'), 'category_empty' => _t('gen.js.category_empty'), 'labels_empty' => _t('gen.js.labels_empty'), - 'language' => FreshRSS_Context::$user_conf->language, + 'language' => FreshRSS_Context::userConf()->language, ), 'icons' => array( 'read' => rawurlencode(_i('read')), diff --git a/app/views/helpers/stream-footer.phtml b/app/views/helpers/stream-footer.phtml index 41f4315b5..0cbab601a 100644 --- a/app/views/helpers/stream-footer.phtml +++ b/app/views/helpers/stream-footer.phtml @@ -32,13 +32,13 @@
        diff --git a/app/views/index/about.phtml b/app/views/index/about.phtml index 5ee1729cd..1c41cf4d6 100644 --- a/app/views/index/about.phtml +++ b/app/views/index/about.phtml @@ -33,8 +33,8 @@ environment; - if ($env !== 'production' && FreshRSS_Context::$user_conf->is_admin) { ?> + $env = FreshRSS_Context::systemConf()->environment; + if ($env !== 'production' && FreshRSS_Context::userConf()->is_admin) { ?>

        data/config.php

        'environment' => ''
        hide_read_feeds && + if (FreshRSS_Context::userConf()->hide_read_feeds && FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ) && !FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_READ)) { $class = ' state_unread'; @@ -62,7 +62,7 @@ ?>
      • - show_favicons): ?>✇ + show_favicons): ?>✇ name() ?>
      • @@ -82,6 +82,6 @@
        -
        display_posts ? '' : ' class="hide_posts"' ?>> +
        display_posts ? '' : ' class="hide_posts"' ?>>
        diff --git a/app/views/index/normal.phtml b/app/views/index/normal.phtml index 0d484f518..42c2e0072 100644 --- a/app/views/index/normal.phtml +++ b/app/views/index/normal.phtml @@ -11,10 +11,10 @@ call_user_func($this->callbackBeforeEntries, $this); $display_today = true; $display_yesterday = true; $display_others = true; -$hidePosts = !FreshRSS_Context::$user_conf->display_posts; -$lazyload = FreshRSS_Context::$user_conf->lazyload; -$content_width = FreshRSS_Context::$user_conf->content_width; -$MAX_TAGS_DISPLAYED = FreshRSS_Context::$user_conf->show_tags_max; +$hidePosts = !FreshRSS_Context::userConf()->display_posts; +$lazyload = FreshRSS_Context::userConf()->lazyload; +$content_width = FreshRSS_Context::userConf()->content_width; +$MAX_TAGS_DISPLAYED = FreshRSS_Context::userConf()->show_tags_max; $useKeepUnreadImportant = !FreshRSS_Context::isImportant() && !FreshRSS_Context::isFeed(); $today = @strtotime('today'); @@ -74,12 +74,15 @@ $today = @strtotime('today'); ?>" data-priority="feed->priority() ?>">renderHelper('index/normal/entry_header'); + if ($this->feed === null) { + throw new FreshRSS_Context_Exception('Feed not initialised!'); + } $tags = null; $firstTags = array(); $remainingTags = array(); - if (FreshRSS_Context::$user_conf->show_tags === 'h' || FreshRSS_Context::$user_conf->show_tags === 'f' || FreshRSS_Context::$user_conf->show_tags === 'b') { + if (FreshRSS_Context::userConf()->show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'f' || FreshRSS_Context::userConf()->show_tags === 'b') { $tags = $this->entry->tags(); if (!empty($tags)) { if ($MAX_TAGS_DISPLAYED > 0) { @@ -93,14 +96,14 @@ $today = @strtotime('today'); ?>
        - show_feed_name === 't') { ?> + show_feed_name === 't') { ?> - show_tags === 'h' || FreshRSS_Context::$user_conf->show_tags === 'b') { ?> + show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'b') { ?>

        entry->title() ?>

        - show_author_date === 'h' || FreshRSS_Context::$user_conf->show_author_date === 'b') { ?> + show_author_date === 'h' || FreshRSS_Context::userConf()->show_author_date === 'b') { ?>
        - show_feed_name === 'a') { ?> + show_feed_name === 'a') { ?> @@ -164,8 +167,8 @@ $today = @strtotime('today'); echo $lazyload && $hidePosts ? lazyimg($this->entry->content(true)) : $this->entry->content(true); ?>
        show_author_date === 'f' || FreshRSS_Context::$user_conf->show_author_date === 'b'; - $display_tags = FreshRSS_Context::$user_conf->show_tags === 'f' || FreshRSS_Context::$user_conf->show_tags === 'b'; + $display_authors_date = FreshRSS_Context::userConf()->show_author_date === 'f' || FreshRSS_Context::userConf()->show_author_date === 'b'; + $display_tags = FreshRSS_Context::userConf()->show_tags === 'f' || FreshRSS_Context::userConf()->show_tags === 'b'; if ($display_authors_date || $display_tags) { ?> @@ -173,9 +176,9 @@ $today = @strtotime('today');
        - show_feed_name === 'a') { ?> + show_feed_name === 'a') { ?> @@ -266,4 +269,4 @@ $today = @strtotime('today'); - 0 && FreshRSS_Context::$user_conf->show_nav_buttons) $this->partial('nav_entries'); ?> + 0 && FreshRSS_Context::userConf()->show_nav_buttons) $this->partial('nav_entries'); ?> diff --git a/app/views/index/reader.phtml b/app/views/index/reader.phtml index dc90a144a..f2d7ab46b 100644 --- a/app/views/index/reader.phtml +++ b/app/views/index/reader.phtml @@ -8,9 +8,9 @@ if (!Minz_Request::paramBoolean('ajax')) { call_user_func($this->callbackBeforeEntries, $this); -$lazyload = FreshRSS_Context::$user_conf->lazyload; -$content_width = FreshRSS_Context::$user_conf->content_width; -$MAX_TAGS_DISPLAYED = FreshRSS_Context::$user_conf->show_tags_max; +$lazyload = FreshRSS_Context::userConf()->lazyload; +$content_width = FreshRSS_Context::userConf()->content_width; +$MAX_TAGS_DISPLAYED = FreshRSS_Context::userConf()->show_tags_max; ?>

        @@ -35,7 +35,7 @@ $MAX_TAGS_DISPLAYED = FreshRSS_Context::$user_conf->show_tags_max; $firstTags = array(); $remainingTags = array(); - if (FreshRSS_Context::$user_conf->show_tags == 'h' || FreshRSS_Context::$user_conf->show_tags == 'f' || FreshRSS_Context::$user_conf->show_tags == 'b') { + if (FreshRSS_Context::userConf()->show_tags == 'h' || FreshRSS_Context::userConf()->show_tags == 'f' || FreshRSS_Context::userConf()->show_tags == 'b') { $tags = $this->entry->tags(); if (!empty($tags)) { if ($MAX_TAGS_DISPLAYED > 0) { @@ -69,15 +69,15 @@ $MAX_TAGS_DISPLAYED = FreshRSS_Context::$user_conf->show_tags_max; isRead() ? 'read' : 'unread') ?> isFavorite() ? 'starred' : 'non-starred') ?> - show_feed_name === 't') { ?> + show_feed_name === 't') { ?> - show_favicons): ?> + show_favicons): ?> ✇name() ?>
        - show_tags === 'h' || FreshRSS_Context::$user_conf->show_tags === 'b') { ?> + show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'b') { ?>
        show_tags_max;

        title() ?>

        - show_author_date === 'h' || FreshRSS_Context::$user_conf->show_author_date === 'b') { ?> + show_author_date === 'h' || FreshRSS_Context::userConf()->show_author_date === 'b') { ?>
        - show_feed_name === 'a') { ?> + show_feed_name === 'a') { ?> @@ -141,17 +141,17 @@ $MAX_TAGS_DISPLAYED = FreshRSS_Context::$user_conf->show_tags_max; content(true) ?>
        show_author_date === 'f' || FreshRSS_Context::$user_conf->show_author_date === 'b'; - $display_tags = FreshRSS_Context::$user_conf->show_tags === 'f' || FreshRSS_Context::$user_conf->show_tags === 'b'; + $display_authors_date = FreshRSS_Context::userConf()->show_author_date === 'f' || FreshRSS_Context::userConf()->show_author_date === 'b'; + $display_tags = FreshRSS_Context::userConf()->show_tags === 'f' || FreshRSS_Context::userConf()->show_tags === 'b'; if ($display_authors_date || $display_tags) { ?>