Beispiel #1
0
 public function smart_view($view, $vars = array(), $return = FALSE)
 {
     $orgin_view = $view;
     if (!strpos($view, ".php") && !strpos($view, ".tpl")) {
         $view .= ".tpl";
     }
     PC::preparing_view($view);
     $view_name = $view;
     $smarty = new SmartyBC();
     $config =& get_config();
     $this->caching = 1;
     $smarty->setCompileDir(APPPATH . '/third_party/Smarty-3.1.8/templates_c');
     $smarty->setConfigDir(APPPATH . '/third_party/Smarty-3.1.8/configs');
     $smarty->setCacheDir(APPPATH . '/cache');
     if (strpos($this->_module, '_child') !== false) {
         list($path, $_view) = Modules::find($view, $this->_module, 'views/');
         if ($path == FALSE) {
             list($path, $_view) = Modules::find($view, str_replace("_child", "", $this->_module), 'views/');
         }
     } else {
         list($path, $_view) = Modules::find($view, $this->_module . "_child", 'views/');
         if ($path == FALSE) {
             list($path, $_view) = Modules::find($view, $this->_module, 'views/');
         }
     }
     if ($path == FALSE) {
         list($path, $_view) = Modules::find($orgin_view . ".php", $this->_module, 'views/');
         if ($path != FALSE) {
             $view = $orgin_view . ".php";
             $view_name = $view;
         }
     }
     if ($path == FALSE && strpos($this->_module, '_child') !== false) {
         list($path, $_view) = Modules::find($view, str_replace("_child", "", $this->_module), 'views/');
     }
     if ($path != FALSE) {
         $this->_ci_view_paths = array($path => TRUE) + $this->_ci_view_paths;
         $view = $_view;
     }
     $path_fragment = explode("/", $path);
     if ($path_fragment[0] == "modules") {
         global $active_show;
         $controller =& $active_show->controller;
         $theme_path = "themes/" . $controller->BuilderEngine->get_option('active_frontend_theme') . "/modules/" . $this->_module;
         $theme_file = $theme_path . "/" . $_view . ".php";
         if (file_exists($theme_file)) {
             $path = "../../" . $theme_path;
             $this->_ci_view_paths = array($path => TRUE) + $this->_ci_view_paths;
             $view = $path . "/" . $_view;
         }
         // To be updated
         $view_name = basename($view_name);
     }
     global $active_show;
     global $BuilderEngine;
     $vars['BuilderEngine'] =& $BuilderEngine;
     $vars['versions'] =& $active_show->controller->versions;
     $vars['user'] =& $active_show->controller->user;
     $vars['this'] =& $this;
     $smarty->setTemplateDir($path);
     foreach ($vars as $key => $value) {
         $smarty->assign($key, $value);
     }
     $smarty->assign("test_var", "qweqweqwe");
     if ($return) {
         ob_start();
         $smarty->display($view_name);
         $output = ob_get_contents();
         ob_end_clean();
         return $output;
     } else {
         $smarty->display($view_name);
     }
     /*
     global $active_show;
     global $BuilderEngine;
     $vars['BuilderEngine'] = &$BuilderEngine;
     
     
     
     $vars['versions'] = &$active_show->controller->versions;
     
     $vars['user'] = &$active_show->controller->user;
     
     return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
     */
 }