diff --git a/backend.php b/backend.php index d3d8622d9..c69d6d98b 100644 --- a/backend.php +++ b/backend.php @@ -113,8 +113,7 @@ $op = str_replace("-", "_", $op); - global $pluginhost; - $override = $pluginhost->lookup_handler($op, $method); + $override = PluginHost::getInstance()->lookup_handler($op, $method); if (class_exists($op) || $override) { diff --git a/classes/api.php b/classes/api.php index 945496bcf..9e99ed007 100644 --- a/classes/api.php +++ b/classes/api.php @@ -341,8 +341,7 @@ class API extends Handler { "score" => (int)$line["score"] ); - global $pluginhost; - foreach ($pluginhost->get_hooks($pluginhost::HOOK_RENDER_ARTICLE_API) as $p) { + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) { $article = $p->hook_render_article_api(array("article" => $article)); } @@ -466,9 +465,7 @@ class API extends Handler { } function index($method) { - global $pluginhost; - - $plugin = $pluginhost->get_api_method(strtolower($method)); + $plugin = PluginHost::getInstance()->get_api_method(strtolower($method)); if ($plugin && method_exists($plugin, $method)) { $reply = $plugin->$method(); @@ -697,8 +694,7 @@ class API extends Handler { $headline_row["author"] = $line["author"]; $headline_row["score"] = (int)$line["score"]; - global $pluginhost; - foreach ($pluginhost->get_hooks($pluginhost::HOOK_RENDER_ARTICLE_API) as $p) { + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) { $headline_row = $p->hook_render_article_api(array("headline" => $headline_row)); } diff --git a/classes/feeds.php b/classes/feeds.php index 969c25db1..bef759d36 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -108,14 +108,12 @@ class Feeds extends Handler_Protected { } - global $pluginhost; - - if ($pluginhost->get_plugin("mail")) { + if (PluginHost::getInstance()->get_plugin("mail")) { $reply .= ""; } - if ($pluginhost->get_plugin("mailto")) { + if (PluginHost::getInstance()->get_plugin("mailto")) { $reply .= ""; } @@ -132,7 +130,7 @@ class Feeds extends Handler_Protected { //$reply .= "get_hooks($pluginhost::HOOK_HEADLINE_TOOLBAR_BUTTON) as $p) { + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINE_TOOLBAR_BUTTON) as $p) { echo $p->hook_headline_toolbar_button($feed_id, $is_cat); } @@ -214,9 +212,7 @@ class Feeds extends Handler_Protected { // error_log("search_mode: " . $search_mode); if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) { - global $pluginhost; - - $handler = $pluginhost->get_feed_handler( + $handler = PluginHost::getInstance()->get_feed_handler( PluginHost::feed_to_pfeed_id($feed)); // function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false) { @@ -273,8 +269,6 @@ class Feeds extends Handler_Protected { } } */ - global $pluginhost; - if ($this->dbh->num_rows($result) > 0) { $lnum = $offset; @@ -521,7 +515,7 @@ class Feeds extends Handler_Protected { $line["content"] = sanitize($line["content_preview"], sql_bool_to_bool($line['hide_images']), false, $entry_site_url); - foreach ($pluginhost->get_hooks($pluginhost::HOOK_RENDER_ARTICLE_CDM) as $p) { + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) { $line = $p->hook_render_article_cdm($line); } @@ -679,7 +673,7 @@ class Feeds extends Handler_Protected { $reply['content'] .= "
"; # pane @@ -1503,15 +1500,12 @@ class Pref_Feeds extends Handler_Protected { print " "; - global $pluginhost; - $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION, + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefFeedsPublishedGenerated"); print ""; #pane - global $pluginhost; - - $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB, + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefFeeds"); print ""; #container diff --git a/classes/pref/filters.php b/classes/pref/filters.php index ec7fd0d51..4dbee5906 100644 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -706,8 +706,7 @@ class Pref_Filters extends Handler_Protected { print ""; #pane - global $pluginhost; - $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB, + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefFilters"); print ""; #container diff --git a/classes/pref/labels.php b/classes/pref/labels.php index a928dd017..2ad152c2d 100644 --- a/classes/pref/labels.php +++ b/classes/pref/labels.php @@ -319,8 +319,7 @@ class Pref_Labels extends Handler_Protected { print ""; #pane - global $pluginhost; - $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB, + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefLabels"); print ""; #container diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index d8b8ecc75..b2e7edf03 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -79,8 +79,7 @@ class Pref_Prefs extends Handler_Protected { return; } - global $pluginhost; - $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]); + $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]); if (method_exists($authenticator, "change_password")) { print $authenticator->change_password($_SESSION["uid"], $old_pw, $new_pw); @@ -255,10 +254,7 @@ class Pref_Prefs extends Handler_Protected { print ""; if ($_SESSION["auth_module"]) { - global $pluginhost; - - $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]); - + $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]); } else { $authenticator = false; } @@ -436,8 +432,7 @@ class Pref_Prefs extends Handler_Protected { } } - global $pluginhost; - $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION, + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefPrefsAuth"); print ""; #pane @@ -675,8 +670,7 @@ class Pref_Prefs extends Handler_Protected { print ""; - global $pluginhost; - $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION, + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefPrefsPrefsInside"); print ''; # inside pane @@ -712,8 +706,7 @@ class Pref_Prefs extends Handler_Protected { "; */ - global $pluginhost; - $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION, + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefPrefsPrefsOutside"); print ""; @@ -877,8 +870,7 @@ class Pref_Prefs extends Handler_Protected { print ""; #pane - global $pluginhost; - $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB, + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefPrefs"); print ""; #container @@ -918,8 +910,7 @@ class Pref_Prefs extends Handler_Protected { $password = $_REQUEST["password"]; $otp = $_REQUEST["otp"]; - global $pluginhost; - $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]); + $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]); if ($authenticator->check_password($_SESSION["uid"], $password)) { @@ -951,8 +942,7 @@ class Pref_Prefs extends Handler_Protected { function otpdisable() { $password = $this->dbh->escape_string($_REQUEST["password"]); - global $pluginhost; - $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]); + $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]); if ($authenticator->check_password($_SESSION["uid"], $password)) { @@ -978,8 +968,7 @@ class Pref_Prefs extends Handler_Protected { function clearplugindata() { $name = $this->dbh->escape_string($_REQUEST["name"]); - global $pluginhost; - $pluginhost->clear_data($pluginhost->get_plugin($name)); + PluginHost::getInstance()->clear_data(PluginHost::getInstance()->get_plugin($name)); } function customizeCSS() { diff --git a/classes/pref/system.php b/classes/pref/system.php index 3d82b8fff..725c337dc 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -66,8 +66,7 @@ class Pref_System extends Handler_Protected { print ""; - global $pluginhost; - $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB, + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefSystem"); print ""; #container diff --git a/classes/pref/users.php b/classes/pref/users.php index d483c771b..4b7d2d69a 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -453,8 +453,7 @@ class Pref_Users extends Handler_Protected { print ""; #pane - global $pluginhost; - $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB, + PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefUsers"); print ""; #container diff --git a/include/functions.php b/include/functions.php index 3c8e9d62c..9f890eba7 100644 --- a/include/functions.php +++ b/include/functions.php @@ -9,7 +9,6 @@ $fetch_last_error_code = false; $fetch_last_content_type = false; $fetch_curl_used = false; - $pluginhost = false; mb_internal_encoding("UTF-8"); date_default_timezone_set('UTC'); @@ -622,8 +621,7 @@ if (!SINGLE_USER_MODE) { $user_id = false; - global $pluginhost; - foreach ($pluginhost->get_hooks($pluginhost::HOOK_AUTH_USER) as $plugin) { + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_AUTH_USER) as $plugin) { $user_id = (int) $plugin->authenticate($login, $password); @@ -734,11 +732,10 @@ if ($owner_uid) { $plugins = get_pref("_ENABLED_PLUGINS", $owner_uid); - global $pluginhost; - $pluginhost->load($plugins, $pluginhost::KIND_USER, $owner_uid); + PluginHost::getInstance()->load($plugins, PluginHost::KIND_USER, $owner_uid); if (get_schema_version() > 100) { - $pluginhost->load_data(); + PluginHost::getInstance()->load_data(); } } } @@ -1443,18 +1440,13 @@ array_push($ret_arr, $cv); } - global $pluginhost; - - if ($pluginhost) { - $feeds = $pluginhost->get_feeds(-1); - - if (is_array($feeds)) { - foreach ($feeds as $feed) { - $cv = array("id" => PluginHost::pfeed_to_feed_id($feed['id']), - "counter" => $feed['sender']->get_unread($feed['id'])); + $feeds = PluginHost::getInstance()->get_feeds(-1); + if (is_array($feeds)) { + foreach ($feeds as $feed) { + $cv = array("id" => PluginHost::pfeed_to_feed_id($feed['id']), + "counter" => $feed['sender']->get_unread($feed['id'])); array_push($ret_arr, $cv); - } } } @@ -1982,8 +1974,7 @@ "help_dialog" => __("Show help dialog")) ); - global $pluginhost; - foreach ($pluginhost->get_hooks($pluginhost::HOOK_HOTKEY_INFO) as $plugin) { + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HOTKEY_INFO) as $plugin) { $hotkeys = $plugin->hook_hotkey_info($hotkeys); } @@ -2059,8 +2050,7 @@ $hotkeys["^(40)|Ctrl-down"] = "next_article_noscroll"; } - global $pluginhost; - foreach ($pluginhost->get_hooks($pluginhost::HOOK_HOTKEY_MAP) as $plugin) { + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HOTKEY_MAP) as $plugin) { $hotkeys = $plugin->hook_hotkey_map($hotkeys); } @@ -2753,18 +2743,14 @@ $disallowed_attributes = array('id', 'style', 'class'); - global $pluginhost; - - if (isset($pluginhost)) { - foreach ($pluginhost->get_hooks($pluginhost::HOOK_SANITIZE) as $plugin) { - $retval = $plugin->hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes); - if (is_array($retval)) { - $doc = $retval[0]; - $allowed_elements = $retval[1]; - $disallowed_attributes = $retval[2]; - } else { - $doc = $retval; - } + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SANITIZE) as $plugin) { + $retval = $plugin->hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes); + if (is_array($retval)) { + $doc = $retval[0]; + $allowed_elements = $retval[1]; + $disallowed_attributes = $retval[2]; + } else { + $doc = $retval; } } @@ -3065,9 +3051,7 @@ $line["content"] = sanitize($line["content"], false, $owner_uid, $line["site_url"]); - global $pluginhost; - - foreach ($pluginhost->get_hooks($pluginhost::HOOK_RENDER_ARTICLE) as $p) { + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE) as $p) { $line = $p->hook_render_article($line); } @@ -3142,8 +3126,7 @@ id=\"ATSTRTIP-$id\" connectId=\"ATSTR-$id\" position=\"below\">$tags_str_full"; - global $pluginhost; - foreach ($pluginhost->get_hooks($pluginhost::HOOK_ARTICLE_BUTTON) as $p) { + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) { $rv['content'] .= $p->hook_article_button($line); } @@ -3154,8 +3137,7 @@ $rv['content'] .= ""; $rv['content'] .= "