summaryrefslogtreecommitdiff
path: root/classes/feeds.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2022-11-24 23:31:33 +0300
committerAndrew Dolgov <[email protected]>2022-11-24 23:31:33 +0300
commita30b9bb649d6e10a5d7c2feb73376669cf23ef68 (patch)
tree33716caf2286a0c544a2f053ea07c677aebd5fd4 /classes/feeds.php
parentbe6bc72a742c5fb7f87a4495009ed71ff0fbb8d8 (diff)
rework favicon storage to use DiskCache
Diffstat (limited to 'classes/feeds.php')
-rwxr-xr-xclasses/feeds.php32
1 files changed, 21 insertions, 11 deletions
diff --git a/classes/feeds.php b/classes/feeds.php
index a063b9ed5..d34a23e4b 100755
--- a/classes/feeds.php
+++ b/classes/feeds.php
@@ -1163,11 +1163,28 @@ class Feeds extends Handler_Protected {
}
static function _get_icon_file(int $feed_id): string {
- return Config::get(Config::ICONS_DIR) . "/$feed_id.ico";
+ $favicon_cache = new DiskCache('feed-icons');
+
+ return $favicon_cache->get_full_path((string)$feed_id);
}
- static function _has_icon(int $id): bool {
- return is_file(Config::get(Config::ICONS_DIR) . "/$id.ico") && filesize(Config::get(Config::ICONS_DIR) . "/$id.ico") > 0;
+ static function _get_icon_url(int $feed_id, string $fallback_url = "") : string {
+ if (self::_has_icon($feed_id)) {
+ $icon_url = Config::get_self_url() . "/public.php?" . http_build_query([
+ 'op' => 'feed_icon',
+ 'id' => $feed_id,
+ ]);
+
+ return $icon_url;
+ }
+
+ return $fallback_url;
+ }
+
+ static function _has_icon(int $feed_id): bool {
+ $favicon_cache = new DiskCache('feed-icons');
+
+ return $favicon_cache->exists((string)$feed_id);
}
/**
@@ -1191,16 +1208,9 @@ class Feeds extends Handler_Protected {
if ($id < LABEL_BASE_INDEX) {
return "label";
} else {
- $icon = self::_get_icon_file($id);
-
- if ($icon && file_exists($icon)) {
- return Config::get(Config::ICONS_URL) . "/" . basename($icon) . "?" . filemtime($icon);
- }
+ return self::_get_icon_url($id);
}
- break;
}
-
- return false;
}
/**