Completed
Push — master ( 1c95fe...5490fd )
by
unknown
02:43
created
assets/lib/Formatter/SqlFormatter.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -330,8 +330,8 @@
 block discarded – undo
330 330
     }
331 331
 
332 332
     /**
333
-     * @param $string
334
-     * @return null
333
+     * @param string $string
334
+     * @return string|null
335 335
      */
336 336
     protected static function getQuotedString($string)
337 337
     {
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 
863 863
         // A reserved word cannot be preceded by a '.'
864 864
         // this makes it so in "mytable.from", "from" is not considered a reserved word
865
-        if (!$previous || !isset($previous[self::TOKEN_VALUE]) || $previous[self::TOKEN_VALUE] !== '.') {
865
+        if ( ! $previous || ! isset($previous[self::TOKEN_VALUE]) || $previous[self::TOKEN_VALUE] !== '.') {
866 866
             $upper = strtoupper($string);
867 867
             // Top Level Reserved Word
868 868
             if (preg_match('/^(' . self::$regex_reserved_toplevel . ')($|\s|' . self::$regex_boundaries . ')/', $upper,
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
                 $length = 0;
1119 1119
                 for ($j = 1; $j <= 250; $j++) {
1120 1120
                     // Reached end of string
1121
-                    if (!isset($tokens[$i + $j])) {
1121
+                    if ( ! isset($tokens[$i + $j])) {
1122 1122
                         break;
1123 1123
                     }
1124 1124
 
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
                     $return = rtrim($return, ' ');
1157 1157
                 }
1158 1158
 
1159
-                if (!$inline_parentheses) {
1159
+                if ( ! $inline_parentheses) {
1160 1160
                     $increase_block_indent = true;
1161 1161
                     // Add a newline after the parentheses
1162 1162
                     $newline = true;
@@ -1189,7 +1189,7 @@  discard block
 block discarded – undo
1189 1189
                 }
1190 1190
 
1191 1191
                 // Add a newline before the closing parentheses (if not already added)
1192
-                if (!$added_newline) {
1192
+                if ( ! $added_newline) {
1193 1193
                     $return .= "\n" . str_repeat($tab, $indent_level);
1194 1194
                 }
1195 1195
             } // Top level reserved words start a new line and increase the special indent level
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
                 // Add a newline after the top level reserved word
1207 1207
                 $newline = true;
1208 1208
                 // Add a newline before the top level reserved word (if not already added)
1209
-                if (!$added_newline) {
1209
+                if ( ! $added_newline) {
1210 1210
                     $return .= "\n" . str_repeat($tab, $indent_level);
1211 1211
                 } // If we already added a newline, redo the indentation since it may be different now
1212 1212
                 else {
@@ -1220,14 +1220,14 @@  discard block
 block discarded – undo
1220 1220
                     $highlighted = preg_replace('/\s+/', ' ', $highlighted);
1221 1221
                 }
1222 1222
                 //if SQL 'LIMIT' clause, start variable to reset newline
1223
-                if ($token[self::TOKEN_VALUE] === 'LIMIT' && !$inline_parentheses) {
1223
+                if ($token[self::TOKEN_VALUE] === 'LIMIT' && ! $inline_parentheses) {
1224 1224
                     $clause_limit = true;
1225 1225
                 }
1226 1226
             } // Checks if we are out of the limit clause
1227 1227
             elseif ($clause_limit && $token[self::TOKEN_VALUE] !== "," && $token[self::TOKEN_TYPE] !== self::TOKEN_TYPE_NUMBER && $token[self::TOKEN_TYPE] !== self::TOKEN_TYPE_WHITESPACE) {
1228 1228
                 $clause_limit = false;
1229 1229
             } // Commas start a new line (unless within inline parentheses or SQL 'LIMIT' clause)
1230
-            elseif ($token[self::TOKEN_VALUE] === ',' && !$inline_parentheses) {
1230
+            elseif ($token[self::TOKEN_VALUE] === ',' && ! $inline_parentheses) {
1231 1231
                 //If the previous TOKEN_VALUE is 'LIMIT', resets new line
1232 1232
                 if ($clause_limit === true) {
1233 1233
                     $newline = false;
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
             } // Newline reserved words start a new line
1240 1240
             elseif ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_RESERVED_NEWLINE) {
1241 1241
                 // Add a newline before the reserved word (if not already added)
1242
-                if (!$added_newline) {
1242
+                if ( ! $added_newline) {
1243 1243
                     $return .= "\n" . str_repeat($tab, $indent_level);
1244 1244
                 }
1245 1245
 
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
         foreach ($tokens as $token) {
1334 1334
             // If this is a query separator
1335 1335
             if ($token[self::TOKEN_VALUE] === ';') {
1336
-                if (!$empty) {
1336
+                if ( ! $empty) {
1337 1337
                     $queries[] = $current_query . ';';
1338 1338
                 }
1339 1339
                 $current_query = '';
@@ -1349,7 +1349,7 @@  discard block
 block discarded – undo
1349 1349
             $current_query .= $token[self::TOKEN_VALUE];
1350 1350
         }
1351 1351
 
1352
-        if (!$empty) {
1352
+        if ( ! $empty) {
1353 1353
             $queries[] = trim($current_query);
1354 1354
         }
1355 1355
 
@@ -1643,7 +1643,7 @@  discard block
 block discarded – undo
1643 1643
             return $string . "\n";
1644 1644
         } else {
1645 1645
             $string = trim($string);
1646
-            if (!self::$use_pre) {
1646
+            if ( ! self::$use_pre) {
1647 1647
                 return $string;
1648 1648
             }
1649 1649
 
Please login to merge, or discard this patch.
Braces   +184 added lines, -182 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
  * @link       http://github.com/jdorn/sql-formatter
13 13
  * @version    1.2.18
14 14
  */
15
-class SqlFormatter
16
-{
15
+class SqlFormatter
16
+{
17 17
     // Constants for token types
18 18
     const TOKEN_TYPE_WHITESPACE = 0;
19 19
     const TOKEN_TYPE_WORD = 1;
@@ -732,8 +732,8 @@  discard block
 block discarded – undo
732 732
      * Get stats about the token cache
733 733
      * @return Array An array containing the keys 'hits', 'misses', 'entries', and 'size' in bytes
734 734
      */
735
-    public static function getCacheStats()
736
-    {
735
+    public static function getCacheStats()
736
+    {
737 737
         return array(
738 738
             'hits'    => self::$cache_hits,
739 739
             'misses'  => self::$cache_misses,
@@ -745,9 +745,9 @@  discard block
 block discarded – undo
745 745
     /**
746 746
      * Stuff that only needs to be done once.  Builds regular expressions and sorts the reserved words.
747 747
      */
748
-    protected static function init()
749
-    {
750
-        if (self::$init) {
748
+    protected static function init()
749
+    {
750
+        if (self::$init) {
751 751
             return;
752 752
         }
753 753
 
@@ -779,10 +779,10 @@  discard block
 block discarded – undo
779 779
      *
780 780
      * @return Array An associative array containing the type and value of the token.
781 781
      */
782
-    protected static function getNextToken($string, $previous = null)
783
-    {
782
+    protected static function getNextToken($string, $previous = null)
783
+    {
784 784
         // Whitespace
785
-        if (preg_match('/^\s+/', $string, $matches)) {
785
+        if (preg_match('/^\s+/', $string, $matches)) {
786 786
             return array(
787 787
                 self::TOKEN_VALUE => $matches[0],
788 788
                 self::TOKEN_TYPE  => self::TOKEN_TYPE_WHITESPACE
@@ -790,17 +790,18 @@  discard block
 block discarded – undo
790 790
         }
791 791
 
792 792
         // Comment
793
-        if ($string[0] === '#' || (isset($string[1]) && ($string[0] === '-' && $string[1] === '-') || ($string[0] === '/' && $string[1] === '*'))) {
793
+        if ($string[0] === '#' || (isset($string[1]) && ($string[0] === '-' && $string[1] === '-') || ($string[0] === '/' && $string[1] === '*'))) {
794 794
             // Comment until end of line
795
-            if ($string[0] === '-' || $string[0] === '#') {
795
+            if ($string[0] === '-' || $string[0] === '#') {
796 796
                 $last = strpos($string, "\n");
797 797
                 $type = self::TOKEN_TYPE_COMMENT;
798
-            } else { // Comment until closing comment tag
798
+            } else {
799
+// Comment until closing comment tag
799 800
                 $last = strpos($string, "*/", 2) + 2;
800 801
                 $type = self::TOKEN_TYPE_BLOCK_COMMENT;
801 802
             }
802 803
 
803
-            if ($last === false) {
804
+            if ($last === false) {
804 805
                 $last = strlen($string);
805 806
             }
806 807
 
@@ -811,7 +812,7 @@  discard block
 block discarded – undo
811 812
         }
812 813
 
813 814
         // Quoted String
814
-        if ($string[0] === '"' || $string[0] === '\'' || $string[0] === '`' || $string[0] === '[') {
815
+        if ($string[0] === '"' || $string[0] === '\'' || $string[0] === '`' || $string[0] === '[') {
815 816
             $return = array(
816 817
                 self::TOKEN_TYPE  => (($string[0] === '`' || $string[0] === '[') ? self::TOKEN_TYPE_BACKTICK_QUOTE : self::TOKEN_TYPE_QUOTE),
817 818
                 self::TOKEN_VALUE => self::getQuotedString($string)
@@ -821,31 +822,31 @@  discard block
 block discarded – undo
821 822
         }
822 823
 
823 824
         // User-defined Variable
824
-        if (($string[0] === '@' || $string[0] === ':') && isset($string[1])) {
825
+        if (($string[0] === '@' || $string[0] === ':') && isset($string[1])) {
825 826
             $ret = array(
826 827
                 self::TOKEN_VALUE => null,
827 828
                 self::TOKEN_TYPE  => self::TOKEN_TYPE_VARIABLE
828 829
             );
829 830
 
830 831
             // If the variable name is quoted
831
-            if ($string[1] === '"' || $string[1] === '\'' || $string[1] === '`') {
832
+            if ($string[1] === '"' || $string[1] === '\'' || $string[1] === '`') {
832 833
                 $ret[self::TOKEN_VALUE] = $string[0] . self::getQuotedString(substr($string, 1));
833 834
             } // Non-quoted variable name
834
-            else {
835
+            else {
835 836
                 preg_match('/^(' . $string[0] . '[a-zA-Z0-9\._\$]+)/', $string, $matches);
836
-                if ($matches) {
837
+                if ($matches) {
837 838
                     $ret[self::TOKEN_VALUE] = $matches[1];
838 839
                 }
839 840
             }
840 841
 
841
-            if ($ret[self::TOKEN_VALUE] !== null) {
842
+            if ($ret[self::TOKEN_VALUE] !== null) {
842 843
                 return $ret;
843 844
             }
844 845
         }
845 846
 
846 847
         // Number (decimal, binary, or hex)
847 848
         if (preg_match('/^([0-9]+(\.[0-9]+)?|0x[0-9a-fA-F]+|0b[01]+)($|\s|"\'`|' . self::$regex_boundaries . ')/',
848
-            $string, $matches)) {
849
+            $string, $matches)) {
849 850
             return array(
850 851
                 self::TOKEN_VALUE => $matches[1],
851 852
                 self::TOKEN_TYPE  => self::TOKEN_TYPE_NUMBER
@@ -853,7 +854,7 @@  discard block
 block discarded – undo
853 854
         }
854 855
 
855 856
         // Boundary Character (punctuation and symbols)
856
-        if (preg_match('/^(' . self::$regex_boundaries . ')/', $string, $matches)) {
857
+        if (preg_match('/^(' . self::$regex_boundaries . ')/', $string, $matches)) {
857 858
             return array(
858 859
                 self::TOKEN_VALUE => $matches[1],
859 860
                 self::TOKEN_TYPE  => self::TOKEN_TYPE_BOUNDARY
@@ -862,11 +863,11 @@  discard block
 block discarded – undo
862 863
 
863 864
         // A reserved word cannot be preceded by a '.'
864 865
         // this makes it so in "mytable.from", "from" is not considered a reserved word
865
-        if (!$previous || !isset($previous[self::TOKEN_VALUE]) || $previous[self::TOKEN_VALUE] !== '.') {
866
+        if (!$previous || !isset($previous[self::TOKEN_VALUE]) || $previous[self::TOKEN_VALUE] !== '.') {
866 867
             $upper = strtoupper($string);
867 868
             // Top Level Reserved Word
868 869
             if (preg_match('/^(' . self::$regex_reserved_toplevel . ')($|\s|' . self::$regex_boundaries . ')/', $upper,
869
-                $matches)) {
870
+                $matches)) {
870 871
                 return array(
871 872
                     self::TOKEN_TYPE  => self::TOKEN_TYPE_RESERVED_TOPLEVEL,
872 873
                     self::TOKEN_VALUE => substr($string, 0, strlen($matches[1]))
@@ -874,7 +875,7 @@  discard block
 block discarded – undo
874 875
             }
875 876
             // Newline Reserved Word
876 877
             if (preg_match('/^(' . self::$regex_reserved_newline . ')($|\s|' . self::$regex_boundaries . ')/', $upper,
877
-                $matches)) {
878
+                $matches)) {
878 879
                 return array(
879 880
                     self::TOKEN_TYPE  => self::TOKEN_TYPE_RESERVED_NEWLINE,
880 881
                     self::TOKEN_VALUE => substr($string, 0, strlen($matches[1]))
@@ -882,7 +883,7 @@  discard block
 block discarded – undo
882 883
             }
883 884
             // Other Reserved Word
884 885
             if (preg_match('/^(' . self::$regex_reserved . ')($|\s|' . self::$regex_boundaries . ')/', $upper,
885
-                $matches)) {
886
+                $matches)) {
886 887
                 return array(
887 888
                     self::TOKEN_TYPE  => self::TOKEN_TYPE_RESERVED,
888 889
                     self::TOKEN_VALUE => substr($string, 0, strlen($matches[1]))
@@ -894,7 +895,7 @@  discard block
 block discarded – undo
894 895
         // this makes it so "count(" is considered a function, but "count" alone is not
895 896
         $upper = strtoupper($string);
896 897
         // function
897
-        if (preg_match('/^(' . self::$regex_function . '[(]|\s|[)])/', $upper, $matches)) {
898
+        if (preg_match('/^(' . self::$regex_function . '[(]|\s|[)])/', $upper, $matches)) {
898 899
             return array(
899 900
                 self::TOKEN_TYPE  => self::TOKEN_TYPE_RESERVED,
900 901
                 self::TOKEN_VALUE => substr($string, 0, strlen($matches[1]) - 1)
@@ -914,8 +915,8 @@  discard block
 block discarded – undo
914 915
      * @param $string
915 916
      * @return null
916 917
      */
917
-    protected static function getQuotedString($string)
918
-    {
918
+    protected static function getQuotedString($string)
919
+    {
919 920
         $ret = null;
920 921
 
921 922
         // This checks for the following patterns:
@@ -924,7 +925,7 @@  discard block
 block discarded – undo
924 925
         // 3. double quoted string using "" or \" to escape
925 926
         // 4. single quoted string using '' or \' to escape
926 927
         if (preg_match('/^(((`[^`]*($|`))+)|((\[[^\]]*($|\]))(\][^\]]*($|\]))*)|(("[^"\\\\]*(?:\\\\.[^"\\\\]*)*("|$))+)|((\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*(\'|$))+))/s',
927
-            $string, $matches)) {
928
+            $string, $matches)) {
928 929
             $ret = $matches[1];
929 930
         }
930 931
 
@@ -939,8 +940,8 @@  discard block
 block discarded – undo
939 940
      *
940 941
      * @return Array An array of tokens.
941 942
      */
942
-    protected static function tokenize($string)
943
-    {
943
+    protected static function tokenize($string)
944
+    {
944 945
         self::init();
945 946
 
946 947
         $tokens = array();
@@ -953,9 +954,9 @@  discard block
 block discarded – undo
953 954
         $current_length = strlen($string);
954 955
 
955 956
         // Keep processing the string until it is empty
956
-        while ($current_length) {
957
+        while ($current_length) {
957 958
             // If the string stopped shrinking, there was a problem
958
-            if ($old_string_len <= $current_length) {
959
+            if ($old_string_len <= $current_length) {
959 960
                 $tokens[] = array(
960 961
                     self::TOKEN_VALUE => $string,
961 962
                     self::TOKEN_TYPE  => self::TOKEN_TYPE_ERROR
@@ -966,26 +967,26 @@  discard block
 block discarded – undo
966 967
             $old_string_len = $current_length;
967 968
 
968 969
             // Determine if we can use caching
969
-            if ($current_length >= self::$max_cachekey_size) {
970
+            if ($current_length >= self::$max_cachekey_size) {
970 971
                 $cacheKey = substr($string, 0, self::$max_cachekey_size);
971
-            } else {
972
+            } else {
972 973
                 $cacheKey = false;
973 974
             }
974 975
 
975 976
             // See if the token is already cached
976
-            if ($cacheKey && isset(self::$token_cache[$cacheKey])) {
977
+            if ($cacheKey && isset(self::$token_cache[$cacheKey])) {
977 978
                 // Retrieve from cache
978 979
                 $token = self::$token_cache[$cacheKey];
979 980
                 $token_length = strlen($token[self::TOKEN_VALUE]);
980 981
                 self::$cache_hits++;
981
-            } else {
982
+            } else {
982 983
                 // Get the next token and the token type
983 984
                 $token = self::getNextToken($string, $token);
984 985
                 $token_length = strlen($token[self::TOKEN_VALUE]);
985 986
                 self::$cache_misses++;
986 987
 
987 988
                 // If the token is shorter than the max length, store it in cache
988
-                if ($cacheKey && $token_length < self::$max_cachekey_size) {
989
+                if ($cacheKey && $token_length < self::$max_cachekey_size) {
989 990
                     self::$token_cache[$cacheKey] = $token;
990 991
                 }
991 992
             }
@@ -1009,8 +1010,8 @@  discard block
 block discarded – undo
1009 1010
      *
1010 1011
      * @return String The SQL string with HTML styles and formatting wrapped in a <pre> tag
1011 1012
      */
1012
-    public static function format($string, $highlight = true)
1013
-    {
1013
+    public static function format($string, $highlight = true)
1014
+    {
1014 1015
         // This variable will be populated with formatted html
1015 1016
         $return = '';
1016 1017
 
@@ -1032,47 +1033,48 @@  discard block
 block discarded – undo
1032 1033
 
1033 1034
         // Remove existing whitespace
1034 1035
         $tokens = array();
1035
-        foreach ($original_tokens as $i => $token) {
1036
-            if ($token[self::TOKEN_TYPE] !== self::TOKEN_TYPE_WHITESPACE) {
1036
+        foreach ($original_tokens as $i => $token) {
1037
+            if ($token[self::TOKEN_TYPE] !== self::TOKEN_TYPE_WHITESPACE) {
1037 1038
                 $token['i'] = $i;
1038 1039
                 $tokens[] = $token;
1039 1040
             }
1040 1041
         }
1041 1042
 
1042 1043
         // Format token by token
1043
-        foreach ($tokens as $i => $token) {
1044
+        foreach ($tokens as $i => $token) {
1044 1045
             // Get highlighted token if doing syntax highlighting
1045
-            if ($highlight) {
1046
+            if ($highlight) {
1046 1047
                 $highlighted = self::highlightToken($token);
1047
-            } else { // If returning raw text
1048
+            } else {
1049
+// If returning raw text
1048 1050
                 $highlighted = $token[self::TOKEN_VALUE];
1049 1051
             }
1050 1052
 
1051 1053
             // If we are increasing the special indent level now
1052
-            if ($increase_special_indent) {
1054
+            if ($increase_special_indent) {
1053 1055
                 $indent_level++;
1054 1056
                 $increase_special_indent = false;
1055 1057
                 array_unshift($indent_types, 'special');
1056 1058
             }
1057 1059
             // If we are increasing the block indent level now
1058
-            if ($increase_block_indent) {
1060
+            if ($increase_block_indent) {
1059 1061
                 $indent_level++;
1060 1062
                 $increase_block_indent = false;
1061 1063
                 array_unshift($indent_types, 'block');
1062 1064
             }
1063 1065
 
1064 1066
             // If we need a new line before the token
1065
-            if ($newline) {
1067
+            if ($newline) {
1066 1068
                 $return .= "\n" . str_repeat($tab, $indent_level);
1067 1069
                 $newline = false;
1068 1070
                 $added_newline = true;
1069
-            } else {
1071
+            } else {
1070 1072
                 $added_newline = false;
1071 1073
             }
1072 1074
 
1073 1075
             // Display comments directly where they appear in the source
1074
-            if ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_COMMENT || $token[self::TOKEN_TYPE] === self::TOKEN_TYPE_BLOCK_COMMENT) {
1075
-                if ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_BLOCK_COMMENT) {
1076
+            if ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_COMMENT || $token[self::TOKEN_TYPE] === self::TOKEN_TYPE_BLOCK_COMMENT) {
1077
+                if ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_BLOCK_COMMENT) {
1076 1078
                     $indent = str_repeat($tab, $indent_level);
1077 1079
                     $return .= "\n" . $indent;
1078 1080
                     $highlighted = str_replace("\n", "\n" . $indent, $highlighted);
@@ -1083,12 +1085,12 @@  discard block
 block discarded – undo
1083 1085
                 continue;
1084 1086
             }
1085 1087
 
1086
-            if ($inline_parentheses) {
1088
+            if ($inline_parentheses) {
1087 1089
                 // End of inline parentheses
1088
-                if ($token[self::TOKEN_VALUE] === ')') {
1090
+                if ($token[self::TOKEN_VALUE] === ')') {
1089 1091
                     $return = rtrim($return, ' ');
1090 1092
 
1091
-                    if ($inline_indented) {
1093
+                    if ($inline_indented) {
1092 1094
                         array_shift($indent_types);
1093 1095
                         $indent_level--;
1094 1096
                         $return .= "\n" . str_repeat($tab, $indent_level);
@@ -1100,8 +1102,8 @@  discard block
 block discarded – undo
1100 1102
                     continue;
1101 1103
                 }
1102 1104
 
1103
-                if ($token[self::TOKEN_VALUE] === ',') {
1104
-                    if ($inline_count >= 30) {
1105
+                if ($token[self::TOKEN_VALUE] === ',') {
1106
+                    if ($inline_count >= 30) {
1105 1107
                         $inline_count = 0;
1106 1108
                         $newline = true;
1107 1109
                     }
@@ -1111,21 +1113,21 @@  discard block
 block discarded – undo
1111 1113
             }
1112 1114
 
1113 1115
             // Opening parentheses increase the block indent level and start a new line
1114
-            if ($token[self::TOKEN_VALUE] === '(') {
1116
+            if ($token[self::TOKEN_VALUE] === '(') {
1115 1117
                 // First check if this should be an inline parentheses block
1116 1118
                 // Examples are "NOW()", "COUNT(*)", "int(10)", key(`somecolumn`), DECIMAL(7,2)
1117 1119
                 // Allow up to 3 non-whitespace tokens inside inline parentheses
1118 1120
                 $length = 0;
1119
-                for ($j = 1; $j <= 250; $j++) {
1121
+                for ($j = 1; $j <= 250; $j++) {
1120 1122
                     // Reached end of string
1121
-                    if (!isset($tokens[$i + $j])) {
1123
+                    if (!isset($tokens[$i + $j])) {
1122 1124
                         break;
1123 1125
                     }
1124 1126
 
1125 1127
                     $next = $tokens[$i + $j];
1126 1128
 
1127 1129
                     // Reached closing parentheses, able to inline it
1128
-                    if ($next[self::TOKEN_VALUE] === ')') {
1130
+                    if ($next[self::TOKEN_VALUE] === ')') {
1129 1131
                         $inline_parentheses = true;
1130 1132
                         $inline_count = 0;
1131 1133
                         $inline_indented = false;
@@ -1133,72 +1135,72 @@  discard block
 block discarded – undo
1133 1135
                     }
1134 1136
 
1135 1137
                     // Reached an invalid token for inline parentheses
1136
-                    if ($next[self::TOKEN_VALUE] === ';' || $next[self::TOKEN_VALUE] === '(') {
1138
+                    if ($next[self::TOKEN_VALUE] === ';' || $next[self::TOKEN_VALUE] === '(') {
1137 1139
                         break;
1138 1140
                     }
1139 1141
 
1140 1142
                     // Reached an invalid token type for inline parentheses
1141
-                    if ($next[self::TOKEN_TYPE] === self::TOKEN_TYPE_RESERVED_TOPLEVEL || $next[self::TOKEN_TYPE] === self::TOKEN_TYPE_RESERVED_NEWLINE || $next[self::TOKEN_TYPE] === self::TOKEN_TYPE_COMMENT || $next[self::TOKEN_TYPE] === self::TOKEN_TYPE_BLOCK_COMMENT) {
1143
+                    if ($next[self::TOKEN_TYPE] === self::TOKEN_TYPE_RESERVED_TOPLEVEL || $next[self::TOKEN_TYPE] === self::TOKEN_TYPE_RESERVED_NEWLINE || $next[self::TOKEN_TYPE] === self::TOKEN_TYPE_COMMENT || $next[self::TOKEN_TYPE] === self::TOKEN_TYPE_BLOCK_COMMENT) {
1142 1144
                         break;
1143 1145
                     }
1144 1146
 
1145 1147
                     $length += strlen($next[self::TOKEN_VALUE]);
1146 1148
                 }
1147 1149
 
1148
-                if ($inline_parentheses && $length > 30) {
1150
+                if ($inline_parentheses && $length > 30) {
1149 1151
                     $increase_block_indent = true;
1150 1152
                     $inline_indented = true;
1151 1153
                     $newline = true;
1152 1154
                 }
1153 1155
 
1154 1156
                 // Take out the preceding space unless there was whitespace there in the original query
1155
-                if (isset($original_tokens[$token['i'] - 1]) && $original_tokens[$token['i'] - 1][self::TOKEN_TYPE] !== self::TOKEN_TYPE_WHITESPACE) {
1157
+                if (isset($original_tokens[$token['i'] - 1]) && $original_tokens[$token['i'] - 1][self::TOKEN_TYPE] !== self::TOKEN_TYPE_WHITESPACE) {
1156 1158
                     $return = rtrim($return, ' ');
1157 1159
                 }
1158 1160
 
1159
-                if (!$inline_parentheses) {
1161
+                if (!$inline_parentheses) {
1160 1162
                     $increase_block_indent = true;
1161 1163
                     // Add a newline after the parentheses
1162 1164
                     $newline = true;
1163 1165
                 }
1164 1166
 
1165 1167
             } // Closing parentheses decrease the block indent level
1166
-            elseif ($token[self::TOKEN_VALUE] === ')') {
1168
+            elseif ($token[self::TOKEN_VALUE] === ')') {
1167 1169
                 // Remove whitespace before the closing parentheses
1168 1170
                 $return = rtrim($return, ' ');
1169 1171
 
1170 1172
                 $indent_level--;
1171 1173
 
1172 1174
                 // Reset indent level
1173
-                while ($j = array_shift($indent_types)) {
1174
-                    if ($j === 'special') {
1175
+                while ($j = array_shift($indent_types)) {
1176
+                    if ($j === 'special') {
1175 1177
                         $indent_level--;
1176
-                    } else {
1178
+                    } else {
1177 1179
                         break;
1178 1180
                     }
1179 1181
                 }
1180 1182
 
1181
-                if ($indent_level < 0) {
1183
+                if ($indent_level < 0) {
1182 1184
                     // This is an error
1183 1185
                     $indent_level = 0;
1184 1186
 
1185
-                    if ($highlight) {
1187
+                    if ($highlight) {
1186 1188
                         $return .= "\n" . self::highlightError($token[self::TOKEN_VALUE]);
1187 1189
                         continue;
1188 1190
                     }
1189 1191
                 }
1190 1192
 
1191 1193
                 // Add a newline before the closing parentheses (if not already added)
1192
-                if (!$added_newline) {
1194
+                if (!$added_newline) {
1193 1195
                     $return .= "\n" . str_repeat($tab, $indent_level);
1194 1196
                 }
1195 1197
             } // Top level reserved words start a new line and increase the special indent level
1196
-            elseif ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_RESERVED_TOPLEVEL) {
1198
+            elseif ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_RESERVED_TOPLEVEL) {
1197 1199
                 $increase_special_indent = true;
1198 1200
 
1199 1201
                 // If the last indent type was 'special', decrease the special indent for this round
1200 1202
                 reset($indent_types);
1201
-                if (current($indent_types) === 'special') {
1203
+                if (current($indent_types) === 'special') {
1202 1204
                     $indent_level--;
1203 1205
                     array_shift($indent_types);
1204 1206
                 }
@@ -1206,88 +1208,88 @@  discard block
 block discarded – undo
1206 1208
                 // Add a newline after the top level reserved word
1207 1209
                 $newline = true;
1208 1210
                 // Add a newline before the top level reserved word (if not already added)
1209
-                if (!$added_newline) {
1211
+                if (!$added_newline) {
1210 1212
                     $return .= "\n" . str_repeat($tab, $indent_level);
1211 1213
                 } // If we already added a newline, redo the indentation since it may be different now
1212
-                else {
1214
+                else {
1213 1215
                     $return = rtrim($return, $tab) . str_repeat($tab, $indent_level);
1214 1216
                 }
1215 1217
 
1216 1218
                 // If the token may have extra whitespace
1217 1219
                 if (strpos($token[self::TOKEN_VALUE], ' ') !== false || strpos($token[self::TOKEN_VALUE],
1218 1220
                         "\n") !== false || strpos($token[self::TOKEN_VALUE], "\t") !== false
1219
-                ) {
1221
+                ) {
1220 1222
                     $highlighted = preg_replace('/\s+/', ' ', $highlighted);
1221 1223
                 }
1222 1224
                 //if SQL 'LIMIT' clause, start variable to reset newline
1223
-                if ($token[self::TOKEN_VALUE] === 'LIMIT' && !$inline_parentheses) {
1225
+                if ($token[self::TOKEN_VALUE] === 'LIMIT' && !$inline_parentheses) {
1224 1226
                     $clause_limit = true;
1225 1227
                 }
1226 1228
             } // Checks if we are out of the limit clause
1227
-            elseif ($clause_limit && $token[self::TOKEN_VALUE] !== "," && $token[self::TOKEN_TYPE] !== self::TOKEN_TYPE_NUMBER && $token[self::TOKEN_TYPE] !== self::TOKEN_TYPE_WHITESPACE) {
1229
+            elseif ($clause_limit && $token[self::TOKEN_VALUE] !== "," && $token[self::TOKEN_TYPE] !== self::TOKEN_TYPE_NUMBER && $token[self::TOKEN_TYPE] !== self::TOKEN_TYPE_WHITESPACE) {
1228 1230
                 $clause_limit = false;
1229 1231
             } // Commas start a new line (unless within inline parentheses or SQL 'LIMIT' clause)
1230
-            elseif ($token[self::TOKEN_VALUE] === ',' && !$inline_parentheses) {
1232
+            elseif ($token[self::TOKEN_VALUE] === ',' && !$inline_parentheses) {
1231 1233
                 //If the previous TOKEN_VALUE is 'LIMIT', resets new line
1232
-                if ($clause_limit === true) {
1234
+                if ($clause_limit === true) {
1233 1235
                     $newline = false;
1234 1236
                     $clause_limit = false;
1235 1237
                 } // All other cases of commas
1236
-                else {
1238
+                else {
1237 1239
                     $newline = true;
1238 1240
                 }
1239 1241
             } // Newline reserved words start a new line
1240
-            elseif ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_RESERVED_NEWLINE) {
1242
+            elseif ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_RESERVED_NEWLINE) {
1241 1243
                 // Add a newline before the reserved word (if not already added)
1242
-                if (!$added_newline) {
1244
+                if (!$added_newline) {
1243 1245
                     $return .= "\n" . str_repeat($tab, $indent_level);
1244 1246
                 }
1245 1247
 
1246 1248
                 // If the token may have extra whitespace
1247 1249
                 if (strpos($token[self::TOKEN_VALUE], ' ') !== false || strpos($token[self::TOKEN_VALUE],
1248 1250
                         "\n") !== false || strpos($token[self::TOKEN_VALUE], "\t") !== false
1249
-                ) {
1251
+                ) {
1250 1252
                     $highlighted = preg_replace('/\s+/', ' ', $highlighted);
1251 1253
                 }
1252 1254
             } // Multiple boundary characters in a row should not have spaces between them (not including parentheses)
1253
-            elseif ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_BOUNDARY) {
1254
-                if (isset($tokens[$i - 1]) && $tokens[$i - 1][self::TOKEN_TYPE] === self::TOKEN_TYPE_BOUNDARY) {
1255
-                    if (isset($original_tokens[$token['i'] - 1]) && $original_tokens[$token['i'] - 1][self::TOKEN_TYPE] !== self::TOKEN_TYPE_WHITESPACE) {
1255
+            elseif ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_BOUNDARY) {
1256
+                if (isset($tokens[$i - 1]) && $tokens[$i - 1][self::TOKEN_TYPE] === self::TOKEN_TYPE_BOUNDARY) {
1257
+                    if (isset($original_tokens[$token['i'] - 1]) && $original_tokens[$token['i'] - 1][self::TOKEN_TYPE] !== self::TOKEN_TYPE_WHITESPACE) {
1256 1258
                         $return = rtrim($return, ' ');
1257 1259
                     }
1258 1260
                 }
1259 1261
             }
1260 1262
 
1261 1263
             // If the token shouldn't have a space before it
1262
-            if ($token[self::TOKEN_VALUE] === '.' || $token[self::TOKEN_VALUE] === ',' || $token[self::TOKEN_VALUE] === ';') {
1264
+            if ($token[self::TOKEN_VALUE] === '.' || $token[self::TOKEN_VALUE] === ',' || $token[self::TOKEN_VALUE] === ';') {
1263 1265
                 $return = rtrim($return, ' ');
1264 1266
             }
1265 1267
 
1266 1268
             $return .= $highlighted . ' ';
1267 1269
 
1268 1270
             // If the token shouldn't have a space after it
1269
-            if ($token[self::TOKEN_VALUE] === '(' || $token[self::TOKEN_VALUE] === '.') {
1271
+            if ($token[self::TOKEN_VALUE] === '(' || $token[self::TOKEN_VALUE] === '.') {
1270 1272
                 $return = rtrim($return, ' ');
1271 1273
             }
1272 1274
 
1273 1275
             // If this is the "-" of a negative number, it shouldn't have a space after it
1274
-            if ($token[self::TOKEN_VALUE] === '-' && isset($tokens[$i + 1]) && $tokens[$i + 1][self::TOKEN_TYPE] === self::TOKEN_TYPE_NUMBER && isset($tokens[$i - 1])) {
1276
+            if ($token[self::TOKEN_VALUE] === '-' && isset($tokens[$i + 1]) && $tokens[$i + 1][self::TOKEN_TYPE] === self::TOKEN_TYPE_NUMBER && isset($tokens[$i - 1])) {
1275 1277
                 $prev = $tokens[$i - 1][self::TOKEN_TYPE];
1276
-                if ($prev !== self::TOKEN_TYPE_QUOTE && $prev !== self::TOKEN_TYPE_BACKTICK_QUOTE && $prev !== self::TOKEN_TYPE_WORD && $prev !== self::TOKEN_TYPE_NUMBER) {
1278
+                if ($prev !== self::TOKEN_TYPE_QUOTE && $prev !== self::TOKEN_TYPE_BACKTICK_QUOTE && $prev !== self::TOKEN_TYPE_WORD && $prev !== self::TOKEN_TYPE_NUMBER) {
1277 1279
                     $return = rtrim($return, ' ');
1278 1280
                 }
1279 1281
             }
1280 1282
         }
1281 1283
 
1282 1284
         // If there are unmatched parentheses
1283
-        if ($highlight && array_search('block', $indent_types) !== false) {
1285
+        if ($highlight && array_search('block', $indent_types) !== false) {
1284 1286
             $return .= "\n" . self::highlightError("WARNING: unclosed parentheses or section");
1285 1287
         }
1286 1288
 
1287 1289
         // Replace tab characters with the configuration tab character
1288 1290
         $return = trim(str_replace("\t", self::$tab, $return));
1289 1291
 
1290
-        if ($highlight) {
1292
+        if ($highlight) {
1291 1293
             $return = self::output($return);
1292 1294
         }
1293 1295
 
@@ -1301,13 +1303,13 @@  discard block
 block discarded – undo
1301 1303
      *
1302 1304
      * @return String The SQL string with HTML styles applied
1303 1305
      */
1304
-    public static function highlight($string)
1305
-    {
1306
+    public static function highlight($string)
1307
+    {
1306 1308
         $tokens = self::tokenize($string);
1307 1309
 
1308 1310
         $return = '';
1309 1311
 
1310
-        foreach ($tokens as $token) {
1312
+        foreach ($tokens as $token) {
1311 1313
             $return .= self::highlightToken($token);
1312 1314
         }
1313 1315
 
@@ -1322,18 +1324,18 @@  discard block
 block discarded – undo
1322 1324
      *
1323 1325
      * @return Array An array of individual query strings without trailing semicolons
1324 1326
      */
1325
-    public static function splitQuery($string)
1326
-    {
1327
+    public static function splitQuery($string)
1328
+    {
1327 1329
         $queries = array();
1328 1330
         $current_query = '';
1329 1331
         $empty = true;
1330 1332
 
1331 1333
         $tokens = self::tokenize($string);
1332 1334
 
1333
-        foreach ($tokens as $token) {
1335
+        foreach ($tokens as $token) {
1334 1336
             // If this is a query separator
1335
-            if ($token[self::TOKEN_VALUE] === ';') {
1336
-                if (!$empty) {
1337
+            if ($token[self::TOKEN_VALUE] === ';') {
1338
+                if (!$empty) {
1337 1339
                     $queries[] = $current_query . ';';
1338 1340
                 }
1339 1341
                 $current_query = '';
@@ -1342,14 +1344,14 @@  discard block
 block discarded – undo
1342 1344
             }
1343 1345
 
1344 1346
             // If this is a non-empty character
1345
-            if ($token[self::TOKEN_TYPE] !== self::TOKEN_TYPE_WHITESPACE && $token[self::TOKEN_TYPE] !== self::TOKEN_TYPE_COMMENT && $token[self::TOKEN_TYPE] !== self::TOKEN_TYPE_BLOCK_COMMENT) {
1347
+            if ($token[self::TOKEN_TYPE] !== self::TOKEN_TYPE_WHITESPACE && $token[self::TOKEN_TYPE] !== self::TOKEN_TYPE_COMMENT && $token[self::TOKEN_TYPE] !== self::TOKEN_TYPE_BLOCK_COMMENT) {
1346 1348
                 $empty = false;
1347 1349
             }
1348 1350
 
1349 1351
             $current_query .= $token[self::TOKEN_VALUE];
1350 1352
         }
1351 1353
 
1352
-        if (!$empty) {
1354
+        if (!$empty) {
1353 1355
             $queries[] = trim($current_query);
1354 1356
         }
1355 1357
 
@@ -1363,15 +1365,15 @@  discard block
 block discarded – undo
1363 1365
      *
1364 1366
      * @return String The SQL string without comments
1365 1367
      */
1366
-    public static function removeComments($string)
1367
-    {
1368
+    public static function removeComments($string)
1369
+    {
1368 1370
         $result = '';
1369 1371
 
1370 1372
         $tokens = self::tokenize($string);
1371 1373
 
1372
-        foreach ($tokens as $token) {
1374
+        foreach ($tokens as $token) {
1373 1375
             // Skip comment tokens
1374
-            if ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_COMMENT || $token[self::TOKEN_TYPE] === self::TOKEN_TYPE_BLOCK_COMMENT) {
1376
+            if ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_COMMENT || $token[self::TOKEN_TYPE] === self::TOKEN_TYPE_BLOCK_COMMENT) {
1375 1377
                 continue;
1376 1378
             }
1377 1379
 
@@ -1389,32 +1391,32 @@  discard block
 block discarded – undo
1389 1391
      *
1390 1392
      * @return String The SQL string without comments
1391 1393
      */
1392
-    public static function compress($string)
1393
-    {
1394
+    public static function compress($string)
1395
+    {
1394 1396
         $result = '';
1395 1397
 
1396 1398
         $tokens = self::tokenize($string);
1397 1399
 
1398 1400
         $whitespace = true;
1399
-        foreach ($tokens as $token) {
1401
+        foreach ($tokens as $token) {
1400 1402
             // Skip comment tokens
1401
-            if ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_COMMENT || $token[self::TOKEN_TYPE] === self::TOKEN_TYPE_BLOCK_COMMENT) {
1403
+            if ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_COMMENT || $token[self::TOKEN_TYPE] === self::TOKEN_TYPE_BLOCK_COMMENT) {
1402 1404
                 continue;
1403 1405
             } // Remove extra whitespace in reserved words (e.g "OUTER     JOIN" becomes "OUTER JOIN")
1404
-            elseif ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_RESERVED || $token[self::TOKEN_TYPE] === self::TOKEN_TYPE_RESERVED_NEWLINE || $token[self::TOKEN_TYPE] === self::TOKEN_TYPE_RESERVED_TOPLEVEL) {
1406
+            elseif ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_RESERVED || $token[self::TOKEN_TYPE] === self::TOKEN_TYPE_RESERVED_NEWLINE || $token[self::TOKEN_TYPE] === self::TOKEN_TYPE_RESERVED_TOPLEVEL) {
1405 1407
                 $token[self::TOKEN_VALUE] = preg_replace('/\s+/', ' ', $token[self::TOKEN_VALUE]);
1406 1408
             }
1407 1409
 
1408
-            if ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_WHITESPACE) {
1410
+            if ($token[self::TOKEN_TYPE] === self::TOKEN_TYPE_WHITESPACE) {
1409 1411
                 // If the last token was whitespace, don't add another one
1410
-                if ($whitespace) {
1412
+                if ($whitespace) {
1411 1413
                     continue;
1412
-                } else {
1414
+                } else {
1413 1415
                     $whitespace = true;
1414 1416
                     // Convert all whitespace to a single space
1415 1417
                     $token[self::TOKEN_VALUE] = ' ';
1416 1418
                 }
1417
-            } else {
1419
+            } else {
1418 1420
                 $whitespace = false;
1419 1421
             }
1420 1422
 
@@ -1431,39 +1433,39 @@  discard block
 block discarded – undo
1431 1433
      *
1432 1434
      * @return String HTML code of the highlighted token.
1433 1435
      */
1434
-    protected static function highlightToken($token)
1435
-    {
1436
+    protected static function highlightToken($token)
1437
+    {
1436 1438
         $type = $token[self::TOKEN_TYPE];
1437 1439
 
1438
-        if (self::is_cli()) {
1440
+        if (self::is_cli()) {
1439 1441
             $token = $token[self::TOKEN_VALUE];
1440
-        } else {
1441
-            if (defined('ENT_IGNORE')) {
1442
+        } else {
1443
+            if (defined('ENT_IGNORE')) {
1442 1444
                 $token = htmlentities($token[self::TOKEN_VALUE], ENT_COMPAT | ENT_IGNORE, 'UTF-8');
1443
-            } else {
1445
+            } else {
1444 1446
                 $token = htmlentities($token[self::TOKEN_VALUE], ENT_COMPAT, 'UTF-8');
1445 1447
             }
1446 1448
         }
1447 1449
 
1448
-        if ($type === self::TOKEN_TYPE_BOUNDARY) {
1450
+        if ($type === self::TOKEN_TYPE_BOUNDARY) {
1449 1451
             return self::highlightBoundary($token);
1450
-        } elseif ($type === self::TOKEN_TYPE_WORD) {
1452
+        } elseif ($type === self::TOKEN_TYPE_WORD) {
1451 1453
             return self::highlightWord($token);
1452
-        } elseif ($type === self::TOKEN_TYPE_BACKTICK_QUOTE) {
1454
+        } elseif ($type === self::TOKEN_TYPE_BACKTICK_QUOTE) {
1453 1455
             return self::highlightBacktickQuote($token);
1454
-        } elseif ($type === self::TOKEN_TYPE_QUOTE) {
1456
+        } elseif ($type === self::TOKEN_TYPE_QUOTE) {
1455 1457
             return self::highlightQuote($token);
1456
-        } elseif ($type === self::TOKEN_TYPE_RESERVED) {
1458
+        } elseif ($type === self::TOKEN_TYPE_RESERVED) {
1457 1459
             return self::highlightReservedWord($token);
1458
-        } elseif ($type === self::TOKEN_TYPE_RESERVED_TOPLEVEL) {
1460
+        } elseif ($type === self::TOKEN_TYPE_RESERVED_TOPLEVEL) {
1459 1461
             return self::highlightReservedWord($token);
1460
-        } elseif ($type === self::TOKEN_TYPE_RESERVED_NEWLINE) {
1462
+        } elseif ($type === self::TOKEN_TYPE_RESERVED_NEWLINE) {
1461 1463
             return self::highlightReservedWord($token);
1462
-        } elseif ($type === self::TOKEN_TYPE_NUMBER) {
1464
+        } elseif ($type === self::TOKEN_TYPE_NUMBER) {
1463 1465
             return self::highlightNumber($token);
1464
-        } elseif ($type === self::TOKEN_TYPE_VARIABLE) {
1466
+        } elseif ($type === self::TOKEN_TYPE_VARIABLE) {
1465 1467
             return self::highlightVariable($token);
1466
-        } elseif ($type === self::TOKEN_TYPE_COMMENT || $type === self::TOKEN_TYPE_BLOCK_COMMENT) {
1468
+        } elseif ($type === self::TOKEN_TYPE_COMMENT || $type === self::TOKEN_TYPE_BLOCK_COMMENT) {
1467 1469
             return self::highlightComment($token);
1468 1470
         }
1469 1471
 
@@ -1477,11 +1479,11 @@  discard block
 block discarded – undo
1477 1479
      *
1478 1480
      * @return String HTML code of the highlighted token.
1479 1481
      */
1480
-    protected static function highlightQuote($value)
1481
-    {
1482
-        if (self::is_cli()) {
1482
+    protected static function highlightQuote($value)
1483
+    {
1484
+        if (self::is_cli()) {
1483 1485
             return self::$cli_quote . $value . "\x1b[0m";
1484
-        } else {
1486
+        } else {
1485 1487
             return '<span ' . self::$quote_attributes . '>' . $value . '</span>';
1486 1488
         }
1487 1489
     }
@@ -1493,11 +1495,11 @@  discard block
 block discarded – undo
1493 1495
      *
1494 1496
      * @return String HTML code of the highlighted token.
1495 1497
      */
1496
-    protected static function highlightBacktickQuote($value)
1497
-    {
1498
-        if (self::is_cli()) {
1498
+    protected static function highlightBacktickQuote($value)
1499
+    {
1500
+        if (self::is_cli()) {
1499 1501
             return self::$cli_backtick_quote . $value . "\x1b[0m";
1500
-        } else {
1502
+        } else {
1501 1503
             return '<span ' . self::$backtick_quote_attributes . '>' . $value . '</span>';
1502 1504
         }
1503 1505
     }
@@ -1509,11 +1511,11 @@  discard block
 block discarded – undo
1509 1511
      *
1510 1512
      * @return String HTML code of the highlighted token.
1511 1513
      */
1512
-    protected static function highlightReservedWord($value)
1513
-    {
1514
-        if (self::is_cli()) {
1514
+    protected static function highlightReservedWord($value)
1515
+    {
1516
+        if (self::is_cli()) {
1515 1517
             return self::$cli_reserved . $value . "\x1b[0m";
1516
-        } else {
1518
+        } else {
1517 1519
             return '<span ' . self::$reserved_attributes . '>' . $value . '</span>';
1518 1520
         }
1519 1521
     }
@@ -1525,15 +1527,15 @@  discard block
 block discarded – undo
1525 1527
      *
1526 1528
      * @return String HTML code of the highlighted token.
1527 1529
      */
1528
-    protected static function highlightBoundary($value)
1529
-    {
1530
-        if ($value === '(' || $value === ')') {
1530
+    protected static function highlightBoundary($value)
1531
+    {
1532
+        if ($value === '(' || $value === ')') {
1531 1533
             return $value;
1532 1534
         }
1533 1535
 
1534
-        if (self::is_cli()) {
1536
+        if (self::is_cli()) {
1535 1537
             return self::$cli_boundary . $value . "\x1b[0m";
1536
-        } else {
1538
+        } else {
1537 1539
             return '<span ' . self::$boundary_attributes . '>' . $value . '</span>';
1538 1540
         }
1539 1541
     }
@@ -1545,11 +1547,11 @@  discard block
 block discarded – undo
1545 1547
      *
1546 1548
      * @return String HTML code of the highlighted token.
1547 1549
      */
1548
-    protected static function highlightNumber($value)
1549
-    {
1550
-        if (self::is_cli()) {
1550
+    protected static function highlightNumber($value)
1551
+    {
1552
+        if (self::is_cli()) {
1551 1553
             return self::$cli_number . $value . "\x1b[0m";
1552
-        } else {
1554
+        } else {
1553 1555
             return '<span ' . self::$number_attributes . '>' . $value . '</span>';
1554 1556
         }
1555 1557
     }
@@ -1561,11 +1563,11 @@  discard block
 block discarded – undo
1561 1563
      *
1562 1564
      * @return String HTML code of the highlighted token.
1563 1565
      */
1564
-    protected static function highlightError($value)
1565
-    {
1566
-        if (self::is_cli()) {
1566
+    protected static function highlightError($value)
1567
+    {
1568
+        if (self::is_cli()) {
1567 1569
             return self::$cli_error . $value . "\x1b[0m";
1568
-        } else {
1570
+        } else {
1569 1571
             return '<span ' . self::$error_attributes . '>' . $value . '</span>';
1570 1572
         }
1571 1573
     }
@@ -1577,11 +1579,11 @@  discard block
 block discarded – undo
1577 1579
      *
1578 1580
      * @return String HTML code of the highlighted token.
1579 1581
      */
1580
-    protected static function highlightComment($value)
1581
-    {
1582
-        if (self::is_cli()) {
1582
+    protected static function highlightComment($value)
1583
+    {
1584
+        if (self::is_cli()) {
1583 1585
             return self::$cli_comment . $value . "\x1b[0m";
1584
-        } else {
1586
+        } else {
1585 1587
             return '<span ' . self::$comment_attributes . '>' . $value . '</span>';
1586 1588
         }
1587 1589
     }
@@ -1593,11 +1595,11 @@  discard block
 block discarded – undo
1593 1595
      *
1594 1596
      * @return String HTML code of the highlighted token.
1595 1597
      */
1596
-    protected static function highlightWord($value)
1597
-    {
1598
-        if (self::is_cli()) {
1598
+    protected static function highlightWord($value)
1599
+    {
1600
+        if (self::is_cli()) {
1599 1601
             return self::$cli_word . $value . "\x1b[0m";
1600
-        } else {
1602
+        } else {
1601 1603
             return '<span ' . self::$word_attributes . '>' . $value . '</span>';
1602 1604
         }
1603 1605
     }
@@ -1609,11 +1611,11 @@  discard block
 block discarded – undo
1609 1611
      *
1610 1612
      * @return String HTML code of the highlighted token.
1611 1613
      */
1612
-    protected static function highlightVariable($value)
1613
-    {
1614
-        if (self::is_cli()) {
1614
+    protected static function highlightVariable($value)
1615
+    {
1616
+        if (self::is_cli()) {
1615 1617
             return self::$cli_variable . $value . "\x1b[0m";
1616
-        } else {
1618
+        } else {
1617 1619
             return '<span ' . self::$variable_attributes . '>' . $value . '</span>';
1618 1620
         }
1619 1621
     }
@@ -1625,8 +1627,8 @@  discard block
 block discarded – undo
1625 1627
      *
1626 1628
      * @return String The quoted string
1627 1629
      */
1628
-    private static function quote_regex($a)
1629
-    {
1630
+    private static function quote_regex($a)
1631
+    {
1630 1632
         return preg_quote($a, '/');
1631 1633
     }
1632 1634
 
@@ -1637,13 +1639,13 @@  discard block
 block discarded – undo
1637 1639
      *
1638 1640
      * @return String The quoted string
1639 1641
      */
1640
-    private static function output($string)
1641
-    {
1642
-        if (self::is_cli()) {
1642
+    private static function output($string)
1643
+    {
1644
+        if (self::is_cli()) {
1643 1645
             return $string . "\n";
1644
-        } else {
1646
+        } else {
1645 1647
             $string = trim($string);
1646
-            if (!self::$use_pre) {
1648
+            if (!self::$use_pre) {
1647 1649
                 return $string;
1648 1650
             }
1649 1651
 
@@ -1654,11 +1656,11 @@  discard block
 block discarded – undo
1654 1656
     /**
1655 1657
      * @return bool
1656 1658
      */
1657
-    private static function is_cli()
1658
-    {
1659
-        if (isset(self::$cli)) {
1659
+    private static function is_cli()
1660
+    {
1661
+        if (isset(self::$cli)) {
1660 1662
             return self::$cli;
1661
-        } else {
1663
+        } else {
1662 1664
             return php_sapi_name() === 'cli';
1663 1665
         }
1664 1666
     }
Please login to merge, or discard this patch.
assets/snippets/DocLister/core/controller/site_content.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -440,8 +440,8 @@
 block discarded – undo
440 440
     }
441 441
 
442 442
     /**
443
-     * @param $table
444
-     * @param $sort
443
+     * @param string $table
444
+     * @param string $sort
445 445
      * @return array
446 446
      */
447 447
     protected function injectSortByTV($table, $sort)
Please login to merge, or discard this patch.
Upper-Lower-Casing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
             }
277 277
             $where = sqlHelper::trimLogicalOp($where);
278 278
 
279
-            $where = "WHERE {$where}";
279
+            $where = "where {$where}";
280 280
             $whereArr = array();
281 281
             if (!$this->getCFGDef('showNoPublish', 0)) {
282 282
                 $whereArr[] = "c.deleted=0 AND c.published=1";
@@ -358,15 +358,15 @@  discard block
 block discarded – undo
358 358
 
359 359
             if ($this->getCFGDef('showNoPublish', 0)) {
360 360
                 if ($where != '') {
361
-                    $where = "WHERE {$where}";
361
+                    $where = "where {$where}";
362 362
                 } else {
363 363
                     $where = '';
364 364
                 }
365 365
             } else {
366 366
                 if ($where != '') {
367
-                    $where = "WHERE {$where} AND ";
367
+                    $where = "where {$where} AND ";
368 368
                 } else {
369
-                    $where = "WHERE {$where} ";
369
+                    $where = "where {$where} ";
370 370
                 }
371 371
                 $where .= "c.deleted=0 AND c.published=1";
372 372
             }
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 
381 381
             $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0));
382 382
 
383
-            $rs = $this->dbQuery("SELECT {$fields} FROM {$tbl_site_content} {$where} {$group} {$sort} {$limit}");
383
+            $rs = $this->dbQuery("select {$fields} FROM {$tbl_site_content} {$where} {$group} {$sort} {$limit}");
384 384
 
385 385
             $rows = $this->modx->db->makeArray($rs);
386 386
 
@@ -407,9 +407,9 @@  discard block
 block discarded – undo
407 407
         $tbl_site_content = $this->getTable('site_content', 'c');
408 408
         $sanitarInIDs = $this->sanitarIn($id);
409 409
         if ($this->getCFGDef('showNoPublish', 0)) {
410
-            $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1";
410
+            $where = "where {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1";
411 411
         } else {
412
-            $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1";
412
+            $where = "where {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1";
413 413
         }
414 414
 
415 415
         $rs = $this->dbQuery("SELECT id FROM {$tbl_site_content} {$where}");
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
         $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id'));
502 502
 
503 503
         if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
504
-            $sql = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " .
504
+            $sql = $this->dbQuery("select {$fields} FROM " . $from . " " . $where . " " .
505 505
                 $group . " " .
506 506
                 $sort . " " .
507 507
                 $this->LimitSQL($this->getCFGDef('queryLimit', 0))
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('MODX_BASE_PATH')) {
2
+if ( ! defined('MODX_BASE_PATH')) {
3 3
     die('HACK???');
4 4
 }
5 5
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         $this->_docs = ($type == 'parents') ? $this->getChildrenList() : $this->getDocList();
59 59
         if ($tvlist != '' && count($this->_docs) > 0) {
60 60
             $tv = $this->extTV->getTVList(array_keys($this->_docs), $tvlist);
61
-            if (!is_array($tv)) {
61
+            if ( ! is_array($tv)) {
62 62
                 $tv = array();
63 63
             }
64 64
             foreach ($tv as $docID => $TVitem) {
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
 
281 281
             $where = "WHERE {$where}";
282 282
             $whereArr = array();
283
-            if (!$this->getCFGDef('showNoPublish', 0)) {
283
+            if ( ! $this->getCFGDef('showNoPublish', 0)) {
284 284
                 $whereArr[] = "c.deleted=0 AND c.published=1";
285 285
             }
286
-            else{
286
+            else {
287 287
                 $q_true = 1;
288 288
             }
289 289
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 
339 339
             $q_true = $q_true ? $q_true : $group != 'GROUP BY c.id';
340 340
 
341
-            if ( $q_true ){
341
+            if ($q_true) {
342 342
                 $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group}) as `tmp`");
343 343
                 $out = $this->modx->db->getValue($rs);
344 344
             }
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
     protected function injectSortByTV($table, $sort)
446 446
     {
447 447
         $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort);
448
-        if (!is_array($out) || empty($out)) {
448
+        if ( ! is_array($out) || empty($out)) {
449 449
             $out = array($table, $sort);
450 450
         }
451 451
 
@@ -462,12 +462,12 @@  discard block
 block discarded – undo
462 462
 
463 463
         $tmpWhere = $this->getCFGDef('addWhereList', '');
464 464
         $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);
465
-        if (!empty($tmpWhere)) {
465
+        if ( ! empty($tmpWhere)) {
466 466
             $where[] = $tmpWhere;
467 467
         }
468 468
 
469 469
         $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']);
470
-        if (!empty($tmpWhere)) {
470
+        if ( ! empty($tmpWhere)) {
471 471
             $where[] = $tmpWhere;
472 472
         }
473 473
 
@@ -500,13 +500,13 @@  discard block
 block discarded – undo
500 500
                 $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
501 501
             }
502 502
         }
503
-        if (!empty($tmpWhere)) {
503
+        if ( ! empty($tmpWhere)) {
504 504
             $where[] = $tmpWhere;
505 505
         }
506
-        if (!$this->getCFGDef('showNoPublish', 0)) {
506
+        if ( ! $this->getCFGDef('showNoPublish', 0)) {
507 507
             $where[] = "c.deleted=0 AND c.published=1";
508 508
         }
509
-        if (!empty($where)) {
509
+        if ( ! empty($where)) {
510 510
             $where = "WHERE " . implode(" AND ", $where);
511 511
         } else {
512 512
             $where = '';
Please login to merge, or discard this patch.
Braces   +107 added lines, -109 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('MODX_BASE_PATH')) {
2
+if (!defined('MODX_BASE_PATH')) {
3 3
     die('HACK???');
4 4
 }
5 5
 
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
  * @license GNU General Public License (GPL), http://www.gnu.org/copyleft/gpl.html
12 12
  * @author Agel_Nash <[email protected]>, kabachello <[email protected]>
13 13
  */
14
-class site_contentDocLister extends DocLister
15
-{
14
+class site_contentDocLister extends DocLister
15
+{
16 16
     /**
17 17
      * Экземпляр экстендера TV
18 18
      *
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
      * @param array $cfg
33 33
      * @param null $startTime
34 34
      */
35
-    public function __construct($modx, $cfg = array(), $startTime = null)
36
-    {
35
+    public function __construct($modx, $cfg = array(), $startTime = null)
36
+    {
37 37
         parent::__construct($modx, $cfg, $startTime);
38 38
         $this->extTV = $this->getExtender('tv', true, true);
39 39
     }
@@ -41,35 +41,35 @@  discard block
 block discarded – undo
41 41
     /**
42 42
      * @absctract
43 43
      */
44
-    public function getDocs($tvlist = '')
45
-    {
46
-        if ($tvlist == '') {
44
+    public function getDocs($tvlist = '')
45
+    {
46
+        if ($tvlist == '') {
47 47
             $tvlist = $this->getCFGDef('tvList', '');
48 48
         }
49 49
         
50 50
         $this->extTV->getAllTV_Name();
51 51
 
52
-        if ($this->extPaginate = $this->getExtender('paginate')) {
52
+        if ($this->extPaginate = $this->getExtender('paginate')) {
53 53
             $this->extPaginate->init($this);
54
-        } else {
54
+        } else {
55 55
             $this->config->setConfig(array('start' => 0));
56 56
         }
57 57
         $type = $this->getCFGDef('idType', 'parents');
58 58
         $this->_docs = ($type == 'parents') ? $this->getChildrenList() : $this->getDocList();
59
-        if ($tvlist != '' && count($this->_docs) > 0) {
59
+        if ($tvlist != '' && count($this->_docs) > 0) {
60 60
             $tv = $this->extTV->getTVList(array_keys($this->_docs), $tvlist);
61
-            if (!is_array($tv)) {
61
+            if (!is_array($tv)) {
62 62
                 $tv = array();
63 63
             }
64
-            foreach ($tv as $docID => $TVitem) {
65
-                if (isset($this->_docs[$docID]) && is_array($this->_docs[$docID])) {
64
+            foreach ($tv as $docID => $TVitem) {
65
+                if (isset($this->_docs[$docID]) && is_array($this->_docs[$docID])) {
66 66
                     $this->_docs[$docID] = array_merge($this->_docs[$docID], $TVitem);
67
-                } else {
67
+                } else {
68 68
                     unset($this->_docs[$docID]);
69 69
                 }
70 70
             }
71 71
         }
72
-        if (1 == $this->getCFGDef('tree', '0')) {
72
+        if (1 == $this->getCFGDef('tree', '0')) {
73 73
             $this->treeBuild('id', 'parent');
74 74
         }
75 75
 
@@ -80,24 +80,24 @@  discard block
 block discarded – undo
80 80
      * @param string $tpl
81 81
      * @return string
82 82
      */
83
-    public function _render($tpl = '')
84
-    {
83
+    public function _render($tpl = '')
84
+    {
85 85
         $out = '';
86
-        if ($tpl == '') {
86
+        if ($tpl == '') {
87 87
             $tpl = $this->getCFGDef('tpl', '@CODE:<a href="[+url+]">[+pagetitle+]</a><br />');
88 88
         }
89
-        if ($tpl != '') {
89
+        if ($tpl != '') {
90 90
             $date = $this->getCFGDef('dateSource', 'pub_date');
91 91
 
92 92
             $this->toPlaceholders(count($this->_docs), 1, "display"); // [+display+] - сколько показано на странице.
93 93
 
94 94
             $i = 1;
95 95
             $sysPlh = $this->renameKeyArr($this->_plh, $this->getCFGDef("sysKey", "dl"));
96
-            if (count($this->_docs) > 0) {
96
+            if (count($this->_docs) > 0) {
97 97
                 /**
98 98
                  * @var $extUser user_DL_Extender
99 99
                  */
100
-                if ($extUser = $this->getExtender('user')) {
100
+                if ($extUser = $this->getExtender('user')) {
101 101
                     $extUser->init($this, array('fields' => $this->getCFGDef("userFields", "")));
102 102
                 }
103 103
 
@@ -116,20 +116,20 @@  discard block
 block discarded – undo
116 116
                  */
117 117
                 $extJotCount = $this->getCFGdef('jotcount', 0) ? $this->getExtender('jotcount', true) : null;
118 118
 
119
-                if ($extJotCount) {
119
+                if ($extJotCount) {
120 120
                     $comments = $extJotCount->countComments(array_keys($this->_docs));
121 121
                 }
122 122
 
123 123
                 $this->skippedDocs = 0;
124
-                foreach ($this->_docs as $item) {
124
+                foreach ($this->_docs as $item) {
125 125
                     $this->renderTPL = $tpl;
126
-                    if ($extUser) {
126
+                    if ($extUser) {
127 127
                         $item = $extUser->setUserData($item); //[+user.id.createdby+], [+user.fullname.publishedby+], [+dl.user.publishedby+]....
128 128
                     }
129 129
 
130 130
                     $item['summary'] = $extSummary ? $this->getSummary($item, $extSummary, 'introtext', 'content') : '';
131 131
 
132
-                    if ($extJotCount) {
132
+                    if ($extJotCount) {
133 133
                         $item['jotcount'] = APIHelpers::getkey($comments, $item['id'], 0);
134 134
                     }
135 135
 
@@ -139,20 +139,20 @@  discard block
 block discarded – undo
139 139
 
140 140
                     $item['title'] = ($item['menutitle'] == '' ? $item['pagetitle'] : $item['menutitle']);
141 141
 
142
-                    if ($this->getCFGDef('makeUrl', 1)) {
143
-                        if ($item['type'] == 'reference') {
142
+                    if ($this->getCFGDef('makeUrl', 1)) {
143
+                        if ($item['type'] == 'reference') {
144 144
                             $item['url'] = is_numeric($item['content']) ? $this->modx->makeUrl($item['content'], '', '',
145 145
                                 $this->getCFGDef('urlScheme', '')) : $item['content'];
146
-                        } else {
146
+                        } else {
147 147
                             $item['url'] = $this->modx->makeUrl($item['id'], '', '', $this->getCFGDef('urlScheme', ''));
148 148
                         }
149 149
                     }
150 150
 
151
-                    if (isset($item[$date])) {
151
+                    if (isset($item[$date])) {
152 152
                         $_date = is_numeric($item[$date]) && $item[$date] == (int)$item[$date] ? $item[$date] : strtotime($item[$date]);
153
-                        if ($_date !== false) {
153
+                        if ($_date !== false) {
154 154
                             $_date = $_date + $this->modx->config['server_offset_time'];
155
-                            if ($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') {
155
+                            if ($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') {
156 156
                                 $item['date'] = strftime($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'), $_date);
157 157
                             }
158 158
                         }
@@ -161,35 +161,35 @@  discard block
 block discarded – undo
161 161
                     $findTpl = $this->renderTPL;
162 162
                     $tmp = $this->uniformPrepare($item, $i);
163 163
                     extract($tmp, EXTR_SKIP);
164
-                    if ($this->renderTPL == '') {
164
+                    if ($this->renderTPL == '') {
165 165
                         $this->renderTPL = $findTpl;
166 166
                     }
167 167
 
168
-                    if ($extPrepare) {
168
+                    if ($extPrepare) {
169 169
                         $item = $extPrepare->init($this, array(
170 170
                             'data'      => $item,
171 171
                             'nameParam' => 'prepare'
172 172
                         ));
173
-                        if (is_bool($item) && $item === false) {
173
+                        if (is_bool($item) && $item === false) {
174 174
                             $this->skippedDocs++;
175 175
                             continue;
176 176
                         }
177 177
                     }
178 178
                     $tmp = $this->parseChunk($this->renderTPL, $item);
179 179
 
180
-                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
180
+                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
181 181
                         $this->toPlaceholders($tmp, 1,
182 182
                             "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page
183 183
                     }
184 184
                     $out .= $tmp;
185 185
                     $i++;
186 186
                 }
187
-            } else {
187
+            } else {
188 188
                 $noneTPL = $this->getCFGDef("noneTPL", "");
189 189
                 $out = ($noneTPL != '') ? $this->parseChunk($noneTPL, $sysPlh) : '';
190 190
             }
191 191
             $out = $this->renderWrap($out);
192
-        } else {
192
+        } else {
193 193
             $out = 'no template';
194 194
         }
195 195
 
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
      * @param array $array
203 203
      * @return string
204 204
      */
205
-    public function getJSON($data, $fields, $array = array())
206
-    {
205
+    public function getJSON($data, $fields, $array = array())
206
+    {
207 207
         $out = array();
208 208
         $fields = is_array($fields) ? $fields : explode(",", $fields);
209 209
         $date = $this->getCFGDef('dateSource', 'pub_date');
@@ -223,44 +223,44 @@  discard block
 block discarded – undo
223 223
          */
224 224
         $extE = $this->getExtender('e', true, true);
225 225
 
226
-        foreach ($data as $num => $item) {
226
+        foreach ($data as $num => $item) {
227 227
             $row = $item;
228
-            if ((array('1') == $fields || in_array('summary', $fields)) && $extSummary) {
228
+            if ((array('1') == $fields || in_array('summary', $fields)) && $extSummary) {
229 229
                 $row['summary'] = $this->getSummary($this->_docs[$num], $extSummary, 'introtext', 'content');
230 230
             }
231
-            if (array('1') == $fields || in_array('date', $fields)) {
232
-                if (isset($this->_docs[$num][$date])) {
231
+            if (array('1') == $fields || in_array('date', $fields)) {
232
+                if (isset($this->_docs[$num][$date])) {
233 233
                     $_date = is_numeric($this->_docs[$num][$date]) && $this->_docs[$num][$date] == (int)$this->_docs[$num][$date] ? $this->_docs[$num][$date] : strtotime($this->_docs[$num][$date]);
234
-                    if ($_date !== false) {
234
+                    if ($_date !== false) {
235 235
                         $_date = $_date + $this->modx->config['server_offset_time'];
236
-                        if ($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') {
236
+                        if ($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') {
237 237
                             $row['date'] = strftime($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'), $_date);
238 238
                         }
239 239
                     }
240 240
                 }
241 241
             }
242
-            if (array('1') == $fields || in_array(array('menutitle', 'pagetitle'), $fields)) {
242
+            if (array('1') == $fields || in_array(array('menutitle', 'pagetitle'), $fields)) {
243 243
                 $row['title'] = ($row['menutitle'] == '' ? $row['pagetitle'] : $row['menutitle']);
244 244
             }
245 245
             if ((bool)$this->getCFGDef('makeUrl', 1) && (array('1') == $fields || in_array(array('content', 'type'),
246 246
                         $fields))
247
-            ) {
248
-                if ($row['type'] == 'reference') {
247
+            ) {
248
+                if ($row['type'] == 'reference') {
249 249
                     $row['url'] = is_numeric($row['content']) ? $this->modx->makeUrl($row['content'], '', '',
250 250
                         $this->getCFGDef('urlScheme', '')) : $row['content'];
251
-                } else {
251
+                } else {
252 252
                     $row['url'] = $this->modx->makeUrl($row['id'], '', '', $this->getCFGDef('urlScheme', ''));
253 253
                 }
254 254
             }
255
-            if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
256
-                if (is_array($tmp)) {
255
+            if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
256
+                if (is_array($tmp)) {
257 257
                     $row = $tmp;
258 258
                 }
259 259
             }
260 260
 
261
-            if ($extPrepare) {
261
+            if ($extPrepare) {
262 262
                 $row = $extPrepare->init($this, array('data' => $row));
263
-                if (is_bool($row) && $row === false) {
263
+                if (is_bool($row) && $row === false) {
264 264
                     continue;
265 265
                 }
266 266
             }
@@ -273,36 +273,35 @@  discard block
 block discarded – undo
273 273
     /**
274 274
      * @abstract
275 275
      */
276
-    public function getChildrenCount()
277
-    {
276
+    public function getChildrenCount()
277
+    {
278 278
         $out = 0;
279 279
         $sanitarInIDs = $this->sanitarIn($this->IDs);
280
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
280
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
281 281
             $q_true = $this->getCFGDef('ignoreEmpty', '0');
282 282
             $q_true = $q_true ? $q_true : $this->getCFGDef('idType', 'parents') == 'parents';
283 283
             $where = $this->getCFGDef('addWhereList', '');
284 284
             $where = sqlHelper::trimLogicalOp($where);
285 285
             $where = ($where ? $where . ' AND ' : '') . $this->_filters['where'];
286
-            if ($where != '' && $this->_filters['where'] != '') {
286
+            if ($where != '' && $this->_filters['where'] != '') {
287 287
                 $where .= " AND ";
288 288
             }
289 289
             $where = sqlHelper::trimLogicalOp($where);
290 290
 
291 291
             $where = "WHERE {$where}";
292 292
             $whereArr = array();
293
-            if (!$this->getCFGDef('showNoPublish', 0)) {
293
+            if (!$this->getCFGDef('showNoPublish', 0)) {
294 294
                 $whereArr[] = "c.deleted=0 AND c.published=1";
295
-            }
296
-            else{
295
+            } else {
297 296
                 $q_true = 1;
298 297
             }
299 298
 
300 299
             $tbl_site_content = $this->getTable('site_content', 'c');
301 300
 
302
-            if ($sanitarInIDs != "''") {
303
-                switch ($this->getCFGDef('idType', 'parents')) {
301
+            if ($sanitarInIDs != "''") {
302
+                switch ($this->getCFGDef('idType', 'parents')) {
304 303
                     case 'parents':
305
-                        switch ($this->getCFGDef('showParent', '0')) {
304
+                        switch ($this->getCFGDef('showParent', '0')) {
306 305
                             case '-1':
307 306
                                 $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")";
308 307
                                 break;
@@ -314,10 +313,10 @@  discard block
 block discarded – undo
314 313
                                 $tmpWhere = "(c.parent IN ({$sanitarInIDs}) OR c.id IN({$sanitarInIDs}))";
315 314
                                 break;
316 315
                         }
317
-                        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
316
+                        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
318 317
                             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
319 318
                             $whereArr[] = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
320
-                        } else {
319
+                        } else {
321 320
                             $whereArr[] = $tmpWhere;
322 321
                         }
323 322
 
@@ -332,14 +331,14 @@  discard block
 block discarded – undo
332 331
 
333 332
             $q_true = $q_true ? $q_true : trim($where) != 'WHERE';
334 333
 
335
-            if (trim($where) != 'WHERE') {
334
+            if (trim($where) != 'WHERE') {
336 335
                 $where .= " AND ";
337 336
             }
338 337
 
339 338
             $where .= implode(" AND ", $whereArr);
340 339
             $where = sqlHelper::trimLogicalOp($where);
341 340
 
342
-            if (trim($where) == 'WHERE') {
341
+            if (trim($where) == 'WHERE') {
343 342
                 $where = '';
344 343
             }
345 344
             $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id'));
@@ -348,11 +347,10 @@  discard block
 block discarded – undo
348 347
 
349 348
             $q_true = $q_true ? $q_true : $group != 'GROUP BY c.id';
350 349
 
351
-            if ( $q_true ){
350
+            if ( $q_true ) {
352 351
                 $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group}) as `tmp`");
353 352
                 $out = $this->modx->db->getValue($rs);
354
-            }
355
-            else {
353
+            } else {
356 354
                 $out = count($this->IDs);
357 355
             }
358 356
         }
@@ -363,11 +361,11 @@  discard block
 block discarded – undo
363 361
     /**
364 362
      * @return array
365 363
      */
366
-    protected function getDocList()
367
-    {
364
+    protected function getDocList()
365
+    {
368 366
         $out = array();
369 367
         $sanitarInIDs = $this->sanitarIn($this->IDs);
370
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
368
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
371 369
             $where = $this->getCFGDef('addWhereList', '');
372 370
             $where = sqlHelper::trimLogicalOp($where);
373 371
 
@@ -375,21 +373,21 @@  discard block
 block discarded – undo
375 373
             $where = sqlHelper::trimLogicalOp($where);
376 374
 
377 375
             $tbl_site_content = $this->getTable('site_content', 'c');
378
-            if ($sanitarInIDs != "''") {
376
+            if ($sanitarInIDs != "''") {
379 377
                 $where .= ($where ? " AND " : "") . "c.id IN ({$sanitarInIDs}) AND";
380 378
             }
381 379
             $where = sqlHelper::trimLogicalOp($where);
382 380
 
383
-            if ($this->getCFGDef('showNoPublish', 0)) {
384
-                if ($where != '') {
381
+            if ($this->getCFGDef('showNoPublish', 0)) {
382
+                if ($where != '') {
385 383
                     $where = "WHERE {$where}";
386
-                } else {
384
+                } else {
387 385
                     $where = '';
388 386
                 }
389
-            } else {
390
-                if ($where != '') {
387
+            } else {
388
+                if ($where != '') {
391 389
                     $where = "WHERE {$where} AND ";
392
-                } else {
390
+                } else {
393 391
                     $where = "WHERE {$where} ";
394 392
                 }
395 393
                 $where .= "c.deleted=0 AND c.published=1";
@@ -408,7 +406,7 @@  discard block
 block discarded – undo
408 406
 
409 407
             $rows = $this->modx->db->makeArray($rs);
410 408
 
411
-            foreach ($rows as $item) {
409
+            foreach ($rows as $item) {
412 410
                 $out[$item['id']] = $item;
413 411
             }
414 412
         }
@@ -420,19 +418,19 @@  discard block
 block discarded – undo
420 418
      * @param string $id
421 419
      * @return array
422 420
      */
423
-    public function getChildrenFolder($id)
424
-    {
421
+    public function getChildrenFolder($id)
422
+    {
425 423
         $where = $this->getCFGDef('addWhereFolder', '');
426 424
         $where = sqlHelper::trimLogicalOp($where);
427
-        if ($where != '') {
425
+        if ($where != '') {
428 426
             $where .= " AND ";
429 427
         }
430 428
 
431 429
         $tbl_site_content = $this->getTable('site_content', 'c');
432 430
         $sanitarInIDs = $this->sanitarIn($id);
433
-        if ($this->getCFGDef('showNoPublish', 0)) {
431
+        if ($this->getCFGDef('showNoPublish', 0)) {
434 432
             $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1";
435
-        } else {
433
+        } else {
436 434
             $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1";
437 435
         }
438 436
 
@@ -440,7 +438,7 @@  discard block
 block discarded – undo
440 438
 
441 439
         $rows = $this->modx->db->makeArray($rs);
442 440
         $out = array();
443
-        foreach ($rows as $item) {
441
+        foreach ($rows as $item) {
444 442
             $out[] = $item['id'];
445 443
         }
446 444
 
@@ -452,10 +450,10 @@  discard block
 block discarded – undo
452 450
      * @param $sort
453 451
      * @return array
454 452
      */
455
-    protected function injectSortByTV($table, $sort)
456
-    {
453
+    protected function injectSortByTV($table, $sort)
454
+    {
457 455
         $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort);
458
-        if (!is_array($out) || empty($out)) {
456
+        if (!is_array($out) || empty($out)) {
459 457
             $out = array($table, $sort);
460 458
         }
461 459
 
@@ -465,19 +463,19 @@  discard block
 block discarded – undo
465 463
     /**
466 464
      * @return array
467 465
      */
468
-    protected function getChildrenList()
469
-    {
466
+    protected function getChildrenList()
467
+    {
470 468
         $where = array();
471 469
         $out = array();
472 470
 
473 471
         $tmpWhere = $this->getCFGDef('addWhereList', '');
474 472
         $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);
475
-        if (!empty($tmpWhere)) {
473
+        if (!empty($tmpWhere)) {
476 474
             $where[] = $tmpWhere;
477 475
         }
478 476
 
479 477
         $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']);
480
-        if (!empty($tmpWhere)) {
478
+        if (!empty($tmpWhere)) {
481 479
             $where[] = $tmpWhere;
482 480
         }
483 481
 
@@ -488,8 +486,8 @@  discard block
 block discarded – undo
488 486
         $sanitarInIDs = $this->sanitarIn($this->IDs);
489 487
 
490 488
         $tmpWhere = null;
491
-        if ($sanitarInIDs != "''") {
492
-            switch ($this->getCFGDef('showParent', '0')) {
489
+        if ($sanitarInIDs != "''") {
490
+            switch ($this->getCFGDef('showParent', '0')) {
493 491
                 case '-1':
494 492
                     $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")";
495 493
                     break;
@@ -502,29 +500,29 @@  discard block
 block discarded – undo
502 500
                     break;
503 501
             }
504 502
         }
505
-        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
503
+        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
506 504
             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
507
-            if (empty($tmpWhere)) {
505
+            if (empty($tmpWhere)) {
508 506
                 $tmpWhere = "c.id IN({$addDocs})";
509
-            } else {
507
+            } else {
510 508
                 $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
511 509
             }
512 510
         }
513
-        if (!empty($tmpWhere)) {
511
+        if (!empty($tmpWhere)) {
514 512
             $where[] = $tmpWhere;
515 513
         }
516
-        if (!$this->getCFGDef('showNoPublish', 0)) {
514
+        if (!$this->getCFGDef('showNoPublish', 0)) {
517 515
             $where[] = "c.deleted=0 AND c.published=1";
518 516
         }
519
-        if (!empty($where)) {
517
+        if (!empty($where)) {
520 518
             $where = "WHERE " . implode(" AND ", $where);
521
-        } else {
519
+        } else {
522 520
             $where = '';
523 521
         }
524 522
         $fields = $this->getCFGDef('selectFields', 'c.*');
525 523
         $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id'));
526 524
 
527
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
525
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
528 526
             $sql = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " .
529 527
                 $group . " " .
530 528
                 $sort . " " .
@@ -533,7 +531,7 @@  discard block
 block discarded – undo
533 531
 
534 532
             $rows = $this->modx->db->makeArray($sql);
535 533
 
536
-            foreach ($rows as $item) {
534
+            foreach ($rows as $item) {
537 535
                 $out[$item['id']] = $item;
538 536
             }
539 537
         }
@@ -546,10 +544,10 @@  discard block
 block discarded – undo
546 544
      * @param string $type
547 545
      * @return string
548 546
      */
549
-    public function changeSortType($field, $type)
550
-    {
547
+    public function changeSortType($field, $type)
548
+    {
551 549
         $type = trim($type);
552
-        switch (strtoupper($type)) {
550
+        switch (strtoupper($type)) {
553 551
             case 'TVDATETIME':
554 552
                 $field = "STR_TO_DATE(" . $field . ",'%d-%m-%Y %H:%i:%s')";
555 553
                 break;
Please login to merge, or discard this patch.
assets/snippets/DocLister/snippet.DLReflect.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,10 +44,10 @@
 block discarded – undo
44 44
 $reflectTPL = APIHelpers::getkey($params, 'reflectTPL',
45 45
     '@CODE: <li><a href="[+url+]" title="[+title+]">[+title+]</a></li>');
46 46
 /**
47
- * activeReflectTPL
48
- *        Шаблон активной даты.
49
- *    Поддерживается такие же плейсхолдеры, как и в шаблоне reflectTPL
50
- */
47
+     * activeReflectTPL
48
+     *        Шаблон активной даты.
49
+     *    Поддерживается такие же плейсхолдеры, как и в шаблоне reflectTPL
50
+     */
51 51
 $activeReflectTPL = APIHelpers::getkey($params, 'activeReflectTPL', '@CODE: <li><span>[+title+]</span></li>');
52 52
 
53 53
 list($dateFormat, $sqlDateFormat, $reflectValidator) = DLReflect::switchReflect($reflectType, function () {
Please login to merge, or discard this patch.
Braces   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *            year - по годам
26 26
  */
27 27
 $reflectType = APIHelpers::getkey($params, 'reflectType', 'month');
28
-if (!in_array($reflectType, array('year', 'month'))) {
28
+if (!in_array($reflectType, array('year', 'month'))) {
29 29
     return '';
30 30
 }
31 31
 
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
  */
51 51
 $activeReflectTPL = APIHelpers::getkey($params, 'activeReflectTPL', '@CODE: <li><span>[+title+]</span></li>');
52 52
 
53
-list($dateFormat, $sqlDateFormat, $reflectValidator) = DLReflect::switchReflect($reflectType, function () {
53
+list($dateFormat, $sqlDateFormat, $reflectValidator) = DLReflect::switchReflect($reflectType, function () {
54 54
     return array('m-Y', '%m-%Y', array('DLReflect', 'validateMonth'));
55
-}, function () {
55
+}, function () {
56 56
     return array('Y', '%Y', array('DLReflect', 'validateYear'));
57 57
 });
58 58
 $tmp = $originalDate = date($dateFormat);
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
  *        Если не указан в параметре, то генерируется автоматически текущая дата
66 66
  */
67 67
 $currentReflect = APIHelpers::getkey($params, 'currentReflect', $tmp);
68
-if (!call_user_func($reflectValidator, $currentYear)) {
68
+if (!call_user_func($reflectValidator, $currentYear)) {
69 69
     $currentReflect = $tmp;
70 70
 }
71 71
 $originalCurrentReflect = $currentReflect;
72 72
 
73 73
 $selectCurrentReflect = APIHelpers::getkey($params, 'selectCurrentReflect', 1);
74
-if (!$selectCurrentReflect && $currentReflect == $tmp) {
74
+if (!$selectCurrentReflect && $currentReflect == $tmp) {
75 75
     $currentReflect = null;
76 76
 }
77 77
 
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
  */
100 100
 $tmp = APIHelpers::getkey($params, 'activeReflect', $currentReflect);
101 101
 $tmpGet = APIHelpers::getkey($_GET, $reflectType, $tmp);
102
-if (!call_user_func($reflectValidator, $tmpGet)) {
102
+if (!call_user_func($reflectValidator, $tmpGet)) {
103 103
     $activeReflect = $tmp;
104
-    if (!call_user_func($reflectValidator, $activeReflect)) {
104
+    if (!call_user_func($reflectValidator, $activeReflect)) {
105 105
         $activeReflect = $currentReflect;
106 106
     }
107
-} else {
107
+} else {
108 108
     $activeReflect = $tmpGet;
109 109
 }
110 110
 
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
 $DLParams['api'] = 'id';
160 160
 $DLParams['orderBy'] = $reflectField;
161 161
 $DLParams['saveDLObject'] = 'DLAPI';
162
-if ($reflectSource == 'tv') {
162
+if ($reflectSource == 'tv') {
163 163
     $DLParams['tvSortType'] = 'TVDATETIME';
164 164
     $DLParams['selectFields'] = "DATE_FORMAT(STR_TO_DATE(`dltv_" . $reflectField . "_1`.`value`,'%d-%m-%Y %H:%i:%s'), '" . $sqlDateFormat . "') as `id`";
165
-} else {
165
+} else {
166 166
     $DLParams['orderBy'] = $reflectField;
167 167
     $DLParams['selectFields'] = "DATE_FORMAT(FROM_UNIXTIME(" . $reflectField . "), '" . $sqlDateFormat . "') as `id`";
168 168
 }
@@ -170,32 +170,32 @@  discard block
 block discarded – undo
170 170
 /** Получаем объект DocLister'a */
171 171
 $DLAPI = $modx->getPlaceholder('DLAPI');
172 172
 
173
-if ($reflectType == 'month') {
173
+if ($reflectType == 'month') {
174 174
     //Загружаем лексикон с месяцами
175 175
     $DLAPI->loadLang('months');
176 176
 }
177 177
 
178 178
 /** Разбираем API ответ от DocLister'a */
179 179
 $totalReflects = json_decode($totalReflects, true);
180
-if (is_null($totalReflects)) {
180
+if (is_null($totalReflects)) {
181 181
     $totalReflects = array();
182 182
 }
183 183
 $totalReflects = new DLCollection($modx, $totalReflects);
184
-$totalReflects = $totalReflects->filter(function ($el) {
184
+$totalReflects = $totalReflects->filter(function ($el) {
185 185
     return !empty($el['id']);
186 186
 });
187 187
 /** Добавляем активную дату в коллекцию */
188
-if (!is_null($activeReflect)) {
188
+if (!is_null($activeReflect)) {
189 189
     $totalReflects->add(array('id' => $activeReflect), $activeReflect);
190 190
 }
191 191
 $hasCurrentReflect = ($totalReflects->indexOf(array('id' => $originalCurrentReflect)) !== false);
192 192
 
193 193
 /** Добавляем текущую дату в коллекцию */
194
-if ($appendCurrentReflect) {
194
+if ($appendCurrentReflect) {
195 195
     $totalReflects->add(array('id' => $originalCurrentReflect), $originalCurrentReflect);
196 196
 }
197 197
 /** Сортируем даты по возрастанию */
198
-$totalReflects->sort(function ($a, $b) use ($dateFormat) {
198
+$totalReflects->sort(function ($a, $b) use ($dateFormat) {
199 199
     $aDate = DateTime::createFromFormat($dateFormat, $a['id']);
200 200
     $bDate = DateTime::createFromFormat($dateFormat, $b['id']);
201 201
 
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
     $activeReflect,
208 208
     $originalDate,
209 209
     $dateFormat
210
-) {
210
+) {
211 211
     $aDate = DateTime::createFromFormat($dateFormat, $val['id']);
212
-    if (is_null($activeReflect)) {
212
+    if (is_null($activeReflect)) {
213 213
         $activeReflect = $originalDate;
214 214
     }
215 215
     $bDate = DateTime::createFromFormat($dateFormat, $activeReflect);
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
     return $aDate->getTimestamp() < $bDate->getTimestamp();
218 218
 });
219 219
 /** Удаляем текущую активную дату из списка дат идущих за текущим */
220
-if ($rReflect->indexOf(array('id' => $originalCurrentReflect)) !== false) {
220
+if ($rReflect->indexOf(array('id' => $originalCurrentReflect)) !== false) {
221 221
     $rReflect->reindex()->remove(0);
222 222
 }
223 223
 /** Разворачиваем в обратном порядке список дат до текущей даты */
@@ -225,13 +225,13 @@  discard block
 block discarded – undo
225 225
 
226 226
 /** Расчитываем сколько дат из какого списка взять */
227 227
 $showBefore = ($lReflect->count() < $limitBefore || empty($limitBefore)) ? $lReflect->count() : $limitBefore;
228
-if (($rReflect->count() < $limitAfter) || empty($limitAfter)) {
228
+if (($rReflect->count() < $limitAfter) || empty($limitAfter)) {
229 229
     $showAfter = $rReflect->count();
230 230
     $showBefore += !empty($limitAfter) ? ($limitAfter - $rReflect->count()) : 0;
231
-} else {
232
-    if ($limitBefore > 0) {
231
+} else {
232
+    if ($limitBefore > 0) {
233 233
         $showAfter = $limitAfter + ($limitBefore - $showBefore);
234
-    } else {
234
+    } else {
235 235
         $showAfter = $limitAfter;
236 236
     }
237 237
 }
@@ -241,25 +241,25 @@  discard block
 block discarded – undo
241 241
 $outReflects = new DLCollection($modx);
242 242
 /** Берем нужное число элементов с левой стороны */
243 243
 $i = 0;
244
-foreach ($lReflect as $item) {
245
-    if ((++$i) > $showBefore) {
244
+foreach ($lReflect as $item) {
245
+    if ((++$i) > $showBefore) {
246 246
         break;
247 247
     }
248 248
     $outReflects->add($item['id']);
249 249
 }
250 250
 /** Добавляем текущую дату */
251
-if (is_null($activeReflect)) {
252
-    if (($hasCurrentReflect && !$selectCurrentReflect) || $appendCurrentReflect) {
251
+if (is_null($activeReflect)) {
252
+    if (($hasCurrentReflect && !$selectCurrentReflect) || $appendCurrentReflect) {
253 253
         $outReflects->add($originalCurrentReflect);
254 254
     }
255
-} else {
255
+} else {
256 256
     $outReflects->add($activeReflect);
257 257
 }
258 258
 
259 259
 /** Берем оставшее число позиций с правой стороны */
260 260
 $i = 0;
261
-foreach ($rReflect as $item) {
262
-    if ((++$i) > $showAfter) {
261
+foreach ($rReflect as $item) {
262
+    if ((++$i) > $showAfter) {
263 263
         break;
264 264
     }
265 265
     $outReflects->add($item['id']);
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
 
268 268
 $sortDir = APIHelpers::getkey($params, 'sortDir', 'ASC');
269 269
 /** Сортируем результатирующий список  */
270
-$outReflects = $outReflects->sort(function ($a, $b) use ($sortDir, $dateFormat) {
270
+$outReflects = $outReflects->sort(function ($a, $b) use ($sortDir, $dateFormat) {
271 271
     $aDate = DateTime::createFromFormat($dateFormat, $a);
272 272
     $bDate = DateTime::createFromFormat($dateFormat, $b);
273 273
     $out = false;
274
-    switch ($sortDir) {
274
+    switch ($sortDir) {
275 275
         case 'ASC':
276 276
             $out = $aDate->getTimestamp() - $bDate->getTimestamp();
277 277
             break;
@@ -284,10 +284,10 @@  discard block
 block discarded – undo
284 284
 })->reindex()->unique();
285 285
 
286 286
 /** Применяем шаблон к каждой отображаемой дате */
287
-foreach ($outReflects as $reflectItem) {
287
+foreach ($outReflects as $reflectItem) {
288 288
     $tpl = (!is_null($activeReflect) && $activeReflect == $reflectItem) ? $activeReflectTPL : $reflectTPL;
289 289
 
290
-    $data = DLReflect::switchReflect($reflectType, function () use ($reflectItem, $DLAPI) {
290
+    $data = DLReflect::switchReflect($reflectType, function () use ($reflectItem, $DLAPI) {
291 291
         list($vMonth, $vYear) = explode('-', $reflectItem, 2);
292 292
 
293 293
         return array(
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
             'monthName' => $DLAPI->getMsg('months.' . (int)$vMonth),
296 296
             'year'      => $vYear,
297 297
         );
298
-    }, function () use ($reflectItem) {
298
+    }, function () use ($reflectItem) {
299 299
         return array(
300 300
             'year' => $reflectItem
301 301
         );
@@ -321,9 +321,9 @@  discard block
 block discarded – undo
321 321
 /**
322 322
  * Ну и выводим стек отладки если это нужно
323 323
  */
324
-if (isset($_SESSION['usertype']) && $_SESSION['usertype'] == 'manager') {
324
+if (isset($_SESSION['usertype']) && $_SESSION['usertype'] == 'manager') {
325 325
     $debug = $DLAPI->debug->showLog();
326
-} else {
326
+} else {
327 327
     $debug = '';
328 328
 }
329 329
 
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *            year - по годам
26 26
  */
27 27
 $reflectType = APIHelpers::getkey($params, 'reflectType', 'month');
28
-if (!in_array($reflectType, array('year', 'month'))) {
28
+if ( ! in_array($reflectType, array('year', 'month'))) {
29 29
     return '';
30 30
 }
31 31
 
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
  */
51 51
 $activeReflectTPL = APIHelpers::getkey($params, 'activeReflectTPL', '@CODE: <li><span>[+title+]</span></li>');
52 52
 
53
-list($dateFormat, $sqlDateFormat, $reflectValidator) = DLReflect::switchReflect($reflectType, function () {
53
+list($dateFormat, $sqlDateFormat, $reflectValidator) = DLReflect::switchReflect($reflectType, function() {
54 54
     return array('m-Y', '%m-%Y', array('DLReflect', 'validateMonth'));
55
-}, function () {
55
+}, function() {
56 56
     return array('Y', '%Y', array('DLReflect', 'validateYear'));
57 57
 });
58 58
 $tmp = $originalDate = date($dateFormat);
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
  *        Если не указан в параметре, то генерируется автоматически текущая дата
66 66
  */
67 67
 $currentReflect = APIHelpers::getkey($params, 'currentReflect', $tmp);
68
-if (!call_user_func($reflectValidator, $currentYear)) {
68
+if ( ! call_user_func($reflectValidator, $currentYear)) {
69 69
     $currentReflect = $tmp;
70 70
 }
71 71
 $originalCurrentReflect = $currentReflect;
72 72
 
73 73
 $selectCurrentReflect = APIHelpers::getkey($params, 'selectCurrentReflect', 1);
74
-if (!$selectCurrentReflect && $currentReflect == $tmp) {
74
+if ( ! $selectCurrentReflect && $currentReflect == $tmp) {
75 75
     $currentReflect = null;
76 76
 }
77 77
 
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
  */
100 100
 $tmp = APIHelpers::getkey($params, 'activeReflect', $currentReflect);
101 101
 $tmpGet = APIHelpers::getkey($_GET, $reflectType, $tmp);
102
-if (!call_user_func($reflectValidator, $tmpGet)) {
102
+if ( ! call_user_func($reflectValidator, $tmpGet)) {
103 103
     $activeReflect = $tmp;
104
-    if (!call_user_func($reflectValidator, $activeReflect)) {
104
+    if ( ! call_user_func($reflectValidator, $activeReflect)) {
105 105
         $activeReflect = $currentReflect;
106 106
     }
107 107
 } else {
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
     $totalReflects = array();
182 182
 }
183 183
 $totalReflects = new DLCollection($modx, $totalReflects);
184
-$totalReflects = $totalReflects->filter(function ($el) {
185
-    return !empty($el['id']);
184
+$totalReflects = $totalReflects->filter(function($el) {
185
+    return ! empty($el['id']);
186 186
 });
187 187
 /** Добавляем активную дату в коллекцию */
188
-if (!is_null($activeReflect)) {
188
+if ( ! is_null($activeReflect)) {
189 189
     $totalReflects->add(array('id' => $activeReflect), $activeReflect);
190 190
 }
191 191
 $hasCurrentReflect = ($totalReflects->indexOf(array('id' => $originalCurrentReflect)) !== false);
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     $totalReflects->add(array('id' => $originalCurrentReflect), $originalCurrentReflect);
196 196
 }
197 197
 /** Сортируем даты по возрастанию */
198
-$totalReflects->sort(function ($a, $b) use ($dateFormat) {
198
+$totalReflects->sort(function($a, $b) use ($dateFormat) {
199 199
     $aDate = DateTime::createFromFormat($dateFormat, $a['id']);
200 200
     $bDate = DateTime::createFromFormat($dateFormat, $b['id']);
201 201
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 })->reindex();
204 204
 
205 205
 /** Разделяем коллекцию дат на 2 части (до текущей даты и после) */
206
-list($lReflect, $rReflect) = $totalReflects->partition(function ($key, $val) use (
206
+list($lReflect, $rReflect) = $totalReflects->partition(function($key, $val) use (
207 207
     $activeReflect,
208 208
     $originalDate,
209 209
     $dateFormat
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 $showBefore = ($lReflect->count() < $limitBefore || empty($limitBefore)) ? $lReflect->count() : $limitBefore;
228 228
 if (($rReflect->count() < $limitAfter) || empty($limitAfter)) {
229 229
     $showAfter = $rReflect->count();
230
-    $showBefore += !empty($limitAfter) ? ($limitAfter - $rReflect->count()) : 0;
230
+    $showBefore += ! empty($limitAfter) ? ($limitAfter - $rReflect->count()) : 0;
231 231
 } else {
232 232
     if ($limitBefore > 0) {
233 233
         $showAfter = $limitAfter + ($limitBefore - $showBefore);
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 }
250 250
 /** Добавляем текущую дату */
251 251
 if (is_null($activeReflect)) {
252
-    if (($hasCurrentReflect && !$selectCurrentReflect) || $appendCurrentReflect) {
252
+    if (($hasCurrentReflect && ! $selectCurrentReflect) || $appendCurrentReflect) {
253 253
         $outReflects->add($originalCurrentReflect);
254 254
     }
255 255
 } else {
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 
268 268
 $sortDir = APIHelpers::getkey($params, 'sortDir', 'ASC');
269 269
 /** Сортируем результатирующий список  */
270
-$outReflects = $outReflects->sort(function ($a, $b) use ($sortDir, $dateFormat) {
270
+$outReflects = $outReflects->sort(function($a, $b) use ($sortDir, $dateFormat) {
271 271
     $aDate = DateTime::createFromFormat($dateFormat, $a);
272 272
     $bDate = DateTime::createFromFormat($dateFormat, $b);
273 273
     $out = false;
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
 
286 286
 /** Применяем шаблон к каждой отображаемой дате */
287 287
 foreach ($outReflects as $reflectItem) {
288
-    $tpl = (!is_null($activeReflect) && $activeReflect == $reflectItem) ? $activeReflectTPL : $reflectTPL;
288
+    $tpl = ( ! is_null($activeReflect) && $activeReflect == $reflectItem) ? $activeReflectTPL : $reflectTPL;
289 289
 
290
-    $data = DLReflect::switchReflect($reflectType, function () use ($reflectItem, $DLAPI) {
290
+    $data = DLReflect::switchReflect($reflectType, function() use ($reflectItem, $DLAPI) {
291 291
         list($vMonth, $vYear) = explode('-', $reflectItem, 2);
292 292
 
293 293
         return array(
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
             'monthName' => $DLAPI->getMsg('months.' . (int)$vMonth),
296 296
             'year'      => $vYear,
297 297
         );
298
-    }, function () use ($reflectItem) {
298
+    }, function() use ($reflectItem) {
299 299
         return array(
300 300
             'year' => $reflectItem
301 301
         );
Please login to merge, or discard this patch.
assets/snippets/DocLister/core/DocLister.abstract.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -399,8 +399,8 @@  discard block
 block discarded – undo
399 399
     /**
400 400
      * @param $name
401 401
      * @param $table
402
-     * @param $alias
403
-     * @return mixed
402
+     * @param string $alias
403
+     * @return string
404 404
      */
405 405
     public function TableAlias($name, $table, $alias)
406 406
     {
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
     /**
466 466
      * Разбор JSON строки при помощи json_decode
467 467
      *
468
-     * @param $json string строка c JSON
468
+     * @param string $json string строка c JSON
469 469
      * @param array $config ассоциативный массив с настройками для json_decode
470 470
      * @param bool $nop создавать ли пустой объект запрашиваемого типа
471 471
      * @return array|mixed|xNop
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
      * Удаление определенных данных из массива
551 551
      *
552 552
      * @param array $data массив с данными
553
-     * @param mixed $val значение которые необходимо удалить из массива
553
+     * @param string $val значение которые необходимо удалить из массива
554 554
      * @return array отчищеный массив с данными
555 555
      */
556 556
     private function unsetArrayVal($data, $val)
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
 
1181 1181
     /**
1182 1182
      * @param array $item
1183
-     * @param null $extSummary
1183
+     * @param summary_DL_Extender $extSummary
1184 1184
      * @param string $introField
1185 1185
      * @param string $contentField
1186 1186
      * @return mixed|string
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('MODX_BASE_PATH')) {
2
+if ( ! defined('MODX_BASE_PATH')) {
3 3
     die('HACK???');
4 4
 }
5 5
 /**
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
             $this->modx = $modx;
197 197
             $this->setDebug(1);
198 198
 
199
-            if (!is_array($cfg) || empty($cfg)) {
199
+            if ( ! is_array($cfg) || empty($cfg)) {
200 200
                 $cfg = $this->modx->Event->params;
201 201
             }
202 202
         } else {
@@ -384,11 +384,11 @@  discard block
 block discarded – undo
384 384
      */
385 385
     public function getTable($name, $alias = '')
386 386
     {
387
-        if (!isset($this->_table[$name])) {
387
+        if ( ! isset($this->_table[$name])) {
388 388
             $this->_table[$name] = $this->modx->getFullTableName($name);
389 389
         }
390 390
         $table = $this->_table[$name];
391
-        if (!empty($alias) && is_scalar($alias)) {
391
+        if ( ! empty($alias) && is_scalar($alias)) {
392 392
             $table .= " as `" . $alias . "`";
393 393
         }
394 394
 
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
      */
404 404
     public function TableAlias($name, $table, $alias)
405 405
     {
406
-        if (!$this->checkTableAlias($name, $table)) {
406
+        if ( ! $this->checkTableAlias($name, $table)) {
407 407
             $this->AddTable[$table][$name] = $alias;
408 408
         }
409 409
 
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
     public function isErrorJSON($json)
449 449
     {
450 450
         $error = jsonHelper::json_last_error_msg();
451
-        if (!in_array($error, array('error_none', 'other'))) {
451
+        if ( ! in_array($error, array('error_none', 'other'))) {
452 452
             $this->debug->error($this->getMsg('json.' . $error) . ": " . $this->debug->dumpData($json, 'code'), 'JSON');
453 453
             $error = true;
454 454
         }
@@ -467,13 +467,13 @@  discard block
 block discarded – undo
467 467
         $extenders = $this->getCFGDef('extender', '');
468 468
         $extenders = explode(",", $extenders);
469 469
         $tmp = $this->getCFGDef('requestActive', '') != '' || in_array('request', $extenders);
470
-        if ($tmp && !$this->_loadExtender('request')) {
470
+        if ($tmp && ! $this->_loadExtender('request')) {
471 471
             //OR request in extender's parameter
472 472
             throw new Exception('Error load request extender');
473 473
         }
474 474
 
475 475
         $tmp = $this->getCFGDef('summary', '') != '' || in_array('summary', $extenders);
476
-        if ($tmp && !$this->_loadExtender('summary')) {
476
+        if ($tmp && ! $this->_loadExtender('summary')) {
477 477
             //OR summary in extender's parameter
478 478
             throw new Exception('Error load summary extender');
479 479
         }
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
                 $this->getCFGDef('TplCurrentPage', '') != '' || $this->getCFGDef('TplWrapPaginate', '') != '' ||
486 486
                 $this->getCFGDef('pageLimit', '') != '' || $this->getCFGDef('pageAdjacents', '') != '' ||
487 487
                 $this->getCFGDef('PaginateClass', '') != '' || $this->getCFGDef('TplNextP', '') != ''
488
-            ) && !$this->_loadExtender('paginate')
488
+            ) && ! $this->_loadExtender('paginate')
489 489
         ) {
490 490
             throw new Exception('Error load paginate extender');
491 491
         } else {
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
         if ($ext != '') {
651 651
             $ext = explode(",", $ext);
652 652
             foreach ($ext as $item) {
653
-                if ($item != '' && !$this->_loadExtender($item)) {
653
+                if ($item != '' && ! $this->_loadExtender($item)) {
654 654
                     throw new Exception('Error load ' . APIHelpers::e($item) . ' extender');
655 655
                 }
656 656
             }
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
      */
712 712
     public function sanitarIn($data, $sep = ',', $quote = true)
713 713
     {
714
-        if (!is_array($data)) {
714
+        if ( ! is_array($data)) {
715 715
             $data = explode($sep, $data);
716 716
         }
717 717
         $out = array();
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
     protected function renderTree($data)
849 849
     {
850 850
         $out = '';
851
-        if (!empty($data['#childNodes'])) {
851
+        if ( ! empty($data['#childNodes'])) {
852 852
             foreach ($data['#childNodes'] as $item) {
853 853
                 $out .= $this->renderTree($item);
854 854
             }
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
     public function parseLang($tpl)
888 888
     {
889 889
         $this->debug->debug(array("parseLang" => $tpl), "parseLang", 2, array('html'));
890
-        if (is_scalar($tpl) && !empty($tpl)) {
890
+        if (is_scalar($tpl) && ! empty($tpl)) {
891 891
             if (preg_match_all("/\[\%([a-zA-Z0-9\.\_\-]+)\%\]/", $tpl, $match)) {
892 892
                 $langVal = array();
893 893
                 foreach ($match[1] as $item) {
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
     {
959 959
         $out = $data;
960 960
         $docs = count($this->_docs) - $this->skippedDocs;
961
-        if ((($this->getCFGDef("noneWrapOuter", "1") && $docs == 0) || $docs > 0) && !empty($this->ownerTPL)) {
961
+        if ((($this->getCFGDef("noneWrapOuter", "1") && $docs == 0) || $docs > 0) && ! empty($this->ownerTPL)) {
962 962
             $this->debug->debug("", "renderWrapTPL", 2);
963 963
             $parse = true;
964 964
             $plh = array($this->getCFGDef("sysKey", "dl") . ".wrap" => $data);
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
                 }
982 982
                 $plh = $params;
983 983
             }
984
-            if ($parse && !empty($this->ownerTPL)) {
984
+            if ($parse && ! empty($this->ownerTPL)) {
985 985
                 $this->debug->updateMessage(
986 986
                     array("render ownerTPL" => $this->ownerTPL, "With data" => print_r($plh, 1)),
987 987
                     "renderWrapTPL",
@@ -1120,10 +1120,10 @@  discard block
 block discarded – undo
1120 1120
         $introField = $this->getCFGDef("introField", $introField);
1121 1121
         $contentField = $this->getCFGDef("contentField", $contentField);
1122 1122
 
1123
-        if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1123
+        if ( ! empty($introField) && ! empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1124 1124
             $out = $item[$introField];
1125 1125
         } else {
1126
-            if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1126
+            if ( ! empty($contentField) && ! empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1127 1127
                 $out = $extSummary->init($this, array(
1128 1128
                     "content"      => $item[$contentField],
1129 1129
                     "action"       => $this->getCFGDef("summary", ""),
@@ -1192,7 +1192,7 @@  discard block
 block discarded – undo
1192 1192
             $flag = true;
1193 1193
 
1194 1194
         } else {
1195
-            if (!class_exists($classname, false) && $classname != '') {
1195
+            if ( ! class_exists($classname, false) && $classname != '') {
1196 1196
                 if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) {
1197 1197
                     include_once(dirname(__FILE__) . "/extender/" . $name . ".extender.inc");
1198 1198
                 }
@@ -1202,7 +1202,7 @@  discard block
 block discarded – undo
1202 1202
                 $flag = true;
1203 1203
             }
1204 1204
         }
1205
-        if (!$flag) {
1205
+        if ( ! $flag) {
1206 1206
             $this->debug->debug("Error load Extender " . $this->debug->dumpData($name));
1207 1207
         }
1208 1208
         $this->debug->debugEnd('LoadExtender');
@@ -1260,7 +1260,7 @@  discard block
 block discarded – undo
1260 1260
         $this->debug->debug('clean IDs ' . $this->debug->dumpData($IDs) . ' with separator ' . $this->debug->dumpData($sep),
1261 1261
             'cleanIDs', 2);
1262 1262
         $out = array();
1263
-        if (!is_array($IDs)) {
1263
+        if ( ! is_array($IDs)) {
1264 1264
             $IDs = explode($sep, $IDs);
1265 1265
         }
1266 1266
         foreach ($IDs as $item) {
@@ -1296,7 +1296,7 @@  discard block
 block discarded – undo
1296 1296
     {
1297 1297
         $out = array();
1298 1298
         foreach ($this->_docs as $doc => $val) {
1299
-            if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) {
1299
+            if (isset($val[$userField]) && (($uniq && ! in_array($val[$userField], $out)) || ! $uniq)) {
1300 1300
                 $out[$doc] = $val[$userField];
1301 1301
             }
1302 1302
         }
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
                             $out['order'] = $tmp;
1386 1386
                         // no break
1387 1387
                     }
1388
-                    if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1388
+                    if ('' == $out['order'] || ! in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1389 1389
                         $out['order'] = $orderDef; //Default
1390 1390
                     }
1391 1391
 
@@ -1476,21 +1476,21 @@  discard block
 block discarded – undo
1476 1476
         $children = array(); // children of each ID
1477 1477
         $ids = array();
1478 1478
         foreach ($data as $i => $r) {
1479
-            $row =& $data[$i];
1479
+            $row = & $data[$i];
1480 1480
             $id = $row[$idName];
1481 1481
             $pid = $row[$pidName];
1482
-            $children[$pid][$id] =& $row;
1483
-            if (!isset($children[$id])) {
1482
+            $children[$pid][$id] = & $row;
1483
+            if ( ! isset($children[$id])) {
1484 1484
                 $children[$id] = array();
1485 1485
             }
1486
-            $row['#childNodes'] =& $children[$id];
1486
+            $row['#childNodes'] = & $children[$id];
1487 1487
             $ids[$row[$idName]] = true;
1488 1488
         }
1489 1489
         // Root elements are elements with non-found PIDs.
1490 1490
         $this->_tree = array();
1491 1491
         foreach ($data as $i => $r) {
1492
-            $row =& $data[$i];
1493
-            if (!isset($ids[$row[$pidName]])) {
1492
+            $row = & $data[$i];
1493
+            if ( ! isset($ids[$row[$pidName]])) {
1494 1494
                 $this->_tree[$row[$idName]] = $row;
1495 1495
             }
1496 1496
         }
@@ -1531,7 +1531,7 @@  discard block
 block discarded – undo
1531 1531
         $this->debug->debug("getFilters: " . $this->debug->dumpData($filter_string), 'getFilter', 1);
1532 1532
         // the filter parameter tells us, which filters can be used in this query
1533 1533
         $filter_string = trim($filter_string, ' ;');
1534
-        if (!$filter_string) {
1534
+        if ( ! $filter_string) {
1535 1535
             return;
1536 1536
         }
1537 1537
         $output = array('join' => '', 'where' => '');
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
                 $subfilters = $this->smartSplit($subfilters);
1545 1545
                 foreach ($subfilters as $subfilter) {
1546 1546
                     $subfilter = $this->getFilters(trim($subfilter));
1547
-                    if (!$subfilter) {
1547
+                    if ( ! $subfilter) {
1548 1548
                         continue;
1549 1549
                     }
1550 1550
                     if ($subfilter['join']) {
@@ -1554,14 +1554,14 @@  discard block
 block discarded – undo
1554 1554
                         $wheres[] = $subfilter['where'];
1555 1555
                     }
1556 1556
                 }
1557
-                $output['join'] = !empty($joins) ? implode(' ', $joins) : '';
1558
-                $output['where'] = !empty($wheres) ? '(' . implode($sql, $wheres) . ')' : '';
1557
+                $output['join'] = ! empty($joins) ? implode(' ', $joins) : '';
1558
+                $output['where'] = ! empty($wheres) ? '(' . implode($sql, $wheres) . ')' : '';
1559 1559
             }
1560 1560
         }
1561 1561
 
1562
-        if (!$logic_op_found) {
1562
+        if ( ! $logic_op_found) {
1563 1563
             $filter = $this->loadFilter($filter_string);
1564
-            if (!$filter) {
1564
+            if ( ! $filter) {
1565 1565
                 $this->debug->warning('Error while loading DocLister filter "' . $this->debug->dumpData($filter_string) . '": check syntax!');
1566 1566
                 $output = false;
1567 1567
             } else {
@@ -1633,7 +1633,7 @@  discard block
 block discarded – undo
1633 1633
         $fltr_params = explode(':', $filter, 2);
1634 1634
         $fltr = APIHelpers::getkey($fltr_params, 0, null);
1635 1635
         // check if the filter is implemented
1636
-        if (!is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1636
+        if ( ! is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1637 1637
             require_once dirname(__FILE__) . '/filter/' . $fltr . '.filter.php';
1638 1638
             /**
1639 1639
              * @var tv_DL_filter|content_DL_filter $fltr_class
Please login to merge, or discard this patch.
Braces   +285 added lines, -279 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('MODX_BASE_PATH')) {
2
+if (!defined('MODX_BASE_PATH')) {
3 3
     die('HACK???');
4 4
 }
5 5
 /**
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 /**
21 21
  * Class DocLister
22 22
  */
23
-abstract class DocLister
24
-{
23
+abstract class DocLister
24
+{
25 25
     /**
26 26
      * Ключ в массиве $_REQUEST в котором находится алиас запрашиваемого документа
27 27
      */
@@ -182,48 +182,48 @@  discard block
 block discarded – undo
182 182
      * @param int $startTime время запуска сниппета
183 183
      * @throws Exception
184 184
      */
185
-    public function __construct($modx, $cfg = array(), $startTime = null)
186
-    {
185
+    public function __construct($modx, $cfg = array(), $startTime = null)
186
+    {
187 187
         $this->setTimeStart($startTime);
188 188
 
189
-        if (extension_loaded('mbstring')) {
189
+        if (extension_loaded('mbstring')) {
190 190
             mb_internal_encoding("UTF-8");
191
-        } else {
191
+        } else {
192 192
             throw new Exception('Not found php extension mbstring');
193 193
         }
194 194
 
195
-        if ($modx instanceof DocumentParser) {
195
+        if ($modx instanceof DocumentParser) {
196 196
             $this->modx = $modx;
197 197
             $this->setDebug(1);
198 198
 
199
-            if (!is_array($cfg) || empty($cfg)) {
199
+            if (!is_array($cfg) || empty($cfg)) {
200 200
                 $cfg = $this->modx->Event->params;
201 201
             }
202
-        } else {
202
+        } else {
203 203
             throw new Exception('MODX var is not instaceof DocumentParser');
204 204
         }
205 205
 
206 206
         $this->FS = \Helpers\FS::getInstance();
207 207
         $this->config = new \Helpers\Config($cfg);
208 208
 
209
-        if (isset($cfg['config'])) {
209
+        if (isset($cfg['config'])) {
210 210
             $this->config->setPath(dirname(__DIR__))->loadConfig($cfg['config']);
211 211
         }
212 212
 
213
-        if ($this->config->setConfig($cfg) === false) {
213
+        if ($this->config->setConfig($cfg) === false) {
214 214
             throw new Exception('no parameters to run DocLister');
215 215
         }
216 216
 
217 217
         $this->loadLang(array('core', 'json'));
218 218
         $this->setDebug($this->getCFGDef('debug', 0));
219 219
 
220
-        if ($this->checkDL()) {
220
+        if ($this->checkDL()) {
221 221
             $cfg = array();
222 222
             $idType = $this->getCFGDef('idType', '');
223
-            if (empty($idType) && $this->getCFGDef('documents', '') != '') {
223
+            if (empty($idType) && $this->getCFGDef('documents', '') != '') {
224 224
                 $idType = 'documents';
225 225
             }
226
-            switch ($idType) {
226
+            switch ($idType) {
227 227
                 case 'documents':
228 228
                     $IDs = $this->getCFGDef('documents');
229 229
                     $cfg['idType'] = "documents";
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
                 case 'parents':
232 232
                 default:
233 233
                     $cfg['idType'] = "parents";
234
-                    if (($IDs = $this->getCFGDef('parents')) === null) {
234
+                    if (($IDs = $this->getCFGDef('parents')) === null) {
235 235
                         $IDs = $this->getCurrentMODXPageID();
236 236
                     }
237 237
                     break;
238 238
             }
239 239
             $this->config->setConfig($cfg);
240 240
 
241
-            if (empty($this->table)) {
241
+            if (empty($this->table)) {
242 242
                 $this->table = $this->getTable($this->getCFGDef('table', 'site_content'));
243 243
             }
244 244
             $this->idField = $this->getCFGDef('idField', 'id');
@@ -249,12 +249,12 @@  discard block
 block discarded – undo
249 249
 
250 250
         $this->setLocate();
251 251
 
252
-        if ($this->getCFGDef("customLang")) {
252
+        if ($this->getCFGDef("customLang")) {
253 253
             $this->getCustomLang();
254 254
         }
255 255
         $this->loadExtender($this->getCFGDef("extender", ""));
256 256
 
257
-        if ($this->checkExtender('request')) {
257
+        if ($this->checkExtender('request')) {
258 258
             $this->extender['request']->init($this, $this->getCFGDef("requestActive", ""));
259 259
         }
260 260
         $this->_filters = $this->getFilters($this->getCFGDef('filters', ''));
@@ -266,21 +266,21 @@  discard block
 block discarded – undo
266 266
      * @param string $str строка с фильтром
267 267
      * @return array массив субфильтров
268 268
      */
269
-    public function smartSplit($str)
270
-    {
269
+    public function smartSplit($str)
270
+    {
271 271
         $res = array();
272 272
         $cur = '';
273 273
         $open = 0;
274 274
         $strlen = mb_strlen($str, 'UTF-8');
275
-        for ($i = 0; $i <= $strlen; $i++) {
275
+        for ($i = 0; $i <= $strlen; $i++) {
276 276
             $e = mb_substr($str, $i, 1, 'UTF-8');
277
-            switch ($e) {
277
+            switch ($e) {
278 278
                 case ')':
279 279
                     $open--;
280
-                    if ($open == 0) {
280
+                    if ($open == 0) {
281 281
                         $res[] = $cur . ')';
282 282
                         $cur = '';
283
-                    } else {
283
+                    } else {
284 284
                         $cur .= $e;
285 285
                     }
286 286
                     break;
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
                     $cur .= $e;
290 290
                     break;
291 291
                 case ';':
292
-                    if ($open == 0) {
292
+                    if ($open == 0) {
293 293
                         $res[] = $cur;
294 294
                         $cur = '';
295
-                    } else {
295
+                    } else {
296 296
                         $cur .= $e;
297 297
                     }
298 298
                     break;
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
             }
302 302
         }
303 303
         $cur = preg_replace("/(\))$/u", '', $cur);
304
-        if ($cur != '') {
304
+        if ($cur != '') {
305 305
             $res[] = $cur;
306 306
         }
307 307
 
@@ -312,8 +312,8 @@  discard block
 block discarded – undo
312 312
      * Трансформация объекта в строку
313 313
      * @return string последний ответ от DocLister'а
314 314
      */
315
-    public function __toString()
316
-    {
315
+    public function __toString()
316
+    {
317 317
         return $this->outData;
318 318
     }
319 319
 
@@ -321,8 +321,8 @@  discard block
 block discarded – undo
321 321
      * Установить время запуска сниппета
322 322
      * @param float|null $time
323 323
      */
324
-    public function setTimeStart($time = null)
325
-    {
324
+    public function setTimeStart($time = null)
325
+    {
326 326
         $this->_timeStart = is_null($time) ? microtime(true) : $time;
327 327
     }
328 328
 
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
      *
332 332
      * @return int
333 333
      */
334
-    public function getTimeStart()
335
-    {
334
+    public function getTimeStart()
335
+    {
336 336
         return $this->_timeStart;
337 337
     }
338 338
 
@@ -340,27 +340,27 @@  discard block
 block discarded – undo
340 340
      * Установка режима отладки
341 341
      * @param int $flag режим отладки
342 342
      */
343
-    public function setDebug($flag = 0)
344
-    {
343
+    public function setDebug($flag = 0)
344
+    {
345 345
         $flag = abs((int)$flag);
346
-        if ($this->_debugMode != $flag) {
346
+        if ($this->_debugMode != $flag) {
347 347
             $this->_debugMode = $flag;
348 348
             $this->debug = null;
349
-            if ($this->_debugMode > 0) {
350
-                if (isset($_SESSION['usertype']) && $_SESSION['usertype'] == 'manager') {
349
+            if ($this->_debugMode > 0) {
350
+                if (isset($_SESSION['usertype']) && $_SESSION['usertype'] == 'manager') {
351 351
                     error_reporting(E_ALL ^ E_NOTICE);
352 352
                     ini_set('display_errors', 1);
353 353
                 }
354 354
                 $dir = dirname(dirname(__FILE__));
355
-                if (file_exists($dir . "/lib/DLdebug.class.php")) {
355
+                if (file_exists($dir . "/lib/DLdebug.class.php")) {
356 356
                     include_once($dir . "/lib/DLdebug.class.php");
357
-                    if (class_exists("DLdebug", false)) {
357
+                    if (class_exists("DLdebug", false)) {
358 358
                         $this->debug = new DLdebug($this);
359 359
                     }
360 360
                 }
361 361
             }
362 362
 
363
-            if (is_null($this->debug)) {
363
+            if (is_null($this->debug)) {
364 364
                 $this->debug = new xNop();
365 365
                 $this->_debugMode = 0;
366 366
                 error_reporting(0);
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
     /**
373 373
      * Информация о режиме отладки
374 374
      */
375
-    public function getDebug()
376
-    {
375
+    public function getDebug()
376
+    {
377 377
         return $this->_debugMode;
378 378
     }
379 379
 
@@ -384,13 +384,13 @@  discard block
 block discarded – undo
384 384
      * @param string $alias желаемый алиас таблицы
385 385
      * @return string имя таблицы с префиксом и алиасом
386 386
      */
387
-    public function getTable($name, $alias = '')
388
-    {
389
-        if (!isset($this->_table[$name])) {
387
+    public function getTable($name, $alias = '')
388
+    {
389
+        if (!isset($this->_table[$name])) {
390 390
             $this->_table[$name] = $this->modx->getFullTableName($name);
391 391
         }
392 392
         $table = $this->_table[$name];
393
-        if (!empty($alias) && is_scalar($alias)) {
393
+        if (!empty($alias) && is_scalar($alias)) {
394 394
             $table .= " as `" . $alias . "`";
395 395
         }
396 396
 
@@ -403,9 +403,9 @@  discard block
 block discarded – undo
403 403
      * @param $alias
404 404
      * @return mixed
405 405
      */
406
-    public function TableAlias($name, $table, $alias)
407
-    {
408
-        if (!$this->checkTableAlias($name, $table)) {
406
+    public function TableAlias($name, $table, $alias)
407
+    {
408
+        if (!$this->checkTableAlias($name, $table)) {
409 409
             $this->AddTable[$table][$name] = $alias;
410 410
         }
411 411
 
@@ -417,8 +417,8 @@  discard block
 block discarded – undo
417 417
      * @param $table
418 418
      * @return bool
419 419
      */
420
-    public function checkTableAlias($name, $table)
421
-    {
420
+    public function checkTableAlias($name, $table)
421
+    {
422 422
         return isset($this->AddTable[$table][$name]);
423 423
     }
424 424
 
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
      * @param bool $nop создавать ли пустой объект запрашиваемого типа
431 431
      * @return array|mixed|xNop
432 432
      */
433
-    public function jsonDecode($json, $config = array(), $nop = false)
434
-    {
433
+    public function jsonDecode($json, $config = array(), $nop = false)
434
+    {
435 435
         $this->debug->debug('Decode JSON: ' . $this->debug->dumpData($json) . "\r\nwith config: " . $this->debug->dumpData($config),
436 436
             'jsonDecode', 2);
437 437
         $config = jsonHelper::jsonDecode($json, $config, $nop);
@@ -447,10 +447,10 @@  discard block
 block discarded – undo
447 447
      * @param $json string строка с JSON для записи в лог при отладке
448 448
      * @return bool|string
449 449
      */
450
-    public function isErrorJSON($json)
451
-    {
450
+    public function isErrorJSON($json)
451
+    {
452 452
         $error = jsonHelper::json_last_error_msg();
453
-        if (!in_array($error, array('error_none', 'other'))) {
453
+        if (!in_array($error, array('error_none', 'other'))) {
454 454
             $this->debug->error($this->getMsg('json.' . $error) . ": " . $this->debug->dumpData($json, 'code'), 'JSON');
455 455
             $error = true;
456 456
         }
@@ -462,20 +462,20 @@  discard block
 block discarded – undo
462 462
      * Проверка параметров и загрузка необходимых экстендеров
463 463
      * return boolean статус загрузки
464 464
      */
465
-    public function checkDL()
466
-    {
465
+    public function checkDL()
466
+    {
467 467
         $this->debug->debug('Check DocLister parameters', 'checkDL', 2);
468 468
         $flag = true;
469 469
         $extenders = $this->getCFGDef('extender', '');
470 470
         $extenders = explode(",", $extenders);
471 471
         $tmp = $this->getCFGDef('requestActive', '') != '' || in_array('request', $extenders);
472
-        if ($tmp && !$this->_loadExtender('request')) {
472
+        if ($tmp && !$this->_loadExtender('request')) {
473 473
             //OR request in extender's parameter
474 474
             throw new Exception('Error load request extender');
475 475
         }
476 476
 
477 477
         $tmp = $this->getCFGDef('summary', '') != '' || in_array('summary', $extenders);
478
-        if ($tmp && !$this->_loadExtender('summary')) {
478
+        if ($tmp && !$this->_loadExtender('summary')) {
479 479
             //OR summary in extender's parameter
480 480
             throw new Exception('Error load summary extender');
481 481
         }
@@ -488,15 +488,15 @@  discard block
 block discarded – undo
488 488
                 $this->getCFGDef('pageLimit', '') != '' || $this->getCFGDef('pageAdjacents', '') != '' ||
489 489
                 $this->getCFGDef('PaginateClass', '') != '' || $this->getCFGDef('TplNextP', '') != ''
490 490
             ) && !$this->_loadExtender('paginate')
491
-        ) {
491
+        ) {
492 492
             throw new Exception('Error load paginate extender');
493
-        } else {
494
-            if ((int)$this->getCFGDef('display', 0) == 0) {
493
+        } else {
494
+            if ((int)$this->getCFGDef('display', 0) == 0) {
495 495
                 $extenders = $this->unsetArrayVal($extenders, 'paginate');
496 496
             }
497 497
         }
498 498
 
499
-        if ($this->getCFGDef('prepare', '') != '' || $this->getCFGDef('prepareWrap') != '') {
499
+        if ($this->getCFGDef('prepare', '') != '' || $this->getCFGDef('prepareWrap') != '') {
500 500
             $this->_loadExtender('prepare');
501 501
         }
502 502
 
@@ -513,14 +513,14 @@  discard block
 block discarded – undo
513 513
      * @param mixed $val значение которые необходимо удалить из массива
514 514
      * @return array отчищеный массив с данными
515 515
      */
516
-    private function unsetArrayVal($data, $val)
517
-    {
516
+    private function unsetArrayVal($data, $val)
517
+    {
518 518
         $out = array();
519
-        if (is_array($data)) {
520
-            foreach ($data as $item) {
521
-                if ($item != $val) {
519
+        if (is_array($data)) {
520
+            foreach ($data as $item) {
521
+                if ($item != $val) {
522 522
                     $out[] = $item;
523
-                } else {
523
+                } else {
524 524
                     continue;
525 525
                 }
526 526
             }
@@ -535,14 +535,14 @@  discard block
 block discarded – undo
535 535
      * @param int $id уникальный идентификатор страницы
536 536
      * @return string URL страницы
537 537
      */
538
-    public function getUrl($id = 0)
539
-    {
538
+    public function getUrl($id = 0)
539
+    {
540 540
         $id = ((int)$id > 0) ? (int)$id : $this->getCurrentMODXPageID();
541 541
 
542 542
         $link = $this->checkExtender('request') ? $this->extender['request']->getLink() : $this->getRequest();
543
-        if ($id == $this->modx->config['site_start']) {
543
+        if ($id == $this->modx->config['site_start']) {
544 544
             $url = $this->modx->config['site_url'] . ($link != '' ? "?{$link}" : "");
545
-        } else {
545
+        } else {
546 546
             $url = $this->modx->makeUrl($id, '', $link, $this->getCFGDef('urlScheme', ''));
547 547
         }
548 548
 
@@ -570,16 +570,16 @@  discard block
 block discarded – undo
570 570
      * @param string $tpl шаблон
571 571
      * @return string
572 572
      */
573
-    public function render($tpl = '')
574
-    {
573
+    public function render($tpl = '')
574
+    {
575 575
         $this->debug->debug(array('Render data with template ' => $tpl), 'render', 2, array('html'));
576 576
         $out = '';
577
-        if (1 == $this->getCFGDef('tree', '0')) {
578
-            foreach ($this->_tree as $item) {
577
+        if (1 == $this->getCFGDef('tree', '0')) {
578
+            foreach ($this->_tree as $item) {
579 579
                 $out .= $this->renderTree($item);
580 580
             }
581 581
             $out = $this->renderWrap($out);
582
-        } else {
582
+        } else {
583 583
             $out = $this->_render($tpl);
584 584
         }
585 585
 
@@ -598,8 +598,8 @@  discard block
 block discarded – undo
598 598
      *
599 599
      * @return int
600 600
      */
601
-    public function getCurrentMODXPageID()
602
-    {
601
+    public function getCurrentMODXPageID()
602
+    {
603 603
         $id = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0;
604 604
         $docData = isset($this->modx->documentObject) ? $this->modx->documentObject : array();
605 605
 
@@ -615,9 +615,9 @@  discard block
 block discarded – undo
615 615
      * @param integer $line error on line
616 616
      * @param array $trace stack trace
617 617
      */
618
-    public function ErrorLogger($message, $code, $file, $line, $trace)
619
-    {
620
-        if (abs($this->getCFGDef('debug', '0')) == '1') {
618
+    public function ErrorLogger($message, $code, $file, $line, $trace)
619
+    {
620
+        if (abs($this->getCFGDef('debug', '0')) == '1') {
621 621
             $out = "CODE #" . $code . "<br />";
622 622
             $out .= "on file: " . $file . ":" . $line . "<br />";
623 623
             $out .= "<pre>";
@@ -634,8 +634,8 @@  discard block
 block discarded – undo
634 634
      *
635 635
      * @return DocumentParser
636 636
      */
637
-    public function getMODX()
638
-    {
637
+    public function getMODX()
638
+    {
639 639
         return $this->modx;
640 640
     }
641 641
 
@@ -646,13 +646,13 @@  discard block
 block discarded – undo
646 646
      * @return boolean status load extenders
647 647
      * @throws Exception
648 648
      */
649
-    public function loadExtender($ext = '')
650
-    {
649
+    public function loadExtender($ext = '')
650
+    {
651 651
         $out = true;
652
-        if ($ext != '') {
652
+        if ($ext != '') {
653 653
             $ext = explode(",", $ext);
654
-            foreach ($ext as $item) {
655
-                if ($item != '' && !$this->_loadExtender($item)) {
654
+            foreach ($ext as $item) {
655
+                if ($item != '' && !$this->_loadExtender($item)) {
656 656
                     throw new Exception('Error load ' . APIHelpers::e($item) . ' extender');
657 657
                 }
658 658
             }
@@ -668,8 +668,8 @@  discard block
 block discarded – undo
668 668
      * @param mixed $def значение по умолчанию, если в конфиге нет искомого параметра
669 669
      * @return mixed значение из конфига
670 670
      */
671
-    public function getCFGDef($name, $def = null)
672
-    {
671
+    public function getCFGDef($name, $def = null)
672
+    {
673 673
         return $this->config->getCFGDef($name, $def);
674 674
     }
675 675
 
@@ -681,15 +681,15 @@  discard block
 block discarded – undo
681 681
      * @param string $key ключ локального плейсхолдера
682 682
      * @return string
683 683
      */
684
-    public function toPlaceholders($data, $set = 0, $key = 'contentPlaceholder')
685
-    {
684
+    public function toPlaceholders($data, $set = 0, $key = 'contentPlaceholder')
685
+    {
686 686
         $this->debug->debug(null, 'toPlaceholders', 2);
687
-        if ($set == 0) {
687
+        if ($set == 0) {
688 688
             $set = $this->getCFGDef('contentPlaceholder', 0);
689 689
         }
690 690
         $this->_plh[$key] = $data;
691 691
         $id = $this->getCFGDef('id', '');
692
-        if ($id != '') {
692
+        if ($id != '') {
693 693
             $id .= ".";
694 694
         }
695 695
         $out = DLTemplate::getInstance($this->getMODX())->toPlaceholders($data, $set, $key, $id);
@@ -711,14 +711,14 @@  discard block
 block discarded – undo
711 711
      * @param boolean $quote заключать ли данные на выходе в кавычки
712 712
      * @return string обработанная строка
713 713
      */
714
-    public function sanitarIn($data, $sep = ',', $quote = true)
715
-    {
716
-        if (!is_array($data)) {
714
+    public function sanitarIn($data, $sep = ',', $quote = true)
715
+    {
716
+        if (!is_array($data)) {
717 717
             $data = explode($sep, $data);
718 718
         }
719 719
         $out = array();
720
-        foreach ($data as $item) {
721
-            if ($item !== '') {
720
+        foreach ($data as $item) {
721
+            if ($item !== '') {
722 722
                 $out[] = $this->modx->db->escape($item);
723 723
             }
724 724
         }
@@ -739,12 +739,12 @@  discard block
 block discarded – undo
739 739
      * @param string $lang имя языкового пакета
740 740
      * @return array
741 741
      */
742
-    public function getCustomLang($lang = '')
743
-    {
744
-        if (empty($lang)) {
742
+    public function getCustomLang($lang = '')
743
+    {
744
+        if (empty($lang)) {
745 745
             $lang = $this->getCFGDef('lang', $this->modx->config['manager_language']);
746 746
         }
747
-        if (file_exists(dirname(dirname(__FILE__)) . "/lang/" . $lang . ".php")) {
747
+        if (file_exists(dirname(dirname(__FILE__)) . "/lang/" . $lang . ".php")) {
748 748
             $tmp = include(dirname(__FILE__) . "/lang/" . $lang . ".php");
749 749
             $this->_customLang = is_array($tmp) ? $tmp : array();
750 750
         }
@@ -760,25 +760,25 @@  discard block
 block discarded – undo
760 760
      * @param boolean $rename Переименовывать ли элементы массива
761 761
      * @return array массив с лексиконом
762 762
      */
763
-    public function loadLang($name = 'core', $lang = '', $rename = true)
764
-    {
765
-        if (empty($lang)) {
763
+    public function loadLang($name = 'core', $lang = '', $rename = true)
764
+    {
765
+        if (empty($lang)) {
766 766
             $lang = $this->getCFGDef('lang', $this->modx->config['manager_language']);
767 767
         }
768 768
 
769 769
         $this->debug->debug('Load language ' . $this->debug->dumpData($name) . "." . $this->debug->dumpData($lang),
770 770
             'loadlang', 2);
771
-        if (is_scalar($name)) {
771
+        if (is_scalar($name)) {
772 772
             $name = array($name);
773 773
         }
774
-        foreach ($name as $n) {
775
-            if (file_exists(dirname(__FILE__) . "/lang/" . $lang . "/" . $n . ".inc.php")) {
774
+        foreach ($name as $n) {
775
+            if (file_exists(dirname(__FILE__) . "/lang/" . $lang . "/" . $n . ".inc.php")) {
776 776
                 $tmp = include(dirname(__FILE__) . "/lang/" . $lang . "/" . $n . ".inc.php");
777
-                if (is_array($tmp)) {
777
+                if (is_array($tmp)) {
778 778
                     /**
779 779
                      * Переименовыываем элементы массива из array('test'=>'data') в array('name.test'=>'data')
780 780
                      */
781
-                    if ($rename) {
781
+                    if ($rename) {
782 782
                         $tmp = $this->renameKeyArr($tmp, $n, '', '.');
783 783
                     }
784 784
                     $this->_lang = array_merge($this->_lang, $tmp);
@@ -797,11 +797,11 @@  discard block
 block discarded – undo
797 797
      * @param string $def Строка по умолчанию, если запись в языковом пакете не будет обнаружена
798 798
      * @return string строка в соответствии с текущими языковыми настройками
799 799
      */
800
-    public function getMsg($name, $def = '')
801
-    {
802
-        if (isset($this->_customLang[$name])) {
800
+    public function getMsg($name, $def = '')
801
+    {
802
+        if (isset($this->_customLang[$name])) {
803 803
             $say = $this->_customLang[$name];
804
-        } else {
804
+        } else {
805 805
             $say = \APIHelpers::getkey($this->_lang, $name, $def);
806 806
         }
807 807
 
@@ -817,8 +817,8 @@  discard block
 block discarded – undo
817 817
      * @param string $sep разделитель суффиксов, префиксов и ключей массива
818 818
      * @return array массив с переименованными ключами
819 819
      */
820
-    public function renameKeyArr($data, $prefix = '', $suffix = '', $sep = '.')
821
-    {
820
+    public function renameKeyArr($data, $prefix = '', $suffix = '', $sep = '.')
821
+    {
822 822
         return \APIHelpers::renameKeyArr($data, $prefix, $suffix, $sep);
823 823
     }
824 824
 
@@ -828,12 +828,12 @@  discard block
 block discarded – undo
828 828
      * @param string $locale локаль
829 829
      * @return string имя установленной локали
830 830
      */
831
-    public function setLocate($locale = '')
832
-    {
833
-        if ('' == $locale) {
831
+    public function setLocate($locale = '')
832
+    {
833
+        if ('' == $locale) {
834 834
             $locale = $this->getCFGDef('locale', '');
835 835
         }
836
-        if ('' != $locale) {
836
+        if ('' != $locale) {
837 837
             setlocale(LC_ALL, $locale);
838 838
         }
839 839
 
@@ -847,11 +847,11 @@  discard block
 block discarded – undo
847 847
      * @param array $data массив сформированный как дерево
848 848
      * @return string строка для отображения пользователю
849 849
      */
850
-    protected function renderTree($data)
851
-    {
850
+    protected function renderTree($data)
851
+    {
852 852
         $out = '';
853
-        if (!empty($data['#childNodes'])) {
854
-            foreach ($data['#childNodes'] as $item) {
853
+        if (!empty($data['#childNodes'])) {
854
+            foreach ($data['#childNodes'] as $item) {
855 855
                 $out .= $this->renderTree($item);
856 856
             }
857 857
         }
@@ -868,8 +868,8 @@  discard block
 block discarded – undo
868 868
      * @param string $name Template: chunk name || @CODE: template || @FILE: file with template
869 869
      * @return string html template with placeholders without data
870 870
      */
871
-    private function _getChunk($name)
872
-    {
871
+    private function _getChunk($name)
872
+    {
873 873
         $this->debug->debug(array('Get chunk by name' => $name), "getChunk", 2, array('html'));
874 874
         //without trim
875 875
         $tpl = DLTemplate::getInstance($this->getMODX())->getChunk($name);
@@ -886,18 +886,18 @@  discard block
 block discarded – undo
886 886
      * @param string $tpl HTML шаблон
887 887
      * @return string
888 888
      */
889
-    public function parseLang($tpl)
890
-    {
889
+    public function parseLang($tpl)
890
+    {
891 891
         $this->debug->debug(array("parseLang" => $tpl), "parseLang", 2, array('html'));
892
-        if (is_scalar($tpl) && !empty($tpl)) {
893
-            if (preg_match_all("/\[\%([a-zA-Z0-9\.\_\-]+)\%\]/", $tpl, $match)) {
892
+        if (is_scalar($tpl) && !empty($tpl)) {
893
+            if (preg_match_all("/\[\%([a-zA-Z0-9\.\_\-]+)\%\]/", $tpl, $match)) {
894 894
                 $langVal = array();
895
-                foreach ($match[1] as $item) {
895
+                foreach ($match[1] as $item) {
896 896
                     $langVal[] = $this->getMsg($item);
897 897
                 }
898 898
                 $tpl = str_replace($match[0], $langVal, $tpl);
899 899
             }
900
-        } else {
900
+        } else {
901 901
             $tpl = '';
902 902
         }
903 903
         $this->debug->debugEnd("parseLang");
@@ -913,20 +913,24 @@  discard block
 block discarded – undo
913 913
      * @param bool $parseDocumentSource render html template via DocumentParser::parseDocumentSource()
914 914
      * @return string html template with data without placeholders
915 915
      */
916
-    public function parseChunk($name, $data, $parseDocumentSource = false)
917
-    {
916
+    public function parseChunk($name, $data, $parseDocumentSource = false)
917
+    {
918 918
         $this->debug->debug(
919 919
             array("parseChunk" => $name, "With data" => print_r($data, 1)),
920 920
             "parseChunk",
921 921
             2, array('html', null)
922 922
         );
923 923
         $DLTemplate = DLTemplate::getInstance($this->getMODX());
924
-        if ($path = $this->getCFGDef('templatePath')) $DLTemplate->setTemplatePath($path);
925
-        if ($ext = $this->getCFGDef('templateExtension')) $DLTemplate->setTemplateExtension($ext);
924
+        if ($path = $this->getCFGDef('templatePath')) {
925
+            $DLTemplate->setTemplatePath($path);
926
+        }
927
+        if ($ext = $this->getCFGDef('templateExtension')) {
928
+            $DLTemplate->setTemplateExtension($ext);
929
+        }
926 930
         $DLTemplate->setTwigTemplateVars(array('DocLister'=>$this));
927 931
         $out = $DLTemplate->parseChunk($name, $data, $parseDocumentSource);
928 932
         $out = $this->parseLang($out);
929
-        if (empty($out)) {
933
+        if (empty($out)) {
930 934
             $this->debug->debug("Empty chunk: " . $this->debug->dumpData($name), '', 2);
931 935
         }
932 936
         $this->debug->debugEnd("parseChunk");
@@ -942,8 +946,8 @@  discard block
 block discarded – undo
942 946
      *
943 947
      * @return string html template from parameter
944 948
      */
945
-    public function getChunkByParam($name, $val = '')
946
-    {
949
+    public function getChunkByParam($name, $val = '')
950
+    {
947 951
         $data = $this->getCFGDef($name, $val);
948 952
         $data = $this->_getChunk($data);
949 953
 
@@ -956,11 +960,11 @@  discard block
 block discarded – undo
956 960
      * @param string $data html код который нужно обернуть в ownerTPL
957 961
      * @return string результатирующий html код
958 962
      */
959
-    public function renderWrap($data)
960
-    {
963
+    public function renderWrap($data)
964
+    {
961 965
         $out = $data;
962 966
         $docs = count($this->_docs) - $this->skippedDocs;
963
-        if ((($this->getCFGDef("noneWrapOuter", "1") && $docs == 0) || $docs > 0) && !empty($this->ownerTPL)) {
967
+        if ((($this->getCFGDef("noneWrapOuter", "1") && $docs == 0) || $docs > 0) && !empty($this->ownerTPL)) {
964 968
             $this->debug->debug("", "renderWrapTPL", 2);
965 969
             $parse = true;
966 970
             $plh = array($this->getCFGDef("sysKey", "dl") . ".wrap" => $data);
@@ -968,7 +972,7 @@  discard block
 block discarded – undo
968 972
              * @var $extPrepare prepare_DL_Extender
969 973
              */
970 974
             $extPrepare = $this->getExtender('prepare');
971
-            if ($extPrepare) {
975
+            if ($extPrepare) {
972 976
                 $params = $extPrepare->init($this, array(
973 977
                     'data'      => array(
974 978
                         'docs'         => $this->_docs,
@@ -977,13 +981,13 @@  discard block
 block discarded – undo
977 981
                     'nameParam' => 'prepareWrap',
978 982
                     'return'    => 'placeholders'
979 983
                 ));
980
-                if (is_bool($params) && $params === false) {
984
+                if (is_bool($params) && $params === false) {
981 985
                     $out = $data;
982 986
                     $parse = false;
983 987
                 }
984 988
                 $plh = $params;
985 989
             }
986
-            if ($parse && !empty($this->ownerTPL)) {
990
+            if ($parse && !empty($this->ownerTPL)) {
987 991
                 $this->debug->updateMessage(
988 992
                     array("render ownerTPL" => $this->ownerTPL, "With data" => print_r($plh, 1)),
989 993
                     "renderWrapTPL",
@@ -991,7 +995,7 @@  discard block
 block discarded – undo
991 995
                 );
992 996
                 $out = $this->parseChunk($this->ownerTPL, $plh);
993 997
             }
994
-            if (empty($this->ownerTPL)) {
998
+            if (empty($this->ownerTPL)) {
995 999
                 $this->debug->updateMessage("empty ownerTPL", "renderWrapTPL");
996 1000
             }
997 1001
             $this->debug->debugEnd("renderWrapTPL");
@@ -1007,8 +1011,8 @@  discard block
 block discarded – undo
1007 1011
      * @param int $i номер итерации в цикле
1008 1012
      * @return array массив с данными которые можно использовать в цикле render метода
1009 1013
      */
1010
-    protected function uniformPrepare(&$data, $i = 0)
1011
-    {
1014
+    protected function uniformPrepare(&$data, $i = 0)
1015
+    {
1012 1016
         $class = array();
1013 1017
 
1014 1018
         $iterationName = ($i % 2 == 1) ? 'Odd' : 'Even';
@@ -1022,20 +1026,20 @@  discard block
 block discarded – undo
1022 1026
             "dl") . '.full_iteration'] = ($this->extPaginate) ? ($i + $this->getCFGDef('display',
1023 1027
                 0) * ($this->extPaginate->currentPage() - 1)) : $i;
1024 1028
 
1025
-        if ($i == 1) {
1029
+        if ($i == 1) {
1026 1030
             $this->renderTPL = $this->getCFGDef('tplFirst', $this->renderTPL);
1027 1031
             $class[] = $this->getCFGDef('firstClass', 'first');
1028 1032
         }
1029
-        if ($i == (count($this->_docs) - $this->skippedDocs)) {
1033
+        if ($i == (count($this->_docs) - $this->skippedDocs)) {
1030 1034
             $this->renderTPL = $this->getCFGDef('tplLast', $this->renderTPL);
1031 1035
             $class[] = $this->getCFGDef('lastClass', 'last');
1032 1036
         }
1033
-        if ($this->modx->documentIdentifier == $data['id']) {
1037
+        if ($this->modx->documentIdentifier == $data['id']) {
1034 1038
             $this->renderTPL = $this->getCFGDef('tplCurrent', $this->renderTPL);
1035 1039
             $data[$this->getCFGDef("sysKey",
1036 1040
                 "dl") . '.active'] = 1; //[+active+] - 1 if $modx->documentIdentifer equal ID this element
1037 1041
             $class[] = $this->getCFGDef('currentClass', 'current');
1038
-        } else {
1042
+        } else {
1039 1043
             $data[$this->getCFGDef("sysKey", "dl") . '.active'] = 0;
1040 1044
         }
1041 1045
 
@@ -1046,8 +1050,8 @@  discard block
 block discarded – undo
1046 1050
          * @var $extE e_DL_Extender
1047 1051
          */
1048 1052
         $extE = $this->getExtender('e', true, true);
1049
-        if ($out = $extE->init($this, compact('data'))) {
1050
-            if (is_array($out)) {
1053
+        if ($out = $extE->init($this, compact('data'))) {
1054
+            if (is_array($out)) {
1051 1055
                 $data = $out;
1052 1056
             }
1053 1057
         }
@@ -1063,42 +1067,43 @@  discard block
 block discarded – undo
1063 1067
      * @param array $array данные которые необходимо примешать к ответу на каждой записи $data
1064 1068
      * @return string JSON строка
1065 1069
      */
1066
-    public function getJSON($data, $fields, $array = array())
1067
-    {
1070
+    public function getJSON($data, $fields, $array = array())
1071
+    {
1068 1072
         $out = array();
1069 1073
         $fields = is_array($fields) ? $fields : explode(",", $fields);
1070
-        if (is_array($array) && count($array) > 0) {
1074
+        if (is_array($array) && count($array) > 0) {
1071 1075
             $tmp = array();
1072
-            foreach ($data as $i => $v) { //array_merge not valid work with integer index key
1076
+            foreach ($data as $i => $v) {
1077
+//array_merge not valid work with integer index key
1073 1078
                 $tmp[$i] = (isset($array[$i]) ? array_merge($v, $array[$i]) : $v);
1074 1079
             }
1075 1080
             $data = $tmp;
1076 1081
         }
1077 1082
 
1078
-        foreach ($data as $num => $doc) {
1083
+        foreach ($data as $num => $doc) {
1079 1084
             $tmp = array();
1080
-            foreach ($doc as $name => $value) {
1081
-                if (in_array($name, $fields) || (isset($fields[0]) && $fields[0] == '1')) {
1085
+            foreach ($doc as $name => $value) {
1086
+                if (in_array($name, $fields) || (isset($fields[0]) && $fields[0] == '1')) {
1082 1087
                     $tmp[str_replace(".", "_", $name)] = $value; //JSON element name without dot
1083 1088
                 }
1084 1089
             }
1085 1090
             $out[$num] = $tmp;
1086 1091
         }
1087 1092
 
1088
-        if ('new' == $this->getCFGDef('JSONformat', 'old')) {
1093
+        if ('new' == $this->getCFGDef('JSONformat', 'old')) {
1089 1094
             $return = array();
1090 1095
 
1091 1096
             $return['rows'] = array();
1092
-            foreach ($out as $key => $item) {
1097
+            foreach ($out as $key => $item) {
1093 1098
                 $return['rows'][] = APIHelpers::getkey($item, $key, $item);
1094 1099
             }
1095 1100
             $return['total'] = $this->getChildrenCount();
1096
-        }elseif ('simple' == $this->getCFGDef('JSONformat', 'old')) {
1101
+        } elseif ('simple' == $this->getCFGDef('JSONformat', 'old')) {
1097 1102
             $return = array();
1098
-            foreach ($out as $key => $item) {
1103
+            foreach ($out as $key => $item) {
1099 1104
                 $return[] = APIHelpers::getkey($item, $key, $item);
1100 1105
             }
1101
-        } else {
1106
+        } else {
1102 1107
             $return = $out;
1103 1108
         }
1104 1109
         $this->outData = json_encode($return);
@@ -1114,11 +1119,11 @@  discard block
 block discarded – undo
1114 1119
      * @param string $contentField
1115 1120
      * @return mixed|string
1116 1121
      */
1117
-    protected function getSummary(array $item = array(), $extSummary = null, $introField = '', $contentField = '')
1118
-    {
1122
+    protected function getSummary(array $item = array(), $extSummary = null, $introField = '', $contentField = '')
1123
+    {
1119 1124
         $out = '';
1120 1125
 
1121
-        if (is_null($extSummary)) {
1126
+        if (is_null($extSummary)) {
1122 1127
             /**
1123 1128
              * @var $extSummary summary_DL_Extender
1124 1129
              */
@@ -1127,10 +1132,10 @@  discard block
 block discarded – undo
1127 1132
         $introField = $this->getCFGDef("introField", $introField);
1128 1133
         $contentField = $this->getCFGDef("contentField", $contentField);
1129 1134
 
1130
-        if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1135
+        if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1131 1136
             $out = $item[$introField];
1132
-        } else {
1133
-            if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1137
+        } else {
1138
+            if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1134 1139
                 $out = $extSummary->init($this, array(
1135 1140
                     "content"      => $item[$contentField],
1136 1141
                     "action"       => $this->getCFGDef("summary", ""),
@@ -1148,8 +1153,8 @@  discard block
 block discarded – undo
1148 1153
      * @param string $name extender name
1149 1154
      * @return boolean status extender load
1150 1155
      */
1151
-    public function checkExtender($name)
1152
-    {
1156
+    public function checkExtender($name)
1157
+    {
1153 1158
         return (isset($this->extender[$name]) && $this->extender[$name] instanceof $name . "_DL_Extender");
1154 1159
     }
1155 1160
 
@@ -1157,8 +1162,8 @@  discard block
 block discarded – undo
1157 1162
      * @param $name
1158 1163
      * @param $obj
1159 1164
      */
1160
-    public function setExtender($name, $obj)
1161
-    {
1165
+    public function setExtender($name, $obj)
1166
+    {
1162 1167
         $this->extender[$name] = $obj;
1163 1168
     }
1164 1169
 
@@ -1170,13 +1175,13 @@  discard block
 block discarded – undo
1170 1175
      * @param bool $nop если экстендер не загружен, то загружать ли xNop
1171 1176
      * @return null|xNop
1172 1177
      */
1173
-    public function getExtender($name, $autoload = false, $nop = false)
1174
-    {
1178
+    public function getExtender($name, $autoload = false, $nop = false)
1179
+    {
1175 1180
         $out = null;
1176
-        if ((is_scalar($name) && $this->checkExtender($name)) || ($autoload && $this->_loadExtender($name))) {
1181
+        if ((is_scalar($name) && $this->checkExtender($name)) || ($autoload && $this->_loadExtender($name))) {
1177 1182
             $out = $this->extender[$name];
1178 1183
         }
1179
-        if ($nop && is_null($out)) {
1184
+        if ($nop && is_null($out)) {
1180 1185
             $out = new xNop();
1181 1186
         }
1182 1187
 
@@ -1189,27 +1194,27 @@  discard block
 block discarded – undo
1189 1194
      * @param string $name name extender
1190 1195
      * @return boolean $flag status load extender
1191 1196
      */
1192
-    protected function _loadExtender($name)
1193
-    {
1197
+    protected function _loadExtender($name)
1198
+    {
1194 1199
         $this->debug->debug('Load Extender ' . $this->debug->dumpData($name), 'LoadExtender', 2);
1195 1200
         $flag = false;
1196 1201
 
1197 1202
         $classname = ($name != '') ? $name . "_DL_Extender" : "";
1198
-        if ($classname != '' && isset($this->extender[$name]) && $this->extender[$name] instanceof $classname) {
1203
+        if ($classname != '' && isset($this->extender[$name]) && $this->extender[$name] instanceof $classname) {
1199 1204
             $flag = true;
1200 1205
 
1201
-        } else {
1202
-            if (!class_exists($classname, false) && $classname != '') {
1203
-                if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) {
1206
+        } else {
1207
+            if (!class_exists($classname, false) && $classname != '') {
1208
+                if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) {
1204 1209
                     include_once(dirname(__FILE__) . "/extender/" . $name . ".extender.inc");
1205 1210
                 }
1206 1211
             }
1207
-            if (class_exists($classname, false) && $classname != '') {
1212
+            if (class_exists($classname, false) && $classname != '') {
1208 1213
                 $this->extender[$name] = new $classname($this, $name);
1209 1214
                 $flag = true;
1210 1215
             }
1211 1216
         }
1212
-        if (!$flag) {
1217
+        if (!$flag) {
1213 1218
             $this->debug->debug("Error load Extender " . $this->debug->dumpData($name));
1214 1219
         }
1215 1220
         $this->debug->debugEnd('LoadExtender');
@@ -1227,16 +1232,16 @@  discard block
 block discarded – undo
1227 1232
      * @param mixed $IDs список id документов по которым необходима выборка
1228 1233
      * @return array очищенный массив
1229 1234
      */
1230
-    public function setIDs($IDs)
1231
-    {
1235
+    public function setIDs($IDs)
1236
+    {
1232 1237
         $this->debug->debug('set ID list ' . $this->debug->dumpData($IDs), 'setIDs', 2);
1233 1238
         $IDs = $this->cleanIDs($IDs);
1234 1239
         $type = $this->getCFGDef('idType', 'parents');
1235 1240
         $depth = $this->getCFGDef('depth', '');
1236
-        if ($type == 'parents' && $depth > 0) {
1241
+        if ($type == 'parents' && $depth > 0) {
1237 1242
             $tmp = $IDs;
1238
-            do {
1239
-                if (count($tmp) > 0) {
1243
+            do {
1244
+                if (count($tmp) > 0) {
1240 1245
                     $tmp = $this->getChildrenFolder($tmp);
1241 1246
                     $IDs = array_merge($IDs, $tmp);
1242 1247
                 }
@@ -1250,8 +1255,8 @@  discard block
 block discarded – undo
1250 1255
     /**
1251 1256
      * @return int
1252 1257
      */
1253
-    public function getIDs()
1254
-    {
1258
+    public function getIDs()
1259
+    {
1255 1260
         return $this->IDs;
1256 1261
     }
1257 1262
 
@@ -1262,17 +1267,18 @@  discard block
 block discarded – undo
1262 1267
      * @param string $sep разделитель
1263 1268
      * @return array очищенный массив с данными
1264 1269
      */
1265
-    public function cleanIDs($IDs, $sep = ',')
1266
-    {
1270
+    public function cleanIDs($IDs, $sep = ',')
1271
+    {
1267 1272
         $this->debug->debug('clean IDs ' . $this->debug->dumpData($IDs) . ' with separator ' . $this->debug->dumpData($sep),
1268 1273
             'cleanIDs', 2);
1269 1274
         $out = array();
1270
-        if (!is_array($IDs)) {
1275
+        if (!is_array($IDs)) {
1271 1276
             $IDs = explode($sep, $IDs);
1272 1277
         }
1273
-        foreach ($IDs as $item) {
1278
+        foreach ($IDs as $item) {
1274 1279
             $item = trim($item);
1275
-            if (is_numeric($item) && (int)$item >= 0) { //Fix 0xfffffffff
1280
+            if (is_numeric($item) && (int)$item >= 0) {
1281
+//Fix 0xfffffffff
1276 1282
                 $out[] = (int)$item;
1277 1283
             }
1278 1284
         }
@@ -1286,8 +1292,8 @@  discard block
 block discarded – undo
1286 1292
      * Проверка массива с id-шниками документов для выборки
1287 1293
      * @return boolean пригодны ли данные для дальнейшего использования
1288 1294
      */
1289
-    protected function checkIDs()
1290
-    {
1295
+    protected function checkIDs()
1296
+    {
1291 1297
         return (is_array($this->IDs) && count($this->IDs) > 0) ? true : false;
1292 1298
     }
1293 1299
 
@@ -1299,11 +1305,11 @@  discard block
 block discarded – undo
1299 1305
      * @global array $_docs all documents
1300 1306
      * @return array all field values
1301 1307
      */
1302
-    public function getOneField($userField, $uniq = false)
1303
-    {
1308
+    public function getOneField($userField, $uniq = false)
1309
+    {
1304 1310
         $out = array();
1305
-        foreach ($this->_docs as $doc => $val) {
1306
-            if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) {
1311
+        foreach ($this->_docs as $doc => $val) {
1312
+            if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) {
1307 1313
                 $out[$doc] = $val[$userField];
1308 1314
             }
1309 1315
         }
@@ -1314,8 +1320,8 @@  discard block
 block discarded – undo
1314 1320
     /**
1315 1321
      * @return DLCollection
1316 1322
      */
1317
-    public function docsCollection()
1318
-    {
1323
+    public function docsCollection()
1324
+    {
1319 1325
         return new DLCollection($this->modx, $this->_docs);
1320 1326
     }
1321 1327
 
@@ -1343,10 +1349,10 @@  discard block
 block discarded – undo
1343 1349
      * @param string $group
1344 1350
      * @return string
1345 1351
      */
1346
-    protected function getGroupSQL($group = '')
1347
-    {
1352
+    protected function getGroupSQL($group = '')
1353
+    {
1348 1354
         $out = '';
1349
-        if ($group != '') {
1355
+        if ($group != '') {
1350 1356
             $out = 'GROUP BY ' . $group;
1351 1357
         }
1352 1358
 
@@ -1365,12 +1371,12 @@  discard block
 block discarded – undo
1365 1371
      *
1366 1372
      * @return string Order by for SQL
1367 1373
      */
1368
-    protected function SortOrderSQL($sortName, $orderDef = 'DESC')
1369
-    {
1374
+    protected function SortOrderSQL($sortName, $orderDef = 'DESC')
1375
+    {
1370 1376
         $this->debug->debug('', 'sortORDER', 2);
1371 1377
 
1372 1378
         $sort = '';
1373
-        switch ($this->getCFGDef('sortType', '')) {
1379
+        switch ($this->getCFGDef('sortType', '')) {
1374 1380
             case 'none':
1375 1381
                 break;
1376 1382
             case 'doclist':
@@ -1381,10 +1387,10 @@  discard block
 block discarded – undo
1381 1387
                 break;
1382 1388
             default:
1383 1389
                 $out = array('orderBy' => '', 'order' => '', 'sortBy' => '');
1384
-                if (($tmp = $this->getCFGDef('orderBy', '')) != '') {
1390
+                if (($tmp = $this->getCFGDef('orderBy', '')) != '') {
1385 1391
                     $out['orderBy'] = $tmp;
1386
-                } else {
1387
-                    switch (true) {
1392
+                } else {
1393
+                    switch (true) {
1388 1394
                         case ('' != ($tmp = $this->getCFGDef('sortDir', ''))): //higher priority than order
1389 1395
                             $out['order'] = $tmp;
1390 1396
                         // no break
@@ -1392,7 +1398,7 @@  discard block
 block discarded – undo
1392 1398
                             $out['order'] = $tmp;
1393 1399
                         // no break
1394 1400
                     }
1395
-                    if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1401
+                    if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1396 1402
                         $out['order'] = $orderDef; //Default
1397 1403
                     }
1398 1404
 
@@ -1413,26 +1419,26 @@  discard block
 block discarded – undo
1413 1419
      *
1414 1420
      * @return string LIMIT вставка в SQL запрос
1415 1421
      */
1416
-    protected function LimitSQL($limit = 0, $offset = 0)
1417
-    {
1422
+    protected function LimitSQL($limit = 0, $offset = 0)
1423
+    {
1418 1424
         $this->debug->debug('', 'limitSQL', 2);
1419 1425
         $ret = '';
1420
-        if ($limit == 0) {
1426
+        if ($limit == 0) {
1421 1427
             $limit = $this->getCFGDef('display', 0);
1422 1428
         }
1423
-        if ($offset == 0) {
1429
+        if ($offset == 0) {
1424 1430
             $offset = $this->getCFGDef('offset', 0);
1425 1431
         }
1426 1432
         $offset += $this->getCFGDef('start', 0);
1427 1433
         $total = $this->getCFGDef('total', 0);
1428
-        if ($limit < ($total - $limit)) {
1434
+        if ($limit < ($total - $limit)) {
1429 1435
             $limit = $total - $offset;
1430 1436
         }
1431 1437
 
1432
-        if ($limit != 0) {
1438
+        if ($limit != 0) {
1433 1439
             $ret = "LIMIT " . (int)$offset . "," . (int)$limit;
1434
-        } else {
1435
-            if ($offset != 0) {
1440
+        } else {
1441
+            if ($offset != 0) {
1436 1442
                 /**
1437 1443
                  * To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter
1438 1444
                  * @see http://dev.mysql.com/doc/refman/5.0/en/select.html
@@ -1452,8 +1458,8 @@  discard block
 block discarded – undo
1452 1458
      * @param string $charset
1453 1459
      * @return string Clear string
1454 1460
      */
1455
-    public function sanitarData($data, $charset = 'UTF-8')
1456
-    {
1461
+    public function sanitarData($data, $charset = 'UTF-8')
1462
+    {
1457 1463
         return APIHelpers::sanitarTag($data, $charset);
1458 1464
     }
1459 1465
 
@@ -1464,8 +1470,8 @@  discard block
 block discarded – undo
1464 1470
      * @param string $parentField default name parent field
1465 1471
      * @return array
1466 1472
      */
1467
-    public function treeBuild($idField = 'id', $parentField = 'parent')
1468
-    {
1473
+    public function treeBuild($idField = 'id', $parentField = 'parent')
1474
+    {
1469 1475
         return $this->_treeBuild($this->_docs, $this->getCFGDef('idField', $idField),
1470 1476
             $this->getCFGDef('parentField', $parentField));
1471 1477
     }
@@ -1478,16 +1484,16 @@  discard block
 block discarded – undo
1478 1484
      * @param string $pidName name parent field in associative data array
1479 1485
      * @return array
1480 1486
      */
1481
-    private function _treeBuild($data, $idName, $pidName)
1482
-    {
1487
+    private function _treeBuild($data, $idName, $pidName)
1488
+    {
1483 1489
         $children = array(); // children of each ID
1484 1490
         $ids = array();
1485
-        foreach ($data as $i => $r) {
1491
+        foreach ($data as $i => $r) {
1486 1492
             $row =& $data[$i];
1487 1493
             $id = $row[$idName];
1488 1494
             $pid = $row[$pidName];
1489 1495
             $children[$pid][$id] =& $row;
1490
-            if (!isset($children[$id])) {
1496
+            if (!isset($children[$id])) {
1491 1497
                 $children[$id] = array();
1492 1498
             }
1493 1499
             $row['#childNodes'] =& $children[$id];
@@ -1495,9 +1501,9 @@  discard block
 block discarded – undo
1495 1501
         }
1496 1502
         // Root elements are elements with non-found PIDs.
1497 1503
         $this->_tree = array();
1498
-        foreach ($data as $i => $r) {
1504
+        foreach ($data as $i => $r) {
1499 1505
             $row =& $data[$i];
1500
-            if (!isset($ids[$row[$pidName]])) {
1506
+            if (!isset($ids[$row[$pidName]])) {
1501 1507
                 $this->_tree[$row[$idName]] = $row;
1502 1508
             }
1503 1509
         }
@@ -1511,8 +1517,8 @@  discard block
 block discarded – undo
1511 1517
      *
1512 1518
      * @return string PrimaryKey основной таблицы
1513 1519
      */
1514
-    public function getPK()
1515
-    {
1520
+    public function getPK()
1521
+    {
1516 1522
         return isset($this->idField) ? $this->idField : 'id';
1517 1523
     }
1518 1524
 
@@ -1521,8 +1527,8 @@  discard block
 block discarded – undo
1521 1527
      * По умолчанию это parent. Переопределить можно в контроллере присвоив другое значение переменной parentField
1522 1528
      * @return string Parent Key основной таблицы
1523 1529
      */
1524
-    public function getParentField()
1525
-    {
1530
+    public function getParentField()
1531
+    {
1526 1532
         return isset($this->parentField) ? $this->parentField : '';
1527 1533
     }
1528 1534
 
@@ -1533,31 +1539,31 @@  discard block
 block discarded – undo
1533 1539
      * @param string $filter_string строка со всеми фильтрами
1534 1540
      * @return mixed результат разбора фильтров
1535 1541
      */
1536
-    protected function getFilters($filter_string)
1537
-    {
1542
+    protected function getFilters($filter_string)
1543
+    {
1538 1544
         $this->debug->debug("getFilters: " . $this->debug->dumpData($filter_string), 'getFilter', 1);
1539 1545
         // the filter parameter tells us, which filters can be used in this query
1540 1546
         $filter_string = trim($filter_string, ' ;');
1541
-        if (!$filter_string) {
1547
+        if (!$filter_string) {
1542 1548
             return;
1543 1549
         }
1544 1550
         $output = array('join' => '', 'where' => '');
1545 1551
         $logic_op_found = false;
1546 1552
         $joins = $wheres = array();
1547
-        foreach ($this->_logic_ops as $op => $sql) {
1548
-            if (strpos($filter_string, $op) === 0) {
1553
+        foreach ($this->_logic_ops as $op => $sql) {
1554
+            if (strpos($filter_string, $op) === 0) {
1549 1555
                 $logic_op_found = true;
1550 1556
                 $subfilters = mb_substr($filter_string, strlen($op) + 1, mb_strlen($filter_string, "UTF-8"), "UTF-8");
1551 1557
                 $subfilters = $this->smartSplit($subfilters);
1552
-                foreach ($subfilters as $subfilter) {
1558
+                foreach ($subfilters as $subfilter) {
1553 1559
                     $subfilter = $this->getFilters(trim($subfilter));
1554
-                    if (!$subfilter) {
1560
+                    if (!$subfilter) {
1555 1561
                         continue;
1556 1562
                     }
1557
-                    if ($subfilter['join']) {
1563
+                    if ($subfilter['join']) {
1558 1564
                         $joins[] = $subfilter['join'];
1559 1565
                     }
1560
-                    if ($subfilter['where']) {
1566
+                    if ($subfilter['where']) {
1561 1567
                         $wheres[] = $subfilter['where'];
1562 1568
                     }
1563 1569
                 }
@@ -1566,12 +1572,12 @@  discard block
 block discarded – undo
1566 1572
             }
1567 1573
         }
1568 1574
 
1569
-        if (!$logic_op_found) {
1575
+        if (!$logic_op_found) {
1570 1576
             $filter = $this->loadFilter($filter_string);
1571
-            if (!$filter) {
1577
+            if (!$filter) {
1572 1578
                 $this->debug->warning('Error while loading DocLister filter "' . $this->debug->dumpData($filter_string) . '": check syntax!');
1573 1579
                 $output = false;
1574
-            } else {
1580
+            } else {
1575 1581
                 $output['join'] = $filter->get_join();
1576 1582
                 $output['where'] = $filter->get_where();
1577 1583
             }
@@ -1584,16 +1590,16 @@  discard block
 block discarded – undo
1584 1590
     /**
1585 1591
      * @return mixed
1586 1592
      */
1587
-    public function filtersWhere()
1588
-    {
1593
+    public function filtersWhere()
1594
+    {
1589 1595
         return APIHelpers::getkey($this->_filters, 'where', '');
1590 1596
     }
1591 1597
 
1592 1598
     /**
1593 1599
      * @return mixed
1594 1600
      */
1595
-    public function filtersJoin()
1596
-    {
1601
+    public function filtersJoin()
1602
+    {
1597 1603
         return APIHelpers::getkey($this->_filters, 'join', '');
1598 1604
     }
1599 1605
 
@@ -1604,10 +1610,10 @@  discard block
 block discarded – undo
1604 1610
      * @param $type string тип фильтрации
1605 1611
      * @return string имя поля с учетом приведения типа
1606 1612
      */
1607
-    public function changeSortType($field, $type)
1608
-    {
1613
+    public function changeSortType($field, $type)
1614
+    {
1609 1615
         $type = trim($type);
1610
-        switch (strtoupper($type)) {
1616
+        switch (strtoupper($type)) {
1611 1617
             case 'DECIMAL':
1612 1618
                 $field = 'CAST(' . $field . ' as DECIMAL(10,2))';
1613 1619
                 break;
@@ -1633,14 +1639,14 @@  discard block
 block discarded – undo
1633 1639
      * @param string $filter срока с параметрами фильтрации
1634 1640
      * @return bool
1635 1641
      */
1636
-    protected function loadFilter($filter)
1637
-    {
1642
+    protected function loadFilter($filter)
1643
+    {
1638 1644
         $this->debug->debug('Load filter ' . $this->debug->dumpData($filter), 'loadFilter', 2);
1639 1645
         $out = false;
1640 1646
         $fltr_params = explode(':', $filter, 2);
1641 1647
         $fltr = APIHelpers::getkey($fltr_params, 0, null);
1642 1648
         // check if the filter is implemented
1643
-        if (!is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1649
+        if (!is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1644 1650
             require_once dirname(__FILE__) . '/filter/' . $fltr . '.filter.php';
1645 1651
             /**
1646 1652
              * @var tv_DL_filter|content_DL_filter $fltr_class
@@ -1648,12 +1654,12 @@  discard block
 block discarded – undo
1648 1654
             $fltr_class = $fltr . '_DL_filter';
1649 1655
             $this->totalFilters++;
1650 1656
             $fltr_obj = new $fltr_class();
1651
-            if ($fltr_obj->init($this, $filter)) {
1657
+            if ($fltr_obj->init($this, $filter)) {
1652 1658
                 $out = $fltr_obj;
1653
-            } else {
1659
+            } else {
1654 1660
                 $this->debug->error("Wrong filter parameter: '{$this->debug->dumpData($filter)}'", 'Filter');
1655 1661
             }
1656
-        } else {
1662
+        } else {
1657 1663
             $this->debug->error("Error load Filter: '{$this->debug->dumpData($filter)}'", 'Filter');
1658 1664
         }
1659 1665
         $this->debug->debugEnd("loadFilter");
@@ -1665,8 +1671,8 @@  discard block
 block discarded – undo
1665 1671
      * Общее число фильтров
1666 1672
      * @return int
1667 1673
      */
1668
-    public function getCountFilters()
1669
-    {
1674
+    public function getCountFilters()
1675
+    {
1670 1676
         return (int)$this->totalFilters;
1671 1677
     }
1672 1678
 
@@ -1674,8 +1680,8 @@  discard block
 block discarded – undo
1674 1680
      * Выполнить SQL запрос
1675 1681
      * @param string $q SQL запрос
1676 1682
      */
1677
-    public function dbQuery($q)
1678
-    {
1683
+    public function dbQuery($q)
1684
+    {
1679 1685
         $this->debug->debug($q, "query", 1, 'sql');
1680 1686
         $out = $this->modx->db->query($q);
1681 1687
         $this->debug->debugEnd("query");
@@ -1693,8 +1699,8 @@  discard block
 block discarded – undo
1693 1699
      * @param string $tpl шаблон подстановки значения в SQL запрос
1694 1700
      * @return string строка для подстановки в SQL запрос
1695 1701
      */
1696
-    public function LikeEscape($field, $value, $escape = '=', $tpl = '%[+value+]%')
1697
-    {
1702
+    public function LikeEscape($field, $value, $escape = '=', $tpl = '%[+value+]%')
1703
+    {
1698 1704
         return sqlHelper::LikeEscape($this->modx, $field, $value, $escape, $tpl);
1699 1705
     }
1700 1706
 
@@ -1702,8 +1708,8 @@  discard block
 block discarded – undo
1702 1708
      * Получение REQUEST_URI без GET-ключа с
1703 1709
      * @return string
1704 1710
      */
1705
-    public function getRequest()
1706
-    {
1711
+    public function getRequest()
1712
+    {
1707 1713
         $URL = null;
1708 1714
         parse_str(parse_url(MODX_SITE_URL . $_SERVER['REQUEST_URI'], PHP_URL_QUERY), $URL);
1709 1715
 
Please login to merge, or discard this patch.
assets/snippets/DLUsers/plugin.DLLogout.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-if (!defined('MODX_BASE_PATH')) {
2
+if ( ! defined('MODX_BASE_PATH')) {
3 3
     die('What are you doing? Get out of here!');
4 4
 }
5 5
 if ($modx->event->name == 'OnWebPagePrerender' && $modx->getLoginUserID('web')) {
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2
-if (!defined('MODX_BASE_PATH')) {
2
+if (!defined('MODX_BASE_PATH')) {
3 3
     die('What are you doing? Get out of here!');
4 4
 }
5
-if ($modx->event->name == 'OnWebPagePrerender' && $modx->getLoginUserID('web')) {
5
+if ($modx->event->name == 'OnWebPagePrerender' && $modx->getLoginUserID('web')) {
6 6
     $snippetName = (isset($snippetName) && is_string($snippetName)) ? $snippetName : 'DLUsers';
7 7
     $modx->runSnippet($snippetName, array(
8 8
         'action' => 'logout'
Please login to merge, or discard this patch.
assets/snippets/DocLister/snippet.DLBeforeAfter.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 include_once(MODX_BASE_PATH . 'assets/lib/APIHelpers.class.php');
3
-if (!function_exists('validateMonth')) {
3
+if ( ! function_exists('validateMonth')) {
4 4
     /**
5 5
      * @param $val
6 6
      * @return bool
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     }
21 21
 }
22 22
 
23
-if (!function_exists('buildUrl')) {
23
+if ( ! function_exists('buildUrl')) {
24 24
     /**
25 25
      * @param $url
26 26
      * @param int $start
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
         $requestName = 'start';
34 34
         if ($requestName != '' && is_array($params)) {
35 35
             $params = array_merge($params, array($requestName => null));
36
-            if (!empty($start)) {
36
+            if ( ! empty($start)) {
37 37
                 $params[$requestName] = $start;
38 38
             }
39 39
             $q = http_build_query($params);
40 40
             $url = explode("?", $url, 2);
41 41
             $url = $url[0];
42
-            if (!empty($q)) {
42
+            if ( ! empty($q)) {
43 43
                 $url .= "?" . $q;
44 44
             }
45 45
         }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
 $tmp = date("Y-m-d H:i:s");
61 61
 $currentDay = APIHelpers::getkey($params, 'currentDay', $tmp); // Текущий день
62
-if (!validateDate($currentDay)) {
62
+if ( ! validateDate($currentDay)) {
63 63
     $currentDay = $tmp;
64 64
 }
65 65
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     'pagesAfter'     => ceil($elements['after'] / $elements['display'])
156 156
 );
157 157
 
158
-if (!is_null($beforeStart)) {
158
+if ( ! is_null($beforeStart)) {
159 159
     $tpl = $DLObj->getCFGDef('TplPrevP', '@CODE: <a href="[+url+]">Назад</a>');
160 160
     $beforePage = $DLObj->parseChunk($tpl, array_merge($pageParams, array(
161 161
         'url'      => buildUrl($DLObj->getUrl(), $beforeStart),
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 }
175 175
 $modx->setPlaceholder('pages.before', $beforePage);
176 176
 
177
-if (!is_null($afterStart)) {
177
+if ( ! is_null($afterStart)) {
178 178
     $tpl = $DLObj->getCFGDef('TplNextP', '@CODE: <a href="[+url+]">Далее</a>');
179 179
     $afterPage = $DLObj->parseChunk($tpl, array_merge($pageParams, array(
180 180
         'url'      => buildUrl($DLObj->getUrl(), $afterStart),
Please login to merge, or discard this patch.
Braces   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 include_once(MODX_BASE_PATH . 'assets/lib/APIHelpers.class.php');
3
-if (!function_exists('validateMonth')) {
3
+if (!function_exists('validateMonth')) {
4 4
     /**
5 5
      * @param $val
6 6
      * @return bool
7 7
      */
8
-    function validateDate($val)
9
-    {
8
+    function validateDate($val)
9
+    {
10 10
         $flag = false;
11
-        if (is_string($val)) {
11
+        if (is_string($val)) {
12 12
             $val = explode("-", $val, 3);
13 13
             $flag = (count($val) == 3 && is_array($val) && strlen($val[2]) == 2 && strlen($val[1]) == 2 && strlen($val[0]) == 4); //Валидация содержимого массива
14 14
             $flag = ($flag && (int)$val[2] > 0 && (int)$val[2] <= 31); //Валидация дня
@@ -20,26 +20,26 @@  discard block
 block discarded – undo
20 20
     }
21 21
 }
22 22
 
23
-if (!function_exists('buildUrl')) {
23
+if (!function_exists('buildUrl')) {
24 24
     /**
25 25
      * @param $url
26 26
      * @param int $start
27 27
      * @return array|string
28 28
      */
29
-    function buildUrl($url, $start = 0)
30
-    {
29
+    function buildUrl($url, $start = 0)
30
+    {
31 31
         $params = parse_url($url, PHP_URL_QUERY);
32 32
         parse_str(html_entity_decode($params), $params);
33 33
         $requestName = 'start';
34
-        if ($requestName != '' && is_array($params)) {
34
+        if ($requestName != '' && is_array($params)) {
35 35
             $params = array_merge($params, array($requestName => null));
36
-            if (!empty($start)) {
36
+            if (!empty($start)) {
37 37
                 $params[$requestName] = $start;
38 38
             }
39 39
             $q = http_build_query($params);
40 40
             $url = explode("?", $url, 2);
41 41
             $url = $url[0];
42
-            if (!empty($q)) {
42
+            if (!empty($q)) {
43 43
                 $url .= "?" . $q;
44 44
             }
45 45
         }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
 $tmp = date("Y-m-d H:i:s");
61 61
 $currentDay = APIHelpers::getkey($params, 'currentDay', $tmp); // Текущий день
62
-if (!validateDate($currentDay)) {
62
+if (!validateDate($currentDay)) {
63 63
     $currentDay = $tmp;
64 64
 }
65 65
 
@@ -70,17 +70,17 @@  discard block
 block discarded – undo
70 70
 //Если положительное значение, то нужы события предстоящие. Если отрицательное - прошедшее
71 71
 $rule = ($start >= 0) ? 'after' : 'before';
72 72
 $noRule = ($start >= 0) ? 'before' : 'after';
73
-if ($start < 0) {
73
+if ($start < 0) {
74 74
     $start = abs($start) > $display ? ($start + $display) : 0;
75 75
 }
76 76
 $d = $modx->db->escape($currentDay);
77
-if ($dateSource == 'tv') {
77
+if ($dateSource == 'tv') {
78 78
     $params['tvSortType'] = 'TVDATETIME';
79 79
     $query = array(
80 80
         'after'  => "STR_TO_DATE(`dltv_" . $dateField . "_1`.`value`,'%d-%m-%Y %H:%i:%s') >= '" . $d . "'",
81 81
         'before' => "STR_TO_DATE(`dltv_" . $dateField . "_1`.`value`,'%d-%m-%Y %H:%i:%s') < '" . $d . "'"
82 82
     );
83
-} else {
83
+} else {
84 84
     $query = array(
85 85
         'after'  => "FROM_UNIXTIME(" . $dateField . ") >= '" . $d . "'",
86 86
         'before' => "FROM_UNIXTIME(" . $dateField . ") < '" . $d . "'"
@@ -119,32 +119,32 @@  discard block
 block discarded – undo
119 119
 $elements[$noRule] = $DLObj->getChildrenCount();
120 120
 
121 121
 $afterStart = $beforeStart = null;
122
-switch (true) {
122
+switch (true) {
123 123
     case ($elements['offset'] > 0):
124 124
         $beforeStart = $elements['offset'] - $elements['display'];
125
-        if ($elements['offset'] + $elements['display'] < $elements['after']) {
125
+        if ($elements['offset'] + $elements['display'] < $elements['after']) {
126 126
             $afterStart = $elements['offset'] + $elements['display'];
127
-        } else {
127
+        } else {
128 128
             $afterStart = null;
129 129
         }
130 130
         break;
131 131
     case ($elements['offset'] < 0):
132 132
         $afterStart = $elements['offset'] + $elements['display'];
133
-        if (abs($elements['offset']) + $elements['display'] <= $elements['before']) {
133
+        if (abs($elements['offset']) + $elements['display'] <= $elements['before']) {
134 134
             $beforeStart = $elements['offset'] - $elements['display'];
135
-        } else {
135
+        } else {
136 136
             $beforeStart = null;
137 137
         }
138 138
         break;
139 139
     default: // ($start = 0)
140
-        if ($elements['display'] < $elements['after']) {
140
+        if ($elements['display'] < $elements['after']) {
141 141
             $afterStart = $elements['display'];
142
-        } else {
142
+        } else {
143 143
             $afterStart = null;
144 144
         }
145
-        if ($elements['display'] <= $elements['before']) {
145
+        if ($elements['display'] <= $elements['before']) {
146 146
             $beforeStart = -1 * $elements['display'];
147
-        } else {
147
+        } else {
148 148
             $beforeStart = null;
149 149
         }
150 150
 }
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     'pagesAfter'     => ceil($elements['after'] / $elements['display'])
156 156
 );
157 157
 
158
-if (!is_null($beforeStart)) {
158
+if (!is_null($beforeStart)) {
159 159
     $tpl = $DLObj->getCFGDef('TplPrevP', '@CODE: <a href="[+url+]">Назад</a>');
160 160
     $beforePage = $DLObj->parseChunk($tpl, array_merge($pageParams, array(
161 161
         'url'      => buildUrl($DLObj->getUrl(), $beforeStart),
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
         'elements' => $elements['before'],
164 164
         'pages'    => ceil($elements['before'] / $elements['display'])
165 165
     )));
166
-} else {
167
-    if ($DLObj->getCFGDef("PrevNextAlwaysShow", 0)) {
166
+} else {
167
+    if ($DLObj->getCFGDef("PrevNextAlwaysShow", 0)) {
168 168
         $tpl = $DLObj->getCFGDef('TplPrevI', '@CODE: Назад');
169 169
         $beforePage = $DLObj->parseChunk($tpl, array_merge($pageParams, array(
170 170
             'elements' => $elements['before'],
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 }
175 175
 $modx->setPlaceholder('pages.before', $beforePage);
176 176
 
177
-if (!is_null($afterStart)) {
177
+if (!is_null($afterStart)) {
178 178
     $tpl = $DLObj->getCFGDef('TplNextP', '@CODE: <a href="[+url+]">Далее</a>');
179 179
     $afterPage = $DLObj->parseChunk($tpl, array_merge($pageParams, array(
180 180
         'url'      => buildUrl($DLObj->getUrl(), $afterStart),
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
         'elements' => $elements['after'],
183 183
         'pages'    => ceil($elements['before'] / $elements['display'])
184 184
     )));
185
-} else {
186
-    if ($DLObj->getCFGDef("PrevNextAlwaysShow", 0)) {
185
+} else {
186
+    if ($DLObj->getCFGDef("PrevNextAlwaysShow", 0)) {
187 187
         $tpl = $DLObj->getCFGDef('TplNextI', '@CODE: Далее');
188 188
         $afterPage = $DLObj->parseChunk($tpl, array_merge($pageParams, array(
189 189
             'elements' => $elements['after'],
@@ -194,10 +194,10 @@  discard block
 block discarded – undo
194 194
 $modx->setPlaceholder('pages.after', $afterPage);
195 195
 
196 196
 $debug = $DLObj->getCFGDef('debug', 0);
197
-if ($debug) {
198
-    if ($debug > 0) {
197
+if ($debug) {
198
+    if ($debug > 0) {
199 199
         $out = $DLObj->debug->showLog() . $out;
200
-    } else {
200
+    } else {
201 201
         $out .= $DLObj->debug->showLog();
202 202
     }
203 203
 }
Please login to merge, or discard this patch.
assets/snippets/DocLister/snippet.DLReflectFilter.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
  *            year - по годам
27 27
  */
28 28
 $reflectType = APIHelpers::getkey($params, 'reflectType', 'month');
29
-if (!in_array($reflectType, array('year', 'month'))) {
29
+if ( ! in_array($reflectType, array('year', 'month'))) {
30 30
     return '';
31 31
 }
32 32
 
33
-list($dateFormat, $sqlDateFormat, $reflectValidator) = DLReflect::switchReflect($reflectType, function () {
33
+list($dateFormat, $sqlDateFormat, $reflectValidator) = DLReflect::switchReflect($reflectType, function() {
34 34
     return array('m-Y', '%m-%Y', array('DLReflect', 'validateMonth'));
35
-}, function () {
35
+}, function() {
36 36
     return array('Y', '%Y', array('DLReflect', 'validateYear'));
37 37
 });
38 38
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 $selectCurrentReflect = APIHelpers::getkey($params, 'selectCurrentReflect', 1);
51 51
 if ($selectCurrentReflect) {
52 52
     $currentReflect = APIHelpers::getkey($params, 'currentReflect', $tmp);
53
-    if (!call_user_func($reflectValidator, $currentReflect)) {
53
+    if ( ! call_user_func($reflectValidator, $currentReflect)) {
54 54
         $currentReflect = $tmp;
55 55
     }
56 56
 } else {
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
  */
66 66
 $tmp = APIHelpers::getkey($params, 'activeReflect', $currentReflect);
67 67
 $tmpGet = APIHelpers::getkey($_GET, $reflectType, $tmp);
68
-if (!call_user_func($reflectValidator, $tmpGet)) {
68
+if ( ! call_user_func($reflectValidator, $tmpGet)) {
69 69
     $activeReflect = $tmp;
70
-    if (!call_user_func($reflectValidator, $activeReflect)) {
70
+    if ( ! call_user_func($reflectValidator, $activeReflect)) {
71 71
         $activeReflect = $currentReflect;
72 72
     }
73 73
 } else {
Please login to merge, or discard this patch.
Braces   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
  *            year - по годам
27 27
  */
28 28
 $reflectType = APIHelpers::getkey($params, 'reflectType', 'month');
29
-if (!in_array($reflectType, array('year', 'month'))) {
29
+if (!in_array($reflectType, array('year', 'month'))) {
30 30
     return '';
31 31
 }
32 32
 
33
-list($dateFormat, $sqlDateFormat, $reflectValidator) = DLReflect::switchReflect($reflectType, function () {
33
+list($dateFormat, $sqlDateFormat, $reflectValidator) = DLReflect::switchReflect($reflectType, function () {
34 34
     return array('m-Y', '%m-%Y', array('DLReflect', 'validateMonth'));
35
-}, function () {
35
+}, function () {
36 36
     return array('Y', '%Y', array('DLReflect', 'validateYear'));
37 37
 });
38 38
 
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
  *        Если не указан в параметре, то генерируется автоматически текущая дата
49 49
  */
50 50
 $selectCurrentReflect = APIHelpers::getkey($params, 'selectCurrentReflect', 1);
51
-if ($selectCurrentReflect) {
51
+if ($selectCurrentReflect) {
52 52
     $currentReflect = APIHelpers::getkey($params, 'currentReflect', $tmp);
53
-    if (!call_user_func($reflectValidator, $currentReflect)) {
53
+    if (!call_user_func($reflectValidator, $currentReflect)) {
54 54
         $currentReflect = $tmp;
55 55
     }
56
-} else {
56
+} else {
57 57
     $currentReflect = null;
58 58
 }
59 59
 /**
@@ -65,24 +65,24 @@  discard block
 block discarded – undo
65 65
  */
66 66
 $tmp = APIHelpers::getkey($params, 'activeReflect', $currentReflect);
67 67
 $tmpGet = APIHelpers::getkey($_GET, $reflectType, $tmp);
68
-if (!call_user_func($reflectValidator, $tmpGet)) {
68
+if (!call_user_func($reflectValidator, $tmpGet)) {
69 69
     $activeReflect = $tmp;
70
-    if (!call_user_func($reflectValidator, $activeReflect)) {
70
+    if (!call_user_func($reflectValidator, $activeReflect)) {
71 71
         $activeReflect = $currentReflect;
72 72
     }
73
-} else {
73
+} else {
74 74
     $activeReflect = $tmpGet;
75 75
 }
76
-if ($activeReflect) {
76
+if ($activeReflect) {
77 77
     $v = $modx->db->escape($activeReflect);
78
-    if ($reflectSource == 'tv') {
78
+    if ($reflectSource == 'tv') {
79 79
         $params['tvSortType'] = 'TVDATETIME';
80 80
         $params['addWhereList'] = "DATE_FORMAT(STR_TO_DATE(`dltv_" . $reflectField . "_1`.`value`,'%d-%m-%Y %H:%i:%s'), '" . $sqlDateFormat . "')='" . $v . "'";
81
-    } else {
81
+    } else {
82 82
         $params['addWhereList'] = "DATE_FORMAT(FROM_UNIXTIME(" . $reflectField . "), '" . $sqlDateFormat . "')='" . $v . "'";
83 83
     }
84
-} else {
85
-    if ($reflectSource == 'tv') {
84
+} else {
85
+    if ($reflectSource == 'tv') {
86 86
         $params['tvSortType'] = 'TVDATETIME';
87 87
     }
88 88
 }
Please login to merge, or discard this patch.
assets/snippets/DocLister/lib/DLdebug.class.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
                 'format' => $format,
89 89
                 'start'  => microtime(true) - $this->DocLister->getTimeStart()
90 90
             );
91
-            if (is_scalar($key) && !empty($key)) {
91
+            if (is_scalar($key) && ! empty($key)) {
92 92
                 $data['time'] = microtime(true);
93 93
                 $this->_calcLog[$key] = $data;
94 94
             } else {
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function updateMessage($message, $key, $format = null)
106 106
     {
107
-        if (is_scalar($key) && !empty($key) && isset($this->_calcLog[$key])) {
107
+        if (is_scalar($key) && ! empty($key) && isset($this->_calcLog[$key])) {
108 108
             $this->_calcLog[$key]['msg'] = $message;
109
-            if (!is_null($format)) {
109
+            if ( ! is_null($format)) {
110 110
                 $this->_calcLog[$key]['format'] = $format;
111 111
             }
112 112
         }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      */
166 166
     private function _sendLogEvent($type, $message, $title = '')
167 167
     {
168
-        $title = "DocLister" . (!empty($title) ? ' - ' . $title : '');
168
+        $title = "DocLister" . ( ! empty($title) ? ' - ' . $title : '');
169 169
         $this->modx->logEvent(0, $type, $message, $title);
170 170
     }
171 171
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
                                 $msg = $this->dumpData($msg);
204 204
                                 break;
205 205
                         }
206
-                        if (!empty($title) && !is_numeric($title)) {
206
+                        if ( ! empty($title) && ! is_numeric($title)) {
207 207
                             $message .= $this->DocLister->parseChunk('@CODE:<strong>[+title+]</strong>: [+msg+]<br />',
208 208
                                 compact('msg', 'title'));
209 209
                         } else {
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
                     </li>';
223 223
                 $out .= $this->DocLister->parseChunk("@CODE: " . $tpl, $item);
224 224
             }
225
-            if (!empty($out)) {
225
+            if ( ! empty($out)) {
226 226
                 $out = $this->DocLister->parseChunk("@CODE:
227 227
                 <style>.dlDebug{
228 228
                     background: #eee !important;
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
     public function dumpData($data, $wrap = '', $charset = 'UTF-8')
280 280
     {
281 281
         $out = $this->DocLister->sanitarData(print_r($data, 1), $charset);
282
-        if (!empty($wrap) && is_string($wrap)) {
282
+        if ( ! empty($wrap) && is_string($wrap)) {
283 283
             $out = "<{$wrap}>{$out}</{$wrap}>";
284 284
         }
285 285
 
Please login to merge, or discard this patch.
Braces   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@  discard block
 block discarded – undo
5 5
 /**
6 6
  * Class DLdebug
7 7
  */
8
-class DLdebug
9
-{
8
+class DLdebug
9
+{
10 10
     /**
11 11
      * @var array
12 12
      */
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
      * DLdebug constructor.
36 36
      * @param $DocLister
37 37
      */
38
-    public function __construct($DocLister)
39
-    {
40
-        if ($DocLister instanceof DocLister) {
38
+    public function __construct($DocLister)
39
+    {
40
+        if ($DocLister instanceof DocLister) {
41 41
             $this->DocLister = $DocLister;
42 42
             $this->modx = $this->DocLister->getMODX();
43 43
         }
@@ -47,16 +47,16 @@  discard block
 block discarded – undo
47 47
     /**
48 48
      * @return array
49 49
      */
50
-    public function getLog()
51
-    {
50
+    public function getLog()
51
+    {
52 52
         return $this->_log;
53 53
     }
54 54
 
55 55
     /**
56 56
      * @return $this
57 57
      */
58
-    public function clearLog()
59
-    {
58
+    public function clearLog()
59
+    {
60 60
         $this->_log = array();
61 61
 
62 62
         return $this;
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
     /**
66 66
      * @return int
67 67
      */
68
-    public function countLog()
69
-    {
68
+    public function countLog()
69
+    {
70 70
         return count($this->_log);
71 71
     }
72 72
 
@@ -79,19 +79,19 @@  discard block
 block discarded – undo
79 79
      * @param int $mode
80 80
      * @param bool $format
81 81
      */
82
-    public function debug($message, $key = null, $mode = 0, $format = false)
83
-    {
82
+    public function debug($message, $key = null, $mode = 0, $format = false)
83
+    {
84 84
         $mode = (int)$mode;
85
-        if ($mode > 0 && $this->DocLister->getDebug() >= $mode) {
85
+        if ($mode > 0 && $this->DocLister->getDebug() >= $mode) {
86 86
             $data = array(
87 87
                 'msg'    => $message,
88 88
                 'format' => $format,
89 89
                 'start'  => microtime(true) - $this->DocLister->getTimeStart()
90 90
             );
91
-            if (is_scalar($key) && !empty($key)) {
91
+            if (is_scalar($key) && !empty($key)) {
92 92
                 $data['time'] = microtime(true);
93 93
                 $this->_calcLog[$key] = $data;
94
-            } else {
94
+            } else {
95 95
                 $this->_log[$this->countLog()] = $data;
96 96
             }
97 97
         }
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
      * @param $key
103 103
      * @param null $format
104 104
      */
105
-    public function updateMessage($message, $key, $format = null)
106
-    {
107
-        if (is_scalar($key) && !empty($key) && isset($this->_calcLog[$key])) {
105
+    public function updateMessage($message, $key, $format = null)
106
+    {
107
+        if (is_scalar($key) && !empty($key) && isset($this->_calcLog[$key])) {
108 108
             $this->_calcLog[$key]['msg'] = $message;
109
-            if (!is_null($format)) {
109
+            if (!is_null($format)) {
110 110
                 $this->_calcLog[$key]['format'] = $format;
111 111
             }
112 112
         }
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
      * @param null $msg
118 118
      * @param null $format
119 119
      */
120
-    public function debugEnd($key, $msg = null, $format = null)
121
-    {
122
-        if (is_scalar($key) && isset($this->_calcLog[$key], $this->_calcLog[$key]['time']) && $this->DocLister->getDebug() > 0) {
120
+    public function debugEnd($key, $msg = null, $format = null)
121
+    {
122
+        if (is_scalar($key) && isset($this->_calcLog[$key], $this->_calcLog[$key]['time']) && $this->DocLister->getDebug() > 0) {
123 123
             $this->_log[$this->countLog()] = array(
124 124
                 'msg'    => isset($msg) ? $msg : $this->_calcLog[$key]['msg'],
125 125
                 'start'  => $this->_calcLog[$key]['start'],
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
      * @param $message
136 136
      * @param string $title
137 137
      */
138
-    public function info($message, $title = '')
139
-    {
138
+    public function info($message, $title = '')
139
+    {
140 140
         $this->_sendLogEvent(1, $message, $title);
141 141
     }
142 142
 
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
      * @param $message
145 145
      * @param string $title
146 146
      */
147
-    public function warning($message, $title = '')
148
-    {
147
+    public function warning($message, $title = '')
148
+    {
149 149
         $this->_sendLogEvent(2, $message, $title);
150 150
     }
151 151
 
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
      * @param $message
154 154
      * @param string $title
155 155
      */
156
-    public function error($message, $title = '')
157
-    {
156
+    public function error($message, $title = '')
157
+    {
158 158
         $this->_sendLogEvent(3, $message, $title);
159 159
     }
160 160
 
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
      * @param $message
164 164
      * @param string $title
165 165
      */
166
-    private function _sendLogEvent($type, $message, $title = '')
167
-    {
166
+    private function _sendLogEvent($type, $message, $title = '')
167
+    {
168 168
         $title = "DocLister" . (!empty($title) ? ' - ' . $title : '');
169 169
         $this->modx->logEvent(0, $type, $message, $title);
170 170
     }
@@ -172,26 +172,26 @@  discard block
 block discarded – undo
172 172
     /**
173 173
      * @return string
174 174
      */
175
-    public function showLog()
176
-    {
175
+    public function showLog()
176
+    {
177 177
         $out = "";
178
-        if ($this->DocLister->getDebug() > 0 && is_array($this->_log)) {
179
-            foreach ($this->_log as $item) {
178
+        if ($this->DocLister->getDebug() > 0 && is_array($this->_log)) {
179
+            foreach ($this->_log as $item) {
180 180
                 $item['time'] = isset($item['time']) ? round(floatval($item['time']), 5) : 0;
181 181
                 $item['start'] = isset($item['start']) ? round(floatval($item['start']), 5) : 0;
182 182
 
183
-                if (isset($item['msg'])) {
184
-                    if (is_scalar($item['msg'])) {
183
+                if (isset($item['msg'])) {
184
+                    if (is_scalar($item['msg'])) {
185 185
                         $item['msg'] = array($item['msg']);
186 186
                     }
187
-                    if (is_scalar($item['format'])) {
187
+                    if (is_scalar($item['format'])) {
188 188
                         $item['format'] = array($item['format']);
189 189
                     }
190 190
                     $message = '';
191 191
                     $i = 0;
192
-                    foreach ($item['msg'] as $title => $msg) {
192
+                    foreach ($item['msg'] as $title => $msg) {
193 193
                         $format = isset($item['format'][$i]) ? $item['format'][$i] : null;
194
-                        switch ($format) {
194
+                        switch ($format) {
195 195
                             case 'sql':
196 196
                                 $msg = $this->dumpData(Formatter\SqlFormatter::format($msg), '', null);
197 197
                                 break;
@@ -203,16 +203,16 @@  discard block
 block discarded – undo
203 203
                                 $msg = $this->dumpData($msg);
204 204
                                 break;
205 205
                         }
206
-                        if (!empty($title) && !is_numeric($title)) {
206
+                        if (!empty($title) && !is_numeric($title)) {
207 207
                             $message .= $this->DocLister->parseChunk('@CODE:<strong>[+title+]</strong>: [+msg+]<br />',
208 208
                                 compact('msg', 'title'));
209
-                        } else {
209
+                        } else {
210 210
                             $message .= $msg;
211 211
                         }
212 212
                         $i++;
213 213
                     }
214 214
                     $item['msg'] = $message;
215
-                } else {
215
+                } else {
216 216
                     $item['msg'] = '';
217 217
                 }
218 218
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
                     </li>';
223 223
                 $out .= $this->DocLister->parseChunk("@CODE: " . $tpl, $item);
224 224
             }
225
-            if (!empty($out)) {
225
+            if (!empty($out)) {
226 226
                 $out = $this->DocLister->parseChunk("@CODE:
227 227
                 <style>.dlDebug{
228 228
                     background: #eee !important;
@@ -276,10 +276,10 @@  discard block
 block discarded – undo
276 276
      * @param string $charset
277 277
      * @return string
278 278
      */
279
-    public function dumpData($data, $wrap = '', $charset = 'UTF-8')
280
-    {
279
+    public function dumpData($data, $wrap = '', $charset = 'UTF-8')
280
+    {
281 281
         $out = $this->DocLister->sanitarData(print_r($data, 1), $charset);
282
-        if (!empty($wrap) && is_string($wrap)) {
282
+        if (!empty($wrap) && is_string($wrap)) {
283 283
             $out = "<{$wrap}>{$out}</{$wrap}>";
284 284
         }
285 285
 
Please login to merge, or discard this patch.
assets/snippets/DocLister/lib/DLReflect.class.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!class_exists("DLReflect", false)) {
3
+if ( ! class_exists("DLReflect", false)) {
4 4
     /**
5 5
      * Class DLReflect
6 6
      */
Please login to merge, or discard this patch.
Braces   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!class_exists("DLReflect", false)) {
3
+if (!class_exists("DLReflect", false)) {
4 4
     /**
5 5
      * Class DLReflect
6 6
      */
7
-    class DLReflect
8
-    {
7
+    class DLReflect
8
+    {
9 9
         /**
10 10
          * @param $val
11 11
          * @return bool
12 12
          */
13
-        public static function validateMonth($val)
14
-        {
13
+        public static function validateMonth($val)
14
+        {
15 15
             $flag = false;
16
-            if (is_scalar($val)) {
16
+            if (is_scalar($val)) {
17 17
                 $val = explode("-", $val, 2);
18 18
                 $flag = (count($val) && is_array($val) && strlen($val[0]) == 2 && strlen($val[1]) == 4); //Валидация содержимого массива
19 19
                 $flag = ($flag && (int)$val[0] > 0 && (int)$val[0] <= 12); //Валидация месяца
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
          * @param $val
28 28
          * @return bool
29 29
          */
30
-        public static function validateYear($val)
31
-        {
30
+        public static function validateYear($val)
31
+        {
32 32
             $flag = false;
33
-            if (is_scalar($val)) {
33
+            if (is_scalar($val)) {
34 34
                 $flag = (strlen($val) == 4); //Валидация строки
35 35
                 $flag = ($flag && (int)$val > 1900 && (int)$val <= 2100); //Валидация года
36 36
             }
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
          * @param $yearAction
45 45
          * @return mixed|null
46 46
          */
47
-        public static function switchReflect($type, $monthAction, $yearAction)
48
-        {
47
+        public static function switchReflect($type, $monthAction, $yearAction)
48
+        {
49 49
             $out = null;
50 50
             $action = $type . "Action";
51 51
 
Please login to merge, or discard this patch.