Esempio n. 1
0
 public function get_varys()
 {
     $varys['HOST'] = vmc::base_url(true);
     //host信息
     $varys['REWRITE'] = defined('URL_REWRITE') ? URL_REWRITE : '';
     //是否有rewirte支持
     $varys['LANG'] = vmc::get_lang();
     //语言环境
     return $varys;
 }
Esempio n. 2
0
 static function tips_item_by_app($app_id)
 {
     $lang = vmc::get_lang();
     $tips = array();
     foreach (file(PUBLIC_DIR . '/app/' . $app_id . '/lang/' . $lang . '/tips.txt') as $tip) {
         $tip = trim($tip);
         if ($tip) {
             $tips[] = $tip;
         }
     }
     return $tips;
 }
Esempio n. 3
0
 public function display($tmpl_file, $app_id = null, $fetch = false, $is_theme = false)
 {
     array_unshift($this->_files, $tmpl_file);
     $this->_vars = $this->pagedata;
     if ($p = strpos($tmpl_file, ':')) {
         $object = vmc::service('tpl_source.' . substr($tmpl_file, 0, $p));
         if ($object) {
             $tmpl_file_path = substr($tmpl_file, $p + 1);
             $last_modified = $object->last_modified($tmpl_file_path);
         }
     } else {
         if (defined('EXTENDS_DIR') && file_exists(EXTENDS_DIR . '/' . ($app_id ? $app_id : $this->app->app_id) . '/view/' . $tmpl_file)) {
             $tmpl_file = EXTENDS_DIR . '/' . ($app_id ? $app_id : $this->app->app_id) . '/view/' . $tmpl_file;
         } else {
             if (!$is_theme) {
                 $tmpl_file = realpath(APP_DIR . '/' . ($app_id ? $app_id : $this->app->app_id) . '/view/' . $tmpl_file);
             } else {
                 $tmpl_file = realpath(THEME_DIR . '/' . $tmpl_file);
             }
         }
         $last_modified = filemtime($tmpl_file);
     }
     if (!$last_modified) {
         trigger_error('未知VIEW', E_USER_ERROR);
     }
     $this->tmpl_cachekey('__temp_lang', vmc::get_lang());
     //设置模版所属语言包
     $this->tmpl_cachekey('__temp_app_id', $app_id ? $app_id : $this->app->app_id);
     $compile_id = $this->compile_id($tmpl_file);
     if ($this->force_compile || !cachemgr::get($compile_id . $last_modified, $compile_code)) {
         if ($object) {
             $compile_code = $this->_compiler()->compile($object->get_file_contents($tmpl_file_path));
         } else {
             $compile_code = $this->_compiler()->compile_file($tmpl_file);
         }
         if ($compile_code !== false) {
             cachemgr::co_start();
             cachemgr::set($compile_id . $last_modified, $compile_code, cachemgr::co_end());
         }
     }
     ob_start();
     eval('?>' . $compile_code);
     $content = ob_get_contents();
     ob_end_clean();
     array_shift($this->_files);
     $this->pre_display($content);
     if ($fetch === true) {
         return $content;
     } else {
         echo $content;
     }
 }