diff options
Diffstat (limited to 'classes')
-rw-r--r-- | classes/API.php | 2 | ||||
-rw-r--r-- | classes/Config.php | 15 | ||||
-rw-r--r-- | classes/DiskCache.php | 2 | ||||
-rw-r--r-- | classes/Feeds.php | 90 | ||||
-rw-r--r-- | classes/PluginHost.php | 23 | ||||
-rw-r--r-- | classes/Pref_Prefs.php | 14 | ||||
-rw-r--r-- | classes/Prefs.php | 6 | ||||
-rw-r--r-- | classes/UrlHelper.php | 26 | ||||
-rw-r--r-- | classes/UserHelper.php | 3 |
9 files changed, 50 insertions, 131 deletions
diff --git a/classes/API.php b/classes/API.php index 45820f300..6dbb1f246 100644 --- a/classes/API.php +++ b/classes/API.php @@ -817,7 +817,7 @@ class API extends Handler { $headline_row["labels"] = $labels; - $headline_row["feed_title"] = isset($line["feed_title"]) ? $line["feed_title"] : $feed_title; + $headline_row["feed_title"] = $line["feed_title"] ?? $feed_title; $headline_row["comments_count"] = (int)$line["num_comments"]; $headline_row["comments_link"] = $line["comments"]; diff --git a/classes/Config.php b/classes/Config.php index d28a259c9..e9d44063c 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -491,12 +491,9 @@ class Config { $self_url_path = $proto . '://' . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); $self_url_path = preg_replace("/(\/api\/{1,})?(\w+\.php)?(\?.*$)?$/", "", $self_url_path); + $self_url_path = preg_replace("/(\/plugins(.local))\/.{1,}$/", "", $self_url_path); - if (substr($self_url_path, -1) === "/") { - return substr($self_url_path, 0, -1); - } else { - return $self_url_path; - } + return rtrim($self_url_path, "/"); } } /* sanity check stuff */ @@ -665,8 +662,8 @@ class Config { <?php foreach ($errors as $error) { echo self::format_error($error); } ?> - <p>You might want to check tt-rss <a target="_blank" href="https://tt-rss.org/wiki.php">wiki</a> or the - <a target="_blank" href="https://community.tt-rss.org/">forums</a> for more information. Please search the forums before creating new topic + <p>You might want to check the tt-rss <a target="_blank" href="https://tt-rss.org/wiki/InstallationNotes/">wiki</a> or + <a target="_blank" href="https://community.tt-rss.org/">forums</a> for more information. Please search the forums before creating a new topic for your question.</p> </div> </body> @@ -681,8 +678,8 @@ class Config { echo " * " . strip_tags($error)."\n"; } - echo "\nYou might want to check tt-rss wiki or the forums for more information.\n"; - echo "Please search the forums before creating new topic for your question.\n"; + echo "\nYou might want to check the tt-rss wiki or forums for more information.\n"; + echo "Please search the forums before creating a new topic for your question.\n"; exit(1); } diff --git a/classes/DiskCache.php b/classes/DiskCache.php index 196eed02d..d6335a9e7 100644 --- a/classes/DiskCache.php +++ b/classes/DiskCache.php @@ -410,7 +410,7 @@ class DiskCache implements Cache_Adapter { $mimetype = $this->adapter->get_mime_type(basename($filename)); if ($mimetype) - return isset($this->mimeMap[$mimetype]) ? $this->mimeMap[$mimetype] : ""; + return $this->mimeMap[$mimetype] ?? ""; else return ""; } diff --git a/classes/Feeds.php b/classes/Feeds.php index 64674b2d2..71379762f 100644 --- a/classes/Feeds.php +++ b/classes/Feeds.php @@ -18,12 +18,9 @@ class Feeds extends Handler_Protected { const FEED_ALL = -4; /** - * a special case feed used to display auxiliary information when there's nothing to load (e.g. no stuff in fresh feed) - * - * TODO: Remove this and 'Feeds::_generate_dashboard_feed()'? It only seems to be used if 'Feeds::view()' (also potentially removable) - * gets passed the ID. + * -5 was FEED_DASHBOARD, intended to be used when there + * was nothing to show, but the related code was unused */ - const FEED_DASHBOARD = -5; /** special feed for recently read articles */ const FEED_RECENTLY_READ = -6; @@ -492,11 +489,6 @@ class Feeds extends Handler_Protected { if (is_numeric($feed)) $feed = (int) $feed; - if ($feed == Feeds::FEED_DASHBOARD) { - print json_encode($this->_generate_dashboard_feed()); - return; - } - $sth = false; if ($feed < LABEL_BASE_INDEX) { @@ -572,50 +564,6 @@ class Feeds extends Handler_Protected { } /** - * @return array<string, array<string, mixed>> - */ - private function _generate_dashboard_feed(): array { - $reply = array(); - - $reply['headlines']['id'] = Feeds::FEED_DASHBOARD; - $reply['headlines']['is_cat'] = false; - - $reply['headlines']['toolbar'] = ''; - - $reply['headlines']['content'] = "<div class='whiteBox'>".__('No feed selected.'); - - $reply['headlines']['content'] .= "<p><span class=\"text-muted\">"; - - $sth = $this->pdo->prepare("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds - WHERE owner_uid = ?"); - $sth->execute([$_SESSION['uid']]); - $row = $sth->fetch(); - - $last_updated = TimeHelper::make_local_datetime($row["last_updated"], false); - - $reply['headlines']['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated); - - $num_errors = ORM::for_table('ttrss_feeds') - ->where_not_equal('last_error', '') - ->where('owner_uid', $_SESSION['uid']) - ->where_gte('update_interval', 0) - ->count('id'); - - if ($num_errors > 0) { - $reply['headlines']['content'] .= "<br/>"; - $reply['headlines']['content'] .= "<a class=\"text-muted\" href=\"#\" onclick=\"CommonDialogs.showFeedsWithErrors(); return false\">". - __('Some feeds have update errors (click for details)')."</a>"; - } - $reply['headlines']['content'] .= "</span></p>"; - - $reply['headlines-info'] = array("count" => 0, - "unread" => 0, - "disable_cache" => true); - - return $reply; - } - - /** * @return array<string, mixed> */ private function _generate_error_feed(string $error): array { @@ -1495,23 +1443,23 @@ class Feeds extends Handler_Protected { // right before adding them to SQL part $feed = $params["feed"]; - $limit = isset($params["limit"]) ? $params["limit"] : 30; + $limit = $params["limit"] ?? 30; $view_mode = $params["view_mode"]; - $cat_view = isset($params["cat_view"]) ? $params["cat_view"] : false; - $search = isset($params["search"]) ? $params["search"] : false; - $search_language = isset($params["search_language"]) ? $params["search_language"] : ""; - $override_order = isset($params["override_order"]) ? $params["override_order"] : false; - $offset = isset($params["offset"]) ? $params["offset"] : 0; - $owner_uid = isset($params["owner_uid"]) ? $params["owner_uid"] : $_SESSION["uid"]; - $since_id = isset($params["since_id"]) ? $params["since_id"] : 0; - $include_children = isset($params["include_children"]) ? $params["include_children"] : false; - $ignore_vfeed_group = isset($params["ignore_vfeed_group"]) ? $params["ignore_vfeed_group"] : false; - $override_strategy = isset($params["override_strategy"]) ? $params["override_strategy"] : false; - $override_vfeed = isset($params["override_vfeed"]) ? $params["override_vfeed"] : false; - $start_ts = isset($params["start_ts"]) ? $params["start_ts"] : false; - $check_first_id = isset($params["check_first_id"]) ? $params["check_first_id"] : false; - $skip_first_id_check = isset($params["skip_first_id_check"]) ? $params["skip_first_id_check"] : false; - //$order_by = isset($params["order_by"]) ? $params["order_by"] : false; + $cat_view = $params["cat_view"] ?? false; + $search = $params["search"] ?? false; + $search_language = $params["search_language"] ?? ""; + $override_order = $params["override_order"] ?? false; + $offset = $params["offset"] ?? 0; + $owner_uid = $params["owner_uid"] ?? $_SESSION["uid"]; + $since_id = $params["since_id"] ?? 0; + $include_children = $params["include_children"] ?? false; + $ignore_vfeed_group = $params["ignore_vfeed_group"] ?? false; + $override_strategy = $params["override_strategy"] ?? false; + $override_vfeed = $params["override_vfeed"] ?? false; + $start_ts = $params["start_ts"] ?? false; + $check_first_id = $params["check_first_id"] ?? false; + $skip_first_id_check = $params["skip_first_id_check"] ?? false; + //$order_by = $params["order_by"] ?? false; $ext_tables_part = ""; $limit_query_part = ""; @@ -2287,7 +2235,7 @@ class Feeds extends Handler_Protected { * @return array{0: string, 1: array<int, string>} [$search_query_part, $search_words] */ private static function _search_to_sql(string $search, string $search_language, int $owner_uid): array { - $keywords = str_getcsv(preg_replace('/(-?\w+)\:"(\w+)/', '"{$1}:{$2}', trim($search)), ' '); + $keywords = str_getcsv(preg_replace('/(-?\w+)\:"(\w+)/', '"{$1}:{$2}', trim($search)), ' ', '"', ''); $query_keywords = array(); $search_words = array(); $search_query_leftover = array(); diff --git a/classes/PluginHost.php b/classes/PluginHost.php index 2098be4e6..f3febc431 100644 --- a/classes/PluginHost.php +++ b/classes/PluginHost.php @@ -586,11 +586,7 @@ class PluginHost { $method = strtolower($method); if (isset($this->handlers[$handler])) { - if (isset($this->handlers[$handler]["*"])) { - return $this->handlers[$handler]["*"]; - } else { - return $this->handlers[$handler][$method]; - } + return $this->handlers[$handler]["*"] ?? $this->handlers[$handler][$method]; } return false; @@ -752,15 +748,8 @@ class PluginHost { if ($profile_id) { $idx = get_class($sender); - $this->load_data(); - - if (isset($this->storage[$idx][$profile_id][$name])) { - return $this->storage[$idx][$profile_id][$name]; - } else { - return $default_value; - } - + return $this->storage[$idx][$profile_id][$name] ?? $default_value; } else { return $this->get($sender, $name, $default_value); } @@ -772,14 +761,8 @@ class PluginHost { */ function get(Plugin $sender, string $name, $default_value = false) { $idx = get_class($sender); - $this->load_data(); - - if (isset($this->storage[$idx][$name])) { - return $this->storage[$idx][$name]; - } else { - return $default_value; - } + return $this->storage[$idx][$name] ?? $default_value; } /** diff --git a/classes/Pref_Prefs.php b/classes/Pref_Prefs.php index 5cbf3c6d1..dd28bd3f2 100644 --- a/classes/Pref_Prefs.php +++ b/classes/Pref_Prefs.php @@ -655,7 +655,7 @@ class Pref_Prefs extends Handler_Protected { <?= \Controls\button_tag(\Controls\icon("palette") . " " . __("Customize"), "", ["onclick" => "Helpers.Prefs.customizeCSS()"]) ?> <?= \Controls\button_tag(\Controls\icon("open_in_new") . " " . __("More themes..."), "", - ["class" => "alt-info", "onclick" => "window.open(\"https://tt-rss.org/wiki/Themes\")"]) ?> + ["class" => "alt-info", "onclick" => "window.open(\"https://tt-rss.org/Themes/\")"]) ?> <?php @@ -898,7 +898,7 @@ class Pref_Prefs extends Handler_Protected { </div> <div dojoType="dijit.layout.ContentPane" region="bottom"> - <button dojoType='dijit.form.Button' class="alt-info pull-right" onclick='window.open("https://tt-rss.org/wiki/Plugins")'> + <button dojoType='dijit.form.Button' class="alt-info pull-right" onclick='window.open("https://tt-rss.org/Plugins/")'> <i class='material-icons'>help</i> <?= __("More info") ?> </button> @@ -1481,17 +1481,11 @@ class Pref_Prefs extends Handler_Protected { } private function _get_short_desc(string $pref_name): string { - if (isset($this->pref_help[$pref_name][0])) { - return $this->pref_help[$pref_name][0]; - } - return ""; + return $this->pref_help[$pref_name][0] ?? ""; } private function _get_help_text(string $pref_name): string { - if (isset($this->pref_help[$pref_name][1])) { - return $this->pref_help[$pref_name][1]; - } - return ""; + return $this->pref_help[$pref_name][1] ?? ""; } private function appPasswordList(): void { diff --git a/classes/Prefs.php b/classes/Prefs.php index f778f0f84..8d84d5ec2 100644 --- a/classes/Prefs.php +++ b/classes/Prefs.php @@ -303,11 +303,7 @@ class Prefs { */ private function _get_cache(string $pref_name, int $owner_uid, ?int $profile_id) { $cache_key = sprintf("%d/%d/%s", $owner_uid, $profile_id, $pref_name); - - if (isset($this->cache[$cache_key])) - return $this->cache[$cache_key]; - - return null; + return $this->cache[$cache_key] ?? null; } /** diff --git a/classes/UrlHelper.php b/classes/UrlHelper.php index 7c426bedf..ba1f474bc 100644 --- a/classes/UrlHelper.php +++ b/classes/UrlHelper.php @@ -276,19 +276,19 @@ class UrlHelper { } $url = $options["url"]; - $type = isset($options["type"]) ? $options["type"] : false; - $login = isset($options["login"]) ? $options["login"] : false; - $pass = isset($options["pass"]) ? $options["pass"] : false; - $auth_type = isset($options["auth_type"]) ? $options["auth_type"] : "basic"; - $post_query = isset($options["post_query"]) ? $options["post_query"] : false; - $timeout = isset($options["timeout"]) ? $options["timeout"] : false; - $last_modified = isset($options["last_modified"]) ? $options["last_modified"] : ""; - $useragent = isset($options["useragent"]) ? $options["useragent"] : false; - $followlocation = isset($options["followlocation"]) ? $options["followlocation"] : true; - $max_size = isset($options["max_size"]) ? $options["max_size"] : Config::get(Config::MAX_DOWNLOAD_FILE_SIZE); // in bytes - $http_accept = isset($options["http_accept"]) ? $options["http_accept"] : false; - $http_referrer = isset($options["http_referrer"]) ? $options["http_referrer"] : false; - $encoding = isset($options["encoding"]) ? $options["encoding"] : false; + $type = $options["type"] ?? false; + $login = $options["login"] ?? false; + $pass = $options["pass"] ?? false; + $auth_type = $options["auth_type"] ?? "basic"; + $post_query = $options["post_query"] ?? false; + $timeout = $options["timeout"] ?? false; + $last_modified = $options["last_modified"] ?? ""; + $useragent = $options["useragent"] ?? false; + $followlocation = $options["followlocation"] ?? true; + $max_size = $options["max_size"] ?? Config::get(Config::MAX_DOWNLOAD_FILE_SIZE); // in bytes + $http_accept = $options["http_accept"] ?? false; + $http_referrer = $options["http_referrer"] ?? false; + $encoding = $options["encoding"] ?? false; $url = ltrim($url, ' '); $url = str_replace(' ', '%20', $url); diff --git a/classes/UserHelper.php b/classes/UserHelper.php index 92c397764..0c2ed349b 100644 --- a/classes/UserHelper.php +++ b/classes/UserHelper.php @@ -62,6 +62,7 @@ class UserHelper { if (!Config::get(Config::SINGLE_USER_MODE)) { $user_id = false; $auth_module = false; + $login = mb_strtolower($login); PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_AUTH_USER, function ($result, $plugin) use (&$user_id, &$auth_module) { @@ -222,7 +223,7 @@ class UserHelper { static function find_user_by_login(string $login): ?int { $user = ORM::for_table('ttrss_users') - ->where('login', $login) + ->where_raw('LOWER(login) = LOWER(?)', [$login]) ->find_one(); if ($user) |