summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2012-12-23 16:15:34 +0400
committerAndrew Dolgov <[email protected]>2012-12-23 16:15:34 +0400
commit6065f3ad6364943e4d6b160db8a2c78ff52e2373 (patch)
treed70921595927cfa9030df409aee15362954f1c54
parent5a0e03923f47bc1140fd71b4899cd1e35fd59006 (diff)
add support for plugins in prefs
-rw-r--r--classes/pluginhost.php8
-rw-r--r--classes/pref/feeds.php4
-rw-r--r--classes/pref/filters.php5
-rw-r--r--classes/pref/instances.php5
-rw-r--r--classes/pref/labels.php5
-rw-r--r--classes/pref/prefs.php4
-rw-r--r--classes/pref/users.php5
-rw-r--r--prefs.php24
8 files changed, 57 insertions, 3 deletions
diff --git a/classes/pluginhost.php b/classes/pluginhost.php
index f4e01178b..d7926fa4e 100644
--- a/classes/pluginhost.php
+++ b/classes/pluginhost.php
@@ -6,6 +6,8 @@ class PluginHost {
const HOOK_ARTICLE_BUTTON = 1;
const HOOK_ARTICLE_FILTER = 2;
+ const HOOK_PREFS_TAB = 3;
+ const HOOK_PREFS_SECTION = 4;
function __construct($link) {
$this->link = $link;
@@ -28,6 +30,12 @@ class PluginHost {
return $this->plugins[$name];
}
+ function run_hooks($type, $method, $args) {
+ foreach ($this->get_hooks($type) as $hook) {
+ $hook->$method($args);
+ }
+ }
+
function add_hook($type, $sender) {
if (!is_array($this->hooks[$type])) {
$this->hooks[$type] = array();
diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php
index c51174b07..1f6d63f2c 100644
--- a/classes/pref/feeds.php
+++ b/classes/pref/feeds.php
@@ -1530,6 +1530,10 @@ class Pref_Feeds extends Handler_Protected {
print "</div>"; #pane
+ global $pluginhost;
+ $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB,
+ "hook_prefs_tab", "prefFeeds");
+
print "</div>"; #container
}
diff --git a/classes/pref/filters.php b/classes/pref/filters.php
index 2eed4dee9..572d29f8b 100644
--- a/classes/pref/filters.php
+++ b/classes/pref/filters.php
@@ -625,6 +625,11 @@ class Pref_Filters extends Handler_Protected {
</div>";
print "</div>"; #pane
+
+ global $pluginhost;
+ $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB,
+ "hook_prefs_tab", "prefFilters");
+
print "</div>"; #container
}
diff --git a/classes/pref/instances.php b/classes/pref/instances.php
index 0ce390805..763bb49fa 100644
--- a/classes/pref/instances.php
+++ b/classes/pref/instances.php
@@ -211,6 +211,11 @@ class Pref_Instances extends Handler_Protected {
print "</table>";
print "</div>"; #pane
+
+ global $pluginhost;
+ $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB,
+ "hook_prefs_tab", "prefInstances");
+
print "</div>"; #container
}
diff --git a/classes/pref/labels.php b/classes/pref/labels.php
index a7f79146a..e63a0cfc2 100644
--- a/classes/pref/labels.php
+++ b/classes/pref/labels.php
@@ -318,6 +318,11 @@ class Pref_Labels extends Handler_Protected {
</div>";
print "</div>"; #pane
+
+ global $pluginhost;
+ $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB,
+ "hook_prefs_tab", "prefLabels");
+
print "</div>"; #container
}
diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php
index e9f420774..013d589ca 100644
--- a/classes/pref/prefs.php
+++ b/classes/pref/prefs.php
@@ -650,6 +650,10 @@ class Pref_Prefs extends Handler_Protected {
print "</div>"; #pane
}
+ global $pluginhost;
+ $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB,
+ "hook_prefs_tab", "prefPrefs");
+
print "</div>"; #container
}
diff --git a/classes/pref/users.php b/classes/pref/users.php
index a39dce786..40264660d 100644
--- a/classes/pref/users.php
+++ b/classes/pref/users.php
@@ -487,6 +487,11 @@ class Pref_Users extends Handler_Protected {
}
print "</div>"; #pane
+
+ global $pluginhost;
+ $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB,
+ "hook_prefs_tab", "prefUsers");
+
print "</div>"; #container
}
diff --git a/prefs.php b/prefs.php
index d83e2ddf3..74bcd4cc1 100644
--- a/prefs.php
+++ b/prefs.php
@@ -44,9 +44,27 @@
<script type="text/javascript" charset="utf-8" src="localized_js.php?<?php echo $dt_add ?>"></script>
- <script type="text/javascript" charset="utf-8" src="js/functions.js?<?php echo $dt_add ?>"></script>
- <script type="text/javascript" charset="utf-8" src="js/deprecated.js?<?php echo $dt_add ?>"></script>
- <script type="text/javascript" charset="utf-8" src="js/prefs.js?<?php echo $dt_add ?>"></script>
+ <script type="text/javascript">
+ <?php
+ require 'lib/jsmin.php';
+
+ global $pluginhost;
+
+ foreach ($pluginhost->get_plugins() as $n => $p) {
+ if (method_exists($p, "get_prefs_js")) {
+ echo JSMin::minify($p->get_prefs_js());
+ }
+ }
+
+ foreach (array("functions", "deprecated", "prefs") as $js) {
+ if (!isset($_GET['debug'])) {
+ echo JSMin::minify(file_get_contents("js/$js.js"));
+ } else {
+ echo file_get_contents("js/$js.js");
+ }
+ }
+ ?>
+ </script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>