Пример #1
0
 public function cache_reset($label)
 {
     $cache = new WaxCache($label);
     if ($data = $cache->valid(true)) {
         return $cache->set($data);
     }
 }
Пример #2
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;
 }
Пример #3
0
 public static function unset_cache($model, $field, $id = false)
 {
     $cache = new WaxCache($model . "/" . $field . "/" . $id, "memory");
     $cache->expire();
 }
Пример #4
0
 public function save()
 {
     $cache = new WaxCache($this->table . "_tree_cache");
     $cache->expire();
     return parent::save();
 }
Пример #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;
 }