Index: trunk/core/kernel/parser/template.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/kernel/parser/template.php (.../template.php) (revision 6093) +++ trunk/core/kernel/parser/template.php (.../template.php) (revision 6583) @@ -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); }