@@ -48,8 +48,7 @@ |
||
| 48 | 48 | function filtroEmail($email){ |
| 49 | 49 | if (!filter_input(INPUT_POST, $email, FILTER_VALIDATE_EMAIL)){ |
| 50 | 50 | echo "E-Mail no es valido"; |
| 51 | - } |
|
| 52 | - else |
|
| 51 | + } else |
|
| 53 | 52 | { |
| 54 | 53 | echo "E-Mail es valido"; |
| 55 | 54 | } |
@@ -130,14 +130,18 @@ discard block |
||
| 130 | 130 | // Itearate all inputs |
| 131 | 131 | foreach ($toShow as $input) { |
| 132 | 132 | // Reading data |
| 133 | - if (isset($input['data'])) $data = $input['data']; |
|
| 133 | + if (isset($input['data'])) { |
|
| 134 | + $data = $input['data']; |
|
| 135 | + } |
|
| 134 | 136 | |
| 135 | 137 | // New row |
| 136 | 138 | echo '<div>'; |
| 137 | 139 | // Showing labels |
| 138 | 140 | if ($this->show_labels) { |
| 139 | 141 | echo '<div>'; |
| 140 | - if (isset($input['label']) and $input['label'] != '') echo $input['label']; |
|
| 142 | + if (isset($input['label']) and $input['label'] != '') { |
|
| 143 | + echo $input['label']; |
|
| 144 | + } |
|
| 141 | 145 | echo '</div>'; |
| 142 | 146 | } |
| 143 | 147 | |
@@ -182,7 +186,9 @@ discard block |
||
| 182 | 186 | private function showInput($data) { |
| 183 | 187 | $r = ''; |
| 184 | 188 | // Number start if is range |
| 185 | - if ($data['type'] == 'range' and isset($data['min'])) $r .= $data['min'] . ' '; |
|
| 189 | + if ($data['type'] == 'range' and isset($data['min'])) { |
|
| 190 | + $r .= $data['min'] . ' '; |
|
| 191 | + } |
|
| 186 | 192 | |
| 187 | 193 | $r .= '<input '; |
| 188 | 194 | |
@@ -197,7 +203,9 @@ discard block |
||
| 197 | 203 | $r .= '/>'; |
| 198 | 204 | |
| 199 | 205 | // Number end if is range |
| 200 | - if ($data['type'] == 'range' and isset($data['max'])) $r .= $data['max'] . ' '; |
|
| 206 | + if ($data['type'] == 'range' and isset($data['max'])) { |
|
| 207 | + $r .= $data['max'] . ' '; |
|
| 208 | + } |
|
| 201 | 209 | |
| 202 | 210 | // Return |
| 203 | 211 | return $r; |
@@ -220,7 +228,9 @@ discard block |
||
| 220 | 228 | // Si no tiene m�ltiples valores (es un string), lo retornamos de golpe |
| 221 | 229 | if (!is_array($values)) { |
| 222 | 230 | // Comprobamos el value, es posible que el usuario este intentando crear los Radio (option) de forma separada |
| 223 | - if (!is_array($values) and $selected == $values) $base .= ' checked="checked" '; |
|
| 231 | + if (!is_array($values) and $selected == $values) { |
|
| 232 | + $base .= ' checked="checked" '; |
|
| 233 | + } |
|
| 224 | 234 | return $base . ' value="'.$values.'" />'; |
| 225 | 235 | } |
| 226 | 236 | |
@@ -229,7 +239,9 @@ discard block |
||
| 229 | 239 | $r = ''; |
| 230 | 240 | foreach ($values as $id=>$text) { |
| 231 | 241 | $r .= $base; |
| 232 | - if ($selected !== null and $id == $selected) $r .= ' checked="checked" '; |
|
| 242 | + if ($selected !== null and $id == $selected) { |
|
| 243 | + $r .= ' checked="checked" '; |
|
| 244 | + } |
|
| 233 | 245 | $r .= ' value="'. $id .'" />'.$text.'</label>'; |
| 234 | 246 | } |
| 235 | 247 | |
@@ -263,7 +275,9 @@ discard block |
||
| 263 | 275 | if ($selected != '') { |
| 264 | 276 | foreach ($values as $val=>$txt) { |
| 265 | 277 | $r .= '<option value="' . $val . '"'; |
| 266 | - if ($val == $selected) $r .= ' selected '; |
|
| 278 | + if ($val == $selected) { |
|
| 279 | + $r .= ' selected '; |
|
| 280 | + } |
|
| 267 | 281 | $r .= '>' . $txt . '</option>'; |
| 268 | 282 | } |
| 269 | 283 | } else { |
@@ -304,12 +318,24 @@ discard block |
||
| 304 | 318 | */ |
| 305 | 319 | private function showStartForm() { |
| 306 | 320 | $r = '<form '; |
| 307 | - if ($this->action!= '') $r .= 'action="'.$this->action.'" '; |
|
| 308 | - if ($this->method != '') $r .= 'method="'.$this->method .'" '; |
|
| 309 | - if ($this->name != '') $r .= 'name="'.$this->name .'" '; |
|
| 310 | - if ($this->on_submit != '') $r .= 'onSubmit="'.$this->on_submit .'" '; |
|
| 311 | - if ($this->id != '') $r .= 'id="'.$this->id .'" '; |
|
| 312 | - if ($this->class != '') $r .= 'class="'.$this->class .'" '; |
|
| 321 | + if ($this->action!= '') { |
|
| 322 | + $r .= 'action="'.$this->action.'" '; |
|
| 323 | + } |
|
| 324 | + if ($this->method != '') { |
|
| 325 | + $r .= 'method="'.$this->method .'" '; |
|
| 326 | + } |
|
| 327 | + if ($this->name != '') { |
|
| 328 | + $r .= 'name="'.$this->name .'" '; |
|
| 329 | + } |
|
| 330 | + if ($this->on_submit != '') { |
|
| 331 | + $r .= 'onSubmit="'.$this->on_submit .'" '; |
|
| 332 | + } |
|
| 333 | + if ($this->id != '') { |
|
| 334 | + $r .= 'id="'.$this->id .'" '; |
|
| 335 | + } |
|
| 336 | + if ($this->class != '') { |
|
| 337 | + $r .= 'class="'.$this->class .'" '; |
|
| 338 | + } |
|
| 313 | 339 | |
| 314 | 340 | return $r . '>'.PHP_EOL; |
| 315 | 341 | } |
@@ -370,7 +396,9 @@ discard block |
||
| 370 | 396 | } |
| 371 | 397 | } |
| 372 | 398 | |
| 373 | - if ($success >= $total) return true; |
|
| 399 | + if ($success >= $total) { |
|
| 400 | + return true; |
|
| 401 | + } |
|
| 374 | 402 | return false; |
| 375 | 403 | } |
| 376 | 404 | |
@@ -570,8 +598,11 @@ discard block |
||
| 570 | 598 | * @return string/null Return the value, if don't exist, return null |
| 571 | 599 | */ |
| 572 | 600 | private function getData($key, $default = null) { |
| 573 | - if ($this->method == "post") return isset($_POST[$key]) ? $_POST[$key] : $default; |
|
| 574 | - else return isset($_GET[$key]) ? $_GET[$key] : $default; |
|
| 601 | + if ($this->method == "post") { |
|
| 602 | + return isset($_POST[$key]) ? $_POST[$key] : $default; |
|
| 603 | + } else { |
|
| 604 | + return isset($_GET[$key]) ? $_GET[$key] : $default; |
|
| 605 | + } |
|
| 575 | 606 | } |
| 576 | 607 | |
| 577 | 608 | /* |
@@ -614,9 +645,15 @@ discard block |
||
| 614 | 645 | ); |
| 615 | 646 | |
| 616 | 647 | |
| 617 | - if ($required) $data['required'] = 'required'; |
|
| 618 | - if ($placeholder != '') $data['placeholder'] = $placeholder; |
|
| 619 | - if (!empty($attributes)) array_merge($data, $attributes); |
|
| 648 | + if ($required) { |
|
| 649 | + $data['required'] = 'required'; |
|
| 650 | + } |
|
| 651 | + if ($placeholder != '') { |
|
| 652 | + $data['placeholder'] = $placeholder; |
|
| 653 | + } |
|
| 654 | + if (!empty($attributes)) { |
|
| 655 | + array_merge($data, $attributes); |
|
| 656 | + } |
|
| 620 | 657 | |
| 621 | 658 | |
| 622 | 659 | // Saving data to object |
@@ -624,7 +661,9 @@ discard block |
||
| 624 | 661 | 'type' => 'input', |
| 625 | 662 | 'data' => $data |
| 626 | 663 | ); |
| 627 | - if ($label != '') $content['label'] = $label; |
|
| 664 | + if ($label != '') { |
|
| 665 | + $content['label'] = $label; |
|
| 666 | + } |
|
| 628 | 667 | |
| 629 | 668 | $this->content[] = $content; |
| 630 | 669 | } |
@@ -651,19 +690,33 @@ discard block |
||
| 651 | 690 | ); |
| 652 | 691 | |
| 653 | 692 | |
| 654 | - if ($required) $data['required'] = 'required'; |
|
| 655 | - if ($min) $data['min'] = $min; |
|
| 656 | - if ($max) $data['max'] = $max; |
|
| 657 | - if ($step) $data['step'] = $step; |
|
| 658 | - if ($placeholder != '') $data['placeholder'] = $placeholder; |
|
| 659 | - if (!empty($attributes)) array_merge($data, $attributes); |
|
| 693 | + if ($required) { |
|
| 694 | + $data['required'] = 'required'; |
|
| 695 | + } |
|
| 696 | + if ($min) { |
|
| 697 | + $data['min'] = $min; |
|
| 698 | + } |
|
| 699 | + if ($max) { |
|
| 700 | + $data['max'] = $max; |
|
| 701 | + } |
|
| 702 | + if ($step) { |
|
| 703 | + $data['step'] = $step; |
|
| 704 | + } |
|
| 705 | + if ($placeholder != '') { |
|
| 706 | + $data['placeholder'] = $placeholder; |
|
| 707 | + } |
|
| 708 | + if (!empty($attributes)) { |
|
| 709 | + array_merge($data, $attributes); |
|
| 710 | + } |
|
| 660 | 711 | |
| 661 | 712 | // Saving data to object |
| 662 | 713 | $content = array( |
| 663 | 714 | 'type' => 'input', |
| 664 | 715 | 'data' => $data |
| 665 | 716 | ); |
| 666 | - if ($label != '') $content['label'] = $label; |
|
| 717 | + if ($label != '') { |
|
| 718 | + $content['label'] = $label; |
|
| 719 | + } |
|
| 667 | 720 | |
| 668 | 721 | $this->content[] = $content; |
| 669 | 722 | } |
@@ -688,19 +741,33 @@ discard block |
||
| 688 | 741 | 'value' => $value, |
| 689 | 742 | ); |
| 690 | 743 | |
| 691 | - if ($required) $data['required'] = 'required'; |
|
| 692 | - if ($min) $data['min'] = $min; |
|
| 693 | - if ($max) $data['max'] = $max; |
|
| 694 | - if ($step) $data['step'] = $step; |
|
| 695 | - if ($placeholder != '') $data['placeholder'] = $placeholder; |
|
| 696 | - if (!empty($attributes)) array_merge($data, $attributes); |
|
| 744 | + if ($required) { |
|
| 745 | + $data['required'] = 'required'; |
|
| 746 | + } |
|
| 747 | + if ($min) { |
|
| 748 | + $data['min'] = $min; |
|
| 749 | + } |
|
| 750 | + if ($max) { |
|
| 751 | + $data['max'] = $max; |
|
| 752 | + } |
|
| 753 | + if ($step) { |
|
| 754 | + $data['step'] = $step; |
|
| 755 | + } |
|
| 756 | + if ($placeholder != '') { |
|
| 757 | + $data['placeholder'] = $placeholder; |
|
| 758 | + } |
|
| 759 | + if (!empty($attributes)) { |
|
| 760 | + array_merge($data, $attributes); |
|
| 761 | + } |
|
| 697 | 762 | |
| 698 | 763 | // Saving data to object |
| 699 | 764 | $content = array( |
| 700 | 765 | 'type' => 'input', |
| 701 | 766 | 'data' => $data |
| 702 | 767 | ); |
| 703 | - if ($label != '') $content['label'] = $label; |
|
| 768 | + if ($label != '') { |
|
| 769 | + $content['label'] = $label; |
|
| 770 | + } |
|
| 704 | 771 | |
| 705 | 772 | $this->content[] = $content; |
| 706 | 773 | } |
@@ -721,14 +788,20 @@ discard block |
||
| 721 | 788 | 'name' => $name, |
| 722 | 789 | 'value' => $value |
| 723 | 790 | ); |
| 724 | - if ($required) $data['required'] = 'required'; |
|
| 725 | - if (!empty($attributes)) array_merge($data, $attributes); |
|
| 791 | + if ($required) { |
|
| 792 | + $data['required'] = 'required'; |
|
| 793 | + } |
|
| 794 | + if (!empty($attributes)) { |
|
| 795 | + array_merge($data, $attributes); |
|
| 796 | + } |
|
| 726 | 797 | |
| 727 | 798 | $content = array( |
| 728 | 799 | 'type' => 'input', |
| 729 | 800 | 'data' => $data |
| 730 | 801 | ); |
| 731 | - if ($label != '') $content['label'] = $label; |
|
| 802 | + if ($label != '') { |
|
| 803 | + $content['label'] = $label; |
|
| 804 | + } |
|
| 732 | 805 | |
| 733 | 806 | $this->content[] = $content; |
| 734 | 807 | } |
@@ -746,13 +819,19 @@ discard block |
||
| 746 | 819 | * @param array $attributes Optional atributes not listened (in array). This will be applicated to all radioButton |
| 747 | 820 | */ |
| 748 | 821 | public function addRadio($label = '', $name = '', $values = array(), $selected = null, $required = false, $attributes = array()) { |
| 749 | - if (!is_array($values)) die('FATAL ERROR: Trying to create "RadioButton" with string VALUE, is requried use ARRAY()'); |
|
| 822 | + if (!is_array($values)) { |
|
| 823 | + die('FATAL ERROR: Trying to create "RadioButton" with string VALUE, is requried use ARRAY()'); |
|
| 824 | + } |
|
| 750 | 825 | $data = array( |
| 751 | 826 | 'name' => $name, |
| 752 | 827 | ); |
| 753 | 828 | |
| 754 | - if ($required) $data['required'] = 'required'; |
|
| 755 | - if (!empty($attributes)) array_merge($data, $attributes); |
|
| 829 | + if ($required) { |
|
| 830 | + $data['required'] = 'required'; |
|
| 831 | + } |
|
| 832 | + if (!empty($attributes)) { |
|
| 833 | + array_merge($data, $attributes); |
|
| 834 | + } |
|
| 756 | 835 | |
| 757 | 836 | |
| 758 | 837 | |
@@ -762,7 +841,9 @@ discard block |
||
| 762 | 841 | 'values' => $values, |
| 763 | 842 | 'selected' => $selected |
| 764 | 843 | ); |
| 765 | - if ($label != '') $content['label'] = $label; |
|
| 844 | + if ($label != '') { |
|
| 845 | + $content['label'] = $label; |
|
| 846 | + } |
|
| 766 | 847 | |
| 767 | 848 | $this->content[] = $content; |
| 768 | 849 | } |
@@ -783,9 +864,15 @@ discard block |
||
| 783 | 864 | 'name' => $name, |
| 784 | 865 | 'required' => $required, |
| 785 | 866 | ); |
| 786 | - if ($required) $data['required'] = 'required'; |
|
| 787 | - if ($multiple) $data['multiple'] = 'multiple'; |
|
| 788 | - if (!empty($attributes)) array_merge($data, $attributes); |
|
| 867 | + if ($required) { |
|
| 868 | + $data['required'] = 'required'; |
|
| 869 | + } |
|
| 870 | + if ($multiple) { |
|
| 871 | + $data['multiple'] = 'multiple'; |
|
| 872 | + } |
|
| 873 | + if (!empty($attributes)) { |
|
| 874 | + array_merge($data, $attributes); |
|
| 875 | + } |
|
| 789 | 876 | |
| 790 | 877 | |
| 791 | 878 | // In this case, the values are saved in the main of array to speed up select loader |
@@ -795,7 +882,9 @@ discard block |
||
| 795 | 882 | 'values' => $values, |
| 796 | 883 | 'selected' => $selected |
| 797 | 884 | ); |
| 798 | - if ($label != '') $content['label'] = $label; |
|
| 885 | + if ($label != '') { |
|
| 886 | + $content['label'] = $label; |
|
| 887 | + } |
|
| 799 | 888 | |
| 800 | 889 | $this->content[] = $content; |
| 801 | 890 | } |
@@ -813,7 +902,9 @@ discard block |
||
| 813 | 902 | 'name' => $name, |
| 814 | 903 | 'value' => $value |
| 815 | 904 | ); |
| 816 | - if (!empty($attributes)) array_merge($data, $attributes); |
|
| 905 | + if (!empty($attributes)) { |
|
| 906 | + array_merge($data, $attributes); |
|
| 907 | + } |
|
| 817 | 908 | |
| 818 | 909 | $this->content[] = array( |
| 819 | 910 | 'type' => 'input', |
@@ -836,7 +927,9 @@ discard block |
||
| 836 | 927 | 'value' => $value, |
| 837 | 928 | 'onClick' => $onClick |
| 838 | 929 | ); |
| 839 | - if (!empty($attributes)) array_merge($data, $attributes); |
|
| 930 | + if (!empty($attributes)) { |
|
| 931 | + array_merge($data, $attributes); |
|
| 932 | + } |
|
| 840 | 933 | |
| 841 | 934 | $this->content[] = array( |
| 842 | 935 | 'type' => 'input', |
@@ -858,8 +951,12 @@ discard block |
||
| 858 | 951 | 'name' => $name, |
| 859 | 952 | ); |
| 860 | 953 | |
| 861 | - if ($required) $data['required'] = 'required'; |
|
| 862 | - if (!empty($attributes)) array_merge($data, $attributes); |
|
| 954 | + if ($required) { |
|
| 955 | + $data['required'] = 'required'; |
|
| 956 | + } |
|
| 957 | + if (!empty($attributes)) { |
|
| 958 | + array_merge($data, $attributes); |
|
| 959 | + } |
|
| 863 | 960 | |
| 864 | 961 | // Saving data to object |
| 865 | 962 | $content = array( |
@@ -867,7 +964,9 @@ discard block |
||
| 867 | 964 | 'text' => $value, |
| 868 | 965 | 'data' => $data |
| 869 | 966 | ); |
| 870 | - if ($label != '') $content['label'] = $label; |
|
| 967 | + if ($label != '') { |
|
| 968 | + $content['label'] = $label; |
|
| 969 | + } |
|
| 871 | 970 | |
| 872 | 971 | $this->content[] = $content; |
| 873 | 972 | } |
@@ -885,18 +984,26 @@ discard block |
||
| 885 | 984 | if ($this->logErrors) { |
| 886 | 985 | // Try to get a name (label or name) |
| 887 | 986 | if (class_exists('kw')) { |
| 888 | - if (isset($data['label'])) $this->errors .= 'Found an error in field' . ': "' . $data['label'] . '": '; |
|
| 889 | - elseif (isset($data['name'])) $this->errors .= 'Found an error in field' . ': "' . $data['name'] . '": '; |
|
| 987 | + if (isset($data['label'])) { |
|
| 988 | + $this->errors .= 'Found an error in field' . ': "' . $data['label'] . '": '; |
|
| 989 | + } elseif (isset($data['name'])) { |
|
| 990 | + $this->errors .= 'Found an error in field' . ': "' . $data['name'] . '": '; |
|
| 991 | + } |
|
| 890 | 992 | } else { |
| 891 | - if (isset($data['label'])) $this->errors .= 'Found an error in field' . $data['label'] . '": '; |
|
| 892 | - elseif (isset($data['name'])) $this->errors .= 'Found an error in field' . ': "' . $data['name'] . '": '; |
|
| 993 | + if (isset($data['label'])) { |
|
| 994 | + $this->errors .= 'Found an error in field' . $data['label'] . '": '; |
|
| 995 | + } elseif (isset($data['name'])) { |
|
| 996 | + $this->errors .= 'Found an error in field' . ': "' . $data['name'] . '": '; |
|
| 997 | + } |
|
| 893 | 998 | } |
| 894 | 999 | |
| 895 | 1000 | // preparing message |
| 896 | 1001 | $this->errors .= ' ' . $message . '.'; |
| 897 | 1002 | |
| 898 | 1003 | // Extra message (title attribute) |
| 899 | - if (isset($data['title']) and $data['title'] != '') $this->errors .= ' | '. 'MESSAGE' .': ' . $data['title']; |
|
| 1004 | + if (isset($data['title']) and $data['title'] != '') { |
|
| 1005 | + $this->errors .= ' | '. 'MESSAGE' .': ' . $data['title']; |
|
| 1006 | + } |
|
| 900 | 1007 | |
| 901 | 1008 | $this->errors .= '<br />'; |
| 902 | 1009 | } |
@@ -189,35 +189,55 @@ discard block |
||
| 189 | 189 | $start = $cur_page - $this->max_links; |
| 190 | 190 | $end = $cur_page + $this->max_links; |
| 191 | 191 | |
| 192 | - if ($start < 1) $start = 1; |
|
| 193 | - if ($end > $this->total_pages) $end = $this->total_pages; |
|
| 192 | + if ($start < 1) { |
|
| 193 | + $start = 1; |
|
| 194 | + } |
|
| 195 | + if ($end > $this->total_pages) { |
|
| 196 | + $end = $this->total_pages; |
|
| 197 | + } |
|
| 194 | 198 | |
| 195 | 199 | // Showing all clickable pages (create div if class is defined) |
| 196 | - if ($this->style != '') $r = '<div class="'.$this->style.'">'; |
|
| 197 | - else $r = ''; |
|
| 200 | + if ($this->style != '') { |
|
| 201 | + $r = '<div class="'.$this->style.'">'; |
|
| 202 | + } else { |
|
| 203 | + $r = ''; |
|
| 204 | + } |
|
| 198 | 205 | |
| 199 | 206 | |
| 200 | 207 | // First / previous |
| 201 | 208 | if ($this->cur_page > 1) { |
| 202 | - if ($this->first != '') $r .= '<a class="first" href="' . $url_start . '1' . $url_end . '">'.$this->first.'</a> '; |
|
| 203 | - if ($this->previous != '') $r .= '<a class="previous" href="' . $url_start . ($cur_page - 1) . $url_end . '">'.$this->previous.'</a> '; |
|
| 209 | + if ($this->first != '') { |
|
| 210 | + $r .= '<a class="first" href="' . $url_start . '1' . $url_end . '">'.$this->first.'</a> '; |
|
| 211 | + } |
|
| 212 | + if ($this->previous != '') { |
|
| 213 | + $r .= '<a class="previous" href="' . $url_start . ($cur_page - 1) . $url_end . '">'.$this->previous.'</a> '; |
|
| 214 | + } |
|
| 204 | 215 | } |
| 205 | 216 | |
| 206 | 217 | // You can optimize this separating BEFORE and AFTER current page in two for (to avoid load "if" in each loop) |
| 207 | 218 | // but it would be difficult on changes |
| 208 | 219 | for ($n=$start; $n<=$end; $n++) { |
| 209 | - if ($n != $cur_page) $r .= '<a class="link" href="'. $url_start . $n . $url_end . '">'.$n.'</a> '; |
|
| 210 | - else $r .= '<a class="current">'.$n.'</a> '; |
|
| 220 | + if ($n != $cur_page) { |
|
| 221 | + $r .= '<a class="link" href="'. $url_start . $n . $url_end . '">'.$n.'</a> '; |
|
| 222 | + } else { |
|
| 223 | + $r .= '<a class="current">'.$n.'</a> '; |
|
| 224 | + } |
|
| 211 | 225 | } |
| 212 | 226 | |
| 213 | 227 | // next / last |
| 214 | 228 | if ($this->cur_page < $this->total_pages) { |
| 215 | - if ($this->next != '') $r .= '<a class="next" href="' . $url_start . ($cur_page + 1) . $url_end . '">'.$this->next.'</a> '; |
|
| 216 | - if ($this->last != '') $r .= '<a class="last" href="' . $url_start . $this->total_pages . $url_end .'">'.$this->last.'</a> '; |
|
| 229 | + if ($this->next != '') { |
|
| 230 | + $r .= '<a class="next" href="' . $url_start . ($cur_page + 1) . $url_end . '">'.$this->next.'</a> '; |
|
| 231 | + } |
|
| 232 | + if ($this->last != '') { |
|
| 233 | + $r .= '<a class="last" href="' . $url_start . $this->total_pages . $url_end .'">'.$this->last.'</a> '; |
|
| 234 | + } |
|
| 217 | 235 | } |
| 218 | 236 | |
| 219 | 237 | // End div (if exist) |
| 220 | - if ($this->style != '') $r .= '</div>'; |
|
| 238 | + if ($this->style != '') { |
|
| 239 | + $r .= '</div>'; |
|
| 240 | + } |
|
| 221 | 241 | |
| 222 | 242 | return $r; |
| 223 | 243 | } |
@@ -234,7 +254,9 @@ discard block |
||
| 234 | 254 | $this->original_page = $cur_page; |
| 235 | 255 | |
| 236 | 256 | // Filter values |
| 237 | - if (!is_numeric($cur_page) or $cur_page < 1) $cur_page = 1; |
|
| 257 | + if (!is_numeric($cur_page) or $cur_page < 1) { |
|
| 258 | + $cur_page = 1; |
|
| 259 | + } |
|
| 238 | 260 | |
| 239 | 261 | // Set new filtered values (is faster this method) |
| 240 | 262 | $this->cur_page = $cur_page; |
@@ -253,14 +275,17 @@ discard block |
||
| 253 | 275 | $records = $this->records; |
| 254 | 276 | |
| 255 | 277 | // Force maxium records loaded (only if is specified by user) |
| 256 | - if ($max_records > 0 and $max_records > $total_records) |
|
| 257 | - $this->total_records = $max_records; |
|
| 278 | + if ($max_records > 0 and $max_records > $total_records) { |
|
| 279 | + $this->total_records = $max_records; |
|
| 280 | + } |
|
| 258 | 281 | |
| 259 | 282 | // Calculate total pages that have |
| 260 | 283 | $total_pages = ceil($this->total_records / $records); |
| 261 | 284 | |
| 262 | 285 | // Is correct current page? |
| 263 | - if ($this->cur_page > $total_pages) $this->cur_page = $total_pages; |
|
| 286 | + if ($this->cur_page > $total_pages) { |
|
| 287 | + $this->cur_page = $total_pages; |
|
| 288 | + } |
|
| 264 | 289 | $this->total_pages = $total_pages; |
| 265 | 290 | |
| 266 | 291 | // Specify LIMIT to do a query |
@@ -302,8 +327,11 @@ discard block |
||
| 302 | 327 | if (!in_array(substr($query_string[0], -1), array('?', '&'))) { |
| 303 | 328 | // Current string haven't any at end and it isn't "&" or "?" ? |
| 304 | 329 | // If initial string have one character at least it means that not is the first index |
| 305 | - if (isset($query_string[0][0])) $this->url_start = '?'.$query_string[0].'&'; |
|
| 306 | - else $this->url_start = '?'.$query_string[0]; |
|
| 330 | + if (isset($query_string[0][0])) { |
|
| 331 | + $this->url_start = '?'.$query_string[0].'&'; |
|
| 332 | + } else { |
|
| 333 | + $this->url_start = '?'.$query_string[0]; |
|
| 334 | + } |
|
| 307 | 335 | } else { |
| 308 | 336 | // Current string already have ? or &, |
| 309 | 337 | $this->url_start = '?'.$query_string[0]; |
@@ -318,10 +346,14 @@ discard block |
||
| 318 | 346 | foreach ($gets as $get) { |
| 319 | 347 | if ($get != $get_name) { |
| 320 | 348 | // Trying to get the GET |
| 321 | - if (isset($_GET[$get])) $tmp .= $get.'='.$_GET[$get].'&'; |
|
| 349 | + if (isset($_GET[$get])) { |
|
| 350 | + $tmp .= $get.'='.$_GET[$get].'&'; |
|
| 351 | + } |
|
| 322 | 352 | } else { |
| 323 | 353 | // Pour the $tmp content to $tmp_start |
| 324 | - if ($tmp_start == '') $tmp_start .= '?'; |
|
| 354 | + if ($tmp_start == '') { |
|
| 355 | + $tmp_start .= '?'; |
|
| 356 | + } |
|
| 325 | 357 | $tmp_start .= $tmp; |
| 326 | 358 | $tmp = ''; |
| 327 | 359 | } |
@@ -332,8 +364,9 @@ discard block |
||
| 332 | 364 | // If have start and end |
| 333 | 365 | $this->url_start = $tmp_start; |
| 334 | 366 | $this->url_end = $tmp; |
| 367 | + } else { |
|
| 368 | + $this->url_start = '?'.$tmp; |
|
| 335 | 369 | } |
| 336 | - else $this->url_start = '?'.$tmp; |
|
| 337 | 370 | } |
| 338 | 371 | } else{ |
| 339 | 372 | // Non recicle |
@@ -79,12 +79,13 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | function obtenerDireccionIP(){ |
| 82 | - if (!empty($_SERVER ['HTTP_CLIENT_IP'] )) |
|
| 83 | - $ip=$_SERVER ['HTTP_CLIENT_IP']; |
|
| 84 | - elseif (!empty($_SERVER ['HTTP_X_FORWARDED_FOR'] )) |
|
| 85 | - $ip=$_SERVER ['HTTP_X_FORWARDED_FOR']; |
|
| 86 | - else |
|
| 87 | - $ip=$_SERVER ['REMOTE_ADDR']; |
|
| 82 | + if (!empty($_SERVER ['HTTP_CLIENT_IP'] )) { |
|
| 83 | + $ip=$_SERVER ['HTTP_CLIENT_IP']; |
|
| 84 | + } elseif (!empty($_SERVER ['HTTP_X_FORWARDED_FOR'] )) { |
|
| 85 | + $ip=$_SERVER ['HTTP_X_FORWARDED_FOR']; |
|
| 86 | + } else { |
|
| 87 | + $ip=$_SERVER ['REMOTE_ADDR']; |
|
| 88 | + } |
|
| 88 | 89 | |
| 89 | 90 | return $ip; |
| 90 | 91 | } |
@@ -94,8 +95,7 @@ discard block |
||
| 94 | 95 | |
| 95 | 96 | if($ipCliente == $ip){ |
| 96 | 97 | return true; |
| 97 | - } |
|
| 98 | - else{ |
|
| 98 | + } else{ |
|
| 99 | 99 | header('location: http://www.tusitioweb/redireccion'); |
| 100 | 100 | exit; |
| 101 | 101 | } |
@@ -106,8 +106,7 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | if (in_array($ipCliente,$ips)){ |
| 108 | 108 | return true; |
| 109 | - } |
|
| 110 | - else{ |
|
| 109 | + } else{ |
|
| 111 | 110 | header('location: http://direccion_envio_salida'); |
| 112 | 111 | exit; |
| 113 | 112 | } |
@@ -118,8 +117,7 @@ discard block |
||
| 118 | 117 | |
| 119 | 118 | if(substr($ipCliente, 0, 8 ) == "150.214."){ |
| 120 | 119 | return true; |
| 121 | - } |
|
| 122 | - else{ |
|
| 120 | + } else{ |
|
| 123 | 121 | header('location: http://direccion_envio_salida'); |
| 124 | 122 | exit; |
| 125 | 123 | } |
@@ -43,15 +43,13 @@ |
||
| 43 | 43 | |
| 44 | 44 | if(is_callable(array($controlador, $metodo))){ |
| 45 | 45 | $metodo = $peticion->getMetodo(); |
| 46 | - } |
|
| 47 | - else{ |
|
| 46 | + } else{ |
|
| 48 | 47 | $metodo = 'index'; |
| 49 | 48 | } |
| 50 | 49 | |
| 51 | 50 | if(isset($args)){ |
| 52 | 51 | call_user_func_array(array($controlador, $metodo), $args); |
| 53 | - } |
|
| 54 | - else{ |
|
| 52 | + } else{ |
|
| 55 | 53 | call_user_func(array($controlador, $metodo)); |
| 56 | 54 | } |
| 57 | 55 | |
@@ -39,8 +39,7 @@ discard block |
||
| 39 | 39 | if(is_readable($rutaLib)){ |
| 40 | 40 | require_once $rutaLib; |
| 41 | 41 | //echo 'libreria cargada'; |
| 42 | - } |
|
| 43 | - else { |
|
| 42 | + } else { |
|
| 44 | 43 | throw new Exception("houston tenemos un problema! al cargar libreria"); |
| 45 | 44 | } |
| 46 | 45 | } |
@@ -53,8 +52,7 @@ discard block |
||
| 53 | 52 | $modelo = new $modelo; |
| 54 | 53 | return $modelo; |
| 55 | 54 | //echo 'modelo cargado'; |
| 56 | - } |
|
| 57 | - else { |
|
| 55 | + } else { |
|
| 58 | 56 | //echo $rutaMod; |
| 59 | 57 | |
| 60 | 58 | |
@@ -68,8 +66,7 @@ discard block |
||
| 68 | 66 | if(is_readable($rutaAyudante)){ |
| 69 | 67 | require_once $rutaAyudante; |
| 70 | 68 | //echo 'libreria cargada'; |
| 71 | - } |
|
| 72 | - else { |
|
| 69 | + } else { |
|
| 73 | 70 | throw new Exception("houston tenemos un problema! al cargar ayudante"); |
| 74 | 71 | } |
| 75 | 72 | } |
@@ -42,8 +42,7 @@ |
||
| 42 | 42 | include_once SITE_ROOT . 'mvc/vistas' . DS . ADICIONALES_VISTA . DS . 'encabezado.php'; |
| 43 | 43 | include_once $ver_ruta; |
| 44 | 44 | include_once SITE_ROOT . 'mvc/vistas' . DS . ADICIONALES_VISTA . DS . 'pie_de_pagina.php'; |
| 45 | - } |
|
| 46 | - else { |
|
| 45 | + } else { |
|
| 47 | 46 | |
| 48 | 47 | header('Location: '. Cf_BASE_URL.'error/index'.'?error='.'vista' ); |
| 49 | 48 | |
@@ -82,7 +82,9 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function log() |
| 84 | 84 | { |
| 85 | - if ( func_num_args() < 1 ) return; |
|
| 85 | + if ( func_num_args() < 1 ) { |
|
| 86 | + return; |
|
| 87 | + } |
|
| 86 | 88 | |
| 87 | 89 | foreach ( func_get_args() as $argument ) { |
| 88 | 90 | if ( is_array( $argument ) ) { |
@@ -100,7 +102,9 @@ discard block |
||
| 100 | 102 | } |
| 101 | 103 | } |
| 102 | 104 | |
| 103 | - if ( $this->mode === self::C_LOGGER_ECHO ) echo "<br>\n"; |
|
| 105 | + if ( $this->mode === self::C_LOGGER_ECHO ) { |
|
| 106 | + echo "<br>\n"; |
|
| 107 | + } |
|
| 104 | 108 | } |
| 105 | 109 | } |
| 106 | 110 | |
@@ -161,7 +165,9 @@ discard block |
||
| 161 | 165 | { |
| 162 | 166 | $found = array(); |
| 163 | 167 | foreach( $this->logs as $logEntry ) { |
| 164 | - if ( strpos( $logEntry, $needle ) !== FALSE ) $found[] = $logEntry; |
|
| 168 | + if ( strpos( $logEntry, $needle ) !== FALSE ) { |
|
| 169 | + $found[] = $logEntry; |
|
| 170 | + } |
|
| 165 | 171 | } |
| 166 | 172 | return $found; |
| 167 | 173 | } |
@@ -231,7 +237,9 @@ discard block |
||
| 231 | 237 | */ |
| 232 | 238 | protected function fillInValue( $value ) |
| 233 | 239 | { |
| 234 | - if ( is_null( $value ) ) $value = 'NULL'; |
|
| 240 | + if ( is_null( $value ) ) { |
|
| 241 | + $value = 'NULL'; |
|
| 242 | + } |
|
| 235 | 243 | |
| 236 | 244 | $value = strval( $value ); |
| 237 | 245 | if ( strlen( $value ) > ( $this->strLen ) ) { |
@@ -257,7 +265,9 @@ discard block |
||
| 257 | 265 | protected function output( $str ) |
| 258 | 266 | { |
| 259 | 267 | $this->logs[] = $str; |
| 260 | - if ( !$this->mode ) echo $str .'<br />'; |
|
| 268 | + if ( !$this->mode ) { |
|
| 269 | + echo $str .'<br />'; |
|
| 270 | + } |
|
| 261 | 271 | } |
| 262 | 272 | |
| 263 | 273 | /** |
@@ -317,7 +327,9 @@ discard block |
||
| 317 | 327 | */ |
| 318 | 328 | public function log() |
| 319 | 329 | { |
| 320 | - if ( func_num_args() < 1 ) return; |
|
| 330 | + if ( func_num_args() < 1 ) { |
|
| 331 | + return; |
|
| 332 | + } |
|
| 321 | 333 | |
| 322 | 334 | $sql = func_get_arg( 0 ); |
| 323 | 335 | |
@@ -684,7 +696,9 @@ discard block |
||
| 684 | 696 | //Unfortunately the code field is supposed to be int by default (php) |
| 685 | 697 | //So we need a property to convey the SQL State code. |
| 686 | 698 | $err = $e->getMessage(); |
| 687 | - if ( $this->loggingEnabled && $this->logger ) $this->logger->log( 'An error occurred: ' . $err ); |
|
| 699 | + if ( $this->loggingEnabled && $this->logger ) { |
|
| 700 | + $this->logger->log( 'An error occurred: ' . $err ); |
|
| 701 | + } |
|
| 688 | 702 | $exception = new SQL( $err, 0 ); |
| 689 | 703 | $exception->setSQLState( $e->getCode() ); |
| 690 | 704 | throw $exception; |
@@ -784,7 +798,9 @@ discard block |
||
| 784 | 798 | */ |
| 785 | 799 | public function connect() |
| 786 | 800 | { |
| 787 | - if ( $this->isConnected ) return; |
|
| 801 | + if ( $this->isConnected ) { |
|
| 802 | + return; |
|
| 803 | + } |
|
| 788 | 804 | try { |
| 789 | 805 | $user = $this->connectInfo['user']; |
| 790 | 806 | $pass = $this->connectInfo['pass']; |
@@ -865,11 +881,19 @@ discard block |
||
| 865 | 881 | { |
| 866 | 882 | $arr = $this->GetAll( $sql, $bindings ); |
| 867 | 883 | $res = NULL; |
| 868 | - if ( !is_array( $arr ) ) return NULL; |
|
| 869 | - if ( count( $arr ) === 0 ) return NULL; |
|
| 884 | + if ( !is_array( $arr ) ) { |
|
| 885 | + return NULL; |
|
| 886 | + } |
|
| 887 | + if ( count( $arr ) === 0 ) { |
|
| 888 | + return NULL; |
|
| 889 | + } |
|
| 870 | 890 | $row1 = array_shift( $arr ); |
| 871 | - if ( !is_array( $row1 ) ) return NULL; |
|
| 872 | - if ( count( $row1 ) === 0 ) return NULL; |
|
| 891 | + if ( !is_array( $row1 ) ) { |
|
| 892 | + return NULL; |
|
| 893 | + } |
|
| 894 | + if ( count( $row1 ) === 0 ) { |
|
| 895 | + return NULL; |
|
| 896 | + } |
|
| 873 | 897 | $col1 = array_shift( $row1 ); |
| 874 | 898 | return $col1; |
| 875 | 899 | } |
@@ -1205,7 +1229,9 @@ discard block |
||
| 1205 | 1229 | && $mode !== self::C_ERR_EXCEPTION |
| 1206 | 1230 | && $mode !== self::C_ERR_FUNC |
| 1207 | 1231 | && $mode !== self::C_ERR_FATAL |
| 1208 | - ) throw new \Exception( 'Invalid error mode selected' ); |
|
| 1232 | + ) { |
|
| 1233 | + throw new \Exception( 'Invalid error mode selected' ); |
|
| 1234 | + } |
|
| 1209 | 1235 | |
| 1210 | 1236 | if ( $mode === self::C_ERR_FUNC && !is_callable( $func ) ) { |
| 1211 | 1237 | throw new \Exception( 'Invalid error handler' ); |
@@ -1322,7 +1348,9 @@ discard block |
||
| 1322 | 1348 | public static function setMetaAll( $beans, $property, $value ) |
| 1323 | 1349 | { |
| 1324 | 1350 | foreach( $beans as $bean ) { |
| 1325 | - if ( $bean instanceof OODBBean ) $bean->__info[ $property ] = $value; |
|
| 1351 | + if ( $bean instanceof OODBBean ) { |
|
| 1352 | + $bean->__info[ $property ] = $value; |
|
| 1353 | + } |
|
| 1326 | 1354 | } |
| 1327 | 1355 | |
| 1328 | 1356 | return $beans; |
@@ -1645,7 +1673,9 @@ discard block |
||
| 1645 | 1673 | |
| 1646 | 1674 | if ( $parents ) { |
| 1647 | 1675 | foreach ( $this as $key => $value ) { |
| 1648 | - if ( substr( $key, -3 ) != '_id' ) continue; |
|
| 1676 | + if ( substr( $key, -3 ) != '_id' ) { |
|
| 1677 | + continue; |
|
| 1678 | + } |
|
| 1649 | 1679 | |
| 1650 | 1680 | $prop = substr( $key, 0, strlen( $key ) - 3 ); |
| 1651 | 1681 | $this->$prop; |
@@ -1659,13 +1689,17 @@ discard block |
||
| 1659 | 1689 | $vn = array(); |
| 1660 | 1690 | |
| 1661 | 1691 | foreach ( $value as $i => $b ) { |
| 1662 | - if ( !( $b instanceof OODBBean ) ) continue; |
|
| 1692 | + if ( !( $b instanceof OODBBean ) ) { |
|
| 1693 | + continue; |
|
| 1694 | + } |
|
| 1663 | 1695 | $vn[] = $b->export( $meta, FALSE, FALSE, $filters ); |
| 1664 | 1696 | $value = $vn; |
| 1665 | 1697 | } |
| 1666 | 1698 | } elseif ( $value instanceof OODBBean ) { |
| 1667 | 1699 | if ( $hasFilters ) { |
| 1668 | - if ( !in_array( strtolower( $value->getMeta( 'type' ) ), $filters ) ) continue; |
|
| 1700 | + if ( !in_array( strtolower( $value->getMeta( 'type' ) ), $filters ) ) { |
|
| 1701 | + continue; |
|
| 1702 | + } |
|
| 1669 | 1703 | } |
| 1670 | 1704 | |
| 1671 | 1705 | $value = $value->export( $meta, $parents, FALSE, $filters ); |
@@ -1728,7 +1762,9 @@ discard block |
||
| 1728 | 1762 | unset( $this->properties[$property] ); |
| 1729 | 1763 | |
| 1730 | 1764 | $shadowKey = 'sys.shadow.'.$property; |
| 1731 | - if ( isset( $this->__info[ $shadowKey ] ) ) unset( $this->__info[$shadowKey] ); |
|
| 1765 | + if ( isset( $this->__info[ $shadowKey ] ) ) { |
|
| 1766 | + unset( $this->__info[$shadowKey] ); |
|
| 1767 | + } |
|
| 1732 | 1768 | |
| 1733 | 1769 | //also clear modifiers |
| 1734 | 1770 | $this->withSql = ''; |
@@ -1895,7 +1931,9 @@ discard block |
||
| 1895 | 1931 | { |
| 1896 | 1932 | static $beautifulColumns = array(); |
| 1897 | 1933 | |
| 1898 | - if ( ctype_lower( $property ) ) return $property; |
|
| 1934 | + if ( ctype_lower( $property ) ) { |
|
| 1935 | + return $property; |
|
| 1936 | + } |
|
| 1899 | 1937 | |
| 1900 | 1938 | if ( |
| 1901 | 1939 | ( strpos( $property, 'own' ) === 0 && ctype_upper( substr( $property, 3, 1 ) ) ) |
@@ -2479,7 +2517,9 @@ discard block |
||
| 2479 | 2517 | } |
| 2480 | 2518 | |
| 2481 | 2519 | if ( !is_null( $maxDepth ) ) { |
| 2482 | - if ( !$maxDepth-- ) return $this; |
|
| 2520 | + if ( !$maxDepth-- ) { |
|
| 2521 | + return $this; |
|
| 2522 | + } |
|
| 2483 | 2523 | } |
| 2484 | 2524 | |
| 2485 | 2525 | $oldFetchType = $this->fetchType; |
@@ -2489,9 +2529,13 @@ discard block |
||
| 2489 | 2529 | |
| 2490 | 2530 | $beans = $this->$property; |
| 2491 | 2531 | |
| 2492 | - if ( $beans === NULL ) return $this; |
|
| 2532 | + if ( $beans === NULL ) { |
|
| 2533 | + return $this; |
|
| 2534 | + } |
|
| 2493 | 2535 | |
| 2494 | - if ( !is_array( $beans ) ) $beans = array( $beans ); |
|
| 2536 | + if ( !is_array( $beans ) ) { |
|
| 2537 | + $beans = array( $beans ); |
|
| 2538 | + } |
|
| 2495 | 2539 | |
| 2496 | 2540 | foreach( $beans as $bean ) { |
| 2497 | 2541 | |
@@ -2641,11 +2685,17 @@ discard block |
||
| 2641 | 2685 | */ |
| 2642 | 2686 | public function hasListChanged( $property ) |
| 2643 | 2687 | { |
| 2644 | - if ( !array_key_exists( $property, $this->properties ) ) return FALSE; |
|
| 2688 | + if ( !array_key_exists( $property, $this->properties ) ) { |
|
| 2689 | + return FALSE; |
|
| 2690 | + } |
|
| 2645 | 2691 | $diffAdded = array_diff_assoc( $this->properties[$property], $this->__info['sys.shadow.'.$property] ); |
| 2646 | - if ( count( $diffAdded ) ) return TRUE; |
|
| 2692 | + if ( count( $diffAdded ) ) { |
|
| 2693 | + return TRUE; |
|
| 2694 | + } |
|
| 2647 | 2695 | $diffMissing = array_diff_assoc( $this->__info['sys.shadow.'.$property], $this->properties[$property] ); |
| 2648 | - if ( count( $diffMissing ) ) return TRUE; |
|
| 2696 | + if ( count( $diffMissing ) ) { |
|
| 2697 | + return TRUE; |
|
| 2698 | + } |
|
| 2649 | 2699 | return FALSE; |
| 2650 | 2700 | } |
| 2651 | 2701 | |
@@ -2856,11 +2906,19 @@ discard block |
||
| 2856 | 2906 | $this->via = NULL; |
| 2857 | 2907 | $ids = $beanIndex = $references = array(); |
| 2858 | 2908 | |
| 2859 | - if ( strlen( $list ) < 4 ) throw new RedException('Invalid own-list.'); |
|
| 2860 | - if ( strpos( $list, 'own') !== 0 ) throw new RedException('Only own-lists can be aggregated.'); |
|
| 2861 | - if ( !ctype_upper( substr( $list, 3, 1 ) ) ) throw new RedException('Invalid own-list.'); |
|
| 2909 | + if ( strlen( $list ) < 4 ) { |
|
| 2910 | + throw new RedException('Invalid own-list.'); |
|
| 2911 | + } |
|
| 2912 | + if ( strpos( $list, 'own') !== 0 ) { |
|
| 2913 | + throw new RedException('Only own-lists can be aggregated.'); |
|
| 2914 | + } |
|
| 2915 | + if ( !ctype_upper( substr( $list, 3, 1 ) ) ) { |
|
| 2916 | + throw new RedException('Invalid own-list.'); |
|
| 2917 | + } |
|
| 2862 | 2918 | |
| 2863 | - if ( is_null( $type ) ) $type = $property; |
|
| 2919 | + if ( is_null( $type ) ) { |
|
| 2920 | + $type = $property; |
|
| 2921 | + } |
|
| 2864 | 2922 | |
| 2865 | 2923 | foreach( $this->$list as $bean ) { |
| 2866 | 2924 | $field = $property . '_id'; |
@@ -3320,7 +3378,9 @@ discard block |
||
| 3320 | 3378 | } |
| 3321 | 3379 | |
| 3322 | 3380 | foreach ( $rows as $row ) { |
| 3323 | - if ( empty( $row ) ) continue; |
|
| 3381 | + if ( empty( $row ) ) { |
|
| 3382 | + continue; |
|
| 3383 | + } |
|
| 3324 | 3384 | |
| 3325 | 3385 | if ( count( $row ) > 2 ) { |
| 3326 | 3386 | $key = array_shift( $row ); |
@@ -3357,7 +3417,9 @@ discard block |
||
| 3357 | 3417 | { |
| 3358 | 3418 | $this->sql = $sql; |
| 3359 | 3419 | |
| 3360 | - if ( !$noSignal ) $this->signal( 'sql_exec', $this ); |
|
| 3420 | + if ( !$noSignal ) { |
|
| 3421 | + $this->signal( 'sql_exec', $this ); |
|
| 3422 | + } |
|
| 3361 | 3423 | |
| 3362 | 3424 | return $this->db->GetOne( $sql, $bindings ); |
| 3363 | 3425 | } |
@@ -4257,7 +4319,9 @@ discard block |
||
| 4257 | 4319 | public static function renameAssociation( $from, $to = NULL ) |
| 4258 | 4320 | { |
| 4259 | 4321 | if ( is_array( $from ) ) { |
| 4260 | - foreach ( $from as $key => $value ) self::$renames[$key] = $value; |
|
| 4322 | + foreach ( $from as $key => $value ) { |
|
| 4323 | + self::$renames[$key] = $value; |
|
| 4324 | + } |
|
| 4261 | 4325 | |
| 4262 | 4326 | return; |
| 4263 | 4327 | } |
@@ -4438,7 +4502,9 @@ discard block |
||
| 4438 | 4502 | private function putResultInCache( $cacheTag, $key, $values ) |
| 4439 | 4503 | { |
| 4440 | 4504 | if ( isset( $this->cache[$cacheTag] ) ) { |
| 4441 | - if ( count( $this->cache[$cacheTag] ) > $this->maxCacheSizePerType ) array_shift( $this->cache[$cacheTag] ); |
|
| 4505 | + if ( count( $this->cache[$cacheTag] ) > $this->maxCacheSizePerType ) { |
|
| 4506 | + array_shift( $this->cache[$cacheTag] ); |
|
| 4507 | + } |
|
| 4442 | 4508 | } else { |
| 4443 | 4509 | $this->cache[$cacheTag] = array(); |
| 4444 | 4510 | } |
@@ -4470,12 +4536,16 @@ discard block |
||
| 4470 | 4536 | |
| 4471 | 4537 | $sqlConditions = array(); |
| 4472 | 4538 | foreach ( $conditions as $column => $values ) { |
| 4473 | - if ( !count( $values ) ) continue; |
|
| 4539 | + if ( !count( $values ) ) { |
|
| 4540 | + continue; |
|
| 4541 | + } |
|
| 4474 | 4542 | |
| 4475 | 4543 | $sql = $this->esc( $column ); |
| 4476 | 4544 | $sql .= ' IN ( '; |
| 4477 | 4545 | |
| 4478 | - if ( !is_array( $values ) ) $values = array( $values ); |
|
| 4546 | + if ( !is_array( $values ) ) { |
|
| 4547 | + $values = array( $values ); |
|
| 4548 | + } |
|
| 4479 | 4549 | |
| 4480 | 4550 | // If it's safe to skip bindings, do so... |
| 4481 | 4551 | if ( ctype_digit( implode( '', $values ) ) ) { |
@@ -4516,7 +4586,9 @@ discard block |
||
| 4516 | 4586 | $sql = implode( ' AND ', $sqlConditions ); |
| 4517 | 4587 | $sql = " WHERE ( $sql ) "; |
| 4518 | 4588 | |
| 4519 | - if ( $addSql ) $sql .= $addSql; |
|
| 4589 | + if ( $addSql ) { |
|
| 4590 | + $sql .= $addSql; |
|
| 4591 | + } |
|
| 4520 | 4592 | } elseif ( $addSql ) { |
| 4521 | 4593 | $sql = $addSql; |
| 4522 | 4594 | } |
@@ -4570,7 +4642,9 @@ discard block |
||
| 4570 | 4642 | } |
| 4571 | 4643 | |
| 4572 | 4644 | foreach( $map as $key ) { |
| 4573 | - if ( $key['from'] === $property ) return $key; |
|
| 4645 | + if ( $key['from'] === $property ) { |
|
| 4646 | + return $key; |
|
| 4647 | + } |
|
| 4574 | 4648 | } |
| 4575 | 4649 | return NULL; |
| 4576 | 4650 | } |
@@ -4781,7 +4855,9 @@ discard block |
||
| 4781 | 4855 | $result = $this->adapter->getCell( "INSERT INTO $table (id) VALUES($default) $suffix" ); |
| 4782 | 4856 | } |
| 4783 | 4857 | |
| 4784 | - if ( $suffix ) return $result; |
|
| 4858 | + if ( $suffix ) { |
|
| 4859 | + return $result; |
|
| 4860 | + } |
|
| 4785 | 4861 | |
| 4786 | 4862 | $last_id = $this->adapter->getInsertID(); |
| 4787 | 4863 | |
@@ -4939,8 +5015,9 @@ discard block |
||
| 4939 | 5015 | */ |
| 4940 | 5016 | public function writeJoin( $type, $targetType, $leftRight = 'LEFT' ) |
| 4941 | 5017 | { |
| 4942 | - if ( $leftRight !== 'LEFT' && $leftRight !== 'RIGHT' && $leftRight !== 'INNER' ) |
|
| 4943 | - throw new RedException( 'Invalid JOIN.' ); |
|
| 5018 | + if ( $leftRight !== 'LEFT' && $leftRight !== 'RIGHT' && $leftRight !== 'INNER' ) { |
|
| 5019 | + throw new RedException( 'Invalid JOIN.' ); |
|
| 5020 | + } |
|
| 4944 | 5021 | |
| 4945 | 5022 | $table = $this->esc( $type ); |
| 4946 | 5023 | $targetTable = $this->esc( $targetType ); |
@@ -5209,7 +5286,9 @@ discard block |
||
| 5209 | 5286 | */ |
| 5210 | 5287 | public function widenColumn( $type, $property, $dataType ) |
| 5211 | 5288 | { |
| 5212 | - if ( !isset($this->typeno_sqltype[$dataType]) ) return FALSE; |
|
| 5289 | + if ( !isset($this->typeno_sqltype[$dataType]) ) { |
|
| 5290 | + return FALSE; |
|
| 5291 | + } |
|
| 5213 | 5292 | |
| 5214 | 5293 | $table = $this->esc( $type ); |
| 5215 | 5294 | $column = $this->esc( $property ); |
@@ -5316,7 +5395,9 @@ discard block |
||
| 5316 | 5395 | foreach( $keys as $key ) { |
| 5317 | 5396 | if ( |
| 5318 | 5397 | $key['from'] === $field |
| 5319 | - ) return $key['table']; |
|
| 5398 | + ) { |
|
| 5399 | + return $key['table']; |
|
| 5400 | + } |
|
| 5320 | 5401 | } |
| 5321 | 5402 | return NULL; |
| 5322 | 5403 | } |
@@ -5512,8 +5593,12 @@ discard block |
||
| 5512 | 5593 | { |
| 5513 | 5594 | $this->svalue = $value; |
| 5514 | 5595 | |
| 5515 | - if ( is_null( $value ) ) return MySQL::C_DATATYPE_BOOL; |
|
| 5516 | - if ( $value === INF ) return MySQL::C_DATATYPE_TEXT7; |
|
| 5596 | + if ( is_null( $value ) ) { |
|
| 5597 | + return MySQL::C_DATATYPE_BOOL; |
|
| 5598 | + } |
|
| 5599 | + if ( $value === INF ) { |
|
| 5600 | + return MySQL::C_DATATYPE_TEXT7; |
|
| 5601 | + } |
|
| 5517 | 5602 | |
| 5518 | 5603 | if ( $flagSpecial ) { |
| 5519 | 5604 | if ( preg_match( '/^\d{4}\-\d\d-\d\d$/', $value ) ) { |
@@ -5538,7 +5623,9 @@ discard block |
||
| 5538 | 5623 | return MySQL::C_DATATYPE_BOOL; |
| 5539 | 5624 | } |
| 5540 | 5625 | |
| 5541 | - if ( is_float( $value ) ) return self::C_DATATYPE_DOUBLE; |
|
| 5626 | + if ( is_float( $value ) ) { |
|
| 5627 | + return self::C_DATATYPE_DOUBLE; |
|
| 5628 | + } |
|
| 5542 | 5629 | |
| 5543 | 5630 | if ( !$this->startsWithZeros( $value ) ) { |
| 5544 | 5631 | |
@@ -5595,7 +5682,9 @@ discard block |
||
| 5595 | 5682 | { |
| 5596 | 5683 | $tableNoQ = $this->esc( $type, TRUE ); |
| 5597 | 5684 | $columns = array(); |
| 5598 | - foreach( $properties as $key => $column ) $columns[$key] = $this->esc( $column ); |
|
| 5685 | + foreach( $properties as $key => $column ) { |
|
| 5686 | + $columns[$key] = $this->esc( $column ); |
|
| 5687 | + } |
|
| 5599 | 5688 | $table = $this->esc( $type ); |
| 5600 | 5689 | sort( $columns ); // Else we get multiple indexes due to order-effects |
| 5601 | 5690 | $name = 'UQ_' . sha1( implode( ',', $columns ) ); |
@@ -5640,7 +5729,9 @@ discard block |
||
| 5640 | 5729 | $targetFieldNoQ = $this->esc( $targetProperty, TRUE ); |
| 5641 | 5730 | $tableNoQ = $this->esc( $type, TRUE ); |
| 5642 | 5731 | $fieldNoQ = $this->esc( $property, TRUE ); |
| 5643 | - if ( !is_null( $this->getForeignKeyForTypeProperty( $tableNoQ, $fieldNoQ ) ) ) return FALSE; |
|
| 5732 | + if ( !is_null( $this->getForeignKeyForTypeProperty( $tableNoQ, $fieldNoQ ) ) ) { |
|
| 5733 | + return FALSE; |
|
| 5734 | + } |
|
| 5644 | 5735 | |
| 5645 | 5736 | //Widen the column if it's incapable of representing a foreign key (at least INT). |
| 5646 | 5737 | $columns = $this->getColumns( $tableNoQ ); |
@@ -5792,7 +5883,9 @@ discard block |
||
| 5792 | 5883 | |
| 5793 | 5884 | $oldColumnNames = array_keys( $this->getColumns( $table ) ); |
| 5794 | 5885 | |
| 5795 | - foreach ( $oldColumnNames as $k => $v ) $oldColumnNames[$k] = "`$v`"; |
|
| 5886 | + foreach ( $oldColumnNames as $k => $v ) { |
|
| 5887 | + $oldColumnNames[$k] = "`$v`"; |
|
| 5888 | + } |
|
| 5796 | 5889 | |
| 5797 | 5890 | $q[] = "CREATE TEMPORARY TABLE tmp_backup(" . implode( ",", $oldColumnNames ) . ");"; |
| 5798 | 5891 | $q[] = "INSERT INTO tmp_backup SELECT * FROM `$table`;"; |
@@ -5818,16 +5911,22 @@ discard block |
||
| 5818 | 5911 | foreach ( $tableMap['indexes'] as $name => $index ) { |
| 5819 | 5912 | if ( strpos( $name, 'UQ_' ) === 0 ) { |
| 5820 | 5913 | $cols = explode( '__', substr( $name, strlen( 'UQ_' . $table ) ) ); |
| 5821 | - foreach ( $cols as $k => $v ) $cols[$k] = "`$v`"; |
|
| 5914 | + foreach ( $cols as $k => $v ) { |
|
| 5915 | + $cols[$k] = "`$v`"; |
|
| 5916 | + } |
|
| 5822 | 5917 | $q[] = "CREATE UNIQUE INDEX $name ON `$table` (" . implode( ',', $cols ) . ")"; |
| 5823 | - } else $q[] = "CREATE INDEX $name ON `$table` ({$index['name']}) "; |
|
| 5918 | + } else { |
|
| 5919 | + $q[] = "CREATE INDEX $name ON `$table` ({$index['name']}) "; |
|
| 5920 | + } |
|
| 5824 | 5921 | } |
| 5825 | 5922 | |
| 5826 | 5923 | $q[] = "INSERT INTO `$table` SELECT * FROM tmp_backup;"; |
| 5827 | 5924 | $q[] = "DROP TABLE tmp_backup;"; |
| 5828 | 5925 | $q[] = "PRAGMA foreign_keys = 1 "; |
| 5829 | 5926 | |
| 5830 | - foreach ( $q as $sq ) $this->adapter->exec( $sq ); |
|
| 5927 | + foreach ( $q as $sq ) { |
|
| 5928 | + $this->adapter->exec( $sq ); |
|
| 5929 | + } |
|
| 5831 | 5930 | } |
| 5832 | 5931 | |
| 5833 | 5932 | /** |
@@ -5874,9 +5973,13 @@ discard block |
||
| 5874 | 5973 | $targetColumn = $this->esc( $targetProperty, TRUE ); |
| 5875 | 5974 | |
| 5876 | 5975 | $tables = $this->getTables(); |
| 5877 | - if ( !in_array( $targetTable, $tables ) ) return FALSE; |
|
| 5976 | + if ( !in_array( $targetTable, $tables ) ) { |
|
| 5977 | + return FALSE; |
|
| 5978 | + } |
|
| 5878 | 5979 | |
| 5879 | - if ( !is_null( $this->getForeignKeyForTypeProperty( $table, $column ) ) ) return FALSE; |
|
| 5980 | + if ( !is_null( $this->getForeignKeyForTypeProperty( $table, $column ) ) ) { |
|
| 5981 | + return FALSE; |
|
| 5982 | + } |
|
| 5880 | 5983 | $t = $this->getTable( $table ); |
| 5881 | 5984 | $consSQL = ( $constraint ? 'CASCADE' : 'SET NULL' ); |
| 5882 | 5985 | $label = 'from_' . $column . '_to_table_' . $targetTable . '_col_' . $targetColumn; |
@@ -5953,14 +6056,24 @@ discard block |
||
| 5953 | 6056 | { |
| 5954 | 6057 | $this->svalue = $value; |
| 5955 | 6058 | |
| 5956 | - if ( $value === NULL ) return self::C_DATATYPE_INTEGER; |
|
| 5957 | - if ( $value === INF ) return self::C_DATATYPE_TEXT; |
|
| 6059 | + if ( $value === NULL ) { |
|
| 6060 | + return self::C_DATATYPE_INTEGER; |
|
| 6061 | + } |
|
| 6062 | + if ( $value === INF ) { |
|
| 6063 | + return self::C_DATATYPE_TEXT; |
|
| 6064 | + } |
|
| 5958 | 6065 | |
| 5959 | - if ( $this->startsWithZeros( $value ) ) return self::C_DATATYPE_TEXT; |
|
| 6066 | + if ( $this->startsWithZeros( $value ) ) { |
|
| 6067 | + return self::C_DATATYPE_TEXT; |
|
| 6068 | + } |
|
| 5960 | 6069 | |
| 5961 | - if ( $value === TRUE || $value === FALSE ) return self::C_DATATYPE_INTEGER; |
|
| 6070 | + if ( $value === TRUE || $value === FALSE ) { |
|
| 6071 | + return self::C_DATATYPE_INTEGER; |
|
| 6072 | + } |
|
| 5962 | 6073 | |
| 5963 | - if ( is_numeric( $value ) && ( intval( $value ) == $value ) && $value < 2147483648 && $value > -2147483648 ) return self::C_DATATYPE_INTEGER; |
|
| 6074 | + if ( is_numeric( $value ) && ( intval( $value ) == $value ) && $value < 2147483648 && $value > -2147483648 ) { |
|
| 6075 | + return self::C_DATATYPE_INTEGER; |
|
| 6076 | + } |
|
| 5964 | 6077 | |
| 5965 | 6078 | if ( ( is_numeric( $value ) && $value < 2147483648 && $value > -2147483648) |
| 5966 | 6079 | || preg_match( '/\d{4}\-\d\d\-\d\d/', $value ) |
@@ -6037,7 +6150,9 @@ discard block |
||
| 6037 | 6150 | $columnsRaw = $this->adapter->get( "PRAGMA table_info('$table')" ); |
| 6038 | 6151 | |
| 6039 | 6152 | $columns = array(); |
| 6040 | - foreach ( $columnsRaw as $r ) $columns[$r['name']] = $r['type']; |
|
| 6153 | + foreach ( $columnsRaw as $r ) { |
|
| 6154 | + $columns[$r['name']] = $r['type']; |
|
| 6155 | + } |
|
| 6041 | 6156 | |
| 6042 | 6157 | return $columns; |
| 6043 | 6158 | } |
@@ -6078,7 +6193,9 @@ discard block |
||
| 6078 | 6193 | public function addIndex( $type, $name, $column ) |
| 6079 | 6194 | { |
| 6080 | 6195 | $columns = $this->getColumns( $type ); |
| 6081 | - if ( !isset( $columns[$column] ) ) return FALSE; |
|
| 6196 | + if ( !isset( $columns[$column] ) ) { |
|
| 6197 | + return FALSE; |
|
| 6198 | + } |
|
| 6082 | 6199 | |
| 6083 | 6200 | $table = $this->esc( $type ); |
| 6084 | 6201 | $name = preg_replace( '/\W/', '', $name ); |
@@ -6337,7 +6454,9 @@ discard block |
||
| 6337 | 6454 | { |
| 6338 | 6455 | $this->svalue = $value; |
| 6339 | 6456 | |
| 6340 | - if ( $value === INF ) return self::C_DATATYPE_TEXT; |
|
| 6457 | + if ( $value === INF ) { |
|
| 6458 | + return self::C_DATATYPE_TEXT; |
|
| 6459 | + } |
|
| 6341 | 6460 | |
| 6342 | 6461 | if ( $flagSpecial && $value ) { |
| 6343 | 6462 | if ( preg_match( '/^\d{4}\-\d\d-\d\d$/', $value ) ) { |
@@ -6369,9 +6488,13 @@ discard block |
||
| 6369 | 6488 | } |
| 6370 | 6489 | } |
| 6371 | 6490 | |
| 6372 | - if ( is_float( $value ) ) return self::C_DATATYPE_DOUBLE; |
|
| 6491 | + if ( is_float( $value ) ) { |
|
| 6492 | + return self::C_DATATYPE_DOUBLE; |
|
| 6493 | + } |
|
| 6373 | 6494 | |
| 6374 | - if ( $this->startsWithZeros( $value ) ) return self::C_DATATYPE_TEXT; |
|
| 6495 | + if ( $this->startsWithZeros( $value ) ) { |
|
| 6496 | + return self::C_DATATYPE_TEXT; |
|
| 6497 | + } |
|
| 6375 | 6498 | |
| 6376 | 6499 | if ( $value === FALSE || $value === TRUE || $value === NULL || ( is_numeric( $value ) |
| 6377 | 6500 | && AQueryWriter::canBeTreatedAsInt( $value ) |
@@ -6393,7 +6516,9 @@ discard block |
||
| 6393 | 6516 | { |
| 6394 | 6517 | $r = ( isset( $this->sqltype_typeno[$typedescription] ) ) ? $this->sqltype_typeno[$typedescription] : 99; |
| 6395 | 6518 | |
| 6396 | - if ( $includeSpecials ) return $r; |
|
| 6519 | + if ( $includeSpecials ) { |
|
| 6520 | + return $r; |
|
| 6521 | + } |
|
| 6397 | 6522 | |
| 6398 | 6523 | if ( $r >= QueryWriter::C_DATATYPE_RANGE_SPECIAL ) { |
| 6399 | 6524 | return self::C_DATATYPE_SPECIFIED; |
@@ -6425,7 +6550,9 @@ discard block |
||
| 6425 | 6550 | { |
| 6426 | 6551 | $tableNoQ = $this->esc( $type, TRUE ); |
| 6427 | 6552 | $columns = array(); |
| 6428 | - foreach( $properties as $key => $column ) $columns[$key] = $this->esc( $column ); |
|
| 6553 | + foreach( $properties as $key => $column ) { |
|
| 6554 | + $columns[$key] = $this->esc( $column ); |
|
| 6555 | + } |
|
| 6429 | 6556 | $table = $this->esc( $type ); |
| 6430 | 6557 | sort( $columns ); //else we get multiple indexes due to order-effects |
| 6431 | 6558 | $name = "UQ_" . sha1( $table . implode( ',', $columns ) ); |
@@ -6481,7 +6608,9 @@ discard block |
||
| 6481 | 6608 | $targetField = $this->esc( $targetProperty ); |
| 6482 | 6609 | $tableNoQ = $this->esc( $type, TRUE ); |
| 6483 | 6610 | $fieldNoQ = $this->esc( $property, TRUE ); |
| 6484 | - if ( !is_null( $this->getForeignKeyForTypeProperty( $tableNoQ, $fieldNoQ ) ) ) return FALSE; |
|
| 6611 | + if ( !is_null( $this->getForeignKeyForTypeProperty( $tableNoQ, $fieldNoQ ) ) ) { |
|
| 6612 | + return FALSE; |
|
| 6613 | + } |
|
| 6485 | 6614 | try{ |
| 6486 | 6615 | $delRule = ( $isDep ? 'CASCADE' : 'SET NULL' ); |
| 6487 | 6616 | $this->adapter->exec( "ALTER TABLE {$table} |
@@ -6787,7 +6916,9 @@ discard block |
||
| 6787 | 6916 | |
| 6788 | 6917 | $myFieldLink = $bean->getMeta( 'type' ) . '_id'; |
| 6789 | 6918 | $alias = $bean->getMeta( 'sys.alias.' . $trash->getMeta( 'type' ) ); |
| 6790 | - if ( $alias ) $myFieldLink = $alias . '_id'; |
|
| 6919 | + if ( $alias ) { |
|
| 6920 | + $myFieldLink = $alias . '_id'; |
|
| 6921 | + } |
|
| 6791 | 6922 | |
| 6792 | 6923 | if ( $trash->getMeta( 'sys.garbage' ) === true ) { |
| 6793 | 6924 | $this->trash( $trash ); |
@@ -6864,7 +6995,9 @@ discard block |
||
| 6864 | 6995 | { |
| 6865 | 6996 | $linkField = $property . '_id'; |
| 6866 | 6997 | $id = $this->prepareEmbeddedBean( $value ); |
| 6867 | - if ($bean->$linkField != $id) $bean->$linkField = $id; |
|
| 6998 | + if ($bean->$linkField != $id) { |
|
| 6999 | + $bean->$linkField = $id; |
|
| 7000 | + } |
|
| 6868 | 7001 | $bean->setMeta( 'cast.' . $linkField, 'id' ); |
| 6869 | 7002 | $embeddedBeans[$linkField] = $value; |
| 6870 | 7003 | unset( $bean->$property ); |
@@ -7367,7 +7500,9 @@ discard block |
||
| 7367 | 7500 | |
| 7368 | 7501 | $myFieldLink = $beanType . '_id'; |
| 7369 | 7502 | $alias = $bean->getMeta( 'sys.alias.' . $addition->getMeta( 'type' ) ); |
| 7370 | - if ( $alias ) $myFieldLink = $alias . '_id'; |
|
| 7503 | + if ( $alias ) { |
|
| 7504 | + $myFieldLink = $alias . '_id'; |
|
| 7505 | + } |
|
| 7371 | 7506 | |
| 7372 | 7507 | $addition->$myFieldLink = $bean->id; |
| 7373 | 7508 | $addition->setMeta( 'cast.' . $myFieldLink, 'id' ); |
@@ -7629,7 +7764,9 @@ discard block |
||
| 7629 | 7764 | |
| 7630 | 7765 | $myFieldLink = $beanType . '_id'; |
| 7631 | 7766 | $alias = $bean->getMeta( 'sys.alias.' . $addition->getMeta( 'type' ) ); |
| 7632 | - if ( $alias ) $myFieldLink = $alias . '_id'; |
|
| 7767 | + if ( $alias ) { |
|
| 7768 | + $myFieldLink = $alias . '_id'; |
|
| 7769 | + } |
|
| 7633 | 7770 | |
| 7634 | 7771 | $addition->$myFieldLink = $bean->id; |
| 7635 | 7772 | $addition->setMeta( 'cast.' . $myFieldLink, 'id' ); |
@@ -7948,7 +8085,9 @@ discard block |
||
| 7948 | 8085 | public function dispense( $type, $number = 1, $alwaysReturnArray = FALSE ) |
| 7949 | 8086 | { |
| 7950 | 8087 | if ( $number < 1 ) { |
| 7951 | - if ( $alwaysReturnArray ) return array(); |
|
| 8088 | + if ( $alwaysReturnArray ) { |
|
| 8089 | + return array(); |
|
| 8090 | + } |
|
| 7952 | 8091 | return NULL; |
| 7953 | 8092 | } |
| 7954 | 8093 | |
@@ -8258,8 +8397,12 @@ discard block |
||
| 8258 | 8397 | list( $type, $property ) = explode( '.', $field ); |
| 8259 | 8398 | $mode = ($mode === 'write') ? QueryWriter::C_SQLFILTER_WRITE : QueryWriter::C_SQLFILTER_READ; |
| 8260 | 8399 | |
| 8261 | - if ( !isset( self::$sqlFilters[$mode] ) ) self::$sqlFilters[$mode] = array(); |
|
| 8262 | - if ( !isset( self::$sqlFilters[$mode][$type] ) ) self::$sqlFilters[$mode][$type] = array(); |
|
| 8400 | + if ( !isset( self::$sqlFilters[$mode] ) ) { |
|
| 8401 | + self::$sqlFilters[$mode] = array(); |
|
| 8402 | + } |
|
| 8403 | + if ( !isset( self::$sqlFilters[$mode][$type] ) ) { |
|
| 8404 | + self::$sqlFilters[$mode][$type] = array(); |
|
| 8405 | + } |
|
| 8263 | 8406 | |
| 8264 | 8407 | if ( is_null( $function ) ) { |
| 8265 | 8408 | unset( self::$sqlFilters[$mode][$type][$property] ); |
@@ -8619,7 +8762,9 @@ discard block |
||
| 8619 | 8762 | { |
| 8620 | 8763 | if ( count( $conditions ) > 0 ) { |
| 8621 | 8764 | foreach( $conditions as $key => $condition ) { |
| 8622 | - if ( !count( $condition ) ) unset( $conditions[$key] ); |
|
| 8765 | + if ( !count( $condition ) ) { |
|
| 8766 | + unset( $conditions[$key] ); |
|
| 8767 | + } |
|
| 8623 | 8768 | } |
| 8624 | 8769 | } |
| 8625 | 8770 | |
@@ -8694,7 +8839,9 @@ discard block |
||
| 8694 | 8839 | */ |
| 8695 | 8840 | public function findMulti( $types, $sql, $bindings = array(), $remappings = array(), $queryTemplate = ' %s.%s AS %s__%s' ) |
| 8696 | 8841 | { |
| 8697 | - if ( !is_array( $types ) ) $types = explode( ',', $types ); |
|
| 8842 | + if ( !is_array( $types ) ) { |
|
| 8843 | + $types = explode( ',', $types ); |
|
| 8844 | + } |
|
| 8698 | 8845 | if ( !is_array( $sql ) ) { |
| 8699 | 8846 | $writer = $this->toolbox->getWriter(); |
| 8700 | 8847 | $adapter = $this->toolbox->getDatabaseAdapter(); |
@@ -8732,8 +8879,12 @@ discard block |
||
| 8732 | 8879 | $wannaBean[$property] = $value; |
| 8733 | 8880 | } |
| 8734 | 8881 | } |
| 8735 | - if ( !isset( $wannaBean['id'] ) ) continue; |
|
| 8736 | - if ( is_null( $wannaBean['id'] ) ) continue; |
|
| 8882 | + if ( !isset( $wannaBean['id'] ) ) { |
|
| 8883 | + continue; |
|
| 8884 | + } |
|
| 8885 | + if ( is_null( $wannaBean['id'] ) ) { |
|
| 8886 | + continue; |
|
| 8887 | + } |
|
| 8737 | 8888 | $wannaBeans[$type][$wannaBean['id']] = $wannaBean; |
| 8738 | 8889 | } |
| 8739 | 8890 | } |
@@ -8752,7 +8903,9 @@ discard block |
||
| 8752 | 8903 | $do = $remapping['do']; |
| 8753 | 8904 | foreach( $beans[$a] as $bean ) { |
| 8754 | 8905 | foreach( $beans[$b] as $putBean ) { |
| 8755 | - if ( $matcher( $bean, $putBean, $beans ) ) $do( $bean, $putBean, $beans, $remapping ); |
|
| 8906 | + if ( $matcher( $bean, $putBean, $beans ) ) { |
|
| 8907 | + $do( $bean, $putBean, $beans, $remapping ); |
|
| 8908 | + } |
|
| 8756 | 8909 | } |
| 8757 | 8910 | } |
| 8758 | 8911 | } |
@@ -9865,7 +10018,9 @@ discard block |
||
| 9865 | 10018 | } |
| 9866 | 10019 | |
| 9867 | 10020 | foreach( $values as $enumItem ) { |
| 9868 | - if ( $enumItem->name === $value ) return $enumItem; |
|
| 10021 | + if ( $enumItem->name === $value ) { |
|
| 10022 | + return $enumItem; |
|
| 10023 | + } |
|
| 9869 | 10024 | } |
| 9870 | 10025 | |
| 9871 | 10026 | $newEnumItems = $this->dispenseLabels( $type, array( $value ) ); |
@@ -10062,7 +10217,9 @@ discard block |
||
| 10062 | 10217 | */ |
| 10063 | 10218 | public static function testConnection() |
| 10064 | 10219 | { |
| 10065 | - if ( !isset( self::$adapter ) ) return FALSE; |
|
| 10220 | + if ( !isset( self::$adapter ) ) { |
|
| 10221 | + return FALSE; |
|
| 10222 | + } |
|
| 10066 | 10223 | |
| 10067 | 10224 | $database = self::$adapter->getDatabase(); |
| 10068 | 10225 | try { |
@@ -10212,7 +10369,9 @@ discard block |
||
| 10212 | 10369 | ); |
| 10213 | 10370 | |
| 10214 | 10371 | $wkey = trim( strtolower( $dbType ) ); |
| 10215 | - if ( !isset( $writers[$wkey] ) ) trigger_error( 'Unsupported DSN: '.$wkey ); |
|
| 10372 | + if ( !isset( $writers[$wkey] ) ) { |
|
| 10373 | + trigger_error( 'Unsupported DSN: '.$wkey ); |
|
| 10374 | + } |
|
| 10216 | 10375 | $writerClass = '\\RedBeanPHP\\QueryWriter\\'.$writers[$wkey]; |
| 10217 | 10376 | $writer = new $writerClass( $adapter ); |
| 10218 | 10377 | $redbean = new OODB( $writer, $frozen ); |
@@ -10419,7 +10578,9 @@ discard block |
||
| 10419 | 10578 | */ |
| 10420 | 10579 | public static function trash( $beanOrType, $id = NULL ) |
| 10421 | 10580 | { |
| 10422 | - if ( is_string( $beanOrType ) ) return self::trash( self::load( $beanOrType, $id ) ); |
|
| 10581 | + if ( is_string( $beanOrType ) ) { |
|
| 10582 | + return self::trash( self::load( $beanOrType, $id ) ); |
|
| 10583 | + } |
|
| 10423 | 10584 | return self::$redbean->trash( $beanOrType ); |
| 10424 | 10585 | } |
| 10425 | 10586 | |
@@ -10441,8 +10602,12 @@ discard block |
||
| 10441 | 10602 | |
| 10442 | 10603 | if ( !isset( $typeOrBeanArray['_type'] ) ) { |
| 10443 | 10604 | $list = array(); |
| 10444 | - foreach( $typeOrBeanArray as $beanArray ) if ( !( is_array( $beanArray ) && isset( $beanArray['_type'] ) ) ) throw new RedException( 'Invalid Array Bean' ); |
|
| 10445 | - foreach( $typeOrBeanArray as $beanArray ) $list[] = self::dispense( $beanArray ); |
|
| 10605 | + foreach( $typeOrBeanArray as $beanArray ) { |
|
| 10606 | + if ( !( is_array( $beanArray ) && isset( $beanArray['_type'] ) ) ) throw new RedException( 'Invalid Array Bean' ); |
|
| 10607 | + } |
|
| 10608 | + foreach( $typeOrBeanArray as $beanArray ) { |
|
| 10609 | + $list[] = self::dispense( $beanArray ); |
|
| 10610 | + } |
|
| 10446 | 10611 | return $list; |
| 10447 | 10612 | } |
| 10448 | 10613 | |
@@ -10894,7 +11059,9 @@ discard block |
||
| 10894 | 11059 | */ |
| 10895 | 11060 | public static function useExportCase( $caseStyle = 'default' ) |
| 10896 | 11061 | { |
| 10897 | - if ( !in_array( $caseStyle, array( 'default', 'camel', 'dolphin' ) ) ) throw new RedException( 'Invalid case selected.' ); |
|
| 11062 | + if ( !in_array( $caseStyle, array( 'default', 'camel', 'dolphin' ) ) ) { |
|
| 11063 | + throw new RedException( 'Invalid case selected.' ); |
|
| 11064 | + } |
|
| 10898 | 11065 | self::$exportCaseStyle = $caseStyle; |
| 10899 | 11066 | } |
| 10900 | 11067 | |
@@ -11095,7 +11262,9 @@ discard block |
||
| 11095 | 11262 | */ |
| 11096 | 11263 | public static function begin() |
| 11097 | 11264 | { |
| 11098 | - if ( !self::$redbean->isFrozen() ) return FALSE; |
|
| 11265 | + if ( !self::$redbean->isFrozen() ) { |
|
| 11266 | + return FALSE; |
|
| 11267 | + } |
|
| 11099 | 11268 | |
| 11100 | 11269 | self::$adapter->startTransaction(); |
| 11101 | 11270 | |
@@ -11110,7 +11279,9 @@ discard block |
||
| 11110 | 11279 | */ |
| 11111 | 11280 | public static function commit() |
| 11112 | 11281 | { |
| 11113 | - if ( !self::$redbean->isFrozen() ) return FALSE; |
|
| 11282 | + if ( !self::$redbean->isFrozen() ) { |
|
| 11283 | + return FALSE; |
|
| 11284 | + } |
|
| 11114 | 11285 | |
| 11115 | 11286 | self::$adapter->commit(); |
| 11116 | 11287 | |
@@ -11125,7 +11296,9 @@ discard block |
||
| 11125 | 11296 | */ |
| 11126 | 11297 | public static function rollback() |
| 11127 | 11298 | { |
| 11128 | - if ( !self::$redbean->isFrozen() ) return FALSE; |
|
| 11299 | + if ( !self::$redbean->isFrozen() ) { |
|
| 11300 | + return FALSE; |
|
| 11301 | + } |
|
| 11129 | 11302 | |
| 11130 | 11303 | self::$adapter->rollback(); |
| 11131 | 11304 | |
@@ -11170,8 +11343,11 @@ discard block |
||
| 11170 | 11343 | public static function flat( $array, $result = array() ) |
| 11171 | 11344 | { |
| 11172 | 11345 | foreach( $array as $value ) { |
| 11173 | - if ( is_array( $value ) ) $result = self::flat( $value, $result ); |
|
| 11174 | - else $result[] = $value; |
|
| 11346 | + if ( is_array( $value ) ) { |
|
| 11347 | + $result = self::flat( $value, $result ); |
|
| 11348 | + } else { |
|
| 11349 | + $result[] = $value; |
|
| 11350 | + } |
|
| 11175 | 11351 | } |
| 11176 | 11352 | return $result; |
| 11177 | 11353 | } |
@@ -11350,7 +11526,9 @@ discard block |
||
| 11350 | 11526 | */ |
| 11351 | 11527 | public static function isoDateTime( $time = NULL ) |
| 11352 | 11528 | { |
| 11353 | - if ( !$time ) $time = time(); |
|
| 11529 | + if ( !$time ) { |
|
| 11530 | + $time = time(); |
|
| 11531 | + } |
|
| 11354 | 11532 | |
| 11355 | 11533 | return @date( 'Y-m-d H:i:s', $time ); |
| 11356 | 11534 | } |
@@ -11975,7 +12153,9 @@ discard block |
||
| 11975 | 12153 | */ |
| 11976 | 12154 | protected function duplicate( OODBBean $bean, $trail = array(), $preserveIDs = FALSE ) |
| 11977 | 12155 | { |
| 11978 | - if ( $this->inTrailOrAdd( $trail, $bean ) ) return $bean; |
|
| 12156 | + if ( $this->inTrailOrAdd( $trail, $bean ) ) { |
|
| 12157 | + return $bean; |
|
| 12158 | + } |
|
| 11979 | 12159 | |
| 11980 | 12160 | $type = $bean->getMeta( 'type' ); |
| 11981 | 12161 | |
@@ -11983,7 +12163,9 @@ discard block |
||
| 11983 | 12163 | foreach ( $this->tables as $table ) { |
| 11984 | 12164 | |
| 11985 | 12165 | if ( !empty( $this->filters ) ) { |
| 11986 | - if ( !in_array( $table, $this->filters ) ) continue; |
|
| 12166 | + if ( !in_array( $table, $this->filters ) ) { |
|
| 12167 | + continue; |
|
| 12168 | + } |
|
| 11987 | 12169 | } |
| 11988 | 12170 | |
| 11989 | 12171 | list( $owned, $shared ) = $this->getListNames( $table ); |
@@ -12216,8 +12398,12 @@ discard block |
||
| 12216 | 12398 | $array[] = $duplicate->export( FALSE, $parents, FALSE, $filters ); |
| 12217 | 12399 | } |
| 12218 | 12400 | |
| 12219 | - if ( $caseStyle === 'camel' ) $array = $this->camelfy( $array ); |
|
| 12220 | - if ( $caseStyle === 'dolphin' ) $array = $this->camelfy( $array, true ); |
|
| 12401 | + if ( $caseStyle === 'camel' ) { |
|
| 12402 | + $array = $this->camelfy( $array ); |
|
| 12403 | + } |
|
| 12404 | + if ( $caseStyle === 'dolphin' ) { |
|
| 12405 | + $array = $this->camelfy( $array, true ); |
|
| 12406 | + } |
|
| 12221 | 12407 | |
| 12222 | 12408 | return $array; |
| 12223 | 12409 | } |
@@ -65,7 +65,7 @@ |
||
| 65 | 65 | $this->_vista->imprimirVista('index', 'instalador'); |
| 66 | 66 | $this->_sesion->iniciarSesion('_s', false); |
| 67 | 67 | |
| 68 | - }elseif (Cf_CONFIG_INICIO=='false') { |
|
| 68 | + } elseif (Cf_CONFIG_INICIO=='false') { |
|
| 69 | 69 | |
| 70 | 70 | $this->_vista->titulo = 'CalimaFramework'; |
| 71 | 71 | $this->_vista->imprimirVista('index', 'instalador'); |