modified() static public method

Recursively check when the dir and all subfolders have been modified for the last time.
static public modified ( string $dir, integer $modified ) : integer
$dir string The path of the directory
$modified integer internal modified store
return integer
Example #1
0
 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();
 }
Example #2
0
 /**
  * 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']);
 }
Example #3
0
 public function testModified()
 {
     $this->assertTrue(is_int(dir::modified(TEST_ROOT)));
 }