【类 型】:
【原 因】: 【过 程】: 【影 响】:
This commit is contained in:
parent
884e824710
commit
5fe976590a
@ -108,7 +108,7 @@ class CheckController extends PublicController
|
|||||||
exit(); //有问题跳出
|
exit(); //有问题跳出
|
||||||
}
|
}
|
||||||
|
|
||||||
//后台校验 运费 打包费 和 前端提交值 ps:目前和商铺表 里的运费 打包费进行比较 后续可能要根据比如运输距离 商户根据订单单独修改的值 进行对比
|
//后台校验 运费 打包费 和 前端提交值 ps:目前和单位表 里的运费 打包费进行比较 后续可能要根据比如运输距离 商户根据订单单独修改的值 进行对比
|
||||||
$shopDb = D('shop');
|
$shopDb = D('shop');
|
||||||
$whereShop['shop_id'] = $_REQUEST['shop_id'];
|
$whereShop['shop_id'] = $_REQUEST['shop_id'];
|
||||||
$shop = $shopDb->where($whereShop)->find();
|
$shop = $shopDb->where($whereShop)->find();
|
||||||
|
@ -90,7 +90,7 @@ class NormalController extends PublicController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @description: 获取商铺信息
|
* @description: 获取单位信息
|
||||||
*/
|
*/
|
||||||
public function getShopCon()
|
public function getShopCon()
|
||||||
{
|
{
|
||||||
@ -99,7 +99,7 @@ class NormalController extends PublicController
|
|||||||
if ($shopCon = $shopDb->where($where)->find()) {
|
if ($shopCon = $shopDb->where($where)->find()) {
|
||||||
echo json_encode(array('status' => 1, 'msg' => '访问成功', "shopCon" => $shopCon));
|
echo json_encode(array('status' => 1, 'msg' => '访问成功', "shopCon" => $shopCon));
|
||||||
} else {
|
} else {
|
||||||
echo json_encode(array('status' => 0, 'msg' => '暂无商铺信息'));
|
echo json_encode(array('status' => 0, 'msg' => '暂无单位信息'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ class PayController extends PublicController
|
|||||||
$fieldShop = array('price_min', 'weight_max');
|
$fieldShop = array('price_min', 'weight_max');
|
||||||
$shopDb = D('shop');
|
$shopDb = D('shop');
|
||||||
if (!$shop = $shopDb->where($whereShop)->field($fieldShop)->find()) {
|
if (!$shop = $shopDb->where($whereShop)->field($fieldShop)->find()) {
|
||||||
echo json_encode(array('status' => 0, 'msg' => '商铺不存在'));
|
echo json_encode(array('status' => 0, 'msg' => '单位不存在'));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
if ($order['openid'] != $this->openid || (float)$order['total_price'] < (float)$shop['price_min'] || $order['total_weight'] > $shop['weight_max']) {
|
if ($order['openid'] != $this->openid || (float)$order['total_price'] < (float)$shop['price_min'] || $order['total_weight'] > $shop['weight_max']) {
|
||||||
|
@ -9,7 +9,7 @@ class AdminController extends PublicController
|
|||||||
echo "hello wolrd";
|
echo "hello wolrd";
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @description: 获取商铺列表
|
* @description: 获取单位列表
|
||||||
*/
|
*/
|
||||||
public function getShopList()
|
public function getShopList()
|
||||||
{
|
{
|
||||||
@ -21,11 +21,11 @@ class AdminController extends PublicController
|
|||||||
if ($shopList = $shopDb->where($where)->select()) {
|
if ($shopList = $shopDb->where($where)->select()) {
|
||||||
echo json_encode(array('status' => 1, 'msg' => '访问成功', "shopList" => $shopList));
|
echo json_encode(array('status' => 1, 'msg' => '访问成功', "shopList" => $shopList));
|
||||||
} else {
|
} else {
|
||||||
echo json_encode(array('status' => 0, 'msg' => '暂无商铺数据'));
|
echo json_encode(array('status' => 0, 'msg' => '暂无单位数据'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @description: 商铺添加
|
* @description: 单位添加
|
||||||
*/
|
*/
|
||||||
public function addShop()
|
public function addShop()
|
||||||
{
|
{
|
||||||
@ -78,7 +78,7 @@ class AdminController extends PublicController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @description: 商铺更新
|
* @description: 单位更新
|
||||||
*/
|
*/
|
||||||
public function saveShop()
|
public function saveShop()
|
||||||
{
|
{
|
||||||
@ -455,7 +455,7 @@ class AdminController extends PublicController
|
|||||||
*/
|
*/
|
||||||
public function deleteMessage()
|
public function deleteMessage()
|
||||||
{
|
{
|
||||||
// 权限判断(总管理员可操作所有商铺)
|
// 权限判断(总管理员可操作所有单位)
|
||||||
if ($this->tokenShop_id != C('powerId')) {
|
if ($this->tokenShop_id != C('powerId')) {
|
||||||
$where['shop_id'] = $this->tokenShop_id;
|
$where['shop_id'] = $this->tokenShop_id;
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,16 @@
|
|||||||
// | Author: liu21st <liu21st@gmail.com>
|
// | Author: liu21st <liu21st@gmail.com>
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
namespace Behavior;
|
namespace Behavior;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统行为扩展:模板内容输出替换
|
* 系统行为扩展:模板内容输出替换
|
||||||
*/
|
*/
|
||||||
class ContentReplaceBehavior {
|
class ContentReplaceBehavior
|
||||||
|
{
|
||||||
|
|
||||||
// 行为扩展的执行入口必须是run
|
// 行为扩展的执行入口必须是run
|
||||||
public function run(&$content){
|
public function run(&$content)
|
||||||
|
{
|
||||||
$content = $this->templateContentReplace($content);
|
$content = $this->templateContentReplace($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,7 +28,8 @@ class ContentReplaceBehavior {
|
|||||||
* @param string $content 模板内容
|
* @param string $content 模板内容
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function templateContentReplace($content) {
|
protected function templateContentReplace($content)
|
||||||
|
{
|
||||||
// 系统默认的特殊变量替换
|
// 系统默认的特殊变量替换
|
||||||
$replace = array(
|
$replace = array(
|
||||||
'__ROOT__' => __ROOT__, // 当前网站地址
|
'__ROOT__' => __ROOT__, // 当前网站地址
|
||||||
@ -33,15 +37,14 @@ class ContentReplaceBehavior {
|
|||||||
'__MODULE__' => __MODULE__,
|
'__MODULE__' => __MODULE__,
|
||||||
'__ACTION__' => __ACTION__, // 当前操作地址
|
'__ACTION__' => __ACTION__, // 当前操作地址
|
||||||
'__SELF__' => htmlentities(__SELF__), // 当前页面地址
|
'__SELF__' => htmlentities(__SELF__), // 当前页面地址
|
||||||
'__CONTROLLER__'=> __CONTROLLER__,
|
'__CONTROLLER__' => __CONTROLLER__,
|
||||||
'__URL__' => __CONTROLLER__,
|
'__URL__' => __CONTROLLER__,
|
||||||
'__PUBLIC__' => __ROOT__.'/Public',// 站点公共目录
|
'__PUBLIC__' => __ROOT__ . '/Public', // 站点公共目录
|
||||||
);
|
);
|
||||||
// 允许用户自定义模板的字符串替换
|
// 允许用户自定义模板的字符串替换
|
||||||
if(is_array(C('TMPL_PARSE_STRING')) )
|
if (is_array(C('TMPL_PARSE_STRING')))
|
||||||
$replace = array_merge($replace,C('TMPL_PARSE_STRING'));
|
$replace = array_merge($replace, C('TMPL_PARSE_STRING'));
|
||||||
$content = str_replace(array_keys($replace),array_values($replace),$content);
|
$content = str_replace(array_keys($replace), array_values($replace), $content);
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -9,22 +9,24 @@
|
|||||||
// | Author: liu21st <liu21st@gmail.com>
|
// | Author: liu21st <liu21st@gmail.com>
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
namespace Think;
|
namespace Think;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ThinkPHP 视图类
|
* ThinkPHP 视图类
|
||||||
*/
|
*/
|
||||||
class View {
|
class View
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* 模板输出变量
|
* 模板输出变量
|
||||||
* @var tVar
|
* @var tVar
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
protected $tVar = array();
|
protected $tVar = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模板主题
|
* 模板主题
|
||||||
* @var theme
|
* @var theme
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
protected $theme = '';
|
protected $theme = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,10 +35,11 @@ class View {
|
|||||||
* @param mixed $name
|
* @param mixed $name
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
*/
|
*/
|
||||||
public function assign($name,$value=''){
|
public function assign($name, $value = '')
|
||||||
if(is_array($name)) {
|
{
|
||||||
$this->tVar = array_merge($this->tVar,$name);
|
if (is_array($name)) {
|
||||||
}else {
|
$this->tVar = array_merge($this->tVar, $name);
|
||||||
|
} else {
|
||||||
$this->tVar[$name] = $value;
|
$this->tVar[$name] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,11 +50,12 @@ class View {
|
|||||||
* @param string $name
|
* @param string $name
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function get($name=''){
|
public function get($name = '')
|
||||||
if('' === $name) {
|
{
|
||||||
|
if ('' === $name) {
|
||||||
return $this->tVar;
|
return $this->tVar;
|
||||||
}
|
}
|
||||||
return isset($this->tVar[$name])?$this->tVar[$name]:false;
|
return isset($this->tVar[$name]) ? $this->tVar[$name] : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,12 +68,13 @@ class View {
|
|||||||
* @param string $prefix 模板缓存前缀
|
* @param string $prefix 模板缓存前缀
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function display($templateFile='',$charset='',$contentType='',$content='',$prefix='') {
|
public function display($templateFile = '', $charset = '', $contentType = '', $content = '', $prefix = '')
|
||||||
|
{
|
||||||
G('viewStartTime');
|
G('viewStartTime');
|
||||||
// 解析并获取模板内容
|
// 解析并获取模板内容
|
||||||
$content = $this->fetch($templateFile,$content,$prefix);
|
$content = $this->fetch($templateFile, $content, $prefix);
|
||||||
// 输出模板内容
|
// 输出模板内容
|
||||||
$this->render($content,$charset,$contentType);
|
$this->render($content, $charset, $contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,12 +85,13 @@ class View {
|
|||||||
* @param string $contentType 输出类型
|
* @param string $contentType 输出类型
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
private function render($content,$charset='',$contentType=''){
|
private function render($content, $charset = '', $contentType = '')
|
||||||
if(empty($charset)) $charset = C('DEFAULT_CHARSET');
|
{
|
||||||
if(empty($contentType)) $contentType = C('TMPL_CONTENT_TYPE');
|
if (empty($charset)) $charset = C('DEFAULT_CHARSET');
|
||||||
|
if (empty($contentType)) $contentType = C('TMPL_CONTENT_TYPE');
|
||||||
// 网页字符编码
|
// 网页字符编码
|
||||||
header('Content-Type:'.$contentType.'; charset='.$charset);
|
header('Content-Type:' . $contentType . '; charset=' . $charset);
|
||||||
header('Cache-control: '.C('HTTP_CACHE_CONTROL')); // 页面缓存控制
|
header('Cache-control: ' . C('HTTP_CACHE_CONTROL')); // 页面缓存控制
|
||||||
header('X-Powered-By:ThinkPHP');
|
header('X-Powered-By:ThinkPHP');
|
||||||
// 输出模板文件
|
// 输出模板文件
|
||||||
echo $content;
|
echo $content;
|
||||||
@ -99,35 +105,36 @@ class View {
|
|||||||
* @param string $prefix 模板缓存前缀
|
* @param string $prefix 模板缓存前缀
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function fetch($templateFile='',$content='',$prefix='') {
|
public function fetch($templateFile = '', $content = '', $prefix = '')
|
||||||
if(empty($content)) {
|
{
|
||||||
|
if (empty($content)) {
|
||||||
$templateFile = $this->parseTemplate($templateFile);
|
$templateFile = $this->parseTemplate($templateFile);
|
||||||
// 模板文件不存在直接返回
|
// 模板文件不存在直接返回
|
||||||
if(!is_file($templateFile)) E(L('_TEMPLATE_NOT_EXIST_').':'.$templateFile);
|
if (!is_file($templateFile)) E(L('_TEMPLATE_NOT_EXIST_') . ':' . $templateFile);
|
||||||
}else{
|
} else {
|
||||||
defined('THEME_PATH') or define('THEME_PATH', $this->getThemePath());
|
defined('THEME_PATH') or define('THEME_PATH', $this->getThemePath());
|
||||||
}
|
}
|
||||||
// 页面缓存
|
// 页面缓存
|
||||||
ob_start();
|
ob_start();
|
||||||
ob_implicit_flush(0);
|
ob_implicit_flush(0);
|
||||||
if('php' == strtolower(C('TMPL_ENGINE_TYPE'))) { // 使用PHP原生模板
|
if ('php' == strtolower(C('TMPL_ENGINE_TYPE'))) { // 使用PHP原生模板
|
||||||
$_content = $content;
|
$_content = $content;
|
||||||
// 模板阵列变量分解成为独立变量
|
// 模板阵列变量分解成为独立变量
|
||||||
extract($this->tVar, EXTR_OVERWRITE);
|
extract($this->tVar, EXTR_OVERWRITE);
|
||||||
// 直接载入PHP模板
|
// 直接载入PHP模板
|
||||||
empty($_content)?include $templateFile:eval('?>'.$_content);
|
empty($_content) ? include $templateFile : eval('?>' . $_content);
|
||||||
}else{
|
} else {
|
||||||
// 视图解析标签
|
// 视图解析标签
|
||||||
$params = array('var'=>$this->tVar,'file'=>$templateFile,'content'=>$content,'prefix'=>$prefix);
|
$params = array('var' => $this->tVar, 'file' => $templateFile, 'content' => $content, 'prefix' => $prefix);
|
||||||
$_content = !empty($content)?:$templateFile;
|
$_content = !empty($content) ?: $templateFile;
|
||||||
if((!empty($content) && $this->checkContentCache($content,$prefix)) || $this->checkCache($templateFile,$prefix)) { // 缓存有效
|
if ((!empty($content) && $this->checkContentCache($content, $prefix)) || $this->checkCache($templateFile, $prefix)) { // 缓存有效
|
||||||
//载入模版缓存文件
|
//载入模版缓存文件
|
||||||
Storage::load(C('CACHE_PATH').$prefix.md5($_content).C('TMPL_CACHFILE_SUFFIX'),$this->tVar);
|
Storage::load(C('CACHE_PATH') . $prefix . md5($_content) . C('TMPL_CACHFILE_SUFFIX'), $this->tVar);
|
||||||
}else{
|
} else {
|
||||||
$tpl = Think::instance('Think\\Template');
|
$tpl = Think::instance('Think\\Template');
|
||||||
// 编译并加载模板文件
|
// 编译并加载模板文件
|
||||||
$tpl->fetch($_content,$this->tVar,$prefix);
|
$tpl->fetch($_content, $this->tVar, $prefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 获取并清空缓存
|
// 获取并清空缓存
|
||||||
$content = ob_get_clean();
|
$content = ob_get_clean();
|
||||||
@ -139,14 +146,14 @@ class View {
|
|||||||
'__MODULE__' => __MODULE__,
|
'__MODULE__' => __MODULE__,
|
||||||
'__ACTION__' => __ACTION__, // 当前操作地址
|
'__ACTION__' => __ACTION__, // 当前操作地址
|
||||||
'__SELF__' => __SELF__, // 当前页面地址
|
'__SELF__' => __SELF__, // 当前页面地址
|
||||||
'__CONTROLLER__'=> __CONTROLLER__,
|
'__CONTROLLER__' => __CONTROLLER__,
|
||||||
'__URL__' => __CONTROLLER__,
|
'__URL__' => __CONTROLLER__,
|
||||||
'__PUBLIC__' => __ROOT__.'/Public',// 站点公共目录
|
'__PUBLIC__' => __ROOT__ . '/Public', // 站点公共目录
|
||||||
);
|
);
|
||||||
// 允许用户自定义模板的字符串替换
|
// 允许用户自定义模板的字符串替换
|
||||||
if(is_array(C('TMPL_PARSE_STRING')) )
|
if (is_array(C('TMPL_PARSE_STRING')))
|
||||||
$replace = array_merge($replace,C('TMPL_PARSE_STRING'));
|
$replace = array_merge($replace, C('TMPL_PARSE_STRING'));
|
||||||
$content = str_replace(array_keys($replace),array_values($replace),$content);
|
$content = str_replace(array_keys($replace), array_values($replace), $content);
|
||||||
// 输出模板文件
|
// 输出模板文件
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
@ -158,23 +165,24 @@ class View {
|
|||||||
* @param string $tmplTemplateFile 模板文件名
|
* @param string $tmplTemplateFile 模板文件名
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected function checkCache($tmplTemplateFile,$prefix='') {
|
protected function checkCache($tmplTemplateFile, $prefix = '')
|
||||||
|
{
|
||||||
if (!C('TMPL_CACHE_ON')) // 优先对配置设定检测
|
if (!C('TMPL_CACHE_ON')) // 优先对配置设定检测
|
||||||
return false;
|
return false;
|
||||||
$tmplCacheFile = C('CACHE_PATH').$prefix.md5($tmplTemplateFile).C('TMPL_CACHFILE_SUFFIX');
|
$tmplCacheFile = C('CACHE_PATH') . $prefix . md5($tmplTemplateFile) . C('TMPL_CACHFILE_SUFFIX');
|
||||||
if(!Storage::has($tmplCacheFile)){
|
if (!Storage::has($tmplCacheFile)) {
|
||||||
return false;
|
return false;
|
||||||
}elseif (filemtime($tmplTemplateFile) > Storage::get($tmplCacheFile,'mtime')) {
|
} elseif (filemtime($tmplTemplateFile) > Storage::get($tmplCacheFile, 'mtime')) {
|
||||||
// 模板文件如果有更新则缓存需要更新
|
// 模板文件如果有更新则缓存需要更新
|
||||||
return false;
|
return false;
|
||||||
}elseif (C('TMPL_CACHE_TIME') != 0 && time() > Storage::get($tmplCacheFile,'mtime')+C('TMPL_CACHE_TIME')) {
|
} elseif (C('TMPL_CACHE_TIME') != 0 && time() > Storage::get($tmplCacheFile, 'mtime') + C('TMPL_CACHE_TIME')) {
|
||||||
// 缓存是否在有效期
|
// 缓存是否在有效期
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 开启布局模板
|
// 开启布局模板
|
||||||
if(C('LAYOUT_ON')) {
|
if (C('LAYOUT_ON')) {
|
||||||
$layoutFile = THEME_PATH.C('LAYOUT_NAME').C('TMPL_TEMPLATE_SUFFIX');
|
$layoutFile = THEME_PATH . C('LAYOUT_NAME') . C('TMPL_TEMPLATE_SUFFIX');
|
||||||
if(filemtime($layoutFile) > Storage::get($tmplCacheFile,'mtime')) {
|
if (filemtime($layoutFile) > Storage::get($tmplCacheFile, 'mtime')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,13 +197,14 @@ class View {
|
|||||||
* @param string $tmplContent 模板内容
|
* @param string $tmplContent 模板内容
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected function checkContentCache($tmplContent,$prefix='') {
|
protected function checkContentCache($tmplContent, $prefix = '')
|
||||||
if(Storage::has(C('CACHE_PATH').$prefix.md5($tmplContent).C('TMPL_CACHFILE_SUFFIX'))){
|
{
|
||||||
|
if (Storage::has(C('CACHE_PATH') . $prefix . md5($tmplContent) . C('TMPL_CACHFILE_SUFFIX'))) {
|
||||||
return true;
|
return true;
|
||||||
}else{
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自动定位模板文件
|
* 自动定位模板文件
|
||||||
@ -203,8 +212,9 @@ class View {
|
|||||||
* @param string $template 模板文件规则
|
* @param string $template 模板文件规则
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function parseTemplate($template='') {
|
public function parseTemplate($template = '')
|
||||||
if(is_file($template)) {
|
{
|
||||||
|
if (is_file($template)) {
|
||||||
return $template;
|
return $template;
|
||||||
}
|
}
|
||||||
$depr = C('TMPL_FILE_DEPR');
|
$depr = C('TMPL_FILE_DEPR');
|
||||||
@ -212,23 +222,23 @@ class View {
|
|||||||
|
|
||||||
// 获取当前模块
|
// 获取当前模块
|
||||||
$module = MODULE_NAME;
|
$module = MODULE_NAME;
|
||||||
if(strpos($template,'@')){ // 跨模块调用模版文件
|
if (strpos($template, '@')) { // 跨模块调用模版文件
|
||||||
list($module,$template) = explode('@',$template);
|
list($module, $template) = explode('@', $template);
|
||||||
}
|
}
|
||||||
// 获取当前主题的模版路径
|
// 获取当前主题的模版路径
|
||||||
defined('THEME_PATH') or define('THEME_PATH', $this->getThemePath($module));
|
defined('THEME_PATH') or define('THEME_PATH', $this->getThemePath($module));
|
||||||
|
|
||||||
// 分析模板文件规则
|
// 分析模板文件规则
|
||||||
if('' == $template) {
|
if ('' == $template) {
|
||||||
// 如果模板文件名为空 按照默认规则定位
|
// 如果模板文件名为空 按照默认规则定位
|
||||||
$template = CONTROLLER_NAME . $depr . ACTION_NAME;
|
$template = CONTROLLER_NAME . $depr . ACTION_NAME;
|
||||||
}elseif(false === strpos($template, $depr)){
|
} elseif (false === strpos($template, $depr)) {
|
||||||
$template = CONTROLLER_NAME . $depr . $template;
|
$template = CONTROLLER_NAME . $depr . $template;
|
||||||
}
|
}
|
||||||
$file = THEME_PATH.$template.C('TMPL_TEMPLATE_SUFFIX');
|
$file = THEME_PATH . $template . C('TMPL_TEMPLATE_SUFFIX');
|
||||||
if(C('TMPL_LOAD_DEFAULTTHEME') && THEME_NAME != C('DEFAULT_THEME') && !is_file($file)){
|
if (C('TMPL_LOAD_DEFAULTTHEME') && THEME_NAME != C('DEFAULT_THEME') && !is_file($file)) {
|
||||||
// 找不到当前主题模板的时候定位默认主题中的模板
|
// 找不到当前主题模板的时候定位默认主题中的模板
|
||||||
$file = dirname(THEME_PATH).'/'.C('DEFAULT_THEME').'/'.$template.C('TMPL_TEMPLATE_SUFFIX');
|
$file = dirname(THEME_PATH) . '/' . C('DEFAULT_THEME') . '/' . $template . C('TMPL_TEMPLATE_SUFFIX');
|
||||||
}
|
}
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
@ -239,16 +249,17 @@ class View {
|
|||||||
* @param string $module 模块名
|
* @param string $module 模块名
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getThemePath($module=MODULE_NAME){
|
protected function getThemePath($module = MODULE_NAME)
|
||||||
|
{
|
||||||
// 获取当前主题名称
|
// 获取当前主题名称
|
||||||
$theme = $this->getTemplateTheme();
|
$theme = $this->getTemplateTheme();
|
||||||
// 获取当前主题的模版路径
|
// 获取当前主题的模版路径
|
||||||
$tmplPath = C('VIEW_PATH'); // 模块设置独立的视图目录
|
$tmplPath = C('VIEW_PATH'); // 模块设置独立的视图目录
|
||||||
if(!$tmplPath){
|
if (!$tmplPath) {
|
||||||
// 定义TMPL_PATH 则改变全局的视图目录到模块之外
|
// 定义TMPL_PATH 则改变全局的视图目录到模块之外
|
||||||
$tmplPath = defined('TMPL_PATH')? TMPL_PATH.$module.'/' : APP_PATH.$module.'/'.C('DEFAULT_V_LAYER').'/';
|
$tmplPath = defined('TMPL_PATH') ? TMPL_PATH . $module . '/' : APP_PATH . $module . '/' . C('DEFAULT_V_LAYER') . '/';
|
||||||
}
|
}
|
||||||
return $tmplPath.$theme;
|
return $tmplPath . $theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -257,7 +268,8 @@ class View {
|
|||||||
* @param mixed $theme 主题名称
|
* @param mixed $theme 主题名称
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function theme($theme){
|
public function theme($theme)
|
||||||
|
{
|
||||||
$this->theme = $theme;
|
$this->theme = $theme;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -267,27 +279,27 @@ class View {
|
|||||||
* @access private
|
* @access private
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getTemplateTheme() {
|
private function getTemplateTheme()
|
||||||
if($this->theme) { // 指定模板主题
|
{
|
||||||
|
if ($this->theme) { // 指定模板主题
|
||||||
$theme = $this->theme;
|
$theme = $this->theme;
|
||||||
}else{
|
} else {
|
||||||
/* 获取模板主题名称 */
|
/* 获取模板主题名称 */
|
||||||
$theme = C('DEFAULT_THEME');
|
$theme = C('DEFAULT_THEME');
|
||||||
if(C('TMPL_DETECT_THEME')) {// 自动侦测模板主题
|
if (C('TMPL_DETECT_THEME')) { // 自动侦测模板主题
|
||||||
$t = C('VAR_TEMPLATE');
|
$t = C('VAR_TEMPLATE');
|
||||||
if (isset($_GET[$t])){
|
if (isset($_GET[$t])) {
|
||||||
$theme = $_GET[$t];
|
$theme = $_GET[$t];
|
||||||
}elseif(cookie('think_template')){
|
} elseif (cookie('think_template')) {
|
||||||
$theme = cookie('think_template');
|
$theme = cookie('think_template');
|
||||||
}
|
}
|
||||||
if(!in_array($theme,explode(',',C('THEME_LIST')))){
|
if (!in_array($theme, explode(',', C('THEME_LIST')))) {
|
||||||
$theme = C('DEFAULT_THEME');
|
$theme = C('DEFAULT_THEME');
|
||||||
}
|
}
|
||||||
cookie('think_template',$theme,864000);
|
cookie('think_template', $theme, 864000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defined('THEME_NAME') || define('THEME_NAME', $theme); // 当前模板主题名称
|
defined('THEME_NAME') || define('THEME_NAME', $theme); // 当前模板主题名称
|
||||||
return $theme?$theme . '/':'';
|
return $theme ? $theme . '/' : '';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user