mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
修改标签库的方法命名 取消 import标签
This commit is contained in:
@@ -1378,7 +1378,7 @@ class Request
|
|||||||
*/
|
*/
|
||||||
public function getContent()
|
public function getContent()
|
||||||
{
|
{
|
||||||
if (null === $this->content) {
|
if (is_null($this->content)) {
|
||||||
$this->content = file_get_contents('php://input');
|
$this->content = file_get_contents('php://input');
|
||||||
}
|
}
|
||||||
return $this->content;
|
return $this->content;
|
||||||
|
|||||||
@@ -672,7 +672,7 @@ class Template
|
|||||||
*/
|
*/
|
||||||
public function parseTagLib($tagLib, &$content, $hide = false)
|
public function parseTagLib($tagLib, &$content, $hide = false)
|
||||||
{
|
{
|
||||||
if (strpos($tagLib, '\\')) {
|
if (false !== strpos($tagLib, '\\')) {
|
||||||
// 支持指定标签库的命名空间
|
// 支持指定标签库的命名空间
|
||||||
$className = $tagLib;
|
$className = $tagLib;
|
||||||
$tagLib = substr($tagLib, strrpos($tagLib, '\\') + 1);
|
$tagLib = substr($tagLib, strrpos($tagLib, '\\') + 1);
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ class TagLib
|
|||||||
$alias = $_lib . $name != $node['name'] ? ($_lib ? strstr($node['name'], $_lib) : $node['name']) : '';
|
$alias = $_lib . $name != $node['name'] ? ($_lib ? strstr($node['name'], $_lib) : $node['name']) : '';
|
||||||
// 解析标签属性
|
// 解析标签属性
|
||||||
$attrs = $this->parseAttr($node['begin'][0], $name, $alias);
|
$attrs = $this->parseAttr($node['begin'][0], $name, $alias);
|
||||||
$method = '_' . $name;
|
$method = 'tag' . $name;
|
||||||
// 读取标签库中对应的标签内容 replace[0]用来替换标签头,replace[1]用来替换标签尾
|
// 读取标签库中对应的标签内容 replace[0]用来替换标签头,replace[1]用来替换标签尾
|
||||||
$replace = explode($break, $this->$method($attrs, $break));
|
$replace = explode($break, $this->$method($attrs, $break));
|
||||||
if (count($replace) > 1) {
|
if (count($replace) > 1) {
|
||||||
@@ -176,7 +176,7 @@ class TagLib
|
|||||||
$alias = $_lib . $name != $matches[1] ? ($_lib ? strstr($matches[1], $_lib) : $matches[1]) : '';
|
$alias = $_lib . $name != $matches[1] ? ($_lib ? strstr($matches[1], $_lib) : $matches[1]) : '';
|
||||||
// 解析标签属性
|
// 解析标签属性
|
||||||
$attrs = $this->parseAttr($matches[0], $name, $alias);
|
$attrs = $this->parseAttr($matches[0], $name, $alias);
|
||||||
$method = '_' . $name;
|
$method = 'tag' . $name;
|
||||||
return $this->$method($attrs, '');
|
return $this->$method($attrs, '');
|
||||||
}, $content);
|
}, $content);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ class Cx extends Taglib
|
|||||||
'notpresent' => ['attr' => 'name'],
|
'notpresent' => ['attr' => 'name'],
|
||||||
'defined' => ['attr' => 'name'],
|
'defined' => ['attr' => 'name'],
|
||||||
'notdefined' => ['attr' => 'name'],
|
'notdefined' => ['attr' => 'name'],
|
||||||
'import' => ['attr' => 'file,href,type,value,basepath', 'close' => 0],
|
'load' => ['attr' => 'file,href,type,value,basepath', 'close' => 0, 'alias' => ['import,css,js', 'type']],
|
||||||
'load' => ['attr' => 'file,href,type,value,basepath', 'close' => 0, 'alias' => ['css,js', 'type']],
|
|
||||||
'assign' => ['attr' => 'name,value', 'close' => 0],
|
'assign' => ['attr' => 'name,value', 'close' => 0],
|
||||||
'define' => ['attr' => 'name,value', 'close' => 0],
|
'define' => ['attr' => 'name,value', 'close' => 0],
|
||||||
'for' => ['attr' => 'start,end,name,comparison,step'],
|
'for' => ['attr' => 'start,end,name,comparison,step'],
|
||||||
@@ -61,7 +60,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _php($tag, $content)
|
public function tagPhp($tag, $content)
|
||||||
{
|
{
|
||||||
$parseStr = '<?php ' . $content . ' ?>';
|
$parseStr = '<?php ' . $content . ' ?>';
|
||||||
return $parseStr;
|
return $parseStr;
|
||||||
@@ -79,7 +78,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string|void
|
* @return string|void
|
||||||
*/
|
*/
|
||||||
public function _volist($tag, $content)
|
public function tagVolist($tag, $content)
|
||||||
{
|
{
|
||||||
$name = $tag['name'];
|
$name = $tag['name'];
|
||||||
$id = $tag['id'];
|
$id = $tag['id'];
|
||||||
@@ -131,7 +130,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string|void
|
* @return string|void
|
||||||
*/
|
*/
|
||||||
public function _foreach($tag, $content)
|
public function tagForeach($tag, $content)
|
||||||
{
|
{
|
||||||
// 直接使用表达式
|
// 直接使用表达式
|
||||||
if (!empty($tag['expression'])) {
|
if (!empty($tag['expression'])) {
|
||||||
@@ -212,7 +211,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _if($tag, $content)
|
public function tagIf($tag, $content)
|
||||||
{
|
{
|
||||||
$condition = !empty($tag['expression']) ? $tag['expression'] : $tag['condition'];
|
$condition = !empty($tag['expression']) ? $tag['expression'] : $tag['condition'];
|
||||||
$condition = $this->parseCondition($condition);
|
$condition = $this->parseCondition($condition);
|
||||||
@@ -228,7 +227,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _elseif($tag, $content)
|
public function tagElseif($tag, $content)
|
||||||
{
|
{
|
||||||
$condition = !empty($tag['expression']) ? $tag['expression'] : $tag['condition'];
|
$condition = !empty($tag['expression']) ? $tag['expression'] : $tag['condition'];
|
||||||
$condition = $this->parseCondition($condition);
|
$condition = $this->parseCondition($condition);
|
||||||
@@ -243,7 +242,7 @@ class Cx extends Taglib
|
|||||||
* @param array $tag 标签属性
|
* @param array $tag 标签属性
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _else($tag)
|
public function tagElse($tag)
|
||||||
{
|
{
|
||||||
$parseStr = '<?php else: ?>';
|
$parseStr = '<?php else: ?>';
|
||||||
return $parseStr;
|
return $parseStr;
|
||||||
@@ -262,7 +261,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _switch($tag, $content)
|
public function tagSwitch($tag, $content)
|
||||||
{
|
{
|
||||||
$name = !empty($tag['expression']) ? $tag['expression'] : $tag['name'];
|
$name = !empty($tag['expression']) ? $tag['expression'] : $tag['name'];
|
||||||
$name = $this->autoBuildVar($name);
|
$name = $this->autoBuildVar($name);
|
||||||
@@ -277,7 +276,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _case($tag, $content)
|
public function tagCase($tag, $content)
|
||||||
{
|
{
|
||||||
$value = !empty($tag['expression']) ? $tag['expression'] : $tag['value'];
|
$value = !empty($tag['expression']) ? $tag['expression'] : $tag['value'];
|
||||||
$flag = substr($value, 0, 1);
|
$flag = substr($value, 0, 1);
|
||||||
@@ -309,7 +308,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _default($tag)
|
public function tagDefault($tag)
|
||||||
{
|
{
|
||||||
$parseStr = '<?php default: ?>';
|
$parseStr = '<?php default: ?>';
|
||||||
return $parseStr;
|
return $parseStr;
|
||||||
@@ -324,7 +323,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _compare($tag, $content)
|
public function tagCompare($tag, $content)
|
||||||
{
|
{
|
||||||
$name = $tag['name'];
|
$name = $tag['name'];
|
||||||
$value = $tag['value'];
|
$value = $tag['value'];
|
||||||
@@ -359,7 +358,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _range($tag, $content)
|
public function tagRange($tag, $content)
|
||||||
{
|
{
|
||||||
$name = $tag['name'];
|
$name = $tag['name'];
|
||||||
$value = $tag['value'];
|
$value = $tag['value'];
|
||||||
@@ -394,7 +393,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _present($tag, $content)
|
public function tagPresent($tag, $content)
|
||||||
{
|
{
|
||||||
$name = $tag['name'];
|
$name = $tag['name'];
|
||||||
$name = $this->autoBuildVar($name);
|
$name = $this->autoBuildVar($name);
|
||||||
@@ -411,7 +410,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _notpresent($tag, $content)
|
public function tagNotpresent($tag, $content)
|
||||||
{
|
{
|
||||||
$name = $tag['name'];
|
$name = $tag['name'];
|
||||||
$name = $this->autoBuildVar($name);
|
$name = $this->autoBuildVar($name);
|
||||||
@@ -428,7 +427,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _empty($tag, $content)
|
public function tagEmpty($tag, $content)
|
||||||
{
|
{
|
||||||
$name = $tag['name'];
|
$name = $tag['name'];
|
||||||
$name = $this->autoBuildVar($name);
|
$name = $this->autoBuildVar($name);
|
||||||
@@ -445,7 +444,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _notempty($tag, $content)
|
public function tagNotempty($tag, $content)
|
||||||
{
|
{
|
||||||
$name = $tag['name'];
|
$name = $tag['name'];
|
||||||
$name = $this->autoBuildVar($name);
|
$name = $this->autoBuildVar($name);
|
||||||
@@ -460,7 +459,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content
|
* @param string $content
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _defined($tag, $content)
|
public function tagDefined($tag, $content)
|
||||||
{
|
{
|
||||||
$name = $tag['name'];
|
$name = $tag['name'];
|
||||||
$parseStr = '<?php if(defined("' . $name . '")): ?>' . $content . '<?php endif; ?>';
|
$parseStr = '<?php if(defined("' . $name . '")): ?>' . $content . '<?php endif; ?>';
|
||||||
@@ -474,7 +473,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content
|
* @param string $content
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _notdefined($tag, $content)
|
public function tagNotdefined($tag, $content)
|
||||||
{
|
{
|
||||||
$name = $tag['name'];
|
$name = $tag['name'];
|
||||||
$parseStr = '<?php if(!defined("' . $name . '")): ?>' . $content . '<?php endif; ?>';
|
$parseStr = '<?php if(!defined("' . $name . '")): ?>' . $content . '<?php endif; ?>';
|
||||||
@@ -482,19 +481,17 @@ class Cx extends Taglib
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* import 标签解析 {import file="Js.Base" /}
|
* load 标签解析 {load file="/static/js/base.js" /}
|
||||||
* 格式:{import file="Css.Base" type="css" /}
|
* 格式:{load file="/static/css/base.css" /}
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $tag 标签属性
|
* @param array $tag 标签属性
|
||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @param boolean $isFile 是否文件方式
|
|
||||||
* @param string $type 类型
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _import($tag, $content, $isFile = false)
|
public function tagLoad($tag, $content)
|
||||||
{
|
{
|
||||||
$file = isset($tag['file']) ? $tag['file'] : $tag['href'];
|
$file = isset($tag['file']) ? $tag['file'] : $tag['href'];
|
||||||
$type = isset($tag['type']) ? strtolower($tag['type']) : ($isFile ? null : 'js');
|
$type = isset($tag['type']) ? strtolower($tag['type']) : '';
|
||||||
$parseStr = '';
|
$parseStr = '';
|
||||||
$endStr = '';
|
$endStr = '';
|
||||||
// 判断是否存在加载条件 允许使用函数判断(默认为isset)
|
// 判断是否存在加载条件 允许使用函数判断(默认为isset)
|
||||||
@@ -505,13 +502,11 @@ class Cx extends Taglib
|
|||||||
$parseStr .= '<?php if(' . $name . '): ?>';
|
$parseStr .= '<?php if(' . $name . '): ?>';
|
||||||
$endStr = '<?php endif; ?>';
|
$endStr = '<?php endif; ?>';
|
||||||
}
|
}
|
||||||
if ($isFile) {
|
|
||||||
// 文件方式导入
|
// 文件方式导入
|
||||||
$array = explode(',', $file);
|
$array = explode(',', $file);
|
||||||
foreach ($array as $val) {
|
foreach ($array as $val) {
|
||||||
if (!$type || isset($reset)) {
|
|
||||||
$type = $reset = strtolower(substr(strrchr($val, '.'), 1));
|
$type = $reset = strtolower(substr(strrchr($val, '.'), 1));
|
||||||
}
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'js':
|
case 'js':
|
||||||
$parseStr .= '<script type="text/javascript" src="' . $val . '"></script>';
|
$parseStr .= '<script type="text/javascript" src="' . $val . '"></script>';
|
||||||
@@ -524,39 +519,9 @@ class Cx extends Taglib
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// 命名空间导入模式
|
|
||||||
$basepath = !empty($tag['basepath']) ? $tag['basepath'] : '/public';
|
|
||||||
// 命名空间方式导入外部文件
|
|
||||||
$array = explode(',', $file);
|
|
||||||
foreach ($array as $val) {
|
|
||||||
if (strpos($val, '?')) {
|
|
||||||
list($val, $version) = explode('?', $val);
|
|
||||||
} else {
|
|
||||||
$version = '';
|
|
||||||
}
|
|
||||||
switch ($type) {
|
|
||||||
case 'js':
|
|
||||||
$parseStr .= '<script type="text/javascript" src="' . $basepath . '/' . str_replace(['.', '#'], ['/', '.'], $val) . '.js' . ($version ? '?' . $version : '') . '"></script>';
|
|
||||||
break;
|
|
||||||
case 'css':
|
|
||||||
$parseStr .= '<link rel="stylesheet" type="text/css" href="' . $basepath . '/' . str_replace(['.', '#'], ['/', '.'], $val) . '.css' . ($version ? '?' . $version : '') . '" />';
|
|
||||||
break;
|
|
||||||
case 'php':
|
|
||||||
$parseStr .= '<?php \think\Loader::import("' . $val . '"); ?>';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $parseStr . $endStr;
|
return $parseStr . $endStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// import别名 采用文件方式加载(要使用命名空间必须用import) 例如 <load file="__PUBLIC__/Js/Base.js" />
|
|
||||||
public function _load($tag, $content)
|
|
||||||
{
|
|
||||||
return $this->_import($tag, $content, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* assign标签解析
|
* assign标签解析
|
||||||
* 在模板中给某个变量赋值 支持变量赋值
|
* 在模板中给某个变量赋值 支持变量赋值
|
||||||
@@ -566,7 +531,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _assign($tag, $content)
|
public function tagAssign($tag, $content)
|
||||||
{
|
{
|
||||||
$name = $this->autoBuildVar($tag['name']);
|
$name = $this->autoBuildVar($tag['name']);
|
||||||
$flag = substr($tag['value'], 0, 1);
|
$flag = substr($tag['value'], 0, 1);
|
||||||
@@ -588,7 +553,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _define($tag, $content)
|
public function tagDefine($tag, $content)
|
||||||
{
|
{
|
||||||
$name = '\'' . $tag['name'] . '\'';
|
$name = '\'' . $tag['name'] . '\'';
|
||||||
$flag = substr($tag['value'], 0, 1);
|
$flag = substr($tag['value'], 0, 1);
|
||||||
@@ -612,7 +577,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _for($tag, $content)
|
public function tagFor($tag, $content)
|
||||||
{
|
{
|
||||||
//设置默认值
|
//设置默认值
|
||||||
$start = 0;
|
$start = 0;
|
||||||
@@ -663,7 +628,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _url($tag, $content)
|
public function tagUrl($tag, $content)
|
||||||
{
|
{
|
||||||
$url = isset($tag['link']) ? $tag['link'] : '';
|
$url = isset($tag['link']) ? $tag['link'] : '';
|
||||||
$vars = isset($tag['vars']) ? $tag['vars'] : '';
|
$vars = isset($tag['vars']) ? $tag['vars'] : '';
|
||||||
@@ -689,7 +654,7 @@ class Cx extends Taglib
|
|||||||
* @param string $content 标签内容
|
* @param string $content 标签内容
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function _function($tag, $content)
|
public function tagFunction($tag, $content)
|
||||||
{
|
{
|
||||||
$name = !empty($tag['name']) ? $tag['name'] : 'func';
|
$name = !empty($tag['name']) ? $tag['name'] : 'func';
|
||||||
$vars = !empty($tag['vars']) ? $tag['vars'] : '';
|
$vars = !empty($tag['vars']) ? $tag['vars'] : '';
|
||||||
|
|||||||
Reference in New Issue
Block a user