Exemple #1
0
 /**
  * Method description
  *
  * More detailed method description
  * @param    void
  * @return   void
  */
 function buildComplete()
 {
     if (!isset($this->tpl)) {
         $this->tpl = $this->createTemplate();
     }
     if (Config::get("CACHE_STATIC_PAGES")) {
         $page = Controller::getInstance()->getPage();
         $cn = Controller::getInstance()->getControllerName();
         $storage = Storage::create("WHTML cache");
         if (!$storage->is_set($cn . "_" . $page . "_" . $this->getId())) {
             $this->page_text = $this->getSrc() ? file_get_contents($this->getSrc()) : ($this->getText() ? $this->getText() : null);
             $storage->set($cn . "_" . $page . "_" . $this->getId(), array("text" => $this->page_text, "cache_time" => time()));
         } else {
             $p = $storage->get($cn . "_" . $page . "_" . $this->getId());
             $mtime = 0;
             $changed = 0;
             if ($this->getSrc()) {
                 if (fileChanged($this->getSrc(), $p['cache_time']) || Controller::getInstance()->XMLPageChanged($p['cache_time'])) {
                     $this->page_text = $this->getSrc() ? file_get_contents($this->getSrc()) : "";
                     $storage->set($cn . "_" . $page . "_" . $this->getId(), array("text" => $this->page_text, "cache_time" => time()));
                 } else {
                     $this->page_text = $p['text'];
                 }
             } else {
                 $this->page_text = $this->getText();
             }
         }
     } else {
         $this->page_text = $this->getSrc() ? file_get_contents($this->getSrc()) : ($this->getText() ? $this->getText() : null);
     }
     parent::buildComplete();
 }
Exemple #2
0
 /**
  * Checks if current page changed since the specified time.
  *
  * Primarily used by internal functions.
  *
  * @param int time to check
  * @return bool result of checking
  */
 function XMLPageChanged($mtime)
 {
     if (!isset($mtime)) {
         return true;
     }
     $file = Config::get('ROOT_DIR') . Config::get("XMLPAGES_DIR") . "/" . $this->controller_name . "/" . $this->page . ".xml";
     if (fileChanged($file, $mtime)) {
         return true;
     }
     foreach ($this->ie_files as $f) {
         if (fileChanged($f, $mtime)) {
             return true;
         }
     }
     return false;
 }