]> git.wh0rd.org - tt-rss.git/commitdiff
pluginhost: allow loading user plugins from plugins.local
authorAndrew Dolgov <noreply@fakecake.org>
Fri, 5 Jun 2015 14:54:52 +0000 (17:54 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Fri, 5 Jun 2015 14:54:52 +0000 (17:54 +0300)
.gitignore
classes/pluginhost.php
include/functions2.php
plugins.local/index.html [new file with mode: 0644]

index e7e5407d072a0c9009fa878ed7935d127bf03591..09fccffa597be4f8dd6048aafc56f4a5b947484c 100644 (file)
@@ -3,6 +3,7 @@
 *.DS_Store
 #*
 .idea/*
+plugins.local/*
 config.php
 feed-icons/*
 cache/*/*
index 4576982912fed6a571e7b875e83b1b97ffecf3b5..13da7e7ab697d508e4808944a341a336029eac64 100644 (file)
@@ -129,7 +129,15 @@ class PluginHost {
                }
        }
        function load_all($kind, $owner_uid = false) {
-               $plugins = array_map("basename", glob("plugins/*"));
+               $plugins = array_map("basename", array_filter(glob("plugins/*"), "is_dir"));
+
+               if (is_dir("plugins.local")) {
+                       $plugins = array_merge($plugins, array_map("basename",
+                               array_filter(glob("plugins.local/*"), "is_dir")));
+               }
+
+               asort($plugins);
+
                $this->load(join(",", $plugins), $kind, $owner_uid);
        }
 
@@ -142,9 +150,15 @@ class PluginHost {
                        $class = trim($class);
                        $class_file = strtolower(basename($class));
 
-                       if (!is_dir(dirname(__FILE__)."/../plugins/$class_file")) continue;
+                       if (!is_dir(__DIR__."/../plugins/$class_file") &&
+                                       !is_dir(__DIR__."/../plugins.local/$class_file")) continue;
+
+                       // try system plugin directory first
+                       $file = __DIR__ . "/../plugins/$class_file/init.php";
 
-                       $file = dirname(__FILE__)."/../plugins/$class_file/init.php";
+                       if (!file_exists($file)) {
+                               $file = __DIR__ . "/../plugins.local/$class_file/init.php";
+                       }
 
                        if (!isset($this->plugins[$class])) {
                                if (file_exists($file)) require_once $file;
index 27b1933d0a0717c38b50b30b53c024c171660dcc..4f8a0523ba37cfddeffb37d98ce45f65cf297ce7 100644 (file)
                        array("code" => $code, "message" => $message)));
 
        }
+
+       function abs_to_rel_path($dir) {
+               $tmp = str_replace(dirname(__DIR__), "", $dir);
+
+               if (strlen($tmp) > 0 && substr($tmp, 0, 1) == "/") $tmp = substr($tmp, 1);
+
+               return $tmp;
+       }
 ?>
diff --git a/plugins.local/index.html b/plugins.local/index.html
new file mode 100644 (file)
index 0000000..e69de29