summaryrefslogtreecommitdiffstats
path: root/code/modules.inc.php
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2006-04-11 20:05:04 +0200
committerneoraider <devnull@localhost>2006-04-11 20:05:04 +0200
commit2fe04a4707412ff2f4f8df5f5524bb1b2dcbb3d7 (patch)
tree6947238ea3e304acec01f24dff358d67e86cc1e2 /code/modules.inc.php
parente267e31bd045ff4a6bfa1489b0ad0eb5fcc7b31d (diff)
downloadneon-2fe04a4707412ff2f4f8df5f5524bb1b2dcbb3d7.tar
neon-2fe04a4707412ff2f4f8df5f5524bb1b2dcbb3d7.zip
XML-Parser und Modulverwaltung implementiert.
Diffstat (limited to 'code/modules.inc.php')
-rw-r--r--code/modules.inc.php71
1 files changed, 71 insertions, 0 deletions
diff --git a/code/modules.inc.php b/code/modules.inc.php
index a1bf361..1e84d45 100644
--- a/code/modules.inc.php
+++ b/code/modules.inc.php
@@ -1,5 +1,76 @@
<?PHP
+ require_once('code/xmlparser.inc.php');
+
+ function require_mod($file) {
+ if(isset($GLOBALS['modules']->code[$file]))
+ require_once($GLOBALS['modules']->code[$file]);
+ elseif(isset($GLOBALS['modules']->handlers[$file]))
+ require_once($GLOBALS['modules']->handlers[$file]);
+ else
+ require_once($file);
+ }
+
class Modules {
+ var $modules;
+ var $code;
+ var $handlers;
+ function Modules() {
+ $this->modules = array();
+ $this->code = array();
+ $this->handlers = array();
+
+ $dir = opendir('modules');
+
+ while($moddir = readdir($dir)) {
+ if($moddir[0] != '.' && is_dir('modules/' . $moddir)) {
+ $data = $GLOBALS['xmlparser']->ParseFile('modules/' . $moddir . '/module.xml');
+
+ if(!$data) continue;
+
+ $info = $GLOBALS['xmlparser']->FindTag($data, 'info');
+ if(!is_array($info)) continue;
+
+ $name = $GLOBALS['xmlparser']->FindTag($info, 'name');
+ if(!is_array($name)) continue;
+ if(count($name['children']) != 1) continue;
+ if(!is_string($name['children'][0])) continue;
+
+ $name = $name['children'][0];
+
+ $this->module[$name] = array('name' => $name, 'code' => array(),
+ 'handlers' => array());
+
+ $files = $GLOBALS['xmlparser']->FindTag($data, 'files');
+ if(!is_array($files)) continue;
+
+ foreach($files['children'] as $file) {
+ if(!is_array($file)) continue;
+ if(count($file['children']) != 1) continue;
+ if(!is_string($file['children'][0])) continue;
+
+ switch($file['tag']) {
+ case 'code':
+ $filename = 'code/' . $file['children'][0] . '.inc.php';
+ $realname = 'modules/' . $moddir . '/code/' . $file['children'][0] . '.inc.php';
+
+ $this->code[$filename] = $realname;
+ $this->modules[$name]['code'][$filename] = $realname;
+ break;
+ case 'handler':
+ $filename = 'handlers/' . $file['children'][0] . '.inc.php';
+ $realname = 'modules/' . $moddir . '/handlers/' . $file['children'][0] . '.inc.php';
+
+ $this->handlers[$filename] = $realname;
+ $this->modules[$name]['handlers'][$filename] = $realname;
+ }
+ }
+ }
+ }
+
+ closedir($dir);
+ }
}
+
+ $GLOBALS['modules'] = new Modules;
?>