Esempio n. 1
0
 function view($resource_name, $params = array())
 {
     $this->setTemplateDir(APPPATH . 'views');
     $this->setCompileDir(APPPATH . 'compile');
     $alang = array();
     if (strpos($resource_name, '.') === false) {
         $resource_name .= '.html';
     }
     if (!is_file($this->template_dir[0] . $resource_name)) {
         show_error("template: [{$resource_name}] cannot be found.");
     }
     foreach ($this->js as $k => $file) {
         $this->js[$k] = self::checkResoure($file);
     }
     foreach ($this->css as $k => $file) {
         $this->css[$k] = self::checkResoure($file);
     }
     foreach ($this->css_ie as $k => $file) {
         $this->css_ie[$k] = self::checkResoure($file);
     }
     foreach ($this->css_all_ie as $k => $file) {
         $this->css_all_ie[$k] = self::checkResoure($file);
     }
     $data = array('view' => $resource_name, 'js' => $this->js, 'css' => $this->css, 'css_ie' => $this->css_ie, 'css_all_ie' => $this->css_all_ie, 'script' => $this->script, 'siteDir' => $this->CI->config->item('base_url'), 'imgURL' => $this->CI->config->item('image_url') . DS, 'assetsURL' => $this->CI->config->item('asset_url') . '/assets/', 'siteurl' => $this->CI->config->item('base_url'));
     if (!empty($this->tpl_vars)) {
         foreach ($this->tpl_vars as $index => $val) {
             $data[$index] = $val;
         }
     }
     if (isset($this->CI->title)) {
         $data['pagetitle'] = $this->CI->title;
     }
     // bug($params);
     // bug($data);die('quannh');
     $data = array_merge($data, (array) $params);
     // bug($data);die('quannh');
     if ($this->useTemp === FALSE) {
         return parent::display($resource_name, $data);
     }
     return parent::display('layout/' . $this->layout . '.html', $data);
 }
Esempio n. 2
0
 /**
  * displays the template results
  *
  * @param string $tpl_name
  * @param string $cache_id
  * @param string $compile_id
  * @return void
  */
 public function display($tpl_name, $cache_id = null, $compile_id = null)
 {
     if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] && preg_match('/MSIE (7|8)/', $this->_request->getAgent())) {
         // 检测是否为IE
         $content = $this->fetch($tpl_name);
         $content = str_replace(array('http://' . SP_STATIC_HOST . '/', SP_URL_STAT, SP_URL_USER), '/', $content);
         $content = str_replace('/wanlitong/', SP_URL_USER . 'wanlitong/', $content);
         echo $content;
     } else {
         //$g_view->assign("res_bundle", FALSE);
         parent::display(trim($tpl_name), $cache_id, $compile_id);
     }
 }
 public static function fatalNoDatabaseError($error)
 {
     global $NONINTERACTIVE_SCRIPT;
     if (isset($NONINTERACTIVE_SCRIPT) && $NONINTERACTIVE_SCRIPT) {
         // Non-interactive script running, return error message as comments
         echo "#error_occured\n";
         echo "# An error has occured in the application\n";
         echo "# ::{$error}::\n";
         echo "# Memory used: " . memory_get_usage() . "\n";
         die;
     }
     $smarty = new \SmartyBC();
     $smarty->compile_check = true;
     $smarty->register_block('t', 'smarty_block_t');
     // Needed even though message will be in English
     $smarty->assign("Application", APPLICATION_NAME);
     $smarty->assign("error", $error);
     $smarty->assign("memory_used", memory_get_usage());
     $smarty->display("error.tpl");
     die;
 }
Esempio n. 4
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));
     */
 }