Esempio n. 1
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;
}
Esempio n. 2
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);
 }
 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);
         }
     }
 }
Esempio n. 4
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);
 }
Esempio n. 6
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();
     }
 }
Esempio n. 7
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'));
 }
Esempio n. 8
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';
     }
 }
Esempio n. 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';
     }
 }
Esempio n. 10
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(&$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);
         }
     }
 }
Esempio n. 12
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);
 }
Esempio n. 13
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);
 }
Esempio n. 14
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);
 }
 /**
  * 检查静态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;
 }
Esempio n. 16
0
 /**
  * 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);
                 }
             }
         }
     }
 }
 /**
  * 检查静态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;
 }
Esempio n. 18
0
 /**
  * 架构函数
  * 
  * @access public
  */
 public function __construct()
 {
     $this->tagLib = strtolower(substr(get_class($this), 6));
     $this->tpl = \Think\Think::instance('Think\\Template');
 }
Esempio n. 19
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;
 }
?>
    </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"];
Esempio n. 21
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;
 }