當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Think類代碼示例

本文整理匯總了PHP中Think的典型用法代碼示例。如果您正苦於以下問題:PHP Think類的具體用法?PHP Think怎麽用?PHP Think使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Think類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 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);
         }
     }
 }
開發者ID:yunsite,項目名稱:e-tuan001-com,代碼行數:35,代碼來源:ParseTemplateBehavior.class.php

示例2: __construct

 /**
  * 架構函數 取得模板對象實例
  * @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();
     }
 }
開發者ID:highestgoodlikewater,項目名稱:ecshoptk,代碼行數:32,代碼來源:Controller.class.php

示例3: __construct

 /**
  * 架構函數 取得模板對象實例
  * @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']);
     }
 }
開發者ID:xiaoyueer98,項目名稱:wap.rrl.com,代碼行數:29,代碼來源:Action.class.php

示例4: run

 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')));
 }
開發者ID:nexteee,項目名稱:php,代碼行數:34,代碼來源:ParseTemplateBehavior.class.php

示例5: run

 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');
 }
開發者ID:xibaachao,項目名稱:1bz,代碼行數:31,代碼來源:ParseTemplateBehavior.class.php

示例6: fetch

 /**
 +----------------------------------------------------------
 * 渲染模板輸出
 +----------------------------------------------------------
 * @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);
 }
開發者ID:xiaoyueer98,項目名稱:m-heimiwifi-com,代碼行數:21,代碼來源:TemplateThink.class.php

示例7: __construct

 /**
  * 架構函數 取得模板對象實例
  * @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();
     }
 }
開發者ID:cnn007,項目名稱:FHCRM,代碼行數:29,代碼來源:Action.class.php

示例8: run

 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);
         }
     }
 }
開發者ID:ljhchshm,項目名稱:weixin,代碼行數:30,代碼來源:ParseTemplateBehavior.class.php

示例9: omnipotent

/**
 * 萬能字段字段類型表單處理
 * @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;
}
開發者ID:NeilFee,項目名稱:vipxinbaigo,代碼行數:39,代碼來源:form.inc.php

示例10: water

 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);
 }
開發者ID:yaks,項目名稱:weixinshop,代碼行數:33,代碼來源:Image_sae.class.php

示例11: run

 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');
     }
 }
開發者ID:jackycgq,項目名稱:extend,代碼行數:33,代碼來源:ParseTemplateBehavior.class.php

示例12: Instance

 public static function Instance()
 {
     if (!self::$_instance) {
         self::$_instance = new Think();
     }
     return self::$_instance;
 }
開發者ID:beerdude26,項目名稱:NewNova,代碼行數:7,代碼來源:class_think.php

示例13: __construct

 /**
  * 架構函數 取得模板對象實例
  * @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();
     }
 }
開發者ID:chenyongze,項目名稱:bighaha,代碼行數:36,代碼來源:Controller.class.php

示例14: __construct

 public function __construct()
 {
     $this->mid = $_SESSION['mid'];
     $this->model = model("AddonData");
     $this->view = Think::instance('View');
     $this->start();
 }
開發者ID:armebayelm,項目名稱:thinksns-vietnam,代碼行數:7,代碼來源:AbstractAddons.class.php

示例15: sae_storage_root

function sae_storage_root($domain)
{
    if (defined('SAE_CACHE_BUILDER')) {
        return '~sae_storage_root("' . $domain . '")';
    }
    $s = Think::instance('SaeStorage');
    return rtrim($s->getUrl($domain, ''), '/');
}
開發者ID:ysking,項目名稱:commlib,代碼行數:8,代碼來源:sae_common.php


注:本文中的Think類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。