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


PHP think\Think類代碼示例

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


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

示例1: run

 public function run(&$params)
 {
     if (!defined('BUILD_LITE_FILE')) {
         return;
     }
     $litefile = C('RUNTIME_LITE_FILE', null, RUNTIME_PATH . 'lite.php');
     if (is_file($litefile)) {
         return;
     }
     $defs = get_defined_constants(true);
     $content = 'namespace {$GLOBALS[\'_beginTime\'] = microtime(TRUE);';
     if (MEMORY_LIMIT_ON) {
         $content .= '$GLOBALS[\'_startUseMems\'] = memory_get_usage();';
     }
     // 生成數組定義
     unset($defs['user']['BUILD_LITE_FILE']);
     $content .= $this->buildArrayDefine($defs['user']) . '}';
     // 讀取編譯列表文件
     $filelist = is_file(CONF_PATH . 'lite.php') ? include CONF_PATH . 'lite.php' : array(THINK_PATH . 'Common/functions.php', COMMON_PATH . 'Common/function.php', CORE_PATH . 'Think' . EXT, CORE_PATH . 'Hook' . EXT, CORE_PATH . 'App' . EXT, CORE_PATH . 'Dispatcher' . EXT, CORE_PATH . 'Log' . EXT, CORE_PATH . 'Log/Driver/File' . EXT, CORE_PATH . 'Route' . EXT, CORE_PATH . 'Controller' . EXT, CORE_PATH . 'View' . EXT, CORE_PATH . 'Storage' . EXT, CORE_PATH . 'Storage/Driver/File' . EXT, CORE_PATH . 'Exception' . EXT, BEHAVIOR_PATH . 'ParseTemplateBehavior' . EXT, BEHAVIOR_PATH . 'ContentReplaceBehavior' . EXT);
     // 編譯文件
     foreach ($filelist as $file) {
         if (is_file($file)) {
             $content .= compile($file);
         }
     }
     // 處理Think類的start方法
     $content = preg_replace('/\\$runtimefile = RUNTIME_PATH(.+?)(if\\(APP_STATUS)/', '\\2', $content, 1);
     $content .= "\nnamespace { Think\\Think::addMap(" . var_export(\Think\Think::getMap(), true) . ");";
     $content .= "\nL(" . var_export(L(), true) . ");\nC(" . var_export(C(), true) . ');Think\\Hook::import(' . var_export(\Think\Hook::get(), true) . ');Think\\Think::start();}';
     // 生成運行Lite文件
     file_put_contents($litefile, strip_whitespace('<?php ' . $content));
 }
開發者ID:beyondzgz,項目名稱:thinkphp,代碼行數:32,代碼來源:BuildLiteBehavior.class.php

示例2: 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'])) {
             // 緩存有效
             //載入模版緩存文件
             Storage::load(C('CACHE_PATH') . $_data['prefix'] . md5($_content) . C('TMPL_CACHFILE_SUFFIX'), $_data['var'], 'tpl');
         } else {
             $tpl = Think::instance('Think\\Template');
             // 編譯並加載模板文件
             $tpl->fetch($_content, $_data['var'], $_data['prefix']);
         }
     } else {
         // 調用第三方模板引擎解析和輸出
         if (strpos($engine, '\\')) {
             $class = $engine;
         } else {
             $class = 'Think\\Template\\Driver\\' . ucwords($engine);
         }
         if (class_exists($class)) {
             $tpl = new $class();
             $tpl->fetch($_content, $_data['var']);
         } else {
             // 類沒有定義
             E(L('_NOT_SUPPORT_') . ': ' . $class);
         }
     }
 }
開發者ID:Backflag,項目名稱:weiphp2.0.1202,代碼行數:32,代碼來源:ParseTemplateBehavior.class.php

示例3: omnipotent

/**
 * 萬能字段字段類型表單處理
 * @param type $field 字段名 
 * @param type $value 字段內容
 * @param type $fieldinfo 字段配置
 * @return type
 */
