instance() public static method

取得对象实例 支持调用类的静态方法
public static instance ( string $class, string $method = '' ) : object
$class string 对象类名
$method string 类的静态方法名
return object
 /**
 +----------------------------------------------------------
 * 渲染模板输出
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $templateFile 模板文件名
 * @param array $var 模板变量
 * @param string $charset 模板输出字符集
 * @param string $varPrefix 模板变量前缀
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public function fetch($templateFile, $var, $charset)
 {
     // 缓存无效 重新编译
     $tpl = Think::instance('ThinkTemplate');
     // 编译并加载模板文件
     $tpl->load($templateFile, $var, $charset);
 }
 public function run(&$_data)
 {
     $engine = strtolower(C('TMPL_ENGINE_TYPE'));
     if ('think' == $engine) {
         // 采用Think模板引擎
         if ($this->checkCache($_data['file'])) {
             // 缓存有效
             // 分解变量并载入模板缓存
             extract($_data['var'], EXTR_OVERWRITE);
             //载入模版缓存文件
             include C('CACHE_PATH') . md5($_data['file']) . C('TMPL_CACHFILE_SUFFIX');
         } else {
             $tpl = Think::instance('ThinkTemplate');
             // 编译并加载模板文件
             $tpl->fetch($_data['file'], $_data['var']);
         }
     } else {
         // 调用第三方模板引擎解析和输出
         $class = 'Template' . ucwords($engine);
         if (is_file(CORE_PATH . 'Driver/Template/' . $class . '.class.php')) {
             // 内置驱动
             $path = CORE_PATH;
         } else {
             // 扩展驱动
             $path = EXTEND_PATH;
         }
         if (require_cache($path . 'Driver/Template/' . $class . '.class.php')) {
             $tpl = new $class();
             $tpl->fetch($_data['file'], $_data['var']);
         } else {
             // 类没有定义
             throw_exception(L('_NOT_SUPPERT_') . ': ' . $class);
         }
     }
 }
 public function __construct()
 {
     $this->mid = $_SESSION['mid'];
     $this->model = model("AddonData");
     $this->view = Think::instance('View');
     $this->start();
 }
 public function run(&$_data)
 {
     $engine = strtolower(C('TMPL_ENGINE_TYPE'));
     $_content = empty($_data['content']) ? $_data['file'] : $_data['content'];
     $_data['prefix'] = !empty($_data['prefix']) ? $_data['prefix'] : C('TMPL_CACHE_PREFIX');
     if ('think' == $engine) {
         // 采用Think模板引擎
         if (!empty($_data['content']) && $this->checkContentCache($_data['content'], $_data['prefix']) || $this->checkCache($_data['file'], $_data['prefix'])) {
             // 缓存有效
             // 分解变量并载入模板缓存
             extract($_data['var'], EXTR_OVERWRITE);
             //载入模版缓存文件
             include C('CACHE_PATH') . $_data['prefix'] . md5($_content) . C('TMPL_CACHFILE_SUFFIX');
         } else {
             $tpl = Think::instance('ThinkTemplate');
             // 编译并加载模板文件
             $tpl->fetch($_content, $_data['var'], $_data['prefix']);
         }
     } else {
         // 调用第三方模板引擎解析和输出
         $class = 'Template' . ucwords($engine);
         if (class_exists($class)) {
             $tpl = new $class();
             $tpl->fetch($_content, $_data['var']);
         } else {
             // 类没有定义
             throw_exception(L('_NOT_SUPPERT_') . ': ' . $class);
         }
     }
 }
 /**
  * 架构函数 取得模板对象实例
  * @access public
  */
 public function __construct()
 {
     if (is_file('./Conf/user.php')) {
         //已经安装了
         $moduleModel = D('Common/Module');
         /*读取站点配置*/
         $config = api('Config/lists');
         C($config);
         //添加配置
         $module = $moduleModel->getModule(MODULE_NAME);
         if (strtolower(MODULE_NAME) != 'install' && strtolower(MODULE_NAME) != 'admin') {
             if (!C('WEB_SITE_CLOSE')) {
                 header("Content-Type: text/html; charset=utf-8");
                 exit('站点已经关闭,请稍后访问~');
             }
             if (strtolower(MODULE_NAME) != 'install' && strtolower(MODULE_NAME) != 'admin') {
                 $moduleModel->checkCanVisit(MODULE_NAME);
             }
         }
     }
     Hook::listen('action_begin', $this->config);
     //实例化视图类
     $this->view = Think::instance('Think\\View');
     if (!empty($module)) {
         $this->view->assign('MODULE_INFO', $module);
         $this->view->assign('MODULE_ALIAS', $module['alias']);
     }
     //控制器初始化
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
 }
