@@ -20,6 +20,8 @@ abstract class Addons
2020 protected $ error ;
2121 // 插件目录
2222 public $ addons_path = '' ;
23+ public $ addonPath = '' ;
24+
2325 // 插件标识
2426 protected $ addonName = '' ;
2527 // 插件配置作用域
@@ -39,10 +41,11 @@ public function __construct($name = null)
3941 $ this ->addonName = $ name ;
4042
4143 // 获取当前插件目录
42- $ this ->addons_path = ADDON_PATH . $ name . DS ;
44+ $ this ->addonPath = ADDON_PATH . $ name . DS ;
45+ $ this ->addons_path = $ this ->addonPath ;
4346
4447 // 初始化视图模型
45- $ config = ['view_path ' => $ this ->addons_path ];
48+ $ config = ['view_path ' => $ this ->addonPath ];
4649 $ config = array_merge (Config::get ('template ' ), $ config );
4750 $ this ->view = new View ($ config , Config::get ('view_replace_str ' ));
4851
@@ -69,9 +72,9 @@ final public function getInfo($name = '', $force = false)
6972 }
7073 }
7174 $ info = [];
72- $ info_file = $ this ->addons_path . 'info.ini ' ;
73- if (is_file ($ info_file )) {
74- $ info = Config::parse ($ info_file , '' , $ name , $ this ->infoRange );
75+ $ infoFile = $ this ->addonPath . 'info.ini ' ;
76+ if (is_file ($ infoFile )) {
77+ $ info = Config::parse ($ infoFile , '' , $ name , $ this ->infoRange );
7578 $ info ['url ' ] = addon_url ($ name );
7679 }
7780 Config::set ($ name , $ info , $ this ->infoRange );
@@ -96,13 +99,15 @@ final public function getConfig($name = '', $force = false)
9699 }
97100 }
98101 $ config = [];
99- $ config_file = $ this ->addons_path . 'config.php ' ;
100- if (is_file ($ config_file )) {
101- $ temp_arr = include $ config_file ;
102- foreach ($ temp_arr as $ key => $ value ) {
103- $ config [$ value ['name ' ]] = $ value ['value ' ];
102+ $ configFile = $ this ->addonPath . 'config.php ' ;
103+ if (is_file ($ configFile )) {
104+ $ configArr = include $ configFile ;
105+ if (is_array ($ configArr )) {
106+ foreach ($ configArr as $ key => $ value ) {
107+ $ config [$ value ['name ' ]] = $ value ['value ' ];
108+ }
109+ unset($ configArr );
104110 }
105- unset($ temp_arr );
106111 }
107112 Config::set ($ name , $ config , $ this ->configRange );
108113
@@ -154,9 +159,9 @@ final public function getFullConfig($name = '')
154159 if (empty ($ name )) {
155160 $ name = $ this ->getName ();
156161 }
157- $ config_file = $ this ->addons_path . 'config.php ' ;
158- if (is_file ($ config_file )) {
159- $ fullConfigArr = include $ config_file ;
162+ $ configFile = $ this ->addonPath . 'config.php ' ;
163+ if (is_file ($ configFile )) {
164+ $ fullConfigArr = include $ configFile ;
160165 }
161166 return $ fullConfigArr ;
162167 }
0 commit comments