From d71e70bedf4fa7244f3fcce789e29504c452d5cd Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 12 Jul 2018 16:23:32 -0700 Subject: functions to support module and widget registration by plugins. These have identical construction to core modules and widgets and are registered just like hooks during addon load. Also additional Apps functions addon_app_installed() and system_app_installed() which will eventually replace feature_installed() for features which are converted to apps. The convention being used is that the module associated with the app calls the appropriate *_app_installed() function and if not present emits descriptive text about the app and exits. This allows one to click on an 'available' app and learn about it. Once installed, the app module behaves normally and may offer functionality or what once were addon settings on the settings/featured page. Refer to zap-addons in the zap repository for examples of how this is being used to eliminate the 'additional features' and 'addon settings' pages. --- Zotlabs/Web/Router.php | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'Zotlabs/Web/Router.php') diff --git a/Zotlabs/Web/Router.php b/Zotlabs/Web/Router.php index fb551e36f..c4db0ef3e 100644 --- a/Zotlabs/Web/Router.php +++ b/Zotlabs/Web/Router.php @@ -2,6 +2,7 @@ namespace Zotlabs\Web; +use Zotlabs\Extend\Route; use Exception; /** @@ -52,14 +53,31 @@ class Router { * First see if we have a plugin which is masquerading as a module. */ - if(is_array(\App::$plugins) && in_array($module,\App::$plugins) && file_exists("addon/{$module}/{$module}.php")) { - include_once("addon/{$module}/{$module}.php"); - if(class_exists($modname)) { - $this->controller = new $modname; - \App::$module_loaded = true; + $routes = Route::get(); + if($routes) { + foreach($routes as $route) { + if(is_array($route) && strtolower($route[1]) === $module) { + include_once($route[0]); + if(class_exists($modname)) { + $this->controller = new $modname; + \App::$module_loaded = true; + } + } } - elseif(function_exists($module . '_module')) { - \App::$module_loaded = true; + } + + // legacy plugins - this can be removed when they have all been converted + + if(! (\App::$module_loaded)) { + if(is_array(\App::$plugins) && in_array($module,\App::$plugins) && file_exists("addon/{$module}/{$module}.php")) { + include_once("addon/{$module}/{$module}.php"); + if(class_exists($modname)) { + $this->controller = new $modname; + \App::$module_loaded = true; + } + elseif(function_exists($module . '_module')) { + \App::$module_loaded = true; + } } } -- cgit v1.2.3