Beispiel #6
0
/**
 * 万能字段字段类型表单处理
 * @param type $field 字段名 
 * @param type $value 字段内容
 * @param type $fieldinfo 字段配置
 * @return type
 */
function omnipotent($field, $value, $fieldinfo)
{
    $view = Think::instance('View');
    $setting = unserialize($fieldinfo['setting']);
    //特殊处理
    if (in_array($setting['fieldtype'], array('text', 'mediumtext', 'longtext'))) {
        $_value = unserialize($value);
        if ($value && $_value) {
            $value = $_value;
            $this->data[$field] = $value;
        }
    }
    $formtext = str_replace('{FIELD_VALUE}', $value, $setting["formtext"]);
    $formtext = str_replace('{MODELID}', $this->modelid, $formtext);
    $formtext = str_replace('{ID}', $this->id ? $this->id : 0, $formtext);
    // 页面缓存
    ob_start();
    ob_implicit_flush(0);
    $view->assign($this->data);
    $view->display('', '', '', $formtext, '');
    // 获取并清空缓存
    $formtext = ob_get_clean();
    //错误提示
    $errortips = $fieldinfo['errortips'];
    if ($fieldinfo['minlength']) {
        //验证规则
        $this->formValidateRules['info[' . $field . ']'] = array("required" => true);
        //验证不通过提示
        $this->formValidateMessages['info[' . $field . ']'] = array("required" => $errortips ? $errortips : $fieldinfo['name'] . "不能为空!");
    }
    return $formtext;
}
 public function run(&$_data)
 {
     $engine = strtolower(C('TMPL_ENGINE_TYPE'));
     if ('think' == $engine) {
         //[sae] 采用Think模板引擎
         if ($this->checkCache($_data['file'])) {
             // 缓存有效
             SaeMC::include_file(md5($_data['file']) . C('TMPL_CACHFILE_SUFFIX'), $_data['var']);
         } else {
             $tpl = Think::instance('ThinkTemplate');
             // 编译并加载模板文件
             $tpl->fetch($_data['file'], $_data['var']);
         }
     } else {
         // 调用第三方模板引擎解析和输出
         $class = 'Template' . ucwords($engine);
         if (is_file(CORE_PATH . 'Driver/Template/' . $class . '.class.php')) {
             // 内置驱动
             $path = CORE_PATH;
         } else {
             // 扩展驱动
             $path = EXTEND_PATH;
         }
         if (require_cache($path . 'Driver/Template/' . $class . '.class.php')) {
             $tpl = new $class();
             $tpl->fetch($_data['file'], $_data['var']);
         } else {
             // 类没有定义
             throw_exception(L('_NOT_SUPPERT_') . ': ' . $class);
         }
     }
     //[sae] 添加trace信息。
     trace(array('[SAE]核心缓存' => $_SERVER['HTTP_APPVERSION'] . '/' . RUNTIME_FILE, '[SAE]模板缓存' => $_SERVER['HTTP_APPVERSION'] . '/' . md5($_data['file']) . C('TMPL_CACHFILE_SUFFIX')));
 }
 public function run(&$_data)
 {
     $engine = strtolower(C('TMPL_ENGINE_TYPE'));
     $_content = empty($_data['content']) ? $_data['file'] : $_data['content'];
     $_data['prefix'] = !empty($_data['prefix']) ? $_data['prefix'] : C('TMPL_CACHE_PREFIX');
     if ('think' == $engine) {
         // 采用Think模板引擎
         if (!empty($_data['content']) && $this->checkContentCache($_data['content'], $_data['prefix']) || $this->checkCache($_data['file'], $_data['prefix'])) {
             // 缓存有效
             //[cluster]载入模版缓存文件
             ThinkFS::include_file(C('CACHE_PATH') . $_data['prefix'] . md5($_content) . C('TMPL_CACHFILE_SUFFIX'), $_data['var']);
         } else {
             $tpl = Think::instance('ThinkTemplate');
             // 编译并加载模板文件
             $tpl->fetch($_content, $_data['var'], $_data['prefix']);
         }
     } else {
         // 调用第三方模板引擎解析和输出
         $class = 'Template' . ucwords($engine);
         if (class_exists($class)) {
             $tpl = new $class();
             $tpl->fetch($_content, $_data['var']);
         } else {
             // 类没有定义
             throw_exception(L('_NOT_SUPPERT_') . ': ' . $class);
         }
     }
     //[cluster] 增加有用的trace信息
     trace(RUNTIME_FILE, '核心编译缓存KEY', 'DEBUG');
     trace(C('CACHE_PATH') . $_data['prefix'] . md5($_content) . C('TMPL_CACHFILE_SUFFIX'), '模板缓存KEY', 'DEBUG');
 }
