Completed
Push — master ( 3e6b83...d01548 )
by
unknown
04:25 queued 02:07
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   +106 added lines, -108 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,30 +161,30 @@  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
             }
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
      * @param array $array
201 201
      * @return string
202 202
      */
203
-    public function getJSON($data, $fields, $array = array())
204
-    {
203
+    public function getJSON($data, $fields, $array = array())
204
+    {
205 205
         $out = array();
206 206
         $fields = is_array($fields) ? $fields : explode(",", $fields);
207 207
         $date = $this->getCFGDef('dateSource', 'pub_date');
@@ -221,44 +221,44 @@  discard block
 block discarded – undo
221 221
          */
222 222
         $extE = $this->getExtender('e', true, true);
223 223
 
224
-        foreach ($data as $num => $item) {
224
+        foreach ($data as $num => $item) {
225 225
             $row = $item;
226
-            if ((array('1') == $fields || in_array('summary', $fields)) && $extSummary) {
226
+            if ((array('1') == $fields || in_array('summary', $fields)) && $extSummary) {
227 227
                 $row['summary'] = $this->getSummary($this->_docs[$num], $extSummary, 'introtext', 'content');
228 228
             }
229
-            if (array('1') == $fields || in_array('date', $fields)) {
230
-                if (isset($this->_docs[$num][$date])) {
229
+            if (array('1') == $fields || in_array('date', $fields)) {
230
+                if (isset($this->_docs[$num][$date])) {
231 231
                     $_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]);
232
-                    if ($_date !== false) {
232
+                    if ($_date !== false) {
233 233
                         $_date = $_date + $this->modx->config['server_offset_time'];
234
-                        if ($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') {
234
+                        if ($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') {
235 235
                             $row['date'] = strftime($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'), $_date);
236 236
                         }
237 237
                     }
238 238
                 }
239 239
             }
240
-            if (array('1') == $fields || in_array(array('menutitle', 'pagetitle'), $fields)) {
240
+            if (array('1') == $fields || in_array(array('menutitle', 'pagetitle'), $fields)) {
241 241
                 $row['title'] = ($row['menutitle'] == '' ? $row['pagetitle'] : $row['menutitle']);
242 242
             }
243 243
             if ((bool)$this->getCFGDef('makeUrl', 1) && (array('1') == $fields || in_array(array('content', 'type'),
244 244
                         $fields))
245
-            ) {
246
-                if ($row['type'] == 'reference') {
245
+            ) {
246
+                if ($row['type'] == 'reference') {
247 247
                     $row['url'] = is_numeric($row['content']) ? $this->modx->makeUrl($row['content'], '', '',
248 248
                         $this->getCFGDef('urlScheme', '')) : $row['content'];
249
-                } else {
249
+                } else {
250 250
                     $row['url'] = $this->modx->makeUrl($row['id'], '', '', $this->getCFGDef('urlScheme', ''));
251 251
                 }
252 252
             }
253
-            if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
254
-                if (is_array($tmp)) {
253
+            if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
254
+                if (is_array($tmp)) {
255 255
                     $row = $tmp;
256 256
                 }
257 257
             }
258 258
 
259
-            if ($extPrepare) {
259
+            if ($extPrepare) {
260 260
                 $row = $extPrepare->init($this, array('data' => $row));
261
-                if (is_bool($row) && $row === false) {
261
+                if (is_bool($row) && $row === false) {
262 262
                     continue;
263 263
                 }
264 264
             }
@@ -271,36 +271,35 @@  discard block
 block discarded – undo
271 271
     /**
272 272
      * @abstract
273 273
      */
274
-    public function getChildrenCount()
275
-    {
274
+    public function getChildrenCount()
275
+    {
276 276
         $out = 0;
277 277
         $sanitarInIDs = $this->sanitarIn($this->IDs);
278
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
278
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
279 279
             $q_true = $this->getCFGDef('ignoreEmpty', '0');
280 280
             $q_true = $q_true ? $q_true : $this->getCFGDef('idType', 'parents') == 'parents';
281 281
             $where = $this->getCFGDef('addWhereList', '');
282 282
             $where = sqlHelper::trimLogicalOp($where);
283 283
             $where = ($where ? $where . ' AND ' : '') . $this->_filters['where'];
284
-            if ($where != '' && $this->_filters['where'] != '') {
284
+            if ($where != '' && $this->_filters['where'] != '') {
285 285
                 $where .= " AND ";
286 286
             }
287 287
             $where = sqlHelper::trimLogicalOp($where);
288 288
 
289 289
             $where = "WHERE {$where}";
290 290
             $whereArr = array();
291
-            if (!$this->getCFGDef('showNoPublish', 0)) {
291
+            if (!$this->getCFGDef('showNoPublish', 0)) {
292 292
                 $whereArr[] = "c.deleted=0 AND c.published=1";
293
-            }
294
-            else{
293
+            } else {
295 294
                 $q_true = 1;
296 295
             }
297 296
 
298 297
             $tbl_site_content = $this->getTable('site_content', 'c');
299 298
 
300
-            if ($sanitarInIDs != "''") {
301
-                switch ($this->getCFGDef('idType', 'parents')) {
299
+            if ($sanitarInIDs != "''") {
300
+                switch ($this->getCFGDef('idType', 'parents')) {
302 301
                     case 'parents':
303
-                        switch ($this->getCFGDef('showParent', '0')) {
302
+                        switch ($this->getCFGDef('showParent', '0')) {
304 303
                             case '-1':
305 304
                                 $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")";
306 305
                                 break;
@@ -312,10 +311,10 @@  discard block
 block discarded – undo
312 311
                                 $tmpWhere = "(c.parent IN ({$sanitarInIDs}) OR c.id IN({$sanitarInIDs}))";
313 312
                                 break;
314 313
                         }
315
-                        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
314
+                        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
316 315
                             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
317 316
                             $whereArr[] = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
318
-                        } else {
317
+                        } else {
319 318
                             $whereArr[] = $tmpWhere;
320 319
                         }
321 320
 
@@ -330,14 +329,14 @@  discard block
 block discarded – undo
330 329
 
331 330
             $q_true = $q_true ? $q_true : trim($where) != 'WHERE';
332 331
 
333
-            if (trim($where) != 'WHERE') {
332
+            if (trim($where) != 'WHERE') {
334 333
                 $where .= " AND ";
335 334
             }
336 335
 
337 336
             $where .= implode(" AND ", $whereArr);
338 337
             $where = sqlHelper::trimLogicalOp($where);
339 338
 
340
-            if (trim($where) == 'WHERE') {
339
+            if (trim($where) == 'WHERE') {
341 340
                 $where = '';
342 341
             }
343 342
             $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id'));
@@ -346,11 +345,10 @@  discard block
 block discarded – undo
346 345
 
347 346
             $q_true = $q_true ? $q_true : $group != 'GROUP BY c.id';
348 347
 
349
-            if ( $q_true ){
348
+            if ( $q_true ) {
350 349
                 $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group}) as `tmp`");
351 350
                 $out = $this->modx->db->getValue($rs);
352
-            }
353
-            else {
351
+            } else {
354 352
                 $out = count($this->IDs);
355 353
             }
356 354
         }
@@ -361,11 +359,11 @@  discard block
 block discarded – undo
361 359
     /**
362 360
      * @return array
363 361
      */
364
-    protected function getDocList()
365
-    {
362
+    protected function getDocList()
363
+    {
366 364
         $out = array();
367 365
         $sanitarInIDs = $this->sanitarIn($this->IDs);
368
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
366
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
369 367
             $where = $this->getCFGDef('addWhereList', '');
370 368
             $where = sqlHelper::trimLogicalOp($where);
371 369
 
@@ -373,21 +371,21 @@  discard block
 block discarded – undo
373 371
             $where = sqlHelper::trimLogicalOp($where);
374 372
 
375 373
             $tbl_site_content = $this->getTable('site_content', 'c');
376
-            if ($sanitarInIDs != "''") {
374
+            if ($sanitarInIDs != "''") {
377 375
                 $where .= ($where ? " AND " : "") . "c.id IN ({$sanitarInIDs}) AND";
378 376
             }
379 377
             $where = sqlHelper::trimLogicalOp($where);
380 378
 
381
-            if ($this->getCFGDef('showNoPublish', 0)) {
382
-                if ($where != '') {
379
+            if ($this->getCFGDef('showNoPublish', 0)) {
380
+                if ($where != '') {
383 381
                     $where = "WHERE {$where}";
384
-                } else {
382
+                } else {
385 383
                     $where = '';
386 384
                 }
387
-            } else {
388
-                if ($where != '') {
385
+            } else {
386
+                if ($where != '') {
389 387
                     $where = "WHERE {$where} AND ";
390
-                } else {
388
+                } else {
391 389
                     $where = "WHERE {$where} ";
392 390
                 }
393 391
                 $where .= "c.deleted=0 AND c.published=1";
@@ -406,7 +404,7 @@  discard block
 block discarded – undo
406 404
 
407 405
             $rows = $this->modx->db->makeArray($rs);
408 406
 
409
-            foreach ($rows as $item) {
407
+            foreach ($rows as $item) {
410 408
                 $out[$item['id']] = $item;
411 409
             }
412 410
         }
@@ -418,19 +416,19 @@  discard block
 block discarded – undo
418 416
      * @param string $id
419 417
      * @return array
420 418
      */
421
-    public function getChildrenFolder($id)
422
-    {
419
+    public function getChildrenFolder($id)
420
+    {
423 421
         $where = $this->getCFGDef('addWhereFolder', '');
424 422
         $where = sqlHelper::trimLogicalOp($where);
425
-        if ($where != '') {
423
+        if ($where != '') {
426 424
             $where .= " AND ";
427 425
         }
428 426
 
429 427
         $tbl_site_content = $this->getTable('site_content', 'c');
430 428
         $sanitarInIDs = $this->sanitarIn($id);
431
-        if ($this->getCFGDef('showNoPublish', 0)) {
429
+        if ($this->getCFGDef('showNoPublish', 0)) {
432 430
             $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1";
433
-        } else {
431
+        } else {
434 432
             $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1";
435 433
         }
436 434
 
@@ -438,7 +436,7 @@  discard block
 block discarded – undo
438 436
 
439 437
         $rows = $this->modx->db->makeArray($rs);
440 438
         $out = array();
441
-        foreach ($rows as $item) {
439
+        foreach ($rows as $item) {
442 440
             $out[] = $item['id'];
443 441
         }
444 442
 
@@ -450,10 +448,10 @@  discard block
 block discarded – undo
450 448
      * @param $sort
451 449
      * @return array
452 450
      */
453
-    protected function injectSortByTV($table, $sort)
454
-    {
451
+    protected function injectSortByTV($table, $sort)
452
+    {
455 453
         $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort);
456
-        if (!is_array($out) || empty($out)) {
454
+        if (!is_array($out) || empty($out)) {
457 455
             $out = array($table, $sort);
458 456
         }
459 457
 
@@ -463,19 +461,19 @@  discard block
 block discarded – undo
463 461
     /**
464 462
      * @return array
465 463
      */
466
-    protected function getChildrenList()
467
-    {
464
+    protected function getChildrenList()
465
+    {
468 466
         $where = array();
469 467
         $out = array();
470 468
 
471 469
         $tmpWhere = $this->getCFGDef('addWhereList', '');
472 470
         $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);
473
-        if (!empty($tmpWhere)) {
471
+        if (!empty($tmpWhere)) {
474 472
             $where[] = $tmpWhere;
475 473
         }
476 474
 
477 475
         $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']);
478
-        if (!empty($tmpWhere)) {
476
+        if (!empty($tmpWhere)) {
479 477
             $where[] = $tmpWhere;
480 478
         }
481 479
 
@@ -486,8 +484,8 @@  discard block
 block discarded – undo
486 484
         $sanitarInIDs = $this->sanitarIn($this->IDs);
487 485
 
488 486
         $tmpWhere = null;
489
-        if ($sanitarInIDs != "''") {
490
-            switch ($this->getCFGDef('showParent', '0')) {
487
+        if ($sanitarInIDs != "''") {
488
+            switch ($this->getCFGDef('showParent', '0')) {
491 489
                 case '-1':
492 490
                     $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")";
493 491
                     break;
@@ -500,29 +498,29 @@  discard block
 block discarded – undo
500 498
                     break;
501 499
             }
502 500
         }
503
-        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
501
+        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
504 502
             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
505
-            if (empty($tmpWhere)) {
503
+            if (empty($tmpWhere)) {
506 504
                 $tmpWhere = "c.id IN({$addDocs})";
507
-            } else {
505
+            } else {
508 506
                 $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
509 507
             }
510 508
         }
511
-        if (!empty($tmpWhere)) {
509
+        if (!empty($tmpWhere)) {
512 510
             $where[] = $tmpWhere;
513 511
         }
514
-        if (!$this->getCFGDef('showNoPublish', 0)) {
512
+        if (!$this->getCFGDef('showNoPublish', 0)) {
515 513
             $where[] = "c.deleted=0 AND c.published=1";
516 514
         }
517
-        if (!empty($where)) {
515
+        if (!empty($where)) {
518 516
             $where = "WHERE " . implode(" AND ", $where);
519
-        } else {
517
+        } else {
520 518
             $where = '';
521 519
         }
522 520
         $fields = $this->getCFGDef('selectFields', 'c.*');
523 521
         $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id'));
524 522
 
525
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
523
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
526 524
             $sql = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " .
527 525
                 $group . " " .
528 526
                 $sort . " " .
@@ -531,7 +529,7 @@  discard block
 block discarded – undo
531 529
 
532 530
             $rows = $this->modx->db->makeArray($sql);
533 531
 
534
-            foreach ($rows as $item) {
532
+            foreach ($rows as $item) {
535 533
                 $out[$item['id']] = $item;
536 534
             }
537 535
         }
@@ -544,10 +542,10 @@  discard block
 block discarded – undo
544 542
      * @param string $type
545 543
      * @return string
546 544
      */
547
-    public function changeSortType($field, $type)
548
-    {
545
+    public function changeSortType($field, $type)
546
+    {
549 547
         $type = trim($type);
550
-        switch (strtoupper($type)) {
548
+        switch (strtoupper($type)) {
551 549
             case 'TVDATETIME':
552 550
                 $field = "STR_TO_DATE(" . $field . ",'%d-%m-%Y %H:%i:%s')";
553 551
                 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   +287 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,7 +231,7 @@  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;
@@ -247,12 +247,12 @@  discard block
 block discarded – undo
247 247
 
248 248
         $this->setLocate();
249 249
 
250
-        if ($this->getCFGDef("customLang")) {
250
+        if ($this->getCFGDef("customLang")) {
251 251
             $this->getCustomLang();
252 252
         }
253 253
         $this->loadExtender($this->getCFGDef("extender", ""));
254 254
 
255
-        if ($this->checkExtender('request')) {
255
+        if ($this->checkExtender('request')) {
256 256
             $this->extender['request']->init($this, $this->getCFGDef("requestActive", ""));
257 257
         }
258 258
         $this->_filters = $this->getFilters($this->getCFGDef('filters', ''));
@@ -264,21 +264,21 @@  discard block
 block discarded – undo
264 264
      * @param string $str строка с фильтром
265 265
      * @return array массив субфильтров
266 266
      */
267
-    public function smartSplit($str)
268
-    {
267
+    public function smartSplit($str)
268
+    {
269 269
         $res = array();
270 270
         $cur = '';
271 271
         $open = 0;
272 272
         $strlen = mb_strlen($str, 'UTF-8');
273
-        for ($i = 0; $i <= $strlen; $i++) {
273
+        for ($i = 0; $i <= $strlen; $i++) {
274 274
             $e = mb_substr($str, $i, 1, 'UTF-8');
275
-            switch ($e) {
275
+            switch ($e) {
276 276
                 case ')':
277 277
                     $open--;
278
-                    if ($open == 0) {
278
+                    if ($open == 0) {
279 279
                         $res[] = $cur . ')';
280 280
                         $cur = '';
281
-                    } else {
281
+                    } else {
282 282
                         $cur .= $e;
283 283
                     }
284 284
                     break;
@@ -287,10 +287,10 @@  discard block
 block discarded – undo
287 287
                     $cur .= $e;
288 288
                     break;
289 289
                 case ';':
290
-                    if ($open == 0) {
290
+                    if ($open == 0) {
291 291
                         $res[] = $cur;
292 292
                         $cur = '';
293
-                    } else {
293
+                    } else {
294 294
                         $cur .= $e;
295 295
                     }
296 296
                     break;
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
             }
300 300
         }
301 301
         $cur = preg_replace("/(\))$/u", '', $cur);
302
-        if ($cur != '') {
302
+        if ($cur != '') {
303 303
             $res[] = $cur;
304 304
         }
305 305
 
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
      * Трансформация объекта в строку
311 311
      * @return string последний ответ от DocLister'а
312 312
      */
313
-    public function __toString()
314
-    {
313
+    public function __toString()
314
+    {
315 315
         return $this->outData;
316 316
     }
317 317
 
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
      * Установить время запуска сниппета
320 320
      * @param float|null $time
321 321
      */
322
-    public function setTimeStart($time = null)
323
-    {
322
+    public function setTimeStart($time = null)
323
+    {
324 324
         $this->_timeStart = is_null($time) ? microtime(true) : $time;
325 325
     }
326 326
 
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
      *
330 330
      * @return int
331 331
      */
332
-    public function getTimeStart()
333
-    {
332
+    public function getTimeStart()
333
+    {
334 334
         return $this->_timeStart;
335 335
     }
336 336
 
@@ -338,27 +338,27 @@  discard block
 block discarded – undo
338 338
      * Установка режима отладки
339 339
      * @param int $flag режим отладки
340 340
      */
341
-    public function setDebug($flag = 0)
342
-    {
341
+    public function setDebug($flag = 0)
342
+    {
343 343
         $flag = abs((int)$flag);
344
-        if ($this->_debugMode != $flag) {
344
+        if ($this->_debugMode != $flag) {
345 345
             $this->_debugMode = $flag;
346 346
             $this->debug = null;
347
-            if ($this->_debugMode > 0) {
348
-                if (isset($_SESSION['usertype']) && $_SESSION['usertype'] == 'manager') {
347
+            if ($this->_debugMode > 0) {
348
+                if (isset($_SESSION['usertype']) && $_SESSION['usertype'] == 'manager') {
349 349
                     error_reporting(E_ALL ^ E_NOTICE);
350 350
                     ini_set('display_errors', 1);
351 351
                 }
352 352
                 $dir = dirname(dirname(__FILE__));
353
-                if (file_exists($dir . "/lib/DLdebug.class.php")) {
353
+                if (file_exists($dir . "/lib/DLdebug.class.php")) {
354 354
                     include_once($dir . "/lib/DLdebug.class.php");
355
-                    if (class_exists("DLdebug", false)) {
355
+                    if (class_exists("DLdebug", false)) {
356 356
                         $this->debug = new DLdebug($this);
357 357
                     }
358 358
                 }
359 359
             }
360 360
 
361
-            if (is_null($this->debug)) {
361
+            if (is_null($this->debug)) {
362 362
                 $this->debug = new xNop();
363 363
                 $this->_debugMode = 0;
364 364
                 error_reporting(0);
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
     /**
371 371
      * Информация о режиме отладки
372 372
      */
373
-    public function getDebug()
374
-    {
373
+    public function getDebug()
374
+    {
375 375
         return $this->_debugMode;
376 376
     }
377 377
 
@@ -382,13 +382,13 @@  discard block
 block discarded – undo
382 382
      * @param string $alias желаемый алиас таблицы
383 383
      * @return string имя таблицы с префиксом и алиасом
384 384
      */
385
-    public function getTable($name, $alias = '')
386
-    {
387
-        if (!isset($this->_table[$name])) {
385
+    public function getTable($name, $alias = '')
386
+    {
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
 
@@ -401,9 +401,9 @@  discard block
 block discarded – undo
401 401
      * @param $alias
402 402
      * @return mixed
403 403
      */
404
-    public function TableAlias($name, $table, $alias)
405
-    {
406
-        if (!$this->checkTableAlias($name, $table)) {
404
+    public function TableAlias($name, $table, $alias)
405
+    {
406
+        if (!$this->checkTableAlias($name, $table)) {
407 407
             $this->AddTable[$table][$name] = $alias;
408 408
         }
409 409
 
@@ -415,8 +415,8 @@  discard block
 block discarded – undo
415 415
      * @param $table
416 416
      * @return bool
417 417
      */
418
-    public function checkTableAlias($name, $table)
419
-    {
418
+    public function checkTableAlias($name, $table)
419
+    {
420 420
         return isset($this->AddTable[$table][$name]);
421 421
     }
422 422
 
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
      * @param bool $nop создавать ли пустой объект запрашиваемого типа
429 429
      * @return array|mixed|xNop
430 430
      */
431
-    public function jsonDecode($json, $config = array(), $nop = false)
432
-    {
431
+    public function jsonDecode($json, $config = array(), $nop = false)
432
+    {
433 433
         $this->debug->debug('Decode JSON: ' . $this->debug->dumpData($json) . "\r\nwith config: " . $this->debug->dumpData($config),
434 434
             'jsonDecode', 2);
435 435
         $config = jsonHelper::jsonDecode($json, $config, $nop);
@@ -445,10 +445,10 @@  discard block
 block discarded – undo
445 445
      * @param $json string строка с JSON для записи в лог при отладке
446 446
      * @return bool|string
447 447
      */
448
-    public function isErrorJSON($json)
449
-    {
448
+    public function isErrorJSON($json)
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
         }
@@ -460,20 +460,20 @@  discard block
 block discarded – undo
460 460
      * Проверка параметров и загрузка необходимых экстендеров
461 461
      * return boolean статус загрузки
462 462
      */
463
-    public function checkDL()
464
-    {
463
+    public function checkDL()
464
+    {
465 465
         $this->debug->debug('Check DocLister parameters', 'checkDL', 2);
466 466
         $flag = true;
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
         }
@@ -486,15 +486,15 @@  discard block
 block discarded – undo
486 486
                 $this->getCFGDef('pageLimit', '') != '' || $this->getCFGDef('pageAdjacents', '') != '' ||
487 487
                 $this->getCFGDef('PaginateClass', '') != '' || $this->getCFGDef('TplNextP', '') != ''
488 488
             ) && !$this->_loadExtender('paginate')
489
-        ) {
489
+        ) {
490 490
             throw new Exception('Error load paginate extender');
491
-        } else {
492
-            if ((int)$this->getCFGDef('display', 0) == 0) {
491
+        } else {
492
+            if ((int)$this->getCFGDef('display', 0) == 0) {
493 493
                 $extenders = $this->unsetArrayVal($extenders, 'paginate');
494 494
             }
495 495
         }
496 496
 
497
-        if ($this->getCFGDef('prepare', '') != '' || $this->getCFGDef('prepareWrap') != '') {
497
+        if ($this->getCFGDef('prepare', '') != '' || $this->getCFGDef('prepareWrap') != '') {
498 498
             $this->_loadExtender('prepare');
499 499
         }
500 500
 
@@ -511,14 +511,14 @@  discard block
 block discarded – undo
511 511
      * @param mixed $val значение которые необходимо удалить из массива
512 512
      * @return array отчищеный массив с данными
513 513
      */
514
-    private function unsetArrayVal($data, $val)
515
-    {
514
+    private function unsetArrayVal($data, $val)
515
+    {
516 516
         $out = array();
517
-        if (is_array($data)) {
518
-            foreach ($data as $item) {
519
-                if ($item != $val) {
517
+        if (is_array($data)) {
518
+            foreach ($data as $item) {
519
+                if ($item != $val) {
520 520
                     $out[] = $item;
521
-                } else {
521
+                } else {
522 522
                     continue;
523 523
                 }
524 524
             }
@@ -533,14 +533,14 @@  discard block
 block discarded – undo
533 533
      * @param int $id уникальный идентификатор страницы
534 534
      * @return string URL страницы
535 535
      */
536
-    public function getUrl($id = 0)
537
-    {
536
+    public function getUrl($id = 0)
537
+    {
538 538
         $id = ((int)$id > 0) ? (int)$id : $this->getCurrentMODXPageID();
539 539
 
540 540
         $link = $this->checkExtender('request') ? $this->extender['request']->getLink() : $this->getRequest();
541
-        if ($id == $this->modx->config['site_start']) {
541
+        if ($id == $this->modx->config['site_start']) {
542 542
             $url = $this->modx->config['site_url'] . ($link != '' ? "?{$link}" : "");
543
-        } else {
543
+        } else {
544 544
             $url = $this->modx->makeUrl($id, '', $link, $this->getCFGDef('urlScheme', ''));
545 545
         }
546 546
 
@@ -568,20 +568,22 @@  discard block
 block discarded – undo
568 568
      * @param string $tpl шаблон
569 569
      * @return string
570 570
      */
571
-    public function render($tpl = '')
572
-    {
571
+    public function render($tpl = '')
572
+    {
573 573
         $this->debug->debug(array('Render data with template ' => $tpl), 'render', 2, array('html'));
574 574
         $out = '';
575
-        if (1 == $this->getCFGDef('tree', '0')) {
576
-            foreach ($this->_tree as $item) {
575
+        if (1 == $this->getCFGDef('tree', '0')) {
576
+            foreach ($this->_tree as $item) {
577 577
                 $out .= $this->renderTree($item);
578 578
             }
579 579
             $out = $this->renderWrap($out);
580
-        } else {
580
+        } else {
581 581
             $out = $this->_render($tpl);
582 582
         }
583 583
 
584
-        if ($out) $this->outData = DLTemplate::getInstance($this->modx)->parseDocumentSource($out);
584
+        if ($out) {
585
+            $this->outData = DLTemplate::getInstance($this->modx)->parseDocumentSource($out);
586
+        }
585 587
         $this->debug->debugEnd('render');
586 588
 
587 589
         return $this->outData;
@@ -596,8 +598,8 @@  discard block
 block discarded – undo
596 598
      *
597 599
      * @return int
598 600
      */
599
-    public function getCurrentMODXPageID()
600
-    {
601
+    public function getCurrentMODXPageID()
602
+    {
601 603
         $id = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0;
602 604
         $docData = isset($this->modx->documentObject) ? $this->modx->documentObject : array();
603 605
 
@@ -613,9 +615,9 @@  discard block
 block discarded – undo
613 615
      * @param integer $line error on line
614 616
      * @param array $trace stack trace
615 617
      */
616
-    public function ErrorLogger($message, $code, $file, $line, $trace)
617
-    {
618
-        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') {
619 621
             $out = "CODE #" . $code . "<br />";
620 622
             $out .= "on file: " . $file . ":" . $line . "<br />";
621 623
             $out .= "<pre>";
@@ -632,8 +634,8 @@  discard block
 block discarded – undo
632 634
      *
633 635
      * @return DocumentParser
634 636
      */
635
-    public function getMODX()
636
-    {
637
+    public function getMODX()
638
+    {
637 639
         return $this->modx;
638 640
     }
639 641
 
@@ -644,13 +646,13 @@  discard block
 block discarded – undo
644 646
      * @return boolean status load extenders
645 647
      * @throws Exception
646 648
      */
647
-    public function loadExtender($ext = '')
648
-    {
649
+    public function loadExtender($ext = '')
650
+    {
649 651
         $out = true;
650
-        if ($ext != '') {
652
+        if ($ext != '') {
651 653
             $ext = explode(",", $ext);
652
-            foreach ($ext as $item) {
653
-                if ($item != '' && !$this->_loadExtender($item)) {
654
+            foreach ($ext as $item) {
655
+                if ($item != '' && !$this->_loadExtender($item)) {
654 656
                     throw new Exception('Error load ' . APIHelpers::e($item) . ' extender');
655 657
                 }
656 658
             }
@@ -666,8 +668,8 @@  discard block
 block discarded – undo
666 668
      * @param mixed $def значение по умолчанию, если в конфиге нет искомого параметра
667 669
      * @return mixed значение из конфига
668 670
      */
669
-    public function getCFGDef($name, $def = null)
670
-    {
671
+    public function getCFGDef($name, $def = null)
672
+    {
671 673
         return $this->config->getCFGDef($name, $def);
672 674
     }
673 675
 
@@ -679,15 +681,15 @@  discard block
 block discarded – undo
679 681
      * @param string $key ключ локального плейсхолдера
680 682
      * @return string
681 683
      */
682
-    public function toPlaceholders($data, $set = 0, $key = 'contentPlaceholder')
683
-    {
684
+    public function toPlaceholders($data, $set = 0, $key = 'contentPlaceholder')
685
+    {
684 686
         $this->debug->debug(null, 'toPlaceholders', 2);
685
-        if ($set == 0) {
687
+        if ($set == 0) {
686 688
             $set = $this->getCFGDef('contentPlaceholder', 0);
687 689
         }
688 690
         $this->_plh[$key] = $data;
689 691
         $id = $this->getCFGDef('id', '');
690
-        if ($id != '') {
692
+        if ($id != '') {
691 693
             $id .= ".";
692 694
         }
693 695
         $out = DLTemplate::getInstance($this->getMODX())->toPlaceholders($data, $set, $key, $id);
@@ -709,14 +711,14 @@  discard block
 block discarded – undo
709 711
      * @param boolean $quote заключать ли данные на выходе в кавычки
710 712
      * @return string обработанная строка
711 713
      */
712
-    public function sanitarIn($data, $sep = ',', $quote = true)
713
-    {
714
-        if (!is_array($data)) {
714
+    public function sanitarIn($data, $sep = ',', $quote = true)
715
+    {
716
+        if (!is_array($data)) {
715 717
             $data = explode($sep, $data);
716 718
         }
717 719
         $out = array();
718
-        foreach ($data as $item) {
719
-            if ($item !== '') {
720
+        foreach ($data as $item) {
721
+            if ($item !== '') {
720 722
                 $out[] = $this->modx->db->escape($item);
721 723
             }
722 724
         }
@@ -737,12 +739,12 @@  discard block
 block discarded – undo
737 739
      * @param string $lang имя языкового пакета
738 740
      * @return array
739 741
      */
740
-    public function getCustomLang($lang = '')
741
-    {
742
-        if (empty($lang)) {
742
+    public function getCustomLang($lang = '')
743
+    {
744
+        if (empty($lang)) {
743 745
             $lang = $this->getCFGDef('lang', $this->modx->config['manager_language']);
744 746
         }
745
-        if (file_exists(dirname(dirname(__FILE__)) . "/lang/" . $lang . ".php")) {
747
+        if (file_exists(dirname(dirname(__FILE__)) . "/lang/" . $lang . ".php")) {
746 748
             $tmp = include(dirname(__FILE__) . "/lang/" . $lang . ".php");
747 749
             $this->_customLang = is_array($tmp) ? $tmp : array();
748 750
         }
@@ -758,25 +760,25 @@  discard block
 block discarded – undo
758 760
      * @param boolean $rename Переименовывать ли элементы массива
759 761
      * @return array массив с лексиконом
760 762
      */
761
-    public function loadLang($name = 'core', $lang = '', $rename = true)
762
-    {
763
-        if (empty($lang)) {
763
+    public function loadLang($name = 'core', $lang = '', $rename = true)
764
+    {
765
+        if (empty($lang)) {
764 766
             $lang = $this->getCFGDef('lang', $this->modx->config['manager_language']);
765 767
         }
766 768
 
767 769
         $this->debug->debug('Load language ' . $this->debug->dumpData($name) . "." . $this->debug->dumpData($lang),
768 770
             'loadlang', 2);
769
-        if (is_scalar($name)) {
771
+        if (is_scalar($name)) {
770 772
             $name = array($name);
771 773
         }
772
-        foreach ($name as $n) {
773
-            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")) {
774 776
                 $tmp = include(dirname(__FILE__) . "/lang/" . $lang . "/" . $n . ".inc.php");
775
-                if (is_array($tmp)) {
777
+                if (is_array($tmp)) {
776 778
                     /**
777 779
                      * Переименовыываем элементы массива из array('test'=>'data') в array('name.test'=>'data')
778 780
                      */
779
-                    if ($rename) {
781
+                    if ($rename) {
780 782
                         $tmp = $this->renameKeyArr($tmp, $n, '', '.');
781 783
                     }
782 784
                     $this->_lang = array_merge($this->_lang, $tmp);
@@ -795,11 +797,11 @@  discard block
 block discarded – undo
795 797
      * @param string $def Строка по умолчанию, если запись в языковом пакете не будет обнаружена
796 798
      * @return string строка в соответствии с текущими языковыми настройками
797 799
      */
798
-    public function getMsg($name, $def = '')
799
-    {
800
-        if (isset($this->_customLang[$name])) {
800
+    public function getMsg($name, $def = '')
801
+    {
802
+        if (isset($this->_customLang[$name])) {
801 803
             $say = $this->_customLang[$name];
802
-        } else {
804
+        } else {
803 805
             $say = \APIHelpers::getkey($this->_lang, $name, $def);
804 806
         }
805 807
 
@@ -815,8 +817,8 @@  discard block
 block discarded – undo
815 817
      * @param string $sep разделитель суффиксов, префиксов и ключей массива
816 818
      * @return array массив с переименованными ключами
817 819
      */
818
-    public function renameKeyArr($data, $prefix = '', $suffix = '', $sep = '.')
819
-    {
820
+    public function renameKeyArr($data, $prefix = '', $suffix = '', $sep = '.')
821
+    {
820 822
         return \APIHelpers::renameKeyArr($data, $prefix, $suffix, $sep);
821 823
     }
822 824
 
@@ -826,12 +828,12 @@  discard block
 block discarded – undo
826 828
      * @param string $locale локаль
827 829
      * @return string имя установленной локали
828 830
      */
829
-    public function setLocate($locale = '')
830
-    {
831
-        if ('' == $locale) {
831
+    public function setLocate($locale = '')
832
+    {
833
+        if ('' == $locale) {
832 834
             $locale = $this->getCFGDef('locale', '');
833 835
         }
834
-        if ('' != $locale) {
836
+        if ('' != $locale) {
835 837
             setlocale(LC_ALL, $locale);
836 838
         }
837 839
 
@@ -845,11 +847,11 @@  discard block
 block discarded – undo
845 847
      * @param array $data массив сформированный как дерево
846 848
      * @return string строка для отображения пользователю
847 849
      */
848
-    protected function renderTree($data)
849
-    {
850
+    protected function renderTree($data)
851
+    {
850 852
         $out = '';
851
-        if (!empty($data['#childNodes'])) {
852
-            foreach ($data['#childNodes'] as $item) {
853
+        if (!empty($data['#childNodes'])) {
854
+            foreach ($data['#childNodes'] as $item) {
853 855
                 $out .= $this->renderTree($item);
854 856
             }
855 857
         }
@@ -866,8 +868,8 @@  discard block
 block discarded – undo
866 868
      * @param string $name Template: chunk name || @CODE: template || @FILE: file with template
867 869
      * @return string html template with placeholders without data
868 870
      */
869
-    private function _getChunk($name)
870
-    {
871
+    private function _getChunk($name)
872
+    {
871 873
         $this->debug->debug(array('Get chunk by name' => $name), "getChunk", 2, array('html'));
872 874
         //without trim
873 875
         $tpl = DLTemplate::getInstance($this->getMODX())->getChunk($name);
@@ -884,18 +886,18 @@  discard block
 block discarded – undo
884 886
      * @param string $tpl HTML шаблон
885 887
      * @return string
886 888
      */
887
-    public function parseLang($tpl)
888
-    {
889
+    public function parseLang($tpl)
890
+    {
889 891
         $this->debug->debug(array("parseLang" => $tpl), "parseLang", 2, array('html'));
890
-        if (is_scalar($tpl) && !empty($tpl)) {
891
-            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)) {
892 894
                 $langVal = array();
893
-                foreach ($match[1] as $item) {
895
+                foreach ($match[1] as $item) {
894 896
                     $langVal[] = $this->getMsg($item);
895 897
                 }
896 898
                 $tpl = str_replace($match[0], $langVal, $tpl);
897 899
             }
898
-        } else {
900
+        } else {
899 901
             $tpl = '';
900 902
         }
901 903
         $this->debug->debugEnd("parseLang");
@@ -911,20 +913,24 @@  discard block
 block discarded – undo
911 913
      * @param bool $parseDocumentSource render html template via DocumentParser::parseDocumentSource()
912 914
      * @return string html template with data without placeholders
913 915
      */
914
-    public function parseChunk($name, $data, $parseDocumentSource = false)
915
-    {
916
+    public function parseChunk($name, $data, $parseDocumentSource = false)
917
+    {
916 918
         $this->debug->debug(
917 919
             array("parseChunk" => $name, "With data" => print_r($data, 1)),
918 920
             "parseChunk",
919 921
             2, array('html', null)
920 922
         );
921 923
         $DLTemplate = DLTemplate::getInstance($this->getMODX());
922
-        if ($path = $this->getCFGDef('templatePath')) $DLTemplate->setTemplatePath($path);
923
-        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
+        }
924 930
         $DLTemplate->setTwigTemplateVars(array('DocLister'=>$this));
925 931
         $out = $DLTemplate->parseChunk($name, $data, $parseDocumentSource);
926 932
         $out = $this->parseLang($out);
927
-        if (empty($out)) {
933
+        if (empty($out)) {
928 934
             $this->debug->debug("Empty chunk: " . $this->debug->dumpData($name), '', 2);
929 935
         }
930 936
         $this->debug->debugEnd("parseChunk");
@@ -940,8 +946,8 @@  discard block
 block discarded – undo
940 946
      *
941 947
      * @return string html template from parameter
942 948
      */
943
-    public function getChunkByParam($name, $val = '')
944
-    {
949
+    public function getChunkByParam($name, $val = '')
950
+    {
945 951
         $data = $this->getCFGDef($name, $val);
946 952
         $data = $this->_getChunk($data);
947 953
 
@@ -954,11 +960,11 @@  discard block
 block discarded – undo
954 960
      * @param string $data html код который нужно обернуть в ownerTPL
955 961
      * @return string результатирующий html код
956 962
      */
957
-    public function renderWrap($data)
958
-    {
963
+    public function renderWrap($data)
964
+    {
959 965
         $out = $data;
960 966
         $docs = count($this->_docs) - $this->skippedDocs;
961
-        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)) {
962 968
             $this->debug->debug("", "renderWrapTPL", 2);
963 969
             $parse = true;
964 970
             $plh = array($this->getCFGDef("sysKey", "dl") . ".wrap" => $data);
@@ -966,7 +972,7 @@  discard block
 block discarded – undo
966 972
              * @var $extPrepare prepare_DL_Extender
967 973
              */
968 974
             $extPrepare = $this->getExtender('prepare');
969
-            if ($extPrepare) {
975
+            if ($extPrepare) {
970 976
                 $params = $extPrepare->init($this, array(
971 977
                     'data'      => array(
972 978
                         'docs'         => $this->_docs,
@@ -975,13 +981,13 @@  discard block
 block discarded – undo
975 981
                     'nameParam' => 'prepareWrap',
976 982
                     'return'    => 'placeholders'
977 983
                 ));
978
-                if (is_bool($params) && $params === false) {
984
+                if (is_bool($params) && $params === false) {
979 985
                     $out = $data;
980 986
                     $parse = false;
981 987
                 }
982 988
                 $plh = $params;
983 989
             }
984
-            if ($parse && !empty($this->ownerTPL)) {
990
+            if ($parse && !empty($this->ownerTPL)) {
985 991
                 $this->debug->updateMessage(
986 992
                     array("render ownerTPL" => $this->ownerTPL, "With data" => print_r($plh, 1)),
987 993
                     "renderWrapTPL",
@@ -989,7 +995,7 @@  discard block
 block discarded – undo
989 995
                 );
990 996
                 $out = $this->parseChunk($this->ownerTPL, $plh);
991 997
             }
992
-            if (empty($this->ownerTPL)) {
998
+            if (empty($this->ownerTPL)) {
993 999
                 $this->debug->updateMessage("empty ownerTPL", "renderWrapTPL");
994 1000
             }
995 1001
             $this->debug->debugEnd("renderWrapTPL");
@@ -1005,8 +1011,8 @@  discard block
 block discarded – undo
1005 1011
      * @param int $i номер итерации в цикле
1006 1012
      * @return array массив с данными которые можно использовать в цикле render метода
1007 1013
      */
1008
-    protected function uniformPrepare(&$data, $i = 0)
1009
-    {
1014
+    protected function uniformPrepare(&$data, $i = 0)
1015
+    {
1010 1016
         $class = array();
1011 1017
 
1012 1018
         $iterationName = ($i % 2 == 1) ? 'Odd' : 'Even';
@@ -1020,20 +1026,20 @@  discard block
 block discarded – undo
1020 1026
             "dl") . '.full_iteration'] = ($this->extPaginate) ? ($i + $this->getCFGDef('display',
1021 1027
                 0) * ($this->extPaginate->currentPage() - 1)) : $i;
1022 1028
 
1023
-        if ($i == 1) {
1029
+        if ($i == 1) {
1024 1030
             $this->renderTPL = $this->getCFGDef('tplFirst', $this->renderTPL);
1025 1031
             $class[] = $this->getCFGDef('firstClass', 'first');
1026 1032
         }
1027
-        if ($i == (count($this->_docs) - $this->skippedDocs)) {
1033
+        if ($i == (count($this->_docs) - $this->skippedDocs)) {
1028 1034
             $this->renderTPL = $this->getCFGDef('tplLast', $this->renderTPL);
1029 1035
             $class[] = $this->getCFGDef('lastClass', 'last');
1030 1036
         }
1031
-        if ($this->modx->documentIdentifier == $data['id']) {
1037
+        if ($this->modx->documentIdentifier == $data['id']) {
1032 1038
             $this->renderTPL = $this->getCFGDef('tplCurrent', $this->renderTPL);
1033 1039
             $data[$this->getCFGDef("sysKey",
1034 1040
                 "dl") . '.active'] = 1; //[+active+] - 1 if $modx->documentIdentifer equal ID this element
1035 1041
             $class[] = $this->getCFGDef('currentClass', 'current');
1036
-        } else {
1042
+        } else {
1037 1043
             $data[$this->getCFGDef("sysKey", "dl") . '.active'] = 0;
1038 1044
         }
1039 1045
 
@@ -1044,8 +1050,8 @@  discard block
 block discarded – undo
1044 1050
          * @var $extE e_DL_Extender
1045 1051
          */
1046 1052
         $extE = $this->getExtender('e', true, true);
1047
-        if ($out = $extE->init($this, compact('data'))) {
1048
-            if (is_array($out)) {
1053
+        if ($out = $extE->init($this, compact('data'))) {
1054
+            if (is_array($out)) {
1049 1055
                 $data = $out;
1050 1056
             }
1051 1057
         }
@@ -1061,42 +1067,43 @@  discard block
 block discarded – undo
1061 1067
      * @param array $array данные которые необходимо примешать к ответу на каждой записи $data
1062 1068
      * @return string JSON строка
1063 1069
      */
1064
-    public function getJSON($data, $fields, $array = array())
1065
-    {
1070
+    public function getJSON($data, $fields, $array = array())
1071
+    {
1066 1072
         $out = array();
1067 1073
         $fields = is_array($fields) ? $fields : explode(",", $fields);
1068
-        if (is_array($array) && count($array) > 0) {
1074
+        if (is_array($array) && count($array) > 0) {
1069 1075
             $tmp = array();
1070
-            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
1071 1078
                 $tmp[$i] = (isset($array[$i]) ? array_merge($v, $array[$i]) : $v);
1072 1079
             }
1073 1080
             $data = $tmp;
1074 1081
         }
1075 1082
 
1076
-        foreach ($data as $num => $doc) {
1083
+        foreach ($data as $num => $doc) {
1077 1084
             $tmp = array();
1078
-            foreach ($doc as $name => $value) {
1079
-                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')) {
1080 1087
                     $tmp[str_replace(".", "_", $name)] = $value; //JSON element name without dot
1081 1088
                 }
1082 1089
             }
1083 1090
             $out[$num] = $tmp;
1084 1091
         }
1085 1092
 
1086
-        if ('new' == $this->getCFGDef('JSONformat', 'old')) {
1093
+        if ('new' == $this->getCFGDef('JSONformat', 'old')) {
1087 1094
             $return = array();
1088 1095
 
1089 1096
             $return['rows'] = array();
1090
-            foreach ($out as $key => $item) {
1097
+            foreach ($out as $key => $item) {
1091 1098
                 $return['rows'][] = APIHelpers::getkey($item, $key, $item);
1092 1099
             }
1093 1100
             $return['total'] = $this->getChildrenCount();
1094
-        }elseif ('simple' == $this->getCFGDef('JSONformat', 'old')) {
1101
+        } elseif ('simple' == $this->getCFGDef('JSONformat', 'old')) {
1095 1102
             $return = array();
1096
-            foreach ($out as $key => $item) {
1103
+            foreach ($out as $key => $item) {
1097 1104
                 $return[] = APIHelpers::getkey($item, $key, $item);
1098 1105
             }
1099
-        } else {
1106
+        } else {
1100 1107
             $return = $out;
1101 1108
         }
1102 1109
         $this->outData = json_encode($return);
@@ -1112,11 +1119,11 @@  discard block
 block discarded – undo
1112 1119
      * @param string $contentField
1113 1120
      * @return mixed|string
1114 1121
      */
1115
-    protected function getSummary(array $item = array(), $extSummary = null, $introField = '', $contentField = '')
1116
-    {
1122
+    protected function getSummary(array $item = array(), $extSummary = null, $introField = '', $contentField = '')
1123
+    {
1117 1124
         $out = '';
1118 1125
 
1119
-        if (is_null($extSummary)) {
1126
+        if (is_null($extSummary)) {
1120 1127
             /**
1121 1128
              * @var $extSummary summary_DL_Extender
1122 1129
              */
@@ -1125,10 +1132,10 @@  discard block
 block discarded – undo
1125 1132
         $introField = $this->getCFGDef("introField", $introField);
1126 1133
         $contentField = $this->getCFGDef("contentField", $contentField);
1127 1134
 
1128
-        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) {
1129 1136
             $out = $item[$introField];
1130
-        } else {
1131
-            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) {
1132 1139
                 $out = $extSummary->init($this, array(
1133 1140
                     "content"      => $item[$contentField],
1134 1141
                     "action"       => $this->getCFGDef("summary", ""),
@@ -1146,8 +1153,8 @@  discard block
 block discarded – undo
1146 1153
      * @param string $name extender name
1147 1154
      * @return boolean status extender load
1148 1155
      */
1149
-    public function checkExtender($name)
1150
-    {
1156
+    public function checkExtender($name)
1157
+    {
1151 1158
         return (isset($this->extender[$name]) && $this->extender[$name] instanceof $name . "_DL_Extender");
1152 1159
     }
1153 1160
 
@@ -1155,8 +1162,8 @@  discard block
 block discarded – undo
1155 1162
      * @param $name
1156 1163
      * @param $obj
1157 1164
      */
1158
-    public function setExtender($name, $obj)
1159
-    {
1165
+    public function setExtender($name, $obj)
1166
+    {
1160 1167
         $this->extender[$name] = $obj;
1161 1168
     }
1162 1169
 
@@ -1168,13 +1175,13 @@  discard block
 block discarded – undo
1168 1175
      * @param bool $nop если экстендер не загружен, то загружать ли xNop
1169 1176
      * @return null|xNop
1170 1177
      */
1171
-    public function getExtender($name, $autoload = false, $nop = false)
1172
-    {
1178
+    public function getExtender($name, $autoload = false, $nop = false)
1179
+    {
1173 1180
         $out = null;
1174
-        if ((is_scalar($name) && $this->checkExtender($name)) || ($autoload && $this->_loadExtender($name))) {
1181
+        if ((is_scalar($name) && $this->checkExtender($name)) || ($autoload && $this->_loadExtender($name))) {
1175 1182
             $out = $this->extender[$name];
1176 1183
         }
1177
-        if ($nop && is_null($out)) {
1184
+        if ($nop && is_null($out)) {
1178 1185
             $out = new xNop();
1179 1186
         }
1180 1187
 
@@ -1187,27 +1194,27 @@  discard block
 block discarded – undo
1187 1194
      * @param string $name name extender
1188 1195
      * @return boolean $flag status load extender
1189 1196
      */
1190
-    protected function _loadExtender($name)
1191
-    {
1197
+    protected function _loadExtender($name)
1198
+    {
1192 1199
         $this->debug->debug('Load Extender ' . $this->debug->dumpData($name), 'LoadExtender', 2);
1193 1200
         $flag = false;
1194 1201
 
1195 1202
         $classname = ($name != '') ? $name . "_DL_Extender" : "";
1196
-        if ($classname != '' && isset($this->extender[$name]) && $this->extender[$name] instanceof $classname) {
1203
+        if ($classname != '' && isset($this->extender[$name]) && $this->extender[$name] instanceof $classname) {
1197 1204
             $flag = true;
1198 1205
 
1199
-        } else {
1200
-            if (!class_exists($classname, false) && $classname != '') {
1201
-                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")) {
1202 1209
                     include_once(dirname(__FILE__) . "/extender/" . $name . ".extender.inc");
1203 1210
                 }
1204 1211
             }
1205
-            if (class_exists($classname, false) && $classname != '') {
1212
+            if (class_exists($classname, false) && $classname != '') {
1206 1213
                 $this->extender[$name] = new $classname($this, $name);
1207 1214
                 $flag = true;
1208 1215
             }
1209 1216
         }
1210
-        if (!$flag) {
1217
+        if (!$flag) {
1211 1218
             $this->debug->debug("Error load Extender " . $this->debug->dumpData($name));
1212 1219
         }
1213 1220
         $this->debug->debugEnd('LoadExtender');
@@ -1225,16 +1232,16 @@  discard block
 block discarded – undo
1225 1232
      * @param mixed $IDs список id документов по которым необходима выборка
1226 1233
      * @return array очищенный массив
1227 1234
      */
1228
-    public function setIDs($IDs)
1229
-    {
1235
+    public function setIDs($IDs)
1236
+    {
1230 1237
         $this->debug->debug('set ID list ' . $this->debug->dumpData($IDs), 'setIDs', 2);
1231 1238
         $IDs = $this->cleanIDs($IDs);
1232 1239
         $type = $this->getCFGDef('idType', 'parents');
1233 1240
         $depth = $this->getCFGDef('depth', '');
1234
-        if ($type == 'parents' && $depth > 0) {
1241
+        if ($type == 'parents' && $depth > 0) {
1235 1242
             $tmp = $IDs;
1236
-            do {
1237
-                if (count($tmp) > 0) {
1243
+            do {
1244
+                if (count($tmp) > 0) {
1238 1245
                     $tmp = $this->getChildrenFolder($tmp);
1239 1246
                     $IDs = array_merge($IDs, $tmp);
1240 1247
                 }
@@ -1248,8 +1255,8 @@  discard block
 block discarded – undo
1248 1255
     /**
1249 1256
      * @return int
1250 1257
      */
1251
-    public function getIDs()
1252
-    {
1258
+    public function getIDs()
1259
+    {
1253 1260
         return $this->IDs;
1254 1261
     }
1255 1262
 
@@ -1260,17 +1267,18 @@  discard block
 block discarded – undo
1260 1267
      * @param string $sep разделитель
1261 1268
      * @return array очищенный массив с данными
1262 1269
      */
1263
-    public function cleanIDs($IDs, $sep = ',')
1264
-    {
1270
+    public function cleanIDs($IDs, $sep = ',')
1271
+    {
1265 1272
         $this->debug->debug('clean IDs ' . $this->debug->dumpData($IDs) . ' with separator ' . $this->debug->dumpData($sep),
1266 1273
             'cleanIDs', 2);
1267 1274
         $out = array();
1268
-        if (!is_array($IDs)) {
1275
+        if (!is_array($IDs)) {
1269 1276
             $IDs = explode($sep, $IDs);
1270 1277
         }
1271
-        foreach ($IDs as $item) {
1278
+        foreach ($IDs as $item) {
1272 1279
             $item = trim($item);
1273
-            if (is_numeric($item) && (int)$item >= 0) { //Fix 0xfffffffff
1280
+            if (is_numeric($item) && (int)$item >= 0) {
1281
+//Fix 0xfffffffff
1274 1282
                 $out[] = (int)$item;
1275 1283
             }
1276 1284
         }
@@ -1284,8 +1292,8 @@  discard block
 block discarded – undo
1284 1292
      * Проверка массива с id-шниками документов для выборки
1285 1293
      * @return boolean пригодны ли данные для дальнейшего использования
1286 1294
      */
1287
-    protected function checkIDs()
1288
-    {
1295
+    protected function checkIDs()
1296
+    {
1289 1297
         return (is_array($this->IDs) && count($this->IDs) > 0) ? true : false;
1290 1298
     }
1291 1299
 
@@ -1297,11 +1305,11 @@  discard block
 block discarded – undo
1297 1305
      * @global array $_docs all documents
1298 1306
      * @return array all field values
1299 1307
      */
1300
-    public function getOneField($userField, $uniq = false)
1301
-    {
1308
+    public function getOneField($userField, $uniq = false)
1309
+    {
1302 1310
         $out = array();
1303
-        foreach ($this->_docs as $doc => $val) {
1304
-            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)) {
1305 1313
                 $out[$doc] = $val[$userField];
1306 1314
             }
1307 1315
         }
@@ -1312,8 +1320,8 @@  discard block
 block discarded – undo
1312 1320
     /**
1313 1321
      * @return DLCollection
1314 1322
      */
1315
-    public function docsCollection()
1316
-    {
1323
+    public function docsCollection()
1324
+    {
1317 1325
         return new DLCollection($this->modx, $this->_docs);
1318 1326
     }
1319 1327
 
@@ -1341,10 +1349,10 @@  discard block
 block discarded – undo
1341 1349
      * @param string $group
1342 1350
      * @return string
1343 1351
      */
1344
-    protected function getGroupSQL($group = '')
1345
-    {
1352
+    protected function getGroupSQL($group = '')
1353
+    {
1346 1354
         $out = '';
1347
-        if ($group != '') {
1355
+        if ($group != '') {
1348 1356
             $out = 'GROUP BY ' . $group;
1349 1357
         }
1350 1358
 
@@ -1363,12 +1371,12 @@  discard block
 block discarded – undo
1363 1371
      *
1364 1372
      * @return string Order by for SQL
1365 1373
      */
1366
-    protected function SortOrderSQL($sortName, $orderDef = 'DESC')
1367
-    {
1374
+    protected function SortOrderSQL($sortName, $orderDef = 'DESC')
1375
+    {
1368 1376
         $this->debug->debug('', 'sortORDER', 2);
1369 1377
 
1370 1378
         $sort = '';
1371
-        switch ($this->getCFGDef('sortType', '')) {
1379
+        switch ($this->getCFGDef('sortType', '')) {
1372 1380
             case 'none':
1373 1381
                 break;
1374 1382
             case 'doclist':
@@ -1379,10 +1387,10 @@  discard block
 block discarded – undo
1379 1387
                 break;
1380 1388
             default:
1381 1389
                 $out = array('orderBy' => '', 'order' => '', 'sortBy' => '');
1382
-                if (($tmp = $this->getCFGDef('orderBy', '')) != '') {
1390
+                if (($tmp = $this->getCFGDef('orderBy', '')) != '') {
1383 1391
                     $out['orderBy'] = $tmp;
1384
-                } else {
1385
-                    switch (true) {
1392
+                } else {
1393
+                    switch (true) {
1386 1394
                         case ('' != ($tmp = $this->getCFGDef('sortDir', ''))): //higher priority than order
1387 1395
                             $out['order'] = $tmp;
1388 1396
                         // no break
@@ -1390,7 +1398,7 @@  discard block
 block discarded – undo
1390 1398
                             $out['order'] = $tmp;
1391 1399
                         // no break
1392 1400
                     }
1393
-                    if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1401
+                    if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1394 1402
                         $out['order'] = $orderDef; //Default
1395 1403
                     }
1396 1404
 
@@ -1411,26 +1419,26 @@  discard block
 block discarded – undo
1411 1419
      *
1412 1420
      * @return string LIMIT вставка в SQL запрос
1413 1421
      */
1414
-    protected function LimitSQL($limit = 0, $offset = 0)
1415
-    {
1422
+    protected function LimitSQL($limit = 0, $offset = 0)
1423
+    {
1416 1424
         $this->debug->debug('', 'limitSQL', 2);
1417 1425
         $ret = '';
1418
-        if ($limit == 0) {
1426
+        if ($limit == 0) {
1419 1427
             $limit = $this->getCFGDef('display', 0);
1420 1428
         }
1421
-        if ($offset == 0) {
1429
+        if ($offset == 0) {
1422 1430
             $offset = $this->getCFGDef('offset', 0);
1423 1431
         }
1424 1432
         $offset += $this->getCFGDef('start', 0);
1425 1433
         $total = $this->getCFGDef('total', 0);
1426
-        if ($limit < ($total - $limit)) {
1434
+        if ($limit < ($total - $limit)) {
1427 1435
             $limit = $total - $offset;
1428 1436
         }
1429 1437
 
1430
-        if ($limit != 0) {
1438
+        if ($limit != 0) {
1431 1439
             $ret = "LIMIT " . (int)$offset . "," . (int)$limit;
1432
-        } else {
1433
-            if ($offset != 0) {
1440
+        } else {
1441
+            if ($offset != 0) {
1434 1442
                 /**
1435 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
1436 1444
                  * @see http://dev.mysql.com/doc/refman/5.0/en/select.html
@@ -1450,8 +1458,8 @@  discard block
 block discarded – undo
1450 1458
      * @param string $charset
1451 1459
      * @return string Clear string
1452 1460
      */
1453
-    public function sanitarData($data, $charset = 'UTF-8')
1454
-    {
1461
+    public function sanitarData($data, $charset = 'UTF-8')
1462
+    {
1455 1463
         return APIHelpers::sanitarTag($data, $charset);
1456 1464
     }
1457 1465
 
@@ -1462,8 +1470,8 @@  discard block
 block discarded – undo
1462 1470
      * @param string $parentField default name parent field
1463 1471
      * @return array
1464 1472
      */
1465
-    public function treeBuild($idField = 'id', $parentField = 'parent')
1466
-    {
1473
+    public function treeBuild($idField = 'id', $parentField = 'parent')
1474
+    {
1467 1475
         return $this->_treeBuild($this->_docs, $this->getCFGDef('idField', $idField),
1468 1476
             $this->getCFGDef('parentField', $parentField));
1469 1477
     }
@@ -1476,16 +1484,16 @@  discard block
 block discarded – undo
1476 1484
      * @param string $pidName name parent field in associative data array
1477 1485
      * @return array
1478 1486
      */
1479
-    private function _treeBuild($data, $idName, $pidName)
1480
-    {
1487
+    private function _treeBuild($data, $idName, $pidName)
1488
+    {
1481 1489
         $children = array(); // children of each ID
1482 1490
         $ids = array();
1483
-        foreach ($data as $i => $r) {
1491
+        foreach ($data as $i => $r) {
1484 1492
             $row =& $data[$i];
1485 1493
             $id = $row[$idName];
1486 1494
             $pid = $row[$pidName];
1487 1495
             $children[$pid][$id] =& $row;
1488
-            if (!isset($children[$id])) {
1496
+            if (!isset($children[$id])) {
1489 1497
                 $children[$id] = array();
1490 1498
             }
1491 1499
             $row['#childNodes'] =& $children[$id];
@@ -1493,9 +1501,9 @@  discard block
 block discarded – undo
1493 1501
         }
1494 1502
         // Root elements are elements with non-found PIDs.
1495 1503
         $this->_tree = array();
1496
-        foreach ($data as $i => $r) {
1504
+        foreach ($data as $i => $r) {
1497 1505
             $row =& $data[$i];
1498
-            if (!isset($ids[$row[$pidName]])) {
1506
+            if (!isset($ids[$row[$pidName]])) {
1499 1507
                 $this->_tree[$row[$idName]] = $row;
1500 1508
             }
1501 1509
         }
@@ -1509,8 +1517,8 @@  discard block
 block discarded – undo
1509 1517
      *
1510 1518
      * @return string PrimaryKey основной таблицы
1511 1519
      */
1512
-    public function getPK()
1513
-    {
1520
+    public function getPK()
1521
+    {
1514 1522
         return isset($this->idField) ? $this->idField : 'id';
1515 1523
     }
1516 1524
 
@@ -1519,8 +1527,8 @@  discard block
 block discarded – undo
1519 1527
      * По умолчанию это parent. Переопределить можно в контроллере присвоив другое значение переменной parentField
1520 1528
      * @return string Parent Key основной таблицы
1521 1529
      */
1522
-    public function getParentField()
1523
-    {
1530
+    public function getParentField()
1531
+    {
1524 1532
         return isset($this->parentField) ? $this->parentField : '';
1525 1533
     }
1526 1534
 
@@ -1531,31 +1539,31 @@  discard block
 block discarded – undo
1531 1539
      * @param string $filter_string строка со всеми фильтрами
1532 1540
      * @return mixed результат разбора фильтров
1533 1541
      */
1534
-    protected function getFilters($filter_string)
1535
-    {
1542
+    protected function getFilters($filter_string)
1543
+    {
1536 1544
         $this->debug->debug("getFilters: " . $this->debug->dumpData($filter_string), 'getFilter', 1);
1537 1545
         // the filter parameter tells us, which filters can be used in this query
1538 1546
         $filter_string = trim($filter_string, ' ;');
1539
-        if (!$filter_string) {
1547
+        if (!$filter_string) {
1540 1548
             return;
1541 1549
         }
1542 1550
         $output = array('join' => '', 'where' => '');
1543 1551
         $logic_op_found = false;
1544 1552
         $joins = $wheres = array();
1545
-        foreach ($this->_logic_ops as $op => $sql) {
1546
-            if (strpos($filter_string, $op) === 0) {
1553
+        foreach ($this->_logic_ops as $op => $sql) {
1554
+            if (strpos($filter_string, $op) === 0) {
1547 1555
                 $logic_op_found = true;
1548 1556
                 $subfilters = mb_substr($filter_string, strlen($op) + 1, mb_strlen($filter_string, "UTF-8"), "UTF-8");
1549 1557
                 $subfilters = $this->smartSplit($subfilters);
1550
-                foreach ($subfilters as $subfilter) {
1558
+                foreach ($subfilters as $subfilter) {
1551 1559
                     $subfilter = $this->getFilters(trim($subfilter));
1552
-                    if (!$subfilter) {
1560
+                    if (!$subfilter) {
1553 1561
                         continue;
1554 1562
                     }
1555
-                    if ($subfilter['join']) {
1563
+                    if ($subfilter['join']) {
1556 1564
                         $joins[] = $subfilter['join'];
1557 1565
                     }
1558
-                    if ($subfilter['where']) {
1566
+                    if ($subfilter['where']) {
1559 1567
                         $wheres[] = $subfilter['where'];
1560 1568
                     }
1561 1569
                 }
@@ -1564,12 +1572,12 @@  discard block
 block discarded – undo
1564 1572
             }
1565 1573
         }
1566 1574
 
1567
-        if (!$logic_op_found) {
1575
+        if (!$logic_op_found) {
1568 1576
             $filter = $this->loadFilter($filter_string);
1569
-            if (!$filter) {
1577
+            if (!$filter) {
1570 1578
                 $this->debug->warning('Error while loading DocLister filter "' . $this->debug->dumpData($filter_string) . '": check syntax!');
1571 1579
                 $output = false;
1572
-            } else {
1580
+            } else {
1573 1581
                 $output['join'] = $filter->get_join();
1574 1582
                 $output['where'] = $filter->get_where();
1575 1583
             }
@@ -1582,16 +1590,16 @@  discard block
 block discarded – undo
1582 1590
     /**
1583 1591
      * @return mixed
1584 1592
      */
1585
-    public function filtersWhere()
1586
-    {
1593
+    public function filtersWhere()
1594
+    {
1587 1595
         return APIHelpers::getkey($this->_filters, 'where', '');
1588 1596
     }
1589 1597
 
1590 1598
     /**
1591 1599
      * @return mixed
1592 1600
      */
1593
-    public function filtersJoin()
1594
-    {
1601
+    public function filtersJoin()
1602
+    {
1595 1603
         return APIHelpers::getkey($this->_filters, 'join', '');
1596 1604
     }
1597 1605
 
@@ -1602,10 +1610,10 @@  discard block
 block discarded – undo
1602 1610
      * @param $type string тип фильтрации
1603 1611
      * @return string имя поля с учетом приведения типа
1604 1612
      */
1605
-    public function changeSortType($field, $type)
1606
-    {
1613
+    public function changeSortType($field, $type)
1614
+    {
1607 1615
         $type = trim($type);
1608
-        switch (strtoupper($type)) {
1616
+        switch (strtoupper($type)) {
1609 1617
             case 'DECIMAL':
1610 1618
                 $field = 'CAST(' . $field . ' as DECIMAL(10,2))';
1611 1619
                 break;
@@ -1631,14 +1639,14 @@  discard block
 block discarded – undo
1631 1639
      * @param string $filter срока с параметрами фильтрации
1632 1640
      * @return bool
1633 1641
      */
1634
-    protected function loadFilter($filter)
1635
-    {
1642
+    protected function loadFilter($filter)
1643
+    {
1636 1644
         $this->debug->debug('Load filter ' . $this->debug->dumpData($filter), 'loadFilter', 2);
1637 1645
         $out = false;
1638 1646
         $fltr_params = explode(':', $filter, 2);
1639 1647
         $fltr = APIHelpers::getkey($fltr_params, 0, null);
1640 1648
         // check if the filter is implemented
1641
-        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')) {
1642 1650
             require_once dirname(__FILE__) . '/filter/' . $fltr . '.filter.php';
1643 1651
             /**
1644 1652
              * @var tv_DL_filter|content_DL_filter $fltr_class
@@ -1646,12 +1654,12 @@  discard block
 block discarded – undo
1646 1654
             $fltr_class = $fltr . '_DL_filter';
1647 1655
             $this->totalFilters++;
1648 1656
             $fltr_obj = new $fltr_class();
1649
-            if ($fltr_obj->init($this, $filter)) {
1657
+            if ($fltr_obj->init($this, $filter)) {
1650 1658
                 $out = $fltr_obj;
1651
-            } else {
1659
+            } else {
1652 1660
                 $this->debug->error("Wrong filter parameter: '{$this->debug->dumpData($filter)}'", 'Filter');
1653 1661
             }
1654
-        } else {
1662
+        } else {
1655 1663
             $this->debug->error("Error load Filter: '{$this->debug->dumpData($filter)}'", 'Filter');
1656 1664
         }
1657 1665
         $this->debug->debugEnd("loadFilter");
@@ -1663,8 +1671,8 @@  discard block
 block discarded – undo
1663 1671
      * Общее число фильтров
1664 1672
      * @return int
1665 1673
      */
1666
-    public function getCountFilters()
1667
-    {
1674
+    public function getCountFilters()
1675
+    {
1668 1676
         return (int)$this->totalFilters;
1669 1677
     }
1670 1678
 
@@ -1672,8 +1680,8 @@  discard block
 block discarded – undo
1672 1680
      * Выполнить SQL запрос
1673 1681
      * @param string $q SQL запрос
1674 1682
      */
1675
-    public function dbQuery($q)
1676
-    {
1683
+    public function dbQuery($q)
1684
+    {
1677 1685
         $this->debug->debug($q, "query", 1, 'sql');
1678 1686
         $out = $this->modx->db->query($q);
1679 1687
         $this->debug->debugEnd("query");
@@ -1691,8 +1699,8 @@  discard block
 block discarded – undo
1691 1699
      * @param string $tpl шаблон подстановки значения в SQL запрос
1692 1700
      * @return string строка для подстановки в SQL запрос
1693 1701
      */
1694
-    public function LikeEscape($field, $value, $escape = '=', $tpl = '%[+value+]%')
1695
-    {
1702
+    public function LikeEscape($field, $value, $escape = '=', $tpl = '%[+value+]%')
1703
+    {
1696 1704
         return sqlHelper::LikeEscape($this->modx, $field, $value, $escape, $tpl);
1697 1705
     }
1698 1706
 
@@ -1700,8 +1708,8 @@  discard block
 block discarded – undo
1700 1708
      * Получение REQUEST_URI без GET-ключа с
1701 1709
      * @return string
1702 1710
      */
1703
-    public function getRequest()
1704
-    {
1711
+    public function getRequest()
1712
+    {
1705 1713
         $URL = null;
1706 1714
         parse_str(parse_url(MODX_SITE_URL . $_SERVER['REQUEST_URI'], PHP_URL_QUERY), $URL);
1707 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.