@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | - class Request{ |
|
| 27 | + class Request { |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * The value for the super global $_GET |
@@ -90,21 +90,21 @@ discard block |
||
| 90 | 90 | /** |
| 91 | 91 | * Construct new request instance |
| 92 | 92 | */ |
| 93 | - public function __construct(){ |
|
| 93 | + public function __construct() { |
|
| 94 | 94 | $this->get = $_GET; |
| 95 | 95 | $this->post = $_POST; |
| 96 | 96 | $this->server = $_SERVER; |
| 97 | 97 | $this->query = $_REQUEST; |
| 98 | 98 | $this->cookie = $_COOKIE; |
| 99 | 99 | $this->file = $_FILES; |
| 100 | - $this->session =& class_loader('Session', 'classes'); |
|
| 100 | + $this->session = & class_loader('Session', 'classes'); |
|
| 101 | 101 | $this->method = $this->server('REQUEST_METHOD'); |
| 102 | 102 | $this->requestUri = $this->server('REQUEST_URI'); |
| 103 | 103 | $this->header = array(); |
| 104 | - if(function_exists('apache_request_headers')){ |
|
| 104 | + if (function_exists('apache_request_headers')) { |
|
| 105 | 105 | $this->header = apache_request_headers(); |
| 106 | 106 | } |
| 107 | - else if(function_exists('getallheaders')){ |
|
| 107 | + else if (function_exists('getallheaders')) { |
|
| 108 | 108 | $this->header = getallheaders(); |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * Get the request method |
| 114 | 114 | * @return string |
| 115 | 115 | */ |
| 116 | - public function method(){ |
|
| 116 | + public function method() { |
|
| 117 | 117 | return $this->method; |
| 118 | 118 | } |
| 119 | 119 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * Get the request URI |
| 122 | 122 | * @return string |
| 123 | 123 | */ |
| 124 | - public function requestUri(){ |
|
| 124 | + public function requestUri() { |
|
| 125 | 125 | return $this->requestUri; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -131,13 +131,13 @@ discard block |
||
| 131 | 131 | * @param boolean $xss if need apply some XSS attack rule on the value |
| 132 | 132 | * @return array|mixed the item value if the key exists or all array if the key does not exists or is empty |
| 133 | 133 | */ |
| 134 | - public function query($key = null, $xss = true){ |
|
| 135 | - if(empty($key)){ |
|
| 134 | + public function query($key = null, $xss = true) { |
|
| 135 | + if (empty($key)) { |
|
| 136 | 136 | //return all |
| 137 | 137 | return $xss ? clean_input($this->query) : $this->query; |
| 138 | 138 | } |
| 139 | 139 | $query = array_key_exists($key, $this->query) ? $this->query[$key] : null; |
| 140 | - if($xss){ |
|
| 140 | + if ($xss) { |
|
| 141 | 141 | $query = clean_input($query); |
| 142 | 142 | } |
| 143 | 143 | return $query; |
@@ -149,13 +149,13 @@ discard block |
||
| 149 | 149 | * @param boolean $xss if need apply some XSS attack rule on the value |
| 150 | 150 | * @return array|mixed the item value if the key exists or all array if the key does not exists or is empty |
| 151 | 151 | */ |
| 152 | - public function get($key = null, $xss = true){ |
|
| 153 | - if(empty($key)){ |
|
| 152 | + public function get($key = null, $xss = true) { |
|
| 153 | + if (empty($key)) { |
|
| 154 | 154 | //return all |
| 155 | 155 | return $xss ? clean_input($this->get) : $this->get; |
| 156 | 156 | } |
| 157 | 157 | $get = array_key_exists($key, $this->get) ? $this->get[$key] : null; |
| 158 | - if($xss){ |
|
| 158 | + if ($xss) { |
|
| 159 | 159 | $get = clean_input($get); |
| 160 | 160 | } |
| 161 | 161 | return $get; |
@@ -167,13 +167,13 @@ discard block |
||
| 167 | 167 | * @param boolean $xss if need apply some XSS attack rule on the value |
| 168 | 168 | * @return array|mixed the item value if the key exists or all array if the key does not exists or is empty |
| 169 | 169 | */ |
| 170 | - public function post($key = null, $xss = true){ |
|
| 171 | - if(empty($key)){ |
|
| 170 | + public function post($key = null, $xss = true) { |
|
| 171 | + if (empty($key)) { |
|
| 172 | 172 | //return all |
| 173 | 173 | return $xss ? clean_input($this->post) : $this->post; |
| 174 | 174 | } |
| 175 | 175 | $post = array_key_exists($key, $this->post) ? $this->post[$key] : null; |
| 176 | - if($xss){ |
|
| 176 | + if ($xss) { |
|
| 177 | 177 | $post = clean_input($post); |
| 178 | 178 | } |
| 179 | 179 | return $post; |
@@ -185,13 +185,13 @@ discard block |
||
| 185 | 185 | * @param boolean $xss if need apply some XSS attack rule on the value |
| 186 | 186 | * @return array|mixed the item value if the key exists or all array if the key does not exists or is empty |
| 187 | 187 | */ |
| 188 | - public function server($key = null, $xss = true){ |
|
| 189 | - if(empty($key)){ |
|
| 188 | + public function server($key = null, $xss = true) { |
|
| 189 | + if (empty($key)) { |
|
| 190 | 190 | //return all |
| 191 | 191 | return $xss ? clean_input($this->server) : $this->server; |
| 192 | 192 | } |
| 193 | 193 | $server = array_key_exists($key, $this->server) ? $this->server[$key] : null; |
| 194 | - if($xss){ |
|
| 194 | + if ($xss) { |
|
| 195 | 195 | $server = clean_input($server); |
| 196 | 196 | } |
| 197 | 197 | return $server; |
@@ -203,13 +203,13 @@ discard block |
||
| 203 | 203 | * @param boolean $xss if need apply some XSS attack rule on the value |
| 204 | 204 | * @return array|mixed the item value if the key exists or all array if the key does not exists or is empty |
| 205 | 205 | */ |
| 206 | - public function cookie($key = null, $xss = true){ |
|
| 207 | - if(empty($key)){ |
|
| 206 | + public function cookie($key = null, $xss = true) { |
|
| 207 | + if (empty($key)) { |
|
| 208 | 208 | //return all |
| 209 | 209 | return $xss ? clean_input($this->cookie) : $this->cookie; |
| 210 | 210 | } |
| 211 | 211 | $cookie = array_key_exists($key, $this->cookie) ? $this->cookie[$key] : null; |
| 212 | - if($xss){ |
|
| 212 | + if ($xss) { |
|
| 213 | 213 | $cookie = clean_input($cookie); |
| 214 | 214 | } |
| 215 | 215 | return $cookie; |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @param boolean $xss if need apply some XSS attack rule on the value |
| 222 | 222 | * @return array|mixed the item value if the key exists or all array if the key does not exists or is empty |
| 223 | 223 | */ |
| 224 | - public function file($key, $xss = true){ |
|
| 224 | + public function file($key, $xss = true) { |
|
| 225 | 225 | $file = array_key_exists($key, $this->file) ? $this->file[$key] : null; |
| 226 | 226 | return $file; |
| 227 | 227 | } |
@@ -232,9 +232,9 @@ discard block |
||
| 232 | 232 | * @param boolean $xss if need apply some XSS attack rule on the value |
| 233 | 233 | * @return array|mixed the item value if the key exists or null if the key does not exists |
| 234 | 234 | */ |
| 235 | - public function session($key, $xss = true){ |
|
| 235 | + public function session($key, $xss = true) { |
|
| 236 | 236 | $session = $this->session->get($key); |
| 237 | - if($xss){ |
|
| 237 | + if ($xss) { |
|
| 238 | 238 | $session = clean_input($session); |
| 239 | 239 | } |
| 240 | 240 | return $session; |
@@ -246,9 +246,9 @@ discard block |
||
| 246 | 246 | * @param boolean $xss if need apply some XSS attack rule on the value |
| 247 | 247 | * @return mixed the item value if the key exists or null if the key does not exists |
| 248 | 248 | */ |
| 249 | - public function header($key, $xss = true){ |
|
| 249 | + public function header($key, $xss = true) { |
|
| 250 | 250 | $header = array_key_exists($key, $this->header) ? $this->header[$key] : null; |
| 251 | - if($xss){ |
|
| 251 | + if ($xss) { |
|
| 252 | 252 | $header = clean_input($header); |
| 253 | 253 | } |
| 254 | 254 | return $header; |
@@ -24,7 +24,7 @@ discard block |
||
| 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 |
||
| 42 | 42 | * The signleton of the logger |
| 43 | 43 | * @return Object the Log instance |
| 44 | 44 | */ |
| 45 | - private static function getLogger(){ |
|
| 46 | - if(static::$logger == null){ |
|
| 47 | - static::$logger[0] =& class_loader('Log', 'classes'); |
|
| 45 | + private static function getLogger() { |
|
| 46 | + if (static::$logger == null) { |
|
| 47 | + static::$logger[0] = & class_loader('Log', 'classes'); |
|
| 48 | 48 | static::$logger[0]->setLogger('Library::Module'); |
| 49 | 49 | } |
| 50 | 50 | return static::$logger[0]; |
@@ -53,25 +53,25 @@ discard block |
||
| 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 = static::getLogger(); |
| 58 | 58 | $logger->debug('Check if the application contains the modules ...'); |
| 59 | 59 | $moduleDir = opendir(MODULE_PATH); |
| 60 | - while(($module = readdir($moduleDir)) !== false){ |
|
| 61 | - if($module != '.' && $module != '..' && preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)){ |
|
| 60 | + while (($module = readdir($moduleDir)) !== false) { |
|
| 61 | + if ($module != '.' && $module != '..' && preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)) { |
|
| 62 | 62 | static::$list[] = $module; |
| 63 | 63 | } |
| 64 | - else{ |
|
| 65 | - $logger->info('Skipping [' .$module. '], may be this is not a directory or does not exists or is invalid name'); |
|
| 64 | + else { |
|
| 65 | + $logger->info('Skipping [' . $module . '], may be this is not a directory or does not exists or is invalid name'); |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | closedir($moduleDir); |
| 69 | 69 | ksort(static::$list); |
| 70 | 70 | |
| 71 | - if(static::hasModule()){ |
|
| 71 | + if (static::hasModule()) { |
|
| 72 | 72 | $logger->info('The application contains the module below [' . implode(', ', static::getModuleList()) . ']'); |
| 73 | 73 | } |
| 74 | - else{ |
|
| 74 | + else { |
|
| 75 | 75 | $logger->info('The application contains no module skipping'); |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | * Get the list of the custom autoload configuration from module if exists |
| 81 | 81 | * @return array|boolean the autoload configurations list or false if no module contains the autoload configuration values |
| 82 | 82 | */ |
| 83 | - public static function getModulesAutoloadConfig(){ |
|
| 83 | + public static function getModulesAutoloadConfig() { |
|
| 84 | 84 | $logger = static::getLogger(); |
| 85 | - if(! static::hasModule()){ |
|
| 85 | + if (!static::hasModule()) { |
|
| 86 | 86 | $logger->info('No module was loaded skipping.'); |
| 87 | 87 | return false; |
| 88 | 88 | } |
@@ -94,33 +94,33 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | foreach (static::$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 | require_once $file; |
| 99 | - if(! empty($autoload) && is_array($autoload)){ |
|
| 99 | + if (!empty($autoload) && is_array($autoload)) { |
|
| 100 | 100 | //libraries autoload |
| 101 | - if(! empty($autoload['libraries']) && is_array($autoload['libraries'])){ |
|
| 101 | + if (!empty($autoload['libraries']) && is_array($autoload['libraries'])) { |
|
| 102 | 102 | $autoloads['libraries'] = array_merge($autoloads['libraries'], $autoload['libraries']); |
| 103 | 103 | } |
| 104 | 104 | //config autoload |
| 105 | - if(! empty($autoload['config']) && is_array($autoload['config'])){ |
|
| 105 | + if (!empty($autoload['config']) && is_array($autoload['config'])) { |
|
| 106 | 106 | $autoloads['config'] = array_merge($autoloads['config'], $autoload['config']); |
| 107 | 107 | } |
| 108 | 108 | //models autoload |
| 109 | - if(! empty($autoload['models']) && is_array($autoload['models'])){ |
|
| 109 | + if (!empty($autoload['models']) && is_array($autoload['models'])) { |
|
| 110 | 110 | $autoloads['models'] = array_merge($autoloads['models'], $autoload['models']); |
| 111 | 111 | } |
| 112 | 112 | //functions autoload |
| 113 | - if(! empty($autoload['functions']) && is_array($autoload['functions'])){ |
|
| 113 | + if (!empty($autoload['functions']) && is_array($autoload['functions'])) { |
|
| 114 | 114 | $autoloads['functions'] = array_merge($autoloads['functions'], $autoload['functions']); |
| 115 | 115 | } |
| 116 | 116 | //languages autoload |
| 117 | - if(! empty($autoload['languages']) && is_array($autoload['languages'])){ |
|
| 117 | + if (!empty($autoload['languages']) && is_array($autoload['languages'])) { |
|
| 118 | 118 | $autoloads['languages'] = array_merge($autoloads['languages'], $autoload['languages']); |
| 119 | 119 | } |
| 120 | 120 | unset($autoload); |
| 121 | 121 | } |
| 122 | - else{ |
|
| 123 | - show_error('No autoload configuration found in autoload.php for module [' .$module. ']'); |
|
| 122 | + else { |
|
| 123 | + show_error('No autoload configuration found in autoload.php for module [' . $module . ']'); |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -131,23 +131,23 @@ discard block |
||
| 131 | 131 | * Get the list of the custom routes configuration from module if exists |
| 132 | 132 | * @return array|boolean the routes list or false if no module contains the routes configuration |
| 133 | 133 | */ |
| 134 | - public static function getModulesRoutes(){ |
|
| 134 | + public static function getModulesRoutes() { |
|
| 135 | 135 | $logger = static::getLogger(); |
| 136 | - if(! static::hasModule()){ |
|
| 136 | + if (!static::hasModule()) { |
|
| 137 | 137 | $logger->info('No module was loaded skipping.'); |
| 138 | 138 | return false; |
| 139 | 139 | } |
| 140 | 140 | $routes = array(); |
| 141 | 141 | foreach (static::$list as $module) { |
| 142 | 142 | $file = MODULE_PATH . $module . DS . 'config' . DS . 'routes.php'; |
| 143 | - if(file_exists($file)){ |
|
| 143 | + if (file_exists($file)) { |
|
| 144 | 144 | require_once $file; |
| 145 | - if(! empty($route) && is_array($route)){ |
|
| 145 | + if (!empty($route) && is_array($route)) { |
|
| 146 | 146 | $routes = array_merge($routes, $route); |
| 147 | 147 | unset($route); |
| 148 | 148 | } |
| 149 | - else{ |
|
| 150 | - show_error('No routing configuration found in [' .$file. '] for module [' . $module . ']'); |
|
| 149 | + else { |
|
| 150 | + show_error('No routing configuration found in [' . $file . '] for module [' . $module . ']'); |
|
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | } |
@@ -161,23 +161,23 @@ discard block |
||
| 161 | 161 | * @param string $module the module name |
| 162 | 162 | * @return boolean|string false or null if no module have this controller, path the full path of the controller |
| 163 | 163 | */ |
| 164 | - public static function findControllerFullPath($class, $module = null){ |
|
| 164 | + public static function findControllerFullPath($class, $module = null) { |
|
| 165 | 165 | $logger = static::getLogger(); |
| 166 | - if(! static::hasModule()){ |
|
| 166 | + if (!static::hasModule()) { |
|
| 167 | 167 | $logger->info('No module was loaded skiping.'); |
| 168 | 168 | return false; |
| 169 | 169 | } |
| 170 | 170 | $class = str_ireplace('.php', '', $class); |
| 171 | 171 | $class = ucfirst($class); |
| 172 | - $classFile = $class.'.php'; |
|
| 173 | - $logger->debug('Checking the controller [' . $class . '] in module [' .$module. '] ...'); |
|
| 172 | + $classFile = $class . '.php'; |
|
| 173 | + $logger->debug('Checking the controller [' . $class . '] in module [' . $module . '] ...'); |
|
| 174 | 174 | $filePath = MODULE_PATH . $module . DS . 'controllers' . DS . $classFile; |
| 175 | - if(file_exists($filePath)){ |
|
| 176 | - $logger->info('Found controller [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 175 | + if (file_exists($filePath)) { |
|
| 176 | + $logger->info('Found controller [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
| 177 | 177 | return $filePath; |
| 178 | 178 | } |
| 179 | - else{ |
|
| 180 | - $logger->info('Controller [' . $class . '] does not exist in the module [' .$module. ']'); |
|
| 179 | + else { |
|
| 180 | + $logger->info('Controller [' . $class . '] does not exist in the module [' . $module . ']'); |
|
| 181 | 181 | return false; |
| 182 | 182 | } |
| 183 | 183 | } |
@@ -188,23 +188,23 @@ discard block |
||
| 188 | 188 | * @param string $module the module name |
| 189 | 189 | * @return boolean|string false or null if no module have this model, return the full path of this model |
| 190 | 190 | */ |
| 191 | - public static function findModelFullPath($class, $module = null){ |
|
| 191 | + public static function findModelFullPath($class, $module = null) { |
|
| 192 | 192 | $logger = static::getLogger(); |
| 193 | - if(! static::hasModule()){ |
|
| 193 | + if (!static::hasModule()) { |
|
| 194 | 194 | $logger->info('No module was loaded skiping.'); |
| 195 | 195 | return false; |
| 196 | 196 | } |
| 197 | 197 | $class = str_ireplace('.php', '', $class); |
| 198 | 198 | $class = ucfirst($class); |
| 199 | - $classFile = $class.'.php'; |
|
| 200 | - $logger->debug('Checking model [' . $class . '] in module [' .$module. '] ...'); |
|
| 199 | + $classFile = $class . '.php'; |
|
| 200 | + $logger->debug('Checking model [' . $class . '] in module [' . $module . '] ...'); |
|
| 201 | 201 | $filePath = MODULE_PATH . $module . DS . 'models' . DS . $classFile; |
| 202 | - if(file_exists($filePath)){ |
|
| 203 | - $logger->info('Found model [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 202 | + if (file_exists($filePath)) { |
|
| 203 | + $logger->info('Found model [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
| 204 | 204 | return $filePath; |
| 205 | 205 | } |
| 206 | - else{ |
|
| 207 | - $logger->info('Model [' . $class . '] does not exist in the module [' .$module. ']'); |
|
| 206 | + else { |
|
| 207 | + $logger->info('Model [' . $class . '] does not exist in the module [' . $module . ']'); |
|
| 208 | 208 | return false; |
| 209 | 209 | } |
| 210 | 210 | } |
@@ -215,22 +215,22 @@ discard block |
||
| 215 | 215 | * @param string $module the module name |
| 216 | 216 | * @return boolean|string false or null if no module have this configuration, return the full path of this configuration |
| 217 | 217 | */ |
| 218 | - public static function findConfigFullPath($configuration, $module = null){ |
|
| 218 | + public static function findConfigFullPath($configuration, $module = null) { |
|
| 219 | 219 | $logger = static::getLogger(); |
| 220 | - if(! static::hasModule()){ |
|
| 220 | + if (!static::hasModule()) { |
|
| 221 | 221 | $logger->info('No module was loaded skiping.'); |
| 222 | 222 | return false; |
| 223 | 223 | } |
| 224 | 224 | $configuration = str_ireplace('.php', '', $configuration); |
| 225 | - $file = $configuration.'.php'; |
|
| 226 | - $logger->debug('Checking configuration [' . $configuration . '] in module [' .$module. '] ...'); |
|
| 225 | + $file = $configuration . '.php'; |
|
| 226 | + $logger->debug('Checking configuration [' . $configuration . '] in module [' . $module . '] ...'); |
|
| 227 | 227 | $filePath = MODULE_PATH . $module . DS . 'config' . DS . $file; |
| 228 | - if(file_exists($filePath)){ |
|
| 229 | - $logger->info('Found configuration [' . $configuration . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 228 | + if (file_exists($filePath)) { |
|
| 229 | + $logger->info('Found configuration [' . $configuration . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
| 230 | 230 | return $filePath; |
| 231 | 231 | } |
| 232 | - else{ |
|
| 233 | - $logger->info('Configuration [' . $configuration . '] does not exist in the module [' .$module. ']'); |
|
| 232 | + else { |
|
| 233 | + $logger->info('Configuration [' . $configuration . '] does not exist in the module [' . $module . ']'); |
|
| 234 | 234 | return false; |
| 235 | 235 | } |
| 236 | 236 | } |
@@ -241,23 +241,23 @@ discard block |
||
| 241 | 241 | * @param string $module the module name |
| 242 | 242 | * @return boolean|string false or null if no module have this helper, return the full path of this helper |
| 243 | 243 | */ |
| 244 | - public static function findFunctionFullPath($helper, $module = null){ |
|
| 244 | + public static function findFunctionFullPath($helper, $module = null) { |
|
| 245 | 245 | $logger = static::getLogger(); |
| 246 | - if(! static::hasModule()){ |
|
| 246 | + if (!static::hasModule()) { |
|
| 247 | 247 | $logger->info('No module was loaded skiping.'); |
| 248 | 248 | return false; |
| 249 | 249 | } |
| 250 | 250 | $helper = str_ireplace('.php', '', $helper); |
| 251 | 251 | $helper = str_ireplace('function_', '', $helper); |
| 252 | - $file = 'function_'.$helper.'.php'; |
|
| 253 | - $logger->debug('Checking helper [' . $helper . '] in module [' .$module. '] ...'); |
|
| 252 | + $file = 'function_' . $helper . '.php'; |
|
| 253 | + $logger->debug('Checking helper [' . $helper . '] in module [' . $module . '] ...'); |
|
| 254 | 254 | $filePath = MODULE_PATH . $module . DS . 'functions' . DS . $file; |
| 255 | - if(file_exists($filePath)){ |
|
| 256 | - $logger->info('Found helper [' . $helper . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 255 | + if (file_exists($filePath)) { |
|
| 256 | + $logger->info('Found helper [' . $helper . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
| 257 | 257 | return $filePath; |
| 258 | 258 | } |
| 259 | - else{ |
|
| 260 | - $logger->info('Helper [' . $helper . '] does not exist in the module [' .$module. ']'); |
|
| 259 | + else { |
|
| 260 | + $logger->info('Helper [' . $helper . '] does not exist in the module [' . $module . ']'); |
|
| 261 | 261 | return false; |
| 262 | 262 | } |
| 263 | 263 | } |
@@ -269,22 +269,22 @@ discard block |
||
| 269 | 269 | * @param string $module the module name |
| 270 | 270 | * @return boolean|string false or null if no module have this library, return the full path of this library |
| 271 | 271 | */ |
| 272 | - public static function findLibraryFullPath($class, $module = null){ |
|
| 272 | + public static function findLibraryFullPath($class, $module = null) { |
|
| 273 | 273 | $logger = static::getLogger(); |
| 274 | - if(! static::hasModule()){ |
|
| 274 | + if (!static::hasModule()) { |
|
| 275 | 275 | $logger->info('No module was loaded skiping.'); |
| 276 | 276 | return false; |
| 277 | 277 | } |
| 278 | 278 | $class = str_ireplace('.php', '', $class); |
| 279 | - $file = $class.'.php'; |
|
| 280 | - $logger->debug('Checking library [' . $class . '] in module [' .$module. '] ...'); |
|
| 279 | + $file = $class . '.php'; |
|
| 280 | + $logger->debug('Checking library [' . $class . '] in module [' . $module . '] ...'); |
|
| 281 | 281 | $filePath = MODULE_PATH . $module . DS . 'libraries' . DS . $file; |
| 282 | - if(file_exists($filePath)){ |
|
| 283 | - $logger->info('Found library [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 282 | + if (file_exists($filePath)) { |
|
| 283 | + $logger->info('Found library [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
| 284 | 284 | return $filePath; |
| 285 | 285 | } |
| 286 | - else{ |
|
| 287 | - $logger->info('Library [' . $class . '] does not exist in the module [' .$module. ']'); |
|
| 286 | + else { |
|
| 287 | + $logger->info('Library [' . $class . '] does not exist in the module [' . $module . ']'); |
|
| 288 | 288 | return false; |
| 289 | 289 | } |
| 290 | 290 | } |
@@ -296,9 +296,9 @@ discard block |
||
| 296 | 296 | * @param string $module the module name to check |
| 297 | 297 | * @return boolean|string false or null if no module have this view, path the full path of the view |
| 298 | 298 | */ |
| 299 | - public static function findViewFullPath($view, $module = null){ |
|
| 299 | + public static function findViewFullPath($view, $module = null) { |
|
| 300 | 300 | $logger = static::getLogger(); |
| 301 | - if(! static::hasModule()){ |
|
| 301 | + if (!static::hasModule()) { |
|
| 302 | 302 | $logger->info('No module was loaded skiping.'); |
| 303 | 303 | return false; |
| 304 | 304 | } |
@@ -306,14 +306,14 @@ discard block |
||
| 306 | 306 | $view = trim($view, '/\\'); |
| 307 | 307 | $view = str_ireplace('/', DS, $view); |
| 308 | 308 | $viewFile = $view . '.php'; |
| 309 | - $logger->debug('Checking view [' . $view . '] in module [' .$module. '] ...'); |
|
| 309 | + $logger->debug('Checking view [' . $view . '] in module [' . $module . '] ...'); |
|
| 310 | 310 | $filePath = MODULE_PATH . $module . DS . 'views' . DS . $viewFile; |
| 311 | - if(file_exists($filePath)){ |
|
| 312 | - $logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 311 | + if (file_exists($filePath)) { |
|
| 312 | + $logger->info('Found view [' . $view . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
| 313 | 313 | return $filePath; |
| 314 | 314 | } |
| 315 | - else{ |
|
| 316 | - $logger->info('View [' . $view . '] does not exist in the module [' .$module. ']'); |
|
| 315 | + else { |
|
| 316 | + $logger->info('View [' . $view . '] does not exist in the module [' . $module . ']'); |
|
| 317 | 317 | return false; |
| 318 | 318 | } |
| 319 | 319 | } |
@@ -325,23 +325,23 @@ discard block |
||
| 325 | 325 | * @param string $appLang the application language like 'en', 'fr' |
| 326 | 326 | * @return boolean|string false or null if no module have this language, return the full path of this language |
| 327 | 327 | */ |
| 328 | - public static function findLanguageFullPath($language, $module = null, $appLang){ |
|
| 328 | + public static function findLanguageFullPath($language, $module = null, $appLang) { |
|
| 329 | 329 | $logger = static::getLogger(); |
| 330 | - if(! static::hasModule()){ |
|
| 330 | + if (!static::hasModule()) { |
|
| 331 | 331 | $logger->info('No module was loaded skiping.'); |
| 332 | 332 | return false; |
| 333 | 333 | } |
| 334 | 334 | $language = str_ireplace('.php', '', $language); |
| 335 | 335 | $language = str_ireplace('lang_', '', $language); |
| 336 | - $file = 'lang_'.$language.'.php'; |
|
| 337 | - $logger->debug('Checking language [' . $language . '] in module [' .$module. '] ...'); |
|
| 336 | + $file = 'lang_' . $language . '.php'; |
|
| 337 | + $logger->debug('Checking language [' . $language . '] in module [' . $module . '] ...'); |
|
| 338 | 338 | $filePath = MODULE_PATH . $module . DS . 'lang' . DS . $appLang . DS . $file; |
| 339 | - if(file_exists($filePath)){ |
|
| 340 | - $logger->info('Found language [' . $language . '] in module [' .$module. '], the file path is [' .$filePath. ']'); |
|
| 339 | + if (file_exists($filePath)) { |
|
| 340 | + $logger->info('Found language [' . $language . '] in module [' . $module . '], the file path is [' . $filePath . ']'); |
|
| 341 | 341 | return $filePath; |
| 342 | 342 | } |
| 343 | - else{ |
|
| 344 | - $logger->info('Language [' . $language . '] does not exist in the module [' .$module. ']'); |
|
| 343 | + else { |
|
| 344 | + $logger->info('Language [' . $language . '] does not exist in the module [' . $module . ']'); |
|
| 345 | 345 | return false; |
| 346 | 346 | } |
| 347 | 347 | } |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | * Get the list of module loaded |
| 351 | 351 | * @return array the module list |
| 352 | 352 | */ |
| 353 | - public static function getModuleList(){ |
|
| 353 | + public static function getModuleList() { |
|
| 354 | 354 | return static::$list; |
| 355 | 355 | } |
| 356 | 356 | |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | * Check if the application has an module |
| 359 | 359 | * @return boolean |
| 360 | 360 | */ |
| 361 | - public static function hasModule(){ |
|
| 361 | + public static function hasModule() { |
|
| 362 | 362 | return !empty(static::$list); |
| 363 | 363 | } |
| 364 | 364 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | - class Log{ |
|
| 27 | + class Log { |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * The defined constante for Log level |
@@ -52,14 +52,14 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * Create new Log instance |
| 54 | 54 | */ |
| 55 | - public function __construct(){ |
|
| 55 | + public function __construct() { |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * Set the logger to identify each message in the log |
| 60 | 60 | * @param string $logger the logger name |
| 61 | 61 | */ |
| 62 | - public function setLogger($logger){ |
|
| 62 | + public function setLogger($logger) { |
|
| 63 | 63 | $this->logger = $logger; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @see Log::writeLog for more detail |
| 69 | 69 | * @param string $message the log message to save |
| 70 | 70 | */ |
| 71 | - public function fatal($message){ |
|
| 71 | + public function fatal($message) { |
|
| 72 | 72 | $this->writeLog($message, self::FATAL); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @see Log::writeLog for more detail |
| 78 | 78 | * @param string $message the log message to save |
| 79 | 79 | */ |
| 80 | - public function error($message){ |
|
| 80 | + public function error($message) { |
|
| 81 | 81 | $this->writeLog($message, self::ERROR); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @see Log::writeLog for more detail |
| 87 | 87 | * @param string $message the log message to save |
| 88 | 88 | */ |
| 89 | - public function warning($message){ |
|
| 89 | + public function warning($message) { |
|
| 90 | 90 | $this->writeLog($message, self::WARNING); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @see Log::writeLog for more detail |
| 96 | 96 | * @param string $message the log message to save |
| 97 | 97 | */ |
| 98 | - public function info($message){ |
|
| 98 | + public function info($message) { |
|
| 99 | 99 | $this->writeLog($message, self::INFO); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @see Log::writeLog for more detail |
| 105 | 105 | * @param string $message the log message to save |
| 106 | 106 | */ |
| 107 | - public function debug($message){ |
|
| 107 | + public function debug($message) { |
|
| 108 | 108 | $this->writeLog($message, self::DEBUG); |
| 109 | 109 | } |
| 110 | 110 | |
@@ -115,59 +115,59 @@ discard block |
||
| 115 | 115 | * @param int|string $level the log level in integer or string format, if is string will convert into integer |
| 116 | 116 | * to allow check the log level threshold. |
| 117 | 117 | */ |
| 118 | - public function writeLog($message, $level = self::INFO){ |
|
| 118 | + public function writeLog($message, $level = self::INFO) { |
|
| 119 | 119 | $configLogLevel = get_config('log_level'); |
| 120 | - if(! $configLogLevel){ |
|
| 120 | + if (!$configLogLevel) { |
|
| 121 | 121 | //so means no need log just stop here |
| 122 | 122 | return; |
| 123 | 123 | } |
| 124 | 124 | //check config log level |
| 125 | - if(! static::isValidConfigLevel($configLogLevel)){ |
|
| 125 | + if (!static::isValidConfigLevel($configLogLevel)) { |
|
| 126 | 126 | //NOTE: here need put the show_error() "logging" to false to prevent loop |
| 127 | 127 | show_error('Invalid config log level [' . $configLogLevel . '], the value must be one of the following: ' . implode(', ', array_map('strtoupper', static::$validConfigLevel)), $title = 'Log Config Error', $logging = false); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | //check if config log_logger_name is set |
| 131 | - if($this->logger){ |
|
| 131 | + if ($this->logger) { |
|
| 132 | 132 | $configLoggerName = get_config('log_logger_name', ''); |
| 133 | - if($configLoggerName){ |
|
| 134 | - if (is_array($configLoggerName)){ |
|
| 133 | + if ($configLoggerName) { |
|
| 134 | + if (is_array($configLoggerName)) { |
|
| 135 | 135 | //for best comparaison put all string to lowercase |
| 136 | 136 | $configLoggerName = array_map('strtolower', $configLoggerName); |
| 137 | - if(! in_array(strtolower($this->logger), $configLoggerName)){ |
|
| 137 | + if (!in_array(strtolower($this->logger), $configLoggerName)) { |
|
| 138 | 138 | return; |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | - else if(strtolower($this->logger) !== strtolower($configLoggerName)){ |
|
| 141 | + else if (strtolower($this->logger) !== strtolower($configLoggerName)) { |
|
| 142 | 142 | return; |
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | //if $level is not an integer |
| 148 | - if(! is_numeric($level)){ |
|
| 148 | + if (!is_numeric($level)) { |
|
| 149 | 149 | $level = static::getLevelValue($level); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | //check if can logging regarding the log level config |
| 153 | 153 | $configLevel = static::getLevelValue($configLogLevel); |
| 154 | - if($configLevel > $level){ |
|
| 154 | + if ($configLevel > $level) { |
|
| 155 | 155 | //can't log |
| 156 | 156 | return; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | $logSavePath = get_config('log_save_path'); |
| 160 | - if(! $logSavePath){ |
|
| 160 | + if (!$logSavePath) { |
|
| 161 | 161 | $logSavePath = LOGS_PATH; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - if(! is_dir($logSavePath) || !is_writable($logSavePath)){ |
|
| 164 | + if (!is_dir($logSavePath) || !is_writable($logSavePath)) { |
|
| 165 | 165 | //NOTE: here need put the show_error() "logging" to false to prevent loop |
| 166 | 166 | show_error('Error : the log dir does not exists or is not writable', $title = 'Log directory error', $logging = false); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | $path = $logSavePath . 'logs-' . date('Y-m-d') . '.log'; |
| 170 | - if(! file_exists($path)){ |
|
| 170 | + if (!file_exists($path)) { |
|
| 171 | 171 | @touch($path); |
| 172 | 172 | } |
| 173 | 173 | //may be at this time helper user_agent not yet included |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * |
| 202 | 202 | * @return boolean true if the given log level is valid, false if not |
| 203 | 203 | */ |
| 204 | - private static function isValidConfigLevel($level){ |
|
| 204 | + private static function isValidConfigLevel($level) { |
|
| 205 | 205 | $level = strtolower($level); |
| 206 | 206 | return in_array($level, static::$validConfigLevel); |
| 207 | 207 | } |
@@ -211,27 +211,27 @@ discard block |
||
| 211 | 211 | * @param string $level the log level in string format |
| 212 | 212 | * @return int the log level in integer format using the predefinied constants |
| 213 | 213 | */ |
| 214 | - private static function getLevelValue($level){ |
|
| 214 | + private static function getLevelValue($level) { |
|
| 215 | 215 | $level = strtolower($level); |
| 216 | 216 | $value = self::NONE; |
| 217 | 217 | |
| 218 | 218 | //the default value is NONE, so means no need test for NONE |
| 219 | - if($level == 'fatal'){ |
|
| 219 | + if ($level == 'fatal') { |
|
| 220 | 220 | $value = self::FATAL; |
| 221 | 221 | } |
| 222 | - else if($level == 'error'){ |
|
| 222 | + else if ($level == 'error') { |
|
| 223 | 223 | $value = self::ERROR; |
| 224 | 224 | } |
| 225 | - else if($level == 'warning' || $level == 'warn'){ |
|
| 225 | + else if ($level == 'warning' || $level == 'warn') { |
|
| 226 | 226 | $value = self::WARNING; |
| 227 | 227 | } |
| 228 | - else if($level == 'info'){ |
|
| 228 | + else if ($level == 'info') { |
|
| 229 | 229 | $value = self::INFO; |
| 230 | 230 | } |
| 231 | - else if($level == 'debug'){ |
|
| 231 | + else if ($level == 'debug') { |
|
| 232 | 232 | $value = self::DEBUG; |
| 233 | 233 | } |
| 234 | - else if($level == 'all'){ |
|
| 234 | + else if ($level == 'all') { |
|
| 235 | 235 | $value = self::ALL; |
| 236 | 236 | } |
| 237 | 237 | return $value; |
@@ -242,23 +242,23 @@ discard block |
||
| 242 | 242 | * @param integer $level the log level in integer format |
| 243 | 243 | * @return int the log level in string format |
| 244 | 244 | */ |
| 245 | - private static function getLevelName($level){ |
|
| 245 | + private static function getLevelName($level) { |
|
| 246 | 246 | $value = ''; |
| 247 | 247 | |
| 248 | 248 | //the default value is NONE, so means no need test for NONE |
| 249 | - if($level == self::FATAL){ |
|
| 249 | + if ($level == self::FATAL) { |
|
| 250 | 250 | $value = 'FATAL'; |
| 251 | 251 | } |
| 252 | - else if($level == self::ERROR){ |
|
| 252 | + else if ($level == self::ERROR) { |
|
| 253 | 253 | $value = 'ERROR'; |
| 254 | 254 | } |
| 255 | - else if($level == self::WARNING){ |
|
| 255 | + else if ($level == self::WARNING) { |
|
| 256 | 256 | $value = 'WARNING'; |
| 257 | 257 | } |
| 258 | - else if($level == self::INFO){ |
|
| 258 | + else if ($level == self::INFO) { |
|
| 259 | 259 | $value = 'INFO'; |
| 260 | 260 | } |
| 261 | - else if($level == self::DEBUG){ |
|
| 261 | + else if ($level == self::DEBUG) { |
|
| 262 | 262 | $value = 'DEBUG'; |
| 263 | 263 | } |
| 264 | 264 | //no need for ALL |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * Class for Benchmark |
| 29 | 29 | */ |
| 30 | - class Benchmark{ |
|
| 30 | + class Benchmark { |
|
| 31 | 31 | /** |
| 32 | 32 | * The markers for excution time |
| 33 | 33 | * @var array |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * This method is used to mark one point for benchmark (execution time and memory usage) |
| 45 | 45 | * @param string $name the marker name |
| 46 | 46 | */ |
| 47 | - public function mark($name){ |
|
| 47 | + public function mark($name) { |
|
| 48 | 48 | //Marker for execution time |
| 49 | 49 | $this->markersTime[$name] = microtime(true); |
| 50 | 50 | //Marker for memory usage |
@@ -58,12 +58,12 @@ discard block |
||
| 58 | 58 | * @param integer $decimalCount the number of decimal |
| 59 | 59 | * @return double the total execution time |
| 60 | 60 | */ |
| 61 | - public function elapsedTime($startMarkerName = null, $endMarkerName = null, $decimalCount = 6){ |
|
| 62 | - if(! $startMarkerName || !isset($this->markersTime[$startMarkerName])){ |
|
| 61 | + public function elapsedTime($startMarkerName = null, $endMarkerName = null, $decimalCount = 6) { |
|
| 62 | + if (!$startMarkerName || !isset($this->markersTime[$startMarkerName])) { |
|
| 63 | 63 | return 0; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - if(! isset($this->markersTime[$endMarkerName])){ |
|
| 66 | + if (!isset($this->markersTime[$endMarkerName])) { |
|
| 67 | 67 | $this->markersTime[$endMarkerName] = microtime(true); |
| 68 | 68 | } |
| 69 | 69 | return number_format($this->markersTime[$endMarkerName] - $this->markersTime[$startMarkerName], $decimalCount); |
@@ -76,12 +76,12 @@ discard block |
||
| 76 | 76 | * @param integer $decimalCount the number of decimal |
| 77 | 77 | * @return double the total memory usage |
| 78 | 78 | */ |
| 79 | - public function memoryUsage($startMarkerName = null, $endMarkerName = null, $decimalCount = 6){ |
|
| 80 | - if(! $startMarkerName || !isset($this->markersMemory[$startMarkerName])){ |
|
| 79 | + public function memoryUsage($startMarkerName = null, $endMarkerName = null, $decimalCount = 6) { |
|
| 80 | + if (!$startMarkerName || !isset($this->markersMemory[$startMarkerName])) { |
|
| 81 | 81 | return 0; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if(! isset($this->markersMemory[$endMarkerName])){ |
|
| 84 | + if (!isset($this->markersMemory[$endMarkerName])) { |
|
| 85 | 85 | $this->markersMemory[$endMarkerName] = microtime(true); |
| 86 | 86 | } |
| 87 | 87 | return number_format($this->markersMemory[$endMarkerName] - $this->markersMemory[$startMarkerName], $decimalCount); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * PDF library to generate PDF document using the library DOMPDF |
| 29 | 29 | */ |
| 30 | - class PDF{ |
|
| 30 | + class PDF { |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * The dompdf instance |
@@ -44,11 +44,11 @@ discard block |
||
| 44 | 44 | /** |
| 45 | 45 | * Create PDF library instance |
| 46 | 46 | */ |
| 47 | - public function __construct(){ |
|
| 48 | - $this->logger =& class_loader('Log', 'classes'); |
|
| 47 | + public function __construct() { |
|
| 48 | + $this->logger = & class_loader('Log', 'classes'); |
|
| 49 | 49 | $this->logger->setLogger('Library::PDF'); |
| 50 | 50 | |
| 51 | - require_once VENDOR_PATH.'dompdf/dompdf_config.inc.php'; |
|
| 51 | + require_once VENDOR_PATH . 'dompdf/dompdf_config.inc.php'; |
|
| 52 | 52 | $this->dompdf = new Dompdf(); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -62,15 +62,15 @@ discard block |
||
| 62 | 62 | * @return string|void if $stream is true send PDF document to browser for download, else return the generated PDF |
| 63 | 63 | * content like to join in Email attachment of for other purpose use. |
| 64 | 64 | */ |
| 65 | - public function generate($html, $filename = 'output.pdf', $stream = true, $paper = 'A4', $orientation = 'portrait'){ |
|
| 66 | - $this->logger->info('Generating of PDF document: filename [' .$filename. '], stream [' .($stream ? 'TRUE':'FALSE'). '], paper [' .$paper. '], orientation [' .$orientation. ']'); |
|
| 65 | + public function generate($html, $filename = 'output.pdf', $stream = true, $paper = 'A4', $orientation = 'portrait') { |
|
| 66 | + $this->logger->info('Generating of PDF document: filename [' . $filename . '], stream [' . ($stream ? 'TRUE' : 'FALSE') . '], paper [' . $paper . '], orientation [' . $orientation . ']'); |
|
| 67 | 67 | $this->dompdf->load_html($html); |
| 68 | 68 | $this->dompdf->set_paper($paper, $orientation); |
| 69 | 69 | $this->dompdf->render(); |
| 70 | - if($stream){ |
|
| 70 | + if ($stream) { |
|
| 71 | 71 | $this->dompdf->stream($filename); |
| 72 | 72 | } |
| 73 | - else{ |
|
| 73 | + else { |
|
| 74 | 74 | return $this->dompdf->output(); |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @return object the dompdf instance |
| 82 | 82 | */ |
| 83 | - public function getDompdf(){ |
|
| 83 | + public function getDompdf() { |
|
| 84 | 84 | return $this->dompdf; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function __construct() |
| 88 | 88 | { |
| 89 | - $this->logger =& class_loader('Log', 'classes'); |
|
| 89 | + $this->logger = & class_loader('Log', 'classes'); |
|
| 90 | 90 | $this->logger->setLogger('Library::Email'); |
| 91 | 91 | $this->reset(); |
| 92 | 92 | } |
@@ -148,10 +148,10 @@ discard block |
||
| 148 | 148 | public function setTos(array $emails) |
| 149 | 149 | { |
| 150 | 150 | foreach ($emails as $name => $email) { |
| 151 | - if(is_numeric($name)){ |
|
| 151 | + if (is_numeric($name)) { |
|
| 152 | 152 | $this->setTo($email); |
| 153 | 153 | } |
| 154 | - else{ |
|
| 154 | + else { |
|
| 155 | 155 | $this->setTo($email, $name); |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -281,8 +281,8 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | public function addAttachment($path, $filename = null, $data = null) |
| 283 | 283 | { |
| 284 | - if(! file_exists($path)){ |
|
| 285 | - show_error('The file [' .$path. '] does not exists.'); |
|
| 284 | + if (!file_exists($path)) { |
|
| 285 | + show_error('The file [' . $path . '] does not exists.'); |
|
| 286 | 286 | } |
| 287 | 287 | $filename = empty($filename) ? basename($path) : $filename; |
| 288 | 288 | $filename = $this->encodeUtf8($this->filterOther((string) $filename)); |
@@ -304,8 +304,8 @@ discard block |
||
| 304 | 304 | */ |
| 305 | 305 | public function getAttachmentData($path) |
| 306 | 306 | { |
| 307 | - if(! file_exists($path)){ |
|
| 308 | - show_error('The file [' .$path. '] does not exists.'); |
|
| 307 | + if (!file_exists($path)) { |
|
| 308 | + show_error('The file [' . $path . '] does not exists.'); |
|
| 309 | 309 | } |
| 310 | 310 | $filesize = filesize($path); |
| 311 | 311 | $handle = fopen($path, "r"); |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | - class Cookie{ |
|
| 27 | + class Cookie { |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * The logger instance |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | * The signleton of the logger |
| 37 | 37 | * @return Object the Log instance |
| 38 | 38 | */ |
| 39 | - private static function getLogger(){ |
|
| 40 | - if(static::$logger == null){ |
|
| 41 | - static::$logger[0] =& class_loader('Log', 'classes'); |
|
| 39 | + private static function getLogger() { |
|
| 40 | + if (static::$logger == null) { |
|
| 41 | + static::$logger[0] = & class_loader('Log', 'classes'); |
|
| 42 | 42 | static::$logger[0]->setLogger('Library::Cookie'); |
| 43 | 43 | } |
| 44 | 44 | return static::$logger[0]; |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | * @param mixed $default the default value to use if can not find the cokkie item in the list |
| 51 | 51 | * @return mixed the cookie value if exist or the default value |
| 52 | 52 | */ |
| 53 | - public static function get($item, $default = null){ |
|
| 53 | + public static function get($item, $default = null) { |
|
| 54 | 54 | $logger = static::getLogger(); |
| 55 | - if(array_key_exists($item, $_COOKIE)){ |
|
| 55 | + if (array_key_exists($item, $_COOKIE)) { |
|
| 56 | 56 | return $_COOKIE[$item]; |
| 57 | 57 | } |
| 58 | 58 | $logger->warning('Cannot find cookie item [' . $item . '], using the default value [' . $default . ']'); |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | * @param boolean $secure if this cookie will be available on secure connection or not |
| 70 | 70 | * @param boolean $httponly if this cookie will be available under HTTP protocol. |
| 71 | 71 | */ |
| 72 | - public static function set($name, $value = '', $expire = 0, $path = '/', $domain = '', $secure = false, $httponly = false){ |
|
| 73 | - if(headers_sent()){ |
|
| 72 | + public static function set($name, $value = '', $expire = 0, $path = '/', $domain = '', $secure = false, $httponly = false) { |
|
| 73 | + if (headers_sent()) { |
|
| 74 | 74 | show_error('There exists a cookie that we wanted to create that we couldn\'t |
| 75 | 75 | because headers was already sent. Make sure to do this first |
| 76 | 76 | before outputing anything.'); |
| 77 | 77 | } |
| 78 | 78 | $timestamp = $expire; |
| 79 | - if($expire){ |
|
| 79 | + if ($expire) { |
|
| 80 | 80 | $timestamp = time() + $expire; |
| 81 | 81 | } |
| 82 | 82 | setcookie($name, $value, $timestamp, $path, $domain, $secure, $httponly); |
@@ -87,15 +87,15 @@ discard block |
||
| 87 | 87 | * @param string $item the cookie item name to be cleared |
| 88 | 88 | * @return boolean true if the item exists and is deleted successfully otherwise will return false. |
| 89 | 89 | */ |
| 90 | - public static function delete($item){ |
|
| 90 | + public static function delete($item) { |
|
| 91 | 91 | $logger = static::getLogger(); |
| 92 | - if(array_key_exists($item, $_COOKIE)){ |
|
| 93 | - $logger->info('Delete cookie item ['.$item.']'); |
|
| 92 | + if (array_key_exists($item, $_COOKIE)) { |
|
| 93 | + $logger->info('Delete cookie item [' . $item . ']'); |
|
| 94 | 94 | unset($_COOKIE[$item]); |
| 95 | 95 | return true; |
| 96 | 96 | } |
| 97 | - else{ |
|
| 98 | - $logger->warning('Cookie item ['.$item.'] to be deleted does not exists'); |
|
| 97 | + else { |
|
| 98 | + $logger->warning('Cookie item [' . $item . '] to be deleted does not exists'); |
|
| 99 | 99 | return false; |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @param string $item the cookie item name |
| 106 | 106 | * @return boolean true if the cookie item is set, false or not |
| 107 | 107 | */ |
| 108 | - public static function exists($item){ |
|
| 108 | + public static function exists($item) { |
|
| 109 | 109 | return array_key_exists($item, $_COOKIE); |
| 110 | 110 | } |
| 111 | 111 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @since 1.0.0 |
| 39 | 39 | * @filesource |
| 40 | 40 | */ |
| 41 | - class Assets{ |
|
| 41 | + class Assets { |
|
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * The logger instance |
@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | * The signleton of the logger |
| 51 | 51 | * @return Object the Log instance |
| 52 | 52 | */ |
| 53 | - private static function getLogger(){ |
|
| 54 | - if(static::$logger == null){ |
|
| 53 | + private static function getLogger() { |
|
| 54 | + if (static::$logger == null) { |
|
| 55 | 55 | //can't assign reference to static variable |
| 56 | - static::$logger[0] =& class_loader('Log', 'classes'); |
|
| 56 | + static::$logger[0] = & class_loader('Log', 'classes'); |
|
| 57 | 57 | static::$logger[0]->setLogger('Library::Assets'); |
| 58 | 58 | } |
| 59 | 59 | return static::$logger[0]; |
@@ -72,13 +72,13 @@ discard block |
||
| 72 | 72 | * @param $asset the name of the assets file path with the extension. |
| 73 | 73 | * @return string|null the absolute path of the assets file, if it exists otherwise returns null if the file does not exist. |
| 74 | 74 | */ |
| 75 | - public static function path($asset){ |
|
| 75 | + public static function path($asset) { |
|
| 76 | 76 | $logger = static::getLogger(); |
| 77 | 77 | $path = ASSETS_PATH . $asset; |
| 78 | 78 | |
| 79 | 79 | $logger->debug('Including the Assets file [' . $path . ']'); |
| 80 | 80 | //Check if the file exists |
| 81 | - if(file_exists($path)){ |
|
| 81 | + if (file_exists($path)) { |
|
| 82 | 82 | $logger->info('Assets file [' . $path . '] included successfully'); |
| 83 | 83 | return Url::base_url($path); |
| 84 | 84 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * @param $path the name of the css file without the extension. |
| 99 | 99 | * @return string|null the absolute path of the css file, if it exists otherwise returns null if the file does not exist. |
| 100 | 100 | */ |
| 101 | - public static function css($path){ |
|
| 101 | + public static function css($path) { |
|
| 102 | 102 | $logger = static::getLogger(); |
| 103 | 103 | /* |
| 104 | 104 | * if the file name contains the ".css" extension, replace it with |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | $logger->debug('Including the Assets file [' . $path . '] for CSS'); |
| 111 | 111 | //Check if the file exists |
| 112 | - if(file_exists($path)){ |
|
| 112 | + if (file_exists($path)) { |
|
| 113 | 113 | $logger->info('Assets file [' . $path . '] for CSS included successfully'); |
| 114 | 114 | return Url::base_url($path); |
| 115 | 115 | } |
@@ -129,12 +129,12 @@ discard block |
||
| 129 | 129 | * @param $path the name of the javascript file without the extension. |
| 130 | 130 | * @return string|null the absolute path of the javascript file, if it exists otherwise returns null if the file does not exist. |
| 131 | 131 | */ |
| 132 | - public static function js($path){ |
|
| 132 | + public static function js($path) { |
|
| 133 | 133 | $logger = static::getLogger(); |
| 134 | 134 | $path = str_ireplace('.js', '', $path); |
| 135 | 135 | $path = ASSETS_PATH . 'js/' . $path . '.js'; |
| 136 | 136 | $logger->debug('Including the Assets file [' . $path . '] for javascript'); |
| 137 | - if(file_exists($path)){ |
|
| 137 | + if (file_exists($path)) { |
|
| 138 | 138 | $logger->info('Assets file [' . $path . '] for Javascript included successfully'); |
| 139 | 139 | return Url::base_url($path); |
| 140 | 140 | } |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | * @param $path the name of the image file with the extension. |
| 155 | 155 | * @return string|null the absolute path of the image file, if it exists otherwise returns null if the file does not exist. |
| 156 | 156 | */ |
| 157 | - public static function img($path){ |
|
| 157 | + public static function img($path) { |
|
| 158 | 158 | $logger = static::getLogger(); |
| 159 | 159 | $path = ASSETS_PATH . 'images/' . $path; |
| 160 | 160 | $logger->debug('Including the Assets file [' . $path . '] for image'); |
| 161 | - if(file_exists($path)){ |
|
| 161 | + if (file_exists($path)) { |
|
| 162 | 162 | $logger->info('Assets file [' . $path . '] for image included successfully'); |
| 163 | 163 | return Url::base_url($path); |
| 164 | 164 | } |
@@ -25,13 +25,13 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | |
| 28 | - class FormValidation{ |
|
| 28 | + class FormValidation { |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * The form validation status |
| 32 | 32 | * @var boolean |
| 33 | 33 | */ |
| 34 | - protected $_success = false; |
|
| 34 | + protected $_success = false; |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * The list of errors messages |
@@ -40,31 +40,31 @@ discard block |
||
| 40 | 40 | protected $_errorsMessages = array(); |
| 41 | 41 | |
| 42 | 42 | // Array of rule sets, fieldName => PIPE seperated ruleString |
| 43 | - protected $_rules = array(); |
|
| 43 | + protected $_rules = array(); |
|
| 44 | 44 | |
| 45 | 45 | // Array of errors, niceName => Error Message |
| 46 | - protected $_errors = array(); |
|
| 46 | + protected $_errors = array(); |
|
| 47 | 47 | |
| 48 | 48 | // Array of post Key => Nice name labels |
| 49 | - protected $_labels = array(); |
|
| 49 | + protected $_labels = array(); |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * The errors delimiters |
| 53 | 53 | * @var array |
| 54 | 54 | */ |
| 55 | - protected $_allErrorsDelimiter = array('<div class="error">', '</div>'); |
|
| 55 | + protected $_allErrorsDelimiter = array('<div class="error">', '</div>'); |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * The each error delimiter |
| 59 | 59 | * @var array |
| 60 | 60 | */ |
| 61 | - protected $_eachErrorDelimiter = array('<p class="error">', '</p>'); |
|
| 61 | + protected $_eachErrorDelimiter = array('<p class="error">', '</p>'); |
|
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * Indicated if need force the validation to be failed |
| 65 | 65 | * @var boolean |
| 66 | 66 | */ |
| 67 | - protected $_forceFail = false; |
|
| 67 | + protected $_forceFail = false; |
|
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * The list of the error messages overrides by the original |
@@ -98,13 +98,13 @@ discard block |
||
| 98 | 98 | * @return void |
| 99 | 99 | */ |
| 100 | 100 | public function __construct() { |
| 101 | - $this->logger =& class_loader('Log', 'classes'); |
|
| 101 | + $this->logger = & class_loader('Log', 'classes'); |
|
| 102 | 102 | $this->logger->setLogger('Library::FormValidation'); |
| 103 | 103 | |
| 104 | 104 | //Load form validation language message |
| 105 | 105 | Loader::lang('form_validation'); |
| 106 | 106 | $obj = & get_instance(); |
| 107 | - $this->_errorsMessages = array( |
|
| 107 | + $this->_errorsMessages = array( |
|
| 108 | 108 | 'required' => $obj->lang->get('fv_required'), |
| 109 | 109 | 'min_length' => $obj->lang->get('fv_min_length'), |
| 110 | 110 | 'max_length' => $obj->lang->get('fv_max_length'), |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | $this->_success = false; |
| 142 | 142 | $this->_forceFail = false; |
| 143 | 143 | $this->data = array(); |
| 144 | - $this->enableCsrfCheck = false; |
|
| 144 | + $this->enableCsrfCheck = false; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @return FormValidation Current instance of object. |
| 152 | 152 | */ |
| 153 | - public function setData(array $data){ |
|
| 153 | + public function setData(array $data) { |
|
| 154 | 154 | $this->logger->debug('Setting the form validation data, the values are: ' . stringfy_vars($data)); |
| 155 | 155 | $this->data = $data; |
| 156 | 156 | return $this; |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | * Get the form validation data |
| 161 | 161 | * @return array the form validation data to be validated |
| 162 | 162 | */ |
| 163 | - public function getData(){ |
|
| 163 | + public function getData() { |
|
| 164 | 164 | return $this->data; |
| 165 | 165 | } |
| 166 | 166 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * |
| 170 | 170 | * @return string the function name |
| 171 | 171 | */ |
| 172 | - protected function _toCallCase($funcName, $prefix='_validate') { |
|
| 172 | + protected function _toCallCase($funcName, $prefix = '_validate') { |
|
| 173 | 173 | $funcName = strtolower($funcName); |
| 174 | 174 | $finalFuncName = $prefix; |
| 175 | 175 | foreach (explode('_', $funcName) as $funcNamePart) { |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @return boolean Whether or not the form has been submitted or the data is available for validation. |
| 194 | 194 | */ |
| 195 | 195 | public function canDoValidation() { |
| 196 | - return get_instance()->request->method() === 'POST' || ! empty($this->data); |
|
| 196 | + return get_instance()->request->method() === 'POST' || !empty($this->data); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
@@ -215,16 +215,16 @@ discard block |
||
| 215 | 215 | * afterwards. |
| 216 | 216 | */ |
| 217 | 217 | protected function _run() { |
| 218 | - if(get_instance()->request->method() == 'POST' || $this->enableCsrfCheck){ |
|
| 218 | + if (get_instance()->request->method() == 'POST' || $this->enableCsrfCheck) { |
|
| 219 | 219 | $this->logger->debug('Check if CSRF is enabled in configuration'); |
| 220 | 220 | //first check for CSRF |
| 221 | - if( get_config('csrf_enable', false) || $this->enableCsrfCheck){ |
|
| 221 | + if (get_config('csrf_enable', false) || $this->enableCsrfCheck) { |
|
| 222 | 222 | $this->logger->info('Check the CSRF value if is valid'); |
| 223 | - if(! Security::validateCSRF()){ |
|
| 223 | + if (!Security::validateCSRF()) { |
|
| 224 | 224 | show_error('Invalide data, Cross Site Request Forgery do his job, the data to validate is corrupted.'); |
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | - else{ |
|
| 227 | + else { |
|
| 228 | 228 | $this->logger->info('CSRF is not enabled in configuration or not set manully, no need to check it'); |
| 229 | 229 | } |
| 230 | 230 | } |
@@ -232,10 +232,10 @@ discard block |
||
| 232 | 232 | $this->_forceFail = false; |
| 233 | 233 | |
| 234 | 234 | foreach ($this->getData() as $inputName => $inputVal) { |
| 235 | - if(is_array($this->data[$inputName])){ |
|
| 235 | + if (is_array($this->data[$inputName])) { |
|
| 236 | 236 | $this->data[$inputName] = array_map('trim', $this->data[$inputName]); |
| 237 | 237 | } |
| 238 | - else{ |
|
| 238 | + else { |
|
| 239 | 239 | $this->data[$inputName] = trim($this->data[$inputName]); |
| 240 | 240 | } |
| 241 | 241 | |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | public function setRule($inputField, $inputLabel, $ruleSets) { |
| 263 | 263 | $this->_rules[$inputField] = $ruleSets; |
| 264 | 264 | $this->_labels[$inputField] = $inputLabel; |
| 265 | - $this->logger->info('Set the field rule: name [' .$inputField. '], label [' .$inputLabel. '], rules [' .$ruleSets. ']'); |
|
| 265 | + $this->logger->info('Set the field rule: name [' . $inputField . '], label [' . $inputLabel . '], rules [' . $ruleSets . ']'); |
|
| 266 | 266 | return $this; |
| 267 | 267 | } |
| 268 | 268 | |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | } |
| 428 | 428 | $errorOutput .= $errorsEnd; |
| 429 | 429 | echo ($echo) ? $errorOutput : ''; |
| 430 | - return (! $echo) ? $errorOutput : null; |
|
| 430 | + return (!$echo) ? $errorOutput : null; |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
@@ -452,26 +452,26 @@ discard block |
||
| 452 | 452 | /* |
| 453 | 453 | //////////////// hack for regex rule that can contain "|" |
| 454 | 454 | */ |
| 455 | - if(strpos($ruleString, 'regex') !== false){ |
|
| 455 | + if (strpos($ruleString, 'regex') !== false) { |
|
| 456 | 456 | $regexRule = array(); |
| 457 | 457 | $rule = '#regex\[\/(.*)\/([a-zA-Z0-9]?)\]#'; |
| 458 | 458 | preg_match($rule, $ruleString, $regexRule); |
| 459 | 459 | $ruleStringTemp = preg_replace($rule, '', $ruleString); |
| 460 | - if(isset($regexRule[0]) && !empty($regexRule[0])){ |
|
| 460 | + if (isset($regexRule[0]) && !empty($regexRule[0])) { |
|
| 461 | 461 | $ruleSets[] = $regexRule[0]; |
| 462 | 462 | } |
| 463 | 463 | $ruleStringRegex = explode('|', $ruleStringTemp); |
| 464 | - if(is_array($ruleStringRegex)){ |
|
| 464 | + if (is_array($ruleStringRegex)) { |
|
| 465 | 465 | foreach ($ruleStringRegex as $rule) { |
| 466 | 466 | $rule = trim($rule); |
| 467 | - if($rule){ |
|
| 467 | + if ($rule) { |
|
| 468 | 468 | $ruleSets[] = $rule; |
| 469 | 469 | } |
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | 473 | /***********************************/ |
| 474 | - else{ |
|
| 474 | + else { |
|
| 475 | 475 | if (strpos($ruleString, '|') !== FALSE) { |
| 476 | 476 | $ruleSets = explode('|', $ruleString); |
| 477 | 477 | } else { |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | * @return void |
| 504 | 504 | */ |
| 505 | 505 | protected function _validateRule($inputName, $inputVal, $ruleName) { |
| 506 | - $this->logger->debug('Rule validation of field [' .$inputName. '], value [' .$inputVal. '], rule [' .$ruleName. ']'); |
|
| 506 | + $this->logger->debug('Rule validation of field [' . $inputName . '], value [' . $inputVal . '], rule [' . $ruleName . ']'); |
|
| 507 | 507 | // Array to store args |
| 508 | 508 | $ruleArgs = array(); |
| 509 | 509 | |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | $key = $i - 1; |
| 548 | 548 | $rulePhrase = str_replace('%' . $i, $replacements[$key], $rulePhrase); |
| 549 | 549 | } |
| 550 | - if (! array_key_exists($inputName, $this->_errors)) { |
|
| 550 | + if (!array_key_exists($inputName, $this->_errors)) { |
|
| 551 | 551 | $this->_errors[$inputName] = $rulePhrase; |
| 552 | 552 | } |
| 553 | 553 | } |
@@ -599,13 +599,13 @@ discard block |
||
| 599 | 599 | */ |
| 600 | 600 | protected function _validateRequired($inputName, $ruleName, array $ruleArgs) { |
| 601 | 601 | $inputVal = $this->post($inputName); |
| 602 | - if(array_key_exists(1, $ruleArgs) && function_exists($ruleArgs[1])) { |
|
| 602 | + if (array_key_exists(1, $ruleArgs) && function_exists($ruleArgs[1])) { |
|
| 603 | 603 | $callbackReturn = $this->_runEmptyCallback($ruleArgs[1]); |
| 604 | 604 | if ($inputVal == '' && $callbackReturn == true) { |
| 605 | 605 | $this->_setError($inputName, $ruleName, $this->_getLabel($inputName)); |
| 606 | 606 | } |
| 607 | 607 | } |
| 608 | - else if($inputVal == '') { |
|
| 608 | + else if ($inputVal == '') { |
|
| 609 | 609 | $this->_setError($inputName, $ruleName, $this->_getLabel($inputName)); |
| 610 | 610 | } |
| 611 | 611 | } |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | protected function _validateCallback($inputName, $ruleName, array $ruleArgs) { |
| 632 | 632 | if (function_exists($ruleArgs[1]) && !empty($this->data[$inputName])) { |
| 633 | 633 | $result = $this->_runCallback($this->data[$inputName], $ruleArgs[1]); |
| 634 | - if(! $result){ |
|
| 634 | + if (!$result) { |
|
| 635 | 635 | $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName))); |
| 636 | 636 | } |
| 637 | 637 | } |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | continue; |
| 666 | 666 | } |
| 667 | 667 | } |
| 668 | - else{ |
|
| 668 | + else { |
|
| 669 | 669 | if ($inputVal == $doNotEqual) { |
| 670 | 670 | $this->_setError($inputName, $ruleName . ',string', array($this->_getLabel($inputName), $doNotEqual)); |
| 671 | 671 | continue; |
@@ -695,8 +695,8 @@ discard block |
||
| 695 | 695 | */ |
| 696 | 696 | protected function _validateValidEmail($inputName, $ruleName, array $ruleArgs) { |
| 697 | 697 | $inputVal = $this->post($inputName); |
| 698 | - if (! preg_match("/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i", $inputVal)) { |
|
| 699 | - if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 698 | + if (!preg_match("/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i", $inputVal)) { |
|
| 699 | + if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 700 | 700 | return; |
| 701 | 701 | } |
| 702 | 702 | $this->_setError($inputName, $ruleName, $this->_getLabel($inputName)); |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | protected function _validateExactLength($inputName, $ruleName, array $ruleArgs) { |
| 713 | 713 | $inputVal = $this->post($inputName); |
| 714 | 714 | if (strlen($inputVal) != $ruleArgs[1]) { // $ruleArgs[0] is [length] $rulesArgs[1] is just length |
| 715 | - if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 715 | + if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 716 | 716 | return; |
| 717 | 717 | } |
| 718 | 718 | $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1]))); |
@@ -728,7 +728,7 @@ discard block |
||
| 728 | 728 | protected function _validateMaxLength($inputName, $ruleName, array $ruleArgs) { |
| 729 | 729 | $inputVal = $this->post($inputName); |
| 730 | 730 | if (strlen($inputVal) > $ruleArgs[1]) { // $ruleArgs[0] is [length] $rulesArgs[1] is just length |
| 731 | - if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 731 | + if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 732 | 732 | return; |
| 733 | 733 | } |
| 734 | 734 | $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1]))); |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | protected function _validateMinLength($inputName, $ruleName, array $ruleArgs) { |
| 745 | 745 | $inputVal = $this->post($inputName); |
| 746 | 746 | if (strlen($inputVal) < $ruleArgs[1]) { // $ruleArgs[0] is [length] $rulesArgs[1] is just length |
| 747 | - if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 747 | + if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 748 | 748 | return; |
| 749 | 749 | } |
| 750 | 750 | $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1]))); |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | protected function _validateLessThan($inputName, $ruleName, array $ruleArgs) { |
| 761 | 761 | $inputVal = $this->post($inputName); |
| 762 | 762 | if ($inputVal >= $ruleArgs[1]) { |
| 763 | - if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 763 | + if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 764 | 764 | return; |
| 765 | 765 | } |
| 766 | 766 | $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1]))); |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | protected function _validateGreaterThan($inputName, $ruleName, array $ruleArgs) { |
| 777 | 777 | $inputVal = $this->post($inputName); |
| 778 | 778 | if ($inputVal <= $ruleArgs[1]) { |
| 779 | - if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 779 | + if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 780 | 780 | return; |
| 781 | 781 | } |
| 782 | 782 | $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1]))); |
@@ -791,8 +791,8 @@ discard block |
||
| 791 | 791 | */ |
| 792 | 792 | protected function _validateNumeric($inputName, $ruleName, array $ruleArgs) { |
| 793 | 793 | $inputVal = $this->post($inputName); |
| 794 | - if (! is_numeric($inputVal)) { |
|
| 795 | - if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 794 | + if (!is_numeric($inputVal)) { |
|
| 795 | + if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 796 | 796 | return; |
| 797 | 797 | } |
| 798 | 798 | $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName))); |
@@ -808,7 +808,7 @@ discard block |
||
| 808 | 808 | protected function _validateExists($inputName, $ruleName, array $ruleArgs) { |
| 809 | 809 | $inputVal = $this->post($inputName); |
| 810 | 810 | $obj = & get_instance(); |
| 811 | - if(! isset($obj->database)){ |
|
| 811 | + if (!isset($obj->database)) { |
|
| 812 | 812 | return; |
| 813 | 813 | } |
| 814 | 814 | list($table, $column) = explode('.', $ruleArgs[1]); |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | ->get(); |
| 818 | 818 | $nb = $obj->database->numRows(); |
| 819 | 819 | if ($nb == 0) { |
| 820 | - if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 820 | + if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 821 | 821 | return; |
| 822 | 822 | } |
| 823 | 823 | $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName))); |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | protected function _validateIsUnique($inputName, $ruleName, array $ruleArgs) { |
| 834 | 834 | $inputVal = $this->post($inputName); |
| 835 | 835 | $obj = & get_instance(); |
| 836 | - if(! isset($obj->database)){ |
|
| 836 | + if (!isset($obj->database)) { |
|
| 837 | 837 | return; |
| 838 | 838 | } |
| 839 | 839 | list($table, $column) = explode('.', $ruleArgs[1]); |
@@ -842,7 +842,7 @@ discard block |
||
| 842 | 842 | ->get(); |
| 843 | 843 | $nb = $obj->database->numRows(); |
| 844 | 844 | if ($nb != 0) { |
| 845 | - if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 845 | + if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 846 | 846 | return; |
| 847 | 847 | } |
| 848 | 848 | $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName))); |
@@ -858,11 +858,11 @@ discard block |
||
| 858 | 858 | protected function _validateIsUniqueUpdate($inputName, $ruleName, array $ruleArgs) { |
| 859 | 859 | $inputVal = $this->post($inputName); |
| 860 | 860 | $obj = & get_instance(); |
| 861 | - if(! isset($obj->database)){ |
|
| 861 | + if (!isset($obj->database)) { |
|
| 862 | 862 | return; |
| 863 | 863 | } |
| 864 | 864 | $data = explode(',', $ruleArgs[1]); |
| 865 | - if(count($data) < 2){ |
|
| 865 | + if (count($data) < 2) { |
|
| 866 | 866 | return; |
| 867 | 867 | } |
| 868 | 868 | list($table, $column) = explode('.', $data[0]); |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | ->get(); |
| 874 | 874 | $nb = $obj->database->numRows(); |
| 875 | 875 | if ($nb != 0) { |
| 876 | - if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 876 | + if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 877 | 877 | return; |
| 878 | 878 | } |
| 879 | 879 | $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName))); |
@@ -890,8 +890,8 @@ discard block |
||
| 890 | 890 | $inputVal = $this->post($inputName); |
| 891 | 891 | $list = explode(',', $ruleArgs[1]); |
| 892 | 892 | $list = array_map('trim', $list); |
| 893 | - if (! in_array($inputVal, $list)) { |
|
| 894 | - if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 893 | + if (!in_array($inputVal, $list)) { |
|
| 894 | + if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 895 | 895 | return; |
| 896 | 896 | } |
| 897 | 897 | $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1]))); |
@@ -907,8 +907,8 @@ discard block |
||
| 907 | 907 | protected function _validateRegex($inputName, $ruleName, array $ruleArgs) { |
| 908 | 908 | $inputVal = $this->post($inputName); |
| 909 | 909 | $regex = $ruleArgs[1]; |
| 910 | - if (! preg_match($regex, $inputVal)) { |
|
| 911 | - if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 910 | + if (!preg_match($regex, $inputVal)) { |
|
| 911 | + if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) { |
|
| 912 | 912 | return; |
| 913 | 913 | } |
| 914 | 914 | $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName))); |