This commit is contained in:
Abel Hoogeveen 2015-03-17 11:32:28 +01:00
parent 230be3fe60
commit 91740236e7

View File

@ -66,15 +66,33 @@ class Core {
## MODLOADING ## MODLOADING
public function loadMod($name, $version = null) { public function loadMod($name, $version = null) {
$CLASS = $this->loadModule($name); // Get class information
if (!isset($this->mods->{strtolower($CLASS[1])})) { $data = $this->loadModule($name, $version);
return $this->mods->{strtolower($CLASS[1])} = &$CLASS[0];
}
}
public function getMod($name, $version = null) { // If it is an abstract class, create and StdClass
$CLASS = $this->loadModule($name); if (empty($data)) {
return $CLASS[0]; return $this->mods->{strtolower($name)} = new StdClass();
}
// Otherwise load the class
$class_name = $data['className'];
// Create the class object if not created yet
if (!isset($this->mods->{strtolower($data['moduleLinkName'])})) {
$CLASS = new $class_name($this);
if (method_exists($CLASS, 'setModulePath')) {
$CLASS->setModulePath($data['modulePath']);
}
if (method_exists($CLASS, 'setModuleLinkName')) {
$CLASS->setModuleLinkName($data['moduleLinkName']);
}
if (method_exists($CLASS, 'setModuleName')) {
$CLASS->setModuleName($data['moduleName']);
}
$CLASS->onLoad();
return $this->mods->{strtolower($data['moduleLinkName'])} = &$CLASS;
}
} }
private function loadModule($name, $version = null) { private function loadModule($name, $version = null) {
@ -82,7 +100,6 @@ class Core {
if (!isset($this->mods->config->modregister->register)) { if (!isset($this->mods->config->modregister->register)) {
$this->buildModRegister(); $this->buildModRegister();
} else { } else {
$this->register = $this->mods->config->modregister->register; $this->register = $this->mods->config->modregister->register;
} }
@ -156,23 +173,14 @@ class Core {
if (isset($cfg->abstract)) { if (isset($cfg->abstract)) {
if ($cfg->abstract) { if ($cfg->abstract) {
$c = new stdClass(); $c = new stdClass();
return array($c, $cfg->module_name); return array();
} }
} }
// Otherwise create the class object return array('className' => $class_name,
$CLASS = new $class_name($this); 'modulePath' => $cfg->directory,
if (method_exists($CLASS, 'setModulePath')) { 'moduleLinkName' => $cfg->module_name,
$CLASS->setModulePath($cfg->directory); 'moduleName' => $name);
}
if (method_exists($CLASS, 'setModuleLinkName')) {
$CLASS->setModuleLinkName($cfg->module_name);
}
if (method_exists($CLASS, 'setModuleName')) {
$CLASS->setModuleName($name);
}
$CLASS->onLoad();
return array($CLASS, $cfg->module_name);
} }
public function buildModRegister() { public function buildModRegister() {