Index: trunk/core/kernel/utility/formatters/formatters_config.php
===================================================================
diff -u -N -r4762 -r4765
--- trunk/core/kernel/utility/formatters/formatters_config.php (.../formatters_config.php) (revision 4762)
+++ trunk/core/kernel/utility/formatters/formatters_config.php (.../formatters_config.php) (revision 4765)
@@ -2,6 +2,9 @@
$config = Array(
'Prefix' => 'formatters',
+
+ 'EventHandlerClass' => Array('class' => 'kEventHandler', 'file' => '', 'build_event' => 'OnBuild'),
+
'RegisterClasses' => Array(
Array('pseudo'=>'kFormatter','class'=>'kFormatter','file'=>'formatter.php','build_event'=>'','require_classes'=>''),
Array('pseudo'=>'kOptionsFormatter','class'=>'kOptionsFormatter','file'=>'options_formatter.php','build_event'=>'','require_classes'=>'kFormatter'),
Index: trunk/core/kernel/utility/unit_config_reader.php
===================================================================
diff -u -N -r4762 -r4765
--- trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 4762)
+++ trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 4765)
@@ -1,489 +1,489 @@
Application->ModuleInfo) return false;
+ function configAllowed($config_path)
+ {
+ $module_found = false;
+ if (!$this->Application->ModuleInfo) return false;
- foreach($this->Application->ModuleInfo as $module_name => $module_info)
- {
- $module_path = '/'.$module_info['Path'];
- if (preg_match('/^'.preg_quote($module_path, '/').'/', $config_path)) {
-// if (substr($config_path, 0, strlen($module_path)) == $module_path) {
- // config file path starts with module folder path
- $module_found = true;
- break;
- }
+ foreach($this->Application->ModuleInfo as $module_name => $module_info)
+ {
+ $module_path = '/'.$module_info['Path'];
+ if (preg_match('/^'.preg_quote($module_path, '/').'/', $config_path)) {
+ // if (substr($config_path, 0, strlen($module_path)) == $module_path) {
+ // config file path starts with module folder path
+ $module_found = true;
+ break;
}
- return $module_found;
}
+ return $module_found;
+ }
- /**
+ /**
* Returns true if config exists and is allowed for reading
*
* @param string $prefix
* @return bool
*/
- function prefixRegistred($prefix)
- {
- return isset($this->configData[$prefix]) ? true : false;
- }
+ function prefixRegistred($prefix)
+ {
+ return isset($this->configData[$prefix]) ? true : false;
+ }
- /**
+ /**
* Read configs from all directories
* on path specified
*
* @param string $folderPath
* @access public
*/
- function processFolder($folderPath, $cached)
- {
- $fh = opendir($folderPath);
- while (($sub_folder = readdir($fh))) {
- $full_path = $folderPath.'/'.$sub_folder;
- if( $this->isDir($full_path) && file_exists($this->getConfigName($full_path)) )
- {
- if (filemtime($full_path) > $cached) {
- $this->CacheExpired = true;
+ function processFolder($folderPath, $cached)
+ {
+ $fh = opendir($folderPath);
+ while (($sub_folder = readdir($fh))) {
+ $full_path = $folderPath.'/'.$sub_folder;
+ if( $this->isDir($full_path) && file_exists($this->getConfigName($full_path)) )
+ {
+ if (filemtime($full_path) > $cached) {
+ $this->CacheExpired = true;
- $file = $this->getConfigName($full_path);
- if ( $this->Application->isDebugMode() && constOn('DBG_PROFILE_INCLUDES') )
- {
+ $file = $this->getConfigName($full_path);
+ if ( $this->Application->isDebugMode() && constOn('DBG_PROFILE_INCLUDES') )
+ {
- if ( in_array($file, get_required_files()) ) return;
- global $debugger;
- /*$debugger->IncludeLevel++;
- $before_time = getmicrotime();
- $before_mem = memory_get_usage();*/
- k4_include_once(FULL_PATH.$file);
- /*$used_time = getmicrotime() - $before_time;
- $used_mem = memory_get_usage() - $before_mem;
- $debugger->IncludeLevel--;
- $debugger->IncludesData['file'][] = str_replace(FULL_PATH, '', $file);
- $debugger->IncludesData['mem'][] = $used_mem;
- $debugger->IncludesData['time'][] = $used_time;
- $debugger->IncludesData['level'][] = -1;*/
- }
- else {
- include_once($file);
- }
-
- if ( !isset($config) || !$config ) continue;
- $prefix = $config['Prefix'];
- $config['BasePath'] = $full_path;
- $this->configData[$prefix] = $config;
+ if ( in_array($file, get_required_files()) ) return;
+ global $debugger;
+ /*$debugger->IncludeLevel++;
+ $before_time = getmicrotime();
+ $before_mem = memory_get_usage();*/
+ k4_include_once(FULL_PATH.$file);
+ /*$used_time = getmicrotime() - $before_time;
+ $used_mem = memory_get_usage() - $before_mem;
+ $debugger->IncludeLevel--;
+ $debugger->IncludesData['file'][] = str_replace(FULL_PATH, '', $file);
+ $debugger->IncludesData['mem'][] = $used_mem;
+ $debugger->IncludesData['time'][] = $used_time;
+ $debugger->IncludesData['level'][] = -1;*/
}
+ else {
+ include_once($file);
+ }
+
+ if ( !isset($config) || !$config ) continue;
+ $prefix = $config['Prefix'];
+ $config['BasePath'] = $full_path;
+ $this->configData[$prefix] = $config;
}
}
}
+ }
- function postProcessConfig($prefix, $config_key, $dst_prefix_var)
- {
- $main_config =& $this->configData[$prefix];
- $sub_configs = getArrayValue($main_config, $config_key);
- if (!$sub_configs) {
- return false;
+ function postProcessConfig($prefix, $config_key, $dst_prefix_var)
+ {
+ $main_config =& $this->configData[$prefix];
+ $sub_configs = getArrayValue($main_config, $config_key);
+ if (!$sub_configs) {
+ return false;
+ }
+ unset($main_config[$config_key]);
+
+ foreach ($sub_configs as $sub_prefix => $sub_config) {
+ if ($config_key == 'AggregateConfigs' && !isset($this->configData[$sub_prefix])) {
+ $this->loadConfig($sub_prefix);
}
- unset($main_config[$config_key]);
+ $sub_config['Prefix'] = $sub_prefix;
+ $this->configData[$sub_prefix] = array_merge_recursive2($this->configData[$$dst_prefix_var], $sub_config);
- foreach ($sub_configs as $sub_prefix => $sub_config) {
- if ($config_key == 'AggregateConfigs' && !isset($this->configData[$sub_prefix])) {
- $this->loadConfig($sub_prefix);
+ // when merging empty array to non-empty results non-empty array, but empty is required
+ foreach ($sub_config as $sub_key => $sub_value) {
+ if (!$sub_value) {
+ unset($this->configData[$sub_prefix][$sub_key]);
}
- $sub_config['Prefix'] = $sub_prefix;
- $this->configData[$sub_prefix] = array_merge_recursive2($this->configData[$$dst_prefix_var], $sub_config);
-
- // when merging empty array to non-empty results non-empty array, but empty is required
- foreach ($sub_config as $sub_key => $sub_value) {
- if (!$sub_value) {
- unset($this->configData[$sub_prefix][$sub_key]);
- }
- }
- if ($config_key == 'Clones') {
- $this->prefixFiles[$sub_prefix] = $this->prefixFiles[$prefix];
- }
-
- $this->postProcessConfig($sub_prefix, $config_key, $dst_prefix_var);
- if ($config_key == 'AggregateConfigs') {
- $this->postProcessConfig($sub_prefix, 'Clones', 'prefix');
- }
}
+ if ($config_key == 'Clones') {
+ $this->prefixFiles[$sub_prefix] = $this->prefixFiles[$prefix];
+ }
- if (!$prefix) {
- // configs, that used only for cloning & not used ifself
- unset($this->configData[$prefix]);
+ $this->postProcessConfig($sub_prefix, $config_key, $dst_prefix_var);
+ if ($config_key == 'AggregateConfigs') {
+ $this->postProcessConfig($sub_prefix, 'Clones', 'prefix');
}
}
- function ParseConfigs()
- {
- foreach ($this->configData as $prefix => $config) {
- $this->parseConfig($prefix);
- $this->Application->HandleEvent( new kEvent($prefix.':OnAfterConfigRead') );
- }
+ if (!$prefix) {
+ // configs, that used only for cloning & not used ifself
+ unset($this->configData[$prefix]);
}
+ }
- function CacheParsedData()
- {
- $event_manager =& $this->Application->recallObject('EventManager');
- $aggregator =& $this->Application->recallObject('TagsAggregator', 'kArray');
+ function ParseConfigs()
+ {
+ $this->parseConfig('formatters'); // !TEMPORARY!, until config dependecy is created
+ foreach ($this->configData as $prefix => $config) {
+ $this->parseConfig($prefix);
+ $this->Application->HandleEvent( new kEvent($prefix.':OnAfterConfigRead') );
+ }
+ }
- $config_vars = Array(
- 'SessionTimeout',
- 'SessionCookieName',
- 'SessionReferrerCheck',
- 'CookieSessions',
- 'UseCronForRegularEvent',
- 'User_GuestGroup',
- 'User_LoggedInGroup',
- 'SessionTimeout',
- 'UseModRewrite',
- 'AdminDirectory',
- );
+ function CacheParsedData()
+ {
+ $event_manager =& $this->Application->recallObject('EventManager');
+ $aggregator =& $this->Application->recallObject('TagsAggregator', 'kArray');
- foreach ($config_vars as $var) {
- $this->Application->ConfigValue($var);
- }
+ $config_vars = Array(
+ 'SessionTimeout',
+ 'SessionCookieName',
+ 'SessionReferrerCheck',
+ 'CookieSessions',
+ 'UseCronForRegularEvent',
+ 'User_GuestGroup',
+ 'User_LoggedInGroup',
+ 'SessionTimeout',
+ 'UseModRewrite',
+ 'AdminDirectory',
+ );
- $cache = Array(
- 'Factory.Files' => $this->Application->Factory->Files,
- 'Factory.realClasses' => $this->Application->Factory->realClasses,
- 'Factory.Dependencies' => $this->Application->Factory->Dependencies,
- 'ConfigReader.prefixFiles' => $this->prefixFiles,
- 'EventManager.buildEvents' => $event_manager->buildEvents,
- 'EventManager.beforeRegularEvents' => $event_manager->beforeRegularEvents,
- 'EventManager.afterRegularEvents' => $event_manager->afterRegularEvents,
- 'EventManager.beforeHooks' => $event_manager->beforeHooks,
- 'EventManager.afterHooks' => $event_manager->afterHooks,
- 'TagsAggregator.data' => $aggregator->_Array,
+ foreach ($config_vars as $var) {
+ $this->Application->ConfigValue($var);
+ }
- // the following caches should be reset based on admin interaction (adjusting config, enabling modules etc)
- 'Application.Caches.ConfigVariables' => $this->Application->Caches['ConfigVariables'],
- 'Application.ConfigCacheIds' => $this->Application->ConfigCacheIds,
- 'Application.ConfigHash' => $this->Application->ConfigHash,
- 'Application.ModuleInfo' => $this->Application->ModuleInfo,
- );
+ $cache = Array(
+ 'Factory.Files' => $this->Application->Factory->Files,
+ 'Factory.realClasses' => $this->Application->Factory->realClasses,
+ 'Factory.Dependencies' => $this->Application->Factory->Dependencies,
+ 'ConfigReader.prefixFiles' => $this->prefixFiles,
+ 'EventManager.buildEvents' => $event_manager->buildEvents,
+ 'EventManager.beforeRegularEvents' => $event_manager->beforeRegularEvents,
+ 'EventManager.afterRegularEvents' => $event_manager->afterRegularEvents,
+ 'EventManager.beforeHooks' => $event_manager->beforeHooks,
+ 'EventManager.afterHooks' => $event_manager->afterHooks,
+ 'TagsAggregator.data' => $aggregator->_Array,
- $conn =& $this->Application->GetADODBConnection();
- $conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("configs_parsed", '.$conn->qstr(serialize($cache)).', '.adodb_mktime().')');
- }
+ // the following caches should be reset based on admin interaction (adjusting config, enabling modules etc)
+ 'Application.Caches.ConfigVariables' => $this->Application->Caches['ConfigVariables'],
+ 'Application.ConfigCacheIds' => $this->Application->ConfigCacheIds,
+ 'Application.ConfigHash' => $this->Application->ConfigHash,
+ 'Application.ModuleInfo' => $this->Application->ModuleInfo,
+ );
- function ResetParsedData($include_sections=false)
- {
- $conn =& $this->Application->GetADODBConnection();
- $conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName = "configs_parsed"');
+ $conn =& $this->Application->GetADODBConnection();
+ $conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("configs_parsed", '.$conn->qstr(serialize($cache)).', '.adodb_mktime().')');
+ }
- if ($include_sections) {
- $conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName = "sections_parsed"');
- }
+ function ResetParsedData($include_sections=false)
+ {
+ $conn =& $this->Application->GetADODBConnection();
+ $conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName = "configs_parsed"');
+
+ if ($include_sections) {
+ $conn->Query('DELETE FROM '.TABLE_PREFIX.'Cache WHERE VarName = "sections_parsed"');
}
+ }
- function RestoreParsedData()
- {
- $conn =& $this->Application->GetADODBConnection();
- $data = $conn->GetRow('SELECT Data, Cached FROM '.TABLE_PREFIX.'Cache WHERE VarName = "configs_parsed"');
- if ($data && $data['Cached'] > 0 ) {
- $cache = unserialize($data['Data']);
- $this->Application->Factory->Files = $cache['Factory.Files'];
- $this->Application->Factory->realClasses = $cache['Factory.realClasses'];
- $this->Application->Factory->Dependencies = $cache['Factory.Dependencies'];
- $this->prefixFiles = $cache['ConfigReader.prefixFiles'];
+ function RestoreParsedData()
+ {
+ $conn =& $this->Application->GetADODBConnection();
+ $data = $conn->GetRow('SELECT Data, Cached FROM '.TABLE_PREFIX.'Cache WHERE VarName = "configs_parsed"');
+ if ($data && $data['Cached'] > 0 ) {
+ $cache = unserialize($data['Data']);
+ $this->Application->Factory->Files = $cache['Factory.Files'];
+ $this->Application->Factory->realClasses = $cache['Factory.realClasses'];
+ $this->Application->Factory->Dependencies = $cache['Factory.Dependencies'];
+ $this->prefixFiles = $cache['ConfigReader.prefixFiles'];
- $event_manager =& $this->Application->recallObject('EventManager');
- $event_manager->buildEvents = $cache['EventManager.buildEvents'];
- $event_manager->beforeRegularEvents = $cache['EventManager.beforeRegularEvents'];
- $event_manager->afterRegularEvents = $cache['EventManager.afterRegularEvents'];
- $event_manager->beforeHooks = $cache['EventManager.beforeHooks'];
- $event_manager->afterHooks = $cache['EventManager.afterHooks'];
+ $event_manager =& $this->Application->recallObject('EventManager');
+ $event_manager->buildEvents = $cache['EventManager.buildEvents'];
+ $event_manager->beforeRegularEvents = $cache['EventManager.beforeRegularEvents'];
+ $event_manager->afterRegularEvents = $cache['EventManager.afterRegularEvents'];
+ $event_manager->beforeHooks = $cache['EventManager.beforeHooks'];
+ $event_manager->afterHooks = $cache['EventManager.afterHooks'];
- $aggregator =& $this->Application->recallObject('TagsAggregator', 'kArray');
- $aggregator->_Array = $cache['TagsAggregator.data'];
+ $aggregator =& $this->Application->recallObject('TagsAggregator', 'kArray');
+ $aggregator->_Array = $cache['TagsAggregator.data'];
- $this->Application->ConfigHash = $cache['Application.ConfigHash'];
+ $this->Application->ConfigHash = $cache['Application.ConfigHash'];
- $this->Application->Caches['ConfigVariables'] = $cache['Application.ConfigCacheIds'];
- $this->Application->ConfigCacheIds = $cache['Application.ConfigCacheIds'];
+ $this->Application->Caches['ConfigVariables'] = $cache['Application.ConfigCacheIds'];
+ $this->Application->ConfigCacheIds = $cache['Application.ConfigCacheIds'];
- $this->Application->ModuleInfo = $cache['Application.ModuleInfo'];
+ $this->Application->ModuleInfo = $cache['Application.ModuleInfo'];
- return true;
+ return true;
- }
- else return false;
}
+ else return false;
+ }
- function findConfigFiles($folderPath)
- {
- // if FULL_PATH = "/" ensure, that all "/" in $folderPath are not deleted
- $reg_exp = '/^'.preg_quote(FULL_PATH, '/').'/';
- $folderPath = preg_replace($reg_exp, '', $folderPath, 1); // this make sense, since $folderPath may NOT contain FULL_PATH
+ function findConfigFiles($folderPath)
+ {
+ // if FULL_PATH = "/" ensure, that all "/" in $folderPath are not deleted
+ $reg_exp = '/^'.preg_quote(FULL_PATH, '/').'/';
+ $folderPath = preg_replace($reg_exp, '', $folderPath, 1); // this make sense, since $folderPath may NOT contain FULL_PATH
- $fh=opendir(FULL_PATH.$folderPath);
- while(($sub_folder=readdir($fh)))
+ $fh=opendir(FULL_PATH.$folderPath);
+ while(($sub_folder=readdir($fh)))
+ {
+ $full_path = FULL_PATH.$folderPath.'/'.$sub_folder;
+ if( $this->isDir($full_path))
{
- $full_path = FULL_PATH.$folderPath.'/'.$sub_folder;
- if( $this->isDir($full_path))
- {
- if ( file_exists(FULL_PATH.$this->getConfigName($folderPath.'/'.$sub_folder)) ) {
- $this->configFiles[] = $this->getConfigName($folderPath.'/'.$sub_folder);
- }
- $this->findConfigFiles($full_path);
+ if ( file_exists(FULL_PATH.$this->getConfigName($folderPath.'/'.$sub_folder)) ) {
+ $this->configFiles[] = $this->getConfigName($folderPath.'/'.$sub_folder);
+ }
+ $this->findConfigFiles($full_path);
-// if (filemtime($full_path) > $cached) { }
+ // if (filemtime($full_path) > $cached) { }
- }
}
}
+ }
- function includeConfigFiles()
- {
- $this->Application->refreshModuleInfo();
- if (defined('CACHE_CONFIGS_FILES')) {
- $conn =& $this->Application->GetADODBConnection();
- $data = $conn->GetRow('SELECT Data, Cached FROM '.TABLE_PREFIX.'Cache WHERE VarName = "config_files"');
- if ($data && $data['Cached'] > 0 ) {
- $this->configFiles = unserialize($data['Data']);
- $files_cached = $data['Cached'];
- }
- else {
- $this->findConfigFiles($folderPath);
- }
+ function includeConfigFiles()
+ {
+ $this->Application->refreshModuleInfo();
+ if (defined('CACHE_CONFIGS_FILES')) {
+ $conn =& $this->Application->GetADODBConnection();
+ $data = $conn->GetRow('SELECT Data, Cached FROM '.TABLE_PREFIX.'Cache WHERE VarName = "config_files"');
+ if ($data && $data['Cached'] > 0 ) {
+ $this->configFiles = unserialize($data['Data']);
+ $files_cached = $data['Cached'];
}
else {
- $this->findConfigFiles($folderPath);
+ $this->findConfigFiles(''); // search from base directory
}
-
-
- foreach ($this->configFiles as $filename)
- {
- $this->loadConfigFile($filename);
- }
}
+ else {
+ $this->findConfigFiles(''); // search from base directory
+ }
- function scanModules($folderPath)
+ foreach ($this->configFiles as $filename)
{
- if (defined('CACHE_PARSED_CONFIGS') && CACHE_PARSED_CONFIGS) {
- $restored = $this->RestoreParsedData();
- if ($restored) return;
- }
- $this->includeConfigFiles();
- $this->ParseConfigs();
+ $this->loadConfigFile($filename);
+ }
+ }
- if (defined('CACHE_PARSED_CONFIGS')) {
- $this->CacheParsedData();
- }
+ function scanModules($folderPath)
+ {
+ if (defined('CACHE_PARSED_CONFIGS') && CACHE_PARSED_CONFIGS) {
+ $restored = $this->RestoreParsedData();
+ if ($restored) return;
+ }
+ $this->includeConfigFiles();
+ $this->ParseConfigs();
- if (defined('CACHE_CONFIGS_FILES') && $files_cached == 0) {
- $conn =& $this->Application->GetADODBConnection();
- $conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("config_files", '.$conn->qstr(serialize($this->configFiles)).', '.adodb_mktime().')');
- }
+ if (defined('CACHE_PARSED_CONFIGS')) {
+ $this->CacheParsedData();
+ }
- unset($this->configFiles);
+ if (defined('CACHE_CONFIGS_FILES') && $files_cached == 0) {
+ $conn =& $this->Application->GetADODBConnection();
+ $conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("config_files", '.$conn->qstr(serialize($this->configFiles)).', '.adodb_mktime().')');
}
- /**
+ unset($this->configFiles);
+ }
+
+ /**
* Register nessasary classes
*
* @param string $prefix
* @access private
*/
- function parseConfig($prefix)
+ function parseConfig($prefix)
+ {
+ $config =& $this->configData[$prefix];
+ $event_manager =& $this->Application->recallObject('EventManager');
+
+ $register_classes = getArrayValue($config,'RegisterClasses');
+ if (!$register_classes) $register_classes = Array();
+ $class_params=Array('ItemClass','ListClass','EventHandlerClass','TagProcessorClass');
+ foreach($class_params as $param_name)
{
- $config =& $this->configData[$prefix];
- $event_manager =& $this->Application->recallObject('EventManager');
+ if ( !(isset($config[$param_name]) ) ) continue;
+ $config[$param_name]['pseudo'] = $this->getPrefixByParamName($param_name,$prefix);
+ $register_classes[] = $config[$param_name];
+ }
- $register_classes = getArrayValue($config,'RegisterClasses');
- if (!$register_classes) $register_classes = Array();
- $class_params=Array('ItemClass','ListClass','EventHandlerClass','TagProcessorClass');
- foreach($class_params as $param_name)
- {
- if ( !(isset($config[$param_name]) ) ) continue;
- $config[$param_name]['pseudo'] = $this->getPrefixByParamName($param_name,$prefix);
- $register_classes[] = $config[$param_name];
+ foreach($register_classes as $class_info)
+ {
+ $this->Application->registerClass(
+ $class_info['class'],
+ $config['BasePath'].'/'.$class_info['file'],
+ $class_info['pseudo'],
+ getArrayValue($class_info, 'require_classes')
+ );
+ if (getArrayValue($class_info, 'build_event')) {
+ $event_manager->registerBuildEvent($class_info['pseudo'],$class_info['build_event']);
}
+ }
- foreach($register_classes as $class_info)
+ $regular_events = getArrayValue($config, 'RegularEvents');
+ if($regular_events)
+ {
+ foreach($regular_events as $short_name => $regular_event_info)
{
- $this->Application->registerClass(
- $class_info['class'],
- $config['BasePath'].'/'.$class_info['file'],
- $class_info['pseudo'],
- getArrayValue($class_info, 'require_classes')
- );
- if (getArrayValue($class_info, 'build_event')) {
- $event_manager->registerBuildEvent($class_info['pseudo'],$class_info['build_event']);
- }
+ $event_manager->registerRegularEvent( $short_name, $config['Prefix'].':'.$regular_event_info['EventName'], $regular_event_info['RunInterval'], $regular_event_info['Type'] );
}
+ }
- $regular_events = getArrayValue($config, 'RegularEvents');
- if($regular_events)
- {
- foreach($regular_events as $short_name => $regular_event_info)
- {
- $event_manager->registerRegularEvent( $short_name, $config['Prefix'].':'.$regular_event_info['EventName'], $regular_event_info['RunInterval'], $regular_event_info['Type'] );
+ $hooks = getArrayValue($config, 'Hooks');
+ if (is_array($hooks) && count($hooks) > 0) {
+ foreach ($hooks as $hook) {
+ if (isset($config['ParentPrefix']) && $hook['HookToPrefix'] == $config['ParentPrefix']) {
+ trigger_error('Depricated Hook Usage [prefix: '.$config['Prefix'].'; do_prefix: '.$hook['DoPrefix'].'] use #PARENT# and HookToPrefix value where HookToPrefix is same as ParentPrefix', E_USER_NOTICE);
}
- }
- $hooks = getArrayValue($config, 'Hooks');
- if (is_array($hooks) && count($hooks) > 0) {
- foreach ($hooks as $hook) {
- if (isset($config['ParentPrefix']) && $hook['HookToPrefix'] == $config['ParentPrefix']) {
- trigger_error('Depricated Hook Usage [prefix: '.$config['Prefix'].'; do_prefix: '.$hook['DoPrefix'].'] use #PARENT# and HookToPrefix value where HookToPrefix is same as ParentPrefix', E_USER_NOTICE);
- }
+ if ($hook['HookToPrefix'] == '') {
+ $hook['HookToPrefix'] = $config['Prefix']; // new: set hooktoprefix to current prefix if not set
+ }
- if ($hook['HookToPrefix'] == '') {
- $hook['HookToPrefix'] = $config['Prefix']; // new: set hooktoprefix to current prefix if not set
- }
+ if (isset($config['ParentPrefix']) && $hook['HookToPrefix'] == '#PARENT#') {
+ // new: allow to set hook to parent prefix what ever it is
+ $hook['HookToPrefix'] = $config['ParentPrefix'];
+ }
- if (isset($config['ParentPrefix']) && $hook['HookToPrefix'] == '#PARENT#') {
- // new: allow to set hook to parent prefix what ever it is
- $hook['HookToPrefix'] = $config['ParentPrefix'];
- }
+ $do_prefix = $hook['DoPrefix'] == '' ? $config['Prefix'] : $hook['DoPrefix'];
- $do_prefix = $hook['DoPrefix'] == '' ? $config['Prefix'] : $hook['DoPrefix'];
-
- if ( !is_array($hook['HookToEvent']) ) {
- $hook_events = Array( $hook['HookToEvent'] );
- }
- else {
- $hook_events = $hook['HookToEvent'];
- }
- foreach ($hook_events as $hook_event) {
- $this->Application->registerHook($hook['HookToPrefix'], $hook['HookToSpecial'], $hook_event, $hook['Mode'], $do_prefix, $hook['DoSpecial'], $hook['DoEvent'], $hook['Conditional']);
- }
+ if ( !is_array($hook['HookToEvent']) ) {
+ $hook_events = Array( $hook['HookToEvent'] );
}
+ else {
+ $hook_events = $hook['HookToEvent'];
+ }
+ foreach ($hook_events as $hook_event) {
+ $this->Application->registerHook($hook['HookToPrefix'], $hook['HookToSpecial'], $hook_event, $hook['Mode'], $do_prefix, $hook['DoSpecial'], $hook['DoEvent'], $hook['Conditional']);
+ }
}
+ }
- if ( is_array(getArrayValue($config, 'AggregateTags')) ) {
- foreach ($config['AggregateTags'] as $aggregate_tag) {
- $aggregate_tag['LocalPrefix'] = $config['Prefix'];
- $this->Application->registerAggregateTag($aggregate_tag);
- }
+ if ( is_array(getArrayValue($config, 'AggregateTags')) ) {
+ foreach ($config['AggregateTags'] as $aggregate_tag) {
+ $aggregate_tag['LocalPrefix'] = $config['Prefix'];
+ $this->Application->registerAggregateTag($aggregate_tag);
}
+ }
- if ( $this->Application->isDebugMode() && dbg_ConstOn('DBG_VALIDATE_CONFIGS') && isset($config['TableName']) )
- {
- global $debugger;
- $tablename = $config['TableName'];
+ if ( $this->Application->isDebugMode() && dbg_ConstOn('DBG_VALIDATE_CONFIGS') && isset($config['TableName']) )
+ {
+ global $debugger;
+ $tablename = $config['TableName'];
- $conn =& $this->Application->GetADODBConnection();
- $res = $conn->Query("DESCRIBE $tablename");
+ $conn =& $this->Application->GetADODBConnection();
+ $res = $conn->Query("DESCRIBE $tablename");
- foreach ($res as $field) {
- $f_name = $field['Field'];
- if (getArrayValue($config, 'Fields')) {
- if ( !array_key_exists ($f_name, $config['Fields']) ) {
- $debugger->appendHTML("Config Warning: Field $f_name exists in the database, but is not defined in config file for prefix ".$config['Prefix']."!");
- safeDefine('DBG_RAISE_ON_WARNINGS', 1);
- }
- else {
- $options = $config['Fields'][$f_name];
- if ($field['Null'] == '') {
- if ( $f_name != $config['IDField'] && !isset($options['not_null']) && !isset($options['required']) ) {
- $debugger->appendHTML("Config Error: Field $f_name in config for prefix ".$config['Prefix']." is NOT NULL in the database, but is not configured as not_null or required!");
- safeDefine('DBG_RAISE_ON_WARNINGS', 1);
- }
- if ( isset($options['not_null']) && !isset($options['default']) ) {
- $debugger->appendHTML("Config Error: Field $f_name in config for prefix ".$config['Prefix']." is described as NOT NULL, but does not have DEFAULT value!");
- safeDefine('DBG_RAISE_ON_WARNINGS', 1);
- }
+ foreach ($res as $field) {
+ $f_name = $field['Field'];
+ if (getArrayValue($config, 'Fields')) {
+ if ( !array_key_exists ($f_name, $config['Fields']) ) {
+ $debugger->appendHTML("Config Warning: Field $f_name exists in the database, but is not defined in config file for prefix ".$config['Prefix']."!");
+ safeDefine('DBG_RAISE_ON_WARNINGS', 1);
+ }
+ else {
+ $options = $config['Fields'][$f_name];
+ if ($field['Null'] == '') {
+ if ( $f_name != $config['IDField'] && !isset($options['not_null']) && !isset($options['required']) ) {
+ $debugger->appendHTML("Config Error: Field $f_name in config for prefix ".$config['Prefix']." is NOT NULL in the database, but is not configured as not_null or required!");
+ safeDefine('DBG_RAISE_ON_WARNINGS', 1);
}
-
+ if ( isset($options['not_null']) && !isset($options['default']) ) {
+ $debugger->appendHTML("Config Error: Field $f_name in config for prefix ".$config['Prefix']." is described as NOT NULL, but does not have DEFAULT value!");
+ safeDefine('DBG_RAISE_ON_WARNINGS', 1);
+ }
}
+
}
}
}
}
+ }
- function loadConfigFile($filename)
+ function loadConfigFile($filename)
+ {
+ $config_found = file_exists(FULL_PATH.$filename) && $this->configAllowed($filename);
+
+ if( defined('DEBUG_MODE') && DEBUG_MODE && constOn('DBG_PROFILE_INCLUDES') )
{
- $config_found = file_exists(FULL_PATH.$filename) && $this->configAllowed($filename);
+ if ( in_array($filename, get_required_files()) ) return;
+ global $debugger;
+ /*$debugger->IncludeLevel++;
+ $before_time = getmicrotime();
+ $before_mem = memory_get_usage();*/
+ if($config_found) {
+ $file = FULL_PATH.$filename;
+ $debugger->ProfileStart('inc_'.crc32($file), $file);
+ include_once($file);
+ $debugger->ProfileFinish('inc_'.crc32($file));
+ $debugger->profilerAddTotal('includes', 'inc_'.crc32($file));
+ }
+ /*$used_time = getmicrotime() - $before_time;
+ $used_mem = memory_get_usage() - $before_mem;
+ $debugger->IncludeLevel--;
+ $debugger->IncludesData['file'][] = str_replace(FULL_PATH, '', $filename);
+ $debugger->IncludesData['mem'][] = $used_mem;
+ $debugger->IncludesData['time'][] = $used_time;
+ $debugger->IncludesData['level'][] = -1;*/
+ }
+ else
+ {
+ if($config_found) include_once(FULL_PATH.$filename);
+ }
- if( defined('DEBUG_MODE') && DEBUG_MODE && constOn('DBG_PROFILE_INCLUDES') )
- {
- if ( in_array($filename, get_required_files()) ) return;
- global $debugger;
- /*$debugger->IncludeLevel++;
- $before_time = getmicrotime();
- $before_mem = memory_get_usage();*/
- if($config_found) {
- $file = FULL_PATH.$filename;
- $debugger->ProfileStart('inc_'.crc32($file), $file);
- include_once($file);
- $debugger->ProfileFinish('inc_'.crc32($file));
- $debugger->profilerAddTotal('includes', 'inc_'.crc32($file));
- }
- /*$used_time = getmicrotime() - $before_time;
- $used_mem = memory_get_usage() - $before_mem;
- $debugger->IncludeLevel--;
- $debugger->IncludesData['file'][] = str_replace(FULL_PATH, '', $filename);
- $debugger->IncludesData['mem'][] = $used_mem;
- $debugger->IncludesData['time'][] = $used_time;
- $debugger->IncludesData['level'][] = -1;*/
- }
- else
- {
- if($config_found) include_once(FULL_PATH.$filename);
- }
+ if($config_found && isset($config) && $config)
+ {
+ $prefix = isset($config['Prefix']) ? $config['Prefix'] : '';
- if($config_found && isset($config) && $config)
- {
- $prefix = isset($config['Prefix']) ? $config['Prefix'] : '';
+ preg_match('/\/(.*)\//U', $filename, $rets);
+ $config['ModuleFolder'] = $rets[1];
+ $config['BasePath'] = dirname(FULL_PATH.$filename);
+ $this->configData[$prefix] = $config;
+ $this->prefixFiles[$prefix] = $filename;
- preg_match('/\/(.*)\//U', $filename, $rets);
- $config['ModuleFolder'] = $rets[1];
- $config['BasePath'] = dirname(FULL_PATH.$filename);
- $this->configData[$prefix] = $config;
- $this->prefixFiles[$prefix] = $filename;
-
- $this->postProcessConfig($prefix, 'AggregateConfigs', 'sub_prefix');
- $this->postProcessConfig($prefix, 'Clones', 'prefix');
- }
+ $this->postProcessConfig($prefix, 'AggregateConfigs', 'sub_prefix');
+ $this->postProcessConfig($prefix, 'Clones', 'prefix');
}
+ }
- function loadConfig($prefix)
- {
- if (!isset($this->prefixFiles[$prefix])) {
- trigger_error('Configuration file for prefix '.$prefix.' is unknown', E_USER_ERROR);
- return ;
- }
- $file = $this->prefixFiles[$prefix];
- $this->loadConfigFile($file);
- $this->Application->HandleEvent( new kEvent($prefix.':OnAfterConfigRead') );
+ function loadConfig($prefix)
+ {
+ if (!isset($this->prefixFiles[$prefix])) {
+ trigger_error('Configuration file for prefix '.$prefix.' is unknown', E_USER_ERROR);
+ return ;
}
+ $file = $this->prefixFiles[$prefix];
+ $this->loadConfigFile($file);
+ $this->Application->HandleEvent( new kEvent($prefix.':OnAfterConfigRead') );
+ }
- /**
+ /**
* Reads unit (specified by $prefix)
* option specified by $option
*
@@ -493,95 +493,95 @@
* @return string
* @access public
*/
- function getUnitOption($prefix, $name, $default = false)
- {
- if (preg_match('/(.*)\.(.*)/', $prefix, $rets)) {
- if (!isset($this->configData[$rets[1]])) {
- $this->loadConfig($rets[1]);
- }
- $ret = getArrayValue($this->configData, $rets[1], $name, $rets[2]);
+ function getUnitOption($prefix, $name, $default = false)
+ {
+ if (preg_match('/(.*)\.(.*)/', $prefix, $rets)) {
+ if (!isset($this->configData[$rets[1]])) {
+ $this->loadConfig($rets[1]);
}
- else {
- if (!isset($this->configData[$prefix])) {
- $this->loadConfig($prefix);
- }
- $ret = getArrayValue($this->configData, $prefix, $name);
+ $ret = getArrayValue($this->configData, $rets[1], $name, $rets[2]);
+ }
+ else {
+ if (!isset($this->configData[$prefix])) {
+ $this->loadConfig($prefix);
}
- return $ret === false ? $default : $ret;
+ $ret = getArrayValue($this->configData, $prefix, $name);
}
+ return $ret === false ? $default : $ret;
+ }
- /**
+ /**
* Read all unit with $prefix options
*
* @param string $prefix
* @return Array
* @access public
*/
- function getUnitOptions($prefix)
- {
- return $this->prefixRegistred($prefix) ? $this->configData[$prefix] : false;
- }
+ function getUnitOptions($prefix)
+ {
+ return $this->prefixRegistred($prefix) ? $this->configData[$prefix] : false;
+ }
- /**
+ /**
* Set's new unit option value
*
* @param string $prefix
* @param string $name
* @param string $value
* @access public
*/
- function setUnitOption($prefix, $name, $value)
- {
- if (preg_match('/(.*)\.(.*)/', $prefix, $rets)) {
- $this->configData[$rets[1]][$name][$rets[2]] = $value;
- }
- else {
- $this->configData[$prefix][$name] = $value;
- }
-
+ function setUnitOption($prefix, $name, $value)
+ {
+ if (preg_match('/(.*)\.(.*)/', $prefix, $rets)) {
+ $this->configData[$rets[1]][$name][$rets[2]] = $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);
+ else {
+ $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';
- }
+ 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);
- }
+ function isDir($folderPath)
+ {
+ $base_name = basename($folderPath);
+ $ret = !( $base_name == '.' || $base_name == '..' );
+ return $ret && is_dir($folderPath);
+ }
- }
+}
?>
\ No newline at end of file
Index: trunk/kernel/units/statistics/statistics_tag_processor.php
===================================================================
diff -u -N -r4651 -r4765
--- trunk/kernel/units/statistics/statistics_tag_processor.php (.../statistics_tag_processor.php) (revision 4651)
+++ trunk/kernel/units/statistics/statistics_tag_processor.php (.../statistics_tag_processor.php) (revision 4765)
@@ -215,7 +215,8 @@
function GetTotalPending()
{
$sql = 'SELECT Prefix
- FROM '.TABLE_PREFIX.'ItemTypes';
+ FROM '.TABLE_PREFIX.'ItemTypes
+ WHERE LENGTH(ClassName) > 0';
$prefixes = $this->Conn->GetCol($sql);
$sum = 0;
@@ -228,7 +229,8 @@
function PrintPendingStatistics($params)
{
$sql = 'SELECT Prefix
- FROM '.TABLE_PREFIX.'ItemTypes';
+ FROM '.TABLE_PREFIX.'ItemTypes
+ WHERE LENGTH(ClassName) > 0';
$check_prefixes = $this->Conn->GetCol($sql);
if (!$check_prefixes) {
return '';
Index: trunk/core/kernel/event_manager.php
===================================================================
diff -u -N -r4758 -r4765
--- trunk/core/kernel/event_manager.php (.../event_manager.php) (revision 4758)
+++ trunk/core/kernel/event_manager.php (.../event_manager.php) (revision 4765)
@@ -208,7 +208,7 @@
$this->processHooks($event, hBEFORE);
if ($event->status == erFATAL) return true;
}
-
+
$event_handler =& $this->Application->recallObject($event->Prefix.'_EventHandler');
$event_handler->processEvent($event);
Index: trunk/core/units/statistics/statistics_tag_processor.php
===================================================================
diff -u -N -r4651 -r4765
--- trunk/core/units/statistics/statistics_tag_processor.php (.../statistics_tag_processor.php) (revision 4651)
+++ trunk/core/units/statistics/statistics_tag_processor.php (.../statistics_tag_processor.php) (revision 4765)
@@ -215,7 +215,8 @@
function GetTotalPending()
{
$sql = 'SELECT Prefix
- FROM '.TABLE_PREFIX.'ItemTypes';
+ FROM '.TABLE_PREFIX.'ItemTypes
+ WHERE LENGTH(ClassName) > 0';
$prefixes = $this->Conn->GetCol($sql);
$sum = 0;
@@ -228,7 +229,8 @@
function PrintPendingStatistics($params)
{
$sql = 'SELECT Prefix
- FROM '.TABLE_PREFIX.'ItemTypes';
+ FROM '.TABLE_PREFIX.'ItemTypes
+ WHERE LENGTH(ClassName) > 0';
$check_prefixes = $this->Conn->GetCol($sql);
if (!$check_prefixes) {
return '';