From f9e253b4f36dbbd99e1a237d318f8a01054513d8 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 24 Jun 2021 08:37:10 +0300 Subject: fix some warnings, remove unused code, code cleanup --- init.php | 72 ++++++++++++++++++++++------------------------------------------ 1 file changed, 25 insertions(+), 47 deletions(-) diff --git a/init.php b/init.php index 839fda1..d980d06 100644 --- a/init.php +++ b/init.php @@ -2,73 +2,52 @@ class Af_Enclosure_Fix_Type extends Plugin { - /* @var PluginHost $host */ + /** @var PluginHost $host */ private $host; function about() { - return array(1.0, + return [null, "Overrides content type for enclosures based on server-provided data", - "fox"); + "fox"]; } - function save() { - $enable_share_anything = checkbox_to_sql_bool($_POST["enable_share_anything"]); - - $this->host->set($this, "enable_share_anything", $enable_share_anything); - - echo __("Data saved."); - } - - function init($host) - { + function init($host) { $this->host = $host; - if (version_compare(PHP_VERSION, '5.6.0', '<')) { - return; - } - - $host->add_hook($host::HOOK_ENCLOSURE_IMPORTED, $this); - $host->add_hook($host::HOOK_PREFS_EDIT_FEED, $this); - $host->add_hook($host::HOOK_PREFS_SAVE_FEED, $this); + $this->host->add_hook($host::HOOK_ENCLOSURE_IMPORTED, $this); + $this->host->add_hook($host::HOOK_PREFS_EDIT_FEED, $this); + $this->host->add_hook($host::HOOK_PREFS_SAVE_FEED, $this); - $host->add_filter_action($this, "action_fix_enclosure_type", __("Fix media enclosures")); + //$host->add_filter_action($this, "action_fix_enclosure_type", __("Fix media enclosures")); } - /** @noinspection PhpUnused */ function hook_prefs_edit_feed($feed_id) { - print "
".__("Override enclosure content type")."
"; - print "
"; - - $enabled_feeds = $this->host->get($this, "enabled_feeds"); - if (!is_array($enabled_feeds)) $enabled_feeds = array(); - - $key = array_search($feed_id, $enabled_feeds); - $checked = $key !== FALSE ? "checked" : ""; - - print "
"; - - print ""; - - print "
"; - - print "
"; + $enabled_feeds = $this->host->get_array($this, "enabled_feeds"); + ?> +
__("Override enclosure content type") ?>
+
+
+ +
+
+ filter_unknown_feeds($this->host->get($this, "enabled_feeds")); - if (!is_array($enabled_feeds)) $enabled_feeds = array(); + $enabled_feeds = $this->filter_unknown_feeds( + $this->host->get_array($this, "enabled_feeds")); - $enable = checkbox_to_sql_bool($_POST["af_enclosure_fix_type_enabled"]); + $enable = checkbox_to_sql_bool($_POST["af_enclosure_fix_type_enabled"] ?? ""); $key = array_search($feed_id, $enabled_feeds); if ($enable) { - if ($key === FALSE) { + if ($key === false) { array_push($enabled_feeds, $feed_id); } } else { - if ($key !== FALSE) { + if ($key !== false) { unset($enabled_feeds[$key]); } } @@ -76,14 +55,13 @@ class Af_Enclosure_Fix_Type extends Plugin { $this->host->set($this, "enabled_feeds", $enabled_feeds); } - /** @noinspection PhpUnused */ function hook_enclosure_imported($enc, $feed) { $enabled_feeds = $this->host->get($this, "enabled_feeds"); if (!is_array($enabled_feeds) || array_search($feed, $enabled_feeds) === FALSE) return $enc; - $headers = @get_headers($enc->link, 1); + $headers = get_headers($enc->link, 1); if (is_array($headers) && isset($headers["Content-Type"])) { $enc->type = $headers["Content-Type"]; -- cgit v1.2.3