]> git.wh0rd.org Git - tt-rss.git/commitdiff
add support for plugins in prefs
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sun, 23 Dec 2012 12:15:34 +0000 (16:15 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sun, 23 Dec 2012 12:15:34 +0000 (16:15 +0400)
classes/pluginhost.php
classes/pref/feeds.php
classes/pref/filters.php
classes/pref/instances.php
classes/pref/labels.php
classes/pref/prefs.php
classes/pref/users.php
prefs.php

index f4e01178b5ebce2f04b4eedc95a68eca0e2fe520..d7926fa4e0bf62f5b3cd1224016fedaeed91bc18 100644 (file)
@@ -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();
index c51174b07647d5d392f0200c48c5df147397bfdb..1f6d63f2c2626b8cba5e045edc8a13a8ec70d05e 100644 (file)
@@ -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
 
        }
index 2eed4dee92bd5bd9f642ce7b8c998ccf1446f1e4..572d29f8b0c9b28e5507818405eff5632d4a2e35 100644 (file)
@@ -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
 
        }
index 0ce390805a15089cef0d043f61a9d31f49877734..763bb49fafbaf7a7d58c128fa8273d291f06c363 100644 (file)
@@ -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
 
        }
index a7f79146a79611c8dd6d1812253e581baf0dc176..e63a0cfc2f401e036a9c2115cd2915725719a074 100644 (file)
@@ -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
 
        }
index e9f420774b9fad2e57d469dd9c503a53566074e2..013d589ca814208077b59015e09879e1bada0754 100644 (file)
@@ -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
        }
 
index a39dce7860502fe5782193f8052757f4d952a34b..40264660d670166e78cd9426c7720a2c6c8099d7 100644 (file)
@@ -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
 
                }
index d83e2ddf3491b9248e139c900e5f85a4afce01eb..74bcd4cc17d58a6168249a35b6df0c38c1c15cb1 100644 (file)
--- a/prefs.php
+++ b/prefs.php
 
        <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"/>