summaryrefslogtreecommitdiff
path: root/framework/Web/UI/TTemplateManager.php
diff options
context:
space:
mode:
authorwei <>2006-01-06 04:42:44 +0000
committerwei <>2006-01-06 04:42:44 +0000
commit4835704a04cf5aa5ec71a8aef902d54b9c6cae82 (patch)
tree39623c082a78db1b3569a12ab54aa751d376af21 /framework/Web/UI/TTemplateManager.php
parent673d5c08a4d27906864659def27c7783fe45c04f (diff)
Adding I18N support.
Diffstat (limited to 'framework/Web/UI/TTemplateManager.php')
-rw-r--r--framework/Web/UI/TTemplateManager.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php
index cb44b81d..d5c5f0ba 100644
--- a/framework/Web/UI/TTemplateManager.php
+++ b/framework/Web/UI/TTemplateManager.php
@@ -70,7 +70,7 @@ class TTemplateManager extends TModule
*/
public function getTemplateByFileName($fileName)
{
- if(($fileName=realpath($fileName))!==false && is_file($fileName))
+ if(!is_null($fileName=$this->getLocalizedTemplate($fileName)))
{
if(($cache=$this->getApplication()->getCache())===null)
return new TTemplate(file_get_contents($fileName),dirname($fileName),$fileName);
@@ -91,6 +91,22 @@ class TTemplateManager extends TModule
else
return null;
}
+
+ /**
+ * Finds a localized template file.
+ * @param string template file.
+ * @return string|null a localized template file if found, null otherwise.
+ */
+ protected function getLocalizedTemplate($filename)
+ {
+ $app = $this->getApplication()->getGlobalization();
+ if(is_null($app)) return $filename;
+ foreach($app->getLocalizedResource($filename) as $file)
+ {
+ if(($file=realpath($file))!==false && is_file($file))
+ return $file;
+ }
+ }
}
/**