@@ -69,14 +69,14 @@ |
||
69 | 69 | * @param string $item the cookie item name to be cleared |
70 | 70 | * @return boolean true if the item exists and is deleted successfully otherwise will return false. |
71 | 71 | */ |
72 | - public static function delete($item){ |
|
72 | + public static function delete($item) { |
|
73 | 73 | $logger = self::getLogger(); |
74 | - if(array_key_exists($item, $_COOKIE)){ |
|
75 | - $logger->info('Delete cookie item ['.$item.']'); |
|
74 | + if (array_key_exists($item, $_COOKIE)) { |
|
75 | + $logger->info('Delete cookie item [' . $item . ']'); |
|
76 | 76 | unset($_COOKIE[$item]); |
77 | 77 | return true; |
78 | - } else{ |
|
79 | - $logger->warning('Cookie item ['.$item.'] to be deleted does not exists'); |
|
78 | + } else { |
|
79 | + $logger->warning('Cookie item [' . $item . '] to be deleted does not exists'); |
|
80 | 80 | return false; |
81 | 81 | } |
82 | 82 | } |
@@ -245,9 +245,9 @@ discard block |
||
245 | 245 | $this->_forceFail = false; |
246 | 246 | |
247 | 247 | foreach ($this->getData() as $inputName => $inputVal) { |
248 | - if(is_array($this->data[$inputName])){ |
|
248 | + if (is_array($this->data[$inputName])) { |
|
249 | 249 | $this->data[$inputName] = array_map('trim', $this->data[$inputName]); |
250 | - } else{ |
|
250 | + } else { |
|
251 | 251 | $this->data[$inputName] = trim($this->data[$inputName]); |
252 | 252 | } |
253 | 253 | |
@@ -607,12 +607,12 @@ discard block |
||
607 | 607 | */ |
608 | 608 | protected function _validateRequired($inputName, $ruleName, array $ruleArgs) { |
609 | 609 | $inputVal = $this->post($inputName); |
610 | - if(array_key_exists(1, $ruleArgs) && function_exists($ruleArgs[1])) { |
|
610 | + if (array_key_exists(1, $ruleArgs) && function_exists($ruleArgs[1])) { |
|
611 | 611 | $callbackReturn = $this->_runEmptyCallback($ruleArgs[1]); |
612 | 612 | if ($inputVal == '' && $callbackReturn == true) { |
613 | 613 | $this->_setError($inputName, $ruleName, $this->_getLabel($inputName)); |
614 | 614 | } |
615 | - } else if($inputVal == '') { |
|
615 | + } else if ($inputVal == '') { |
|
616 | 616 | $this->_setError($inputName, $ruleName, $this->_getLabel($inputName)); |
617 | 617 | } |
618 | 618 | } |
@@ -55,14 +55,14 @@ |
||
55 | 55 | * @return string|void if $stream is true send PDF document to browser for download, else return the generated PDF |
56 | 56 | * content like to join in Email attachment of for other purpose use. |
57 | 57 | */ |
58 | - public function generate($html, $filename = 'output.pdf', $stream = true, $paper = 'A4', $orientation = 'portrait'){ |
|
59 | - $this->logger->info('Generating of PDF document: filename [' .$filename. '], stream [' .($stream ? 'TRUE':'FALSE'). '], paper [' .$paper. '], orientation [' .$orientation. ']'); |
|
58 | + public function generate($html, $filename = 'output.pdf', $stream = true, $paper = 'A4', $orientation = 'portrait') { |
|
59 | + $this->logger->info('Generating of PDF document: filename [' . $filename . '], stream [' . ($stream ? 'TRUE' : 'FALSE') . '], paper [' . $paper . '], orientation [' . $orientation . ']'); |
|
60 | 60 | $this->dompdf->load_html($html); |
61 | 61 | $this->dompdf->set_paper($paper, $orientation); |
62 | 62 | $this->dompdf->render(); |
63 | - if($stream){ |
|
63 | + if ($stream) { |
|
64 | 64 | $this->dompdf->stream($filename); |
65 | - } else{ |
|
65 | + } else { |
|
66 | 66 | return $this->dompdf->output(); |
67 | 67 | } |
68 | 68 | } |
@@ -142,9 +142,9 @@ |
||
142 | 142 | public function setTos(array $emails) |
143 | 143 | { |
144 | 144 | foreach ($emails as $name => $email) { |
145 | - if(is_numeric($name)){ |
|
145 | + if (is_numeric($name)) { |
|
146 | 146 | $this->setTo($email); |
147 | - } else{ |
|
147 | + } else { |
|
148 | 148 | $this->setTo($email, $name); |
149 | 149 | } |
150 | 150 | } |
@@ -15,9 +15,9 @@ |
||
15 | 15 | $lang['fv_not_equal_string'] = 'Field %1 must not contain the value %2.'; |
16 | 16 | $lang['fv_depends'] = 'Field %1 depends on field %2 which is not valid.'; |
17 | 17 | $lang['fv_is_unique'] = 'The value of field %1 already exists.'; |
18 | - $lang['fv_is_unique_update'] = 'The value of field %1 already exists for another record.'; |
|
18 | + $lang['fv_is_unique_update'] = 'The value of field %1 already exists for another record.'; |
|
19 | 19 | $lang['fv_exists'] = 'The value of the field %1 does not exist.'; |
20 | - $lang['fv_regex'] = 'The value of the field %1 does not use the correct format.'; |
|
20 | + $lang['fv_regex'] = 'The value of the field %1 does not use the correct format.'; |
|
21 | 21 | $lang['fv_in_list'] = 'The value of field %1 must be one of the list (%2).'; |
22 | 22 | $lang['fv_numeric'] = 'The value of field %1 must be a number.'; |
23 | 23 | $lang['fv_callback'] = 'The value of field %1 is not valid.'; |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | * @param string $eventName the name of the event to register for |
48 | 48 | * @param callable $listener the function or class method to receive the event information after dispatch |
49 | 49 | */ |
50 | - public function addListener($eventName, callable $listener){ |
|
51 | - $this->logger->debug('Adding new event listener for the event name [' .$eventName. '], listener [' .stringfy_vars($listener). ']'); |
|
52 | - if(! isset($this->listeners[$eventName])){ |
|
50 | + public function addListener($eventName, callable $listener) { |
|
51 | + $this->logger->debug('Adding new event listener for the event name [' . $eventName . '], listener [' . stringfy_vars($listener) . ']'); |
|
52 | + if (!isset($this->listeners[$eventName])) { |
|
53 | 53 | $this->logger->info('This event does not have the registered event listener before, adding new one'); |
54 | 54 | $this->listeners[$eventName] = array(); |
55 | - } else{ |
|
55 | + } else { |
|
56 | 56 | $this->logger->info('This event already have the registered listener, add this listener to the list'); |
57 | 57 | } |
58 | 58 | $this->listeners[$eventName][] = $listener; |
@@ -63,17 +63,17 @@ discard block |
||
63 | 63 | * @param string $eventName the event name |
64 | 64 | * @param callable $listener the listener callback |
65 | 65 | */ |
66 | - public function removeListener($eventName, callable $listener){ |
|
67 | - $this->logger->debug('Removing of the event listener, the event name [' .$eventName. '], listener [' .stringfy_vars($listener). ']'); |
|
68 | - if(isset($this->listeners[$eventName])){ |
|
66 | + public function removeListener($eventName, callable $listener) { |
|
67 | + $this->logger->debug('Removing of the event listener, the event name [' . $eventName . '], listener [' . stringfy_vars($listener) . ']'); |
|
68 | + if (isset($this->listeners[$eventName])) { |
|
69 | 69 | $this->logger->info('This event have the listeners, check if this listener exists'); |
70 | - if(false !== $index = array_search($listener, $this->listeners[$eventName], true)){ |
|
71 | - $this->logger->info('Found the listener at index [' .$index. '] remove it'); |
|
70 | + if (false !== $index = array_search($listener, $this->listeners[$eventName], true)) { |
|
71 | + $this->logger->info('Found the listener at index [' . $index . '] remove it'); |
|
72 | 72 | unset($this->listeners[$eventName][$index]); |
73 | - } else{ |
|
73 | + } else { |
|
74 | 74 | $this->logger->info('Cannot found this listener in the event listener list'); |
75 | 75 | } |
76 | - } else{ |
|
76 | + } else { |
|
77 | 77 | $this->logger->info('This event does not have this listener ignore remove'); |
78 | 78 | } |
79 | 79 | } |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | * remove all listeners for this event |
84 | 84 | * @param string $eventName the event name |
85 | 85 | */ |
86 | - public function removeAllListener($eventName = null){ |
|
87 | - $this->logger->debug('Removing of all event listener, the event name [' .$eventName. ']'); |
|
88 | - if($eventName !== null && isset($this->listeners[$eventName])){ |
|
86 | + public function removeAllListener($eventName = null) { |
|
87 | + $this->logger->debug('Removing of all event listener, the event name [' . $eventName . ']'); |
|
88 | + if ($eventName !== null && isset($this->listeners[$eventName])) { |
|
89 | 89 | $this->logger->info('The event name is set of exist in the listener just remove all event listener for this event'); |
90 | 90 | unset($this->listeners[$eventName]); |
91 | - } else{ |
|
91 | + } else { |
|
92 | 92 | $this->logger->info('The event name is not set or does not exist in the listener, so remove all event listener'); |
93 | 93 | $this->listeners = array(); |
94 | 94 | } |
@@ -108,20 +108,20 @@ discard block |
||
108 | 108 | * @param mixed|object $event the event information |
109 | 109 | * @return void|object if event need return, will return the final EventInfo object. |
110 | 110 | */ |
111 | - public function dispatch($event){ |
|
112 | - if(! $event || !$event instanceof EventInfo){ |
|
111 | + public function dispatch($event) { |
|
112 | + if (!$event || !$event instanceof EventInfo) { |
|
113 | 113 | $this->logger->info('The event is not set or is not an instance of "EventInfo" create the default "EventInfo" object to use instead of.'); |
114 | 114 | $event = new EventInfo((string) $event); |
115 | 115 | } |
116 | - $this->logger->debug('Dispatch to the event listener, the event [' .stringfy_vars($event). ']'); |
|
117 | - if(isset($event->stop) && $event->stop){ |
|
116 | + $this->logger->debug('Dispatch to the event listener, the event [' . stringfy_vars($event) . ']'); |
|
117 | + if (isset($event->stop) && $event->stop) { |
|
118 | 118 | $this->logger->info('This event need stopped, no need call any listener'); |
119 | 119 | return; |
120 | 120 | } |
121 | - if($event->returnBack){ |
|
121 | + if ($event->returnBack) { |
|
122 | 122 | $this->logger->info('This event need return back, return the result for future use'); |
123 | 123 | return $this->dispatchToListerners($event); |
124 | - } else{ |
|
124 | + } else { |
|
125 | 125 | $this->logger->info('This event no need return back the result, just dispatch it'); |
126 | 126 | $this->dispatchToListerners($event); |
127 | 127 | } |
@@ -132,35 +132,35 @@ discard block |
||
132 | 132 | * @param object EventInfo $event the event information |
133 | 133 | * @return void|object if event need return, will return the final EventInfo instance. |
134 | 134 | */ |
135 | - private function dispatchToListerners(EventInfo $event){ |
|
135 | + private function dispatchToListerners(EventInfo $event) { |
|
136 | 136 | $eBackup = $event; |
137 | 137 | $list = $this->getListeners($event->name); |
138 | - if(empty($list)){ |
|
139 | - $this->logger->info('No event listener is registered for the event [' .$event->name. '] skipping.'); |
|
140 | - if($event->returnBack){ |
|
138 | + if (empty($list)) { |
|
139 | + $this->logger->info('No event listener is registered for the event [' . $event->name . '] skipping.'); |
|
140 | + if ($event->returnBack) { |
|
141 | 141 | return $event; |
142 | 142 | } |
143 | 143 | return; |
144 | - } else{ |
|
145 | - $this->logger->info('Found the registered event listener for the event [' .$event->name. '] the list are: ' . stringfy_vars($list)); |
|
144 | + } else { |
|
145 | + $this->logger->info('Found the registered event listener for the event [' . $event->name . '] the list are: ' . stringfy_vars($list)); |
|
146 | 146 | } |
147 | - foreach($list as $listener){ |
|
148 | - if($eBackup->returnBack){ |
|
147 | + foreach ($list as $listener) { |
|
148 | + if ($eBackup->returnBack) { |
|
149 | 149 | $returnedEvent = call_user_func_array($listener, array($event)); |
150 | - if($returnedEvent instanceof EventInfo){ |
|
150 | + if ($returnedEvent instanceof EventInfo) { |
|
151 | 151 | $event = $returnedEvent; |
152 | - } else{ |
|
153 | - show_error('This event [' .$event->name. '] need you return the event object after processing'); |
|
152 | + } else { |
|
153 | + show_error('This event [' . $event->name . '] need you return the event object after processing'); |
|
154 | 154 | } |
155 | - } else{ |
|
155 | + } else { |
|
156 | 156 | call_user_func_array($listener, array($event)); |
157 | 157 | } |
158 | - if($event->stop){ |
|
158 | + if ($event->stop) { |
|
159 | 159 | break; |
160 | 160 | } |
161 | 161 | } |
162 | 162 | //only test for original event may be during the flow some listeners change this parameter |
163 | - if($eBackup->returnBack){ |
|
163 | + if ($eBackup->returnBack) { |
|
164 | 164 | return $event; |
165 | 165 | } |
166 | 166 | } |
@@ -170,21 +170,21 @@ discard block |
||
170 | 170 | //check in module first |
171 | 171 | $logger->debug('Checking the view [' . $view . '] from module list ...'); |
172 | 172 | $moduleInfo = $this->getModuleInfoForView($view); |
173 | - $module = $moduleInfo['module']; |
|
174 | - $view = $moduleInfo['view']; |
|
173 | + $module = $moduleInfo['module']; |
|
174 | + $view = $moduleInfo['view']; |
|
175 | 175 | |
176 | 176 | $moduleViewPath = Module::findViewFullPath($view, $module); |
177 | - if($moduleViewPath){ |
|
177 | + if ($moduleViewPath) { |
|
178 | 178 | $path = $moduleViewPath; |
179 | - $logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$moduleViewPath. '] we will used it'); |
|
180 | - } else{ |
|
181 | - $logger->info('Cannot find view [' . $view . '] in module [' .$module. '] using the default location'); |
|
179 | + $logger->info('Found view [' . $view . '] in module [' . $module . '], the file path is [' . $moduleViewPath . '] we will used it'); |
|
180 | + } else { |
|
181 | + $logger->info('Cannot find view [' . $view . '] in module [' . $module . '] using the default location'); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $logger->info('The view file path to be loaded is [' . $path . ']'); |
185 | 185 | |
186 | 186 | ///////// |
187 | - if($return){ |
|
187 | + if ($return) { |
|
188 | 188 | return $this->loadView($path, $data, true); |
189 | 189 | } |
190 | 190 | $this->loadView($path, $data, false); |
@@ -298,8 +298,8 @@ discard block |
||
298 | 298 | $output = ob_get_clean(); |
299 | 299 | self::sendHeaders(404); |
300 | 300 | echo $output; |
301 | - } else{ |
|
302 | - show_error('The 404 view [' .$path. '] does not exist'); |
|
301 | + } else { |
|
302 | + show_error('The 404 view [' . $path . '] does not exist'); |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | $output = ob_get_clean(); |
322 | 322 | self::sendHeaders(503); |
323 | 323 | echo $output; |
324 | - } else{ |
|
324 | + } else { |
|
325 | 325 | //can't use show_error() at this time because some dependencies not yet loaded and to prevent loop |
326 | 326 | set_http_status_header(503); |
327 | 327 | echo 'The error view [' . $path . '] does not exist'; |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | * @param string $item the config item name to be deleted |
93 | 93 | * @return boolean true if the item exists and is deleted successfully otherwise will return false. |
94 | 94 | */ |
95 | - public static function delete($item){ |
|
95 | + public static function delete($item) { |
|
96 | 96 | $logger = self::getLogger(); |
97 | - if(array_key_exists($item, self::$config)){ |
|
98 | - $logger->info('Delete config item ['.$item.']'); |
|
97 | + if (array_key_exists($item, self::$config)) { |
|
98 | + $logger->info('Delete config item [' . $item . ']'); |
|
99 | 99 | unset(self::$config[$item]); |
100 | 100 | return true; |
101 | - } else{ |
|
102 | - $logger->warning('Config item ['.$item.'] to be deleted does not exists'); |
|
101 | + } else { |
|
102 | + $logger->warning('Config item [' . $item . '] to be deleted does not exists'); |
|
103 | 103 | return false; |
104 | 104 | } |
105 | 105 | } |
@@ -147,12 +147,12 @@ discard block |
||
147 | 147 | 0, |
148 | 148 | strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])) |
149 | 149 | ); |
150 | - } else{ |
|
150 | + } else { |
|
151 | 151 | $logger->warning('Can not determine the application base URL automatically, use http://localhost as default'); |
152 | 152 | $baseUrl = 'http://localhost/'; |
153 | 153 | } |
154 | 154 | self::set('base_url', $baseUrl); |
155 | 155 | } |
156 | - self::$config['base_url'] = rtrim(self::$config['base_url'], '/') .'/'; |
|
156 | + self::$config['base_url'] = rtrim(self::$config['base_url'], '/') . '/'; |
|
157 | 157 | } |
158 | 158 | } |
@@ -74,25 +74,25 @@ discard block |
||
74 | 74 | $class = $moduleInfo['class']; |
75 | 75 | |
76 | 76 | $moduleModelFilePath = Module::findModelFullPath($class, $module); |
77 | - if ($moduleModelFilePath){ |
|
78 | - $logger->info('Found model [' . $class . '] from module [' .$module. '], the file path is [' .$moduleModelFilePath. '] we will used it'); |
|
77 | + if ($moduleModelFilePath) { |
|
78 | + $logger->info('Found model [' . $class . '] from module [' . $module . '], the file path is [' . $moduleModelFilePath . '] we will used it'); |
|
79 | 79 | $classFilePath = $moduleModelFilePath; |
80 | - } else{ |
|
80 | + } else { |
|
81 | 81 | $logger->info('Cannot find model [' . $class . '] from modules using the default location'); |
82 | 82 | } |
83 | 83 | $logger->info('The model file path to be loaded is [' . $classFilePath . ']'); |
84 | - if (file_exists($classFilePath)){ |
|
84 | + if (file_exists($classFilePath)) { |
|
85 | 85 | require_once $classFilePath; |
86 | - if (class_exists($class)){ |
|
86 | + if (class_exists($class)) { |
|
87 | 87 | $c = new $class(); |
88 | 88 | $obj = & get_instance(); |
89 | 89 | $obj->{$instance} = $c; |
90 | 90 | static::$loaded[$instance] = $class; |
91 | 91 | $logger->info('Model [' . $class . '] --> ' . $classFilePath . ' loaded successfully.'); |
92 | - } else{ |
|
93 | - show_error('The file '.$classFilePath.' exists but does not contain the class ['. $class . ']'); |
|
92 | + } else { |
|
93 | + show_error('The file ' . $classFilePath . ' exists but does not contain the class [' . $class . ']'); |
|
94 | 94 | } |
95 | - } else{ |
|
95 | + } else { |
|
96 | 96 | show_error('Unable to find the model [' . $class . ']'); |
97 | 97 | } |
98 | 98 | } |
@@ -131,17 +131,17 @@ discard block |
||
131 | 131 | } |
132 | 132 | $libraryFilePath = null; |
133 | 133 | $logger->debug('Check if this is a system library ...'); |
134 | - if (file_exists(CORE_LIBRARY_PATH . $file)){ |
|
134 | + if (file_exists(CORE_LIBRARY_PATH . $file)) { |
|
135 | 135 | $libraryFilePath = CORE_LIBRARY_PATH . $file; |
136 | 136 | $class = ucfirst($class); |
137 | 137 | $logger->info('This library is a system library'); |
138 | - } else{ |
|
138 | + } else { |
|
139 | 139 | $logger->info('This library is not a system library'); |
140 | 140 | //first check if this library is in the module |
141 | 141 | $libraryFilePath = self::getLibraryPathUsingModuleInfo($class); |
142 | 142 | //*************** |
143 | 143 | } |
144 | - if (! $libraryFilePath && file_exists(LIBRARY_PATH . $file)){ |
|
144 | + if (!$libraryFilePath && file_exists(LIBRARY_PATH . $file)) { |
|
145 | 145 | $libraryFilePath = LIBRARY_PATH . $file; |
146 | 146 | } |
147 | 147 | $logger->info('The library file path to be loaded is [' . $libraryFilePath . ']'); |
@@ -173,21 +173,21 @@ discard block |
||
173 | 173 | $moduleInfo = self::getModuleInfoForFunction($function); |
174 | 174 | $module = $moduleInfo['module']; |
175 | 175 | $function = $moduleInfo['function']; |
176 | - if(! empty($moduleInfo['file'])){ |
|
176 | + if (!empty($moduleInfo['file'])) { |
|
177 | 177 | $file = $moduleInfo['file']; |
178 | 178 | } |
179 | 179 | $moduleFunctionPath = Module::findFunctionFullPath($function, $module); |
180 | - if ($moduleFunctionPath){ |
|
181 | - $logger->info('Found helper [' . $function . '] from module [' .$module. '], the file path is [' .$moduleFunctionPath. '] we will used it'); |
|
180 | + if ($moduleFunctionPath) { |
|
181 | + $logger->info('Found helper [' . $function . '] from module [' . $module . '], the file path is [' . $moduleFunctionPath . '] we will used it'); |
|
182 | 182 | $functionFilePath = $moduleFunctionPath; |
183 | - } else{ |
|
183 | + } else { |
|
184 | 184 | $logger->info('Cannot find helper [' . $function . '] from modules using the default location'); |
185 | 185 | } |
186 | - if (! $functionFilePath){ |
|
186 | + if (!$functionFilePath) { |
|
187 | 187 | $searchDir = array(FUNCTIONS_PATH, CORE_FUNCTIONS_PATH); |
188 | - foreach($searchDir as $dir){ |
|
188 | + foreach ($searchDir as $dir) { |
|
189 | 189 | $filePath = $dir . $file; |
190 | - if (file_exists($filePath)){ |
|
190 | + if (file_exists($filePath)) { |
|
191 | 191 | $functionFilePath = $filePath; |
192 | 192 | //is already found not to continue |
193 | 193 | break; |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | } |
196 | 196 | } |
197 | 197 | $logger->info('The helper file path to be loaded is [' . $functionFilePath . ']'); |
198 | - if ($functionFilePath){ |
|
198 | + if ($functionFilePath) { |
|
199 | 199 | require_once $functionFilePath; |
200 | 200 | static::$loaded['function_' . $function] = $functionFilePath; |
201 | 201 | $logger->info('Helper [' . $function . '] --> ' . $functionFilePath . ' loaded successfully.'); |
202 | - } else{ |
|
202 | + } else { |
|
203 | 203 | show_error('Unable to find helper file [' . $file . ']'); |
204 | 204 | } |
205 | 205 | } |
@@ -229,25 +229,25 @@ discard block |
||
229 | 229 | $module = $moduleInfo['module']; |
230 | 230 | $filename = $moduleInfo['filename']; |
231 | 231 | $moduleConfigPath = Module::findConfigFullPath($filename, $module); |
232 | - if ($moduleConfigPath){ |
|
233 | - $logger->info('Found config [' . $filename . '] from module [' .$module. '], the file path is [' .$moduleConfigPath. '] we will used it'); |
|
232 | + if ($moduleConfigPath) { |
|
233 | + $logger->info('Found config [' . $filename . '] from module [' . $module . '], the file path is [' . $moduleConfigPath . '] we will used it'); |
|
234 | 234 | $configFilePath = $moduleConfigPath; |
235 | - } else{ |
|
235 | + } else { |
|
236 | 236 | $logger->info('Cannot find config [' . $filename . '] from modules using the default location'); |
237 | 237 | } |
238 | 238 | $logger->info('The config file path to be loaded is [' . $configFilePath . ']'); |
239 | 239 | $config = array(); |
240 | - if (file_exists($configFilePath)){ |
|
240 | + if (file_exists($configFilePath)) { |
|
241 | 241 | require_once $configFilePath; |
242 | - if (! empty($config) && is_array($config)){ |
|
242 | + if (!empty($config) && is_array($config)) { |
|
243 | 243 | Config::setAll($config); |
244 | 244 | static::$loaded['config_' . $filename] = $configFilePath; |
245 | 245 | $logger->info('Configuration [' . $configFilePath . '] loaded successfully.'); |
246 | 246 | $logger->info('The custom application configuration loaded are listed below: ' . stringfy_vars($config)); |
247 | 247 | unset($config); |
248 | 248 | } |
249 | - } else{ |
|
250 | - show_error('Unable to find config file ['. $configFilePath . ']'); |
|
249 | + } else { |
|
250 | + show_error('Unable to find config file [' . $configFilePath . ']'); |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
@@ -278,21 +278,21 @@ discard block |
||
278 | 278 | $moduleInfo = self::getModuleInfoForLanguage($language); |
279 | 279 | $module = $moduleInfo['module']; |
280 | 280 | $language = $moduleInfo['language']; |
281 | - if(! empty($moduleInfo['file'])){ |
|
281 | + if (!empty($moduleInfo['file'])) { |
|
282 | 282 | $file = $moduleInfo['file']; |
283 | 283 | } |
284 | 284 | $moduleLanguagePath = Module::findLanguageFullPath($language, $appLang, $module); |
285 | - if ($moduleLanguagePath){ |
|
286 | - $logger->info('Found language [' . $language . '] from module [' .$module. '], the file path is [' .$moduleLanguagePath. '] we will used it'); |
|
285 | + if ($moduleLanguagePath) { |
|
286 | + $logger->info('Found language [' . $language . '] from module [' . $module . '], the file path is [' . $moduleLanguagePath . '] we will used it'); |
|
287 | 287 | $languageFilePath = $moduleLanguagePath; |
288 | - } else{ |
|
288 | + } else { |
|
289 | 289 | $logger->info('Cannot find language [' . $language . '] from modules using the default location'); |
290 | 290 | } |
291 | - if (! $languageFilePath){ |
|
291 | + if (!$languageFilePath) { |
|
292 | 292 | $searchDir = array(APP_LANG_PATH, CORE_LANG_PATH); |
293 | - foreach($searchDir as $dir){ |
|
293 | + foreach ($searchDir as $dir) { |
|
294 | 294 | $filePath = $dir . $appLang . DS . $file; |
295 | - if (file_exists($filePath)){ |
|
295 | + if (file_exists($filePath)) { |
|
296 | 296 | $languageFilePath = $filePath; |
297 | 297 | //already found no need continue |
298 | 298 | break; |
@@ -329,19 +329,19 @@ discard block |
||
329 | 329 | * 'class' => 'class_name' |
330 | 330 | * ) |
331 | 331 | */ |
332 | - protected static function getModuleInfoForModelLibrary($class){ |
|
332 | + protected static function getModuleInfoForModelLibrary($class) { |
|
333 | 333 | $module = null; |
334 | 334 | $obj = & get_instance(); |
335 | - if (strpos($class, '/') !== false){ |
|
335 | + if (strpos($class, '/') !== false) { |
|
336 | 336 | $path = explode('/', $class); |
337 | - if (isset($path[0]) && in_array($path[0], Module::getModuleList())){ |
|
337 | + if (isset($path[0]) && in_array($path[0], Module::getModuleList())) { |
|
338 | 338 | $module = $path[0]; |
339 | 339 | $class = ucfirst($path[1]); |
340 | 340 | } |
341 | - } else{ |
|
341 | + } else { |
|
342 | 342 | $class = ucfirst($class); |
343 | 343 | } |
344 | - if (! $module && !empty($obj->moduleName)){ |
|
344 | + if (!$module && !empty($obj->moduleName)) { |
|
345 | 345 | $module = $obj->moduleName; |
346 | 346 | } |
347 | 347 | return array( |
@@ -451,15 +451,15 @@ discard block |
||
451 | 451 | * @param string $class the class name to determine the instance |
452 | 452 | * @return string the instance name |
453 | 453 | */ |
454 | - protected static function getModelLibraryInstanceName($class){ |
|
454 | + protected static function getModelLibraryInstanceName($class) { |
|
455 | 455 | //for module |
456 | 456 | $instance = null; |
457 | - if (strpos($class, '/') !== false){ |
|
457 | + if (strpos($class, '/') !== false) { |
|
458 | 458 | $path = explode('/', $class); |
459 | - if (isset($path[1])){ |
|
459 | + if (isset($path[1])) { |
|
460 | 460 | $instance = strtolower($path[1]); |
461 | 461 | } |
462 | - } else{ |
|
462 | + } else { |
|
463 | 463 | $instance = strtolower($class); |
464 | 464 | } |
465 | 465 | return $instance; |
@@ -478,10 +478,10 @@ discard block |
||
478 | 478 | $module = $moduleInfo['module']; |
479 | 479 | $class = $moduleInfo['class']; |
480 | 480 | $moduleLibraryPath = Module::findLibraryFullPath($class, $module); |
481 | - if ($moduleLibraryPath){ |
|
482 | - $logger->info('Found library [' . $class . '] from module [' .$module. '], the file path is [' .$moduleLibraryPath. '] we will used it'); |
|
481 | + if ($moduleLibraryPath) { |
|
482 | + $logger->info('Found library [' . $class . '] from module [' . $module . '], the file path is [' . $moduleLibraryPath . '] we will used it'); |
|
483 | 483 | $libraryFilePath = $moduleLibraryPath; |
484 | - } else{ |
|
484 | + } else { |
|
485 | 485 | $logger->info('Cannot find library [' . $class . '] from modules using the default location'); |
486 | 486 | } |
487 | 487 | return $libraryFilePath; |
@@ -495,20 +495,20 @@ discard block |
||
495 | 495 | * @param array $params the parameter to use |
496 | 496 | * @return void |
497 | 497 | */ |
498 | - protected static function loadLibrary($libraryFilePath, $class, $instance, $params = array()){ |
|
499 | - if ($libraryFilePath){ |
|
498 | + protected static function loadLibrary($libraryFilePath, $class, $instance, $params = array()) { |
|
499 | + if ($libraryFilePath) { |
|
500 | 500 | $logger = static::getLogger(); |
501 | 501 | require_once $libraryFilePath; |
502 | - if (class_exists($class)){ |
|
502 | + if (class_exists($class)) { |
|
503 | 503 | $c = $params ? new $class($params) : new $class(); |
504 | 504 | $obj = & get_instance(); |
505 | 505 | $obj->{$instance} = $c; |
506 | 506 | static::$loaded[$instance] = $class; |
507 | 507 | $logger->info('Library [' . $class . '] --> ' . $libraryFilePath . ' loaded successfully.'); |
508 | - } else{ |
|
509 | - show_error('The file '.$libraryFilePath.' exists but does not contain the class '.$class); |
|
508 | + } else { |
|
509 | + show_error('The file ' . $libraryFilePath . ' exists but does not contain the class ' . $class); |
|
510 | 510 | } |
511 | - } else{ |
|
511 | + } else { |
|
512 | 512 | show_error('Unable to find library class [' . $class . ']'); |
513 | 513 | } |
514 | 514 | } |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | } |
535 | 535 | static::$loaded['lang_' . $language] = $languageFilePath; |
536 | 536 | $logger->info('Language [' . $language . '] --> ' . $languageFilePath . ' loaded successfully.'); |
537 | - } else{ |
|
537 | + } else { |
|
538 | 538 | show_error('Unable to find language [' . $language . ']'); |
539 | 539 | } |
540 | 540 | } |