/framework/ZoopLibrary.php
http://zoop.googlecode.com/ · PHP · 50 lines · 38 code · 6 blank · 6 comment · 5 complexity · e810684a8c592daa01b002aaff5d1e59 MD5 · raw file
- <?php
- abstract class ZoopLibrary
- {
- private $mods, $path;
-
- /**
- * Stuff about the constructor
- *
- * @return ZoopLibrary
- */
- final function __construct($path)
- {
- $this->path = $path;
- $this->mods = array();
- $this->init();
- }
-
- protected function registerMod($name)
- {
- if(!isset($this->mods[$name]))
- $this->mods[$name] = false;
- }
-
- public function hasMod($name)
- {
- return isset($this->mods[$name]);
- }
-
- public function loadMod($name)
- {
- // if this library doesn't have this module then Zoop will have to figure out which one does
- if(!$this->hasMod($name))
- return Zoop::loadMod($name);
-
- if(isset($this->mods[$name]) && $this->mods[$name])
- return;
- $modName = ucfirst($name) . 'Module';
- include("$this->path/$name/$modName.php");
- $this->mods[$name] = new $modName("$this->path/$name", $this);
- }
-
- public function loadMods()
- {
- foreach($this->mods as $name => $mod)
- {
- if(!$mod)
- $this->loadMod($name);
- }
- }
- }