mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
数组定义规范统一
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
namespace Think;
|
||||
class Auto {
|
||||
|
||||
protected $auto = array();
|
||||
protected $auto = [];
|
||||
|
||||
public function rule($rule){
|
||||
$this->auto = $rule;
|
||||
@@ -33,7 +33,7 @@ class Auto {
|
||||
// array('field','填充内容','附加规则',[额外参数])
|
||||
switch(trim($auto[2])) {
|
||||
case 'callback': // 使用回调方法
|
||||
$args = isset($auto[3])?(array)$auto[3]:array();
|
||||
$args = isset($auto[3])?(array)$auto[3]:[];
|
||||
if(isset($data[$auto[0]])) {
|
||||
array_unshift($args,$data[$auto[0]]);
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ class ShowPageTrace {
|
||||
private function showTrace() {
|
||||
// 系统默认显示信息
|
||||
$files = get_included_files();
|
||||
$info = array();
|
||||
$info = [];
|
||||
foreach ($files as $key=>$file){
|
||||
$info[] = $file.' ( '.number_format(filesize($file)/1024,2).' KB )';
|
||||
}
|
||||
$trace = array();
|
||||
$trace = [];
|
||||
Debug::remark('START',$GLOBALS['startTime']);
|
||||
$base = array(
|
||||
'请求信息' => date('Y-m-d H:i:s',$_SERVER['REQUEST_TIME']).' '.$_SERVER['SERVER_PROTOCOL'].' '.$_SERVER['REQUEST_METHOD'].' : '.$_SERVER['PHP_SELF'],
|
||||
@@ -70,9 +70,9 @@ class ShowPageTrace {
|
||||
$name = strtoupper($name);
|
||||
if(strpos($name,'|')) {// 多组信息
|
||||
$array = explode('|',$name);
|
||||
$result = array();
|
||||
$result = [];
|
||||
foreach($array as $name){
|
||||
$result += isset($debug[$name])?$debug[$name]:array();
|
||||
$result += isset($debug[$name])?$debug[$name]:[];
|
||||
}
|
||||
$trace[$title] = $result;
|
||||
}else{
|
||||
|
||||
@@ -20,7 +20,7 @@ class ReadHtmlCacheBehavior {
|
||||
protected $options = array(
|
||||
'HTML_CACHE_ON' => false,
|
||||
'HTML_CACHE_TIME' => 60,
|
||||
'HTML_CACHE_RULES' => array(),
|
||||
'HTML_CACHE_RULES' => [],
|
||||
'HTML_FILE_SUFFIX' => '.html',
|
||||
);
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class TokenBuildBehavior extends Behavior {
|
||||
$tokenName = C('TOKEN_NAME');
|
||||
$tokenType = C('TOKEN_TYPE');
|
||||
if(!isset($_SESSION[$tokenName])) {
|
||||
$_SESSION[$tokenName] = array();
|
||||
$_SESSION[$tokenName] = [];
|
||||
}
|
||||
// 标识当前页面唯一性
|
||||
$tokenKey = md5($_SERVER['REQUEST_URI']);
|
||||
|
||||
@@ -28,7 +28,7 @@ class Apc {
|
||||
* @param array $options 缓存参数
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($options=array()) {
|
||||
public function __construct($options=[]) {
|
||||
if(!function_exists('apc_cache_info')) {
|
||||
throw New Exception('_NOT_SUPPERT_:Apc');
|
||||
}
|
||||
@@ -65,7 +65,7 @@ class Apc {
|
||||
// 记录缓存队列
|
||||
$queue = apc_fetch('__info__');
|
||||
if(!$queue) {
|
||||
$queue = array();
|
||||
$queue = [];
|
||||
}
|
||||
if(false===array_search($name, $queue)) array_push($queue,$name);
|
||||
if(count($queue) > $this->options['length']) {
|
||||
|
||||
@@ -36,7 +36,7 @@ class Db {
|
||||
* @param array $options 缓存参数
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($options=array()) {
|
||||
public function __construct($options=[]) {
|
||||
if(!empty($options)) {
|
||||
$this->options = array_merge($this->options,$options);
|
||||
}
|
||||
@@ -101,7 +101,7 @@ class Db {
|
||||
$queue = xcache_get('__info__');
|
||||
if(!$result) {
|
||||
$this->handler->execute('INSERT INTO '.$this->options['table'].' (`cachekey`,`data`,`expire`) VALUES (\'__info__\',\'\',0)');
|
||||
$queue = array();
|
||||
$queue = [];
|
||||
}else{
|
||||
$queue = unserialize($result[0]['data']);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class Eaccelerator {
|
||||
* @param array $options 缓存参数
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($options=array()) {
|
||||
public function __construct($options=[]) {
|
||||
if(!empty($options)) {
|
||||
$this->options = array_merge($this->options,$options);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class Eaccelerator {
|
||||
// 记录缓存队列
|
||||
$queue = eaccelerator_get('__info__');
|
||||
if(!$queue) {
|
||||
$queue = array();
|
||||
$queue = [];
|
||||
}
|
||||
if(false===array_search($name, $queue)) array_push($queue,$name);
|
||||
if(count($queue) > $this->options['length']) {
|
||||
|
||||
@@ -29,7 +29,7 @@ class File {
|
||||
* 架构函数
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($options=array()) {
|
||||
public function __construct($options=[]) {
|
||||
if(!empty($options)) {
|
||||
$this->options = array_merge($this->options,$options);
|
||||
}
|
||||
@@ -133,7 +133,7 @@ class File {
|
||||
$queue_file = dirname($filename).'/__info__.php';
|
||||
$queue = unserialize(file_get_contents($queue_file));
|
||||
if(!$queue) {
|
||||
$queue = array();
|
||||
$queue = [];
|
||||
}
|
||||
if(false===array_search($name, $queue)) array_push($queue,$name);
|
||||
if(count($queue) > $this->options['length']) {
|
||||
|
||||
@@ -29,7 +29,7 @@ class Memcache {
|
||||
* @param array $options 缓存参数
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($options=array()) {
|
||||
public function __construct($options=[]) {
|
||||
if ( !extension_loaded('memcache') ) {
|
||||
throw new Exception('_NOT_SUPPERT_:memcache');
|
||||
}
|
||||
@@ -71,7 +71,7 @@ class Memcache {
|
||||
// 记录缓存队列
|
||||
$queue = $this->handler->get('__info__');
|
||||
if(!$queue) {
|
||||
$queue = array();
|
||||
$queue = [];
|
||||
}
|
||||
if(false===array_search($name, $queue)) array_push($queue,$name);
|
||||
if(count($queue) > $this->options['length']) {
|
||||
|
||||
@@ -30,7 +30,7 @@ class Redis {
|
||||
* @param array $options 缓存参数
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($options=array()) {
|
||||
public function __construct($options=[]) {
|
||||
if ( !extension_loaded('redis') ) {
|
||||
throw new Exception('_NOT_SUPPERT_:redis');
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class Redis {
|
||||
// 记录缓存队列
|
||||
$queue = $this->handler->get('__info__');
|
||||
if(!$queue) {
|
||||
$queue = array();
|
||||
$queue = [];
|
||||
}
|
||||
if(false===array_search($name, $queue)) array_push($queue,$name);
|
||||
if(count($queue) > $this->options['length']) {
|
||||
|
||||
@@ -29,7 +29,7 @@ class Secache {
|
||||
* @param array $options 缓存参数
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($options=array()) {
|
||||
public function __construct($options=[]) {
|
||||
if(!empty($options)) {
|
||||
$this->options = array_merge($this->options,$options);
|
||||
}
|
||||
@@ -67,7 +67,7 @@ class Secache {
|
||||
// 记录缓存队列
|
||||
$queue = $this->handler->fetch(md5('__info__'));
|
||||
if(!$queue) {
|
||||
$queue = array();
|
||||
$queue = [];
|
||||
}
|
||||
if(false===array_search($key, $queue)) array_push($queue,$key);
|
||||
if(count($queue) > $this->options['length']) {
|
||||
@@ -669,7 +669,7 @@ class secache{
|
||||
}
|
||||
|
||||
function _all_schemas(){
|
||||
$schema = array();
|
||||
$schema = [];
|
||||
for($i=0;$i<16;$i++){
|
||||
$this->_seek(60+$i*$this->schema_item_size);
|
||||
$info = unpack('V1'.implode('/V1',$this->schema_struct),fread($this->_rs,$this->schema_item_size));
|
||||
@@ -683,7 +683,7 @@ class secache{
|
||||
}
|
||||
|
||||
function schemaStatus(){
|
||||
$return = array();
|
||||
$return = [];
|
||||
foreach($this->_all_schemas() as $k=>$schemaItem){
|
||||
if($schemaItem['free']){
|
||||
$this->_dfollow($schemaItem['free'],$schemaItem['freecount']);
|
||||
|
||||
@@ -24,7 +24,7 @@ class Simple {
|
||||
* 架构函数
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($options=array()) {
|
||||
public function __construct($options=[]) {
|
||||
if(!empty($options)) {
|
||||
$this->options = array_merge($this->options,$options);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class Sqlite {
|
||||
* @param array $options 缓存参数
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($options=array()) {
|
||||
public function __construct($options=[]) {
|
||||
if ( !extension_loaded('sqlite') ) {
|
||||
throw new Exception('_NOT_SUPPERT_:sqlite');
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class Wincache {
|
||||
* @param array $options 缓存参数
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($options=array()) {
|
||||
public function __construct($options=[]) {
|
||||
if ( !function_exists('wincache_ucache_info') ) {
|
||||
throw new Exception('_NOT_SUPPERT_:WinCache');
|
||||
}
|
||||
@@ -64,7 +64,7 @@ class Wincache {
|
||||
// 记录缓存队列
|
||||
$queue = wincache_ucache_get('__info__');
|
||||
if(!$queue) {
|
||||
$queue = array();
|
||||
$queue = [];
|
||||
}
|
||||
if(false===array_search($name, $queue)) array_push($queue,$name);
|
||||
if(count($queue) > $this->options['length']) {
|
||||
|
||||
@@ -26,7 +26,7 @@ class Xcache {
|
||||
* @param array $options 缓存参数
|
||||
* @access public
|
||||
*/
|
||||
public function __construct($options=array()) {
|
||||
public function __construct($options=[]) {
|
||||
if ( !function_exists('xcache_info') ) {
|
||||
throw new Exception('_NOT_SUPPERT_:Xcache');
|
||||
}
|
||||
@@ -67,7 +67,7 @@ class Xcache {
|
||||
// 记录缓存队列
|
||||
$queue = xcache_get('__info__');
|
||||
if(!$queue) {
|
||||
$queue = array();
|
||||
$queue = [];
|
||||
}
|
||||
if(false===array_search($name, $queue)) array_push($queue,$name);
|
||||
if(count($queue) > $this->options['length']) {
|
||||
|
||||
@@ -117,7 +117,7 @@ class Controller {
|
||||
*/
|
||||
private function dispatchJump($message,$status=1,$jumpUrl='',$ajax=false) {
|
||||
if(true === $ajax || IS_AJAX) {// AJAX提交
|
||||
$data = is_array($ajax)?$ajax:array();
|
||||
$data = is_array($ajax)?$ajax:[];
|
||||
$data['info'] = $message;
|
||||
$data['status'] = $status;
|
||||
$data['url'] = $jumpUrl;
|
||||
|
||||
@@ -26,7 +26,7 @@ class Mysql extends Driver{
|
||||
$this->initConnect(true);
|
||||
$sql = 'SHOW COLUMNS FROM `'.$tableName.'`';
|
||||
$result = $this->query($sql);
|
||||
$info = array();
|
||||
$info = [];
|
||||
if($result) {
|
||||
foreach ($result as $key => $val) {
|
||||
$info[$val['Field']] = array(
|
||||
@@ -49,7 +49,7 @@ class Mysql extends Driver{
|
||||
public function getTables($dbName='') {
|
||||
$sql = !empty($dbName)?'SHOW TABLES FROM '.$dbName:'SHOW TABLES ';
|
||||
$result = $this->query($sql);
|
||||
$info = array();
|
||||
$info = [];
|
||||
foreach ($result as $key => $val) {
|
||||
$info[$key] = current($val);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ class Oracle extends Driver{
|
||||
."from user_tab_columns a,(select column_name from user_constraints c,user_cons_columns col "
|
||||
."where c.constraint_name=col.constraint_name and c.constraint_type='P'and c.table_name='".strtoupper($tableName)
|
||||
."') b where table_name='".strtoupper($tableName)."' and a.column_name=b.column_name(+)");
|
||||
$info = array();
|
||||
$info = [];
|
||||
if($result) {
|
||||
foreach ($result as $key => $val) {
|
||||
$info[strtolower($val['column_name'])] = array(
|
||||
@@ -91,7 +91,7 @@ class Oracle extends Driver{
|
||||
*/
|
||||
public function getTables($dbName='') {
|
||||
$result = $this->query("select table_name from user_tables");
|
||||
$info = array();
|
||||
$info = [];
|
||||
foreach ($result as $key => $val) {
|
||||
$info[$key] = current($val);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class Pgsql extends Driver{
|
||||
*/
|
||||
public function getFields($tableName) {
|
||||
$result = $this->query('select fields_name as "Field",fields_type as "Type",fields_not_null as "Null",fields_key_name as "Key",fields_default as "Default",fields_default as "Extra" from table_msg('.$tableName.');');
|
||||
$info = array();
|
||||
$info = [];
|
||||
if($result){
|
||||
foreach ($result as $key => $val) {
|
||||
$info[$val['Field']] = array(
|
||||
@@ -49,7 +49,7 @@ class Pgsql extends Driver{
|
||||
*/
|
||||
public function getTables($dbName='') {
|
||||
$result = $this->query("select tablename as Tables_in_test from pg_tables where schemaname ='public'");
|
||||
$info = array();
|
||||
$info = [];
|
||||
foreach ($result as $key => $val) {
|
||||
$info[$key] = current($val);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class Sqlite extends Driver {
|
||||
*/
|
||||
public function getFields($tableName) {
|
||||
$result = $this->query('PRAGMA table_info( '.$tableName.' )');
|
||||
$info = array();
|
||||
$info = [];
|
||||
if($result){
|
||||
foreach ($result as $key => $val) {
|
||||
$info[$val['Field']] = array(
|
||||
@@ -51,7 +51,7 @@ class Sqlite extends Driver {
|
||||
$result = $this->query("SELECT name FROM sqlite_master WHERE type='table' "
|
||||
. "UNION ALL SELECT name FROM sqlite_temp_master "
|
||||
. "WHERE type='table' ORDER BY name");
|
||||
$info = array();
|
||||
$info = [];
|
||||
foreach ($result as $key => $val) {
|
||||
$info[$key] = current($val);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class Sqlsrv extends Driver{
|
||||
AND t.table_schema = c.table_schema
|
||||
AND t.table_name = c.table_name
|
||||
WHERE t.table_name = '$tableName'");
|
||||
$info = array();
|
||||
$info = [];
|
||||
if($result) {
|
||||
foreach ($result as $key => $val) {
|
||||
$info[$val['column_name']] = array(
|
||||
@@ -60,7 +60,7 @@ class Sqlsrv extends Driver{
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE TABLE_TYPE = 'BASE TABLE'
|
||||
");
|
||||
$info = array();
|
||||
$info = [];
|
||||
foreach ($result as $key => $val) {
|
||||
$info[$key] = current($val);
|
||||
}
|
||||
@@ -117,7 +117,7 @@ class Sqlsrv extends Driver{
|
||||
* @param array $options 表达式
|
||||
* @return false | integer
|
||||
*/
|
||||
public function delete($options=array()) {
|
||||
public function delete($options=[]) {
|
||||
$this->model = $options['model'];
|
||||
$sql = 'DELETE FROM '
|
||||
.$this->parseTable($options['table'])
|
||||
|
||||
@@ -18,7 +18,7 @@ class Error {
|
||||
* @param mixed $e 异常对象
|
||||
*/
|
||||
static public function appException($e) {
|
||||
$error = array();
|
||||
$error = [];
|
||||
$error['message'] = $e->getMessage();
|
||||
$error['file'] = $e->getFile();
|
||||
$error['line'] = $e->getLine();
|
||||
@@ -77,7 +77,7 @@ class Error {
|
||||
if(IS_CLI) {
|
||||
exit(is_array($error)?$error['message']:$error);
|
||||
}
|
||||
$e = array();
|
||||
$e = [];
|
||||
if (Config::get('app_debug')) {
|
||||
//调试模式下输出错误信息
|
||||
if (!is_array($error)) {
|
||||
|
||||
@@ -16,13 +16,13 @@ class Gif{
|
||||
* GIF帧列表
|
||||
* @var array
|
||||
*/
|
||||
private $frames = array();
|
||||
private $frames = [];
|
||||
|
||||
/**
|
||||
* 每帧等待时间列表
|
||||
* @var array
|
||||
*/
|
||||
private $delays = array();
|
||||
private $delays = [];
|
||||
|
||||
/**
|
||||
* 构造方法,用于解码GIF图片
|
||||
|
||||
@@ -21,7 +21,7 @@ class Input {
|
||||
* @param array $args 参数 array(key,filter,default)
|
||||
* @return mixed
|
||||
*/
|
||||
static public function __callStatic($type,$args=array()) {
|
||||
static public function __callStatic($type,$args=[]) {
|
||||
switch(strtolower($type)) {
|
||||
case 'get': $input =& $_GET;break;
|
||||
case 'post': $input =& $_POST;break;
|
||||
|
||||
@@ -20,14 +20,14 @@ class File {
|
||||
const SAPI = 4;
|
||||
|
||||
// 日志信息
|
||||
protected $log = array();
|
||||
protected $log = [];
|
||||
protected $config = array(
|
||||
'log_time_format' => '[ c ]',
|
||||
'log_file_size' => 2097152,
|
||||
'log_allow_level' => array('ERR','NOTIC','DEBUG','SQL','INFO'),
|
||||
);
|
||||
|
||||
public function __construct($config=array()){
|
||||
public function __construct($config=[]){
|
||||
$this->config = array_merge($this->config,$config);
|
||||
}
|
||||
|
||||
@@ -75,12 +75,12 @@ class File {
|
||||
$message = date($this->config['log_time_format']).' '.$_SERVER['REMOTE_ADDR'].' '.$_SERVER['REQUEST_URI']."\r\n";
|
||||
if($level) {
|
||||
$message .= implode('',$log)."\r\n";
|
||||
$this->log[$level] = array();
|
||||
$this->log[$level] = [];
|
||||
}else{
|
||||
foreach($log as $info){
|
||||
$message .= implode('',$info)."\r\n";
|
||||
}
|
||||
$this->log = array();
|
||||
$this->log = [];
|
||||
}
|
||||
error_log($message, 3,$destination);
|
||||
//clearstatcache();
|
||||
|
||||
@@ -173,7 +173,7 @@ abstract class Driver {
|
||||
* @param string $method 请求方法GET/POST
|
||||
* @return array $data 响应数据
|
||||
*/
|
||||
protected function http($url, $params, $method = 'GET', $header = array()){
|
||||
protected function http($url, $params, $method = 'GET', $header = []){
|
||||
$vars = http_build_query($params);
|
||||
$opts = array(
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
|
||||
@@ -39,7 +39,7 @@ class Douban extends Driver{
|
||||
*/
|
||||
public function call($api, $param = '', $method = 'GET'){
|
||||
/* 豆瓣调用公共参数 */
|
||||
$params = array();
|
||||
$params = [];
|
||||
$header = array("Authorization: Bearer {$this->token['access_token']}");
|
||||
$data = $this->http($this->url($api), $this->param($params, $param), $method, $header);
|
||||
return json_decode($data, true);
|
||||
|
||||
@@ -39,7 +39,7 @@ class Github extends Driver{
|
||||
*/
|
||||
public function call($api, $param = '', $method = 'GET'){
|
||||
/* Github 调用公共参数 */
|
||||
$params = array();
|
||||
$params = [];
|
||||
$header = array("Authorization: bearer {$this->token['access_token']}");
|
||||
|
||||
$data = $this->http($this->url($api), $this->param($params, $param), $method, $header);
|
||||
|
||||
@@ -45,7 +45,7 @@ class Google extends Driver{
|
||||
*/
|
||||
public function call($api, $param = '', $method = 'GET'){
|
||||
/* Google 调用公共参数 */
|
||||
$params = array();
|
||||
$params = [];
|
||||
$header = array("Authorization: Bearer {$this->token['access_token']}");
|
||||
|
||||
$data = $this->http($this->url($api), $this->param($params, $param), $method, $header);
|
||||
|
||||
@@ -61,7 +61,7 @@ class Renren extends Driver{
|
||||
|
||||
/* 签名 */
|
||||
ksort($params);
|
||||
$param = array();
|
||||
$param = [];
|
||||
foreach ($params as $key => $value){
|
||||
$param[] = "{$key}={$value}";
|
||||
}
|
||||
|
||||
@@ -21,30 +21,30 @@ use Think\TagLib;
|
||||
class Cx extends TagLib {
|
||||
|
||||
// 标签定义
|
||||
protected $tags = array(
|
||||
protected $tags = [
|
||||
// 标签定义: attr 属性列表 close 是否闭合(0 或者1 默认1) alias 标签别名 level 嵌套层次
|
||||
'php' => array(),
|
||||
'volist' => array('attr'=>'name,id,offset,length,key,mod','level'=>3,'alias'=>'iterate'),
|
||||
'foreach' => array('attr'=>'name,item,key','level'=>3),
|
||||
'if' => array('attr'=>'condition','level'=>2),
|
||||
'elseif' => array('attr'=>'condition','close'=>0),
|
||||
'else' => array('attr'=>'','close'=>0),
|
||||
'switch' => array('attr'=>'name','level'=>2),
|
||||
'case' => array('attr'=>'value,break'),
|
||||
'default' => array('attr'=>'','close'=>0),
|
||||
'compare' => array('attr'=>'name,value,type','level'=>3,'alias'=>'eq,equal,notequal,neq,gt,lt,egt,elt,heq,nheq'),
|
||||
'range' => array('attr'=>'name,value,type','level'=>3,'alias'=>'in,notin,between,notbetween'),
|
||||
'empty' => array('attr'=>'name','level'=>3),
|
||||
'notempty' => array('attr'=>'name','level'=>3),
|
||||
'present' => array('attr'=>'name','level'=>3),
|
||||
'notpresent'=> array('attr'=>'name','level'=>3),
|
||||
'defined' => array('attr'=>'name','level'=>3),
|
||||
'notdefined'=> array('attr'=>'name','level'=>3),
|
||||
'import' => array('attr'=>'file,href,type,value,basepath','close'=>0,'alias'=>'load,css,js'),
|
||||
'assign' => array('attr'=>'name,value','close'=>0),
|
||||
'define' => array('attr'=>'name,value','close'=>0),
|
||||
'for' => array('attr'=>'start,end,name,comparison,step', 'level'=>3),
|
||||
);
|
||||
'php' => [],
|
||||
'volist' => ['attr'=>'name,id,offset,length,key,mod','level'=>3,'alias'=>'iterate'],
|
||||
'foreach' => ['attr'=>'name,item,key','level'=>3],
|
||||
'if' => ['attr'=>'condition','level'=>2],
|
||||
'elseif' => ['attr'=>'condition','close'=>0],
|
||||
'else' => ['attr'=>'','close'=>0],
|
||||
'switch' => ['attr'=>'name','level'=>2],
|
||||
'case' => ['attr'=>'value,break'],
|
||||
'default' => ['attr'=>'','close'=>0],
|
||||
'compare' => ['attr'=>'name,value,type','level'=>3,'alias'=>'eq,equal,notequal,neq,gt,lt,egt,elt,heq,nheq'],
|
||||
'range' => ['attr'=>'name,value,type','level'=>3,'alias'=>'in,notin,between,notbetween'],
|
||||
'empty' => ['attr'=>'name','level'=>3],
|
||||
'notempty' => ['attr'=>'name','level'=>3],
|
||||
'present' => ['attr'=>'name','level'=>3],
|
||||
'notpresent'=> ['attr'=>'name','level'=>3],
|
||||
'defined' => ['attr'=>'name','level'=>3],
|
||||
'notdefined'=> ['attr'=>'name','level'=>3],
|
||||
'import' => ['attr'=>'file,href,type,value,basepath','close'=>0,'alias'=>'load,css,js'],
|
||||
'assign' => ['attr'=>'name,value','close'=>0],
|
||||
'define' => ['attr'=>'name,value','close'=>0],
|
||||
'for' => ['attr'=>'start,end,name,comparison,step', 'level'=>3],
|
||||
];
|
||||
|
||||
/**
|
||||
* php标签解析
|
||||
@@ -498,10 +498,10 @@ class Cx extends TagLib {
|
||||
list($val,$version) = explode('?',$val);
|
||||
switch($type) {
|
||||
case 'js':
|
||||
$parseStr .= '<script type="text/javascript" src="'.$basepath.'/'.str_replace(array('.','#'), array('/','.'),$val).'.js'.($version?'?'.$version:'').'"></script>';
|
||||
$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(array('.','#'), array('/','.'),$val).'.css'.($version?'?'.$version:'').'" />';
|
||||
$parseStr .= '<link rel="stylesheet" type="text/css" href="'.$basepath.'/'.str_replace(['.','#'], ['/','.'],$val).'.css'.($version?'?'.$version:'').'" />';
|
||||
break;
|
||||
case 'php':
|
||||
$parseStr .= '<?php import("'.$val.'"); ?>';
|
||||
|
||||
@@ -66,7 +66,7 @@ class Url {
|
||||
if(is_string($vars)) { // aaa=1&bbb=2 转换成数组
|
||||
parse_str($vars,$vars);
|
||||
}elseif(!is_array($vars)){
|
||||
$vars = array();
|
||||
$vars = [];
|
||||
}
|
||||
if(isset($info['query'])) { // 解析地址里面参数 合并到vars
|
||||
parse_str($info['query'],$params);
|
||||
@@ -89,7 +89,7 @@ class Url {
|
||||
// 解析分组、模块和操作
|
||||
$url = trim($url,$depr);
|
||||
$path = explode($depr,$url);
|
||||
$var = array();
|
||||
$var = [];
|
||||
$var[Config::get('var_action')] = !empty($path)?array_pop($path):ACTION_NAME;
|
||||
if(Config::get('require_controller')) {
|
||||
$var[Config::get('var_controller')] = !empty($path)?array_pop($path):CONTROLLER_NAME;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace Think;
|
||||
class Validate {
|
||||
|
||||
protected $validate = array(); // 自动验证定义
|
||||
protected $validate = []; // 自动验证定义
|
||||
// 是否批处理验证
|
||||
protected $patchValidate = false;
|
||||
protected $error = '';
|
||||
@@ -29,12 +29,12 @@ class Validate {
|
||||
* @param string $type 创建类型
|
||||
* @return boolean
|
||||
*/
|
||||
public function valid($data,$rule=array()) {
|
||||
public function valid($data,$rule=[]) {
|
||||
$validate = $rule?$rule:$this->validate;
|
||||
// 属性验证
|
||||
if($validate) { // 如果设置了数据自动验证则进行数据验证
|
||||
if($this->patchValidate) { // 重置验证错误信息
|
||||
$this->error = array();
|
||||
$this->error = [];
|
||||
}
|
||||
foreach($validate as $key=>$val) {
|
||||
// 验证因子定义格式
|
||||
@@ -87,7 +87,7 @@ class Validate {
|
||||
protected function _validationFieldItem($data,$val) {
|
||||
switch(strtolower(trim($val[4]))) {
|
||||
case 'callback':// 调用方法进行验证
|
||||
$args = isset($val[5])?(array)$val[5]:array();
|
||||
$args = isset($val[5])?(array)$val[5]:[];
|
||||
if(is_string($val[0]) && strpos($val[0], ','))
|
||||
$val[0] = explode(',', $val[0]);
|
||||
if(is_array($val[0])){
|
||||
|
||||
Reference in New Issue
Block a user