Пример #1
0
 /**
  * returns the cached template output file name, true if it's cache-able but not cached
  * or false if it's not cached
  *
  * @param Dwoo $dwoo the dwoo instance that requests it
  * @return string|bool
  */
 public function getCachedTemplate(Dwoo $dwoo)
 {
     if ($this->cacheTime !== null) {
         $cacheLength = $this->cacheTime;
     } else {
         $cacheLength = $dwoo->getCacheTime();
     }
     // file is not cacheable
     if ($cacheLength === 0) {
         return false;
     }
     $cachedFile = $this->getCacheFilename($dwoo);
     if (isset(self::$cache['cached'][$this->cacheId]) === true && file_exists($cachedFile)) {
         // already checked, return cache file
         return $cachedFile;
     } elseif ($this->compilationEnforced !== true && file_exists($cachedFile) && ($cacheLength === -1 || filemtime($cachedFile) > $_SERVER['REQUEST_TIME'] - $cacheLength)) {
         // cache is still valid and can be loaded
         self::$cache['cached'][$this->cacheId] = true;
         return $cachedFile;
     } else {
         // file is cacheable
         return true;
     }
 }
 public function getCachedTemplate(Dwoo $dwoo)
 {
     if ($this->cacheTime !== null) {
         $cacheLength = $this->cacheTime;
     } else {
         $cacheLength = $dwoo->getCacheTime();
     }
     if ($cacheLength === 0) {
         return false;
     }
     $cachedFile = $this->getCacheFilename($dwoo);
     if (isset(self::$cache['cached'][$this->cacheId]) === true && file_exists($cachedFile)) {
         return $cachedFile;
     } elseif ($this->compilationEnforced !== true && file_exists($cachedFile) && ($cacheLength === -1 || filemtime($cachedFile) > $_SERVER['REQUEST_TIME'] - $cacheLength) && $this->isValidCompiledFile($this->getCompiledFilename($dwoo))) {
         self::$cache['cached'][$this->cacheId] = true;
         return $cachedFile;
     } else {
         return true;
     }
 }