Passed
Push — 1.0.0-dev ( 83bedf...ceb5d8 )
by nguereza
02:34
created
core/libraries/FormValidation.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
          * @return void
98 98
          */
99 99
         public function __construct() {
100
-            $this->logger =& class_loader('Log', 'classes');
100
+            $this->logger = & class_loader('Log', 'classes');
101 101
             $this->logger->setLogger('Library::FormValidation');
102 102
            
103 103
 		   //Load form validation language message
104 104
             Loader::lang('form_validation');
105 105
             $obj = & get_instance();
106
-            $this->_errorsMessages  = array(
106
+            $this->_errorsMessages = array(
107 107
                         'required'         => $obj->lang->get('fv_required'),
108 108
                         'min_length'       => $obj->lang->get('fv_min_length'),
109 109
                         'max_length'       => $obj->lang->get('fv_max_length'),
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
          * Set the database instance
134 134
          * @param object $database the database instance
135 135
          */
136
-        public function setDatabase(Database $database){
136
+        public function setDatabase(Database $database) {
137 137
             $this->databaseInstance = $database;
138 138
             return $this;
139 139
         }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
          * Get the database instance
143 143
          * @return object the database instance
144 144
          */
145
-        public function getDatabase(){
145
+        public function getDatabase() {
146 146
             return $this->databaseInstance;
147 147
         }
148 148
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 		 *
166 166
          * @return FormValidation Current instance of object.
167 167
          */
168
-        public function setData(array $data){
168
+        public function setData(array $data) {
169 169
             $this->logger->debug('Setting the form validation data, the values are: ' . stringfy_vars($data));
170 170
             $this->data = $data;
171 171
 			return $this;
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
          * Get the form validation data
176 176
          * @return array the form validation data to be validated
177 177
          */
178
-        public function getData(){
178
+        public function getData() {
179 179
             return $this->data;
180 180
         }
181 181
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		*
185 185
 		* @return string the function name
186 186
 		*/
187
-        protected function _toCallCase($funcName, $prefix='_validate') {
187
+        protected function _toCallCase($funcName, $prefix = '_validate') {
188 188
             $funcName = strtolower($funcName);
189 189
             $finalFuncName = $prefix;
190 190
             foreach (explode('_', $funcName) as $funcNamePart) {
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
          * @return boolean Whether or not the form has been submitted or the data is available for validation.
209 209
          */
210 210
         public function canDoValidation() {
211
-            return get_instance()->request->method() === 'POST' || ! empty($this->data);
211
+            return get_instance()->request->method() === 'POST' || !empty($this->data);
212 212
         }
213 213
 
214 214
         /**
@@ -228,14 +228,14 @@  discard block
 block discarded – undo
228 228
          * Validate the CSRF 
229 229
          * @return void 
230 230
          */
231
-        protected function validateCSRF(){
232
-            if(get_instance()->request->method() == 'POST'){
231
+        protected function validateCSRF() {
232
+            if (get_instance()->request->method() == 'POST') {
233 233
                 $this->logger->debug('Check if CSRF is enabled in configuration');
234 234
                 //first check for CSRF
235
-                if (get_config('csrf_enable', false) && ! Security::validateCSRF()){
235
+                if (get_config('csrf_enable', false) && !Security::validateCSRF()) {
236 236
                     show_error('Invalide data, Cross Site Request Forgery do his job, the data to validate is corrupted.');
237 237
                 }
238
-                else{
238
+                else {
239 239
                     $this->logger->info('CSRF is not enabled in configuration or not set manully, no need to check it');
240 240
                 }
241 241
             }
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
             $this->_forceFail = false;
254 254
 
255 255
             foreach ($this->getData() as $inputName => $inputVal) {
256
-    			if(is_array($this->data[$inputName])){
256
+    			if (is_array($this->data[$inputName])) {
257 257
     				$this->data[$inputName] = array_map('trim', $this->data[$inputName]);
258 258
     			}
259
-    			else{
259
+    			else {
260 260
     				$this->data[$inputName] = trim($this->data[$inputName]);
261 261
     			}
262 262
 
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
                     }
267 267
                 }
268 268
             }
269
-            $this->_success =  empty($this->_errors) && $this->_forceFail === false;
269
+            $this->_success = empty($this->_errors) && $this->_forceFail === false;
270 270
         }
271 271
 
272 272
         /**
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         public function setRule($inputField, $inputLabel, $ruleSets) {
281 281
             $this->_rules[$inputField] = $ruleSets;
282 282
             $this->_labels[$inputField] = $inputLabel;
283
-            $this->logger->info('Set the field rule: name [' .$inputField. '], label [' .$inputLabel. '], rules [' .$ruleSets. ']');
283
+            $this->logger->info('Set the field rule: name [' . $inputField . '], label [' . $inputLabel . '], rules [' . $ruleSets . ']');
284 284
             return $this;
285 285
         }
286 286
 
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
             }
445 445
             $errorOutput .= $errorsEnd;
446 446
             echo ($echo) ? $errorOutput : '';
447
-            return (! $echo) ? $errorOutput : null;
447
+            return (!$echo) ? $errorOutput : null;
448 448
         }
449 449
 
450 450
         /**
@@ -469,25 +469,25 @@  discard block
 block discarded – undo
469 469
             /*
470 470
             //////////////// hack for regex rule that can contain "|"
471 471
             */
472
-            if(strpos($ruleString, 'regex') !== false){
472
+            if (strpos($ruleString, 'regex') !== false) {
473 473
                 $regexRule = array();
474 474
                 $rule = '#regex\[\/(.*)\/([a-zA-Z0-9]?)\]#';
475 475
                 preg_match($rule, $ruleString, $regexRule);
476 476
                 $ruleStringTemp = preg_replace($rule, '', $ruleString);
477
-                 if(!empty($regexRule[0])){
477
+                 if (!empty($regexRule[0])) {
478 478
                      $ruleSets[] = $regexRule[0];
479 479
                  }
480 480
                  $ruleStringRegex = explode('|', $ruleStringTemp);
481 481
                 foreach ($ruleStringRegex as $rule) {
482 482
                     $rule = trim($rule);
483
-                    if($rule){
483
+                    if ($rule) {
484 484
                         $ruleSets[] = $rule;
485 485
                     }
486 486
                 }
487 487
                  
488 488
             }
489 489
             /***********************************/
490
-            else{
490
+            else {
491 491
                 if (strpos($ruleString, '|') !== FALSE) {
492 492
                     $ruleSets = explode('|', $ruleString);
493 493
                 } else {
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
          * @return void
520 520
          */
521 521
         protected function _validateRule($inputName, $inputVal, $ruleName) {
522
-            $this->logger->debug('Rule validation of field [' .$inputName. '], value [' .$inputVal. '], rule [' .$ruleName. ']');
522
+            $this->logger->debug('Rule validation of field [' . $inputName . '], value [' . $inputVal . '], rule [' . $ruleName . ']');
523 523
             // Array to store args
524 524
             $ruleArgs = array();
525 525
 
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
                 $key = $i - 1;
565 565
                 $rulePhrase = str_replace('%' . $i, $replacements[$key], $rulePhrase);
566 566
             }
567
-            if (! array_key_exists($inputName, $this->_errors)) {
567
+            if (!array_key_exists($inputName, $this->_errors)) {
568 568
                 $this->_errors[$inputName] = $rulePhrase;
569 569
             }
570 570
         }
@@ -616,13 +616,13 @@  discard block
 block discarded – undo
616 616
          */
617 617
 		protected function _validateRequired($inputName, $ruleName, array $ruleArgs) {
618 618
             $inputVal = $this->post($inputName);
619
-            if(array_key_exists(1, $ruleArgs) && function_exists($ruleArgs[1])) {
619
+            if (array_key_exists(1, $ruleArgs) && function_exists($ruleArgs[1])) {
620 620
                 $callbackReturn = $this->_runEmptyCallback($ruleArgs[1]);
621 621
                 if ($inputVal == '' && $callbackReturn == true) {
622 622
                     $this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
623 623
                 }
624 624
             } 
625
-			else if($inputVal == '') {
625
+			else if ($inputVal == '') {
626 626
 				$this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
627 627
             }
628 628
         }
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
         protected function _validateCallback($inputName, $ruleName, array $ruleArgs) {
649 649
             if (function_exists($ruleArgs[1]) && !empty($this->data[$inputName])) {
650 650
 				$result = $this->_runCallback($this->data[$inputName], $ruleArgs[1]);
651
-				if(! $result){
651
+				if (!$result) {
652 652
 					$this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
653 653
 				}
654 654
             }
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
                         continue;
683 683
                     }
684 684
                 } 
685
-				else{
685
+				else {
686 686
                     if ($inputVal == $doNotEqual) {
687 687
                         $this->_setError($inputName, $ruleName . ',string', array($this->_getLabel($inputName), $doNotEqual));
688 688
                         continue;
@@ -712,8 +712,8 @@  discard block
 block discarded – undo
712 712
          */
713 713
         protected function _validateValidEmail($inputName, $ruleName, array $ruleArgs) {
714 714
             $inputVal = $this->post($inputName);
715
-            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)) {
716
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
715
+            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)) {
716
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
717 717
                     return;
718 718
                 }
719 719
                 $this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
         protected function _validateExactLength($inputName, $ruleName, array $ruleArgs) {
730 730
             $inputVal = $this->post($inputName);
731 731
             if (strlen($inputVal) != $ruleArgs[1]) { // $ruleArgs[0] is [length] $rulesArgs[1] is just length
732
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
732
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
733 733
                     return;
734 734
                 }
735 735
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
         protected function _validateMaxLength($inputName, $ruleName, array $ruleArgs) {
746 746
             $inputVal = $this->post($inputName);
747 747
             if (strlen($inputVal) > $ruleArgs[1]) { // $ruleArgs[0] is [length] $rulesArgs[1] is just length
748
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
748
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
749 749
                     return;
750 750
                 }
751 751
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
         protected function _validateMinLength($inputName, $ruleName, array $ruleArgs) {
762 762
             $inputVal = $this->post($inputName);
763 763
             if (strlen($inputVal) < $ruleArgs[1]) { // $ruleArgs[0] is [length] $rulesArgs[1] is just length
764
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
764
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
765 765
                     return;
766 766
                 }
767 767
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
     	protected function _validateLessThan($inputName, $ruleName, array $ruleArgs) {
778 778
             $inputVal = $this->post($inputName);
779 779
             if ($inputVal >= $ruleArgs[1]) { 
780
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
780
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
781 781
                     return;
782 782
                 }
783 783
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
     	protected function _validateGreaterThan($inputName, $ruleName, array $ruleArgs) {
794 794
             $inputVal = $this->post($inputName);
795 795
             if ($inputVal <= $ruleArgs[1]) {
796
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
796
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
797 797
                     return;
798 798
                 }
799 799
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
@@ -808,8 +808,8 @@  discard block
 block discarded – undo
808 808
          */
809 809
     	protected function _validateNumeric($inputName, $ruleName, array $ruleArgs) {
810 810
             $inputVal = $this->post($inputName);
811
-            if (! is_numeric($inputVal)) {
812
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
811
+            if (!is_numeric($inputVal)) {
812
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
813 813
                     return;
814 814
                 }
815 815
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
@@ -824,9 +824,9 @@  discard block
 block discarded – undo
824 824
          */
825 825
 		protected function _validateExists($inputName, $ruleName, array $ruleArgs) {
826 826
             $inputVal = $this->post($inputName);
827
-    		if (! is_object($this->databaseInstance)){
827
+    		if (!is_object($this->databaseInstance)) {
828 828
                 $obj = & get_instance();
829
-                if(isset($obj->database)){
829
+                if (isset($obj->database)) {
830 830
                     $this->databaseInstance = $obj->database;
831 831
                 } 
832 832
             }
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
     			                                       ->where($column, $inputVal);
836 836
     		$this->databaseInstance->get();
837 837
             if ($this->databaseInstance->numRows() <= 0) {
838
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
838
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
839 839
                     return;
840 840
                 }
841 841
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
@@ -850,9 +850,9 @@  discard block
 block discarded – undo
850 850
          */
851 851
     	protected function _validateIsUnique($inputName, $ruleName, array $ruleArgs) {
852 852
             $inputVal = $this->post($inputName);
853
-            if (! is_object($this->databaseInstance)){
853
+            if (!is_object($this->databaseInstance)) {
854 854
                 $obj = & get_instance();
855
-                if(isset($obj->database)){
855
+                if (isset($obj->database)) {
856 856
                     $this->databaseInstance = $obj->database;
857 857
                 } 
858 858
             }
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
     			                                      ->where($column, $inputVal);
862 862
     		$this->databaseInstance->get();
863 863
     		if ($this->databaseInstance->numRows() > 0) {
864
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
864
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
865 865
                     return;
866 866
                 }
867 867
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
@@ -876,14 +876,14 @@  discard block
 block discarded – undo
876 876
          */
877 877
     	protected function _validateIsUniqueUpdate($inputName, $ruleName, array $ruleArgs) {
878 878
             $inputVal = $this->post($inputName);
879
-    		if (! is_object($this->databaseInstance)){
879
+    		if (!is_object($this->databaseInstance)) {
880 880
                 $obj = & get_instance();
881
-                if(isset($obj->database)){
881
+                if (isset($obj->database)) {
882 882
                     $this->databaseInstance = $obj->database;
883 883
                 } 
884 884
             }
885 885
     		$data = explode(',', $ruleArgs[1]);
886
-    		if(count($data) < 2){
886
+    		if (count($data) < 2) {
887 887
     			return;
888 888
     		}
889 889
     		list($table, $column) = explode('.', $data[0]);
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
                                             		  ->where($field, '!=', trim($val));
894 894
             $this->databaseInstance->get();
895 895
     		if ($this->databaseInstance->numRows() > 0) {
896
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
896
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
897 897
                     return;
898 898
                 }
899 899
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
@@ -910,8 +910,8 @@  discard block
 block discarded – undo
910 910
             $inputVal = $this->post($inputName);
911 911
     		$list = explode(',', $ruleArgs[1]);
912 912
             $list = array_map('trim', $list);
913
-            if (! in_array($inputVal, $list)) {
914
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
913
+            if (!in_array($inputVal, $list)) {
914
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
915 915
                     return;
916 916
                 }
917 917
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
@@ -927,8 +927,8 @@  discard block
 block discarded – undo
927 927
         protected function _validateRegex($inputName, $ruleName, array $ruleArgs) {
928 928
             $inputVal = $this->post($inputName);
929 929
     		$regex = $ruleArgs[1];
930
-            if (! preg_match($regex, $inputVal)) {
931
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
930
+            if (!preg_match($regex, $inputVal)) {
931
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
932 932
                     return;
933 933
                 }
934 934
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
Please login to merge, or discard this patch.
core/libraries/Pagination.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 
27
-    class Pagination{
27
+    class Pagination {
28 28
         
29 29
 		/**
30 30
          * The list of loaded config
@@ -42,15 +42,15 @@  discard block
 block discarded – undo
42 42
          * Create an instance of pagination
43 43
          * @param array $overwriteConfig the list of configuration to overwrite the defined configuration in config_pagination.php
44 44
          */
45
-        public function __construct($overwriteConfig = array()){
46
-            if (file_exists(CONFIG_PATH . 'config_pagination.php')){
45
+        public function __construct($overwriteConfig = array()) {
46
+            if (file_exists(CONFIG_PATH . 'config_pagination.php')) {
47 47
                 $config = array();
48 48
                 require_once CONFIG_PATH . 'config_pagination.php';
49
-                if (empty($config) || ! is_array($config)){
49
+                if (empty($config) || !is_array($config)) {
50 50
                     show_error('No configuration found in ' . CONFIG_PATH . 'config_pagination.php');
51 51
                 }
52
-				else{
53
-					if (! empty($overwriteConfig)){
52
+				else {
53
+					if (!empty($overwriteConfig)) {
54 54
 						$config = array_merge($config, $overwriteConfig);
55 55
 					}
56 56
 					$this->config = $config;
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 					unset($config);
60 60
 				}
61 61
             }
62
-            else{
62
+            else {
63 63
                 show_error('Unable to find the pagination configuration file');
64 64
             }
65 65
         }
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
          * config_pagination.php
71 71
          * @param array $config the configuration to overwrite
72 72
          */
73
-        public function setConfig(array $config = array()){
74
-            if (! empty($config)){
73
+        public function setConfig(array $config = array()) {
74
+            if (!empty($config)) {
75 75
                 $this->config = array_merge($this->config, $config);
76 76
                 Config::setAll($config);
77 77
             }
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
          * 
83 83
          * @return array
84 84
          */
85
-        public function getConfig(){
85
+        public function getConfig() {
86 86
             return $this->config;
87 87
         }
88 88
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
          * Return the value of the pagination query string
91 91
          * @return string
92 92
          */
93
-        public function getPaginationQueryString(){
93
+        public function getPaginationQueryString() {
94 94
             return $this->paginationQueryString;
95 95
         }
96 96
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
          * @param string $paginationQueryString the new value
100 100
          * @return object
101 101
          */
102
-        public function setPaginationQueryString($paginationQueryString){
102
+        public function setPaginationQueryString($paginationQueryString) {
103 103
             $this->paginationQueryString = $paginationQueryString;
104 104
             return $this;
105 105
         }
@@ -112,25 +112,25 @@  discard block
 block discarded – undo
112 112
          * 
113 113
          * @return object
114 114
          */
115
-        public function determinePaginationQueryStringValue(){
115
+        public function determinePaginationQueryStringValue() {
116 116
             $pageQueryName = $this->config['page_query_string_name'];
117 117
             $queryString = Url::queryString();
118 118
             $currentUrl = Url::current();
119 119
             $query = '';
120
-             if ($queryString == ''){
120
+             if ($queryString == '') {
121 121
                 $query = '?' . $pageQueryName . '=';
122 122
             }
123
-            else{
123
+            else {
124 124
                 $tab = explode($pageQueryName . '=', $queryString);
125 125
                 $nb = count($tab);
126
-                if ($nb == 1){
126
+                if ($nb == 1) {
127 127
                     $query = '?' . $queryString . '&' . $pageQueryName . '=';
128 128
                 }
129
-                else{
130
-                    if ($tab[0] == ''){
129
+                else {
130
+                    if ($tab[0] == '') {
131 131
                         $query = '?' . $pageQueryName . '=';
132 132
                     }
133
-                    else{
133
+                    else {
134 134
                         $query = '?' . $tab[0] . '' . $pageQueryName . '=';
135 135
                     }
136 136
                 }
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
          * 
149 149
          * @return string the pagination link
150 150
          */
151
-        public function getLink($totalRows, $currentPageNumber){
151
+        public function getLink($totalRows, $currentPageNumber) {
152 152
             $numberOfLink = $this->config['nb_link'];
153 153
 			$numberOfRowPerPage = $this->config['pagination_per_page'];
154
-            if (empty($this->paginationQueryString)){
154
+            if (empty($this->paginationQueryString)) {
155 155
                 //determine the pagination query string value
156 156
                 $this->determinePaginationQueryStringValue();
157 157
             }
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
             $numberOfLink = (int) $numberOfLink;
164 164
             $numberOfRowPerPage = (int) $numberOfRowPerPage;
165 165
 			
166
-            if ($currentPageNumber <= 0){
166
+            if ($currentPageNumber <= 0) {
167 167
 				$currentPageNumber = 1;
168 168
 			}
169 169
             if ($numberOfPage <= 1 || $numberOfLink <= 0 || $numberOfRowPerPage <= 0) {
@@ -172,40 +172,40 @@  discard block
 block discarded – undo
172 172
             $start = null;
173 173
             $end = null;
174 174
             $begin = null;
175
-            if ($numberOfLink % 2 == 0){
175
+            if ($numberOfLink % 2 == 0) {
176 176
                 $start = $currentPageNumber - ($numberOfLink / 2) + 1;
177 177
                 $end = $currentPageNumber + ($numberOfLink / 2);
178 178
             }
179
-            else{
179
+            else {
180 180
                 $start = $currentPageNumber - floor($numberOfLink / 2);
181 181
                 $end = $currentPageNumber + floor($numberOfLink / 2);
182 182
             }
183
-            if ($start <= 1){
183
+            if ($start <= 1) {
184 184
                 $begin = 1;
185 185
                 $end = $numberOfLink;
186 186
             }
187
-            else if ($start > 1 && $end < $numberOfPage){
187
+            else if ($start > 1 && $end < $numberOfPage) {
188 188
                 $begin = $start;
189 189
                 $end = $end;
190 190
             }
191
-            else{
191
+            else {
192 192
                 $begin = ($numberOfPage - $numberOfLink) + 1;
193 193
                 $end = $numberOfPage;
194 194
             }
195
-            if ($numberOfPage <= $numberOfLink){
195
+            if ($numberOfPage <= $numberOfLink) {
196 196
                 $begin = 1;
197 197
                 $end = $numberOfPage;
198 198
             }
199 199
 
200 200
             //**
201
-            if ($currentPageNumber == 1){
201
+            if ($currentPageNumber == 1) {
202 202
                 $navbar .= $this->buildPaginationLinkForFirstPage($begin, $end, $currentPageNumber);
203 203
             }
204 204
             ///////////
205
-            else if ($currentPageNumber > 1 && $currentPageNumber < $numberOfPage){
205
+            else if ($currentPageNumber > 1 && $currentPageNumber < $numberOfPage) {
206 206
                 $navbar .= $this->buildPaginationLinkForMiddlePage($begin, $end, $currentPageNumber);
207 207
             }
208
-            else if ($currentPageNumber == $numberOfPage){
208
+            else if ($currentPageNumber == $numberOfPage) {
209 209
                $navbar .= $this->buildPaginationLinkForLastPage($begin, $end, $currentPageNumber);
210 210
             }
211 211
             $navbar = $this->config['pagination_open'] . $navbar . $this->config['pagination_close'];
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
          * @param  int $currentPageNumber the pagination current page number
220 220
          * @return string                    
221 221
          */
222
-        protected function buildPaginationLinkForFirstPage($begin, $end, $currentPageNumber){
222
+        protected function buildPaginationLinkForFirstPage($begin, $end, $currentPageNumber) {
223 223
             $navbar = null;
224 224
             $query = $this->paginationQueryString;
225
-            for($i = $begin; $i <= $end; $i++){
226
-                if ($i == $currentPageNumber){
225
+            for ($i = $begin; $i <= $end; $i++) {
226
+                if ($i == $currentPageNumber) {
227 227
                     $navbar .= $this->config['active_link_open'] . $currentPageNumber . $this->config['active_link_close'];
228 228
                 }
229
-                else{
229
+                else {
230 230
                     $navbar .= $this->config['digit_open'] . '<a href="' . $query . $i . '" ' . attributes_to_string($this->config['attributes']) . '>' . $i . '</a>' . $this->config['digit_close'];
231 231
                 }
232 232
             }
@@ -241,19 +241,19 @@  discard block
 block discarded – undo
241 241
          * @param  int $currentPageNumber the pagination current page number
242 242
          * @return string                    
243 243
          */
244
-        protected function buildPaginationLinkForMiddlePage($begin, $end, $currentPageNumber){
244
+        protected function buildPaginationLinkForMiddlePage($begin, $end, $currentPageNumber) {
245 245
             $navbar = null;
246 246
             $query = $this->paginationQueryString;
247 247
             $navbar .= $this->config['previous_open'] . '<a href="' . $query . ($currentPageNumber - 1) . '">' . $this->config['previous_text'] . '</a>' . $this->config['previous_close'];
248
-            for($i = $begin; $i <= $end; $i++){
249
-                if ($i == $currentPageNumber){
248
+            for ($i = $begin; $i <= $end; $i++) {
249
+                if ($i == $currentPageNumber) {
250 250
                     $navbar .= $this->config['active_link_open'] . $currentPageNumber . $this->config['active_link_close'];
251 251
                 }
252
-                else{
253
-                    $navbar .= $this->config['digit_open'] . '<a href="' . $query . $i . '"' . attributes_to_string($this->config['attributes']) . '>' . $i .'</a>' . $this->config['digit_close'];
252
+                else {
253
+                    $navbar .= $this->config['digit_open'] . '<a href="' . $query . $i . '"' . attributes_to_string($this->config['attributes']) . '>' . $i . '</a>' . $this->config['digit_close'];
254 254
                 }
255 255
             }
256
-            $navbar .= $this->config['next_open']."<a href='$query".($currentPageNumber + 1)."'>".$this->config['next_text']."</a>".$this->config['next_close'];
256
+            $navbar .= $this->config['next_open'] . "<a href='$query" . ($currentPageNumber + 1) . "'>" . $this->config['next_text'] . "</a>" . $this->config['next_close'];
257 257
             return $navbar;
258 258
         }
259 259
 
@@ -264,15 +264,15 @@  discard block
 block discarded – undo
264 264
          * @param  int $currentPageNumber the pagination current page number
265 265
          * @return string                    
266 266
          */
267
-        protected function buildPaginationLinkForLastPage($begin, $end, $currentPageNumber){
267
+        protected function buildPaginationLinkForLastPage($begin, $end, $currentPageNumber) {
268 268
             $navbar = null;
269 269
             $query = $this->paginationQueryString;
270 270
             $navbar .= $this->config['previous_open'] . '<a href="' . $query . ($currentPageNumber - 1) . '">' . $this->config['previous_text'] . '</a>' . $this->config['previous_close'];
271
-            for($i = $begin; $i <= $end; $i++){
272
-                if ($i == $currentPageNumber){
271
+            for ($i = $begin; $i <= $end; $i++) {
272
+                if ($i == $currentPageNumber) {
273 273
                     $navbar .= $this->config['active_link_open'] . $currentPageNumber . $this->config['active_link_close'];
274 274
                 }
275
-                else{
275
+                else {
276 276
                     $navbar .= $this->config['digit_open'] . '<a href="' . $query . $i . '"' . attributes_to_string($this->config['attributes']) . '>' . $i . '</a>' . $this->config['digit_close'];
277 277
                 }
278 278
             }
Please login to merge, or discard this patch.
core/libraries/Browser.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -916,27 +916,27 @@  discard block
 block discarded – undo
916 916
                 if (isset($aresult[1])) {
917 917
                     $this->setBrowser(self::BROWSER_IE);
918 918
                     $this->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1]));
919
-                    if(preg_match('#trident/([0-9\.]+);#i', $this->_agent, $aresult)){
920
-                        if($aresult[1] == '3.1'){
919
+                    if (preg_match('#trident/([0-9\.]+);#i', $this->_agent, $aresult)) {
920
+                        if ($aresult[1] == '3.1') {
921 921
                             $this->setVersion('7.0');
922 922
                         }
923
-                        else if($aresult[1] == '4.0'){
923
+                        else if ($aresult[1] == '4.0') {
924 924
                             $this->setVersion('8.0');
925 925
                         }
926
-                        else if($aresult[1] == '5.0'){
926
+                        else if ($aresult[1] == '5.0') {
927 927
                             $this->setVersion('9.0');
928 928
                         }
929
-                        else if($aresult[1] == '6.0'){
929
+                        else if ($aresult[1] == '6.0') {
930 930
                             $this->setVersion('10.0');
931 931
                         }
932
-                        else if($aresult[1] == '7.0'){
932
+                        else if ($aresult[1] == '7.0') {
933 933
                             $this->setVersion('11.0');
934 934
                         }
935
-                        else if($aresult[1] == '8.0'){
935
+                        else if ($aresult[1] == '8.0') {
936 936
                             $this->setVersion('11.0');
937 937
                         }
938 938
                     }
939
-                    if(stripos($this->_agent, 'IEMobile') !== false) {
939
+                    if (stripos($this->_agent, 'IEMobile') !== false) {
940 940
                         $this->setBrowser(self::BROWSER_POCKET_IE);
941 941
                         $this->setMobile(true);
942 942
                     }
@@ -1676,7 +1676,7 @@  discard block
 block discarded – undo
1676 1676
               'mac' => self::PLATFORM_APPLE,
1677 1677
               'android' => self::PLATFORM_ANDROID,
1678 1678
               'Silk' => self::PLATFORM_FIRE_OS,
1679
-              'linux_smarttv' => self::PLATFORM_LINUX .'/'.self::PLATFORM_SMART_TV,
1679
+              'linux_smarttv' => self::PLATFORM_LINUX . '/' . self::PLATFORM_SMART_TV,
1680 1680
               'linux' => self::PLATFORM_LINUX,
1681 1681
               'Nokia' => self::PLATFORM_NOKIA,
1682 1682
               'BlackBerry' => self::PLATFORM_BLACKBERRY,
@@ -1700,9 +1700,9 @@  discard block
 block discarded – undo
1700 1700
             );
1701 1701
 
1702 1702
             foreach ($platformMaps as $name => $value) {
1703
-                if($name == 'linux_smarttv' 
1703
+                if ($name == 'linux_smarttv' 
1704 1704
                     && stripos($this->_agent, 'linux') !== false 
1705
-                    && stripos($this->_agent, 'SMART-TV') !== false ){
1705
+                    && stripos($this->_agent, 'SMART-TV') !== false) {
1706 1706
                         $this->_platform = $value;
1707 1707
                         break;
1708 1708
                 } elseif (stripos($this->_agent, $name) !== false) {
Please login to merge, or discard this patch.
core/functions/function_string.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 *  @filesource
40 40
 	 */
41 41
 
42
-	if(! function_exists('get_random_string')){
42
+	if (!function_exists('get_random_string')) {
43 43
 		/**
44 44
 		 * Generate a random string
45 45
 		 * @param  string $type the type of generation. It can take the values: "alpha" for alphabetic characters,
@@ -49,21 +49,21 @@  discard block
 block discarded – undo
49 49
 		 * @param  boolean $lower if we return the generated string in lowercase (true). By default it's false.
50 50
 		 * @return string the generated string.
51 51
 		 */
52
-		function get_random_string($type = 'alnum', $length = 10, $lower = false){
52
+		function get_random_string($type = 'alnum', $length = 10, $lower = false) {
53 53
 			$chars = array(
54 54
 							'alpha' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
55 55
 							'alnum' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890',
56 56
 							'num' => '1234567890'
57 57
 						);
58 58
 			$str = null;
59
-			if(isset($chars[$type])){
59
+			if (isset($chars[$type])) {
60 60
 				$str = $chars[$type];
61 61
 			}
62 62
 			$random = null;
63
-			for($i = 0; $i < $length; $i++){
63
+			for ($i = 0; $i < $length; $i++) {
64 64
 				$random .= $str[mt_rand() % strlen($str)];
65 65
 			}
66
-			if($lower){
66
+			if ($lower) {
67 67
 				$random = strtolower($random);
68 68
 			}
69 69
 			return $random;
Please login to merge, or discard this patch.