<?php
/* Core module for loading user created extensions / modules */
class pimg_mod
{
/* Resources */
private $pimg;
// PIMG constructor
function __construct($pimg)
{
$this -> pimg = $pimg;
}
/*
User module loader helper
@return: pimg_mod instance
*/
public function init()
{
return $this;
}
/* LOADING MODULES */
public function __call($mod, $args)
{
// Check if the module exists
$mod = basename($mod);
$modFile = dirname(__FILE__) . '/mods/' . $mod . '.pimg.php';
$mod = 'pimg_mod_' . $mod;
if (file_exists($modFile))
{
// Load the module and return an instance
require_once($modFile);
if (!class_exists($mod))
exit('PIMG user module <b>' . $mod . '</b> does not exist or cannot be loaded!');
else {
$mod = new $mod($this -> pimg);
return call_user_func_array(array($mod, 'init'), $args);
}
} else
exit('PIMG user module <b>' . $mod . '</b> does not exist or cannot be loaded!');
}
}
?>
|