88
99class ZalyConfig
1010{
11+ private static $ verifySessionKey = "session_verify_ " ;
12+
13+ public static $ configSiteVersionNameKey = "siteVersionName " ;
14+ public static $ configSiteVersionCodeKey = "siteVersionCode " ;
15+
1116 public static $ config ;
12- private static $ verifySessionKey = " session_verify_ " ;
17+ public static $ sampleConfig ;
1318
14- public static function getConfigFile ()
19+ //load config.php
20+ public static function loadConfigFile ()
1521 {
16- $ fileName = dirname (__FILE__ ) ."/../../config.php " ;
17- if (!file_exists ($ fileName )) {
18- $ fileName = dirname (__FILE__ ) ."/../../config.sample.php " ;
22+ $ fileName = dirname (__FILE__ ) . "/../../config.php " ;
23+ if (!file_exists ($ fileName )) {
24+ $ fileName = dirname (__FILE__ ) . "/../../config.sample.php " ;
1925 }
2026
2127 self ::$ config = require ($ fileName );
2228 }
2329
24- public static function getConfig ($ key = "" )
30+ // load sample.config.php
31+ public static function loadSampleConfigFile ()
32+ {
33+ $ sampleConfigFileName = dirname (__FILE__ ) . "/../../config.sample.php " ;
34+
35+ self ::$ sampleConfig = require ($ sampleConfigFileName );
36+ }
37+
38+ public static function getConfig ($ key = "" )
2539 {
26- self ::getConfigFile ();
27- if (isset (self ::$ config [$ key ])) {
40+ self ::loadConfigFile ();
41+ if (isset (self ::$ config [$ key ])) {
2842 return self ::$ config [$ key ];
2943 }
3044 return false ;
3145 }
46+
47+ public static function getSampleConfig ($ key = "" )
48+ {
49+
50+ self ::loadSampleConfigFile ();
51+
52+ if (isset (self ::$ sampleConfig [$ key ])) {
53+ return self ::$ sampleConfig [$ key ];
54+ }
55+
56+ return false ;
57+ }
58+
3259 public static function getAllConfig ()
3360 {
34- self ::getConfigFile ();
61+ self ::loadConfigFile ();
3562 return self ::$ config ;
3663 }
3764
3865
3966 public static function getSessionVerifyUrl ($ pluginId )
4067 {
41- self ::getConfigFile ();
42- $ key = self ::$ verifySessionKey. $ pluginId ;
68+ self ::loadConfigFile ();
69+ $ key = self ::$ verifySessionKey . $ pluginId ;
4370 return self ::$ config [$ key ];
4471 }
4572
4673 public static function getApiIndexUrl ()
4774 {
4875 $ domain = self ::getDomain ();
4976 $ pageIndexUrl = self ::$ config ['apiPageIndex ' ];
50- if (strpos ($ pageIndexUrl ,"./ " ) == 0 ) {
77+ if (strpos ($ pageIndexUrl , "./ " ) == 0 ) {
5178 $ pageIndexUrl = str_replace ("./ " , "/ " , $ pageIndexUrl );
5279 }
53- return $ domain. $ pageIndexUrl ;
80+ return $ domain . $ pageIndexUrl ;
5481 }
5582
5683 public static function getApiPageJumpUrl ()
5784 {
5885 $ domain = self ::getDomain ();
5986 $ pageJumpUrl = self ::$ config ['apiPageJump ' ];
60- if (strpos ($ pageJumpUrl ,"./ " ) == 0 ) {
87+ if (strpos ($ pageJumpUrl , "./ " ) == 0 ) {
6188 $ pageJumpUrl = str_replace ("./ " , "/ " , $ pageJumpUrl );
6289 }
63- return $ domain. $ pageJumpUrl ;
90+ return $ domain . $ pageJumpUrl ;
6491 }
6592
6693 public static function getApiPageWidget ()
6794 {
6895 $ domain = self ::getDomain ();
6996 $ pageWidgetUrl = self ::$ config ['apiPageWidget ' ];
70- if (strpos ($ pageWidgetUrl ,"./ " ) == 0 ) {
97+ if (strpos ($ pageWidgetUrl , "./ " ) == 0 ) {
7198 $ pageWidgetUrl = str_replace ("./ " , "/ " , $ pageWidgetUrl );
7299 }
73- return $ domain. $ pageWidgetUrl ;
100+ return $ domain . $ pageWidgetUrl ;
74101 }
75102
76103 public static function getDomain ()
77104 {
78- self ::getConfigFile ();
105+ self ::loadConfigFile ();
79106
80- $ scheme = isset ($ _SERVER ['REQUEST_SCHEME ' ]) ? $ _SERVER ['REQUEST_SCHEME ' ]. ":// " : "http:// " ;
81- $ domain = isset ($ _SERVER ['HTTP_HOST ' ]) ? $ _SERVER ['HTTP_HOST ' ] : "" ;
107+ $ scheme = isset ($ _SERVER ['REQUEST_SCHEME ' ]) ? $ _SERVER ['REQUEST_SCHEME ' ] . ":// " : "http:// " ;
108+ $ domain = isset ($ _SERVER ['HTTP_HOST ' ]) ? $ _SERVER ['HTTP_HOST ' ] : "" ;
82109
83- return $ scheme. $ domain ;
110+ return $ scheme . $ domain ;
84111 }
85112}
0 commit comments