mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
Merge branch 'master' of https://github.com/top-think/think
This commit is contained in:
@@ -730,7 +730,7 @@ class Template
|
|||||||
$parseStr = $first . '->' . implode('->', $vars);
|
$parseStr = $first . '->' . implode('->', $vars);
|
||||||
break;
|
break;
|
||||||
default: // 自动判断数组或对象 只支持二维
|
default: // 自动判断数组或对象 只支持二维
|
||||||
$parseStr = 'is_array(' . $first . ')?' . $first . '[\'' . implode('\'][\'', $vars) . '\']:' . $first . '->' . implode('->', $vars);
|
$parseStr = '(is_array(' . $first . ')?' . $first . '[\'' . implode('\'][\'', $vars) . '\']:' . $first . '->' . implode('->', $vars) . ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -321,11 +321,10 @@ class TagLib
|
|||||||
if (!empty($this->tags[$tag]['expression'])) {
|
if (!empty($this->tags[$tag]['expression'])) {
|
||||||
static $_taglibs;
|
static $_taglibs;
|
||||||
if (!isset($_taglibs[$tag])) {
|
if (!isset($_taglibs[$tag])) {
|
||||||
$_taglibs[$tag][0] = strlen($this->tpl->config('taglib_begin') . $tag);
|
$_taglibs[$tag][0] = strlen(ltrim($this->tpl->config('taglib_begin'), '\\') . $tag);
|
||||||
$_taglibs[$tag][1] = strlen($this->tpl->config('taglib_end'));
|
$_taglibs[$tag][1] = strlen(ltrim($this->tpl->config('taglib_end'), '\\'));
|
||||||
}
|
}
|
||||||
$str = substr($str, $_taglibs[$tag][0], -$_taglibs[$tag][1]);
|
$result['expression'] = trim(substr($str, $_taglibs[$tag][0], -$_taglibs[$tag][1]));
|
||||||
$result['expression'] = trim($str);
|
|
||||||
} elseif (empty($this->tags[$tag]) || !empty($this->tags[$tag]['attr'])) {
|
} elseif (empty($this->tags[$tag]) || !empty($this->tags[$tag]['attr'])) {
|
||||||
throw new Exception('_XML_TAG_ERROR_:' . $tag);
|
throw new Exception('_XML_TAG_ERROR_:' . $tag);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ class Cx extends Taglib
|
|||||||
'volist' => ['attr' => 'name,id,offset,length,key,mod', 'alias' => 'iterate'],
|
'volist' => ['attr' => 'name,id,offset,length,key,mod', 'alias' => 'iterate'],
|
||||||
'foreach' => ['attr' => 'name,id,item,key,offset,length,mod', 'expression' => true],
|
'foreach' => ['attr' => 'name,id,item,key,offset,length,mod', 'expression' => true],
|
||||||
'if' => ['attr' => 'condition', 'expression' => true],
|
'if' => ['attr' => 'condition', 'expression' => true],
|
||||||
'elseif' => ['attr' => 'condition', 'close' => 0],
|
'elseif' => ['attr' => 'condition', 'close' => 0, 'expression' => true],
|
||||||
'else' => ['attr' => '', 'close' => 0],
|
'else' => ['attr' => '', 'close' => 0],
|
||||||
'switch' => ['attr' => 'name'],
|
'switch' => ['attr' => 'name', 'expression' => true],
|
||||||
'case' => ['attr' => 'value,break'],
|
'case' => ['attr' => 'value,break', 'expression' => true],
|
||||||
'default' => ['attr' => '', 'close' => 0],
|
'default' => ['attr' => '', 'close' => 0],
|
||||||
'compare' => ['attr' => 'name,value,type', 'alias' => 'eq,equal,notequal,neq,gt,lt,egt,elt,heq,nheq'],
|
'compare' => ['attr' => 'name,value,type', 'alias' => 'eq,equal,notequal,neq,gt,lt,egt,elt,heq,nheq'],
|
||||||
'range' => ['attr' => 'name,value,type', 'alias' => 'in,notin,between,notbetween'],
|
'range' => ['attr' => 'name,value,type', 'alias' => 'in,notin,between,notbetween'],
|
||||||
@@ -251,7 +251,7 @@ class Cx extends Taglib
|
|||||||
*/
|
*/
|
||||||
public function _switch($tag, $content)
|
public function _switch($tag, $content)
|
||||||
{
|
{
|
||||||
$name = $tag['name'];
|
$name = !empty($tag['expression']) ? $tag['expression'] : $tag['name'];
|
||||||
$name = $this->autoBuildVar($name);
|
$name = $this->autoBuildVar($name);
|
||||||
$parseStr = '<?php switch(' . $name . '): ?>' . $content . '<?php endswitch;?>';
|
$parseStr = '<?php switch(' . $name . '): ?>' . $content . '<?php endswitch;?>';
|
||||||
return $parseStr;
|
return $parseStr;
|
||||||
@@ -266,7 +266,7 @@ class Cx extends Taglib
|
|||||||
*/
|
*/
|
||||||
public function _case($tag, $content)
|
public function _case($tag, $content)
|
||||||
{
|
{
|
||||||
$value = $tag['value'];
|
$value = !empty($tag['expression']) ? $tag['expression'] : $tag['value'];
|
||||||
$flag = substr($value, 0, 1);
|
$flag = substr($value, 0, 1);
|
||||||
if ('$' == $flag || ':' == $flag) {
|
if ('$' == $flag || ':' == $flag) {
|
||||||
$value = $this->autoBuildVar($value);
|
$value = $this->autoBuildVar($value);
|
||||||
@@ -309,6 +309,7 @@ class Cx extends Taglib
|
|||||||
* @access public
|
* @access public
|
||||||
* @param array $tag 标签属性
|
* @param array $tag 标签属性
|
||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
|
* @param string $type 比较类型
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _compare($tag, $content, $type = 'eq')
|
public function _compare($tag, $content, $type = 'eq')
|
||||||
@@ -319,12 +320,12 @@ class Cx extends Taglib
|
|||||||
$name = $this->autoBuildVar($name);
|
$name = $this->autoBuildVar($name);
|
||||||
$flag = substr($value, 0, 1);
|
$flag = substr($value, 0, 1);
|
||||||
if ('$' == $flag || ':' == $flag) {
|
if ('$' == $flag || ':' == $flag) {
|
||||||
$value = '(' . $this->autoBuildVar($value) . ')';
|
$value = $this->autoBuildVar($value);
|
||||||
} else {
|
} else {
|
||||||
$value = '\'' . $value . '\'';
|
$value = '\'' . $value . '\'';
|
||||||
}
|
}
|
||||||
$type = $this->parseCondition(' ' . $type . ' ');
|
$type = $this->parseCondition(' ' . $type . ' ');
|
||||||
$parseStr = '<?php if((' . $name . ') ' . $type . ' ' . $value . '): ?>' . $content . '<?php endif; ?>';
|
$parseStr = '<?php if(' . $name . ' ' . $type . ' ' . $value . '): ?>' . $content . '<?php endif; ?>';
|
||||||
return $parseStr;
|
return $parseStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user