summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-06-24 08:37:10 +0300
committerAndrew Dolgov <[email protected]>2021-06-24 08:37:10 +0300
commitf9e253b4f36dbbd99e1a237d318f8a01054513d8 (patch)
treef3fe3052d142c16c8701cccb9ca514dadb6c3192
parent9f5810f5824303c101c45e47d450022b6aedfd54 (diff)
fix some warnings, remove unused code, code cleanup
-rw-r--r--init.php72
1 files 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 "<header>".__("Override enclosure content type")."</header>";
- print "<section>";
-
- $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 "<fieldset>";
-
- print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='af_enclosure_fix_type_enabled'
- name='af_enclosure_fix_type_enabled' $checked>&nbsp;".__('Enable for this feed')."</label>";
-
- print "</fieldset>";
-
- print "</section>";
+ $enabled_feeds = $this->host->get_array($this, "enabled_feeds");
+ ?>
+ <header><?= $this->__("Override enclosure content type") ?></header>
+ <section>
+ <fieldset>
+ <label class='checkbox'>
+ <?= \Controls\checkbox_tag("af_enclosure_fix_type_enabled", in_array($feed_id, $enabled_feeds)) ?>
+ <?= $this->__('Enable for this feed') ?></label>
+ </fieldset>
+ </section>
+ <?php
}
- /** @noinspection PhpUnused */
function hook_prefs_save_feed($feed_id) {
- $enabled_feeds = $this->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"];