StaticPagesController Class Reference
[StaticPages]
Controller for static pages. More...
Inheritance diagram for
StaticPagesController:
Public Member Functions |
|
action_static ($page_data, $page) | |
Load and display template.
|
|
get_routes () | |
Return array of urls which are handled by
this controller. |
|
on_event ($name, $params, &$result) | |
Process events. |
|
Protected Member Functions |
|
collect_templates () | |
Find all templates that form static pages.
|
|
collect_templates_in_dir ($dir_path, $template_prefix) |
Detailed Description
Controller for static pages.
Registers routes to all templates found in /view/templates/{lang}/static
Definition at line 10 of file staticpages.controller.php.
Member Function Documentation
StaticPagesController::action_static | ( | $ | page_data, | |
$ | page | |||
) |
Load and display template.
- Parameters:
-
PageData $page_data string $template
Definition at line 35 of file staticpages.controller.php.
00035 { 00036 $path = 'static/' . $page; 00037 $template_file = TemplatePathResolver::resolve($path); 00038 if (!file_exists($template_file)) { 00039 return CONTROLLER_NOT_FOUND; 00040 } 00041 00042 $cache = $page_data->get_cache_manager(); 00043 if ($cache) { 00044 $cache->set_cache_duration(GyroDate::ONE_DAY); 00045 } 00046 $view = ViewFactory::create_view(IViewFactory::CONTENT, $template_file, $page_data); 00047 $view->render(); 00048 }
StaticPagesController::collect_templates | ( | ) | [protected] |
Find all templates that form static pages.
- Returns:
- array
Definition at line 55 of file staticpages.controller.php.
00055 { 00056 if (is_null($this->cache_templates)) { 00057 $this->cache_templates = array(); 00058 $dirs = TemplatePathResolver::get_template_paths(); 00059 foreach($dirs as $dir) { 00060 $statics_dir = $dir . 'static'; 00061 if (is_dir($statics_dir)) { 00062 $this->collect_templates_in_dir($statics_dir, ''); 00063 } 00064 } 00065 } 00066 return $this->cache_templates; 00067 }
StaticPagesController::collect_templates_in_dir | ( | $ | dir_path, | |
$ | template_prefix | |||
) | [protected] |
Definition at line 69 of file staticpages.controller.php.
00069 { 00070 $it = new DirectoryIterator($dir_path); 00071 foreach($it as $fileinfo) { 00072 if (!$fileinfo->isDot()) { 00073 $file = $fileinfo->getFilename(); 00074 if ($fileinfo->isDir()) { 00075 $this->collect_templates_in_dir($fileinfo->getPathname(), $template_prefix . $file . '/'); 00076 } 00077 else if(substr($file, -8, 8) === '.tpl.php') { 00078 $file = basename(substr($file, 0, -8)); 00079 $tpl = $template_prefix . $file; 00080 $path = $template_prefix; 00081 if ($file != 'index') { 00082 $path .= $file; 00083 } 00084 $this->cache_templates[$tpl] = $path; 00085 } 00086 } 00087 } 00088 }
StaticPagesController::get_routes | ( | ) |
Return array of urls which are handled by this controller.
Reimplemented from ControllerBase.
Definition at line 16 of file staticpages.controller.php.
00016 { 00017 $templates = $this->collect_templates(); 00018 $ret = array(); 00019 foreach ($templates as $template => $path) { 00020 // Generates actions with fixed action like ActionMapper::get_path('static_somedir/somefile.html') 00021 $ret[] = new StaticPageRoute(STATICPAGES_PREPEND, $path, STATICPAGES_APPEND, $template, $this, 'static'); 00022 } 00023 // This allows using a parameterized syntax: ActionMapper::get_path('static', array('page' => 'somedir/somefile.html') 00024 $ret[] = new StaticPageParamterizedRoute(STATICPAGES_PREPEND . '{page:s}' . STATICPAGES_APPEND, $this, 'static'); 00025 00026 return $ret; 00027 }
StaticPagesController::on_event | ( | $ | name, | |
$ | params, | |||
&$ | result | |||
) |
Process events.
Events processed are:
- gsitemap_site
Reimplemented from ControllerBase.
Definition at line 96 of file staticpages.controller.php.
00096 { 00097 if ($name == 'gsitemap_site' && $params == 'main') { 00098 $arr = $this->collect_templates(); 00099 foreach($arr as $template => $path) { 00100 $result[] = array( 00101 'url' => ActionMapper::get_url('static', array('page' => $path)), 00102 'lastmod' => filemtime(TemplatePathResolver::resolve('static/' . $template)) 00103 ); 00104 } 00105 } 00106 }
The documentation for this class was generated from the following file:
- gyro/modules/staticpages/controller/staticpages.controller.php