Файл: adultscript-2.0.3-pro/files/libraries/framework/component.php
Строк: 65
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent
{
private static $components = array();
public static function load($component, $module, $options=array())
{
if (self::enabled($component, $module)) {
$component_file = MODULES_DIR.'/'.$module.'/components/'.$component.'.php';
$component_class = 'VComponent_'.$module.'_'.$component;
$module_class = 'VModule_'.$module;
try {
if (!class_exists($module_class, FALSE)) {
require MODULES_DIR.'/'.$module.'/'.$module.'.php';
}
require $component_file;
$obj = new $component_class($options);
$obj->render();
return TRUE;
} catch (Exception $e) {
throw new VException($e);
}
}
return FALSE;
}
public static function enabled($component, $module)
{
if (!isset(self::$components[$module])) {
self::__cache_components($module);
}
if (isset(self::$components[$module][$component]) &&
self::$components[$module][$component] === 1) {
return TRUE;
}
return FALSE;
}
private static function __cache_components($module)
{
$cfg = VF::cfg('module.'.$module);
self::$components[$module] = $cfg['components'];
}
}
?>