Passed
Push — 1.0.0-dev ( 2b6704...9c9ab7 )
by nguereza
03:19
created
core/classes/Module.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
     */
26 26
    
27
-	class Module{
27
+	class Module {
28 28
 		
29 29
 		/**
30 30
 		 * list of loaded module
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 		 * The signleton of the logger
43 43
 		 * @return Object the Log instance
44 44
 		 */
45
-		private static function getLogger(){
46
-			if(self::$logger == null){
47
-				self::$logger[0] =& class_loader('Log', 'classes');
45
+		private static function getLogger() {
46
+			if (self::$logger == null) {
47
+				self::$logger[0] = & class_loader('Log', 'classes');
48 48
 				self::$logger[0]->setLogger('Library::Module');
49 49
 			}
50 50
 			return self::$logger[0];
@@ -53,24 +53,24 @@  discard block
 block discarded – undo
53 53
 		/**
54 54
 		 * Initialise the module list by scanning the directory MODULE_PATH
55 55
 		 */
56
-		public function init(){
56
+		public function init() {
57 57
 			$logger = self::getLogger();
58 58
 			$logger->debug('Check if the application contains the modules ...');
59 59
 			$moduleDir = opendir(MODULE_PATH);
60
-			if(is_resource($moduleDir)){
61
-				while(($module = readdir($moduleDir)) !== false){
62
-					if(preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)){
60
+			if (is_resource($moduleDir)) {
61
+				while (($module = readdir($moduleDir)) !== false) {
62
+					if (preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)) {
63 63
 						self::$list[] = $module;
64 64
 					}
65
-					else{
66
-						$logger->info('Skipping [' .$module. '], may be this is not a directory or does not exists or is invalid name');
65
+					else {
66
+						$logger->info('Skipping [' . $module . '], may be this is not a directory or does not exists or is invalid name');
67 67
 					}
68 68
 				}
69 69
 				closedir($moduleDir);
70 70
 			}
71 71
 			ksort(self::$list);
72 72
 			
73
-			if(self::hasModule()){
73
+			if (self::hasModule()) {
74 74
 				$logger->info('The application contains the module below [' . implode(', ', self::getModuleList()) . ']');
75 75
 			}
76 76
 		}
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 		 * Get the list of the custom autoload configuration from module if exists
80 80
 		 * @return array|boolean the autoload configurations list or false if no module contains the autoload configuration values
81 81
 		 */
82
-		public static function getModulesAutoloadConfig(){
82
+		public static function getModulesAutoloadConfig() {
83 83
 			$logger = self::getLogger();
84
-			if(! self::hasModule()){
84
+			if (!self::hasModule()) {
85 85
 				$logger->info('No module was loaded skipping.');
86 86
 				return false;
87 87
 			}
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
 			
95 95
 			foreach (self::$list as $module) {
96 96
 				$file = MODULE_PATH . $module . DS . 'config' . DS . 'autoload.php';
97
-				if(file_exists($file)){
97
+				if (file_exists($file)) {
98 98
 					$autoload = array();
99 99
 					require_once $file;
100
-					if(! empty($autoload) && is_array($autoload)){
100
+					if (!empty($autoload) && is_array($autoload)) {
101 101
 						$autoloads = array_merge_recursive($autoloads, $autoload);
102 102
 						unset($autoload);
103 103
 					}
@@ -110,19 +110,19 @@  discard block
 block discarded – undo
110 110
 		 * Get the list of the custom routes configuration from module if exists
111 111
 		 * @return array|boolean the routes list or false if no module contains the routes configuration
112 112
 		 */
113
-		public static function getModulesRoutes(){
113
+		public static function getModulesRoutes() {
114 114
 			$logger = self::getLogger();
115
-			if(! self::hasModule()){
115
+			if (!self::hasModule()) {
116 116
 				$logger->info('No module was loaded skipping.');
117 117
 				return false;
118 118
 			}
119 119
 			$routes = array();
120 120
 			foreach (self::$list as $module) {
121 121
 				$file = MODULE_PATH . $module . DS . 'config' . DS . 'routes.php';
122
-				if(file_exists($file)){
122
+				if (file_exists($file)) {
123 123
 					$route = array();
124 124
 					require_once $file;
125
-					if(! empty($route) && is_array($route)){
125
+					if (!empty($route) && is_array($route)) {
126 126
 						$routes = array_merge($routes, $route);
127 127
 						unset($route);
128 128
 					}
@@ -138,22 +138,22 @@  discard block
 block discarded – undo
138 138
 		 * @param  string $module  the module name
139 139
 		 * @return boolean|string  false or null if no module have this controller, path the full path of the controller
140 140
 		 */
141
-		public static function findControllerFullPath($class, $module = null){
141
+		public static function findControllerFullPath($class, $module = null) {
142 142
 			$logger = self::getLogger();
143
-			if(! self::hasModule()){
143
+			if (!self::hasModule()) {
144 144
 				$logger->info('No module was loaded skiping.');
145 145
 				return false;
146 146
 			}
147 147
 			$class = str_ireplace('.php', '', $class);
148 148
 			$class = ucfirst($class);
149
-			$classFile = $class.'.php';
150
-			$logger->debug('Checking the controller [' . $class . '] in module [' .$module. '] ...');
149
+			$classFile = $class . '.php';
150
+			$logger->debug('Checking the controller [' . $class . '] in module [' . $module . '] ...');
151 151
 			$filePath = MODULE_PATH . $module . DS . 'controllers' . DS . $classFile;
152
-			if(file_exists($filePath)){
153
-				$logger->info('Found controller [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
152
+			if (file_exists($filePath)) {
153
+				$logger->info('Found controller [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']');
154 154
 				return $filePath;
155 155
 			}
156
-			$logger->info('Controller [' . $class . '] does not exist in the module [' .$module. ']');
156
+			$logger->info('Controller [' . $class . '] does not exist in the module [' . $module . ']');
157 157
 			return false;
158 158
 		}
159 159
 
@@ -163,22 +163,22 @@  discard block
 block discarded – undo
163 163
 		 * @param string $module the module name
164 164
 		 * @return boolean|string  false or null if no module have this model, return the full path of this model
165 165
 		 */
166
-		public static function findModelFullPath($class, $module = null){
166
+		public static function findModelFullPath($class, $module = null) {
167 167
 			$logger = self::getLogger();
168
-			if(! self::hasModule()){
168
+			if (!self::hasModule()) {
169 169
 				$logger->info('No module was loaded skiping.');
170 170
 				return false;
171 171
 			}
172 172
 			$class = str_ireplace('.php', '', $class);
173 173
 			$class = ucfirst($class);
174
-			$classFile = $class.'.php';
175
-			$logger->debug('Checking model [' . $class . '] in module [' .$module. '] ...');
174
+			$classFile = $class . '.php';
175
+			$logger->debug('Checking model [' . $class . '] in module [' . $module . '] ...');
176 176
 			$filePath = MODULE_PATH . $module . DS . 'models' . DS . $classFile;
177
-			if(file_exists($filePath)){
178
-				$logger->info('Found model [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
177
+			if (file_exists($filePath)) {
178
+				$logger->info('Found model [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']');
179 179
 				return $filePath;
180 180
 			}
181
-			$logger->info('Model [' . $class . '] does not exist in the module [' .$module. ']');
181
+			$logger->info('Model [' . $class . '] does not exist in the module [' . $module . ']');
182 182
 			return false;
183 183
 		}
184 184
 		
@@ -188,21 +188,21 @@  discard block
 block discarded – undo
188 188
 		 * @param string $module the module name
189 189
 		 * @return boolean|string  false or null if no module have this configuration,  return the full path of this configuration
190 190
 		 */
191
-		public static function findConfigFullPath($configuration, $module = null){
191
+		public static function findConfigFullPath($configuration, $module = null) {
192 192
 			$logger = self::getLogger();
193
-			if(! self::hasModule()){
193
+			if (!self::hasModule()) {
194 194
 				$logger->info('No module was loaded skiping.');
195 195
 				return false;
196 196
 			}
197 197
 			$configuration = str_ireplace('.php', '', $configuration);
198
-			$file = $configuration.'.php';
199
-			$logger->debug('Checking configuration [' . $configuration . '] in module [' .$module. '] ...');
198
+			$file = $configuration . '.php';
199
+			$logger->debug('Checking configuration [' . $configuration . '] in module [' . $module . '] ...');
200 200
 			$filePath = MODULE_PATH . $module . DS . 'config' . DS . $file;
201
-			if(file_exists($filePath)){
202
-				$logger->info('Found configuration [' . $configuration . '] in module [' .$module. '], the file path is [' .$filePath. ']');
201
+			if (file_exists($filePath)) {
202
+				$logger->info('Found configuration [' . $configuration . '] in module [' . $module . '], the file path is [' . $filePath . ']');
203 203
 				return $filePath;
204 204
 			}
205
-			$logger->info('Configuration [' . $configuration . '] does not exist in the module [' .$module. ']');
205
+			$logger->info('Configuration [' . $configuration . '] does not exist in the module [' . $module . ']');
206 206
 			return false;
207 207
 		}
208 208
 
@@ -212,22 +212,22 @@  discard block
 block discarded – undo
212 212
 		 * @param string $module the module name
213 213
 		 * @return boolean|string  false or null if no module have this helper,  return the full path of this helper
214 214
 		 */
215
-		public static function findFunctionFullPath($helper, $module = null){
215
+		public static function findFunctionFullPath($helper, $module = null) {
216 216
 			$logger = self::getLogger();
217
-			if(! self::hasModule()){
217
+			if (!self::hasModule()) {
218 218
 				$logger->info('No module was loaded skiping.');
219 219
 				return false;
220 220
 			}
221 221
 			$helper = str_ireplace('.php', '', $helper);
222 222
 			$helper = str_ireplace('function_', '', $helper);
223
-			$file = 'function_'.$helper.'.php';
224
-			$logger->debug('Checking helper [' . $helper . '] in module [' .$module. '] ...');
223
+			$file = 'function_' . $helper . '.php';
224
+			$logger->debug('Checking helper [' . $helper . '] in module [' . $module . '] ...');
225 225
 			$filePath = MODULE_PATH . $module . DS . 'functions' . DS . $file;
226
-			if(file_exists($filePath)){
227
-				$logger->info('Found helper [' . $helper . '] in module [' .$module. '], the file path is [' .$filePath. ']');
226
+			if (file_exists($filePath)) {
227
+				$logger->info('Found helper [' . $helper . '] in module [' . $module . '], the file path is [' . $filePath . ']');
228 228
 				return $filePath;
229 229
 			}
230
-			$logger->info('Helper [' . $helper . '] does not exist in the module [' .$module. ']');
230
+			$logger->info('Helper [' . $helper . '] does not exist in the module [' . $module . ']');
231 231
 			return false;
232 232
 			
233 233
 		}
@@ -239,21 +239,21 @@  discard block
 block discarded – undo
239 239
 		 * @param string $module the module name
240 240
 		 * @return boolean|string  false or null if no module have this library,  return the full path of this library
241 241
 		 */
242
-		public static function findLibraryFullPath($class, $module = null){
242
+		public static function findLibraryFullPath($class, $module = null) {
243 243
 			$logger = self::getLogger();
244
-			if(! self::hasModule()){
244
+			if (!self::hasModule()) {
245 245
 				$logger->info('No module was loaded skiping.');
246 246
 				return false;
247 247
 			}
248 248
 			$class = str_ireplace('.php', '', $class);
249
-			$file = $class.'.php';
250
-			$logger->debug('Checking library [' . $class . '] in module [' .$module. '] ...');
249
+			$file = $class . '.php';
250
+			$logger->debug('Checking library [' . $class . '] in module [' . $module . '] ...');
251 251
 			$filePath = MODULE_PATH . $module . DS . 'libraries' . DS . $file;
252
-			if(file_exists($filePath)){
253
-				$logger->info('Found library [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
252
+			if (file_exists($filePath)) {
253
+				$logger->info('Found library [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']');
254 254
 				return $filePath;
255 255
 			}
256
-			$logger->info('Library [' . $class . '] does not exist in the module [' .$module. ']');
256
+			$logger->info('Library [' . $class . '] does not exist in the module [' . $module . ']');
257 257
 			return false;
258 258
 		}
259 259
 
@@ -264,9 +264,9 @@  discard block
 block discarded – undo
264 264
 		 * @param string $module the module name to check
265 265
 		 * @return boolean|string  false or null if no module have this view, path the full path of the view
266 266
 		 */
267
-		public static function findViewFullPath($view, $module = null){
267
+		public static function findViewFullPath($view, $module = null) {
268 268
 			$logger = self::getLogger();
269
-			if(! self::hasModule()){
269
+			if (!self::hasModule()) {
270 270
 				$logger->info('No module was loaded skiping.');
271 271
 				return false;
272 272
 			}
@@ -274,13 +274,13 @@  discard block
 block discarded – undo
274 274
 			$view = trim($view, '/\\');
275 275
 			$view = str_ireplace('/', DS, $view);
276 276
 			$viewFile = $view . '.php';
277
-			$logger->debug('Checking view [' . $view . '] in module [' .$module. '] ...');
277
+			$logger->debug('Checking view [' . $view . '] in module [' . $module . '] ...');
278 278
 			$filePath = MODULE_PATH . $module . DS . 'views' . DS . $viewFile;
279
-			if(file_exists($filePath)){
280
-				$logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$filePath. ']');
279
+			if (file_exists($filePath)) {
280
+				$logger->info('Found view [' . $view . '] in module [' . $module . '], the file path is [' . $filePath . ']');
281 281
 				return $filePath;
282 282
 			}
283
-			$logger->info('View [' . $view . '] does not exist in the module [' .$module. ']');
283
+			$logger->info('View [' . $view . '] does not exist in the module [' . $module . ']');
284 284
 			return false;
285 285
 		}
286 286
 
@@ -291,22 +291,22 @@  discard block
 block discarded – undo
291 291
 		 * @param string $appLang the application language like 'en', 'fr'
292 292
 		 * @return boolean|string  false or null if no module have this language,  return the full path of this language
293 293
 		 */
294
-		public static function findLanguageFullPath($language, $module = null, $appLang){
294
+		public static function findLanguageFullPath($language, $module = null, $appLang) {
295 295
 			$logger = self::getLogger();
296
-			if(! self::hasModule()){
296
+			if (!self::hasModule()) {
297 297
 				$logger->info('No module was loaded skiping.');
298 298
 				return false;
299 299
 			}
300 300
 			$language = str_ireplace('.php', '', $language);
301 301
 			$language = str_ireplace('lang_', '', $language);
302
-			$file = 'lang_'.$language.'.php';
303
-			$logger->debug('Checking language [' . $language . '] in module [' .$module. '] ...');
302
+			$file = 'lang_' . $language . '.php';
303
+			$logger->debug('Checking language [' . $language . '] in module [' . $module . '] ...');
304 304
 			$filePath = MODULE_PATH . $module . DS . 'lang' . DS . $appLang . DS . $file;
305
-			if(file_exists($filePath)){
306
-				$logger->info('Found language [' . $language . '] in module [' .$module. '], the file path is [' .$filePath. ']');
305
+			if (file_exists($filePath)) {
306
+				$logger->info('Found language [' . $language . '] in module [' . $module . '], the file path is [' . $filePath . ']');
307 307
 				return $filePath;
308 308
 			}
309
-			$logger->info('Language [' . $language . '] does not exist in the module [' .$module. ']');
309
+			$logger->info('Language [' . $language . '] does not exist in the module [' . $module . ']');
310 310
 			return false;
311 311
 		}
312 312
 
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 		 * Get the list of module loaded
315 315
 		 * @return array the module list
316 316
 		 */
317
-		public static function getModuleList(){
317
+		public static function getModuleList() {
318 318
 			return self::$list;
319 319
 		}
320 320
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 		 * Check if the application has an module
323 323
 		 * @return boolean
324 324
 		 */
325
-		public static function hasModule(){
325
+		public static function hasModule() {
326 326
 			return !empty(self::$list);
327 327
 		}
328 328
 
Please login to merge, or discard this patch.
core/classes/Config.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 
27
-	class Config{
27
+	class Config {
28 28
 		
29 29
 		/**
30 30
 		 * The list of loaded configuration
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 		 * The signleton of the logger
43 43
 		 * @return Object the Log instance
44 44
 		 */
45
-		public static function getLogger(){
46
-			if(self::$logger == null){
45
+		public static function getLogger() {
46
+			if (self::$logger == null) {
47 47
 				$logger = array();
48
-				$logger[0] =& class_loader('Log', 'classes');
48
+				$logger[0] = & class_loader('Log', 'classes');
49 49
 				$logger[0]->setLogger('Library::Config');
50 50
 				self::$logger = $logger[0];
51 51
 			}
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		 * @param object $logger the log object
58 58
 		 * @return object the log instance
59 59
 		 */
60
-		public static function setLogger($logger){
60
+		public static function setLogger($logger) {
61 61
 			self::$logger = $logger;
62 62
 			return self::$logger;
63 63
 		}
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
 		/**
66 66
 		 * Initialize the configuration by loading all the configuration from config file
67 67
 		 */
68
-		public static function init(){
68
+		public static function init() {
69 69
 			$logger = static::getLogger();
70 70
 			$logger->debug('Initialization of the configuration');
71 71
 			self::$config = & load_configurations();
72 72
 			self::setBaseUrlUsingServerVar();
73
-			if(ENVIRONMENT == 'production' && in_array(strtolower(self::$config['log_level']), array('debug', 'info','all'))){
73
+			if (ENVIRONMENT == 'production' && in_array(strtolower(self::$config['log_level']), array('debug', 'info', 'all'))) {
74 74
 				$logger->warning('You are in production environment, please set log level to WARNING, ERROR, FATAL to increase the application performance');
75 75
 			}
76 76
 			$logger->info('Configuration initialized successfully');
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
 		 * @param  mixed $default the default value to use if can not find the config item in the list
84 84
 		 * @return mixed          the config value if exist or the default value
85 85
 		 */
86
-		public static function get($item, $default = null){
86
+		public static function get($item, $default = null) {
87 87
 			$logger = static::getLogger();
88
-			if(array_key_exists($item, self::$config)){
88
+			if (array_key_exists($item, self::$config)) {
89 89
 				return self::$config[$item];
90 90
 			}
91
-			$logger->warning('Cannot find config item ['.$item.'] using the default value ['.$default.']');
91
+			$logger->warning('Cannot find config item [' . $item . '] using the default value [' . $default . ']');
92 92
 			return $default;
93 93
 		}
94 94
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		 * @param string $item  the config item name to set
98 98
 		 * @param mixed $value the config item value
99 99
 		 */
100
-		public static function set($item, $value){
100
+		public static function set($item, $value) {
101 101
 			self::$config[$item] = $value;
102 102
 		}
103 103
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		 * Get all the configuration values
106 106
 		 * @return array the config values
107 107
 		 */
108
-		public static function getAll(){
108
+		public static function getAll() {
109 109
 			return self::$config;
110 110
 		}
111 111
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		 * Set the configuration values bu merged with the existing configuration
114 114
 		 * @param array $config the config values to add in the configuration list
115 115
 		 */
116
-		public static function setAll(array $config = array()){
116
+		public static function setAll(array $config = array()) {
117 117
 			self::$config = array_merge(self::$config, $config);
118 118
 		}
119 119
 
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
 		 * @param  string $item the config item name to be deleted
123 123
 		 * @return boolean true if the item exists and is deleted successfully otherwise will return false.
124 124
 		 */
125
-		public static function delete($item){
125
+		public static function delete($item) {
126 126
 			$logger = static::getLogger();
127
-			if(array_key_exists($item, self::$config)){
128
-				$logger->info('Delete config item ['.$item.']');
127
+			if (array_key_exists($item, self::$config)) {
128
+				$logger->info('Delete config item [' . $item . ']');
129 129
 				unset(self::$config[$item]);
130 130
 				return true;
131 131
 			}
132
-			else{
133
-				$logger->warning('Config item ['.$item.'] to be deleted does not exists');
132
+			else {
133
+				$logger->warning('Config item [' . $item . '] to be deleted does not exists');
134 134
 				return false;
135 135
 			}
136 136
 		}
@@ -139,39 +139,39 @@  discard block
 block discarded – undo
139 139
 		 * Load the configuration file. This an alias to Loader::config()
140 140
 		 * @param  string $config the config name to be loaded
141 141
 		 */
142
-		public static function load($config){
142
+		public static function load($config) {
143 143
 			Loader::config($config);
144 144
 		}
145 145
 
146 146
 		/**
147 147
 		 * Set the configuration for "base_url" if is not set in the configuration
148 148
 		 */
149
-		private static function setBaseUrlUsingServerVar(){
149
+		private static function setBaseUrlUsingServerVar() {
150 150
 			$logger = static::getLogger();
151
-			if (! isset(self::$config['base_url']) || ! is_url(self::$config['base_url'])){
152
-				if(ENVIRONMENT == 'production'){
151
+			if (!isset(self::$config['base_url']) || !is_url(self::$config['base_url'])) {
152
+				if (ENVIRONMENT == 'production') {
153 153
 					$logger->warning('Application base URL is not set or invalid, please set application base URL to increase the application loading time');
154 154
 				}
155 155
 				$baseUrl = null;
156 156
 				$protocol = 'http';
157
-				if(is_https()){
157
+				if (is_https()) {
158 158
 					$protocol = 'https';
159 159
 				}
160
-				$protocol .='://';
160
+				$protocol .= '://';
161 161
 
162
-				if (isset($_SERVER['SERVER_ADDR'])){
162
+				if (isset($_SERVER['SERVER_ADDR'])) {
163 163
 					$baseUrl = $_SERVER['SERVER_ADDR'];
164 164
 					//check if the server is running under IPv6
165
-					if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE){
166
-						$baseUrl = '['.$_SERVER['SERVER_ADDR'].']';
165
+					if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE) {
166
+						$baseUrl = '[' . $_SERVER['SERVER_ADDR'] . ']';
167 167
 					}
168 168
 					$serverPort = 80;
169 169
 					if (isset($_SERVER['SERVER_PORT'])) {
170 170
 						$serverPort = $_SERVER['SERVER_PORT'];
171 171
 					}
172 172
 					$port = '';
173
-					if($serverPort && ((is_https() && $serverPort != 443) || (!is_https() && $serverPort != 80))){
174
-						$port = ':'.$serverPort;
173
+					if ($serverPort && ((is_https() && $serverPort != 443) || (!is_https() && $serverPort != 80))) {
174
+						$port = ':' . $serverPort;
175 175
 					}
176 176
 					$baseUrl = $protocol . $baseUrl . $port . substr(
177 177
 																		$_SERVER['SCRIPT_NAME'], 
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
 																		strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME']))
180 180
 																	);
181 181
 				}
182
-				else{
182
+				else {
183 183
 					$logger->warning('Can not determine the application base URL automatically, use http://localhost as default');
184 184
 					$baseUrl = 'http://localhost/';
185 185
 				}
186 186
 				self::set('base_url', $baseUrl);
187 187
 			}
188
-			self::$config['base_url'] = rtrim(self::$config['base_url'], '/') .'/';
188
+			self::$config['base_url'] = rtrim(self::$config['base_url'], '/') . '/';
189 189
 		}
190 190
 	}
Please login to merge, or discard this patch.
core/classes/Loader.php 1 patch
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 * along with this program; if not, write to the Free Software
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26
-	class Loader{
26
+	class Loader {
27 27
 		
28 28
 		/**
29 29
 		 * List of loaded resources
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		private static $logger;
39 39
 
40 40
 
41
-		public function __construct(){
41
+		public function __construct() {
42 42
 			//add the resources already loaded during application bootstrap
43 43
 			//in the list to prevent duplicate or loading the resources again.
44 44
 			static::$loaded = class_loaded();
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
 		 * The signleton of the logger
52 52
 		 * @return object the Log instance
53 53
 		 */
54
-		public static function getLogger(){
55
-			if(self::$logger == null){
54
+		public static function getLogger() {
55
+			if (self::$logger == null) {
56 56
 				$logger = array();
57
-				$logger[0] =& class_loader('Log', 'classes');
57
+				$logger[0] = & class_loader('Log', 'classes');
58 58
 				$logger[0]->setLogger('Library::Loader');
59 59
 				self::$logger = $logger[0];
60 60
 			}
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		 * @param object $logger the log object
67 67
 		 * @return object the log instance
68 68
 		 */
69
-		public static function setLogger($logger){
69
+		public static function setLogger($logger) {
70 70
 			self::$logger = $logger;
71 71
 			return self::$logger;
72 72
 		}
@@ -80,18 +80,18 @@  discard block
 block discarded – undo
80 80
 		 *
81 81
 		 * @return void
82 82
 		 */
83
-		public static function model($class, $instance = null){
83
+		public static function model($class, $instance = null) {
84 84
 			$logger = static::getLogger();
85 85
 			$class = str_ireplace('.php', '', $class);
86 86
 			$class = trim($class, '/\\');
87
-			$file = ucfirst($class).'.php';
87
+			$file = ucfirst($class) . '.php';
88 88
 			$logger->debug('Loading model [' . $class . '] ...');
89 89
 			//************
90
-			if (! $instance){
90
+			if (!$instance) {
91 91
 				$instance = self::getModelLibraryInstanceName($class);
92 92
 			}
93 93
 			//****************
94
-			if (isset(static::$loaded[$instance])){
94
+			if (isset(static::$loaded[$instance])) {
95 95
 				$logger->info('Model [' . $class . '] already loaded no need to load it again, cost in performance');
96 96
 				return;
97 97
 			}
@@ -104,28 +104,28 @@  discard block
 block discarded – undo
104 104
 			$class  = $moduleInfo['class'];
105 105
 			
106 106
 			$moduleModelFilePath = Module::findModelFullPath($class, $module);
107
-			if ($moduleModelFilePath){
108
-				$logger->info('Found model [' . $class . '] from module [' .$module. '], the file path is [' .$moduleModelFilePath. '] we will used it');
107
+			if ($moduleModelFilePath) {
108
+				$logger->info('Found model [' . $class . '] from module [' . $module . '], the file path is [' . $moduleModelFilePath . '] we will used it');
109 109
 				$classFilePath = $moduleModelFilePath;
110 110
 			}
111
-			else{
111
+			else {
112 112
 				$logger->info('Cannot find model [' . $class . '] from modules using the default location');
113 113
 			}
114 114
 			$logger->info('The model file path to be loaded is [' . $classFilePath . ']');
115
-			if (file_exists($classFilePath)){
115
+			if (file_exists($classFilePath)) {
116 116
 				require_once $classFilePath;
117
-				if (class_exists($class)){
117
+				if (class_exists($class)) {
118 118
 					$c = new $class();
119 119
 					$obj = & get_instance();
120 120
 					$obj->{$instance} = $c;
121 121
 					static::$loaded[$instance] = $class;
122 122
 					$logger->info('Model [' . $class . '] --> ' . $classFilePath . ' loaded successfully.');
123 123
 				}
124
-				else{
125
-					show_error('The file '.$classFilePath.' exists but does not contain the class ['. $class . ']');
124
+				else {
125
+					show_error('The file ' . $classFilePath . ' exists but does not contain the class [' . $class . ']');
126 126
 				}
127 127
 			}
128
-			else{
128
+			else {
129 129
 				show_error('Unable to find the model [' . $class . ']');
130 130
 			}
131 131
 		}
@@ -140,22 +140,22 @@  discard block
 block discarded – undo
140 140
 		 *
141 141
 		 * @return void
142 142
 		 */
143
-		public static function library($class, $instance = null, array $params = array()){
143
+		public static function library($class, $instance = null, array $params = array()) {
144 144
 			$logger = static::getLogger();
145 145
 			$class = str_ireplace('.php', '', $class);
146 146
 			$class = trim($class, '/\\');
147
-			$file = ucfirst($class) .'.php';
147
+			$file = ucfirst($class) . '.php';
148 148
 			$logger->debug('Loading library [' . $class . '] ...');
149
-			if (! $instance){
149
+			if (!$instance) {
150 150
 				$instance = self::getModelLibraryInstanceName($class);
151 151
 			}
152
-			if (isset(static::$loaded[$instance])){
152
+			if (isset(static::$loaded[$instance])) {
153 153
 				$logger->info('Library [' . $class . '] already loaded no need to load it again, cost in performance');
154 154
 				return;
155 155
 			}
156 156
 			$obj = & get_instance();
157 157
 			//Check and load Database library
158
-			if (strtolower($class) == 'database'){
158
+			if (strtolower($class) == 'database') {
159 159
 				$logger->info('This is the Database library ...');
160 160
 				$obj->{$instance} = & class_loader('Database', 'classes/database', $params);
161 161
 				static::$loaded[$instance] = $class;
@@ -164,18 +164,18 @@  discard block
 block discarded – undo
164 164
 			}
165 165
 			$libraryFilePath = null;
166 166
 			$logger->debug('Check if this is a system library ...');
167
-			if (file_exists(CORE_LIBRARY_PATH . $file)){
167
+			if (file_exists(CORE_LIBRARY_PATH . $file)) {
168 168
 				$libraryFilePath = CORE_LIBRARY_PATH . $file;
169 169
 				$class = ucfirst($class);
170 170
 				$logger->info('This library is a system library');
171 171
 			}
172
-			else{
172
+			else {
173 173
 				$logger->info('This library is not a system library');	
174 174
 				//first check if this library is in the module
175 175
 				$libraryFilePath = self::getLibraryPathUsingModuleInfo($class);
176 176
 				//***************
177 177
 			}
178
-			if (! $libraryFilePath && file_exists(LIBRARY_PATH . $file)){
178
+			if (!$libraryFilePath && file_exists(LIBRARY_PATH . $file)) {
179 179
 				$libraryFilePath = LIBRARY_PATH . $file;
180 180
 			}
181 181
 			$logger->info('The library file path to be loaded is [' . $libraryFilePath . ']');
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 		 *
191 191
 		 * @return void
192 192
 		 */
193
-		public static function functions($function){
193
+		public static function functions($function) {
194 194
 			$logger = static::getLogger();
195 195
 			$function = str_ireplace('.php', '', $function);
196 196
 			$function = trim($function, '/\\');
197 197
 			$function = str_ireplace('function_', '', $function);
198
-			$file = 'function_'.$function.'.php';
198
+			$file = 'function_' . $function . '.php';
199 199
 			$logger->debug('Loading helper [' . $function . '] ...');
200
-			if (isset(static::$loaded['function_' . $function])){
200
+			if (isset(static::$loaded['function_' . $function])) {
201 201
 				$logger->info('Helper [' . $function . '] already loaded no need to load it again, cost in performance');
202 202
 				return;
203 203
 			}
@@ -207,22 +207,22 @@  discard block
 block discarded – undo
207 207
 			$moduleInfo = self::getModuleInfoForFunction($function);
208 208
 			$module    = $moduleInfo['module'];
209 209
 			$function  = $moduleInfo['function'];
210
-			if(! empty($moduleInfo['file'])){
210
+			if (!empty($moduleInfo['file'])) {
211 211
 				$file = $moduleInfo['file'];
212 212
 			}
213 213
 			$moduleFunctionPath = Module::findFunctionFullPath($function, $module);
214
-			if ($moduleFunctionPath){
215
-				$logger->info('Found helper [' . $function . '] from module [' .$module. '], the file path is [' .$moduleFunctionPath. '] we will used it');
214
+			if ($moduleFunctionPath) {
215
+				$logger->info('Found helper [' . $function . '] from module [' . $module . '], the file path is [' . $moduleFunctionPath . '] we will used it');
216 216
 				$functionFilePath = $moduleFunctionPath;
217 217
 			}
218
-			else{
218
+			else {
219 219
 				$logger->info('Cannot find helper [' . $function . '] from modules using the default location');
220 220
 			}
221
-			if (! $functionFilePath){
221
+			if (!$functionFilePath) {
222 222
 				$searchDir = array(FUNCTIONS_PATH, CORE_FUNCTIONS_PATH);
223
-				foreach($searchDir as $dir){
223
+				foreach ($searchDir as $dir) {
224 224
 					$filePath = $dir . $file;
225
-					if (file_exists($filePath)){
225
+					if (file_exists($filePath)) {
226 226
 						$functionFilePath = $filePath;
227 227
 						//is already found not to continue
228 228
 						break;
@@ -230,12 +230,12 @@  discard block
 block discarded – undo
230 230
 				}
231 231
 			}
232 232
 			$logger->info('The helper file path to be loaded is [' . $functionFilePath . ']');
233
-			if ($functionFilePath){
233
+			if ($functionFilePath) {
234 234
 				require_once $functionFilePath;
235 235
 				static::$loaded['function_' . $function] = $functionFilePath;
236 236
 				$logger->info('Helper [' . $function . '] --> ' . $functionFilePath . ' loaded successfully.');
237 237
 			}
238
-			else{
238
+			else {
239 239
 				show_error('Unable to find helper file [' . $file . ']');
240 240
 			}
241 241
 		}
@@ -247,14 +247,14 @@  discard block
 block discarded – undo
247 247
 		 *
248 248
 		 * @return void
249 249
 		 */
250
-		public static function config($filename){
250
+		public static function config($filename) {
251 251
 			$logger = static::getLogger();
252 252
 			$filename = str_ireplace('.php', '', $filename);
253 253
 			$filename = trim($filename, '/\\');
254 254
 			$filename = str_ireplace('config_', '', $filename);
255
-			$file = 'config_'.$filename.'.php';
255
+			$file = 'config_' . $filename . '.php';
256 256
 			$logger->debug('Loading configuration [' . $filename . '] ...');
257
-			if (isset(static::$loaded['config_' . $filename])){
257
+			if (isset(static::$loaded['config_' . $filename])) {
258 258
 				$logger->info('Configuration [' . $file . '] already loaded no need to load it again, cost in performance');
259 259
 				return;
260 260
 			}
@@ -265,18 +265,18 @@  discard block
 block discarded – undo
265 265
 			$module    = $moduleInfo['module'];
266 266
 			$filename  = $moduleInfo['filename'];
267 267
 			$moduleConfigPath = Module::findConfigFullPath($filename, $module);
268
-			if ($moduleConfigPath){
269
-				$logger->info('Found config [' . $filename . '] from module [' .$module. '], the file path is [' .$moduleConfigPath. '] we will used it');
268
+			if ($moduleConfigPath) {
269
+				$logger->info('Found config [' . $filename . '] from module [' . $module . '], the file path is [' . $moduleConfigPath . '] we will used it');
270 270
 				$configFilePath = $moduleConfigPath;
271 271
 			}
272
-			else{
272
+			else {
273 273
 				$logger->info('Cannot find config [' . $filename . '] from modules using the default location');
274 274
 			}
275 275
 			$logger->info('The config file path to be loaded is [' . $configFilePath . ']');
276 276
 			$config = array();
277
-			if (file_exists($configFilePath)){
277
+			if (file_exists($configFilePath)) {
278 278
 				require_once $configFilePath;
279
-				if (! empty($config) && is_array($config)){
279
+				if (!empty($config) && is_array($config)) {
280 280
 					Config::setAll($config);
281 281
 					static::$loaded['config_' . $filename] = $configFilePath;
282 282
 					$logger->info('Configuration [' . $configFilePath . '] loaded successfully.');
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
 					unset($config);
285 285
 				}
286 286
 			}
287
-			else{
288
-				show_error('Unable to find config file ['. $configFilePath . ']');
287
+			else {
288
+				show_error('Unable to find config file [' . $configFilePath . ']');
289 289
 			}
290 290
 		}
291 291
 
@@ -297,14 +297,14 @@  discard block
 block discarded – undo
297 297
 		 *
298 298
 		 * @return void
299 299
 		 */
300
-		public static function lang($language){
300
+		public static function lang($language) {
301 301
 			$logger = static::getLogger();
302 302
 			$language = str_ireplace('.php', '', $language);
303 303
 			$language = trim($language, '/\\');
304 304
 			$language = str_ireplace('lang_', '', $language);
305
-			$file = 'lang_'.$language.'.php';
305
+			$file = 'lang_' . $language . '.php';
306 306
 			$logger->debug('Loading language [' . $language . '] ...');
307
-			if (isset(static::$loaded['lang_' . $language])){
307
+			if (isset(static::$loaded['lang_' . $language])) {
308 308
 				$logger->info('Language [' . $language . '] already loaded no need to load it again, cost in performance');
309 309
 				return;
310 310
 			}
@@ -316,22 +316,22 @@  discard block
 block discarded – undo
316 316
 			$moduleInfo = self::getModuleInfoForLanguage($language);
317 317
 			$module    = $moduleInfo['module'];
318 318
 			$language  = $moduleInfo['language'];
319
-			if(! empty($moduleInfo['file'])){
319
+			if (!empty($moduleInfo['file'])) {
320 320
 				$file = $moduleInfo['file'];
321 321
 			}
322 322
 			$moduleLanguagePath = Module::findLanguageFullPath($language, $module, $appLang);
323
-			if ($moduleLanguagePath){
324
-				$logger->info('Found language [' . $language . '] from module [' .$module. '], the file path is [' .$moduleLanguagePath. '] we will used it');
323
+			if ($moduleLanguagePath) {
324
+				$logger->info('Found language [' . $language . '] from module [' . $module . '], the file path is [' . $moduleLanguagePath . '] we will used it');
325 325
 				$languageFilePath = $moduleLanguagePath;
326 326
 			}
327
-			else{
327
+			else {
328 328
 				$logger->info('Cannot find language [' . $language . '] from modules using the default location');
329 329
 			}
330
-			if (! $languageFilePath){
330
+			if (!$languageFilePath) {
331 331
 				$searchDir = array(APP_LANG_PATH, CORE_LANG_PATH);
332
-				foreach($searchDir as $dir){
332
+				foreach ($searchDir as $dir) {
333 333
 					$filePath = $dir . $appLang . DS . $file;
334
-					if (file_exists($filePath)){
334
+					if (file_exists($filePath)) {
335 335
 						$languageFilePath = $filePath;
336 336
 						//already found no need continue
337 337
 						break;
@@ -347,14 +347,14 @@  discard block
 block discarded – undo
347 347
 		 * if can not found will use the default value from configuration
348 348
 		 * @return string the app language like "en", "fr"
349 349
 		 */
350
-		protected static function getAppLang(){
350
+		protected static function getAppLang() {
351 351
 			//determine the current language
352 352
 			$appLang = get_config('default_language');
353 353
 			//if the language exists in the cookie use it
354 354
 			$cfgKey = get_config('language_cookie_name');
355 355
 			$objCookie = & class_loader('Cookie');
356 356
 			$cookieLang = $objCookie->get($cfgKey);
357
-			if ($cookieLang){
357
+			if ($cookieLang) {
358 358
 				$appLang = $cookieLang;
359 359
 			}
360 360
 			return $appLang;
@@ -368,20 +368,20 @@  discard block
 block discarded – undo
368 368
 		 * 	'class' => 'class_name'
369 369
 		 * )
370 370
 		 */
371
-		protected static function getModuleInfoForModelLibrary($class){
371
+		protected static function getModuleInfoForModelLibrary($class) {
372 372
 			$module = null;
373 373
 			$obj = & get_instance();
374
-			if (strpos($class, '/') !== false){
374
+			if (strpos($class, '/') !== false) {
375 375
 				$path = explode('/', $class);
376
-				if (isset($path[0]) && in_array($path[0], Module::getModuleList())){
376
+				if (isset($path[0]) && in_array($path[0], Module::getModuleList())) {
377 377
 					$module = $path[0];
378 378
 					$class = ucfirst($path[1]);
379 379
 				}
380 380
 			}
381
-			else{
381
+			else {
382 382
 				$class = ucfirst($class);
383 383
 			}
384
-			if (! $module && !empty($obj->moduleName)){
384
+			if (!$module && !empty($obj->moduleName)) {
385 385
 				$module = $obj->moduleName;
386 386
 			}
387 387
 			return array(
@@ -400,20 +400,20 @@  discard block
 block discarded – undo
400 400
 		 * 	'file' => 'file'
401 401
 		 * )
402 402
 		 */
403
-		protected static function getModuleInfoForFunction($function){
403
+		protected static function getModuleInfoForFunction($function) {
404 404
 			$module = null;
405 405
 			$file = null;
406 406
 			$obj = & get_instance();
407 407
 			//check if the request class contains module name
408
-			if (strpos($function, '/') !== false){
408
+			if (strpos($function, '/') !== false) {
409 409
 				$path = explode('/', $function);
410
-				if (isset($path[0]) && in_array($path[0], Module::getModuleList())){
410
+				if (isset($path[0]) && in_array($path[0], Module::getModuleList())) {
411 411
 					$module = $path[0];
412 412
 					$function = 'function_' . $path[1];
413
-					$file = $path[0] . DS . $function.'.php';
413
+					$file = $path[0] . DS . $function . '.php';
414 414
 				}
415 415
 			}
416
-			if (! $module && !empty($obj->moduleName)){
416
+			if (!$module && !empty($obj->moduleName)) {
417 417
 				$module = $obj->moduleName;
418 418
 			}
419 419
 			return array(
@@ -433,20 +433,20 @@  discard block
 block discarded – undo
433 433
 		 * 	'file' => 'file'
434 434
 		 * )
435 435
 		 */
436
-		protected static function getModuleInfoForLanguage($language){
436
+		protected static function getModuleInfoForLanguage($language) {
437 437
 			$module = null;
438 438
 			$file = null;
439 439
 			$obj = & get_instance();
440 440
 			//check if the request class contains module name
441
-			if (strpos($language, '/') !== false){
441
+			if (strpos($language, '/') !== false) {
442 442
 				$path = explode('/', $language);
443
-				if (isset($path[0]) && in_array($path[0], Module::getModuleList())){
443
+				if (isset($path[0]) && in_array($path[0], Module::getModuleList())) {
444 444
 					$module = $path[0];
445 445
 					$language = 'lang_' . $path[1] . '.php';
446
-					$file = $path[0] . DS .$language;
446
+					$file = $path[0] . DS . $language;
447 447
 				}
448 448
 			}
449
-			if (! $module && !empty($obj->moduleName)){
449
+			if (!$module && !empty($obj->moduleName)) {
450 450
 				$module = $obj->moduleName;
451 451
 			}
452 452
 			return array(
@@ -466,18 +466,18 @@  discard block
 block discarded – undo
466 466
 		 * 	'filename' => 'filename'
467 467
 		 * )
468 468
 		 */
469
-		protected static function getModuleInfoForConfig($filename){
469
+		protected static function getModuleInfoForConfig($filename) {
470 470
 			$module = null;
471 471
 			$obj = & get_instance();
472 472
 			//check if the request class contains module name
473
-			if (strpos($filename, '/') !== false){
473
+			if (strpos($filename, '/') !== false) {
474 474
 				$path = explode('/', $filename);
475
-				if (isset($path[0]) && in_array($path[0], Module::getModuleList())){
475
+				if (isset($path[0]) && in_array($path[0], Module::getModuleList())) {
476 476
 					$module = $path[0];
477 477
 					$filename = $path[1] . '.php';
478 478
 				}
479 479
 			}
480
-			if (! $module && !empty($obj->moduleName)){
480
+			if (!$module && !empty($obj->moduleName)) {
481 481
 				$module = $obj->moduleName;
482 482
 			}
483 483
 			return array(
@@ -491,16 +491,16 @@  discard block
 block discarded – undo
491 491
 		 * @param  string $class the class name to determine the instance
492 492
 		 * @return string        the instance name
493 493
 		 */
494
-		protected static function getModelLibraryInstanceName($class){
494
+		protected static function getModelLibraryInstanceName($class) {
495 495
 			//for module
496 496
 			$instance = null;
497
-			if (strpos($class, '/') !== false){
497
+			if (strpos($class, '/') !== false) {
498 498
 				$path = explode('/', $class);
499
-				if (isset($path[1])){
499
+				if (isset($path[1])) {
500 500
 					$instance = strtolower($path[1]);
501 501
 				}
502 502
 			}
503
-			else{
503
+			else {
504 504
 				$instance = strtolower($class);
505 505
 			}
506 506
 			return $instance;
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 		 * @param  string $class the class name
512 512
 		 * @return string|null        the library file path otherwise null will be returned
513 513
 		 */
514
-		protected static function getLibraryPathUsingModuleInfo($class){
514
+		protected static function getLibraryPathUsingModuleInfo($class) {
515 515
 			$logger = static::getLogger();
516 516
 			$libraryFilePath = null;
517 517
 			$logger->debug('Checking library [' . $class . '] from module list ...');
@@ -519,11 +519,11 @@  discard block
 block discarded – undo
519 519
 			$module = $moduleInfo['module'];
520 520
 			$class  = $moduleInfo['class'];
521 521
 			$moduleLibraryPath = Module::findLibraryFullPath($class, $module);
522
-			if ($moduleLibraryPath){
523
-				$logger->info('Found library [' . $class . '] from module [' .$module. '], the file path is [' .$moduleLibraryPath. '] we will used it');
522
+			if ($moduleLibraryPath) {
523
+				$logger->info('Found library [' . $class . '] from module [' . $module . '], the file path is [' . $moduleLibraryPath . '] we will used it');
524 524
 				$libraryFilePath = $moduleLibraryPath;
525 525
 			}
526
-			else{
526
+			else {
527 527
 				$logger->info('Cannot find library [' . $class . '] from modules using the default location');
528 528
 			}
529 529
 			return $libraryFilePath;
@@ -537,22 +537,22 @@  discard block
 block discarded – undo
537 537
 		 * @param  array  $params          the parameter to use
538 538
 		 * @return void
539 539
 		 */
540
-		protected static function loadLibrary($libraryFilePath, $class, $instance, $params = array()){
541
-			if ($libraryFilePath){
540
+		protected static function loadLibrary($libraryFilePath, $class, $instance, $params = array()) {
541
+			if ($libraryFilePath) {
542 542
 				$logger = static::getLogger();
543 543
 				require_once $libraryFilePath;
544
-				if (class_exists($class)){
544
+				if (class_exists($class)) {
545 545
 					$c = $params ? new $class($params) : new $class();
546 546
 					$obj = & get_instance();
547 547
 					$obj->{$instance} = $c;
548 548
 					static::$loaded[$instance] = $class;
549 549
 					$logger->info('Library [' . $class . '] --> ' . $libraryFilePath . ' loaded successfully.');
550 550
 				}
551
-				else{
552
-					show_error('The file '.$libraryFilePath.' exists but does not contain the class '.$class);
551
+				else {
552
+					show_error('The file ' . $libraryFilePath . ' exists but does not contain the class ' . $class);
553 553
 				}
554 554
 			}
555
-			else{
555
+			else {
556 556
 				show_error('Unable to find library class [' . $class . ']');
557 557
 			}
558 558
 		}
@@ -563,15 +563,15 @@  discard block
 block discarded – undo
563 563
 		 * @param  string $language           the language name
564 564
 		 * @return void
565 565
 		 */
566
-		protected static function loadLanguage($languageFilePath, $language){
567
-			if ($languageFilePath){
566
+		protected static function loadLanguage($languageFilePath, $language) {
567
+			if ($languageFilePath) {
568 568
 				$logger = static::getLogger();
569 569
 				$lang = array();
570 570
 				require_once $languageFilePath;
571
-				if (! empty($lang) && is_array($lang)){
572
-					$logger->info('Language file  [' .$languageFilePath. '] contains the valid languages keys add them to language list');
571
+				if (!empty($lang) && is_array($lang)) {
572
+					$logger->info('Language file  [' . $languageFilePath . '] contains the valid languages keys add them to language list');
573 573
 					//Note: may be here the class 'Lang' not yet loaded
574
-					$langObj =& class_loader('Lang', 'classes');
574
+					$langObj = & class_loader('Lang', 'classes');
575 575
 					$langObj->addLangMessages($lang);
576 576
 					//free the memory
577 577
 					unset($lang);
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 				static::$loaded['lang_' . $language] = $languageFilePath;
580 580
 				$logger->info('Language [' . $language . '] --> ' . $languageFilePath . ' loaded successfully.');
581 581
 			}
582
-			else{
582
+			else {
583 583
 				show_error('Unable to find language [' . $language . ']');
584 584
 			}
585 585
 		}
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 		 * Get all the autoload using the configuration file
589 589
 		 * @return array
590 590
 		 */
591
-		private function getResourcesFromAutoloadConfig(){
591
+		private function getResourcesFromAutoloadConfig() {
592 592
 			$autoloads = array();
593 593
 			$autoloads['config']    = array();
594 594
 			$autoloads['languages'] = array();
@@ -596,17 +596,17 @@  discard block
 block discarded – undo
596 596
 			$autoloads['models']    = array();
597 597
 			$autoloads['functions'] = array();
598 598
 			//loading of the resources from autoload configuration file
599
-			if (file_exists(CONFIG_PATH . 'autoload.php')){
599
+			if (file_exists(CONFIG_PATH . 'autoload.php')) {
600 600
 				$autoload = array();
601 601
 				require_once CONFIG_PATH . 'autoload.php';
602
-				if (! empty($autoload) && is_array($autoload)){
602
+				if (!empty($autoload) && is_array($autoload)) {
603 603
 					$autoloads = array_merge($autoloads, $autoload);
604 604
 					unset($autoload);
605 605
 				}
606 606
 			}
607 607
 			//loading autoload configuration for modules
608 608
 			$modulesAutoloads = Module::getModulesAutoloadConfig();
609
-			if (! empty($modulesAutoloads) && is_array($modulesAutoloads)){
609
+			if (!empty($modulesAutoloads) && is_array($modulesAutoloads)) {
610 610
 				$autoloads = array_merge_recursive($autoloads, $modulesAutoloads);
611 611
 			}
612 612
 			return $autoloads;
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 		 * Load the autoload configuration
617 617
 		 * @return void
618 618
 		 */
619
-		private function loadResourcesFromAutoloadConfig(){
619
+		private function loadResourcesFromAutoloadConfig() {
620 620
 			$autoloads = array();
621 621
 			$autoloads['config']    = array();
622 622
 			$autoloads['languages'] = array();
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
 		 * @param  array  $resources the resource to load
650 650
 		 * @return void            
651 651
 		 */
652
-		private function loadAutoloadResourcesArray($method, array $resources){
652
+		private function loadAutoloadResourcesArray($method, array $resources) {
653 653
 			foreach ($resources as $name) {
654 654
 				$this->{$method}($name);
655 655
 			}
Please login to merge, or discard this patch.
core/classes/Response.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 
27
-	class Response{
27
+	class Response {
28 28
 
29 29
 		/**
30 30
 		 * The list of request header to send with response
@@ -65,15 +65,15 @@  discard block
 block discarded – undo
65 65
 		/**
66 66
 		 * Construct new response instance
67 67
 		 */
68
-		public function __construct(){
68
+		public function __construct() {
69 69
 			$currentUrl = '';
70
-			if (! empty($_SERVER['REQUEST_URI'])){
70
+			if (!empty($_SERVER['REQUEST_URI'])) {
71 71
 				$currentUrl = $_SERVER['REQUEST_URI'];
72 72
 			}
73
-			if (! empty($_SERVER['QUERY_STRING'])){
73
+			if (!empty($_SERVER['QUERY_STRING'])) {
74 74
 				$currentUrl .= '?' . $_SERVER['QUERY_STRING'];
75 75
 			}
76
-			$this->_currentUrl =  $currentUrl;
76
+			$this->_currentUrl = $currentUrl;
77 77
 					
78 78
 			$this->_currentUrlCacheKey = md5($this->_currentUrl);
79 79
 			
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
 		 * The signleton of the logger
90 90
 		 * @return Object the Log instance
91 91
 		 */
92
-		public static function getLogger(){
93
-			if(self::$logger == null){
92
+		public static function getLogger() {
93
+			if (self::$logger == null) {
94 94
 				$logger = array();
95
-				$logger[0] =& class_loader('Log', 'classes');
95
+				$logger[0] = & class_loader('Log', 'classes');
96 96
 				$logger[0]->setLogger('Library::Response');
97 97
 				self::$logger = $logger[0];
98 98
 			}
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 		 * @param object $logger the log object
105 105
 		 * @return object the log instance
106 106
 		 */
107
-		public static function setLogger($logger){
107
+		public static function setLogger($logger) {
108 108
 			self::$logger = $logger;
109 109
 			return self::$logger;
110 110
 		}
@@ -115,12 +115,12 @@  discard block
 block discarded – undo
115 115
 		 * @param  integer $httpCode the HTTP status code
116 116
 		 * @param  array   $headers   the additional headers to add to the existing headers list
117 117
 		 */
118
-		public static function sendHeaders($httpCode = 200, array $headers = array()){
118
+		public static function sendHeaders($httpCode = 200, array $headers = array()) {
119 119
 			set_http_status_header($httpCode);
120 120
 			self::setHeaders($headers);
121
-			if(! headers_sent()){
122
-				foreach(self::getHeaders() as $key => $value){
123
-					header($key .': '.$value);
121
+			if (!headers_sent()) {
122
+				foreach (self::getHeaders() as $key => $value) {
123
+					header($key . ': ' . $value);
124 124
 				}
125 125
 			}
126 126
 		}
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 		 * Get the list of the headers
130 130
 		 * @return array the headers list
131 131
 		 */
132
-		public static function getHeaders(){
132
+		public static function getHeaders() {
133 133
 			return self::$headers;
134 134
 		}
135 135
 
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
 		 * @param  string $name the header name
139 139
 		 * @return string|null       the header value
140 140
 		 */
141
-		public static function getHeader($name){
142
-			if(array_key_exists($name, self::$headers)){
141
+		public static function getHeader($name) {
142
+			if (array_key_exists($name, self::$headers)) {
143 143
 				return self::$headers[$name];
144 144
 			}
145 145
 			return null;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 		 * @param string $name  the header name
152 152
 		 * @param string $value the header value to be set
153 153
 		 */
154
-		public static function setHeader($name, $value){
154
+		public static function setHeader($name, $value) {
155 155
 			self::$headers[$name] = $value;
156 156
 		}
157 157
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		 * @param array $headers the list of the headers to set. 
161 161
 		 * Note: this will merge with the existing headers
162 162
 		 */
163
-		public static function setHeaders(array $headers){
163
+		public static function setHeaders(array $headers) {
164 164
 			self::$headers = array_merge(self::getHeaders(), $headers);
165 165
 		}
166 166
 		
@@ -168,16 +168,16 @@  discard block
 block discarded – undo
168 168
 		 * Redirect user to the specified page
169 169
 		 * @param  string $path the URL or URI to be redirect to
170 170
 		 */
171
-		public static function redirect($path = ''){
171
+		public static function redirect($path = '') {
172 172
 			$logger = self::getLogger();
173 173
 			$url = Url::site_url($path);
174
-			$logger->info('Redirect to URL [' .$url. ']');
175
-			if(! headers_sent()){
176
-				header('Location: '.$url);
174
+			$logger->info('Redirect to URL [' . $url . ']');
175
+			if (!headers_sent()) {
176
+				header('Location: ' . $url);
177 177
 				exit;
178 178
 			}
179 179
 			echo '<script>
180
-					location.href = "'.$url.'";
180
+					location.href = "'.$url . '";
181 181
 				</script>';
182 182
 		}
183 183
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		 * @return void|string          if $return is true will return the view content otherwise
190 190
 		 * will display the view content.
191 191
 		 */
192
-		public function render($view, $data = null, $return = false){
192
+		public function render($view, $data = null, $return = false) {
193 193
 			$logger = self::getLogger();
194 194
 			//convert data to an array
195 195
 			$data = (array) $data;
@@ -201,22 +201,22 @@  discard block
 block discarded – undo
201 201
 			//check in module first
202 202
 			$logger->debug('Checking the view [' . $view . '] from module list ...');
203 203
 			$moduleInfo = $this->getModuleInfoForView($view);
204
-			$module    = $moduleInfo['module'];
205
-			$view  = $moduleInfo['view'];
204
+			$module = $moduleInfo['module'];
205
+			$view = $moduleInfo['view'];
206 206
 			
207 207
 			$moduleViewPath = Module::findViewFullPath($view, $module);
208
-			if($moduleViewPath){
208
+			if ($moduleViewPath) {
209 209
 				$path = $moduleViewPath;
210
-				$logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$moduleViewPath. '] we will used it');
210
+				$logger->info('Found view [' . $view . '] in module [' . $module . '], the file path is [' . $moduleViewPath . '] we will used it');
211 211
 			}
212
-			else{
213
-				$logger->info('Cannot find view [' . $view . '] in module [' .$module. '] using the default location');
212
+			else {
213
+				$logger->info('Cannot find view [' . $view . '] in module [' . $module . '] using the default location');
214 214
 			}
215 215
 			
216 216
 			$logger->info('The view file path to be loaded is [' . $path . ']');
217 217
 			
218 218
 			/////////
219
-			if($return){
219
+			if ($return) {
220 220
 				return $this->loadView($path, $data, true);
221 221
 			}
222 222
 			$this->loadView($path, $data, false);
@@ -226,28 +226,28 @@  discard block
 block discarded – undo
226 226
 		/**
227 227
 		* Send the final page output to user
228 228
 		*/
229
-		public function renderFinalPage(){
229
+		public function renderFinalPage() {
230 230
 			$logger = self::getLogger();
231 231
 			$obj = & get_instance();
232 232
 			$cachePageStatus = get_config('cache_enable', false) && !empty($obj->view_cache_enable);
233 233
 			$dispatcher = $obj->eventdispatcher;
234 234
 			$content = $this->_pageRender;
235
-			if(! $content){
235
+			if (!$content) {
236 236
 				$logger->warning('The final view content is empty.');
237 237
 				return;
238 238
 			}
239 239
 			//dispatch
240 240
 			$event = $dispatcher->dispatch(new EventInfo('FINAL_VIEW_READY', $content, true));
241 241
 			$content = null;
242
-			if(! empty($event->payload)){
242
+			if (!empty($event->payload)) {
243 243
 				$content = $event->payload;
244 244
 			}
245
-			if(empty($content)){
245
+			if (empty($content)) {
246 246
 				$logger->warning('The view content is empty after dispatch to event listeners.');
247 247
 			}
248 248
 			
249 249
 			//check whether need save the page into cache.
250
-			if($cachePageStatus){
250
+			if ($cachePageStatus) {
251 251
 				$this->savePageContentIntoCache($content);
252 252
 			}
253 253
 			
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 			
260 260
 			//compress the output if is available
261 261
 			$type = null;
262
-			if (self::$_canCompressOutput){
262
+			if (self::$_canCompressOutput) {
263 263
 				$type = 'ob_gzhandler';
264 264
 			}
265 265
 			ob_start($type);
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 		*
276 276
 		* @return boolean whether the page content if available or not
277 277
 		*/
278
-		public function renderFinalPageFromCache(&$cache){
278
+		public function renderFinalPageFromCache(&$cache) {
279 279
 			$logger = self::getLogger();
280 280
 			//the current page cache key for identification
281 281
 			$pageCacheKey = $this->_currentUrlCacheKey;
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
 			$logger->debug('Checking if the page content for the URL [' . $this->_currentUrl . '] is cached ...');
284 284
 			//get the cache information to prepare header to send to browser
285 285
 			$cacheInfo = $cache->getInfo($pageCacheKey);
286
-			if($cacheInfo){
286
+			if ($cacheInfo) {
287 287
 				$status = $this->sendCacheNotYetExpireInfo($cacheInfo);
288
-				if($status === false){
288
+				if ($status === false) {
289 289
 					return $this->sendPageContentToBrowser($cache);
290 290
 				}
291 291
 			}
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 		* Get the final page to be rendered
298 298
 		* @return string
299 299
 		*/
300
-		public function getFinalPageRendered(){
300
+		public function getFinalPageRendered() {
301 301
 			return $this->_pageRender;
302 302
 		}
303 303
 
@@ -305,14 +305,14 @@  discard block
 block discarded – undo
305 305
 		 * Send the HTTP 404 error if can not found the 
306 306
 		 * routing information for the current request
307 307
 		 */
308
-		public static function send404(){
308
+		public static function send404() {
309 309
 			/********* for logs **************/
310 310
 			//can't use $obj = & get_instance()  here because the global super object will be available until
311 311
 			//the main controller is loaded even for Loader::library('xxxx');
312 312
 			$logger = self::getLogger();
313
-			$request =& class_loader('Request', 'classes');
314
-			$userAgent =& class_loader('Browser');
315
-			$browser = $userAgent->getPlatform().', '.$userAgent->getBrowser().' '.$userAgent->getVersion();
313
+			$request = & class_loader('Request', 'classes');
314
+			$userAgent = & class_loader('Browser');
315
+			$browser = $userAgent->getPlatform() . ', ' . $userAgent->getBrowser() . ' ' . $userAgent->getVersion();
316 316
 			
317 317
 			//here can't use Loader::functions just include the helper manually
318 318
 			require_once CORE_FUNCTIONS_PATH . 'function_user_agent.php';
@@ -322,10 +322,10 @@  discard block
 block discarded – undo
322 322
 			$logger->error($str);
323 323
 			/***********************************/
324 324
 			$path = CORE_VIEWS_PATH . '404.php';
325
-			if(file_exists($path)){
325
+			if (file_exists($path)) {
326 326
 				//compress the output if is available
327 327
 				$type = null;
328
-				if (self::$_canCompressOutput){
328
+				if (self::$_canCompressOutput) {
329 329
 					$type = 'ob_gzhandler';
330 330
 				}
331 331
 				ob_start($type);
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
 				self::sendHeaders(404);
335 335
 				echo $output;
336 336
 			}
337
-			else{
338
-				show_error('The 404 view [' .$path. '] does not exist');
337
+			else {
338
+				show_error('The 404 view [' . $path . '] does not exist');
339 339
 			}
340 340
 		}
341 341
 
@@ -343,12 +343,12 @@  discard block
 block discarded – undo
343 343
 		 * Display the error to user
344 344
 		 * @param  array  $data the error information
345 345
 		 */
346
-		public static function sendError(array $data = array()){
346
+		public static function sendError(array $data = array()) {
347 347
 			$path = CORE_VIEWS_PATH . 'errors.php';
348
-			if(file_exists($path)){
348
+			if (file_exists($path)) {
349 349
 				//compress the output if is available
350 350
 				$type = null;
351
-				if (self::$_canCompressOutput){
351
+				if (self::$_canCompressOutput) {
352 352
 					$type = 'ob_gzhandler';
353 353
 				}
354 354
 				ob_start($type);
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 				self::sendHeaders(503);
359 359
 				echo $output;
360 360
 			}
361
-			else{
361
+			else {
362 362
 				//can't use show_error() at this time because some dependencies not yet loaded and to prevent loop
363 363
 				set_http_status_header(503);
364 364
 				echo 'The error view [' . $path . '] does not exist';
@@ -370,17 +370,17 @@  discard block
 block discarded – undo
370 370
 		 * @param  array $cacheInfo the cache information
371 371
 		 * @return boolean            true if the information is sent otherwise false
372 372
 		 */
373
-		protected function sendCacheNotYetExpireInfo($cacheInfo){
374
-			if(! empty($cacheInfo)){
373
+		protected function sendCacheNotYetExpireInfo($cacheInfo) {
374
+			if (!empty($cacheInfo)) {
375 375
 				$logger = self::getLogger();
376 376
 				$lastModified = $cacheInfo['mtime'];
377 377
 				$expire = $cacheInfo['expire'];
378 378
 				$maxAge = $expire - $_SERVER['REQUEST_TIME'];
379 379
 				self::setHeader('Pragma', 'public');
380 380
 				self::setHeader('Cache-Control', 'max-age=' . $maxAge . ', public');
381
-				self::setHeader('Expires', gmdate('D, d M Y H:i:s', $expire).' GMT');
382
-				self::setHeader('Last-modified', gmdate('D, d M Y H:i:s', $lastModified).' GMT');
383
-				if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $lastModified <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])){
381
+				self::setHeader('Expires', gmdate('D, d M Y H:i:s', $expire) . ' GMT');
382
+				self::setHeader('Last-modified', gmdate('D, d M Y H:i:s', $lastModified) . ' GMT');
383
+				if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $lastModified <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
384 384
 					$logger->info('The cache page content is not yet expire for the URL [' . $this->_currentUrl . '] send 304 header to browser');
385 385
 					self::sendHeaders(304);
386 386
 					return true;
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 		 * @param object $cache the cache instance
395 395
 		 * @return boolean     the status of the operation
396 396
 		 */
397
-		protected function sendPageContentToBrowser(&$cache){
397
+		protected function sendPageContentToBrowser(&$cache) {
398 398
 			$logger = self::getLogger();
399 399
 			$logger->info('The cache page content is expired or the browser doesn\'t send the HTTP_IF_MODIFIED_SINCE header for the URL [' . $this->_currentUrl . '] send cache headers to tell the browser');
400 400
 			self::sendHeaders(200);
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 			$pageCacheKey = $this->_currentUrlCacheKey;
403 403
 			//get the cache content
404 404
 			$content = $cache->get($pageCacheKey);
405
-			if($content){
405
+			if ($content) {
406 406
 				$logger->info('The page content for the URL [' . $this->_currentUrl . '] already cached just display it');
407 407
 				//load benchmark class
408 408
 				$benchmark = & class_loader('Benchmark');
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 				///display the final output
417 417
 				//compress the output if is available
418 418
 				$type = null;
419
-				if (self::$_canCompressOutput){
419
+				if (self::$_canCompressOutput) {
420 420
 					$type = 'ob_gzhandler';
421 421
 				}
422 422
 				ob_start($type);
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 		 * @param  string $content the page content to be saved
435 435
 		 * @return void
436 436
 		 */
437
-		protected function savePageContentIntoCache($content){
437
+		protected function savePageContentIntoCache($content) {
438 438
 			$obj = & get_instance();
439 439
 			$logger = self::getLogger();
440 440
 
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 			$url = $this->_currentUrl;
443 443
 			//Cache view Time to live in second
444 444
 			$viewCacheTtl = get_config('cache_ttl');
445
-			if (!empty($obj->view_cache_ttl)){
445
+			if (!empty($obj->view_cache_ttl)) {
446 446
 				$viewCacheTtl = $obj->view_cache_ttl;
447 447
 			}
448 448
 			//the cache handler instance
@@ -455,14 +455,14 @@  discard block
 block discarded – undo
455 455
 			
456 456
 			//get the cache information to prepare header to send to browser
457 457
 			$cacheInfo = $cacheInstance->getInfo($cacheKey);
458
-			if($cacheInfo){
458
+			if ($cacheInfo) {
459 459
 				$lastModified = $cacheInfo['mtime'];
460 460
 				$expire = $cacheInfo['expire'];
461 461
 				$maxAge = $expire - time();
462 462
 				self::setHeader('Pragma', 'public');
463 463
 				self::setHeader('Cache-Control', 'max-age=' . $maxAge . ', public');
464
-				self::setHeader('Expires', gmdate('D, d M Y H:i:s', $expire).' GMT');
465
-				self::setHeader('Last-modified', gmdate('D, d M Y H:i:s', $lastModified).' GMT');	
464
+				self::setHeader('Expires', gmdate('D, d M Y H:i:s', $expire) . ' GMT');
465
+				self::setHeader('Last-modified', gmdate('D, d M Y H:i:s', $lastModified) . ' GMT');	
466 466
 			}
467 467
 		}
468 468
 		
@@ -478,21 +478,21 @@  discard block
 block discarded – undo
478 478
 		 * 	'viewFile' => 'view_file'
479 479
 		 * )
480 480
 		 */
481
-		protected  function getModuleInfoForView($view){
481
+		protected  function getModuleInfoForView($view) {
482 482
 			$module = null;
483 483
 			$viewFile = null;
484 484
 			$obj = & get_instance();
485 485
 			//check if the request class contains module name
486
-			if(strpos($view, '/') !== false){
486
+			if (strpos($view, '/') !== false) {
487 487
 				$viewPath = explode('/', $view);
488
-				if(isset($viewPath[0]) && in_array($viewPath[0], Module::getModuleList())){
488
+				if (isset($viewPath[0]) && in_array($viewPath[0], Module::getModuleList())) {
489 489
 					$module = $viewPath[0];
490 490
 					array_shift($viewPath);
491 491
 					$view = implode('/', $viewPath);
492 492
 					$viewFile = $view . '.php';
493 493
 				}
494 494
 			}
495
-			if(! $module && !empty($obj->moduleName)){
495
+			if (!$module && !empty($obj->moduleName)) {
496 496
 				$module = $obj->moduleName;
497 497
 			}
498 498
 			return array(
@@ -507,13 +507,13 @@  discard block
 block discarded – undo
507 507
 		 * @see  Response::render
508 508
 		 * @return void|string
509 509
 		 */
510
-		protected  function loadView($path, array $data = array(), $return = false){
510
+		protected  function loadView($path, array $data = array(), $return = false) {
511 511
 			$found = false;
512
-			if(file_exists($path)){
512
+			if (file_exists($path)) {
513 513
 				//super instance
514 514
 				$obj = & get_instance();
515
-				foreach(get_object_vars($obj) as $key => $value){
516
-					if(! isset($this->{$key})){
515
+				foreach (get_object_vars($obj) as $key => $value) {
516
+					if (!isset($this->{$key})) {
517 517
 						$this->{$key} = & $obj->{$key};
518 518
 					}
519 519
 				}
@@ -522,14 +522,14 @@  discard block
 block discarded – undo
522 522
 				//need use require() instead of require_once because can load this view many time
523 523
 				require $path;
524 524
 				$content = ob_get_clean();
525
-				if($return){
525
+				if ($return) {
526 526
 					return $content;
527 527
 				}
528 528
 				$this->_pageRender .= $content;
529 529
 				$found = true;
530 530
 			}
531
-			if(! $found){
532
-				show_error('Unable to find view [' .$view . ']');
531
+			if (!$found) {
532
+				show_error('Unable to find view [' . $view . ']');
533 533
 			}
534 534
 		}
535 535
 
Please login to merge, or discard this patch.