Test Setup Failed
Branch 1.0.0-dev (6506b5)
by nguereza
05:54
created
core/libraries/FormValidation.php 1 patch
Spacing   +54 added lines, -54 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
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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)));
Please login to merge, or discard this patch.
core/libraries/StringHash.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 
27
-	class StringHash{
27
+	class StringHash {
28 28
 		 
29 29
 		 //blowfish
30 30
 		private static $algo = '$2a';
Please login to merge, or discard this patch.
core/libraries/Html.php 1 patch
Spacing   +46 added lines, -46 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 Html{
27
+	class Html {
28 28
 
29 29
 		/**
30 30
 		 * Generate the html anchor link
@@ -35,21 +35,21 @@  discard block
 block discarded – undo
35 35
 		 *
36 36
 		 * @return string|void             the anchor link generated html if $return is true or display it if not
37 37
 		 */
38
-		public static function a($link = '', $anchor = null, array $attributes = array(), $return = true){
39
-			if(! is_url($link)){
38
+		public static function a($link = '', $anchor = null, array $attributes = array(), $return = true) {
39
+			if (!is_url($link)) {
40 40
 				$link = Url::site_url($link);
41 41
 			}
42
-			if(! $anchor){
42
+			if (!$anchor) {
43 43
 				$anchor = $link;
44 44
 			}
45 45
 			$str = null;
46
-			$str .= '<a href = "'.$link.'"';
46
+			$str .= '<a href = "' . $link . '"';
47 47
 			$str .= attributes_to_string($attributes);
48 48
 			$str .= '>';
49 49
 			$str .= $anchor;
50 50
 			$str .= '</a>';
51 51
 
52
-			if($return){
52
+			if ($return) {
53 53
 				return $str;
54 54
 			}
55 55
 			echo $str;
@@ -64,18 +64,18 @@  discard block
 block discarded – undo
64 64
 		 *
65 65
 		 * @return string|void             the generated html for mailto link if $return is true or display it if not
66 66
 		 */
67
-		public static function mailto($link, $anchor = null, array $attributes = array(), $return = true){
68
-			if(! $anchor){
67
+		public static function mailto($link, $anchor = null, array $attributes = array(), $return = true) {
68
+			if (!$anchor) {
69 69
 				$anchor = $link;
70 70
 			}
71 71
 			$str = null;
72
-			$str .= '<a href = "mailto:'.$link.'"';
72
+			$str .= '<a href = "mailto:' . $link . '"';
73 73
 			$str .= attributes_to_string($attributes);
74 74
 			$str .= '>';
75 75
 			$str .= $anchor;
76 76
 			$str .= '</a>';
77 77
 
78
-			if($return){
78
+			if ($return) {
79 79
 				return $str;
80 80
 			}
81 81
 			echo $str;
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 		 *
89 89
 		 * @return string|void      the generated "br" html if $return is true or display it if not
90 90
 		 */
91
-		public static function br($nb = 1, $return = true){
92
-			if(! is_numeric($nb) || $nb <= 0){
91
+		public static function br($nb = 1, $return = true) {
92
+			if (!is_numeric($nb) || $nb <= 0) {
93 93
 				$nb = 1;
94 94
 			}
95 95
 			$str = null;
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 				$str .= '<br />';
98 98
 			}
99 99
 
100
-			if($return){
100
+			if ($return) {
101 101
 				return $str;
102 102
 			}
103 103
 			echo $str;
@@ -111,15 +111,15 @@  discard block
 block discarded – undo
111 111
 		 *
112 112
 		 * @return string|void the generated "hr" html if $return is true or display it if not.
113 113
 		 */
114
-		public static function hr($nb = 1, array $attributes = array(), $return = true){
115
-			if(! is_numeric($nb) || $nb <= 0){
114
+		public static function hr($nb = 1, array $attributes = array(), $return = true) {
115
+			if (!is_numeric($nb) || $nb <= 0) {
116 116
 				$nb = 1;
117 117
 			}
118 118
 			$str = null;
119 119
 			for ($i = 1; $i <= $nb; $i++) {
120
-				$str .= '<hr' .attributes_to_string($attributes). ' />';
120
+				$str .= '<hr' . attributes_to_string($attributes) . ' />';
121 121
 			}
122
-			if($return){
122
+			if ($return) {
123 123
 				return $str;
124 124
 			}
125 125
 			echo $str;
@@ -135,18 +135,18 @@  discard block
 block discarded – undo
135 135
 		 *
136 136
 		 * @return string|void the generated header html if $return is true or display it if not.
137 137
 		 */
138
-		public static function head($type = 1, $text = null, $nb = 1, array $attributes = array(), $return = true){
139
-			if(! is_numeric($nb) || $nb <= 0){
138
+		public static function head($type = 1, $text = null, $nb = 1, array $attributes = array(), $return = true) {
139
+			if (!is_numeric($nb) || $nb <= 0) {
140 140
 				$nb = 1;
141 141
 			}
142
-			if(! is_numeric($type) || $type <= 0 || $type > 6){
142
+			if (!is_numeric($type) || $type <= 0 || $type > 6) {
143 143
 				$type = 1;
144 144
 			}
145 145
 			$str = null;
146 146
 			for ($i = 1; $i <= $nb; $i++) {
147
-				$str .= '<h' . $type . attributes_to_string($attributes). '>' .$text. '</h' . $type . '>';
147
+				$str .= '<h' . $type . attributes_to_string($attributes) . '>' . $text . '</h' . $type . '>';
148 148
 			}
149
-			if($return){
149
+			if ($return) {
150 150
 				return $str;
151 151
 			}
152 152
 			echo $str;
@@ -161,15 +161,15 @@  discard block
 block discarded – undo
161 161
 		 *
162 162
 		 * @return string|void the generated "ul" html  if $return is true or display it if not.
163 163
 		 */
164
-		public static function ul($data = array(), $attributes = array(), $return = true){
164
+		public static function ul($data = array(), $attributes = array(), $return = true) {
165 165
 			$data = (array) $data;
166 166
 			$str = null;
167
-			$str .= '<ul' . (! empty($attributes['ul']) ? attributes_to_string($attributes['ul']):'') . '>';
167
+			$str .= '<ul' . (!empty($attributes['ul']) ? attributes_to_string($attributes['ul']) : '') . '>';
168 168
 			foreach ($data as $row) {
169
-				$str .= '<li' . (! empty($attributes['li']) ? attributes_to_string($attributes['li']):'') .'>' .$row. '</li>';
169
+				$str .= '<li' . (!empty($attributes['li']) ? attributes_to_string($attributes['li']) : '') . '>' . $row . '</li>';
170 170
 			}
171 171
 			$str .= '</ul>';
172
-			if($return){
172
+			if ($return) {
173 173
 				return $str;
174 174
 			}
175 175
 			echo $str;
@@ -183,15 +183,15 @@  discard block
 block discarded – undo
183 183
 		 * @param  boolean $return whether need return the generated html or just display it directly
184 184
 		 * @return string|void the generated "ol" html  if $return is true or display it if not.
185 185
 		 */
186
-		public static function ol($data = array(), $attributes = array(), $return = true){
186
+		public static function ol($data = array(), $attributes = array(), $return = true) {
187 187
 			$data = (array) $data;
188 188
 			$str = null;
189
-			$str .= '<ol' . (!empty($attributes['ol']) ? attributes_to_string($attributes['ol']):'') . '>';
189
+			$str .= '<ol' . (!empty($attributes['ol']) ? attributes_to_string($attributes['ol']) : '') . '>';
190 190
 			foreach ($data as $row) {
191
-				$str .= '<li' . (!empty($attributes['li']) ? attributes_to_string($attributes['li']):'') .'>' .$row. '</li>';
191
+				$str .= '<li' . (!empty($attributes['li']) ? attributes_to_string($attributes['li']) : '') . '>' . $row . '</li>';
192 192
 			}
193 193
 			$str .= '</ol>';
194
-			if($return){
194
+			if ($return) {
195 195
 				return $str;
196 196
 			}
197 197
 			echo $str;
@@ -209,46 +209,46 @@  discard block
 block discarded – undo
209 209
 		 * @param  boolean $return whether need return the generated html or just display it directly
210 210
 		 * @return string|void the generated "table" html  if $return is true or display it if not.
211 211
 		 */
212
-		public static function table($headers = array(), $body = array(), $attributes = array(), $use_footer = false, $return = true){
212
+		public static function table($headers = array(), $body = array(), $attributes = array(), $use_footer = false, $return = true) {
213 213
 			$headers = (array) $headers;
214 214
 			$body = (array) $body;
215 215
 			$str = null;
216
-			$str .= '<table' . (! empty($attributes['table']) ? attributes_to_string($attributes['table']):'') . '>';
217
-			if(! empty($headers)){
218
-				$str .= '<thead' . (! empty($attributes['thead']) ? attributes_to_string($attributes['thead']):'') .'>';
219
-				$str .= '<tr' . (! empty($attributes['thead_tr']) ? attributes_to_string($attributes['thead_tr']):'') .'>';
216
+			$str .= '<table' . (!empty($attributes['table']) ? attributes_to_string($attributes['table']) : '') . '>';
217
+			if (!empty($headers)) {
218
+				$str .= '<thead' . (!empty($attributes['thead']) ? attributes_to_string($attributes['thead']) : '') . '>';
219
+				$str .= '<tr' . (!empty($attributes['thead_tr']) ? attributes_to_string($attributes['thead_tr']) : '') . '>';
220 220
 				foreach ($headers as $value) {
221
-					$str .= '<th' . (! empty($attributes['thead_th']) ? attributes_to_string($attributes['thead_th']):'') .'>' .$value. '</th>';
221
+					$str .= '<th' . (!empty($attributes['thead_th']) ? attributes_to_string($attributes['thead_th']) : '') . '>' . $value . '</th>';
222 222
 				}
223 223
 				$str .= '</tr>';
224 224
 				$str .= '</thead>';
225 225
 			}
226
-			else{
226
+			else {
227 227
 				//no need check for footer
228 228
 				$use_footer = false;
229 229
 			}
230
-			$str .= '<tbody' . (! empty($attributes['tbody']) ? attributes_to_string($attributes['tbody']):'') .'>';
230
+			$str .= '<tbody' . (!empty($attributes['tbody']) ? attributes_to_string($attributes['tbody']) : '') . '>';
231 231
 			foreach ($body as $row) {
232
-				if(is_array($row)){
233
-					$str .= '<tr' . (! empty($attributes['tbody_tr']) ? attributes_to_string($attributes['tbody_tr']):'') .'>';
232
+				if (is_array($row)) {
233
+					$str .= '<tr' . (!empty($attributes['tbody_tr']) ? attributes_to_string($attributes['tbody_tr']) : '') . '>';
234 234
 					foreach ($row as $value) {
235
-						$str .= '<td' . (! empty($attributes['tbody_td']) ? attributes_to_string($attributes['tbody_td']):'') .'>' .$value. '</td>';	
235
+						$str .= '<td' . (!empty($attributes['tbody_td']) ? attributes_to_string($attributes['tbody_td']) : '') . '>' . $value . '</td>';	
236 236
 					}
237 237
 					$str .= '</tr>';
238 238
 				}
239 239
 			}
240 240
 			$str .= '</tbody>';
241
-			if($use_footer){
242
-				$str .= '<tfoot' . (! empty($attributes['tfoot']) ? attributes_to_string($attributes['tfoot']):'') .'>';
243
-				$str .= '<tr' . (! empty($attributes['tfoot_tr']) ? attributes_to_string($attributes['tfoot_tr']):'') .'>';
241
+			if ($use_footer) {
242
+				$str .= '<tfoot' . (!empty($attributes['tfoot']) ? attributes_to_string($attributes['tfoot']) : '') . '>';
243
+				$str .= '<tr' . (!empty($attributes['tfoot_tr']) ? attributes_to_string($attributes['tfoot_tr']) : '') . '>';
244 244
 				foreach ($headers as $value) {
245
-					$str .= '<th' . (! empty($attributes['tfoot_th']) ? attributes_to_string($attributes['tfoot_th']):'') .'>' .$value. '</th>';
245
+					$str .= '<th' . (!empty($attributes['tfoot_th']) ? attributes_to_string($attributes['tfoot_th']) : '') . '>' . $value . '</th>';
246 246
 				}
247 247
 				$str .= '</tr>';
248 248
 				$str .= '</tfoot>';
249 249
 			}
250 250
 			$str .= '</table>';
251
-			if($return){
251
+			if ($return) {
252 252
 				return $str;
253 253
 			}
254 254
 			echo $str;
Please login to merge, or discard this patch.
core/libraries/Pagination.php 1 patch
Spacing   +39 added lines, -39 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
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
          * Create an instance of pagination
37 37
          * @param array $overwriteConfig the list of configuration to overwrite the defined configuration in config_pagination.php
38 38
          */
39
-        public function __construct($overwriteConfig = array()){
40
-            if(file_exists(CONFIG_PATH . 'config_pagination.php')){
39
+        public function __construct($overwriteConfig = array()) {
40
+            if (file_exists(CONFIG_PATH . 'config_pagination.php')) {
41 41
                 require_once CONFIG_PATH . 'config_pagination.php';
42
-                if(empty($config) || ! is_array($config)){
42
+                if (empty($config) || !is_array($config)) {
43 43
                     show_error('No configuration found in ' . CONFIG_PATH . 'config_pagination.php');
44 44
                 }
45
-				else{
46
-					if(! empty($overwriteConfig)){
45
+				else {
46
+					if (!empty($overwriteConfig)) {
47 47
 						$config = array_merge($config, $overwriteConfig);
48 48
 					}
49 49
 					$this->config = $config;
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 					unset($config);
52 52
 				}
53 53
             }
54
-            else{
54
+            else {
55 55
                 show_error('Unable to find the pagination configuration file');
56 56
             }
57 57
         }
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
          * config_pagination.php
63 63
          * @param array $config the configuration to set
64 64
          */
65
-        public function setConfig(array $config = array()){
66
-            if(! empty($config)){
65
+        public function setConfig(array $config = array()) {
66
+            if (!empty($config)) {
67 67
                 $this->config = array_merge($this->config, $config);
68 68
                 Config::setAll($config);
69 69
             }
@@ -75,26 +75,26 @@  discard block
 block discarded – undo
75 75
          * @param  int $currentPageNumber the current page number
76 76
          * @return string the pagination link
77 77
          */
78
-        public function getLink($totalRows, $currentPageNumber){
78
+        public function getLink($totalRows, $currentPageNumber) {
79 79
             $pageQueryName = $this->config['page_query_string_name'];
80 80
             $numberOfLink = $this->config['nb_link'];
81 81
 			$numberOfRowPerPage = $this->config['pagination_per_page'];
82 82
             $queryString = Url::queryString();
83 83
             $currentUrl = Url::current();
84
-            if($queryString == ''){
84
+            if ($queryString == '') {
85 85
                 $query = '?' . $pageQueryName . '=';
86 86
             }
87
-            else{
87
+            else {
88 88
                 $tab = explode($pageQueryName . '=', $queryString);
89 89
                 $nb = count($tab);
90
-                if($nb == 1){
90
+                if ($nb == 1) {
91 91
                     $query = '?' . $queryString . '&' . $pageQueryName . '=';
92 92
                 }
93
-                else{
94
-                    if($tab[0] == ''){
93
+                else {
94
+                    if ($tab[0] == '') {
95 95
                         $query = '?' . $pageQueryName . '=';
96 96
                     }
97
-                    else{
97
+                    else {
98 98
                         $query = '?' . $tab[0] . '' . $pageQueryName . '=';
99 99
                     }
100 100
                 }
@@ -103,67 +103,67 @@  discard block
 block discarded – undo
103 103
             $query = $temp[0] . $query;
104 104
             $navbar = '';
105 105
             $numberOfPage = ceil($totalRows / $numberOfRowPerPage);
106
-			if(! is_numeric ($currentPageNumber) || $currentPageNumber <= 0){
106
+			if (!is_numeric($currentPageNumber) || $currentPageNumber <= 0) {
107 107
 				$currentPageNumber = 1;
108 108
 			}
109
-            if($numberOfPage <= 1 || $numberOfLink <= 0 || $numberOfRowPerPage <= 0 || !is_numeric($numberOfLink) || !is_numeric($numberOfRowPerPage)
110
-            ){
109
+            if ($numberOfPage <= 1 || $numberOfLink <= 0 || $numberOfRowPerPage <= 0 || !is_numeric($numberOfLink) || !is_numeric($numberOfRowPerPage)
110
+            ) {
111 111
                 return $navbar;
112 112
             }
113
-            if($numberOfLink % 2 == 0){
113
+            if ($numberOfLink % 2 == 0) {
114 114
                 $start = $currentPageNumber - ($numberOfLink / 2) + 1;
115 115
                 $end = $currentPageNumber + ($numberOfLink / 2);
116 116
             }
117
-            else{
117
+            else {
118 118
                 $start = $currentPageNumber - floor($numberOfLink / 2);
119 119
                 $end = $currentPageNumber + floor($numberOfLink / 2);
120 120
             }
121
-            if($start <= 1){
121
+            if ($start <= 1) {
122 122
                 $begin = 1;
123 123
                 $end = $numberOfLink;
124 124
             }
125
-            else if($start > 1 && $end < $numberOfPage){
125
+            else if ($start > 1 && $end < $numberOfPage) {
126 126
                 $begin = $start;
127 127
                 $end = $end;
128 128
             }
129
-            else{
129
+            else {
130 130
                 $begin = ($numberOfPage - $numberOfLink) + 1;
131 131
                 $end = $numberOfPage;
132 132
             }
133
-            if($numberOfPage <= $numberOfLink){
133
+            if ($numberOfPage <= $numberOfLink) {
134 134
                 $begin = 1;
135 135
                 $end = $numberOfPage;
136 136
             }
137
-            if($currentPageNumber == 1){
138
-                for($i = $begin; $i <= $end; $i++){
139
-                    if($i == $currentPageNumber){
137
+            if ($currentPageNumber == 1) {
138
+                for ($i = $begin; $i <= $end; $i++) {
139
+                    if ($i == $currentPageNumber) {
140 140
                         $navbar .= $this->config['active_link_open'] . $currentPageNumber . $this->config['active_link_close'];
141 141
                     }
142
-                    else{
142
+                    else {
143 143
                         $navbar .= $this->config['digit_open'] . '<a href="' . $query . $i . '" ' . attributes_to_string($this->config['attributes']) . '>' . $i . '</a>' . $this->config['digit_close'];
144 144
                     }
145 145
                 }
146 146
                 $navbar .= $this->config['next_open'] . '<a href="' . $query . ($currentPageNumber + 1) . '">' . $this->config['next_text'] . '</a>' . $this->config['next_close'];
147 147
             }
148
-            else if($currentPageNumber > 1 && $currentPageNumber < $numberOfPage){
148
+            else if ($currentPageNumber > 1 && $currentPageNumber < $numberOfPage) {
149 149
                 $navbar .= $this->config['previous_open'] . '<a href="' . $query . ($currentPageNumber - 1) . '">' . $this->config['previous_text'] . '</a>' . $this->config['previous_close'];
150
-                for($i = $begin; $i <= $end; $i++){
151
-                    if($i == $currentPageNumber){
150
+                for ($i = $begin; $i <= $end; $i++) {
151
+                    if ($i == $currentPageNumber) {
152 152
                         $navbar .= $this->config['active_link_open'] . $currentPageNumber . $this->config['active_link_close'];
153 153
                     }
154
-                    else{
155
-                        $navbar .= $this->config['digit_open'] . '<a href="' . $query . $i . '"' . attributes_to_string($this->config['attributes']) . '>' . $i .'</a>' . $this->config['digit_close'];
154
+                    else {
155
+                        $navbar .= $this->config['digit_open'] . '<a href="' . $query . $i . '"' . attributes_to_string($this->config['attributes']) . '>' . $i . '</a>' . $this->config['digit_close'];
156 156
                     }
157 157
                 }
158
-                $navbar .= $this->config['next_open']."<a href='$query".($currentPageNumber + 1)."'>".$this->config['next_text']."</a>".$this->config['next_close'];
158
+                $navbar .= $this->config['next_open'] . "<a href='$query" . ($currentPageNumber + 1) . "'>" . $this->config['next_text'] . "</a>" . $this->config['next_close'];
159 159
             }
160
-            else if($currentPageNumber == $numberOfPage){
160
+            else if ($currentPageNumber == $numberOfPage) {
161 161
                 $navbar .= $this->config['previous_open'] . '<a href="' . $query . ($currentPageNumber - 1) . '">' . $this->config['previous_text'] . '</a>' . $this->config['previous_close'];
162
-                for($i = $begin; $i <= $end; $i++){
163
-                    if($i == $currentPageNumber){
162
+                for ($i = $begin; $i <= $end; $i++) {
163
+                    if ($i == $currentPageNumber) {
164 164
                         $navbar .= $this->config['active_link_open'] . $currentPageNumber . $this->config['active_link_close'];
165 165
                     }
166
-                    else{
166
+                    else {
167 167
                         $navbar .= $this->config['digit_open'] . '<a href="' . $query . $i . '"' . attributes_to_string($this->config['attributes']) . '>' . $i . '</a>' . $this->config['digit_close'];
168 168
                     }
169 169
                 }
Please login to merge, or discard this patch.
core/libraries/Form.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	*/
26 26
 
27 27
 
28
-	class Form{
28
+	class Form {
29 29
 
30 30
 		/**
31 31
 		 * Generate the form opened tag
@@ -35,33 +35,33 @@  discard block
 block discarded – undo
35 35
 		 * @param  string $enctype    the form enctype like "multipart/form-data"
36 36
 		 * @return string             the generated form html
37 37
 		 */
38
-		public static function open($path = null, array $attributes = array(), $method = 'POST', $enctype = null){
39
-			if($path){
38
+		public static function open($path = null, array $attributes = array(), $method = 'POST', $enctype = null) {
39
+			if ($path) {
40 40
 				$path = Url::site_url($path);
41 41
 			}
42 42
 			$method = strtoupper($method);
43 43
 			$str = null;
44
-			$str .= '<form action = "'.$path.'" method = "'.$method.'"';
45
-			if(! empty($enctype)){
46
-				$str .= ' enctype = "'.$enctype.'" ';
44
+			$str .= '<form action = "' . $path . '" method = "' . $method . '"';
45
+			if (!empty($enctype)) {
46
+				$str .= ' enctype = "' . $enctype . '" ';
47 47
 			}
48
-			if(! isset($attributes['accept-charset'])){
48
+			if (!isset($attributes['accept-charset'])) {
49 49
 				$attributes['accept-charset'] = get_config('charset', 'utf-8');
50 50
 			}
51 51
 			$str .= attributes_to_string($attributes);
52 52
 			$str .= '>';
53 53
 			$checkCsrf = false;
54 54
 			//check if the user set the checking of CSRF manually
55
-			if($method != 'POST' && isset($attributes['csrf'])){
55
+			if ($method != 'POST' && isset($attributes['csrf'])) {
56 56
 				$obj = & get_instance();
57
-				if(! isset($obj->formvalidation)){
57
+				if (!isset($obj->formvalidation)) {
58 58
 					Loader::library('FormValidation');
59 59
 				}
60 60
 				$obj->formvalidation->enableCsrfCheck = true;
61 61
 				$checkCsrf = true;
62 62
 			}
63 63
 			//if CSRF enable or is set manually
64
-			if((get_config('csrf_enable', false) && $method == 'POST') || ($method != 'POST' && $checkCsrf)){
64
+			if ((get_config('csrf_enable', false) && $method == 'POST') || ($method != 'POST' && $checkCsrf)) {
65 65
 				$csrfValue = Security::generateCSRF();
66 66
 				$csrfName = get_config('csrf_key', 'csrf_key');
67 67
 				$str .= static::hidden($csrfName, $csrfValue);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		 * @see Form::open() for more details
75 75
 		 * @return string the generated multipart form html
76 76
 		 */
77
-		public static function openMultipart($path = null, array $attributes = array(), $method = 'POST'){
77
+		public static function openMultipart($path = null, array $attributes = array(), $method = 'POST') {
78 78
 			return self::open($path, $attributes, $method, 'multipart/form-data');
79 79
 		}
80 80
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 		 * Generate the form close
83 83
 		 * @return string the form close html
84 84
 		 */
85
-		public static function close(){
85
+		public static function close() {
86 86
 			return '</form>';
87 87
 		}
88 88
 
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
 		 * @param  array  $legendAttributes the legend additional HTML attributes. Is used only is $legend is not empty
94 94
 		 * @return string         the generated fieldset value
95 95
 		 */
96
-		public static function fieldset($legend = '', array $fieldsetAttributes = array(), array $legendAttributes = array()){
96
+		public static function fieldset($legend = '', array $fieldsetAttributes = array(), array $legendAttributes = array()) {
97 97
 			$str = '<fieldset' . attributes_to_string($fieldsetAttributes) . '>';
98
-			if($legend){
99
-				$str .= '<legend' . attributes_to_string($legendAttributes) . '>'.$legend.'</legend>';
98
+			if ($legend) {
99
+				$str .= '<legend' . attributes_to_string($legendAttributes) . '>' . $legend . '</legend>';
100 100
 			}
101 101
 			return $str;
102 102
 		}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		 * Generate the fieldset close tag
106 106
 		 * @return string the generated html for fieldset close
107 107
 		 */
108
-		public static function fieldsetClose(){
108
+		public static function fieldsetClose() {
109 109
 			return '</fieldset>';
110 110
 		}
111 111
 
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
 		 * @param  string $name the form field name
116 116
 		 * @return string       the error message if exists and null if not
117 117
 		 */
118
-		public static function error($name){
118
+		public static function error($name) {
119 119
 			$return = null;
120 120
 			$obj = & get_instance();
121
-			if(isset($obj->formvalidation)){
121
+			if (isset($obj->formvalidation)) {
122 122
 				$errors = $obj->formvalidation->returnErrors();
123
-				$error =  isset($errors[$name]) ? $errors[$name] : null;
124
-				if($error){
123
+				$error = isset($errors[$name]) ? $errors[$name] : null;
124
+				if ($error) {
125 125
 					list($errorStart, $errorEnd) = $obj->formvalidation->getErrorDelimiter();
126 126
 					$return = $errorStart . $error . $errorEnd;
127 127
 				}
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 		 * @param  mixed $default the default value if can not found the given form field name
136 136
 		 * @return mixed the form field value if is set, otherwise return the default value.
137 137
 		 */
138
-		public static function value($name, $default = null){
138
+		public static function value($name, $default = null) {
139 139
 			$value = get_instance()->request->query($name);
140 140
 			return $value ? $value : $default;
141 141
 		}
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
 		 * @param  array  $attributes the additional attributes to be added
148 148
 		 * @return string the generated label html content
149 149
 		 */
150
-		public static function label($label, $for = '', array $attributes = array()){
150
+		public static function label($label, $for = '', array $attributes = array()) {
151 151
 			$str = '<label';
152
-			if($for){
153
-				$str .= ' for = "'.$for.'"';
152
+			if ($for) {
153
+				$str .= ' for = "' . $for . '"';
154 154
 			}
155 155
 			$str .= attributes_to_string($attributes);
156 156
 			$str .= '>';
157
-			$str .= $label.'</label>';
157
+			$str .= $label . '</label>';
158 158
 			return $str;
159 159
 		}
160 160
 
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
 		 * @param  string $type       the type of the form field (password, text, submit, button, etc.)
167 167
 		 * @return string             the generated form field html content for the input
168 168
 		 */
169
-		public static function input($name, $value = null, array $attributes = array(), $type = 'text'){
169
+		public static function input($name, $value = null, array $attributes = array(), $type = 'text') {
170 170
 			$str = null;
171
-			$str .= '<input name = "'.$name.'" value = "'.$value.'" type = "'.$type.'"';
171
+			$str .= '<input name = "' . $name . '" value = "' . $value . '" type = "' . $type . '"';
172 172
 			$str .= attributes_to_string($attributes);
173 173
 			$str .= '/>';
174 174
 			return $str;
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 		 * Generate the form field for "text"
179 179
 		 * @see Form::input() for more details
180 180
 		 */
181
-		public static function text($name, $value = null, array $attributes = array()){
181
+		public static function text($name, $value = null, array $attributes = array()) {
182 182
 			return self::input($name, $value, $attributes, 'text');
183 183
 		}
184 184
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 		 * Generate the form field for "password"
187 187
 		 * @see Form::input() for more details
188 188
 		 */
189
-		public static function password($name, $value = null, array $attributes = array()){
189
+		public static function password($name, $value = null, array $attributes = array()) {
190 190
 			return self::input($name, $value, $attributes, 'password');
191 191
 		}
192 192
 
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
 		 * Generate the form field for "radio"
195 195
 		 * @see Form::input() for more details
196 196
 		 */
197
-		public static function radio($name, $value = null,  $checked = false, array $attributes = array()){
198
-			if($checked){
197
+		public static function radio($name, $value = null, $checked = false, array $attributes = array()) {
198
+			if ($checked) {
199 199
 				$attributes['checked'] = true;
200 200
 			}
201 201
 			return self::input($name, $value, $attributes, 'radio');
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 		 * Generate the form field for "checkbox"
206 206
 		 * @see Form::input() for more details
207 207
 		 */
208
-		public static function checkbox($name, $value = null, $checked = false, array $attributes = array()){
209
-			if($checked){
208
+		public static function checkbox($name, $value = null, $checked = false, array $attributes = array()) {
209
+			if ($checked) {
210 210
 				$attributes['checked'] = true;
211 211
 			}
212 212
 			return self::input($name, $value, $attributes, 'checkbox');
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		 * Generate the form field for "number"
217 217
 		 * @see Form::input() for more details
218 218
 		 */
219
-		public static function number($name, $value = null, array $attributes = array()){
219
+		public static function number($name, $value = null, array $attributes = array()) {
220 220
 			return self::input($name, $value, $attributes, 'number');
221 221
 		}
222 222
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		 * Generate the form field for "phone"
225 225
 		 * @see Form::input() for more details
226 226
 		 */
227
-		public static function phone($name, $value = null, array $attributes = array()){
227
+		public static function phone($name, $value = null, array $attributes = array()) {
228 228
 			return self::input($name, $value, $attributes, 'phone');
229 229
 		}
230 230
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 		 * Generate the form field for "email"
233 233
 		 * @see Form::input() for more details
234 234
 		 */
235
-		public static function email($name, $value = null, array $attributes = array()){
235
+		public static function email($name, $value = null, array $attributes = array()) {
236 236
 			return self::input($name, $value, $attributes, 'email');
237 237
 		}
238 238
 		
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 		 * Generate the form field for "search"
241 241
 		 * @see Form::input() for more details
242 242
 		 */
243
-		public static function search($name, $value = null, array $attributes = array()){
243
+		public static function search($name, $value = null, array $attributes = array()) {
244 244
 			return self::input($name, $value, $attributes, 'search');
245 245
 		}
246 246
 		
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 		 * Generate the form field for "hidden"
249 249
 		 * @see Form::input() for more details
250 250
 		 */
251
-		public static function hidden($name, $value = null, array $attributes = array()){
251
+		public static function hidden($name, $value = null, array $attributes = array()) {
252 252
 			return self::input($name, $value, $attributes, 'hidden');
253 253
 		}
254 254
 		
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 		 * Generate the form field for "file"
257 257
 		 * @see Form::input() for more details
258 258
 		 */
259
-		public static function file($name, array $attributes = array()){
259
+		public static function file($name, array $attributes = array()) {
260 260
 			return self::input($name, null, $attributes, 'file');
261 261
 		}
262 262
 		
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 		 * Generate the form field for "button"
265 265
 		 * @see Form::input() for more details
266 266
 		 */
267
-		public static function button($name, $value = null, array $attributes = array()){
267
+		public static function button($name, $value = null, array $attributes = array()) {
268 268
 			return self::input($name, $value, $attributes, 'button');
269 269
 		}
270 270
 		
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 		 * Generate the form field for "reset"
273 273
 		 * @see Form::input() for more details
274 274
 		 */
275
-		public static function reset($name, $value = null, array $attributes = array()){
275
+		public static function reset($name, $value = null, array $attributes = array()) {
276 276
 			return self::input($name, $value, $attributes, 'reset');
277 277
 		}
278 278
 		
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		 * Generate the form field for "submit"
281 281
 		 * @see Form::input() for more details
282 282
 		 */
283
-		public static function submit($name, $value = null, array $attributes = array()){
283
+		public static function submit($name, $value = null, array $attributes = array()) {
284 284
 			return self::input($name, $value, $attributes, 'submit');
285 285
 		}
286 286
 
@@ -291,12 +291,12 @@  discard block
 block discarded – undo
291 291
 		 * @param  array  $attributes the additional attributes to be added
292 292
 		 * @return string             the generated textarea form html content
293 293
 		 */
294
-		public static function textarea($name, $value = '', array $attributes = array()){
294
+		public static function textarea($name, $value = '', array $attributes = array()) {
295 295
 			$str = null;
296
-			$str .= '<textarea name = "'.$name.'"';
296
+			$str .= '<textarea name = "' . $name . '"';
297 297
 			$str .= attributes_to_string($attributes);
298 298
 			$str .= '>';
299
-			$str .= $value.'</textarea>';
299
+			$str .= $value . '</textarea>';
300 300
 			return $str;
301 301
 		}
302 302
 		
@@ -308,20 +308,20 @@  discard block
 block discarded – undo
308 308
 		 * @param  array  $attributes the additional attribute to be added
309 309
 		 * @return string             the generated form field html content for select
310 310
 		 */
311
-		public static function select($name, $values = null, $selected = null, array $attributes = array()){
312
-			if(! is_array($values)){
311
+		public static function select($name, $values = null, $selected = null, array $attributes = array()) {
312
+			if (!is_array($values)) {
313 313
 				$values = array('' => $values);
314 314
 			}
315 315
 			$str = null;
316
-			$str .= '<select name = "'.$name.'"';
316
+			$str .= '<select name = "' . $name . '"';
317 317
 			$str .= attributes_to_string($attributes);
318 318
 			$str .= '>';
319
-			foreach($values as $key => $val){
319
+			foreach ($values as $key => $val) {
320 320
 				$select = '';
321
-				if($key == $selected){
321
+				if ($key == $selected) {
322 322
 					$select = 'selected';
323 323
 				}
324
-				$str .= '<option value = "'.$key.'" '.$select.'>'.$val.'</option>';
324
+				$str .= '<option value = "' . $key . '" ' . $select . '>' . $val . '</option>';
325 325
 			}
326 326
 			$str .= '</select>';
327 327
 			return $str;
Please login to merge, or discard this patch.
core/libraries/Browser.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -918,27 +918,27 @@  discard block
 block discarded – undo
918 918
                 if (isset($aresult[1])) {
919 919
                     $this->setBrowser(self::BROWSER_IE);
920 920
                     $this->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1]));
921
-                    if(preg_match('#trident/([0-9\.]+);#i', $this->_agent, $aresult)){
922
-                        if($aresult[1] == '3.1'){
921
+                    if (preg_match('#trident/([0-9\.]+);#i', $this->_agent, $aresult)) {
922
+                        if ($aresult[1] == '3.1') {
923 923
                             $this->setVersion('7.0');
924 924
                         }
925
-                        else if($aresult[1] == '4.0'){
925
+                        else if ($aresult[1] == '4.0') {
926 926
                             $this->setVersion('8.0');
927 927
                         }
928
-                        else if($aresult[1] == '5.0'){
928
+                        else if ($aresult[1] == '5.0') {
929 929
                             $this->setVersion('9.0');
930 930
                         }
931
-                        else if($aresult[1] == '6.0'){
931
+                        else if ($aresult[1] == '6.0') {
932 932
                             $this->setVersion('10.0');
933 933
                         }
934
-                        else if($aresult[1] == '7.0'){
934
+                        else if ($aresult[1] == '7.0') {
935 935
                             $this->setVersion('11.0');
936 936
                         }
937
-                        else if($aresult[1] == '8.0'){
937
+                        else if ($aresult[1] == '8.0') {
938 938
                             $this->setVersion('11.0');
939 939
                         }
940 940
                     }
941
-                    if(stripos($this->_agent, 'IEMobile') !== false) {
941
+                    if (stripos($this->_agent, 'IEMobile') !== false) {
942 942
                         $this->setBrowser(self::BROWSER_POCKET_IE);
943 943
                         $this->setMobile(true);
944 944
                     }
@@ -1684,8 +1684,8 @@  discard block
 block discarded – undo
1684 1684
                 $this->_platform = self::PLATFORM_ANDROID;
1685 1685
             } elseif (stripos($this->_agent, 'Silk') !== false) {
1686 1686
                 $this->_platform = self::PLATFORM_FIRE_OS;
1687
-            } elseif (stripos($this->_agent, 'linux') !== false && stripos($this->_agent, 'SMART-TV') !== false ) {
1688
-                $this->_platform = self::PLATFORM_LINUX .'/'.self::PLATFORM_SMART_TV;
1687
+            } elseif (stripos($this->_agent, 'linux') !== false && stripos($this->_agent, 'SMART-TV') !== false) {
1688
+                $this->_platform = self::PLATFORM_LINUX . '/' . self::PLATFORM_SMART_TV;
1689 1689
             } elseif (stripos($this->_agent, 'linux') !== false) {
1690 1690
                 $this->_platform = self::PLATFORM_LINUX;
1691 1691
             } else if (stripos($this->_agent, 'Nokia') !== false) {
Please login to merge, or discard this patch.
core/functions/function_lang.php 1 patch
Spacing   +4 added lines, -4 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
-	if(! function_exists('__')){
27
+	if (!function_exists('__')) {
28 28
 		/**
29 29
 		 * function for the shortcut to Lang::get()
30 30
 		 * @param  string $key the language key to retrieve
@@ -32,20 +32,20 @@  discard block
 block discarded – undo
32 32
 		 * for the given key
33 33
 		 * @return string  the language value
34 34
 		 */
35
-		function __($key, $default = 'LANGUAGE_ERROR'){
35
+		function __($key, $default = 'LANGUAGE_ERROR') {
36 36
 			return get_instance()->lang->get($key, $default);
37 37
 		}
38 38
 
39 39
 	}
40 40
 
41 41
 
42
-	if(! function_exists('get_languages')){
42
+	if (!function_exists('get_languages')) {
43 43
 		/**
44 44
 		 * function for the shortcut to Lang::getSupported()
45 45
 		 * 
46 46
 		 * @return array all the supported languages
47 47
 		 */
48
-		function get_languages(){
48
+		function get_languages() {
49 49
 			return get_instance()->lang->getSupported();
50 50
 		}
51 51
 
Please login to merge, or discard this patch.
core/functions/function_user_agent.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	
43 43
 	 
44
-	if(! function_exists('get_ip')){
44
+	if (!function_exists('get_ip')) {
45 45
 		/**
46 46
 		 *  Retrieves the user's IP address
47 47
 		 *  
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		 *  
51 51
 		 *  @return string the IP address.
52 52
 		 */
53
-		function get_ip(){
53
+		function get_ip() {
54 54
 			$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
55 55
 
56 56
 			if (isset($_SERVER["HTTP_CLIENT_IP"])) {
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,9 +49,9 @@  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
 			$str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
54
-			switch($type){
54
+			switch ($type) {
55 55
 				case 'alpha':
56 56
 					$str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
57 57
 				break;
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
 				break;
64 64
 			}
65 65
 			$random = null;
66
-			for($i = 0; $i < $length; $i++){
66
+			for ($i = 0; $i < $length; $i++) {
67 67
 				$random .= $str[mt_rand() % strlen($str)];
68 68
 			}
69
-			if($lower){
69
+			if ($lower) {
70 70
 				$random = strtolower($random);
71 71
 			}
72 72
 			return $random;
Please login to merge, or discard this patch.