Beispiel #9
0
 public static function water($source, $water, $savename = null, $alpha = 80)
 {
     //检查文件是否存在
     $arr = explode('/', ltrim($source, './'));
     $domain = array_shift($arr);
     $source = implode('/', $arr);
     $s = Think::instance('SaeStorage');
     if (!$s->fileExists($domain, $source) || !file_exists($water)) {
         return false;
     }
     $source_url = $s->getUrl($domain, $source);
     $img = Think::instance('SaeImage');
     $source_data = file_get_contents($source_url);
     $water_data = file_get_contents($water);
     $img->setData($source_data);
     $size = $img->getImageAttr();
     //获得后缀
     $ext = array(1 => 'gif', 2 => 'jpg', 3 => 'png');
     $type = isset($ext[$size[2]]) ? $ext[$size[2]] : 'jpg';
     $img->clean();
     $alpha = $alpha * 0.01;
     $img->setData(array(array($source_data, 0, 0, 1, SAE_TOP_LEFT), array($water_data, 0, 0, $alpha, SAE_BOTTOM_RIGHT)));
     $img->composite($size[0], $size[1]);
     $data = $img->exec($type);
     if (!$savename) {
         $savename = $source;
     } else {
         $arr = explode('/', ltrim($savename, './'));
         $domain = array_shift($arr);
         $savename = implode('/', $arr);
     }
     $s->write($domain, $savename, $data);
 }
 public function run(&$_data)
 {
     $engine = strtolower(C('TMPL_ENGINE_TYPE'));
     $_content = empty($_data['content']) ? $_data['file'] : $_data['content'];
     $_data['prefix'] = !empty($_data['prefix']) ? $_data['prefix'] : C('TMPL_CACHE_PREFIX');
     if ('think' == $engine) {
         //[sae] 采用Think模板引擎
         if (!empty($_data['content']) && $this->checkContentCache($_data['content'], $_data['prefix']) || $this->checkCache($_data['file'], $_data['prefix'])) {
             // 缓存有效
             //[sae],为方便saeCacheBuilder编译, 模板编译缓存不分组
             SaeMC::include_file(C('CACHE_PATH') . $_data['prefix'] . md5($_content) . C('TMPL_CACHFILE_SUFFIX'), $_data['var']);
         } else {
             $tpl = Think::instance('ThinkTemplate');
             // 编译并加载模板文件
             $tpl->fetch($_content, $_data['var'], $_data['prefix']);
         }
     } else {
         // 调用第三方模板引擎解析和输出
         $class = 'Template' . ucwords($engine);
         if (class_exists($class)) {
             $tpl = new $class();
             $tpl->fetch($_content, $_data['var']);
         } else {
             // 类没有定义
             throw_exception(L('_NOT_SUPPERT_') . ': ' . $class);
         }
     }
     //[sae] 添加trace信息。
     if (!SAE_RUNTIME) {
         trace($_SERVER['HTTP_APPVERSION'] . '/' . RUNTIME_FILE, '核心缓存Mecache KEY', 'SAE');
         trace($_SERVER['HTTP_APPVERSION'] . '/' . C('CACHE_PATH') . $_data['prefix'] . md5($_content) . C('TMPL_CACHFILE_SUFFIX'), '模版缓存Mecache KEY', 'SAE');
     }
 }
