Index: admin_templates/js/catalog.js =================================================================== --- admin_templates/js/catalog.js (revision 13106) +++ admin_templates/js/catalog.js (working copy) @@ -115,10 +115,10 @@ else if ($params[0].length) { document.getElementById($params[0]).innerHTML = $text; } - + // pass catalog object and loaded tab name to event handler $('body').trigger('CatalogTabLoad', [$object, $params[0].replace(/_div$/, '')]); - + if (typeof($object.OnResponceMethod) == 'function') { $object.OnResponceMethod($object); $object.OnResponceMethod = null; Index: admin_templates/js/toolbar.js =================================================================== --- admin_templates/js/toolbar.js (revision 13106) +++ admin_templates/js/toolbar.js (working copy) @@ -42,9 +42,10 @@ if (this.Title.match(/([^:]+):(.*)$/)) { // has module set directly this.Title = RegExp.$2; - this.Module = RegExp.$1; + this.Module = RegExp.$1.toLowerCase(); + if (this.Module == 'in-portal') { - this.Module = 'kernel'; + this.Module = 'core'; } } else { @@ -58,7 +59,14 @@ if (typeof(img_path) == 'undefined') { //alert('error: toolbar image path not set'); } - return img_path.replace('#MODULE#', this.Module) + 'toolbar/'; + + var $module_path = this.Module; + + if (this.Module != 'core') { + $module_path = 'modules/' + $module_path; + } + + return img_path.replace('#MODULE#', $module_path) + 'toolbar/'; } ToolBarButton.prototype.GetHTML = function() { @@ -93,18 +101,6 @@ this.SetOnClick(); this.SetOnRightClick() if (this.Hidden) this.Hide(); - - if (!img.complete) { - var real_path = img_path.replace('#MODULE#', this.Module) + 'toolbar/'; - var old_path = img_path.replace('#MODULE#', 'kernel') + 'toolbar/'+this.ToolBar.IconPrefix + this.Title+'.gif'; - real_path = real_path.replace('http://kostja.prod.intechnic.lv/in-portal.RC', '.'); - old_path = old_path.replace('http://kostja.prod.intechnic.lv/in-portal.RC', '.'); - var source = old_path.replace('/core/', '/kernel/').replace('.gif', '*.gif'); - var path = 'cp '+source+' '+real_path; -// prompt('exec: ', path) -// img.src = 'img/bad_button.GIF'; - } -// preg_print_pre(img, /natural|compl/i) } ToolBarButton.prototype.EditTitle = function() { Index: install.php =================================================================== --- install.php (revision 13106) +++ install.php (working copy) @@ -1166,10 +1166,6 @@ while ( ($sub_folder = readdir($fh)) ) { $folder_path = MODULES_PATH . '/'.$sub_folder; if ($sub_folder != '.' && $sub_folder != '..' && is_dir($folder_path)) { - if ($sub_folder == 'core') { - // skip modules here - continue; - } // this is folder in MODULES_PATH directory if (file_exists($folder_path.'/install.php') && file_exists($folder_path.'/install/install_schema.sql')) { $install_order = trim( file_get_contents($folder_path . '/install/install_order.txt') ); Index: install/install_toolkit.php =================================================================== --- install/install_toolkit.php (revision 13106) +++ install/install_toolkit.php (working copy) @@ -239,14 +239,14 @@ $upgrades_file = sprintf(UPGRADES_FILE, mb_strtolower($module_name).'/', 'sql'); if (!file_exists($upgrades_file)) { // no upgrade file - return '4.0.1'; + return '5.0.0'; } $sqls = file_get_contents($upgrades_file); $versions_found = preg_match_all('/'.VERSION_MARK.'/s', $sqls, $regs); if (!$versions_found) { // upgrades file doesn't contain version definitions - return '4.0.1'; + return '5.0.0'; } return end($regs[1]); Index: kernel/nparser/template_cache.php =================================================================== --- kernel/nparser/template_cache.php (revision 13106) +++ kernel/nparser/template_cache.php (working copy) @@ -68,7 +68,7 @@ $module_paths = Array (); foreach ($this->Application->ModuleInfo as $module_name => $module_info) { - $module_paths[$module_name] = rtrim($module_info['Path'], '/'); + $module_paths[ mb_strtolower($module_name) ] = rtrim($module_info['Path'], '/'); } $this->_modulePaths = $module_paths; @@ -84,6 +84,7 @@ function GetTemplatePaths($filename) { if ($this->Application->isAdmin && array_key_exists($filename, $this->Application->ReplacementTemplates)) { + // process admin template replacement $filename = $this->Application->ReplacementTemplates[$filename]; } @@ -91,8 +92,8 @@ $filename = preg_replace('/^original:(.*)/', '\\1', $filename); if (preg_match('#^[\/]{0,1}([^\/]*)\/(.*)#', $filename, $regs)) { - $module_filename = $regs[2]; $first_dir = $regs[1]; + $module_filename = $regs[2]; } else { $first_dir = ''; @@ -104,31 +105,18 @@ $first_dir = 'theme:' . $this->forceThemeName . ($first_dir ? '/' . $first_dir : ''); } - // !preg_match for backward compatability with full-path plugins - if ($this->Application->isAdmin && ($first_dir == 'plugins') && !preg_match('/admin_templates/', $module_filename)) { - if (preg_match('#^[\/]{0,1}([^\/]*)\/(.*)#', $module_filename, $regs)) {; - $path = MODULES_PATH.'/'.mb_strtolower($first_dir).'/'.$regs[1].'/admin_templates'; - $module_filename = $regs[2]; - } - else { - $first_dir = ''; - $module_filename = $filename; - } + if ($this->Application->isAdmin && array_key_exists($first_dir, $this->_modulePaths)) { + // template belongs to one of the modules + $path = FULL_PATH . '/' . $this->_modulePaths[$first_dir] . '/admin_templates'; } - elseif ($this->Application->isAdmin && in_array($first_dir, $this->_modulePaths)) { - // $this->Application->findModule('Name', $first_dir) - /*if ($first_dir == 'in-portal') { - $first_dir = 'kernel'; - }*/ - $path = MODULES_PATH.'/'.mb_strtolower($first_dir).'/admin_templates'; - } elseif ($this->forceThemeName && preg_match('/^theme:(.*)/', $first_dir, $regs)) { // ability to use Front-End templates in admin (only during mass compilation) $path = FULL_PATH . '/themes/' . $regs[1]; } else { + // template from "core" module $path = $this->BasePath; - $module_filename = $first_dir.'/'.$module_filename; + $module_filename = $first_dir . '/' . $module_filename; } return Array ($path, $module_filename); Index: kernel/processors/main_processor.php =================================================================== --- kernel/processors/main_processor.php (revision 13106) +++ kernel/processors/main_processor.php (working copy) @@ -39,16 +39,23 @@ $cache_key = crc32( serialize($params) ); if (!array_key_exists($cache_key, $cached)) { - $force_admin = array_key_exists('force_admin', $params) && $params['force_admin']; $module = array_key_exists('module', $params) ? $params['module'] : 'core'; - if ($this->Application->isAdmin || $force_admin) { + if ($this->Application->isAdmin) { if ($module == 'in-portal') { $module = 'kernel'; } - $path = $force_admin ? '/core/admin_templates' : THEMES_PATH; - $path = preg_replace('/\/(.*?)\/(.*)/', $module.'/\\2', $path); // remove leading slash + substitute module + // remove leading slash + substitute module + $module_path = $this->Application->findModule('Name', $module, 'Path'); + + if ($module_path !== false) { + $path = $module_path . 'admin_templates'; + } + else { + // remove leading slash + substitute module + $path = preg_replace('/\/(.*?)\/(.*)/', $module . '/\\2', THEMES_PATH); + } } else { $path = mb_substr(THEMES_PATH, 1); @@ -574,6 +581,7 @@ function ModuleInclude($params) { $ret = ''; + $included = Array (); $block_params = array_merge($params, Array('is_silent' => 2)); // don't make fatal errors in case if template is missing $current_template = $this->Application->GetVar('t'); @@ -581,8 +589,6 @@ $skip_prefixes = isset($params['skip_prefixes']) ? explode(',', $params['skip_prefixes']) : Array(); $cms_mode = $this->Application->GetVar('admin'); - $included = Array (); - foreach ($this->Application->ModuleInfo as $module_name => $module_data) { $module_key = mb_strtolower($module_name); @@ -596,7 +602,7 @@ $module_prefix = $module_data['TemplatePath']; } elseif ($this->Application->isAdmin) { - $module_prefix = $module_data['Path']; // was $module_key . '/'; + $module_prefix = $module_key . '/'; // was $module_data['Path']; } else { $module_prefix = $module_data['TemplatePath']; // always have trailing "/" Index: kernel/startup.php =================================================================== --- kernel/startup.php (revision 13106) +++ kernel/startup.php (working copy) @@ -87,7 +87,7 @@ ini_set('memory_limit', '50M'); - define('MODULES_PATH', FULL_PATH); + define('MODULES_PATH', FULL_PATH . '/modules'); define('EXPORT_BASE_PATH', WRITEBALE_BASE . '/export'); define('EXPORT_PATH', FULL_PATH . EXPORT_BASE_PATH); Index: kernel/utility/unit_config_reader.php =================================================================== --- kernel/utility/unit_config_reader.php (revision 13106) +++ kernel/utility/unit_config_reader.php (working copy) @@ -42,6 +42,13 @@ var $_directorySeparator = ''; /** + * Regular expression for detecting module folder + * + * @var string + */ + var $_moduleFolderRegExp = ''; + + /** * Folders to skip during unit config search * * @var Array @@ -58,11 +65,12 @@ { parent::Init($prefix,$special); - $this->_directorySeparator = preg_quote( DIRECTORY_SEPARATOR ); - $this->_skipFolders[] = trim(WRITEBALE_BASE, '/'); // system folder (where web server can write) + $this->_directorySeparator = preg_quote(DIRECTORY_SEPARATOR); $editor_path = explode('/', trim(EDITOR_PATH, '/')); $this->_skipFolders[] = array_pop($editor_path); // last of cmseditor folders + + $this->_moduleFolderRegExp = '#' . $this->_directorySeparator . '(core|modules' . $this->_directorySeparator . '.*?)' . $this->_directorySeparator . '#'; } function CacheParsedData() @@ -95,24 +103,24 @@ } $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, + '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, - // 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.ReplacementTemplates' => $this->Application->ReplacementTemplates, - 'Application.RewriteListeners' => $this->Application->RewriteListeners, - 'Application.ModuleInfo' => $this->Application->ModuleInfo, + // 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.ReplacementTemplates' => $this->Application->ReplacementTemplates, + 'Application.RewriteListeners' => $this->Application->RewriteListeners, + 'Application.ModuleInfo' => $this->Application->ModuleInfo, ); $conn =& $this->Application->GetADODBConnection(); @@ -275,7 +283,8 @@ shuffle($this->configFiles); } else { - $this->findConfigFiles($folderPath); // search from base directory + $this->findConfigFiles(FULL_PATH . '/core'); // search from core directory + $this->findConfigFiles($folderPath); // search from modules directory } foreach ($this->configFiles as $filename) @@ -743,7 +752,7 @@ function PreloadConfigFile($filename) { - $config_found = file_exists(FULL_PATH.$filename) && $this->configAllowed($filename); + $config_found = file_exists(FULL_PATH . $filename) && $this->configAllowed($filename); if (defined('DEBUG_MODE') && DEBUG_MODE && defined('DBG_PROFILE_INCLUDES') && DBG_PROFILE_INCLUDES) { if ( in_array($filename, get_required_files()) ) { @@ -771,7 +780,7 @@ // config file is included for 1st time -> save it's content for future processing $prefix = array_key_exists('Prefix', $config) ? $config['Prefix'] : ''; - preg_match('#' . $this->_directorySeparator . '(.*)' . $this->_directorySeparator . '#U', $filename, $rets); + preg_match($this->_moduleFolderRegExp, $filename, $rets); $config['ModuleFolder'] = $rets[1]; $config['BasePath'] = dirname(FULL_PATH . $filename); @@ -928,33 +937,36 @@ */ function configAllowed($config_path) { + static $module_paths = null; + if (defined('IS_INSTALL') && IS_INSTALL) { // at installation start no modules in db and kernel configs could not be read return true; } - if (preg_match('#' . $this->_directorySeparator . 'plugins' . $this->_directorySeparator . '|' . $this->_directorySeparator . 'core#', $config_path)) { - // always allow to include configs from core and plugins folder + if (preg_match('#^' . $this->_directorySeparator . 'core#', $config_path)) { + // always allow to include configs from "core" module's folder return true; } - $module_found = false; if (!$this->Application->ModuleInfo) { return false; } - foreach ($this->Application->ModuleInfo as $module_name => $module_info) { - $module_path = DIRECTORY_SEPARATOR . trim($module_info['Path'], '/') . DIRECTORY_SEPARATOR; + if (!isset($module_paths)) { + $module_paths = Array (); - // config file path starts with module folder path - if (substr($config_path, 0, strlen($module_path)) == $module_path) { -// if (preg_match('#^' . preg_quote($module_path, '/') . '#', $config_path)) { - $module_found = true; - break; + foreach ($this->Application->ModuleInfo as $module_name => $module_info) { + $module_paths[] = rtrim($module_info['Path'], '/'); } + + $module_paths = array_unique($module_paths); } - return $module_found; + preg_match($this->_moduleFolderRegExp, $config_path, $rets); + + // config file path starts with module folder path + return in_array($rets[1], $module_paths); } /** Index: units/admin/admin_config.php =================================================================== --- units/admin/admin_config.php (revision 13106) +++ units/admin/admin_config.php (working copy) @@ -61,7 +61,7 @@ 'priority' => 0, 'container' => true, 'type' => stTREE, - 'icon_module' => 'in-portal', + 'icon_module' => 'core', ), 'in-portal:service' => Array ( Index: units/helpers/modules_helper.php =================================================================== --- units/helpers/modules_helper.php (revision 13106) +++ units/helpers/modules_helper.php (working copy) @@ -212,7 +212,7 @@ $ret = Array (); while (($entry = $folder->read()) !== false) { $entry_lowercased = strtolower($entry); - if (!is_dir($folder->path . '/' . $entry) || in_array($entry_lowercased, $skip_modules) || (substr($entry_lowercased, 0, 3) != 'in-')) { + if (!is_dir($folder->path . '/' . $entry) || in_array($entry_lowercased, $skip_modules)) { continue; } Index: units/helpers/sections_helper.php =================================================================== --- units/helpers/sections_helper.php (revision 13106) +++ units/helpers/sections_helper.php (working copy) @@ -143,6 +143,7 @@ $this->Tree[$section_name]['icon'] = $regs[2]; $this->Tree[$section_name]['icon_module'] = $regs[1]; // set "icon_module" used in "combined_header" block $module_folder = trim( $this->Application->findModule('Name', $regs[1], 'Path'), '/'); + if ($module_folder == '') { $module_folder = 'core'; } @@ -150,25 +151,27 @@ else { $module_folder = $this->Application->getUnitOption($section_params['SectionPrefix'], 'ModuleFolder'); if (!array_key_exists('icon_module', $section_params)) { - $this->Tree[$section_name]['icon_module'] = $module_folder; // set "icon_module" used in "combined_header" block + // set "icon_module" used in "combined_header" block + $this->Tree[$section_name]['icon_module'] = $this->Application->findModule('Path', $module_folder . '/', 'Name'); } } // this is to display HELP icon instead of missing one.. can be replaced with some other icon to draw attention $icon_file = $module_folder.'/admin_templates/img/icons/icon24_'.$this->Tree[$section_name]['icon']; - /*$core_file = FULL_PATH.'/core/admin_templates/img/icons/icon24_' . $this->Tree[$section_name]['icon'].'.gif'; - if ($module_folder != 'core' && file_exists($core_file) && file_exists(FULL_PATH.'/'.$icon_file.'.gif')) { - if (crc32(file_get_contents($core_file)) == crc32(file_get_contents(FULL_PATH.'/'.$icon_file.'.gif'))) { + /*$core_file = FULL_PATH.'/core/admin_templates/img/icons/icon24_' . $this->Tree[$section_name]['icon'].'.png'; + if ($module_folder != 'core' && file_exists($core_file) && file_exists(FULL_PATH.'/'.$icon_file.'.png')) { + if (crc32(file_get_contents($core_file)) == crc32(file_get_contents(FULL_PATH.'/'.$icon_file.'.png'))) { trigger_error('Section "' . $section_name . '" uses icon copy from "Core" module', E_USER_NOTICE); } }*/ -// if (!file_exists(FULL_PATH.'/'.$icon_file.'.png')) { -// $this->Tree[$section_name]['icon'] = 'help'; -// $this->Tree[$section_name]['icon_module'] = 'core'; -// } + if (!file_exists(FULL_PATH . '/' . $icon_file . '.png')) { + $this->Tree[$section_name]['icon'] = 'help'; + $this->Tree[$section_name]['icon_module'] = 'core'; + } } + $this->Application->HandleEvent( new kEvent('adm:OnAfterBuildTree') ); if (isset($this->Application->Memcached)) { Index: units/modules/modules_event_handler.php =================================================================== --- units/modules/modules_event_handler.php (revision 13106) +++ units/modules/modules_event_handler.php (working copy) @@ -131,7 +131,7 @@ foreach ($new_modules as $module) { $module_record = Array ( 'Name' => $toolkit->getModuleName($module), - 'Path' => $module . '/', + 'Path' => 'modules/' . $module . '/', 'Version' => $toolkit->GetMaxModuleVersion($module), 'Loaded' => 0, 'BuildDate' => null,