make pluginhost a singleton
This commit is contained in:
parent
52d88392da
commit
1ffe3391f9
19 changed files with 89 additions and 148 deletions
|
@ -113,8 +113,7 @@
|
||||||
|
|
||||||
$op = str_replace("-", "_", $op);
|
$op = str_replace("-", "_", $op);
|
||||||
|
|
||||||
global $pluginhost;
|
$override = PluginHost::getInstance()->lookup_handler($op, $method);
|
||||||
$override = $pluginhost->lookup_handler($op, $method);
|
|
||||||
|
|
||||||
if (class_exists($op) || $override) {
|
if (class_exists($op) || $override) {
|
||||||
|
|
||||||
|
|
|
@ -341,8 +341,7 @@ class API extends Handler {
|
||||||
"score" => (int)$line["score"]
|
"score" => (int)$line["score"]
|
||||||
);
|
);
|
||||||
|
|
||||||
global $pluginhost;
|
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) {
|
||||||
foreach ($pluginhost->get_hooks($pluginhost::HOOK_RENDER_ARTICLE_API) as $p) {
|
|
||||||
$article = $p->hook_render_article_api(array("article" => $article));
|
$article = $p->hook_render_article_api(array("article" => $article));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,9 +465,7 @@ class API extends Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
function index($method) {
|
function index($method) {
|
||||||
global $pluginhost;
|
$plugin = PluginHost::getInstance()->get_api_method(strtolower($method));
|
||||||
|
|
||||||
$plugin = $pluginhost->get_api_method(strtolower($method));
|
|
||||||
|
|
||||||
if ($plugin && method_exists($plugin, $method)) {
|
if ($plugin && method_exists($plugin, $method)) {
|
||||||
$reply = $plugin->$method();
|
$reply = $plugin->$method();
|
||||||
|
@ -697,8 +694,7 @@ class API extends Handler {
|
||||||
$headline_row["author"] = $line["author"];
|
$headline_row["author"] = $line["author"];
|
||||||
$headline_row["score"] = (int)$line["score"];
|
$headline_row["score"] = (int)$line["score"];
|
||||||
|
|
||||||
global $pluginhost;
|
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) {
|
||||||
foreach ($pluginhost->get_hooks($pluginhost::HOOK_RENDER_ARTICLE_API) as $p) {
|
|
||||||
$headline_row = $p->hook_render_article_api(array("headline" => $headline_row));
|
$headline_row = $p->hook_render_article_api(array("headline" => $headline_row));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,14 +108,12 @@ class Feeds extends Handler_Protected {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
global $pluginhost;
|
if (PluginHost::getInstance()->get_plugin("mail")) {
|
||||||
|
|
||||||
if ($pluginhost->get_plugin("mail")) {
|
|
||||||
$reply .= "<option value=\"emailArticle(false)\">".__('Forward by email').
|
$reply .= "<option value=\"emailArticle(false)\">".__('Forward by email').
|
||||||
"</option>";
|
"</option>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($pluginhost->get_plugin("mailto")) {
|
if (PluginHost::getInstance()->get_plugin("mailto")) {
|
||||||
$reply .= "<option value=\"mailtoArticle(false)\">".__('Forward by email').
|
$reply .= "<option value=\"mailtoArticle(false)\">".__('Forward by email').
|
||||||
"</option>";
|
"</option>";
|
||||||
}
|
}
|
||||||
|
@ -132,7 +130,7 @@ class Feeds extends Handler_Protected {
|
||||||
|
|
||||||
//$reply .= "</h2";
|
//$reply .= "</h2";
|
||||||
|
|
||||||
foreach ($pluginhost->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);
|
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);
|
// error_log("search_mode: " . $search_mode);
|
||||||
|
|
||||||
if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) {
|
if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) {
|
||||||
global $pluginhost;
|
$handler = PluginHost::getInstance()->get_feed_handler(
|
||||||
|
|
||||||
$handler = $pluginhost->get_feed_handler(
|
|
||||||
PluginHost::feed_to_pfeed_id($feed));
|
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) {
|
// 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) {
|
if ($this->dbh->num_rows($result) > 0) {
|
||||||
|
|
||||||
$lnum = $offset;
|
$lnum = $offset;
|
||||||
|
@ -521,7 +515,7 @@ class Feeds extends Handler_Protected {
|
||||||
$line["content"] = sanitize($line["content_preview"],
|
$line["content"] = sanitize($line["content_preview"],
|
||||||
sql_bool_to_bool($line['hide_images']), false, $entry_site_url);
|
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);
|
$line = $p->hook_render_article_cdm($line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -679,7 +673,7 @@ class Feeds extends Handler_Protected {
|
||||||
|
|
||||||
$reply['content'] .= "<div class=\"cdmFooter\">";
|
$reply['content'] .= "<div class=\"cdmFooter\">";
|
||||||
|
|
||||||
foreach ($pluginhost->get_hooks($pluginhost::HOOK_ARTICLE_LEFT_BUTTON) as $p) {
|
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) {
|
||||||
$reply['content'] .= $p->hook_article_left_button($line);
|
$reply['content'] .= $p->hook_article_left_button($line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -713,7 +707,7 @@ class Feeds extends Handler_Protected {
|
||||||
// $reply['content'] .= "$marked_pic";
|
// $reply['content'] .= "$marked_pic";
|
||||||
// $reply['content'] .= "$published_pic";
|
// $reply['content'] .= "$published_pic";
|
||||||
|
|
||||||
foreach ($pluginhost->get_hooks($pluginhost::HOOK_ARTICLE_BUTTON) as $p) {
|
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) {
|
||||||
$reply['content'] .= $p->hook_article_button($line);
|
$reply['content'] .= $p->hook_article_button($line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -377,8 +377,7 @@ class Handler_Public extends Handler {
|
||||||
|
|
||||||
cleanup_tags(14, 50000);
|
cleanup_tags(14, 50000);
|
||||||
|
|
||||||
global $pluginhost;
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op);
|
||||||
$pluginhost->run_hooks($pluginhost::HOOK_UPDATE_TASK, "hook_update_task", $op);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,7 @@ class PluginHandler extends Handler_Protected {
|
||||||
}
|
}
|
||||||
|
|
||||||
function catchall($method) {
|
function catchall($method) {
|
||||||
global $pluginhost;
|
$plugin = PluginHost::getInstance()->get_plugin($_REQUEST["plugin"]);
|
||||||
|
|
||||||
$plugin = $pluginhost->get_plugin($_REQUEST["plugin"]);
|
|
||||||
|
|
||||||
if ($plugin) {
|
if ($plugin) {
|
||||||
if (method_exists($plugin, $method)) {
|
if (method_exists($plugin, $method)) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ class PluginHost {
|
||||||
private $api_methods = array();
|
private $api_methods = array();
|
||||||
private $owner_uid;
|
private $owner_uid;
|
||||||
private $debug;
|
private $debug;
|
||||||
|
private static $instance;
|
||||||
|
|
||||||
const HOOK_ARTICLE_BUTTON = 1;
|
const HOOK_ARTICLE_BUTTON = 1;
|
||||||
const HOOK_ARTICLE_FILTER = 2;
|
const HOOK_ARTICLE_FILTER = 2;
|
||||||
|
@ -35,13 +36,24 @@ class PluginHost {
|
||||||
const KIND_SYSTEM = 2;
|
const KIND_SYSTEM = 2;
|
||||||
const KIND_USER = 3;
|
const KIND_USER = 3;
|
||||||
|
|
||||||
function __construct($dbh) {
|
function __construct($ignored = false) {
|
||||||
$this->dbh = $dbh;
|
$this->dbh = Db::get();
|
||||||
$this->storage = $_SESSION["plugin_storage"];
|
$this->storage = $_SESSION["plugin_storage"];
|
||||||
|
|
||||||
if (!$this->storage) $this->storage = array();
|
if (!$this->storage) $this->storage = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function __clone() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getInstance() {
|
||||||
|
if (self::$instance == null)
|
||||||
|
self::$instance = new self();
|
||||||
|
|
||||||
|
return self::$instance;
|
||||||
|
}
|
||||||
|
|
||||||
private function register_plugin($name, $plugin) {
|
private function register_plugin($name, $plugin) {
|
||||||
//array_push($this->plugins, $plugin);
|
//array_push($this->plugins, $plugin);
|
||||||
$this->plugins[$name] = $plugin;
|
$this->plugins[$name] = $plugin;
|
||||||
|
|
|
@ -124,9 +124,7 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
|
|
||||||
/* Plugin feeds for -1 */
|
/* Plugin feeds for -1 */
|
||||||
|
|
||||||
global $pluginhost;
|
$feeds = PluginHost::getInstance()->get_feeds(-1);
|
||||||
|
|
||||||
$feeds = $pluginhost->get_feeds(-1);
|
|
||||||
|
|
||||||
if ($feeds) {
|
if ($feeds) {
|
||||||
foreach ($feeds as $feed) {
|
foreach ($feeds as $feed) {
|
||||||
|
@ -1456,8 +1454,7 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('".__("Public OPML URL")."','pubOPMLUrl')\">".
|
print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('".__("Public OPML URL")."','pubOPMLUrl')\">".
|
||||||
__('Display published OPML URL')."</button> ";
|
__('Display published OPML URL')."</button> ";
|
||||||
|
|
||||||
global $pluginhost;
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
|
||||||
$pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION,
|
|
||||||
"hook_prefs_tab_section", "prefFeedsOPML");
|
"hook_prefs_tab_section", "prefFeedsOPML");
|
||||||
|
|
||||||
print "</div>"; # pane
|
print "</div>"; # pane
|
||||||
|
@ -1503,15 +1500,12 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearArticleAccessKeys()\">".
|
print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearArticleAccessKeys()\">".
|
||||||
__('Unshare all articles')."</button> ";
|
__('Unshare all articles')."</button> ";
|
||||||
|
|
||||||
global $pluginhost;
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
|
||||||
$pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION,
|
|
||||||
"hook_prefs_tab_section", "prefFeedsPublishedGenerated");
|
"hook_prefs_tab_section", "prefFeedsPublishedGenerated");
|
||||||
|
|
||||||
print "</div>"; #pane
|
print "</div>"; #pane
|
||||||
|
|
||||||
global $pluginhost;
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
|
||||||
|
|
||||||
$pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB,
|
|
||||||
"hook_prefs_tab", "prefFeeds");
|
"hook_prefs_tab", "prefFeeds");
|
||||||
|
|
||||||
print "</div>"; #container
|
print "</div>"; #container
|
||||||
|
|
|
@ -706,8 +706,7 @@ class Pref_Filters extends Handler_Protected {
|
||||||
|
|
||||||
print "</div>"; #pane
|
print "</div>"; #pane
|
||||||
|
|
||||||
global $pluginhost;
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
|
||||||
$pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB,
|
|
||||||
"hook_prefs_tab", "prefFilters");
|
"hook_prefs_tab", "prefFilters");
|
||||||
|
|
||||||
print "</div>"; #container
|
print "</div>"; #container
|
||||||
|
|
|
@ -319,8 +319,7 @@ class Pref_Labels extends Handler_Protected {
|
||||||
|
|
||||||
print "</div>"; #pane
|
print "</div>"; #pane
|
||||||
|
|
||||||
global $pluginhost;
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
|
||||||
$pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB,
|
|
||||||
"hook_prefs_tab", "prefLabels");
|
"hook_prefs_tab", "prefLabels");
|
||||||
|
|
||||||
print "</div>"; #container
|
print "</div>"; #container
|
||||||
|
|
|
@ -79,8 +79,7 @@ class Pref_Prefs extends Handler_Protected {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
global $pluginhost;
|
$authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]);
|
||||||
$authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]);
|
|
||||||
|
|
||||||
if (method_exists($authenticator, "change_password")) {
|
if (method_exists($authenticator, "change_password")) {
|
||||||
print $authenticator->change_password($_SESSION["uid"], $old_pw, $new_pw);
|
print $authenticator->change_password($_SESSION["uid"], $old_pw, $new_pw);
|
||||||
|
@ -255,10 +254,7 @@ class Pref_Prefs extends Handler_Protected {
|
||||||
print "</form>";
|
print "</form>";
|
||||||
|
|
||||||
if ($_SESSION["auth_module"]) {
|
if ($_SESSION["auth_module"]) {
|
||||||
global $pluginhost;
|
$authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]);
|
||||||
|
|
||||||
$authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$authenticator = false;
|
$authenticator = false;
|
||||||
}
|
}
|
||||||
|
@ -436,8 +432,7 @@ class Pref_Prefs extends Handler_Protected {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
global $pluginhost;
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
|
||||||
$pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION,
|
|
||||||
"hook_prefs_tab_section", "prefPrefsAuth");
|
"hook_prefs_tab_section", "prefPrefsAuth");
|
||||||
|
|
||||||
print "</div>"; #pane
|
print "</div>"; #pane
|
||||||
|
@ -675,8 +670,7 @@ class Pref_Prefs extends Handler_Protected {
|
||||||
|
|
||||||
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"boolean_prefs\" value=\"$listed_boolean_prefs\">";
|
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"boolean_prefs\" value=\"$listed_boolean_prefs\">";
|
||||||
|
|
||||||
global $pluginhost;
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
|
||||||
$pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION,
|
|
||||||
"hook_prefs_tab_section", "prefPrefsPrefsInside");
|
"hook_prefs_tab_section", "prefPrefsPrefsInside");
|
||||||
|
|
||||||
print '</div>'; # inside pane
|
print '</div>'; # inside pane
|
||||||
|
@ -712,8 +706,7 @@ class Pref_Prefs extends Handler_Protected {
|
||||||
<label for='prefs_show_advanced'>" .
|
<label for='prefs_show_advanced'>" .
|
||||||
__("Show additional preferences") . "</label>"; */
|
__("Show additional preferences") . "</label>"; */
|
||||||
|
|
||||||
global $pluginhost;
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
|
||||||
$pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION,
|
|
||||||
"hook_prefs_tab_section", "prefPrefsPrefsOutside");
|
"hook_prefs_tab_section", "prefPrefsPrefsOutside");
|
||||||
|
|
||||||
print "</form>";
|
print "</form>";
|
||||||
|
@ -877,8 +870,7 @@ class Pref_Prefs extends Handler_Protected {
|
||||||
|
|
||||||
print "</div>"; #pane
|
print "</div>"; #pane
|
||||||
|
|
||||||
global $pluginhost;
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
|
||||||
$pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB,
|
|
||||||
"hook_prefs_tab", "prefPrefs");
|
"hook_prefs_tab", "prefPrefs");
|
||||||
|
|
||||||
print "</div>"; #container
|
print "</div>"; #container
|
||||||
|
@ -918,8 +910,7 @@ class Pref_Prefs extends Handler_Protected {
|
||||||
$password = $_REQUEST["password"];
|
$password = $_REQUEST["password"];
|
||||||
$otp = $_REQUEST["otp"];
|
$otp = $_REQUEST["otp"];
|
||||||
|
|
||||||
global $pluginhost;
|
$authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]);
|
||||||
$authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]);
|
|
||||||
|
|
||||||
if ($authenticator->check_password($_SESSION["uid"], $password)) {
|
if ($authenticator->check_password($_SESSION["uid"], $password)) {
|
||||||
|
|
||||||
|
@ -951,8 +942,7 @@ class Pref_Prefs extends Handler_Protected {
|
||||||
function otpdisable() {
|
function otpdisable() {
|
||||||
$password = $this->dbh->escape_string($_REQUEST["password"]);
|
$password = $this->dbh->escape_string($_REQUEST["password"]);
|
||||||
|
|
||||||
global $pluginhost;
|
$authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]);
|
||||||
$authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]);
|
|
||||||
|
|
||||||
if ($authenticator->check_password($_SESSION["uid"], $password)) {
|
if ($authenticator->check_password($_SESSION["uid"], $password)) {
|
||||||
|
|
||||||
|
@ -978,8 +968,7 @@ class Pref_Prefs extends Handler_Protected {
|
||||||
function clearplugindata() {
|
function clearplugindata() {
|
||||||
$name = $this->dbh->escape_string($_REQUEST["name"]);
|
$name = $this->dbh->escape_string($_REQUEST["name"]);
|
||||||
|
|
||||||
global $pluginhost;
|
PluginHost::getInstance()->clear_data(PluginHost::getInstance()->get_plugin($name));
|
||||||
$pluginhost->clear_data($pluginhost->get_plugin($name));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function customizeCSS() {
|
function customizeCSS() {
|
||||||
|
|
|
@ -66,8 +66,7 @@ class Pref_System extends Handler_Protected {
|
||||||
|
|
||||||
print "</div>";
|
print "</div>";
|
||||||
|
|
||||||
global $pluginhost;
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
|
||||||
$pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB,
|
|
||||||
"hook_prefs_tab", "prefSystem");
|
"hook_prefs_tab", "prefSystem");
|
||||||
|
|
||||||
print "</div>"; #container
|
print "</div>"; #container
|
||||||
|
|
|
@ -453,8 +453,7 @@ class Pref_Users extends Handler_Protected {
|
||||||
|
|
||||||
print "</div>"; #pane
|
print "</div>"; #pane
|
||||||
|
|
||||||
global $pluginhost;
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
|
||||||
$pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB,
|
|
||||||
"hook_prefs_tab", "prefUsers");
|
"hook_prefs_tab", "prefUsers");
|
||||||
|
|
||||||
print "</div>"; #container
|
print "</div>"; #container
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
$fetch_last_error_code = false;
|
$fetch_last_error_code = false;
|
||||||
$fetch_last_content_type = false;
|
$fetch_last_content_type = false;
|
||||||
$fetch_curl_used = false;
|
$fetch_curl_used = false;
|
||||||
$pluginhost = false;
|
|
||||||
|
|
||||||
mb_internal_encoding("UTF-8");
|
mb_internal_encoding("UTF-8");
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
|
@ -622,8 +621,7 @@
|
||||||
if (!SINGLE_USER_MODE) {
|
if (!SINGLE_USER_MODE) {
|
||||||
$user_id = false;
|
$user_id = false;
|
||||||
|
|
||||||
global $pluginhost;
|
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_AUTH_USER) as $plugin) {
|
||||||
foreach ($pluginhost->get_hooks($pluginhost::HOOK_AUTH_USER) as $plugin) {
|
|
||||||
|
|
||||||
$user_id = (int) $plugin->authenticate($login, $password);
|
$user_id = (int) $plugin->authenticate($login, $password);
|
||||||
|
|
||||||
|
@ -734,11 +732,10 @@
|
||||||
if ($owner_uid) {
|
if ($owner_uid) {
|
||||||
$plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
|
$plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
|
||||||
|
|
||||||
global $pluginhost;
|
PluginHost::getInstance()->load($plugins, PluginHost::KIND_USER, $owner_uid);
|
||||||
$pluginhost->load($plugins, $pluginhost::KIND_USER, $owner_uid);
|
|
||||||
|
|
||||||
if (get_schema_version() > 100) {
|
if (get_schema_version() > 100) {
|
||||||
$pluginhost->load_data();
|
PluginHost::getInstance()->load_data();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1443,18 +1440,13 @@
|
||||||
array_push($ret_arr, $cv);
|
array_push($ret_arr, $cv);
|
||||||
}
|
}
|
||||||
|
|
||||||
global $pluginhost;
|
$feeds = PluginHost::getInstance()->get_feeds(-1);
|
||||||
|
|
||||||
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']));
|
|
||||||
|
|
||||||
|
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);
|
array_push($ret_arr, $cv);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1982,8 +1974,7 @@
|
||||||
"help_dialog" => __("Show help dialog"))
|
"help_dialog" => __("Show help dialog"))
|
||||||
);
|
);
|
||||||
|
|
||||||
global $pluginhost;
|
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HOTKEY_INFO) as $plugin) {
|
||||||
foreach ($pluginhost->get_hooks($pluginhost::HOOK_HOTKEY_INFO) as $plugin) {
|
|
||||||
$hotkeys = $plugin->hook_hotkey_info($hotkeys);
|
$hotkeys = $plugin->hook_hotkey_info($hotkeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2059,8 +2050,7 @@
|
||||||
$hotkeys["^(40)|Ctrl-down"] = "next_article_noscroll";
|
$hotkeys["^(40)|Ctrl-down"] = "next_article_noscroll";
|
||||||
}
|
}
|
||||||
|
|
||||||
global $pluginhost;
|
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HOTKEY_MAP) as $plugin) {
|
||||||
foreach ($pluginhost->get_hooks($pluginhost::HOOK_HOTKEY_MAP) as $plugin) {
|
|
||||||
$hotkeys = $plugin->hook_hotkey_map($hotkeys);
|
$hotkeys = $plugin->hook_hotkey_map($hotkeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2753,18 +2743,14 @@
|
||||||
|
|
||||||
$disallowed_attributes = array('id', 'style', 'class');
|
$disallowed_attributes = array('id', 'style', 'class');
|
||||||
|
|
||||||
global $pluginhost;
|
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SANITIZE) as $plugin) {
|
||||||
|
$retval = $plugin->hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes);
|
||||||
if (isset($pluginhost)) {
|
if (is_array($retval)) {
|
||||||
foreach ($pluginhost->get_hooks($pluginhost::HOOK_SANITIZE) as $plugin) {
|
$doc = $retval[0];
|
||||||
$retval = $plugin->hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes);
|
$allowed_elements = $retval[1];
|
||||||
if (is_array($retval)) {
|
$disallowed_attributes = $retval[2];
|
||||||
$doc = $retval[0];
|
} else {
|
||||||
$allowed_elements = $retval[1];
|
$doc = $retval;
|
||||||
$disallowed_attributes = $retval[2];
|
|
||||||
} else {
|
|
||||||
$doc = $retval;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3065,9 +3051,7 @@
|
||||||
|
|
||||||
$line["content"] = sanitize($line["content"], false, $owner_uid, $line["site_url"]);
|
$line["content"] = sanitize($line["content"], false, $owner_uid, $line["site_url"]);
|
||||||
|
|
||||||
global $pluginhost;
|
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE) as $p) {
|
||||||
|
|
||||||
foreach ($pluginhost->get_hooks($pluginhost::HOOK_RENDER_ARTICLE) as $p) {
|
|
||||||
$line = $p->hook_render_article($line);
|
$line = $p->hook_render_article($line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3142,8 +3126,7 @@
|
||||||
id=\"ATSTRTIP-$id\" connectId=\"ATSTR-$id\"
|
id=\"ATSTRTIP-$id\" connectId=\"ATSTR-$id\"
|
||||||
position=\"below\">$tags_str_full</div>";
|
position=\"below\">$tags_str_full</div>";
|
||||||
|
|
||||||
global $pluginhost;
|
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) {
|
||||||
foreach ($pluginhost->get_hooks($pluginhost::HOOK_ARTICLE_BUTTON) as $p) {
|
|
||||||
$rv['content'] .= $p->hook_article_button($line);
|
$rv['content'] .= $p->hook_article_button($line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3154,8 +3137,7 @@
|
||||||
$rv['content'] .= "</div>";
|
$rv['content'] .= "</div>";
|
||||||
$rv['content'] .= "<div clear='both'>";
|
$rv['content'] .= "<div clear='both'>";
|
||||||
|
|
||||||
global $pluginhost;
|
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) {
|
||||||
foreach ($pluginhost->get_hooks($pluginhost::HOOK_ARTICLE_LEFT_BUTTON) as $p) {
|
|
||||||
$rv['content'] .= $p->hook_article_left_button($line);
|
$rv['content'] .= $p->hook_article_left_button($line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3361,10 +3343,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function init_plugins() {
|
function init_plugins() {
|
||||||
global $pluginhost;
|
PluginHost::getInstance()->load(PLUGINS, PluginHost::KIND_ALL);
|
||||||
|
|
||||||
$pluginhost = new PluginHost(Db::get());
|
|
||||||
$pluginhost->load(PLUGINS, $pluginhost::KIND_ALL);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -343,15 +343,15 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$pluginhost = new PluginHost(Db::get());
|
$pluginhost = new PluginHost();
|
||||||
$pluginhost->set_debug($debug_enabled);
|
$pluginhost->set_debug($debug_enabled);
|
||||||
$user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
|
$user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
|
||||||
|
|
||||||
$pluginhost->load(PLUGINS, $pluginhost::KIND_ALL);
|
$pluginhost->load(PLUGINS, PluginHost::KIND_ALL);
|
||||||
$pluginhost->load($user_plugins, $pluginhost::KIND_USER, $owner_uid);
|
$pluginhost->load($user_plugins, PluginHost::KIND_USER, $owner_uid);
|
||||||
$pluginhost->load_data();
|
$pluginhost->load_data();
|
||||||
|
|
||||||
foreach ($pluginhost->get_hooks($pluginhost::HOOK_FEED_FETCHED) as $plugin) {
|
foreach ($pluginhost->get_hooks(PluginHost::HOOK_FEED_FETCHED) as $plugin) {
|
||||||
$feed_data = $plugin->hook_feed_fetched($feed_data);
|
$feed_data = $plugin->hook_feed_fetched($feed_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// We use local pluginhost here because we need to load different per-user feed plugins
|
// We use local pluginhost here because we need to load different per-user feed plugins
|
||||||
$pluginhost->run_hooks($pluginhost::HOOK_FEED_PARSED, "hook_feed_parsed", $rss);
|
$pluginhost->run_hooks(PluginHost::HOOK_FEED_PARSED, "hook_feed_parsed", $rss);
|
||||||
|
|
||||||
if ($debug_enabled) {
|
if ($debug_enabled) {
|
||||||
_debug("update_rss_feed: processing feed data...");
|
_debug("update_rss_feed: processing feed data...");
|
||||||
|
@ -673,7 +673,7 @@
|
||||||
"author" => $entry_author,
|
"author" => $entry_author,
|
||||||
"stored" => $stored_article);
|
"stored" => $stored_article);
|
||||||
|
|
||||||
foreach ($pluginhost->get_hooks($pluginhost::HOOK_ARTICLE_FILTER) as $plugin) {
|
foreach ($pluginhost->get_hooks(PluginHost::HOOK_ARTICLE_FILTER) as $plugin) {
|
||||||
$article = $plugin->hook_article_filter($article);
|
$article = $plugin->hook_article_filter($article);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
25
index.php
25
index.php
|
@ -32,16 +32,14 @@
|
||||||
|
|
||||||
if (!init_plugins()) return;
|
if (!init_plugins()) return;
|
||||||
|
|
||||||
global $pluginhost;
|
|
||||||
|
|
||||||
if (!$_REQUEST['mobile']) {
|
if (!$_REQUEST['mobile']) {
|
||||||
if ($mobile->isTablet() && $pluginhost->get_plugin("digest")) {
|
if ($mobile->isTablet() && PluginHost::getInstance()->get_plugin("digest")) {
|
||||||
header('Location: backend.php?op=digest');
|
header('Location: backend.php?op=digest');
|
||||||
exit;
|
exit;
|
||||||
} else if ($mobile->isMobile() && $pluginhost->get_plugin("mobile")) {
|
} else if ($mobile->isMobile() && PluginHost::getInstance()->get_plugin("mobile")) {
|
||||||
header('Location: backend.php?op=mobile');
|
header('Location: backend.php?op=mobile');
|
||||||
exit;
|
exit;
|
||||||
} else if ($mobile->isMobile() && $pluginhost->get_plugin("digest")) {
|
} else if ($mobile->isMobile() && PluginHost::getInstance()->get_plugin("digest")) {
|
||||||
header('Location: backend.php?op=digest');
|
header('Location: backend.php?op=digest');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +72,7 @@
|
||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
<?php
|
<?php
|
||||||
foreach ($pluginhost->get_plugins() as $n => $p) {
|
foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
|
||||||
if (method_exists($p, "get_css")) {
|
if (method_exists($p, "get_css")) {
|
||||||
echo $p->get_css();
|
echo $p->get_css();
|
||||||
}
|
}
|
||||||
|
@ -104,9 +102,7 @@
|
||||||
print get_minified_js(array("tt-rss",
|
print get_minified_js(array("tt-rss",
|
||||||
"functions", "feedlist", "viewfeed", "FeedTree"));
|
"functions", "feedlist", "viewfeed", "FeedTree"));
|
||||||
|
|
||||||
global $pluginhost;
|
foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
|
||||||
|
|
||||||
foreach ($pluginhost->get_plugins() as $n => $p) {
|
|
||||||
if (method_exists($p, "get_js")) {
|
if (method_exists($p, "get_js")) {
|
||||||
echo JShrink\Minifier::minify($p->get_js());
|
echo JShrink\Minifier::minify($p->get_js());
|
||||||
}
|
}
|
||||||
|
@ -205,8 +201,7 @@
|
||||||
<div class="actionChooser">
|
<div class="actionChooser">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
global $pluginhost;
|
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_TOOLBAR_BUTTON) as $p) {
|
||||||
foreach ($pluginhost->get_hooks($pluginhost::HOOK_TOOLBAR_BUTTON) as $p) {
|
|
||||||
echo $p->hook_toolbar_button();
|
echo $p->hook_toolbar_button();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -238,18 +233,14 @@
|
||||||
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcCatchupAll')"><?php echo __('Mark as read') ?></div>
|
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcCatchupAll')"><?php echo __('Mark as read') ?></div>
|
||||||
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcShowOnlyUnread')"><?php echo __('(Un)hide read feeds') ?></div>
|
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcShowOnlyUnread')"><?php echo __('(Un)hide read feeds') ?></div>
|
||||||
<div dojoType="dijit.MenuItem" disabled="1"><?php echo __('Other actions:') ?></div>
|
<div dojoType="dijit.MenuItem" disabled="1"><?php echo __('Other actions:') ?></div>
|
||||||
<!-- <?php if ($pluginhost->get_plugin("digest")) { ?>
|
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcToggleWidescreen')"><?php echo __('Toggle widescreen mode') ?></div>
|
||||||
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcDigest')"><?php echo __('Switch to digest...') ?></div>
|
|
||||||
<?php } ?> -->
|
|
||||||
<!-- <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcTagCloud')"><?php echo __('Show tag cloud...') ?></div> -->
|
|
||||||
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcToggleWidescreen')"><?php echo __('Toggle widescreen mode') ?></div>
|
|
||||||
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcTagSelect')"><?php echo __('Select by tags...') ?></div>
|
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcTagSelect')"><?php echo __('Select by tags...') ?></div>
|
||||||
<!-- <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddLabel')"><?php echo __('Create label...') ?></div>
|
<!-- <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddLabel')"><?php echo __('Create label...') ?></div>
|
||||||
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddFilter')"><?php echo __('Create filter...') ?></div> -->
|
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddFilter')"><?php echo __('Create filter...') ?></div> -->
|
||||||
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcHKhelp')"><?php echo __('Keyboard shortcuts help') ?></div>
|
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcHKhelp')"><?php echo __('Keyboard shortcuts help') ?></div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
foreach ($pluginhost->get_hooks($pluginhost::HOOK_ACTION_ITEM) as $p) {
|
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ACTION_ITEM) as $p) {
|
||||||
echo $p->hook_action_item();
|
echo $p->hook_action_item();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -351,8 +351,7 @@ class Instances extends Plugin implements IHandler {
|
||||||
|
|
||||||
print "</div>"; #pane
|
print "</div>"; #pane
|
||||||
|
|
||||||
global $pluginhost;
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
|
||||||
$pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB,
|
|
||||||
"hook_prefs_tab", "prefInstances");
|
"hook_prefs_tab", "prefInstances");
|
||||||
|
|
||||||
print "</div>"; #container
|
print "</div>"; #container
|
||||||
|
|
|
@ -66,9 +66,7 @@
|
||||||
<?php
|
<?php
|
||||||
require 'lib/jshrink/Minifier.php';
|
require 'lib/jshrink/Minifier.php';
|
||||||
|
|
||||||
global $pluginhost;
|
foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
|
||||||
|
|
||||||
foreach ($pluginhost->get_plugins() as $n => $p) {
|
|
||||||
if (method_exists($p, "get_prefs_js")) {
|
if (method_exists($p, "get_prefs_js")) {
|
||||||
echo JShrink\Minifier::minify($p->get_prefs_js());
|
echo JShrink\Minifier::minify($p->get_prefs_js());
|
||||||
}
|
}
|
||||||
|
@ -134,7 +132,7 @@
|
||||||
title="<?php echo __('System') ?>"></div>
|
title="<?php echo __('System') ?>"></div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php
|
<?php
|
||||||
$pluginhost->run_hooks($pluginhost::HOOK_PREFS_TABS,
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TABS,
|
||||||
"hook_prefs_tabs", false);
|
"hook_prefs_tabs", false);
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -37,8 +37,7 @@
|
||||||
|
|
||||||
$method = $_REQUEST["op"];
|
$method = $_REQUEST["op"];
|
||||||
|
|
||||||
global $pluginhost;
|
$override = PluginHost::getInstance()->lookup_handler("public", $method);
|
||||||
$override = $pluginhost->lookup_handler("public", $method);
|
|
||||||
|
|
||||||
if ($override) {
|
if ($override) {
|
||||||
$handler = $override;
|
$handler = $override;
|
||||||
|
|
12
update.php
12
update.php
|
@ -36,7 +36,7 @@
|
||||||
"list-plugins",
|
"list-plugins",
|
||||||
"help");
|
"help");
|
||||||
|
|
||||||
foreach ($pluginhost->get_commands() as $command => $data) {
|
foreach (PluginHost::getInstance()->get_commands() as $command => $data) {
|
||||||
array_push($longopts, $command . $data["suffix"]);
|
array_push($longopts, $command . $data["suffix"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
print " --help - show this help\n";
|
print " --help - show this help\n";
|
||||||
print "Plugin options:\n";
|
print "Plugin options:\n";
|
||||||
|
|
||||||
foreach ($pluginhost->get_commands() as $command => $data) {
|
foreach (PluginHost::getInstance()->get_commands() as $command => $data) {
|
||||||
$args = $data['arghelp'];
|
$args = $data['arghelp'];
|
||||||
printf(" --%-19s - %s\n", "$command $args", $data["description"]);
|
printf(" --%-19s - %s\n", "$command $args", $data["description"]);
|
||||||
}
|
}
|
||||||
|
@ -161,8 +161,7 @@
|
||||||
$rc = cleanup_tags( 14, 50000);
|
$rc = cleanup_tags( 14, 50000);
|
||||||
_debug("Cleaned $rc cached tags.");
|
_debug("Cleaned $rc cached tags.");
|
||||||
|
|
||||||
global $pluginhost;
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op);
|
||||||
$pluginhost->run_hooks($pluginhost::HOOK_UPDATE_TASK, "hook_update_task", $op);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options["feedbrowser"])) {
|
if (isset($options["feedbrowser"])) {
|
||||||
|
@ -200,8 +199,7 @@
|
||||||
|
|
||||||
_debug("Cleaned $rc cached tags.");
|
_debug("Cleaned $rc cached tags.");
|
||||||
|
|
||||||
global $pluginhost;
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op);
|
||||||
$pluginhost->run_hooks($pluginhost::HOOK_UPDATE_TASK, "hook_update_task", $op);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -368,7 +366,7 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$pluginhost->run_commands($options);
|
PluginHost::getInstance()->run_commands($options);
|
||||||
|
|
||||||
if ($lock_handle != false) {
|
if ($lock_handle != false) {
|
||||||
fclose($lock_handle);
|
fclose($lock_handle);
|
||||||
|
|
Loading…
Reference in a new issue