数组定义用法统一

This commit is contained in:
thinkphp
2013-04-11 14:49:39 +08:00
parent bbe3ebedcf
commit 00ee80e943
35 changed files with 83 additions and 81 deletions

View File

@@ -44,7 +44,7 @@ class ContentReplace {
define('ACTION_URL', CONTROLLER_URL.'/'.ACTION_NAME);
// 系统默认的特殊变量替换
$replace = array(
$replace = [
'__ROOT__' => ROOT_URL, // 当前网站地址
'__APP__' => MODULE_URL, // 当前项目地址
'__CONTROLL__' => CONTROLLER_URL, // 当前操作地址
@@ -52,7 +52,7 @@ class ContentReplace {
'__ACTION__' => ACTION_URL, // 当前操作地址
'__SELF__' => $_SERVER['PHP_SELF'], // 当前页面地址
'__PUBLIC__' => ROOT_URL.'/Public',// 站点公共目录
);
];
// 允许用户自定义模板的字符串替换
if(is_array(Config::get('tmpl_parse_string')) )
$replace = array_merge($replace,Config::get('tmpl_parse_string'));

View File

@@ -17,12 +17,12 @@
* @author liu21st <liu21st@gmail.com>
*/
class ReadHtmlCacheBehavior {
protected $options = array(
protected $options = [
'HTML_CACHE_ON' => false,
'HTML_CACHE_TIME' => 60,
'HTML_CACHE_RULES' => [],
'HTML_FILE_SUFFIX' => '.html',
);
];
// 行为扩展的执行入口必须是run
public function run(&$params){
@@ -72,8 +72,8 @@ class ReadHtmlCacheBehavior {
$rule = preg_replace('/{(\w+)}/e',"\$_GET['\\1']",$rule);
// 特殊系统变量
$rule = str_ireplace(
array('{:app}','{:module}','{:action}','{:group}'),
array(APP_NAME,MODULE_NAME,ACTION_NAME,defined('GROUP_NAME')?GROUP_NAME:''),
['{:app}','{:module}','{:action}','{:group}'],
[APP_NAME,MODULE_NAME,ACTION_NAME,defined('GROUP_NAME')?GROUP_NAME:''],
$rule);
// {|FUN} 单独使用函数
$rule = preg_replace('/{|(\w+)}/e',"\\1()",$rule);

View File

@@ -42,7 +42,7 @@ class ShowPageTrace {
}
$trace = [];
Debug::remark('START',$GLOBALS['startTime']);
$base = array(
$base = [
'请求信息' => date('Y-m-d H:i:s',$_SERVER['REQUEST_TIME']).' '.$_SERVER['SERVER_PROTOCOL'].' '.$_SERVER['REQUEST_METHOD'].' : '.$_SERVER['PHP_SELF'],
'运行时间' => Debug::getUseTime('START','END',6).'s',
'内存开销' => MEMORY_LIMIT_ON?G('START','END','m').'b':'不支持',
@@ -50,7 +50,7 @@ class ShowPageTrace {
'文件加载' => count($files),
'缓存信息' => N('cache_read').' gets '.N('cache_write').' writes ',
'配置加载' => count(Config::get()),
);
];
// 读取项目定义的Trace文件
$traceFile = MODULE_PATH.'trace.php';
if(is_file($traceFile)) {

View File

@@ -19,12 +19,12 @@ defined('THINK_PATH') or exit();
*/
class TokenBuildBehavior extends Behavior {
// 行为参数定义
protected $options = array(
protected $options = [
'TOKEN_ON' => false, // 开启令牌验证
'TOKEN_NAME' => '__hash__', // 令牌验证的表单隐藏字段名称
'TOKEN_TYPE' => 'md5', // 令牌验证哈希规则
'TOKEN_RESET' => true, // 令牌错误后是否重置
);
];
public function run(&$content){
if(C('TOKEN_ON')) {