@@ -29,8 +29,8 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | - * DB session handler model class |
|
| 33 | - */ |
|
| 32 | + * DB session handler model class |
|
| 33 | + */ |
|
| 34 | 34 | abstract class DBSessionHandlerModel extends Model { |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | class DatabaseQueryRunner extends BaseClass { |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * The DatabaseConnection instance |
|
| 35 | - * @var object |
|
| 36 | - */ |
|
| 33 | + /** |
|
| 34 | + * The DatabaseConnection instance |
|
| 35 | + * @var object |
|
| 36 | + */ |
|
| 37 | 37 | private $connection = null; |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | //by default count() return 1 if the parameter is not an array |
| 187 | 187 | //object or object implements Countable. |
| 188 | 188 | if (is_array($result) || is_object($result) || $result instanceof Countable) { |
| 189 | - $numRows = count($result); |
|
| 189 | + $numRows = count($result); |
|
| 190 | 190 | } |
| 191 | 191 | } else { |
| 192 | 192 | $numRows = $this->pdoStatment->rowCount(); |
@@ -387,9 +387,9 @@ discard block |
||
| 387 | 387 | $this->queryCount++; |
| 388 | 388 | |
| 389 | 389 | $queryResult = $this->queryRunner->setQuery($query) |
| 390 | - ->setReturnType($returnAsList) |
|
| 391 | - ->setReturnAsArray($returnAsArray) |
|
| 392 | - ->execute(); |
|
| 390 | + ->setReturnType($returnAsList) |
|
| 391 | + ->setReturnAsArray($returnAsArray) |
|
| 392 | + ->execute(); |
|
| 393 | 393 | |
| 394 | 394 | if (is_object($queryResult)) { |
| 395 | 395 | $this->result = $queryResult->getResult(); |
@@ -405,11 +405,11 @@ discard block |
||
| 405 | 405 | return $this->result; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - /** |
|
| 409 | - * Set the connection instance using database configuration file |
|
| 410 | - * |
|
| 411 | - * @return object|void |
|
| 412 | - */ |
|
| 408 | + /** |
|
| 409 | + * Set the connection instance using database configuration file |
|
| 410 | + * |
|
| 411 | + * @return object|void |
|
| 412 | + */ |
|
| 413 | 413 | protected function setConnectionUsingConfigFile(){ |
| 414 | 414 | $dbConfigFromFile = $this->getDatabaseConfigFromFile(); |
| 415 | 415 | $connection = &class_loader('DatabaseConnection', 'classes/database'); |
@@ -422,7 +422,6 @@ discard block |
||
| 422 | 422 | |
| 423 | 423 | /** |
| 424 | 424 | * Get the database configuration using the configuration file |
| 425 | - |
|
| 426 | 425 | * @return array the database configuration from file |
| 427 | 426 | */ |
| 428 | 427 | protected function getDatabaseConfigFromFile() { |
@@ -410,7 +410,7 @@ |
||
| 410 | 410 | * |
| 411 | 411 | * @return object|void |
| 412 | 412 | */ |
| 413 | - protected function setConnectionUsingConfigFile(){ |
|
| 413 | + protected function setConnectionUsingConfigFile() { |
|
| 414 | 414 | $dbConfigFromFile = $this->getDatabaseConfigFromFile(); |
| 415 | 415 | $connection = &class_loader('DatabaseConnection', 'classes/database'); |
| 416 | 416 | $connection->setConfig($dbConfigFromFile); |
@@ -42,28 +42,28 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | private $driver = null; |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * The database hostname |
|
| 47 | - * @var string |
|
| 48 | - */ |
|
| 45 | + /** |
|
| 46 | + * The database hostname |
|
| 47 | + * @var string |
|
| 48 | + */ |
|
| 49 | 49 | private $hostname = null; |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * The database port |
|
| 53 | - * @var integer |
|
| 54 | - */ |
|
| 51 | + /** |
|
| 52 | + * The database port |
|
| 53 | + * @var integer |
|
| 54 | + */ |
|
| 55 | 55 | private $port = null; |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * The database username |
|
| 59 | - * @var string |
|
| 60 | - */ |
|
| 57 | + /** |
|
| 58 | + * The database username |
|
| 59 | + * @var string |
|
| 60 | + */ |
|
| 61 | 61 | private $username = null; |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * The database password |
|
| 65 | - * @var string |
|
| 66 | - */ |
|
| 63 | + /** |
|
| 64 | + * The database password |
|
| 65 | + * @var string |
|
| 66 | + */ |
|
| 67 | 67 | private $password = null; |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | private $databaseName = null; |
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * The database charset |
|
| 77 | - * @var string |
|
| 78 | - */ |
|
| 75 | + /** |
|
| 76 | + * The database charset |
|
| 77 | + * @var string |
|
| 78 | + */ |
|
| 79 | 79 | private $charset = null; |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -84,10 +84,10 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | private $collation = null; |
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * The database tables prefix |
|
| 89 | - * @var string |
|
| 90 | - */ |
|
| 87 | + /** |
|
| 88 | + * The database tables prefix |
|
| 89 | + * @var string |
|
| 90 | + */ |
|
| 91 | 91 | private $prefix = null; |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - /** |
|
| 118 | - * This is method is used to connect to database |
|
| 119 | - * |
|
| 120 | - * @return boolean true in case of successfully connection false if error |
|
| 121 | - */ |
|
| 117 | + /** |
|
| 118 | + * This is method is used to connect to database |
|
| 119 | + * |
|
| 120 | + * @return boolean true in case of successfully connection false if error |
|
| 121 | + */ |
|
| 122 | 122 | public function connect() { |
| 123 | 123 | try { |
| 124 | 124 | $this->pdo = new PDO($this->getDsnValue(), $this->getUsername(), $this->getPassword()); |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | $this->populatePropertiesFromConfig(); |
| 410 | 410 | |
| 411 | 411 | if (!empty($this->config)) { |
| 412 | - //For logging |
|
| 412 | + //For logging |
|
| 413 | 413 | $configInfo = $this->config; |
| 414 | 414 | //Hide password from log |
| 415 | 415 | $configInfo['password'] = string_hidden($this->getPassword()); |
@@ -418,11 +418,11 @@ discard block |
||
| 418 | 418 | return $this; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - /** |
|
| 422 | - * Update the properties using the current database configuration |
|
| 423 | - * |
|
| 424 | - * @return object the current instance |
|
| 425 | - */ |
|
| 421 | + /** |
|
| 422 | + * Update the properties using the current database configuration |
|
| 423 | + * |
|
| 424 | + * @return object the current instance |
|
| 425 | + */ |
|
| 426 | 426 | protected function populatePropertiesFromConfig() { |
| 427 | 427 | foreach ($this->config as $key => $value) { |
| 428 | 428 | $setter = 'set' . ucfirst($key); |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | class DatabaseQueryBuilder { |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * The DatabaseConnection instance |
|
| 35 | - * @var object |
|
| 36 | - */ |
|
| 33 | + /** |
|
| 34 | + * The DatabaseConnection instance |
|
| 35 | + * @var object |
|
| 36 | + */ |
|
| 37 | 37 | private $connection = null; |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -727,12 +727,12 @@ discard block |
||
| 727 | 727 | * |
| 728 | 728 | * @return string|null |
| 729 | 729 | */ |
| 730 | - protected function buildQueryPart($property, $command = ''){ |
|
| 730 | + protected function buildQueryPart($property, $command = ''){ |
|
| 731 | 731 | if (!empty($this->{$property})) { |
| 732 | 732 | return $command . $this->{$property}; |
| 733 | 733 | } |
| 734 | 734 | return null; |
| 735 | - } |
|
| 735 | + } |
|
| 736 | 736 | |
| 737 | 737 | |
| 738 | 738 | /** |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | $_keys = array(); |
| 415 | 415 | foreach ($keys as $k => $v) { |
| 416 | 416 | $v = $this->checkForNullValue($v); |
| 417 | - if (! is_numeric($v)) { |
|
| 417 | + if (!is_numeric($v)) { |
|
| 418 | 418 | $v = $this->connection->escape($v, $escape); |
| 419 | 419 | } |
| 420 | 420 | $_keys[] = $v; |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | * |
| 728 | 728 | * @return string|null |
| 729 | 729 | */ |
| 730 | - protected function buildQueryPart($property, $command = ''){ |
|
| 730 | + protected function buildQueryPart($property, $command = '') { |
|
| 731 | 731 | if (!empty($this->{$property})) { |
| 732 | 732 | return $command . $this->{$property}; |
| 733 | 733 | } |
@@ -742,7 +742,7 @@ discard block |
||
| 742 | 742 | * @param string $clause the clause type "IS NULL", "IS NOT NULLs" |
| 743 | 743 | * @return object the current DatabaseQueryBuilder instance |
| 744 | 744 | */ |
| 745 | - protected function whereIsNullAndNotNull($field, $andOr = 'AND', $clause = 'IS NULL'){ |
|
| 745 | + protected function whereIsNullAndNotNull($field, $andOr = 'AND', $clause = 'IS NULL') { |
|
| 746 | 746 | if (is_array($field)) { |
| 747 | 747 | foreach ($field as $f) { |
| 748 | 748 | $this->whereIsNullAndNotNull($f, $andOr, $clause); |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | * |
| 761 | 761 | * @return object the current instance |
| 762 | 762 | */ |
| 763 | - protected function setSelectStr($newSelect){ |
|
| 763 | + protected function setSelectStr($newSelect) { |
|
| 764 | 764 | $this->select = (($this->select == '*' || empty($this->select)) |
| 765 | 765 | ? $newSelect |
| 766 | 766 | : $this->select . ', ' . $newSelect); |
@@ -774,8 +774,8 @@ discard block |
||
| 774 | 774 | * @return string the empty string if the value is null |
| 775 | 775 | * otherwise the same value will be returned |
| 776 | 776 | */ |
| 777 | - protected function checkForNullValue($value){ |
|
| 778 | - if(is_null($value)){ |
|
| 777 | + protected function checkForNullValue($value) { |
|
| 778 | + if (is_null($value)) { |
|
| 779 | 779 | return ''; |
| 780 | 780 | } |
| 781 | 781 | return $value; |
@@ -208,7 +208,7 @@ |
||
| 208 | 208 | //If is the SELECT query |
| 209 | 209 | $this->isSelectQuery = stristr($this->query, 'SELECT') !== false; |
| 210 | 210 | |
| 211 | - //if can use cache feature for this query |
|
| 211 | + //if can use cache feature for this query |
|
| 212 | 212 | $this->dbCacheStatus = get_config('cache_enable', false) && $this->cacheTtl > 0; |
| 213 | 213 | } |
| 214 | 214 | |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | public function getCacheContent() { |
| 159 | 159 | //set some attributes values |
| 160 | 160 | $this->setPropertiesValues(); |
| 161 | - if(! $this->isSelectQuery || ! $this->dbCacheStatus){ |
|
| 161 | + if (!$this->isSelectQuery || !$this->dbCacheStatus) { |
|
| 162 | 162 | $this->logger->info('The cache is not enabled for this query or is not a SELECT query'); |
| 163 | 163 | return null; |
| 164 | 164 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | public function saveCacheContent($result) { |
| 186 | 186 | //set some attributes values |
| 187 | 187 | $this->setPropertiesValues(); |
| 188 | - if(! $this->isSelectQuery || ! $this->dbCacheStatus){ |
|
| 188 | + if (!$this->isSelectQuery || !$this->dbCacheStatus) { |
|
| 189 | 189 | //just return true |
| 190 | 190 | return true; |
| 191 | 191 | } |
@@ -133,11 +133,11 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - /** |
|
| 137 | - * Reset the form validation instance |
|
| 138 | - * |
|
| 139 | - * @return object the current instance |
|
| 140 | - */ |
|
| 136 | + /** |
|
| 137 | + * Reset the form validation instance |
|
| 138 | + * |
|
| 139 | + * @return object the current instance |
|
| 140 | + */ |
|
| 141 | 141 | public function reset() { |
| 142 | 142 | $this->rules = array(); |
| 143 | 143 | $this->labels = array(); |
@@ -160,11 +160,11 @@ discard block |
||
| 160 | 160 | return $this; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * Return the validation data |
|
| 165 | - * |
|
| 166 | - * @return array the validation data |
|
| 167 | - */ |
|
| 163 | + /** |
|
| 164 | + * Return the validation data |
|
| 165 | + * |
|
| 166 | + * @return array the validation data |
|
| 167 | + */ |
|
| 168 | 168 | public function getData() { |
| 169 | 169 | return $this->data; |
| 170 | 170 | } |
@@ -213,11 +213,11 @@ discard block |
||
| 213 | 213 | return $this->rules; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - /** |
|
| 217 | - * Return the list of the validations rules for the given field |
|
| 218 | - * |
|
| 219 | - * @return array |
|
| 220 | - */ |
|
| 216 | + /** |
|
| 217 | + * Return the list of the validations rules for the given field |
|
| 218 | + * |
|
| 219 | + * @return array |
|
| 220 | + */ |
|
| 221 | 221 | public function getFieldRules($field) { |
| 222 | 222 | $rules = array(); |
| 223 | 223 | if (array_key_exists($field, $this->rules)) { |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * @return string|null |
| 234 | 234 | */ |
| 235 | 235 | public function getFieldValue($field) { |
| 236 | - $value = null; |
|
| 236 | + $value = null; |
|
| 237 | 237 | if (array_key_exists($field, $this->data)) { |
| 238 | 238 | $value = $this->data[$field]; |
| 239 | 239 | } |
@@ -255,15 +255,15 @@ discard block |
||
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | |
| 258 | - /** |
|
| 259 | - * Return the list of validation errors |
|
| 260 | - * |
|
| 261 | - * @return array the errors list. |
|
| 262 | - * Format: |
|
| 263 | - * [field1] => 'error message 1', |
|
| 264 | - * [field2] => 'error message 2' |
|
| 265 | - */ |
|
| 266 | - public function getErrors() { |
|
| 258 | + /** |
|
| 259 | + * Return the list of validation errors |
|
| 260 | + * |
|
| 261 | + * @return array the errors list. |
|
| 262 | + * Format: |
|
| 263 | + * [field1] => 'error message 1', |
|
| 264 | + * [field2] => 'error message 2' |
|
| 265 | + */ |
|
| 266 | + public function getErrors() { |
|
| 267 | 267 | return $this->errors; |
| 268 | 268 | } |
| 269 | 269 | |
@@ -346,11 +346,11 @@ discard block |
||
| 346 | 346 | return $this; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - /** |
|
| 350 | - * Set the database instance using get_instance() if is null |
|
| 351 | - * |
|
| 352 | - * @return object the current instance |
|
| 353 | - */ |
|
| 349 | + /** |
|
| 350 | + * Set the database instance using get_instance() if is null |
|
| 351 | + * |
|
| 352 | + * @return object the current instance |
|
| 353 | + */ |
|
| 354 | 354 | protected function setDatabaseFromSuperInstanceIfNotSet(){ |
| 355 | 355 | if (!is_object($this->database)) { |
| 356 | 356 | $this->database = get_instance()->database; |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | * @param string|null $field2 the second field used in some validation rule like "matches", "not_equal" |
| 388 | 388 | * |
| 389 | 389 | */ |
| 390 | - protected function setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue = null, $field2 = null) { |
|
| 390 | + protected function setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue = null, $field2 = null) { |
|
| 391 | 391 | //if the field is not required and his value is not set don't set error |
| 392 | 392 | //but in case the field have value validate it |
| 393 | 393 | if (!$this->fieldIsRequired($field) && strlen($value) <= 0) { |
@@ -413,9 +413,9 @@ discard block |
||
| 413 | 413 | * @return string the name of the validation method |
| 414 | 414 | */ |
| 415 | 415 | protected function getRuleValidationMethod($rule) { |
| 416 | - $parts = explode('_', $rule); |
|
| 417 | - $parts = array_map('ucfirst', $parts); |
|
| 418 | - return 'checkRule' . implode('', $parts); |
|
| 416 | + $parts = explode('_', $rule); |
|
| 417 | + $parts = array_map('ucfirst', $parts); |
|
| 418 | + return 'checkRule' . implode('', $parts); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | /** |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | $template['field2}'] = $field2; |
| 470 | 470 | $template['{value2}'] = $this->getFieldValue($field2); |
| 471 | 471 | $template['{label2}'] = $this->getFieldLabel($field2); |
| 472 | - } |
|
| 472 | + } |
|
| 473 | 473 | $message = $this->messages[$rule]; |
| 474 | 474 | //Check for custom message |
| 475 | 475 | if (isset($this->customErrors[$field][$rule])) { |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | //Get the name of the method to validate this rule |
| 501 | 501 | $method = $this->getRuleValidationMethod($realRuleName); |
| 502 | 502 | if (method_exists($this, $method)) { |
| 503 | - call_user_func_array(array($this, $method), array($field, $realRuleName, $paramValue)); |
|
| 503 | + call_user_func_array(array($this, $method), array($field, $realRuleName, $paramValue)); |
|
| 504 | 504 | } |
| 505 | 505 | else{ |
| 506 | 506 | $this->forceError = true; |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | * @param string|null $paramValue the rule parameter |
| 595 | 595 | */ |
| 596 | 596 | protected function checkRuleMinLength($field, $rule, $paramValue) { |
| 597 | - $value = $this->getFieldValue($field); |
|
| 597 | + $value = $this->getFieldValue($field); |
|
| 598 | 598 | if (strlen($value) < $paramValue) { |
| 599 | 599 | $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
| 600 | 600 | } |
@@ -608,7 +608,7 @@ discard block |
||
| 608 | 608 | * @param string|null $paramValue the rule parameter |
| 609 | 609 | */ |
| 610 | 610 | protected function checkRuleMaxLength($field, $rule, $paramValue) { |
| 611 | - $value = $this->getFieldValue($field); |
|
| 611 | + $value = $this->getFieldValue($field); |
|
| 612 | 612 | if (strlen($value) > $paramValue) { |
| 613 | 613 | $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
| 614 | 614 | } |
@@ -622,7 +622,7 @@ discard block |
||
| 622 | 622 | * @param string|null $paramValue the rule parameter |
| 623 | 623 | */ |
| 624 | 624 | protected function checkRuleExactLength($field, $rule, $paramValue) { |
| 625 | - $value = $this->getFieldValue($field); |
|
| 625 | + $value = $this->getFieldValue($field); |
|
| 626 | 626 | if (strlen($value) != $paramValue) { |
| 627 | 627 | $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
| 628 | 628 | } |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | protected function checkRuleNumeric($field, $rule, $paramValue) { |
| 730 | 730 | $value = $this->getFieldValue($field); |
| 731 | 731 | if (!is_numeric($value)) { |
| 732 | - $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
|
| 732 | + $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
|
| 733 | 733 | } |
| 734 | 734 | } |
| 735 | 735 | |
@@ -743,7 +743,7 @@ discard block |
||
| 743 | 743 | protected function checkRuleInteger($field, $rule, $paramValue) { |
| 744 | 744 | $value = $this->getFieldValue($field); |
| 745 | 745 | if (filter_var($value, FILTER_VALIDATE_INT) === false) { |
| 746 | - $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
|
| 746 | + $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
|
| 747 | 747 | } |
| 748 | 748 | } |
| 749 | 749 | |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | protected function checkRuleIntegerNatural($field, $rule, $paramValue) { |
| 758 | 758 | $value = $this->getFieldValue($field); |
| 759 | 759 | if (filter_var($value, FILTER_VALIDATE_INT) === false || $value < 0) { |
| 760 | - $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
|
| 760 | + $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
|
| 761 | 761 | } |
| 762 | 762 | } |
| 763 | 763 | |
@@ -844,7 +844,7 @@ discard block |
||
| 844 | 844 | $format = $paramValue; |
| 845 | 845 | $dateValue = date_create_from_format($format, $value); |
| 846 | 846 | if ($dateValue === false || $dateValue->format($format) !== $value) { |
| 847 | - $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
|
| 847 | + $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
|
| 848 | 848 | } |
| 849 | 849 | } |
| 850 | 850 | |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | protected function checkRuleUrl($field, $rule, $paramValue) { |
| 889 | 889 | $value = $this->getFieldValue($field); |
| 890 | 890 | if (filter_var($value, FILTER_VALIDATE_URL) === false) { |
| 891 | - $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
|
| 891 | + $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
|
| 892 | 892 | } |
| 893 | 893 | } |
| 894 | 894 | |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | protected function checkRuleIp($field, $rule, $paramValue) { |
| 904 | 904 | $value = $this->getFieldValue($field); |
| 905 | 905 | if (filter_var($value, FILTER_VALIDATE_IP) === false) { |
| 906 | - $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
|
| 906 | + $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
|
| 907 | 907 | } |
| 908 | 908 | } |
| 909 | 909 | |
@@ -948,7 +948,7 @@ discard block |
||
| 948 | 948 | $value = $this->getFieldValue($field); |
| 949 | 949 | list($table, $column) = explode('.', $paramValue); |
| 950 | 950 | $this->database->getQueryBuilder()->from($table) |
| 951 | - ->where($column, $value); |
|
| 951 | + ->where($column, $value); |
|
| 952 | 952 | $this->database->get(); |
| 953 | 953 | if ($this->database->numRows() > 0) { |
| 954 | 954 | $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
@@ -970,8 +970,8 @@ discard block |
||
| 970 | 970 | list($table, $column) = explode('.', $data[0]); |
| 971 | 971 | list($columnKey, $valueKey) = explode('=', $data[1]); |
| 972 | 972 | $this->database->getQueryBuilder()->from($table) |
| 973 | - ->where($column, $value) |
|
| 974 | - ->where($columnKey, '!=', trim($valueKey)); |
|
| 973 | + ->where($column, $value) |
|
| 974 | + ->where($columnKey, '!=', trim($valueKey)); |
|
| 975 | 975 | $this->database->get(); |
| 976 | 976 | if ($this->database->numRows() > 0) { |
| 977 | 977 | $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
@@ -991,7 +991,7 @@ discard block |
||
| 991 | 991 | $value = $this->getFieldValue($field); |
| 992 | 992 | list($table, $column) = explode('.', $paramValue); |
| 993 | 993 | $this->database->getQueryBuilder()->from($table) |
| 994 | - ->where($column, $value); |
|
| 994 | + ->where($column, $value); |
|
| 995 | 995 | $this->database->get(); |
| 996 | 996 | if ($this->database->numRows() <= 0) { |
| 997 | 997 | $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | //if the rule is array |
| 184 | 184 | if (is_array($rule)) { |
| 185 | 185 | $rules = $rule; |
| 186 | - } else{ |
|
| 186 | + } else { |
|
| 187 | 187 | //the rule is not an array explode pipe values |
| 188 | 188 | $rules = explode('|', $rule); |
| 189 | 189 | } |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | $this->checkCsrf(); |
| 286 | 286 | |
| 287 | 287 | //Now loop in each field rule and validate it |
| 288 | - foreach($this->rules as $field => $rules) { |
|
| 288 | + foreach ($this->rules as $field => $rules) { |
|
| 289 | 289 | $this->validateField($field, $rules); |
| 290 | 290 | } |
| 291 | 291 | $this->valid = empty($this->errors) && $this->forceError === false; |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | if ($field !== null) { |
| 321 | 321 | $this->customErrors[$field][$rule] = $message; |
| 322 | 322 | } else { |
| 323 | - foreach(array_keys($this->rules) as $field) { |
|
| 323 | + foreach (array_keys($this->rules) as $field) { |
|
| 324 | 324 | $this->customErrors[$field][$rule] = $message; |
| 325 | 325 | } |
| 326 | 326 | } |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | * |
| 352 | 352 | * @return object the current instance |
| 353 | 353 | */ |
| 354 | - protected function setDatabaseFromSuperInstanceIfNotSet(){ |
|
| 354 | + protected function setDatabaseFromSuperInstanceIfNotSet() { |
|
| 355 | 355 | if (!is_object($this->database)) { |
| 356 | 356 | $this->database = get_instance()->database; |
| 357 | 357 | } |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | * @return object the current instance |
| 425 | 425 | */ |
| 426 | 426 | protected function filterValidationData() { |
| 427 | - foreach($this->data as $key => $value ) { |
|
| 427 | + foreach ($this->data as $key => $value) { |
|
| 428 | 428 | $this->data[$key] = trim($value); |
| 429 | 429 | } |
| 430 | 430 | return $this; |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | * @param array $rules the list of rule to validate |
| 485 | 485 | */ |
| 486 | 486 | protected function validateField($field, array $rules) { |
| 487 | - foreach($rules as $rule) { |
|
| 487 | + foreach ($rules as $rule) { |
|
| 488 | 488 | $match = array(); |
| 489 | 489 | $paramValue = null; |
| 490 | 490 | //Is the rule with parameter ?? |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | if (method_exists($this, $method)) { |
| 503 | 503 | call_user_func_array(array($this, $method), array($field, $realRuleName, $paramValue)); |
| 504 | 504 | } |
| 505 | - else{ |
|
| 505 | + else { |
|
| 506 | 506 | $this->forceError = true; |
| 507 | 507 | show_error('Invalid validaton rule "' . $realRuleName . '"'); |
| 508 | 508 | } |
@@ -1034,7 +1034,7 @@ discard block |
||
| 1034 | 1034 | if (call_user_func_array($paramValue, array($value)) === false) { |
| 1035 | 1035 | $this->setFieldErrorWithRequiredCheck($field, $value, $rule, $paramValue); |
| 1036 | 1036 | } |
| 1037 | - } else{ |
|
| 1037 | + } else { |
|
| 1038 | 1038 | $this->forceError = true; |
| 1039 | 1039 | show_error('The callback validation function/method "' . $paramValue . '" does not exist'); |
| 1040 | 1040 | } |
@@ -501,8 +501,7 @@ |
||
| 501 | 501 | $method = $this->getRuleValidationMethod($realRuleName); |
| 502 | 502 | if (method_exists($this, $method)) { |
| 503 | 503 | call_user_func_array(array($this, $method), array($field, $realRuleName, $paramValue)); |
| 504 | - } |
|
| 505 | - else{ |
|
| 504 | + } else{ |
|
| 506 | 505 | $this->forceError = true; |
| 507 | 506 | show_error('Invalid validaton rule "' . $realRuleName . '"'); |
| 508 | 507 | } |