Ubiquity  2.0.3
php rapid development framework
SeoController.php
Go to the documentation of this file.
1 <?php
2 
4 
12 
13 class SeoController extends Controller {
14  const SEO_PREFIX="seo";
15  protected $urlsKey="urls";
16  protected $seoTemplateFilename="@framework/Seo/sitemap.xml.html";
17 
18  public function index() {
19  $config=Startup::getConfig();
20  $base=\rtrim($config['siteUrl'], '/');
23  $urls=$this->_getArrayUrls();
24  if (\is_array($urls)) {
25  $parser=new UrlParser();
26  $parser->parseArray($urls);
27  $this->loadView($this->seoTemplateFilename, [ "urls" => $parser->getUrls(),"base" => $base ]);
28  }
29  }
30 
31  public function _refresh() {
32  }
33 
34  public function getPath(){
35  $seo=new ControllerSeo(\get_class($this));
36  return $seo->getPath();
37  }
38 
39  public function _save($array) {
40  CacheManager::$cache->store($this->_getUrlsFilename(), 'return ' . UArray::asPhpArray($array, "array") . ';');
41  }
42 
43  public function _getArrayUrls() {
44  $key=$this->_getUrlsFilename();
45  if (!CacheManager::$cache->exists($key)) {
46  $this->_save([ ]);
47  }
48  return CacheManager::$cache->fetch($key);
49  }
50 
55  public function _getUrlsFilename() {
56  return self::getUrlsFileName($this->urlsKey);
57  }
58 
59  public static function getUrlsFileName($urlsKey){
60  return self::SEO_PREFIX.DS.$urlsKey;
61  }
62 
67  public function _getSeoTemplateFilename() {
69  }
70 }
71 
static noCache()
Forces the disabling of the browser cache.
Definition: UResponse.php:55
loadView($viewName, $pData=NULL, $asString=false)
Loads the view $viewName possibly passing the variables $pdata.
Definition: Controller.php:66
Base class for controllers.
Definition: Controller.php:18
static asXml($encoding='utf-8')
Sets the response content-type to application/xml.
Definition: UResponse.php:96
static asPhpArray($array, $prefix="", $depth=1, $format=false)
Definition: UArray.php:53