function __construct() { // auto-detect the url if it is not set if (!c::get('url')) { c::set('url', c::get('scheme') . server::get('http_host')); } // check if the cache is enabled at all $this->cacheEnabled = c::get('cache') && (c::get('cache.html') || c::get('cache.data')) ? true : false; if ($this->cacheEnabled) { $this->dataCacheEnabled = c::get('cache.data'); $this->htmlCacheEnabled = c::get('cache.html'); if (c::get('cache.autoupdate')) { $this->modified = dir::modified(c::get('root.content')); } else { $this->modified = 0; } } $cacheID = 'site.php'; $cacheModified = time(); $cacheData = null; // data cache if ($this->dataCacheEnabled) { // find the latest modifed date from all content subdirs // if the cache is enabled and autoupdate is activated. // otherwise the last modified date will be false so the cache // will stay valid forever // check when the data cache has been modified $cacheModified = cache::modified($cacheID); // check if the cache is still valid if ($cacheModified >= $this->modified) { $cacheData = cache::get($cacheID); } } if (empty($cacheData)) { // get the first set of pages $this->rootPages(); // get the additional site info from content/site.txt $this->siteInfo(); if ($this->dataCacheEnabled) { cache::set($cacheID, $this->_); } } else { $this->_ = $cacheData; } // attach the uri after caching // this will definitely be variable :) $this->uri = new uri(); }
/** * Gets the last modification date of all pages * in the content folder. * * @param mixed $format * @param mixed $handler * @return mixed */ public function modified($format = null, $handler = null) { return dir::modified($this->root, $format, $handler ? $handler : $this->kirby->options['date.handler']); }
public function testModified() { $this->assertTrue(is_int(dir::modified(TEST_ROOT))); }