Index: branches/unlabeled/unlabeled-1.59.2/core/kernel/utility/unit_config_reader.php =================================================================== diff -u -r6448 -r6490 --- branches/unlabeled/unlabeled-1.59.2/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 6448) +++ branches/unlabeled/unlabeled-1.59.2/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 6490) @@ -70,6 +70,7 @@ 'Application.Caches.ConfigVariables' => $this->Application->Caches['ConfigVariables'], 'Application.ConfigCacheIds' => $this->Application->ConfigCacheIds, 'Application.ConfigHash' => $this->Application->ConfigHash, + 'Application.ReplacementTemplates' => $this->Application->ReplacementTemplates, 'Application.ModuleInfo' => $this->Application->ModuleInfo, ); @@ -104,6 +105,8 @@ $this->Application->Caches['ConfigVariables'] = $cache['Application.ConfigCacheIds']; $this->Application->ConfigCacheIds = $cache['Application.ConfigCacheIds']; + + $this->Application->ReplacementTemplates = $cache['Application.ReplacementTemplates']; $this->Application->ModuleInfo = $cache['Application.ModuleInfo']; @@ -337,6 +340,11 @@ $this->Application->registerAggregateTag($aggregate_tag); } } + + if (isset($config['ReplacementTemplates']) && $config['ReplacementTemplates']) { + // replacement templates defined in this config + $this->Application->ReplacementTemplates = array_merge_recursive2($this->Application->ReplacementTemplates, $config['ReplacementTemplates']); + } if ( $this->Application->isDebugMode() && constOn('DBG_VALIDATE_CONFIGS') && isset($config['TableName']) ) { Index: branches/unlabeled/unlabeled-1.15.2/core/kernel/parser/template.php =================================================================== diff -u -r6103 -r6490 --- branches/unlabeled/unlabeled-1.15.2/core/kernel/parser/template.php (.../template.php) (revision 6103) +++ branches/unlabeled/unlabeled-1.15.2/core/kernel/parser/template.php (.../template.php) (revision 6490) @@ -87,8 +87,18 @@ $conn =& $this->Application->GetADODBConnection(); } - function LoadTemplate($filename, $title=NULL, $silent=0) + /** + * Based on template name gets it's location on disk and owner module + * + * @param string $filename + * @return Array 0 - path on disk, 1 - template name + */ + function GetTemplatePaths($filename) { + if (isset($this->Application->ReplacementTemplates[$filename])) { + $filename = $this->Application->ReplacementTemplates[$filename]; + } + if (preg_match('#^[\/]{0,1}([^\/]*)\/(.*)#', $filename, $regs)) { $module_filename = $regs[2]; $first_dir = $regs[1]; @@ -106,28 +116,21 @@ $module_filename = $first_dir.'/'.$module_filename; } + return Array ($path, $module_filename); + } + + function LoadTemplate($filename, $title=NULL, $silent=0) + { + list ($path, $module_filename) = $this->GetTemplatePaths($filename); + $template =& new Template($path, $module_filename, $silent); if (!isset($title)) $title = $filename; $this->SetTemplate($title, $template); } - function GetRealFilename($filename, $base=null) { - if (preg_match('#^[\/]{0,1}([^\/]*)\/(.*)#', $filename, $regs)) { - $module_filename = $regs[2]; - $first_dir = $regs[1]; - } - else { - $first_dir = ''; - $module_filename = $filename; - } - - if ( $this->Application->IsAdmin() && $this->Application->findModule('Name', $first_dir)) { - $path = MODULES_PATH.'/'.strtolower($first_dir).'/admin_templates'; - } - else { - $path = isset($base) ? $base : $this->BasePath; - $module_filename = $first_dir.'/'.$module_filename; - } + function GetRealFilename($filename) + { + list ($path, $module_filename) = $this->GetTemplatePaths($filename); return $path.'/'.trim($module_filename, '/'); } @@ -175,8 +178,10 @@ function TemplateExists($filename) { - if (!preg_match("/\.tpl$/", $filename)) $filename .= '.tpl'; $real_file = $this->GetRealFilename($filename); + if (!preg_match('/\.tpl$/', $real_file)) { + $real_file .= '.tpl'; + } return file_exists($real_file); } Index: branches/unlabeled/unlabeled-1.157.2/core/kernel/application.php =================================================================== diff -u -r6432 -r6490 --- branches/unlabeled/unlabeled-1.157.2/core/kernel/application.php (.../application.php) (revision 6432) +++ branches/unlabeled/unlabeled-1.157.2/core/kernel/application.php (.../application.php) (revision 6490) @@ -69,8 +69,15 @@ * @access private */ var $ConfigCacheIds = array(); - + /** + * Template names, that will be used instead of regular templates + * + * @var Array + */ + var $ReplacementTemplates = Array (); + + /** * Reference to debugger * * @var Debugger