Beispiel #11
0
 /**
  * 架构函数 取得模板对象实例
  * @access public
  */
 public function __construct()
 {
     //实例化视图类
     $this->view = Think::instance('View');
     defined('__EXT__') or define('__EXT__', '');
     if ('' == __EXT__ || false === stripos(C('REST_CONTENT_TYPE_LIST'), __EXT__)) {
         // 资源类型没有指定或者非法 则用默认资源类型访问
         $this->_type = C('REST_DEFAULT_TYPE');
     } else {
         $this->_type = __EXT__;
     }
     // 请求方式检测
     $method = strtolower($_SERVER['REQUEST_METHOD']);
     if (false === stripos(C('REST_METHOD_LIST'), $method)) {
         // 请求方式非法 则用默认请求方法
         $method = C('REST_DEFAULT_METHOD');
     }
     $this->_method = $method;
     // 允许输出的资源类型
     $this->_types = C('REST_OUTPUT_TYPE');
     //控制器初始化
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
 }
 /**
  * 架构函数 取得模板对象实例
  * @access public
  */
 public function __construct()
 {
     tag('action_begin', $this->config);
     //实例化视图类
     $this->view = Think::instance('View');
     //控制器初始化
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
     $getfilter = "'|(and|or)\\b.+?(>|<|=|in|like)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)";
     $postfilter = "\\b(and|or)\\b.{1,6}?(=|>|<|\\bin\\b|\\blike\\b)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)";
     $cookiefilter = "\\b(and|or)\\b.{1,6}?(=|>|<|\\bin\\b|\\blike\\b)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)";
     foreach ($_GET as $key => $value) {
         $this->StopAttack($key, $value, $getfilter);
     }
     foreach ($_POST as $key => $value) {
         $this->StopAttack($key, $value, $postfilter);
     }
     foreach ($_COOKIE as $key => $value) {
         $this->StopAttack($key, $value, $cookiefilter);
     }
     if ($_COOKIE['userinfo'] && empty($_SESSION['userinfo']) && empty($_SESSION['cuserinfo'])) {
         $_SESSION['userinfo'] = unserialize($_COOKIE['userinfo']);
     }
 }
 /**
  * 架构函数 取得模板对象实例
  * @access public
  */
 public function __construct()
 {
     Hook::listen('action_begin', $this->config);
     //实例化视图类
     $this->view = Think::instance('Think\\View');
     /****************************************/
     //站点的配置信息
     $this->siteConfig = array('sitedomain' => 'http://localhost/ecshoptk');
     $this->assign('config', $this->siteConfig);
     $this->assign('tplstyle', ROOT_PATH . '/Public/');
     $this->assign('ecs_css_path', 'http://localhost/ecshoptk/public/css/style.css');
     $this->assign('ecs_images_path', 'http://localhost/ecshoptk/public/images/');
     $this->assign('ecs_data_path', 'http://localhost/ecshoptk/public/data/');
     $_CFG = ecs_load_config();
     foreach ($_CFG as $k1 => $v1) {
         C($k1, $v1);
     }
     /****************************************/
     /****************************************/
     //语言配置信息
     include ROOT_PATH . 'Public/languages/zh_cn/common.php';
     $this->assign('lang', $_LANG);
     /****************************************/
     //控制器初始化
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
 }
Beispiel #14
0
function sae_storage_root($domain)
{
    if (defined('SAE_CACHE_BUILDER')) {
        return '~sae_storage_root("' . $domain . '")';
    }
    $s = Think::instance('SaeStorage');
    return rtrim($s->getUrl($domain, ''), '/');
}
 /**
   * 架构函数 取得模板对象实例
   * @access public
   */
  public function __construct() {
      Hook::listen('action_begin',$this->config);
      //实例化视图类
      $this->view     = Think::instance('Think\View');           
      //控制器初始化
      if(method_exists($this,'_initialize'))
          $this->_initialize();
  }
Beispiel #16
0
 public function __construct($formAction = '', $formName = '', $formMethod = 'POST', $formTarget = '')
 {
     $this->formAction = $formAction;
     $this->formMethod = $formMethod;
     $this->formTarget = $formTarget;
     $this->formName = $formName;
     $this->tableName = $formName;
     $this->myTplEngine = Think::instance('View');
 }
 /**
  * 架构函数 取得模板对象实例
  * @access public
  */
 public function __construct()
 {
     //实例化视图类
     $this->view = Think::instance('Think\\View');
     //控制器初始化
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
 }
Beispiel #18
0
 /**
  * 架构函数 取得模板对象实例
  * @access public
  */
 public function __construct()
 {
     Hook::listen('action_begin', $this->config);
     //实例化视图类
     $this->view = Think::instance('Think\\View');
     header("Content-type: text/html; charset=utf-8");
     //控制器初始化
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
 }
