/** * Resets store if necessary to stay in sync with content file */ public function sync() { $file = $this->structure->model()->textfile(); $ageModel = f::exists($file) ? f::modified($file) : 0; $ageStore = s::get($this->id() . '_age'); if ($ageStore < $ageModel) { $this->reset(); $this->age = $ageModel; } else { $this->age = $ageStore; } }
public function testModified() { $site = $this->siteInstance(); $page = new Page($site, '1-a'); $modified = f::modified($page->root()); $this->assertEquals($modified, $page->modified()); $this->assertEquals(date('Y-m-d', $modified), $page->modified('Y-m-d')); // switch the date handler $kirby = $this->kirbyInstance(array('date.handler' => 'strftime')); $site = $this->siteInstance($kirby); $page = new Page($site, '1-a'); $this->assertEquals($modified, $page->modified()); $this->assertEquals(strftime('%Y-%m-%d', $modified), $page->modified('%Y-%m-%d')); }
public function testModified() { $page = $this->siteInstance()->page('tests/file-extension-case-test'); $file = $page->file('a.json'); $modified = f::modified($file->root()); $this->assertEquals($modified, $file->modified()); $this->assertEquals(date('Y-m-d', $modified), $file->modified('Y-m-d')); // switch the date handler $kirby = $this->kirbyInstance(array('date.handler' => 'strftime')); $site = $this->siteInstance($kirby); $page = $site->page('tests/file-extension-case-test'); $file = $page->file('a.json'); $this->assertEquals($modified, $file->modified()); $this->assertEquals(strftime('%Y-%m-%d', $modified), $file->modified('%Y-%m-%d')); }
/** * Get the file's last modification time. * * @return int */ public function modified($format = null, $handler = 'date') { return f::modified($this->root, $format, $handler); }
/** * Returns the timestamp when the page * has been modified * * @return int */ public function modified($format = null, $handler = null) { return f::modified($this->root, $format, $handler ? $handler : $this->kirby->options['date.handler']); }
public static function download($file, $name = null) { // stop the download if the file does not exist or is not readable if (!is_file($file) or !is_readable($file)) { return false; } header::download(array('name' => $name ? $name : f::filename($file), 'size' => f::size($file), 'mime' => f::mime($file), 'modified' => f::modified($file))); die(f::read($file)); }
/** * Returns the timestamp when the page * has been modified * * @return int */ public function modified($format = null) { return f::modified($this->root, $format); }
/** * Checks if the thumbnail already exists * and is newer than the original file * * @return boolean */ public function isThere() { if ($this->options['overwrite'] === true) { return false; } // if the thumb already exists and the source hasn't been updated // we don't need to generate a new thumbnail if (file_exists($this->destination->root) and f::modified($this->destination->root) >= $this->source->modified()) { return true; } return false; }
$jsHandler = kirby()->option('js.handler'); $kirby->options['css.handler'] = function ($url, $media = false) use($cssHandler, $kirby) { if (is_array($url)) { $css = array(); foreach ($url as $u) { $css[] = call($kirby->options['css.handler'], $u); } return implode(PHP_EOL, $css) . PHP_EOL; } $file = $kirby->roots()->index() . DS . $url; if (file_exists($file)) { $mod = f::modified($file); $url = dirname($url) . '/' . f::name($url) . '.' . $mod . '.css'; } return call($cssHandler, array($url, $media)); }; $kirby->options['js.handler'] = function ($src, $async = false) use($jsHandler, $kirby) { if (is_array($src)) { $js = array(); foreach ($src as $s) { $js[] = call($kirby->options['js.handler'], $s); } return implode(PHP_EOL, $js) . PHP_EOL; } $file = $kirby->roots()->index() . DS . $src; if (file_exists($file)) { $mod = f::modified($file); $src = dirname($src) . '/' . f::name($src) . '.' . $mod . '.js'; } return call($jsHandler, array($src, $async)); };
public function testModified() { $this->assertEquals(filemtime($this->contentFile), f::modified($this->contentFile)); }
public function fileExist() { if ($this->data[self::ARRAY_ATTR][self::PARA_OVERWRITE] === true) { return false; } if (file_exists($this->data[self::ARRAY_ATTR][self::PARA_IMG_OUTPUT_ROOT]) && \f::modified($this->data[self::ARRAY_ATTR][self::PARA_IMG_OUTPUT_ROOT]) >= $this->data[self::ARRAY_ATTR][self::PARA_IMG_SOURCE_MODIFIED]) { return true; } return false; }