Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

79 lines (65 sloc) 1.941 kB
<?php
class modules
{
private $modules = array();
public function __construct()
{
$this->load();
}
public function load()
{
$parents = scandir('modules');
array_shift($parents);
array_shift($parents);
foreach ($parents as $parent)
{
$children = scandir('modules/' . $parent);
array_shift($children);
array_shift($children);
foreach ($children as $child)
{
$contents = file_get_contents("modules/{$parent}/{$child}");
$module = eval($contents);
list($childName) = explode('.', $child);
$this->modules[$parent][$childName] = array(
'module' => $module,
'enabled' => true
);
}
}
}
public function unload()
{
$this->modules = array();
}
public function reload()
{
$this->unload();
$this->load();
}
public function disable($command, $module)
{
if (!$this->modules[$command][$module]) return;
$this->modules[$command][$module]['enabled'] = true;
}
public function enable($command, $module)
{
if (!$this->modules[$command][$module]) return;
$this->modules[$command][$module]['enabled'] = true;
}
public function toggle($command, $module)
{
if (!$this->modules[$command][$module]) return;
$val = $this->modules[$command][$module]['enabled'];
$this->modules[$command][$module]['enabled'] = !$val;
}
public function hook($hook, $message)
{
if (!isset($this->modules[$hook])) return;
foreach ($this->modules[$hook] as $module)
{
if (!$module['enabled']) continue;
$module['module']($message);
}
}
}
Jump to Line
Something went wrong with that request. Please try again.