summaryrefslogtreecommitdiffstats
path: root/inc/module.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2016-05-04 18:27:28 +0200
committerSimon Rettberg2016-05-04 18:27:28 +0200
commit80424b29e00609bf837119fa810b5afdadf2b4e9 (patch)
treee59c49265aeb219c4137bdf21e71262201345b99 /inc/module.inc.php
parentWIP (diff)
downloadslx-admin-80424b29e00609bf837119fa810b5afdadf2b4e9.tar.gz
slx-admin-80424b29e00609bf837119fa810b5afdadf2b4e9.tar.xz
slx-admin-80424b29e00609bf837119fa810b5afdadf2b4e9.zip
Work on translations: templates and messages work
Diffstat (limited to 'inc/module.inc.php')
-rw-r--r--inc/module.inc.php33
1 files changed, 22 insertions, 11 deletions
diff --git a/inc/module.inc.php b/inc/module.inc.php
index 73959471..292c744a 100644
--- a/inc/module.inc.php
+++ b/inc/module.inc.php
@@ -11,11 +11,11 @@ class Module
*/
private static $modules = false;
- public static function get($name)
+ public static function get($name, $ignoreDepFail = false)
{
if (!isset(self::$modules[$name]))
return false;
- if (!self::resolveDeps(self::$modules[$name]))
+ if (!self::resolveDeps(self::$modules[$name]) && !$ignoreDepFail)
return false;
return self::$modules[$name];
}
@@ -38,20 +38,17 @@ class Module
$mod->depsChecked = true;
foreach ($mod->dependencies as $dep) {
if (!self::resolveDepsByName($dep)) {
- if ($mod->enabled) {
- error_log("Disabling module {$mod->name}: Dependency $dep failed.");
- }
- $mod->enabled = false;
+ error_log("Disabling module {$mod->name}: Dependency $dep failed.");
$mod->depsMissing = true;
return false;
}
}
}
- return $mod->enabled;
+ return !$mod->depsMissing;
}
/**
- * @return \Module[] List of enabled modules
+ * @return \Module[] List of valid, enabled modules
*/
public static function getEnabled()
{
@@ -63,6 +60,17 @@ class Module
return $ret;
}
+ /**
+ * @return \Module[] List of all modules, including with missing deps
+ */
+ public static function getAll()
+ {
+ foreach (self::$modules as $module) {
+ self::resolveDeps($module);
+ }
+ return self::$modules;
+ }
+
public static function init()
{
if (self::$modules !== false)
@@ -86,7 +94,6 @@ class Module
* Non-static
*/
- private $enabled = false;
private $category = false;
private $depsMissing = false;
private $depsChecked = false;
@@ -98,7 +105,6 @@ class Module
{
$file = 'modules/' . $name . '/config.json';
$json = @json_decode(@file_get_contents($file), true);
- $this->enabled = isset($json['enabled']) && ($json['enabled'] === true || $json['enabled'] === 'true');
if (isset($json['dependencies']) && is_array($json['dependencies'])) {
$this->dependencies = $json['dependencies'];
}
@@ -108,6 +114,11 @@ class Module
$this->name = $name;
}
+ public function hasMissingDependencies()
+ {
+ return $this->depsMissing;
+ }
+
public function newPage()
{
$modulePath = 'modules/' . $this->name . '/page.inc.php';
@@ -121,7 +132,7 @@ class Module
public function activate()
{
- if ($this->activated || !$this->enabled)
+ if ($this->activated || $this->depsMissing)
return;
$this->activated = true;
spl_autoload_register(function($class) {