Beispiel #1
0
 public function cache_get($label)
 {
     $cache = new WaxCache($label);
     if ($cache->valid()) {
         return $cache->get();
     }
 }
Beispiel #2
0
 protected function cached_tree_get()
 {
     $cache = new WaxCache($this->table . "_tree_cache" . $this->filters ? ":" . md5(serialize($this->filters)) : '');
     if ($cache->valid()) {
         return $cache->get();
     } else {
         return false;
     }
 }
Beispiel #3
0
 /**
  * Partial Helper Function
  * Renders a partial from path $path into the current view
  * To inherit an existing view use this method: eg.....
  * 
  *  <?=partial("mypartial", $this);?>
  *
  * Alternate syntax allows standalone execution that runs the partialname() method
  *  <?=partial("mypartial")?>
  *
  * @param string $path 
  * @param array $extra_vals 
  * @param string $format 
  */
 public function partial($path, $extra_vals = array(), $format = "html")
 {
     $controller = WaxUrl::route_controller($path);
     $cache = new WaxCache($_SERVER['HTTP_HOST'] . md5($path . $_SERVER['REQUEST_URI'] . serialize($_GET)) . '.partial');
     if (count($_POST)) {
         $cache->expire();
     }
     if (Config::get('partial_cache') && !substr_count($path, "admin") && !substr_count(strtolower($controller), "admin") && $cache->valid()) {
         $partial = $cache->get();
     } else {
         if ($extra_vals instanceof WaxTemplate) {
             $old_template_paths = $extra_vals->template_paths;
             foreach ($extra_vals as $var => $val) {
                 $this->{$var} = $val;
             }
             $view = new WXTemplate();
             if (count($extra_vals->plugins) > 0) {
                 foreach ($old_template_paths as $template) {
                     $view->add_path(str_replace($extra_vals->use_view, $path, $template));
                 }
             }
             $view->add_path(VIEW_DIR . $path);
             foreach ($this as $var => $val) {
                 if (!$view->{$var}) {
                     $view->{$var} = $val;
                 }
             }
             $view->add_path(VIEW_DIR . $view->controller . "/" . $path);
             $partial = $view->parse($format, "partial");
         } else {
             if (!$controller) {
                 $controller = WaxUrl::$default_controller;
             }
             $delegate = Inflections::slashcamelize($controller, true);
             $delegate .= "Controller";
             $delegate_controller = new $delegate();
             $delegate_controller->controller = $controller;
             $partial = $delegate_controller->execute_partial($path, $format);
         }
     }
     if (Config::get('partial_cache') && !substr_count($controller, "admin")) {
         $cache->set($partial);
     }
     return $partial;
 }
Beispiel #4
0
 public static function get_cache($model, $field, $id, $transform = true)
 {
     $cache = new WaxCache($model . "/" . $field . "/" . $id, "memory");
     $data = unserialize($cache->get());
     if (!$transform) {
         return $data;
     }
     if ($data) {
         $model_this = new $model();
         if (is_array($data[0])) {
             return new WaxRecordset(new $model(), $data);
         } else {
             $row = new $model();
             $row->row = $data;
             return $row;
         }
     }
     return false;
 }
Beispiel #5
0
 public function execute_partial($path, $format = false)
 {
     if (strpos($path, "/")) {
         $partial = substr($path, strrpos($path, "/") + 1);
         $path = substr($path, 0, strrpos($path, "/") + 1);
         $path = $path . $partial;
     } else {
         $partial = $path;
     }
     $sess = $_SESSION[Session::get_hash()];
     unset($sess['referrer']);
     $cache = new WaxCache($_SERVER['HTTP_HOST'] . md5($_SERVER['REQUEST_URI'] . serialize($_GET) . serialize($sess)) . '.partial');
     if (count($_POST)) {
         $cache->expire();
     }
     if (Config::get('partial_cache') && !substr_count($path, "admin") && !substr_count(strtolower($this->controller), "admin") && $cache->valid()) {
         $partial = $cache->get();
     } else {
         if ($this->is_public_method($this, $partial)) {
             $this->{$partial}();
         }
     }
     $partial = $this->build_partial($path, $format);
     if (Config::get('partial_cache') && !substr_count($this->controller, "admin")) {
         $cache->set($partial);
     }
     return $partial;
 }