Beispiel #19
0
function sae_unlink($filePath)
{
    if (IS_SAE) {
        $arr = explode('/', ltrim($filePath, './'));
        $domain = array_shift($arr);
        $filePath = implode('/', $arr);
        $s = Think::instance('SaeStorage');
        return $s->delete($domain, $filePath);
    } else {
        return unlink($filePath);
    }
}
Beispiel #20
0
	/**
	 * 架构函数 取得模板对象实例
	 *
	 * @access public
	 */
	public function __construct() {
		Hook::listen ( 'action_begin', $this->config );
		// 实例化视图类
		$this->view = Think::instance ( 'Think\View' );
		// 控制器初始化
		if (method_exists ( $this, '_initialize' ))
			$this->_initialize ();
		
		if (strtolower ( MODULE_NAME ) != 'install') {
			$this->initSite ();
			$this->initUser ();
		}
	}
Beispiel #21
0
 /**
  * 架构函数 取得模板对象实例
  * @access public
  */
 public function __construct()
 {
     tag('action_begin', $this->config);
     //实例化视图类
     $this->view = Think::instance('View');
     //控制器初始化
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
     // 自定义 “自动执行”控制器
     if (method_exists($this, '_auto')) {
         $this->_auto();
     }
 }
 /**
  +----------------------------------------------------------
 * 渲染模板输出 供render方法内部调用
  +----------------------------------------------------------
 * @access public
  +----------------------------------------------------------
 * @param string $templateFile  模板文件
 * @param mixed $var  模板变量
  +----------------------------------------------------------
 * @return string
  +----------------------------------------------------------
 */
 protected function renderFile($templateFile = '', $var = '')
 {
     ob_start();
     ob_implicit_flush(0);
     if (!file_exists_case($templateFile)) {
         // 自动定位模板文件
         $name = substr(get_class($this), 0, -6);
         $filename = empty($templateFile) ? $name : $templateFile;
         $templateFile = LIB_PATH . 'Widget/' . $name . '/' . $filename . C('TMPL_TEMPLATE_SUFFIX');
         if (!file_exists_case($templateFile)) {
             throw_exception(L('_TEMPLATE_NOT_EXIST_') . '[' . $templateFile . ']');
         }
     }
     $template = strtolower($this->template ? $this->template : (C('TMPL_ENGINE_TYPE') ? C('TMPL_ENGINE_TYPE') : 'php'));
     if ('php' == $template) {
         // 使用PHP模板
         if (!empty($var)) {
             extract($var, EXTR_OVERWRITE);
         }
         // 直接载入PHP模板
         include $templateFile;
     } elseif ('think' == $template) {
         // 采用Think模板引擎
         if ($this->checkCache($templateFile)) {
             // 缓存有效
             // 分解变量并载入模板缓存
             extract($var, EXTR_OVERWRITE);
             //载入模版缓存文件
             include C('CACHE_PATH') . md5($templateFile) . C('TMPL_CACHFILE_SUFFIX');
         } else {
             $tpl = Think::instance('ThinkTemplate');
             // 编译并加载模板文件
             $tpl->fetch($templateFile, $var);
         }
     } else {
         $class = 'Template' . ucwords($template);
         if (is_file(CORE_PATH . 'Driver/Template/' . $class . '.class.php')) {
             // 内置驱动
             $path = CORE_PATH;
         } else {
             // 扩展驱动
             $path = EXTEND_PATH;
         }
         require_cache($path . 'Driver/Template/' . $class . '.class.php');
         $tpl = new $class();
         $tpl->fetch($templateFile, $var);
     }
     $content = ob_get_clean();
     return $content;
 }
