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));
 }
 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);
         }
     }
 }
Beispiel #3
0
/**
 * 万能字段字段类型表单处理
 * @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;
}
Beispiel #4
0
 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);
 }
Beispiel #5
0
 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';
     }
 }
 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);
 }
Beispiel #7
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();
     }
 }
Beispiel #8
0
 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'));
 }
Beispiel #9
0
 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';
     }
 }
Beispiel #10
0
 /**
  * 构造函数
  */
 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';
     }
 }
Beispiel #11
0
 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};
         }
     }
 }
 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();
     }
 }
 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);
         }
     }
 }
Beispiel #14
0
 /**
  * 渲染模板输出
  * @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);
 }
Beispiel #15
0
 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);
 }
Beispiel #16
0
 /**
  * 渲染模板输出 供render方法内部调用
  * @access public
  * @param string $templateFile  模板文件
  * @return string
  */
 protected function renderFile($templateFile = '')
 {
     if (!file_exists_case($templateFile)) {
         // 自动定位模板文件
         $className = explode('\\', get_called_class());
         //行为名
         $behaviorName = str_replace('Behavior', '', end($className));
         //获取模板文件名称
         $filename = empty($templateFile) ? $behaviorName : $templateFile;
         $moduleName = $className[0];
         $templateFile = APP_PATH . $moduleName . '/Behavior/' . $behaviorName . '/' . $filename . C('TMPL_TEMPLATE_SUFFIX');
         if (!file_exists_case($templateFile)) {
             E(L('_TEMPLATE_NOT_EXIST_') . '[' . $templateFile . ']');
         }
     }
     $tpl = \Think\Think::instance('Think\\View');
     $tpl->assign($this->tVar);
     return $tpl->fetch($templateFile);
 }
 /**
  * 检查静态HTML文件是否有效
  * 如果无效需要重新更新
  * @access public
  * @param string $cacheFile  静态文件名
  * @param integer $cacheTime  缓存有效期
  * @return boolean
  */
 public static function checkHTMLCache($cacheFile = '', $cacheTime = '')
 {
     if (!is_file($cacheFile) && 'sae' != APP_MODE) {
         return false;
     } elseif (filemtime(\Think\Think::instance('Think\\View')->parseTemplate()) > self::fileMTime($cacheFile)) {
         // 模板文件如果更新静态文件需要更新
         return false;
     } elseif (!is_numeric($cacheTime) && is_callable($cacheTime)) {
         return $cacheTime($cacheFile);
     } elseif ($cacheTime != 0 && NOW_TIME > self::fileMTime($cacheFile) + $cacheTime) {
         // 文件是否在有效期
         return false;
     }
     //静态文件有效
     return true;
 }
?>
    </ul>
  </div>
  <div style="clear:both"></div>
</div>
<div class="big_ad1" style="padding: 0;"> 
  <img src="http://lorempixel.com/970/102" />
</div>
<div class="art_pic">
  <h2><span class="more right"><a href="<?php 
echo getCategory(8, 'url');
?>
">更多>></a></span><span class="h2_txt">设计欣赏/artist</span></h2>
  <ul>
    <?php 
