Ejemplo n.º 1
0
 public function format_trace($e, $cli = false)
 {
     if (IN_CLI == "true" || $cli) {
         $view = new WXTemplate(array("e" => $e, "help" => $this->help));
         $view->add_path(FRAMEWORK_DIR . "/template/builtin/cli_trace");
         return $view->parse();
     } else {
         $view = new WXTemplate(array("e" => $e, "help" => $this->help));
         $view->add_path(FRAMEWORK_DIR . "/template/builtin/trace");
         return $view->parse();
     }
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 3
0
 /**
  *  Returns a single path as a string.
  *	@return string
  */
 public function view_to_string($view_path, $values = array(), $suffix = "html")
 {
     $view = new WXTemplate($values);
     $view->add_path(VIEW_DIR . $view_path);
     if ($this->use_format) {
         return $view->parse($this->use_format);
     }
     return $view->parse($suffix);
 }