scanModules(MODULES_PATH); } /** * Read configs from all directories * on path specified * * @param string $folderPath * @access public */ function processFolder($folderPath) { $fh=opendir($folderPath); while(($sub_folder=readdir($fh))) { $full_path=$folderPath.'/'.$sub_folder; if( $this->isDir($full_path) && file_exists($this->getConfigName($full_path)) ) { include_once $this->getConfigName($full_path); $prefix=$config['Prefix']; $config['BasePath']=$full_path; $this->configData[$prefix] = $config; $this->parseConfig($prefix); } } } function scanModules($folderPath) { $fh=opendir($folderPath); while(($sub_folder=readdir($fh))) { $full_path=$folderPath.'/'.$sub_folder; if( $this->isDir($full_path) ) { $this->processFolder($full_path); } } } /** * Register nessasary classes * * @param string $prefix * @access private */ function parseConfig($prefix) { $config =& $this->configData[$prefix]; $event_manager =& $this->Application->recallObject('EventManager'); $class_params=Array('ItemClass','ListClass','EventHandlerClass','TagProcessorClass'); foreach($class_params as $param_name) { $class_info =& $config[$param_name]; $pseudo_class = $this->getPrefixByParamName($param_name,$prefix); $this->Application->registerClass( $class_info['class'], $config['BasePath'].'/'.$class_info['file'], $pseudo_class); $event_manager->registerBuildEvent($pseudo_class,$class_info['build_event']); } } /** * Reads unit (specified by $prefix) * option specified by $option * * @param string $prefix * @param string $option * @return string * @access public */ function getUnitOption($prefix,$name) { return $this->configData[$prefix][$name]; } /** * Set's new unit option value * * @param string $prefix * @param string $name * @param string $value * @access public */ function setUnitOption($prefix,$name,$value) { $this->configData[$prefix][$name]=$value; } function getPrefixByParamName($paramName,$prefix) { $pseudo_class_map=Array( 'ItemClass'=>'%s', 'ListClass'=>'%s_List', 'EventHandlerClass'=>'%s_EventHandler', 'TagProcessorClass'=>'%s_TagProcessor' ); return sprintf($pseudo_class_map[$paramName],$prefix); } /** * Get's config file name based * on folder name supplied * * @param string $folderPath * @return string * @access private */ function getConfigName($folderPath) { return $folderPath.'/'.basename($folderPath).'_config.php'; } /** * is_dir ajustment to work with * directory listings too * * @param string $folderPath * @return bool * @access private */ function isDir($folderPath) { $base_name=basename($folderPath); $ret=!($base_name=='.'||$base_name=='..'); return $ret&&is_dir($folderPath); } } ?>