From 1a4a102b498e9ad68ebd8341567fa74743723044 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 21 Feb 2015 17:32:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E8=8C=83=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base.php | 45 +++++++++---------- .../content_replace.php} | 0 .../location_template.php} | 0 .../read_html_cache.php} | 0 .../show_page_trace.php} | 0 .../token_build.php} | 0 library/think/cache/driver/secache.php | 4 +- library/think/loader.php | 8 ++-- library/think/session.php | 4 +- library/think/view.php | 2 +- mode/sae/convention.php | 39 ---------------- 11 files changed, 32 insertions(+), 70 deletions(-) rename library/{think/behavior/ContentReplace.php => behavior/content_replace.php} (100%) rename library/{think/behavior/LocationTemplate.php => behavior/location_template.php} (100%) rename library/{think/behavior/ReadHtmlCache.php => behavior/read_html_cache.php} (100%) rename library/{think/behavior/ShowPageTrace.php => behavior/show_page_trace.php} (100%) rename library/{think/behavior/TokenBuild.php => behavior/token_build.php} (100%) delete mode 100644 mode/sae/convention.php diff --git a/base.php b/base.php index 943899b3..fd417be1 100644 --- a/base.php +++ b/base.php @@ -9,37 +9,36 @@ // | Author: liu21st // +---------------------------------------------------------------------- -if(version_compare(PHP_VERSION,'5.4.0','<')) die('require PHP > 5.4.0 !'); define('MAGIC_QUOTES_GPC', false); // 版本信息 define('THINK_VERSION', '4.0beta'); // 系统常量 -defined('THINK_PATH') or define('THINK_PATH', dirname(__FILE__).'/'); -defined('LIB_PATH') or define('LIB_PATH', THINK_PATH.'library/'); -defined('MODE_PATH') or define('MODE_PATH', THINK_PATH.'mode/'); // 系统应用模式目录 -defined('TRAIT_PATH') or define('TRAIT_PATH', THINK_PATH.'traits/'); -defined('CORE_PATH') or define('CORE_PATH', LIB_PATH.'think/'); -defined('ORG_PATH') or define('ORG_PATH', LIB_PATH.'org/'); -defined('APP_PATH') or define('APP_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/'); -defined('RUNTIME_PATH') or define('RUNTIME_PATH', realpath(APP_PATH).'/runtime/'); -defined('DATA_PATH') or define('DATA_PATH', RUNTIME_PATH.'data/'); -defined('LOG_PATH') or define('LOG_PATH', RUNTIME_PATH.'log/'); -defined('CACHE_PATH') or define('CACHE_PATH', RUNTIME_PATH.'cache/'); -defined('TEMP_PATH') or define('TEMP_PATH', RUNTIME_PATH.'temp/'); -defined('VENDOR_PATH') or define('VENDOR_PATH', THINK_PATH.'vendor/'); -defined('EXT') or define('EXT', '.php'); -defined('MODEL_LAYER') or define('MODEL_LAYER', 'model'); -defined('VIEW_LAYER') or define('VIEW_LAYER', 'view'); -defined('CONTROLLER_LAYER') or define('CONTROLLER_LAYER', 'controller'); -defined('APP_DEBUG') or define('APP_DEBUG', false); // 是否调试模式 +defined('THINK_PATH') || define('THINK_PATH', dirname(__FILE__).'/'); +defined('LIB_PATH') || define('LIB_PATH', THINK_PATH.'library/'); +defined('MODE_PATH') || define('MODE_PATH', THINK_PATH.'mode/'); // 系统应用模式目录 +defined('TRAIT_PATH') || define('TRAIT_PATH', THINK_PATH.'traits/'); +defined('CORE_PATH') || define('CORE_PATH', LIB_PATH.'think/'); +defined('ORG_PATH') || define('ORG_PATH', LIB_PATH.'org/'); +defined('APP_PATH') || define('APP_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/'); +defined('RUNTIME_PATH') || define('RUNTIME_PATH', realpath(APP_PATH).'/runtime/'); +defined('DATA_PATH') || define('DATA_PATH', RUNTIME_PATH.'data/'); +defined('LOG_PATH') || define('LOG_PATH', RUNTIME_PATH.'log/'); +defined('CACHE_PATH') || define('CACHE_PATH', RUNTIME_PATH.'cache/'); +defined('TEMP_PATH') || define('TEMP_PATH', RUNTIME_PATH.'temp/'); +defined('VENDOR_PATH') || define('VENDOR_PATH', THINK_PATH.'vendor/'); +defined('EXT') || define('EXT', '.php'); +defined('MODEL_LAYER') || define('MODEL_LAYER', 'model'); +defined('VIEW_LAYER') || define('VIEW_LAYER', 'view'); +defined('CONTROLLER_LAYER') || define('CONTROLLER_LAYER', 'controller'); +defined('APP_DEBUG') || define('APP_DEBUG', false); // 是否调试模式 if(function_exists('saeAutoLoader')){// 自动识别SAE环境 - defined('APP_MODE') or define('APP_MODE', 'sae'); - defined('STORAGE_TYPE') or define('STORAGE_TYPE', 'Sae'); + defined('APP_MODE') || define('APP_MODE', 'sae'); + defined('STORAGE_TYPE') || define('STORAGE_TYPE', 'Sae'); }else{ - defined('APP_MODE') or define('APP_MODE', 'common'); // 应用模式 默认为普通模式 - defined('STORAGE_TYPE') or define('STORAGE_TYPE', 'File'); // 存储类型 默认为File + defined('APP_MODE') || define('APP_MODE', 'common'); // 应用模式 默认为普通模式 + defined('STORAGE_TYPE') || define('STORAGE_TYPE', 'File'); // 存储类型 默认为File } // 环境常量 diff --git a/library/think/behavior/ContentReplace.php b/library/behavior/content_replace.php similarity index 100% rename from library/think/behavior/ContentReplace.php rename to library/behavior/content_replace.php diff --git a/library/think/behavior/LocationTemplate.php b/library/behavior/location_template.php similarity index 100% rename from library/think/behavior/LocationTemplate.php rename to library/behavior/location_template.php diff --git a/library/think/behavior/ReadHtmlCache.php b/library/behavior/read_html_cache.php similarity index 100% rename from library/think/behavior/ReadHtmlCache.php rename to library/behavior/read_html_cache.php diff --git a/library/think/behavior/ShowPageTrace.php b/library/behavior/show_page_trace.php similarity index 100% rename from library/think/behavior/ShowPageTrace.php rename to library/behavior/show_page_trace.php diff --git a/library/think/behavior/TokenBuild.php b/library/behavior/token_build.php similarity index 100% rename from library/think/behavior/TokenBuild.php rename to library/behavior/token_build.php diff --git a/library/think/cache/driver/secache.php b/library/think/cache/driver/secache.php index 7b1ed37f..8e63bec1 100644 --- a/library/think/cache/driver/secache.php +++ b/library/think/cache/driver/secache.php @@ -161,7 +161,7 @@ class SecacheClient{ if(!file_exists($this->_file)){ $this->create(); }else{ - $this->_rs = fopen($this->_file,'rb+') or $this->trigger_error('Can\'t open the cachefile: '.realpath($this->_file),E_USER_ERROR); + $this->_rs = fopen($this->_file,'rb+') || $this->trigger_error('Can\'t open the cachefile: '.realpath($this->_file),E_USER_ERROR); $this->_seek($this->header_padding); $info = unpack('V1max_size/a*ver',fread($this->_rs,$this->info_size)); if($info['ver']!=$this->ver){ @@ -178,7 +178,7 @@ class SecacheClient{ } function create(){ - $this->_rs = fopen($this->_file,'wb+') or $this->trigger_error('Can\'t open the cachefile: '.realpath($this->_file),E_USER_ERROR);; + $this->_rs = fopen($this->_file,'wb+') || $this->trigger_error('Can\'t open the cachefile: '.realpath($this->_file),E_USER_ERROR);; fseek($this->_rs,0); fputs($this->_rs,'<'.'?php exit()?'.'>'); return $this->_format(); diff --git a/library/think/loader.php b/library/think/loader.php index 048649c8..8f82937c 100644 --- a/library/think/loader.php +++ b/library/think/loader.php @@ -25,9 +25,11 @@ class Loader { include self::$map[$class]; }else{ // 命名空间自动加载 $name = strstr($class, '\\', true); - if(isset(self::$namespace[$name])){ // 注册的命名空间 + if(isset(self::$namespace[$name])){ + // 注册的命名空间 $path = dirname(self::$namespace[$name]) . '/'; - }elseif(is_dir(LIB_PATH.$name)){ // Library目录下面的命名空间自动定位 + }elseif(in_array($name,['think','org','behavior','com']) || is_dir(LIB_PATH.$name)){ + // Library目录下面的命名空间自动定位 $path = LIB_PATH; }else{ // 项目命名空间 $path = APP_PATH; @@ -78,7 +80,7 @@ class Loader { //加载当前项目应用类库 $class = substr_replace($class, '', 0, strlen($class_strut[0]) + 1); $baseUrl = MODULE_PATH; - }elseif (in_array($class_strut[0], ['think','org', 'com'])) { + }elseif (in_array($class_strut[0], ['think','behavior','org', 'com'])) { // org 第三方公共类库 com 企业公共类库 $baseUrl = LIB_PATH; }elseif(in_array($class_strut[0], ['vendor', 'traits'])){ diff --git a/library/think/session.php b/library/think/session.php index d5d985d8..fa739883 100644 --- a/library/think/session.php +++ b/library/think/session.php @@ -138,7 +138,7 @@ class Session { * @return void */ static public function delete($name,$prefix='') { - $prefix = $prefix?$prefix:$this->prefix; + $prefix = $prefix ? $prefix : self::$prefix; if(strpos($name,'.')){ list($name1,$name2) = explode('.',$name); if($prefix){ @@ -161,7 +161,7 @@ class Session { * @return void */ static public function clear($prefix='') { - $prefix = $prefix?$prefix:self::$prefix; + $prefix = $prefix ? $prefix : self::$prefix; if($prefix) { unset($_SESSION[$prefix]); }else{ diff --git a/library/think/view.php b/library/think/view.php index 6ee914fe..eedf5e75 100644 --- a/library/think/view.php +++ b/library/think/view.php @@ -168,7 +168,7 @@ class View { list($module,$template) = explode('@',$template); } // 获取当前主题的模版路径 - defined('THEME_PATH') or define('THEME_PATH', $this->getThemePath($module)); + defined('THEME_PATH') || define('THEME_PATH', $this->getThemePath($module)); // 分析模板文件规则 if('' == $template) { diff --git a/mode/sae/convention.php b/mode/sae/convention.php deleted file mode 100644 index 9101e436..00000000 --- a/mode/sae/convention.php +++ /dev/null @@ -1,39 +0,0 @@ - -// +---------------------------------------------------------------------- - -/** - * SAE模式惯例配置文件 - * 该文件请不要修改,如果要覆盖惯例配置的值,可在应用配置文件中设定和惯例不符的配置项 - * 配置名称大小写任意,系统会统一转换成小写 - * 所有配置参数都可以在生效前动态改变 - */ -defined('THINK_PATH') or exit(); -$st = new SaeStorage(); -return array( - //SAE下固定mysql配置 - 'DB_TYPE' => 'mysql', // 数据库类型 - 'DB_DEPLOY_TYPE' => 1, - 'DB_RW_SEPARATE' => true, - 'DB_HOST' => SAE_MYSQL_HOST_M.','.SAE_MYSQL_HOST_S, // 服务器地址 - 'DB_NAME' => SAE_MYSQL_DB, // 数据库名 - 'DB_USER' => SAE_MYSQL_USER, // 用户名 - 'DB_PWD' => SAE_MYSQL_PASS, // 密码 - 'DB_PORT' => SAE_MYSQL_PORT, // 端口 - //更改模板替换变量,让普通能在所有平台下显示 - 'TMPL_PARSE_STRING' => array( - // __PUBLIC__/upload --> /Public/upload -->http://appname-public.stor.sinaapp.com/upload - '/Public/upload' => $st->getUrl('public','upload') - ), - 'LOG_TYPE' => 'Sae', - 'DATA_CACHE_TYPE' => 'Memcachesae', - 'CHECK_APP_DIR' => false, - 'FILE_UPLOAD_TYPE' => 'Sae', -);