TemplatePathResolver Class Reference
[View]
Finds file for given template ressource. More...
Static Public Member Functions |
|
static | exists ($resource, $required_file_extension= 'tpl.php') |
static | get_template_paths () |
static | resolve ($resource, $required_file_extension= 'tpl.php') |
Resolve path name. |
|
Static Public Attributes |
|
static | $resolved_paths = array() |
Detailed Description
Finds file for given template ressource.
Template files are resolved top-down, if path is relative, that is
- application first
- modules: latest enabled come first
- core
Absolute paths are left untouched.
Definition at line 16 of file templatepathresolver.cls.php.
Member Function Documentation
static TemplatePathResolver::exists | ( | $ | resource, | |
$ | required_file_extension =
'tpl.php' |
|||
) | [static] |
Definition at line 52 of file templatepathresolver.cls.php.
static TemplatePathResolver::get_template_paths | ( | ) | [static] |
Definition at line 88 of file templatepathresolver.cls.php.
00088 { 00089 $lang = strtolower(GyroLocale::get_language()); 00090 if (empty(self::$template_paths[$lang])) { 00091 $dirs = Load::get_base_directories(Load::ORDER_OVERLOAD); 00092 $ret = array(); 00093 foreach($dirs as $dir) { 00094 $test = $dir . 'view/templates/' . $lang . '/'; 00095 if (file_exists($test)) { 00096 $ret[] = $test; 00097 } 00098 $test = $dir . 'view/templates/default/'; 00099 if (file_exists($test)) { 00100 $ret[] = $test; 00101 } 00102 } 00103 self::$template_paths[$lang] = $ret; 00104 } 00105 return self::$template_paths[$lang]; 00106 }
static TemplatePathResolver::resolve | ( | $ | resource, | |
$ | required_file_extension =
'tpl.php' |
|||
) | [static] |
Resolve path name.
If an array is passed, the first item that can be resolved will be returned
- Exceptions:
-
Exception If path could not be resolved
- Parameters:
-
string|array $resource Absolute or relative path or an array string $required_file_extension file extension of template files. Default is "tpl.php"
Definition at line 30 of file templatepathresolver.cls.php.
00030 { 00031 $resource = Arr::force($resource, false); 00032 foreach($resource as $res) { 00033 $key = $res; 00034 if (!isset(self::$resolved_paths[$key])) { 00035 $ret = self::find_template($res, $required_file_extension); 00036 self::$resolved_paths[$key] = $ret; 00037 } 00038 else { 00039 $ret = self::$resolved_paths[$key]; 00040 } 00041 if ($ret !== false) { 00042 break; 00043 } 00044 } 00045 // Not found 00046 if ($ret === false) { 00047 throw new Exception('Template file ' . implode(', ', $resource) . ' not found'); 00048 } 00049 return $ret; 00050 }
Member Data Documentation
TemplatePathResolver::$resolved_paths = array()
[static] |
Definition at line 17 of file templatepathresolver.cls.php.
The documentation for this class was generated from the following file:
- gyro/core/view/base/templatepathresolver.cls.php