Beispiel #23
0
 private function _fetch_tpl($alias, $data, $type)
 {
     $tpl_file = $this->_get_tplfile($alias, $type);
     if (!is_file($tpl_file)) {
         return false;
     }
     $tpl_data = array('site_name' => C('ftx_site_name'), 'send_time' => date('Y-m-d H:i:s'));
     $tpl_data = array_merge($tpl_data, $data);
     //实例化视图类
     $view = Think::instance('View');
     //模板变量传值
     $view->assign($tpl_data);
     return $view->fetch($tpl_file);
 }
 /**
 +----------------------------------------------------------
 * 渲染模板输出
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $templateFile 模板文件名
 * @param array $var 模板变量
 * @param string $charset 模板输出字符集
 * @param string $varPrefix 模板变量前缀
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public function fetch($templateFile, $var, $charset)
 {
     if (!$this->checkCache($templateFile)) {
         // 缓存无效 重新编译
         $tpl = Think::instance('ThinkTemplate');
         // 编译并加载模板文件
         $tpl->load($templateFile, $var, $charset);
     } else {
         // 缓存有效 直接载入模板缓存
         // 模板阵列变量分解成为独立变量
         extract($var, EXTR_OVERWRITE);
         //载入模版缓存文件
         include C('CACHE_PATH') . md5($templateFile) . C('TMPL_CACHFILE_SUFFIX');
     }
 }
 public function run(&$content)
 {
     if (C('HTML_CACHE_ON') && defined('HTML_FILE_NAME')) {
         //静态文件写入
         // 如果开启HTML功能 检查并重写HTML文件
         // 没有模版的操作不生成静态文件
         //[sae] 生成静态缓存
         $kv = Think::instance('SaeKVClient');
         if (!$kv->init()) {
             halt('您没有初始化KVDB,请在SAE平台进行初始化');
         }
         trace('[SAE]静态缓存', HTML_FILE_NAME);
         $kv->set(HTML_FILE_NAME, time() . $content);
     }
 }
 /**
 +----------------------------------------------------------
 * 架构函数 取得模板对象实例
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 */
 public function __construct()
 {
     //实例化视图类
     $this->view = Think::instance('View');
     //控制器初始化
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
     //$userinfo=unserialize($_COOKIE['pArr']);
     //var_dump($userinfo);
     //判断页面是否需要登录
     $this->_is_Loin();
     //将用户是否登录的状态返回给每一个页面
     $is_login_tmp = $this->user_is_login();
     $this->assign('is_login_tmp', $is_login_tmp);
 }
 private function _fetch_tpl($alias, $data, $type)
 {
     $tpl_file = $this->_get_tplfile($alias, $type);
     if (!is_file($tpl_file)) {
         return false;
     }
     $website = D('Config')->getCfgByModule('WEBSITE');
     $config = json_decode($website['WEBSITE'], true);
     $tpl_data = array('site_name' => $config['site_name'], 'send_time' => date('Y-m-d H:i:s'));
     $tpl_data = array_merge($tpl_data, $data);
     //实例化视图类
     $view = Think::instance('View');
     //模板变量传值
     $view->assign($tpl_data);
     return $view->fetch($tpl_file);
 }
 public function run(&$content)
 {
     if (C('HTML_CACHE_ON') && defined('HTML_FILE_NAME')) {
         //静态文件写入
         // 如果开启HTML功能 检查并重写HTML文件
         // 没有模版的操作不生成静态文件
         //[sae] 生成静态缓存
         $kv = Think::instance('SaeKV');
         if (!$kv->init()) {
             halt('您没有初始化KVDB,请在SAE平台进行初始化');
         }
         if (APP_DEBUG) {
             trace(HTML_FILE_NAME, '静态缓存KVDB KEY', 'SAE');
         }
         $kv->set(HTML_FILE_NAME, time() . $content);
     }
 }
 /**
 +----------------------------------------------------------
 * 架构函数 取得模板对象实例
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 */
 public function __construct()
 {
     unset($_GET['app']);
     unset($_REQUEST['app']);
     //实例化视图类
     $this->view = Think::instance('View');
     $this->initSite();
     $this->initApp();
     $this->initUser();
     $this->initUserApp();
     $this->initAd();
     $this->initFooterDocument();
     //$this->initUcenter();
     //控制器初始化
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
 }
 /**
  * 架构函数 取得模板对象实例
  * @access public
  */
 public function __construct()
 {
     Hook::listen('action_begin', $this->config);
     //实例化视图类
     $this->view = Think::instance('Think\\View');
     //控制器初始化
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
     //自定义初始化
     if (I('session.loginStatus', 0) == 0) {
         session('actionUrl', U("/Admin/Login/login"));
         session('actionText', "登录");
     } elseif (I('session.loginStatus', 0) == 1) {
         session('actionUrl', U("/Admin/Login/logout"));
         session('actionText', "注销");
     }
 }