X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=classes%2Fpluginhost.php;h=f40705dd10694a2cd53b43a1e475747ab0cfe84f;hb=57932e183745bada9c6183056597cb5276f68d10;hp=f07e2bbf4593e41e05bcf1e292b7e25d9c87b36e;hpb=df5d2a06657be3abb671c44295848afefc7f8fd4;p=tt-rss.git diff --git a/classes/pluginhost.php b/classes/pluginhost.php old mode 100644 new mode 100755 index f07e2bbf..f40705dd --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -56,6 +56,8 @@ class PluginHost { const HOOK_FORMAT_ARTICLE_CDM = 35; const HOOK_FEED_BASIC_INFO = 36; const HOOK_SEND_LOCAL_FILE = 37; + const HOOK_UNSUBSCRIBE_FEED = 38; + const HOOK_SEND_MAIL = 39; const KIND_ALL = 1; const KIND_SYSTEM = 2; @@ -95,7 +97,7 @@ class PluginHost { function get_pdo() { return $this->pdo; } - + function get_plugin_names() { $names = array(); @@ -169,15 +171,37 @@ class PluginHost { // try system plugin directory first $file = __DIR__ . "/../plugins/$class_file/init.php"; + $vendor_dir = __DIR__ . "/../plugins/$class_file/vendor"; if (!file_exists($file)) { $file = __DIR__ . "/../plugins.local/$class_file/init.php"; + $vendor_dir = __DIR__ . "/../plugins.local/$class_file/vendor"; } if (!isset($this->plugins[$class])) { if (file_exists($file)) require_once $file; if (class_exists($class) && is_subclass_of($class, "Plugin")) { + + // register plugin autoloader if necessary, for namespaced classes ONLY + // layout corresponds to tt-rss main /vendor/author/Package/Class.php + + if (file_exists($vendor_dir)) { + spl_autoload_register(function($class) use ($vendor_dir) { + + if (strpos($class, '\\') !== FALSE) { + list ($namespace, $class_name) = explode('\\', $class, 2); + + if ($namespace && $class_name) { + $class_file = "$vendor_dir/$namespace/" . str_replace('\\', '/', $class_name) . ".php"; + + if (file_exists($class_file)) + require_once $class_file; + } + } + }); + } + $plugin = new $class($this); $plugin_api = $plugin->api_version(); @@ -279,8 +303,6 @@ class PluginHost { } else { return false; } - - return false; } function get_commands() { @@ -361,7 +383,9 @@ class PluginHost { function get_all($sender) { $idx = get_class($sender); - return $this->storage[$idx]; + $data = $this->storage[$idx]; + + return $data ? $data : []; } function clear_data($sender) {