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