function omnipotent($field, $value, $fieldinfo)
{
    $view = \Think\Think::instance('\\Think\\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:sandom123,項目名稱:king400,代碼行數:39,代碼來源:form.inc.php

示例4: __construct

 public function __construct()
 {
     $this->view = \Think\Think::instance('Think\\View');
     $this->plugin_path = './plugins/' . $this->getName() . '/';
     //多語言
     if (C('LANG_SWITCH_ON', null, false)) {
         $lang_file = $this->plugin_path . "Lang/" . LANG_SET . ".php";
         if (is_file($lang_file)) {
             $lang = (include $lang_file);
             L($lang);
         }
     }
     $TMPL_PARSE_STRING = C('TMPL_PARSE_STRING');
     $plugin_root = __ROOT__ . '/plugins/' . $this->getName();
     $TMPL_PARSE_STRING['__PLUGINROOT__'] = $plugin_root;
     if (is_file($this->plugin_path . 'config.php')) {
         $this->config_file = $this->plugin_path . 'config.php';
     }
     $config = $this->getConfig();
     $theme = $config['theme'];
     $depr = "/";
     $theme = empty($theme) ? "" : $theme . $depr;
     $v_layer = C("DEFAULT_V_LAYER");
     $this->tmpl_root = "plugins/" . $this->getName() . "/{$v_layer}/" . $theme;
     $TMPL_PARSE_STRING['__PLUGINTMPL__'] = __ROOT__ . "/" . $this->tmpl_root;
     C('TMPL_PARSE_STRING', $TMPL_PARSE_STRING);
 }
開發者ID:feng8605765,項目名稱:xmmusic,代碼行數:27,代碼來源:Plugin.class.php

示例5: __construct

 public function __construct()
 {
     $this->view = \Think\Think::instance('Think\\View');
     $this->addon_path = ONETHINK_ADDON_PATH . $this->getName() . '/';
     if (is_file($this->addon_path . 'config.php')) {
         $this->config_file = $this->addon_path . 'config.php';
     }
 }
開發者ID:jayfjso,項目名稱:pinsen,代碼行數:8,代碼來源:Addon.class.php

示例6: __construct

 public function __construct()
 {
     $this->view = \Think\Think::instance('Think\\View');
     // $this->addon_path   =   ONETHINK_ADDON_PATH.$this->getName().'/';
     // $TMPL_PARSE_STRING = C('TMPL_PARSE_STRING');
     // $TMPL_PARSE_STRING['__ADDONROOT__'] = __ROOT__ . '/Addons/'.$this->getName();
     // C('TMPL_PARSE_STRING', $TMPL_PARSE_STRING);
 }
開發者ID:Luckyseal,項目名稱:amango,代碼行數:8,代碼來源:AddonsController.class.php

示例7: __construct

 /**
  * 架構函數 取得模板對象實例
  * @access public
  */
 public function __construct()
 {
     Hook::listen('action_begin', $this->config);
     //實例化視圖類
     $this->view = Think::instance('Think\\View');
     //控製器初始化
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
 }
開發者ID:Chocol,項目名稱:think-phpunit,代碼行數:14,代碼來源:Controller.php

示例8: insert_content

 public function insert_content($dynamic = false)
 {
     $Template = Think::instance('Think\\Template');
     $templateFile = $this->load_template_file();
     if ($dynamic) {
         $this->export_theme_link($this->name, $this->theme);
     }
     // 視圖解析標簽
     $Template->fetch($templateFile, $this->view->get(), C('TMPL_CACHE_PREFIX'));
 }
開發者ID:HarrryStudio,項目名稱:microweb,代碼行數:10,代碼來源:Widget.class.php

示例9: _initialize

 protected function _initialize()
 {
     $this->view = \Think\Think::instance('Think\\View');
     $this->addon_path = ADDONS_PATH . $this->getName() . '/View/';
     $TMPL_PARSE_STRING = C('TMPL_PARSE_STRING');
     $TMPL_PARSE_STRING['__ADDONROOT__'] = ADDONS_PATH . $this->getName();
     C('TMPL_PARSE_STRING', $TMPL_PARSE_STRING);
     if (is_file($this->addon_path . 'config.php')) {
         $this->config_file = $this->addon_path . 'config.php';
     }
 }
開發者ID:735579768,項目名稱:Ainiku,代碼行數:11,代碼來源:Plugin.class.php

示例10: __construct

 /**
  * 構造函數
  */
 public function __construct()
 {
     $this->view = \Think\Think::instance('Think\\View');
     $this->addon_path = ADDON_PATH . $this->getName . '/';
     $TMPL_PARSE_STRING = C('TMPL_PARSE_STRING');
     $TMPL_PARSE_STRING['__ADDONROOT__'] = __APP__ . '/Addons/' . $this->getName();
     C('TMPL_PARSE_STRING', $TMPL_PARSE_STRING);
     if (is_file($this->addon_path . 'config.php')) {
         $this->config_file = $this->addon_path . 'config.php';
     }
 }
開發者ID:925800521,項目名稱:itskycms,代碼行數:14,代碼來源:Addon.class.php

示例11: __get

 public function __get($name)
 {
     if (isset(self::$_components[$name])) {
         $components = self::$_components[$name];
         if (!empty($components['class'])) {
             $class = $components['class'];
             if ($components['path'] && !class_exists($class, false)) {
                 import($components['path'], PROJECT_PATH);
             }
             unset($components['class'], $components['path']);
             $this->{$name} = \Think\Think::instance($class);
             return $this->{$name};
         }
     }
 }
開發者ID:sandom123,項目名稱:king400,代碼行數:15,代碼來源:Components.class.php

示例12: run

 public function run(&$params)
 {
     if (IS_CLI) {
         if (!function_exists('pcntl_signal')) {
             E("pcntl_signal not working.\nRepl mode based on Linux OS or PHP for OS X(http://php-osx.liip.ch/)\n");
         }
         Think::addMap(array('Boris\\Boris' => VENDOR_PATH . 'Boris/Boris.php', 'Boris\\Config' => VENDOR_PATH . 'Boris/Config.php', 'Boris\\CLIOptionsHandler' => VENDOR_PATH . 'Boris/CLIOptionsHandler.php', 'Boris\\ColoredInspector' => VENDOR_PATH . 'Boris/ColoredInspector.php', 'Boris\\DumpInspector' => VENDOR_PATH . 'Boris/DumpInspector.php', 'Boris\\EvalWorker' => VENDOR_PATH . 'Boris/EvalWorker.php', 'Boris\\ExportInspector' => VENDOR_PATH . 'Boris/ExportInspector.php', 'Boris\\Inspector' => VENDOR_PATH . 'Boris/Inspector.php', 'Boris\\ReadlineClient' => VENDOR_PATH . 'Boris/ReadlineClient.php', 'Boris\\ShallowParser' => VENDOR_PATH . 'Boris/ShallowParser.php'));
         $boris = new \Boris\Boris(">>> ");
         $config = new \Boris\Config();
         $config->apply($boris, true);
         $options = new \Boris\CLIOptionsHandler();
         $options->handle($boris);
         $boris->onStart(sprintf("echo 'REPL MODE FOR THINKPHP \nTHINKPHP_VERSION: %s, PHP_VERSION: %s, BORIS_VERSION: %s\n';", THINK_VERSION, PHP_VERSION, $boris::VERSION));
         $boris->start();
     }
 }
開發者ID:tiger2soft,項目名稱:ThinkAdmin,代碼行數:16,代碼來源:BorisBehavior.class.php

示例13: run

 public function run(&$templateFile)
 {
     if (C('CTPL_SWITCH_ON') == TRUE) {
         $view = \Think\Think::instance('Think\\View');
         $File = $view->parseTemplate($templateFile);
         if (!empty($File) && !is_file($File)) {
             $ctpl_data_path = str_replace('__COMMON_PATH__', COMMON_PATH, C('CTPL_DATA_PATH'));
             $dir = pathinfo($File);
             if (!is_dir($dir['dirname'])) {
                 mkdir($dir['dirname'], 0755, TRUE);
             }
             $content = !empty($ctpl_data_path) && is_file($ctpl_data_path) ? file_get_contents($ctpl_data_path) : '';
             file_put_contents($File, $content);
         }
     }
 }
開發者ID:baiy,項目名稱:login,代碼行數:16,代碼來源:AutoCreateTemplateBehavior.class.php

示例14: fetch

 /**
  * 渲染模板輸出
  * @param string $templateFile 模板文件名
  * @param array  $parameters   模板變量
  */
 public function fetch($templateFile, $parameters)
 {
     $view = Think::instance('Think\\View');
     $error_tpl = $view->parseTemplate(C('TMPL_ACTION_ERROR'));
     $success_tpl = $view->parseTemplate(C('TMPL_ACTION_SUCcESS'));
     if ($error_tpl === $templateFile || $success_tpl === $templateFile) {
         if (pathinfo($templateFile, PATHINFO_EXTENSION) !== 'twig') {
             $tpl = Think::instance('Think\\Template');
             echo $tpl->fetch($templateFile, $parameters);
             return;
         }
     }
     $templateFile = substr($templateFile, strlen(THEME_PATH));
     $twig = self::getInstance();
     echo $twig->render($templateFile, $parameters);
 }
開發者ID:motsqueen,項目名稱:think-twig,代碼行數:21,代碼來源:Twig.class.php

示例15: __construct

 public function __construct()
 {
     $this->view = \Think\Think::instance('Think\\View');
     $this->plugin_path = './plugins/' . $this->getName() . '/';
     $TMPL_PARSE_STRING = C('TMPL_PARSE_STRING');
     $plugin_root = __ROOT__ . '/plugins/' . $this->getName();
     $TMPL_PARSE_STRING['__PLUGINROOT__'] = $plugin_root;
     if (is_file($this->plugin_path . 'config.php')) {
         $this->config_file = $this->plugin_path . 'config.php';
     }
     $config = $this->getConfig();
     $theme = $config['theme'];
     $depr = "/";
     $theme = empty($theme) ? "" : $theme . $depr;
     $v_layer = C("DEFAULT_V_LAYER");
     $this->tmpl_root = "plugins/" . $this->getName() . "/{$v_layer}/" . $theme;
     $TMPL_PARSE_STRING['__PLUGINTMPL__'] = __ROOT__ . "/" . $this->tmpl_root;
     C('TMPL_PARSE_STRING', $TMPL_PARSE_STRING);
 }
開發者ID:xiaoxianlink,項目名稱:weixin,代碼行數:19,代碼來源:Plugin.class.php


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