$content_tag = \Think\Think::instance("\\Content\\TagLib\\Content");
if (method_exists($content_tag, "lists")) {
    $data = $content_tag->lists(array('action' => 'lists', 'catid' => '8', 'order' => 'id DESC', 'num' => '4', 'page' => '0', 'pagefun' => 'page', 'return' => 'data'));
}
if (is_array($data)) {
    $i = 0;
    $__LIST__ = $data;
    if (count($__LIST__) == 0) {
        echo "";
    } else {
        foreach ($__LIST__ as $key => $vo) {
            $mod = $i % 2;
            ++$i;
            ?>
<li><a href="<?php 
            echo $vo["url"];
 /**
  * TagLib库解析
  * @access public
  * @param string $tagLib 要解析的标签库
  * @param string $content 要解析的模板内容
  * @param boolen $hide 是否隐藏标签库前缀
  * @return string
  */
 public function parseTagLib($tagLib, &$content, $hide = false)
 {
     $begin = $this->config['taglib_begin'];
     $end = $this->config['taglib_end'];
     if (strpos($tagLib, '\\')) {
         // 支持指定标签库的命名空间
         $className = $tagLib;
         $tagLib = substr($tagLib, strrpos($tagLib, '\\') + 1);
     } else {
         $className = 'Think\\Template\\TagLib\\' . ucwords($tagLib);
     }
     $tLib = \Think\Think::instance($className);
     $that = $this;
     foreach ($tLib->getTags() as $name => $val) {
         $tags = array($name);
         if (isset($val['alias'])) {
             // 别名设置
             $tags = explode(',', $val['alias']);
             $tags[] = $name;
         }
         $level = isset($val['level']) ? $val['level'] : 1;
         $closeTag = isset($val['close']) ? $val['close'] : true;
         foreach ($tags as $tag) {
             $parseTag = !$hide ? $tagLib . ':' . $tag : $tag;
             // 实际要解析的标签名称
             if (!method_exists($tLib, '_' . $tag)) {
                 // 别名可以无需定义解析方法
                 $tag = $name;
             }
             $n1 = empty($val['attr']) ? '(\\s*?)' : '\\s([^' . $end . ']*)';
             $this->tempVar = array($tagLib, $tag);
             if (!$closeTag) {
                 $patterns = '/' . $begin . $parseTag . $n1 . '\\/(\\s*?)' . $end . '/is';
                 $content = preg_replace_callback($patterns, function ($matches) use($tLib, $tag, $that) {
                     return $that->parseXmlTag($tLib, $tag, $matches[1], $matches[2]);
                 }, $content);
             } else {
                 $patterns = '/' . $begin . $parseTag . $n1 . $end . '(.*?)' . $begin . '\\/' . $parseTag . '(\\s*?)' . $end . '/is';
                 for ($i = 0; $i < $level; $i++) {
                     $content = preg_replace_callback($patterns, function ($matches) use($tLib, $tag, $that) {
                         return $that->parseXmlTag($tLib, $tag, $matches[1], $matches[2]);
                     }, $content);
                 }
             }
         }
     }
 }
Beispiel #20
0
 public function start()
 {
     // 应用初始化
     Think::start();
 }
 /**
  * 检查静态HTML文件是否有效
  * 如果无效需要重新更新
  * @access public
  * @param string $cacheFile  静态文件名
  * @param integer $cacheTime  缓存有效期
  * @return boolean
  */
 public static function checkHTMLCache($cacheFile = '', $cacheTime = '')
 {
     if (!is_file($cacheFile) && 'sae' != APP_MODE) {
         return false;
     } elseif (filemtime(\Think\Think::instance('Think\\View')->parseTemplate()) > Storage::get($cacheFile, 'mtime', 'html')) {
         // 模板文件如果更新静态文件需要更新
         return false;
     } elseif (!is_numeric($cacheTime) && function_exists($cacheTime)) {
         return $cacheTime($cacheFile);
     } elseif ($cacheTime != 0 && NOW_TIME > Storage::get($cacheFile, 'mtime', 'html') + $cacheTime) {
         // 文件是否在有效期
         return false;
     }
     //静态文件有效
     return true;
 }
Beispiel #22
0
 /**
  * 架构函数
  * 
  * @access public
  */
 public function __construct()
 {
     $this->tagLib = strtolower(substr(get_class($this), 6));
     $this->tpl = \Think\Think::instance('Think\\Template');
 }
Beispiel #23
0
 /**
  * TagLib库解析
  * @access public
  * @param  string $tagLib 要解析的标签库
  * @param  string $content 要解析的模板内容
  * @param  boolean $hide 是否隐藏标签库前缀
  * @return void
  */
 public function parseTagLib($tagLib, &$content, $hide = false)
 {
     if (strpos($tagLib, '\\')) {
         // 支持指定标签库的命名空间
         $className = $tagLib;
         $tagLib = substr($tagLib, strrpos($tagLib, '\\') + 1);
     } else {
         $className = 'Think\\Template\\TagLib\\' . ucwords($tagLib);
     }
     $tagLib = strtolower($tagLib);
     \Think\Think::instance($className)->parseTag($content, $hide ? '' : $tagLib);
     return;
 }
Beispiel #24
0
 /**
  * 执行安装脚本
  * @param type $moduleName 模块名(目录名)
  * @return boolean
  */
 private function runInstallScriptEnd($moduleName = '', $Dir = 'Install')
 {
     if (empty($moduleName)) {
         if ($this->moduleName) {
             $moduleName = $this->moduleName;
         } else {
             $this->error = '模块名称不能为空!';
             return false;
         }
     }
     //检查是否有安装脚本
     if (require_cache($this->appPath . "{$moduleName}/{$Dir}/{$Dir}.class.php") !== true) {
         return true;
     }
     $className = "\\{$moduleName}\\{$Dir}\\{$Dir}";
     $installObj = \Think\Think::instance($className);
     //执行安装
     if (false == $installObj->end()) {
         $this->error = $installObj->getError();
         return false;
     }
     return true;
 }
Beispiel #25
0
    defined('APP_MODE') or define('APP_MODE', 'common');
    // 应用模式 默认为普通模式
    defined('STORAGE_TYPE') or define('STORAGE_TYPE', 'File');
    // 存储类型 默认为File
}
defined('RUNTIME_PATH') or define('RUNTIME_PATH', APP_PATH . 'Runtime/');
// 系统运行时目录
// 系统常量定义
defined('THINK_PATH') or define('THINK_PATH', __DIR__ . '/');
defined('LIB_PATH') or define('LIB_PATH', realpath(THINK_PATH . 'Library') . '/');
// 系统核心类库目录
defined('CORE_PATH') or define('CORE_PATH', LIB_PATH . 'Think/');
// Think类库目录
defined('BEHAVIOR_PATH') or define('BEHAVIOR_PATH', LIB_PATH . 'Behavior/');
// 行为类库目录
defined('COMMON_PATH') or define('COMMON_PATH', APP_PATH . 'Common/');
// 应用公共目录
defined('CONF_PATH') or define('CONF_PATH', COMMON_PATH . 'Conf/');
// 应用配置目录
defined('MODE_PATH') or define('MODE_PATH', THINK_PATH . 'Mode/');
// 系统应用模式目录
defined('CONF_EXT') or define('CONF_EXT', '.php');
// 配置文件后缀
defined('CONF_PARSE') or define('CONF_PARSE', '');
// 配置文件解析方法
define('IS_CLI', PHP_SAPI == 'cli' ? 1 : 0);
// 加载核心Think类
require CORE_PATH . 'Think' . EXT;
// 应用初始化
\Think\Think::start();