Completed
Push — master ( 4a3a91...9c57f8 )
by
unknown
02:14
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
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
             }
295 295
             $where = sqlHelper::trimLogicalOp($where);
296 296
 
297
-            $where = "WHERE {$where}";
297
+            $where = "where {$where}";
298 298
             $whereArr = array();
299 299
             if (!$this->getCFGDef('showNoPublish', 0)) {
300 300
                 $whereArr[] = "c.deleted=0 AND c.published=1";
@@ -388,15 +388,15 @@  discard block
 block discarded – undo
388 388
 
389 389
             if ($this->getCFGDef('showNoPublish', 0)) {
390 390
                 if ($where != '') {
391
-                    $where = "WHERE {$where}";
391
+                    $where = "where {$where}";
392 392
                 } else {
393 393
                     $where = '';
394 394
                 }
395 395
             } else {
396 396
                 if ($where != '') {
397
-                    $where = "WHERE {$where} AND ";
397
+                    $where = "where {$where} AND ";
398 398
                 } else {
399
-                    $where = "WHERE {$where} ";
399
+                    $where = "where {$where} ";
400 400
                 }
401 401
                 $where .= "c.deleted=0 AND c.published=1";
402 402
             }
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 
411 411
             $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0));
412 412
 
413
-            $rs = $this->dbQuery("SELECT {$fields} FROM {$tbl_site_content} {$where} {$group} {$sort} {$limit}");
413
+            $rs = $this->dbQuery("select {$fields} FROM {$tbl_site_content} {$where} {$group} {$sort} {$limit}");
414 414
 
415 415
             $rows = $this->modx->db->makeArray($rs);
416 416
 
@@ -437,9 +437,9 @@  discard block
 block discarded – undo
437 437
         $tbl_site_content = $this->getTable('site_content', 'c');
438 438
         $sanitarInIDs = $this->sanitarIn($id);
439 439
         if ($this->getCFGDef('showNoPublish', 0)) {
440
-            $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1";
440
+            $where = "where {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1";
441 441
         } else {
442
-            $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1";
442
+            $where = "where {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1";
443 443
         }
444 444
 
445 445
         $rs = $this->dbQuery("SELECT id FROM {$tbl_site_content} {$where}");
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
         $group = $this->getGroupSQL($this->getCFGDef('groupBy', ''));
532 532
 
533 533
         if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
534
-            $sql = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " .
534
+            $sql = $this->dbQuery("select {$fields} FROM " . $from . " " . $where . " " .
535 535
                 $group . " " .
536 536
                 $sort . " " .
537 537
                 $this->LimitSQL($this->getCFGDef('queryLimit', 0))
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 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) {
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
                     }
150 150
 
151 151
                     if (isset($item[$date])) {
152
-                        if (!$item[$date] && $date == 'pub_date' && isset($item['createdon'])) {
152
+                        if ( ! $item[$date] && $date == 'pub_date' && isset($item['createdon'])) {
153 153
                             $date = 'createdon';
154 154
                         }
155 155
                         $_date = is_numeric($item[$date]) && $item[$date] == (int)$item[$date] ? $item[$date] : strtotime($item[$date]);
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
             if (array('1') == $fields || in_array('date', $fields)) {
233 233
                 if (isset($row[$date])) {
234
-                    if (!$row[$date] && $date == 'pub_date' && isset($row['createdon'])) {
234
+                    if ( ! $row[$date] && $date == 'pub_date' && isset($row['createdon'])) {
235 235
                         $date = 'createdon';
236 236
                     }   
237 237
                     $_date = is_numeric($row[$date]) && $row[$date] == (int)$row[$date] ? $row[$date] : strtotime($row[$date]);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
                     $row['title'] = empty($row['menutitle']) ? $row['pagetitle'] : $row['menutitle'];
251 251
                 }
252 252
             }
253
-            if ((bool)$this->getCFGDef('makeUrl', 1) && (array('1') == $fields || in_array('url',$fields))
253
+            if ((bool)$this->getCFGDef('makeUrl', 1) && (array('1') == $fields || in_array('url', $fields))
254 254
             ) {
255 255
                 if (isset($row['type']) && $row['type'] == 'reference' && isset($row['content'])) {
256 256
                     $row['url'] = is_numeric($row['content']) ? $this->modx->makeUrl($row['content'], '', '',
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
 
298 298
             $where = "WHERE {$where}";
299 299
             $whereArr = array();
300
-            if (!$this->getCFGDef('showNoPublish', 0)) {
300
+            if ( ! $this->getCFGDef('showNoPublish', 0)) {
301 301
                 $whereArr[] = "c.deleted=0 AND c.published=1";
302 302
             }
303
-            else{
303
+            else {
304 304
                 $q_true = 1;
305 305
             }
306 306
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
             $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id'));
353 353
 
354 354
             $q_true = $q_true ? $q_true : $group != '';
355
-            if ( $q_true ){
355
+            if ($q_true) {
356 356
                 $maxDocs = $this->getCFGDef('maxDocs', 0);
357 357
                 $limit = $maxDocs > 0 ? $this->LimitSQL($this->getCFGDef('maxDocs', 0)) : '';
358 358
                 $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group} {$limit}) as `tmp`");
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
     protected function injectSortByTV($table, $sort)
462 462
     {
463 463
         $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort);
464
-        if (!is_array($out) || empty($out)) {
464
+        if ( ! is_array($out) || empty($out)) {
465 465
             $out = array($table, $sort);
466 466
         }
467 467
 
@@ -478,12 +478,12 @@  discard block
 block discarded – undo
478 478
 
479 479
         $tmpWhere = $this->getCFGDef('addWhereList', '');
480 480
         $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);
481
-        if (!empty($tmpWhere)) {
481
+        if ( ! empty($tmpWhere)) {
482 482
             $where[] = $tmpWhere;
483 483
         }
484 484
 
485 485
         $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']);
486
-        if (!empty($tmpWhere)) {
486
+        if ( ! empty($tmpWhere)) {
487 487
             $where[] = $tmpWhere;
488 488
         }
489 489
 
@@ -516,13 +516,13 @@  discard block
 block discarded – undo
516 516
                 $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
517 517
             }
518 518
         }
519
-        if (!empty($tmpWhere)) {
519
+        if ( ! empty($tmpWhere)) {
520 520
             $where[] = $tmpWhere;
521 521
         }
522
-        if (!$this->getCFGDef('showNoPublish', 0)) {
522
+        if ( ! $this->getCFGDef('showNoPublish', 0)) {
523 523
             $where[] = "c.deleted=0 AND c.published=1";
524 524
         }
525
-        if (!empty($where)) {
525
+        if ( ! empty($where)) {
526 526
             $where = "WHERE " . implode(" AND ", $where);
527 527
         } else {
528 528
             $where = '';
Please login to merge, or discard this patch.
Braces   +109 added lines, -111 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,24 +139,24 @@  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])) {
152
-                        if (!$item[$date] && $date == 'pub_date' && isset($item['createdon'])) {
151
+                    if (isset($item[$date])) {
152
+                        if (!$item[$date] && $date == 'pub_date' && isset($item['createdon'])) {
153 153
                             $date = 'createdon';
154 154
                         }
155 155
                         $_date = is_numeric($item[$date]) && $item[$date] == (int)$item[$date] ? $item[$date] : strtotime($item[$date]);
156
-                        if ($_date !== false) {
156
+                        if ($_date !== false) {
157 157
                             $_date = $_date + $this->modx->config['server_offset_time'];
158 158
                             $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M');
159
-                            if ($dateFormat) {
159
+                            if ($dateFormat) {
160 160
                                 $item['date'] = strftime($dateFormat, $_date);
161 161
                             }
162 162
                         }
@@ -165,30 +165,30 @@  discard block
 block discarded – undo
165 165
                     $findTpl = $this->renderTPL;
166 166
                     $tmp = $this->uniformPrepare($item, $i);
167 167
                     extract($tmp, EXTR_SKIP);
168
-                    if ($this->renderTPL == '') {
168
+                    if ($this->renderTPL == '') {
169 169
                         $this->renderTPL = $findTpl;
170 170
                     }
171 171
 
172
-                    if ($extPrepare) {
172
+                    if ($extPrepare) {
173 173
                         $item = $extPrepare->init($this, array(
174 174
                             'data'      => $item,
175 175
                             'nameParam' => 'prepare'
176 176
                         ));
177
-                        if (is_bool($item) && $item === false) {
177
+                        if (is_bool($item) && $item === false) {
178 178
                             $this->skippedDocs++;
179 179
                             continue;
180 180
                         }
181 181
                     }
182 182
                     $tmp = $this->parseChunk($this->renderTPL, $item);
183 183
 
184
-                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
184
+                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
185 185
                         $this->toPlaceholders($tmp, 1,
186 186
                             "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page
187 187
                     }
188 188
                     $out .= $tmp;
189 189
                     $i++;
190 190
                 }
191
-            } else {
191
+            } else {
192 192
                 $noneTPL = $this->getCFGDef("noneTPL", "");
193 193
                 $out = ($noneTPL != '') ? $this->parseChunk($noneTPL, $sysPlh) : '';
194 194
             }
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
      * @param array $array
205 205
      * @return string
206 206
      */
207
-    public function getJSON($data, $fields, $array = array())
208
-    {
207
+    public function getJSON($data, $fields, $array = array())
208
+    {
209 209
         $out = array();
210 210
         $fields = is_array($fields) ? $fields : explode(",", $fields);
211 211
         $date = $this->getCFGDef('dateSource', 'pub_date');
@@ -224,50 +224,50 @@  discard block
 block discarded – undo
224 224
          */
225 225
         $extE = $this->getExtender('e', true, true);
226 226
 
227
-        foreach ($data as $num => $row) {
228
-            if ((array('1') == $fields || in_array('summary', $fields)) && $extSummary) {
227
+        foreach ($data as $num => $row) {
228
+            if ((array('1') == $fields || in_array('summary', $fields)) && $extSummary) {
229 229
                 $row['summary'] = $this->getSummary($row, $extSummary, 'introtext', 'content');
230 230
             }
231 231
 
232
-            if (array('1') == $fields || in_array('date', $fields)) {
233
-                if (isset($row[$date])) {
234
-                    if (!$row[$date] && $date == 'pub_date' && isset($row['createdon'])) {
232
+            if (array('1') == $fields || in_array('date', $fields)) {
233
+                if (isset($row[$date])) {
234
+                    if (!$row[$date] && $date == 'pub_date' && isset($row['createdon'])) {
235 235
                         $date = 'createdon';
236 236
                     }   
237 237
                     $_date = is_numeric($row[$date]) && $row[$date] == (int)$row[$date] ? $row[$date] : strtotime($row[$date]);
238
-                    if ($_date !== false) {
238
+                    if ($_date !== false) {
239 239
                         $_date = $_date + $this->modx->config['server_offset_time'];
240 240
                         $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M');
241
-                        if ($dateFormat) {
241
+                        if ($dateFormat) {
242 242
                             $row['date'] = strftime($dateFormat, $_date);
243 243
                         }
244 244
                     }
245 245
                 }
246 246
             }
247 247
 
248
-            if (array('1') == $fields || in_array('title', $fields)) {
249
-                if (isset($row['pagetitle'])) {
248
+            if (array('1') == $fields || in_array('title', $fields)) {
249
+                if (isset($row['pagetitle'])) {
250 250
                     $row['title'] = empty($row['menutitle']) ? $row['pagetitle'] : $row['menutitle'];
251 251
                 }
252 252
             }
253 253
             if ((bool)$this->getCFGDef('makeUrl', 1) && (array('1') == $fields || in_array('url',$fields))
254
-            ) {
255
-                if (isset($row['type']) && $row['type'] == 'reference' && isset($row['content'])) {
254
+            ) {
255
+                if (isset($row['type']) && $row['type'] == 'reference' && isset($row['content'])) {
256 256
                     $row['url'] = is_numeric($row['content']) ? $this->modx->makeUrl($row['content'], '', '',
257 257
                         $this->getCFGDef('urlScheme', '')) : $row['content'];
258
-                } elseif (isset($row['id'])) {
258
+                } elseif (isset($row['id'])) {
259 259
                     $row['url'] = $this->modx->makeUrl($row['id'], '', '', $this->getCFGDef('urlScheme', ''));
260 260
                 }
261 261
             }
262
-            if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
263
-                if (is_array($tmp)) {
262
+            if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
263
+                if (is_array($tmp)) {
264 264
                     $row = $tmp;
265 265
                 }
266 266
             }
267 267
 
268
-            if ($extPrepare) {
268
+            if ($extPrepare) {
269 269
                 $row = $extPrepare->init($this, array('data' => $row));
270
-                if (is_bool($row) && $row === false) {
270
+                if (is_bool($row) && $row === false) {
271 271
                     continue;
272 272
                 }
273 273
             }
@@ -280,36 +280,35 @@  discard block
 block discarded – undo
280 280
     /**
281 281
      * @abstract
282 282
      */
283
-    public function getChildrenCount()
284
-    {
283
+    public function getChildrenCount()
284
+    {
285 285
         $out = 0;
286 286
         $sanitarInIDs = $this->sanitarIn($this->IDs);
287
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
287
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
288 288
             $q_true = $this->getCFGDef('ignoreEmpty', '0');
289 289
             $q_true = $q_true ? $q_true : $this->getCFGDef('idType', 'parents') == 'parents';
290 290
             $where = $this->getCFGDef('addWhereList', '');
291 291
             $where = sqlHelper::trimLogicalOp($where);
292 292
             $where = ($where ? $where . ' AND ' : '') . $this->_filters['where'];
293
-            if ($where != '' && $this->_filters['where'] != '') {
293
+            if ($where != '' && $this->_filters['where'] != '') {
294 294
                 $where .= " AND ";
295 295
             }
296 296
             $where = sqlHelper::trimLogicalOp($where);
297 297
 
298 298
             $where = "WHERE {$where}";
299 299
             $whereArr = array();
300
-            if (!$this->getCFGDef('showNoPublish', 0)) {
300
+            if (!$this->getCFGDef('showNoPublish', 0)) {
301 301
                 $whereArr[] = "c.deleted=0 AND c.published=1";
302
-            }
303
-            else{
302
+            } else {
304 303
                 $q_true = 1;
305 304
             }
306 305
 
307 306
             $tbl_site_content = $this->getTable('site_content', 'c');
308 307
 
309
-            if ($sanitarInIDs != "''") {
310
-                switch ($this->getCFGDef('idType', 'parents')) {
308
+            if ($sanitarInIDs != "''") {
309
+                switch ($this->getCFGDef('idType', 'parents')) {
311 310
                     case 'parents':
312
-                        switch ($this->getCFGDef('showParent', '0')) {
311
+                        switch ($this->getCFGDef('showParent', '0')) {
313 312
                             case '-1':
314 313
                                 $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")";
315 314
                                 break;
@@ -321,10 +320,10 @@  discard block
 block discarded – undo
321 320
                                 $tmpWhere = "(c.parent IN ({$sanitarInIDs}) OR c.id IN({$sanitarInIDs}))";
322 321
                                 break;
323 322
                         }
324
-                        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
323
+                        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
325 324
                             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
326 325
                             $whereArr[] = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
327
-                        } else {
326
+                        } else {
328 327
                             $whereArr[] = $tmpWhere;
329 328
                         }
330 329
 
@@ -339,26 +338,25 @@  discard block
 block discarded – undo
339 338
 
340 339
             $q_true = $q_true ? $q_true : trim($where) != 'WHERE';
341 340
 
342
-            if (trim($where) != 'WHERE') {
341
+            if (trim($where) != 'WHERE') {
343 342
                 $where .= " AND ";
344 343
             }
345 344
 
346 345
             $where .= implode(" AND ", $whereArr);
347 346
             $where = sqlHelper::trimLogicalOp($where);
348 347
 
349
-            if (trim($where) == 'WHERE') {
348
+            if (trim($where) == 'WHERE') {
350 349
                 $where = '';
351 350
             }
352 351
             $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id'));
353 352
 
354 353
             $q_true = $q_true ? $q_true : $group != '';
355
-            if ( $q_true ){
354
+            if ( $q_true ) {
356 355
                 $maxDocs = $this->getCFGDef('maxDocs', 0);
357 356
                 $limit = $maxDocs > 0 ? $this->LimitSQL($this->getCFGDef('maxDocs', 0)) : '';
358 357
                 $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group} {$limit}) as `tmp`");
359 358
                 $out = $this->modx->db->getValue($rs);
360
-            }
361
-            else {
359
+            } else {
362 360
                 $out = count($this->IDs);
363 361
             }
364 362
         }
@@ -369,11 +367,11 @@  discard block
 block discarded – undo
369 367
     /**
370 368
      * @return array
371 369
      */
372
-    protected function getDocList()
373
-    {
370
+    protected function getDocList()
371
+    {
374 372
         $out = array();
375 373
         $sanitarInIDs = $this->sanitarIn($this->IDs);
376
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
374
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
377 375
             $where = $this->getCFGDef('addWhereList', '');
378 376
             $where = sqlHelper::trimLogicalOp($where);
379 377
 
@@ -381,21 +379,21 @@  discard block
 block discarded – undo
381 379
             $where = sqlHelper::trimLogicalOp($where);
382 380
 
383 381
             $tbl_site_content = $this->getTable('site_content', 'c');
384
-            if ($sanitarInIDs != "''") {
382
+            if ($sanitarInIDs != "''") {
385 383
                 $where .= ($where ? " AND " : "") . "c.id IN ({$sanitarInIDs}) AND";
386 384
             }
387 385
             $where = sqlHelper::trimLogicalOp($where);
388 386
 
389
-            if ($this->getCFGDef('showNoPublish', 0)) {
390
-                if ($where != '') {
387
+            if ($this->getCFGDef('showNoPublish', 0)) {
388
+                if ($where != '') {
391 389
                     $where = "WHERE {$where}";
392
-                } else {
390
+                } else {
393 391
                     $where = '';
394 392
                 }
395
-            } else {
396
-                if ($where != '') {
393
+            } else {
394
+                if ($where != '') {
397 395
                     $where = "WHERE {$where} AND ";
398
-                } else {
396
+                } else {
399 397
                     $where = "WHERE {$where} ";
400 398
                 }
401 399
                 $where .= "c.deleted=0 AND c.published=1";
@@ -414,7 +412,7 @@  discard block
 block discarded – undo
414 412
 
415 413
             $rows = $this->modx->db->makeArray($rs);
416 414
 
417
-            foreach ($rows as $item) {
415
+            foreach ($rows as $item) {
418 416
                 $out[$item['id']] = $item;
419 417
             }
420 418
         }
@@ -426,19 +424,19 @@  discard block
 block discarded – undo
426 424
      * @param string $id
427 425
      * @return array
428 426
      */
429
-    public function getChildrenFolder($id)
430
-    {
427
+    public function getChildrenFolder($id)
428
+    {
431 429
         $where = $this->getCFGDef('addWhereFolder', '');
432 430
         $where = sqlHelper::trimLogicalOp($where);
433
-        if ($where != '') {
431
+        if ($where != '') {
434 432
             $where .= " AND ";
435 433
         }
436 434
 
437 435
         $tbl_site_content = $this->getTable('site_content', 'c');
438 436
         $sanitarInIDs = $this->sanitarIn($id);
439
-        if ($this->getCFGDef('showNoPublish', 0)) {
437
+        if ($this->getCFGDef('showNoPublish', 0)) {
440 438
             $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1";
441
-        } else {
439
+        } else {
442 440
             $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1";
443 441
         }
444 442
 
@@ -446,7 +444,7 @@  discard block
 block discarded – undo
446 444
 
447 445
         $rows = $this->modx->db->makeArray($rs);
448 446
         $out = array();
449
-        foreach ($rows as $item) {
447
+        foreach ($rows as $item) {
450 448
             $out[] = $item['id'];
451 449
         }
452 450
 
@@ -458,10 +456,10 @@  discard block
 block discarded – undo
458 456
      * @param $sort
459 457
      * @return array
460 458
      */
461
-    protected function injectSortByTV($table, $sort)
462
-    {
459
+    protected function injectSortByTV($table, $sort)
460
+    {
463 461
         $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort);
464
-        if (!is_array($out) || empty($out)) {
462
+        if (!is_array($out) || empty($out)) {
465 463
             $out = array($table, $sort);
466 464
         }
467 465
 
@@ -471,19 +469,19 @@  discard block
 block discarded – undo
471 469
     /**
472 470
      * @return array
473 471
      */
474
-    protected function getChildrenList()
475
-    {
472
+    protected function getChildrenList()
473
+    {
476 474
         $where = array();
477 475
         $out = array();
478 476
 
479 477
         $tmpWhere = $this->getCFGDef('addWhereList', '');
480 478
         $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);
481
-        if (!empty($tmpWhere)) {
479
+        if (!empty($tmpWhere)) {
482 480
             $where[] = $tmpWhere;
483 481
         }
484 482
 
485 483
         $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']);
486
-        if (!empty($tmpWhere)) {
484
+        if (!empty($tmpWhere)) {
487 485
             $where[] = $tmpWhere;
488 486
         }
489 487
 
@@ -494,8 +492,8 @@  discard block
 block discarded – undo
494 492
         $sanitarInIDs = $this->sanitarIn($this->IDs);
495 493
 
496 494
         $tmpWhere = null;
497
-        if ($sanitarInIDs != "''") {
498
-            switch ($this->getCFGDef('showParent', '0')) {
495
+        if ($sanitarInIDs != "''") {
496
+            switch ($this->getCFGDef('showParent', '0')) {
499 497
                 case '-1':
500 498
                     $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")";
501 499
                     break;
@@ -508,29 +506,29 @@  discard block
 block discarded – undo
508 506
                     break;
509 507
             }
510 508
         }
511
-        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
509
+        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
512 510
             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
513
-            if (empty($tmpWhere)) {
511
+            if (empty($tmpWhere)) {
514 512
                 $tmpWhere = "c.id IN({$addDocs})";
515
-            } else {
513
+            } else {
516 514
                 $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
517 515
             }
518 516
         }
519
-        if (!empty($tmpWhere)) {
517
+        if (!empty($tmpWhere)) {
520 518
             $where[] = $tmpWhere;
521 519
         }
522
-        if (!$this->getCFGDef('showNoPublish', 0)) {
520
+        if (!$this->getCFGDef('showNoPublish', 0)) {
523 521
             $where[] = "c.deleted=0 AND c.published=1";
524 522
         }
525
-        if (!empty($where)) {
523
+        if (!empty($where)) {
526 524
             $where = "WHERE " . implode(" AND ", $where);
527
-        } else {
525
+        } else {
528 526
             $where = '';
529 527
         }
530 528
         $fields = $this->getCFGDef('selectFields', 'c.*');
531 529
         $group = $this->getGroupSQL($this->getCFGDef('groupBy', ''));
532 530
 
533
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
531
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
534 532
             $sql = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " .
535 533
                 $group . " " .
536 534
                 $sort . " " .
@@ -539,7 +537,7 @@  discard block
 block discarded – undo
539 537
 
540 538
             $rows = $this->modx->db->makeArray($sql);
541 539
 
542
-            foreach ($rows as $item) {
540
+            foreach ($rows as $item) {
543 541
                 $out[$item['id']] = $item;
544 542
             }
545 543
         }
@@ -552,10 +550,10 @@  discard block
 block discarded – undo
552 550
      * @param string $type
553 551
      * @return string
554 552
      */
555
-    public function changeSortType($field, $type)
556
-    {
553
+    public function changeSortType($field, $type)
554
+    {
557 555
         $type = trim($type);
558
-        switch (strtoupper($type)) {
556
+        switch (strtoupper($type)) {
559 557
             case 'TVDATETIME':
560 558
                 $field = "STR_TO_DATE(" . $field . ",'%d-%m-%Y %H:%i:%s')";
561 559
                 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   +38 added lines, -38 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
 /**
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
             $this->modx = $modx;
199 199
             $this->setDebug(1);
200 200
 
201
-            if (!is_array($cfg) || empty($cfg)) {
201
+            if ( ! is_array($cfg) || empty($cfg)) {
202 202
                 $cfg = $this->modx->Event->params;
203 203
             }
204 204
         } else {
@@ -389,11 +389,11 @@  discard block
 block discarded – undo
389 389
      */
390 390
     public function getTable($name, $alias = '')
391 391
     {
392
-        if (!isset($this->_table[$name])) {
392
+        if ( ! isset($this->_table[$name])) {
393 393
             $this->_table[$name] = $this->modx->getFullTableName($name);
394 394
         }
395 395
         $table = $this->_table[$name];
396
-        if (!empty($alias) && is_scalar($alias)) {
396
+        if ( ! empty($alias) && is_scalar($alias)) {
397 397
             $table .= " as `" . $alias . "`";
398 398
         }
399 399
 
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
      */
409 409
     public function TableAlias($name, $table, $alias)
410 410
     {
411
-        if (!$this->checkTableAlias($name, $table)) {
411
+        if ( ! $this->checkTableAlias($name, $table)) {
412 412
             $this->AddTable[$table][$name] = $alias;
413 413
         }
414 414
 
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
     public function isErrorJSON($json)
454 454
     {
455 455
         $error = jsonHelper::json_last_error_msg();
456
-        if (!in_array($error, array('error_none', 'other'))) {
456
+        if ( ! in_array($error, array('error_none', 'other'))) {
457 457
             $this->debug->error($this->getMsg('json.' . $error) . ": " . $this->debug->dumpData($json, 'code'), 'JSON');
458 458
             $error = true;
459 459
         }
@@ -472,13 +472,13 @@  discard block
 block discarded – undo
472 472
         $extenders = $this->getCFGDef('extender', '');
473 473
         $extenders = explode(",", $extenders);
474 474
         $tmp = $this->getCFGDef('requestActive', '') != '' || in_array('request', $extenders);
475
-        if ($tmp && !$this->_loadExtender('request')) {
475
+        if ($tmp && ! $this->_loadExtender('request')) {
476 476
             //OR request in extender's parameter
477 477
             throw new Exception('Error load request extender');
478 478
         }
479 479
 
480 480
         $tmp = $this->getCFGDef('summary', '') != '' || in_array('summary', $extenders);
481
-        if ($tmp && !$this->_loadExtender('summary')) {
481
+        if ($tmp && ! $this->_loadExtender('summary')) {
482 482
             //OR summary in extender's parameter
483 483
             throw new Exception('Error load summary extender');
484 484
         }
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
                 $this->getCFGDef('TplCurrentPage', '') != '' || $this->getCFGDef('TplWrapPaginate', '') != '' ||
491 491
                 $this->getCFGDef('pageLimit', '') != '' || $this->getCFGDef('pageAdjacents', '') != '' ||
492 492
                 $this->getCFGDef('PaginateClass', '') != '' || $this->getCFGDef('TplNextP', '') != ''
493
-            ) && !$this->_loadExtender('paginate')
493
+            ) && ! $this->_loadExtender('paginate')
494 494
         ) {
495 495
             throw new Exception('Error load paginate extender');
496 496
         } else {
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
         if ($ext != '') {
658 658
             $ext = explode(",", $ext);
659 659
             foreach ($ext as $item) {
660
-                if ($item != '' && !$this->_loadExtender($item)) {
660
+                if ($item != '' && ! $this->_loadExtender($item)) {
661 661
                     throw new Exception('Error load ' . APIHelpers::e($item) . ' extender');
662 662
                 }
663 663
             }
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
      */
719 719
     public function sanitarIn($data, $sep = ',', $quote = true)
720 720
     {
721
-        if (!is_array($data)) {
721
+        if ( ! is_array($data)) {
722 722
             $data = explode($sep, $data);
723 723
         }
724 724
         $out = array();
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
     protected function renderTree($data)
856 856
     {
857 857
         $out = '';
858
-        if (!empty($data['#childNodes'])) {
858
+        if ( ! empty($data['#childNodes'])) {
859 859
             foreach ($data['#childNodes'] as $item) {
860 860
                 $out .= $this->renderTree($item);
861 861
             }
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
     public function parseLang($tpl)
895 895
     {
896 896
         $this->debug->debug(array("parseLang" => $tpl), "parseLang", 2, array('html'));
897
-        if (is_scalar($tpl) && !empty($tpl)) {
897
+        if (is_scalar($tpl) && ! empty($tpl)) {
898 898
             if (preg_match_all("/\[\%([a-zA-Z0-9\.\_\-]+)\%\]/", $tpl, $match)) {
899 899
                 $langVal = array();
900 900
                 foreach ($match[1] as $item) {
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
     {
970 970
         $out = $data;
971 971
         $docs = count($this->_docs) - $this->skippedDocs;
972
-        if ((($this->getCFGDef("noneWrapOuter", "1") && $docs == 0) || $docs > 0) && !empty($this->ownerTPL)) {
972
+        if ((($this->getCFGDef("noneWrapOuter", "1") && $docs == 0) || $docs > 0) && ! empty($this->ownerTPL)) {
973 973
             $this->debug->debug("", "renderWrapTPL", 2);
974 974
             $parse = true;
975 975
             $plh = array($this->getCFGDef("sysKey", "dl") . ".wrap" => $data);
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
                 }
993 993
                 $plh = $params;
994 994
             }
995
-            if ($parse && !empty($this->ownerTPL)) {
995
+            if ($parse && ! empty($this->ownerTPL)) {
996 996
                 $this->debug->updateMessage(
997 997
                     array("render ownerTPL" => $this->ownerTPL, "With data" => print_r($plh, 1)),
998 998
                     "renderWrapTPL",
@@ -1136,10 +1136,10 @@  discard block
 block discarded – undo
1136 1136
         $introField = $this->getCFGDef("introField", $introField);
1137 1137
         $contentField = $this->getCFGDef("contentField", $contentField);
1138 1138
 
1139
-        if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1139
+        if ( ! empty($introField) && ! empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1140 1140
             $out = $item[$introField];
1141 1141
         } else {
1142
-            if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1142
+            if ( ! empty($contentField) && ! empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1143 1143
                 $out = $extSummary->init($this, array(
1144 1144
                     "content"      => $item[$contentField],
1145 1145
                     "action"       => $this->getCFGDef("summary", ""),
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
             $flag = true;
1209 1209
 
1210 1210
         } else {
1211
-            if (!class_exists($classname, false) && $classname != '') {
1211
+            if ( ! class_exists($classname, false) && $classname != '') {
1212 1212
                 if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) {
1213 1213
                     include_once(dirname(__FILE__) . "/extender/" . $name . ".extender.inc");
1214 1214
                 }
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
                 $flag = true;
1219 1219
             }
1220 1220
         }
1221
-        if (!$flag) {
1221
+        if ( ! $flag) {
1222 1222
             $this->debug->debug("Error load Extender " . $this->debug->dumpData($name));
1223 1223
         }
1224 1224
         $this->debug->debugEnd('LoadExtender');
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
         $this->debug->debug('clean IDs ' . $this->debug->dumpData($IDs) . ' with separator ' . $this->debug->dumpData($sep),
1277 1277
             'cleanIDs', 2);
1278 1278
         $out = array();
1279
-        if (!is_array($IDs)) {
1279
+        if ( ! is_array($IDs)) {
1280 1280
             $IDs = explode($sep, $IDs);
1281 1281
         }
1282 1282
         foreach ($IDs as $item) {
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
     {
1313 1313
         $out = array();
1314 1314
         foreach ($this->_docs as $doc => $val) {
1315
-            if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) {
1315
+            if (isset($val[$userField]) && (($uniq && ! in_array($val[$userField], $out)) || ! $uniq)) {
1316 1316
                 $out[$doc] = $val[$userField];
1317 1317
             }
1318 1318
         }
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
                             $out['order'] = $tmp;
1402 1402
                         // no break
1403 1403
                     }
1404
-                    if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1404
+                    if ('' == $out['order'] || ! in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1405 1405
                         $out['order'] = $orderDef; //Default
1406 1406
                     }
1407 1407
 
@@ -1429,7 +1429,7 @@  discard block
 block discarded – undo
1429 1429
         if ($limit == 0) {
1430 1430
             $limit = $this->getCFGDef('display', 0);
1431 1431
         }
1432
-        $maxDocs = $this->getCFGDef('maxDocs',0);
1432
+        $maxDocs = $this->getCFGDef('maxDocs', 0);
1433 1433
         if ($maxDocs > 0 && $limit > $maxDocs) {
1434 1434
             $limit = $maxDocs;
1435 1435
         }
@@ -1496,21 +1496,21 @@  discard block
 block discarded – undo
1496 1496
         $children = array(); // children of each ID
1497 1497
         $ids = array();
1498 1498
         foreach ($data as $i => $r) {
1499
-            $row =& $data[$i];
1499
+            $row = & $data[$i];
1500 1500
             $id = $row[$idName];
1501 1501
             $pid = $row[$pidName];
1502
-            $children[$pid][$id] =& $row;
1503
-            if (!isset($children[$id])) {
1502
+            $children[$pid][$id] = & $row;
1503
+            if ( ! isset($children[$id])) {
1504 1504
                 $children[$id] = array();
1505 1505
             }
1506
-            $row['#childNodes'] =& $children[$id];
1506
+            $row['#childNodes'] = & $children[$id];
1507 1507
             $ids[$row[$idName]] = true;
1508 1508
         }
1509 1509
         // Root elements are elements with non-found PIDs.
1510 1510
         $this->_tree = array();
1511 1511
         foreach ($data as $i => $r) {
1512
-            $row =& $data[$i];
1513
-            if (!isset($ids[$row[$pidName]])) {
1512
+            $row = & $data[$i];
1513
+            if ( ! isset($ids[$row[$pidName]])) {
1514 1514
                 $this->_tree[$row[$idName]] = $row;
1515 1515
             }
1516 1516
         }
@@ -1527,7 +1527,7 @@  discard block
 block discarded – undo
1527 1527
     public function getPK()
1528 1528
     {
1529 1529
         $idField = isset($this->idField) ? $this->idField : 'id';
1530
-        if (!empty($this->alias)) {
1530
+        if ( ! empty($this->alias)) {
1531 1531
             $idField = $this->alias . '.' . $idField;
1532 1532
         }
1533 1533
 
@@ -1542,7 +1542,7 @@  discard block
 block discarded – undo
1542 1542
     public function getParentField()
1543 1543
     {
1544 1544
         $parentField = isset($this->parentField) ? $this->parentField : '';
1545
-        if (!empty($parentField) && !empty($this->alias)) {
1545
+        if ( ! empty($parentField) && ! empty($this->alias)) {
1546 1546
             $parentField = $this->alias . '.' . $parentField;
1547 1547
         }
1548 1548
 
@@ -1561,7 +1561,7 @@  discard block
 block discarded – undo
1561 1561
         $this->debug->debug("getFilters: " . $this->debug->dumpData($filter_string), 'getFilter', 1);
1562 1562
         // the filter parameter tells us, which filters can be used in this query
1563 1563
         $filter_string = trim($filter_string, ' ;');
1564
-        if (!$filter_string) {
1564
+        if ( ! $filter_string) {
1565 1565
             return;
1566 1566
         }
1567 1567
         $output = array('join' => '', 'where' => '');
@@ -1574,7 +1574,7 @@  discard block
 block discarded – undo
1574 1574
                 $subfilters = $this->smartSplit($subfilters);
1575 1575
                 foreach ($subfilters as $subfilter) {
1576 1576
                     $subfilter = $this->getFilters(trim($subfilter));
1577
-                    if (!$subfilter) {
1577
+                    if ( ! $subfilter) {
1578 1578
                         continue;
1579 1579
                     }
1580 1580
                     if ($subfilter['join']) {
@@ -1584,14 +1584,14 @@  discard block
 block discarded – undo
1584 1584
                         $wheres[] = $subfilter['where'];
1585 1585
                     }
1586 1586
                 }
1587
-                $output['join'] = !empty($joins) ? implode(' ', $joins) : '';
1588
-                $output['where'] = !empty($wheres) ? '(' . implode($sql, $wheres) . ')' : '';
1587
+                $output['join'] = ! empty($joins) ? implode(' ', $joins) : '';
1588
+                $output['where'] = ! empty($wheres) ? '(' . implode($sql, $wheres) . ')' : '';
1589 1589
             }
1590 1590
         }
1591 1591
 
1592
-        if (!$logic_op_found) {
1592
+        if ( ! $logic_op_found) {
1593 1593
             $filter = $this->loadFilter($filter_string);
1594
-            if (!$filter) {
1594
+            if ( ! $filter) {
1595 1595
                 $this->debug->warning('Error while loading DocLister filter "' . $this->debug->dumpData($filter_string) . '": check syntax!');
1596 1596
                 $output = false;
1597 1597
             } else {
@@ -1663,7 +1663,7 @@  discard block
 block discarded – undo
1663 1663
         $fltr_params = explode(':', $filter, 2);
1664 1664
         $fltr = APIHelpers::getkey($fltr_params, 0, null);
1665 1665
         // check if the filter is implemented
1666
-        if (!is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1666
+        if ( ! is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1667 1667
             require_once dirname(__FILE__) . '/filter/' . $fltr . '.filter.php';
1668 1668
             /**
1669 1669
              * @var tv_DL_filter|content_DL_filter $fltr_class
Please login to merge, or discard this patch.
Braces   +284 added lines, -282 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
      */
@@ -184,48 +184,48 @@  discard block
 block discarded – undo
184 184
      * @param int $startTime время запуска сниппета
185 185
      * @throws Exception
186 186
      */
187
-    public function __construct($modx, $cfg = array(), $startTime = null)
188
-    {
187
+    public function __construct($modx, $cfg = array(), $startTime = null)
188
+    {
189 189
         $this->setTimeStart($startTime);
190 190
 
191
-        if (extension_loaded('mbstring')) {
191
+        if (extension_loaded('mbstring')) {
192 192
             mb_internal_encoding("UTF-8");
193
-        } else {
193
+        } else {
194 194
             throw new Exception('Not found php extension mbstring');
195 195
         }
196 196
 
197
-        if ($modx instanceof DocumentParser) {
197
+        if ($modx instanceof DocumentParser) {
198 198
             $this->modx = $modx;
199 199
             $this->setDebug(1);
200 200
 
201
-            if (!is_array($cfg) || empty($cfg)) {
201
+            if (!is_array($cfg) || empty($cfg)) {
202 202
                 $cfg = $this->modx->Event->params;
203 203
             }
204
-        } else {
204
+        } else {
205 205
             throw new Exception('MODX var is not instaceof DocumentParser');
206 206
         }
207 207
 
208 208
         $this->FS = \Helpers\FS::getInstance();
209 209
         $this->config = new \Helpers\Config($cfg);
210 210
 
211
-        if (isset($cfg['config'])) {
211
+        if (isset($cfg['config'])) {
212 212
             $this->config->setPath(dirname(__DIR__))->loadConfig($cfg['config']);
213 213
         }
214 214
 
215
-        if ($this->config->setConfig($cfg) === false) {
215
+        if ($this->config->setConfig($cfg) === false) {
216 216
             throw new Exception('no parameters to run DocLister');
217 217
         }
218 218
 
219 219
         $this->loadLang(array('core', 'json'));
220 220
         $this->setDebug($this->getCFGDef('debug', 0));
221 221
 
222
-        if ($this->checkDL()) {
222
+        if ($this->checkDL()) {
223 223
             $cfg = array();
224 224
             $idType = $this->getCFGDef('idType', '');
225
-            if (empty($idType) && $this->getCFGDef('documents', '') != '') {
225
+            if (empty($idType) && $this->getCFGDef('documents', '') != '') {
226 226
                 $idType = 'documents';
227 227
             }
228
-            switch ($idType) {
228
+            switch ($idType) {
229 229
                 case 'documents':
230 230
                     $IDs = $this->getCFGDef('documents');
231 231
                     $cfg['idType'] = "documents";
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
                 case 'parents':
234 234
                 default:
235 235
                     $cfg['idType'] = "parents";
236
-                    if (($IDs = $this->getCFGDef('parents')) === null) {
236
+                    if (($IDs = $this->getCFGDef('parents')) === null) {
237 237
                         $IDs = $this->getCurrentMODXPageID();
238 238
                     }
239 239
                     break;
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
 
253 253
         $this->setLocate();
254 254
 
255
-        if ($this->getCFGDef("customLang")) {
255
+        if ($this->getCFGDef("customLang")) {
256 256
             $this->getCustomLang();
257 257
         }
258 258
         $this->loadExtender($this->getCFGDef("extender", ""));
259 259
 
260
-        if ($this->checkExtender('request')) {
260
+        if ($this->checkExtender('request')) {
261 261
             $this->extender['request']->init($this, $this->getCFGDef("requestActive", ""));
262 262
         }
263 263
         $this->_filters = $this->getFilters($this->getCFGDef('filters', ''));
@@ -269,21 +269,21 @@  discard block
 block discarded – undo
269 269
      * @param string $str строка с фильтром
270 270
      * @return array массив субфильтров
271 271
      */
272
-    public function smartSplit($str)
273
-    {
272
+    public function smartSplit($str)
273
+    {
274 274
         $res = array();
275 275
         $cur = '';
276 276
         $open = 0;
277 277
         $strlen = mb_strlen($str, 'UTF-8');
278
-        for ($i = 0; $i <= $strlen; $i++) {
278
+        for ($i = 0; $i <= $strlen; $i++) {
279 279
             $e = mb_substr($str, $i, 1, 'UTF-8');
280
-            switch ($e) {
280
+            switch ($e) {
281 281
                 case ')':
282 282
                     $open--;
283
-                    if ($open == 0) {
283
+                    if ($open == 0) {
284 284
                         $res[] = $cur . ')';
285 285
                         $cur = '';
286
-                    } else {
286
+                    } else {
287 287
                         $cur .= $e;
288 288
                     }
289 289
                     break;
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
                     $cur .= $e;
293 293
                     break;
294 294
                 case ';':
295
-                    if ($open == 0) {
295
+                    if ($open == 0) {
296 296
                         $res[] = $cur;
297 297
                         $cur = '';
298
-                    } else {
298
+                    } else {
299 299
                         $cur .= $e;
300 300
                     }
301 301
                     break;
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
             }
305 305
         }
306 306
         $cur = preg_replace("/(\))$/u", '', $cur);
307
-        if ($cur != '') {
307
+        if ($cur != '') {
308 308
             $res[] = $cur;
309 309
         }
310 310
 
@@ -315,8 +315,8 @@  discard block
 block discarded – undo
315 315
      * Трансформация объекта в строку
316 316
      * @return string последний ответ от DocLister'а
317 317
      */
318
-    public function __toString()
319
-    {
318
+    public function __toString()
319
+    {
320 320
         return $this->outData;
321 321
     }
322 322
 
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
      * Установить время запуска сниппета
325 325
      * @param float|null $time
326 326
      */
327
-    public function setTimeStart($time = null)
328
-    {
327
+    public function setTimeStart($time = null)
328
+    {
329 329
         $this->_timeStart = is_null($time) ? microtime(true) : $time;
330 330
     }
331 331
 
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
      *
335 335
      * @return int
336 336
      */
337
-    public function getTimeStart()
338
-    {
337
+    public function getTimeStart()
338
+    {
339 339
         return $this->_timeStart;
340 340
     }
341 341
 
@@ -343,27 +343,27 @@  discard block
 block discarded – undo
343 343
      * Установка режима отладки
344 344
      * @param int $flag режим отладки
345 345
      */
346
-    public function setDebug($flag = 0)
347
-    {
346
+    public function setDebug($flag = 0)
347
+    {
348 348
         $flag = abs((int)$flag);
349
-        if ($this->_debugMode != $flag) {
349
+        if ($this->_debugMode != $flag) {
350 350
             $this->_debugMode = $flag;
351 351
             $this->debug = null;
352
-            if ($this->_debugMode > 0) {
353
-                if (isset($_SESSION['usertype']) && $_SESSION['usertype'] == 'manager') {
352
+            if ($this->_debugMode > 0) {
353
+                if (isset($_SESSION['usertype']) && $_SESSION['usertype'] == 'manager') {
354 354
                     error_reporting(E_ALL ^ E_NOTICE);
355 355
                     ini_set('display_errors', 1);
356 356
                 }
357 357
                 $dir = dirname(dirname(__FILE__));
358
-                if (file_exists($dir . "/lib/DLdebug.class.php")) {
358
+                if (file_exists($dir . "/lib/DLdebug.class.php")) {
359 359
                     include_once($dir . "/lib/DLdebug.class.php");
360
-                    if (class_exists("DLdebug", false)) {
360
+                    if (class_exists("DLdebug", false)) {
361 361
                         $this->debug = new DLdebug($this);
362 362
                     }
363 363
                 }
364 364
             }
365 365
 
366
-            if (is_null($this->debug)) {
366
+            if (is_null($this->debug)) {
367 367
                 $this->debug = new xNop();
368 368
                 $this->_debugMode = 0;
369 369
                 error_reporting(0);
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
     /**
376 376
      * Информация о режиме отладки
377 377
      */
378
-    public function getDebug()
379
-    {
378
+    public function getDebug()
379
+    {
380 380
         return $this->_debugMode;
381 381
     }
382 382
 
@@ -387,13 +387,13 @@  discard block
 block discarded – undo
387 387
      * @param string $alias желаемый алиас таблицы
388 388
      * @return string имя таблицы с префиксом и алиасом
389 389
      */
390
-    public function getTable($name, $alias = '')
391
-    {
392
-        if (!isset($this->_table[$name])) {
390
+    public function getTable($name, $alias = '')
391
+    {
392
+        if (!isset($this->_table[$name])) {
393 393
             $this->_table[$name] = $this->modx->getFullTableName($name);
394 394
         }
395 395
         $table = $this->_table[$name];
396
-        if (!empty($alias) && is_scalar($alias)) {
396
+        if (!empty($alias) && is_scalar($alias)) {
397 397
             $table .= " as `" . $alias . "`";
398 398
         }
399 399
 
@@ -406,9 +406,9 @@  discard block
 block discarded – undo
406 406
      * @param $alias
407 407
      * @return mixed
408 408
      */
409
-    public function TableAlias($name, $table, $alias)
410
-    {
411
-        if (!$this->checkTableAlias($name, $table)) {
409
+    public function TableAlias($name, $table, $alias)
410
+    {
411
+        if (!$this->checkTableAlias($name, $table)) {
412 412
             $this->AddTable[$table][$name] = $alias;
413 413
         }
414 414
 
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
      * @param $table
421 421
      * @return bool
422 422
      */
423
-    public function checkTableAlias($name, $table)
424
-    {
423
+    public function checkTableAlias($name, $table)
424
+    {
425 425
         return isset($this->AddTable[$table][$name]);
426 426
     }
427 427
 
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
      * @param bool $nop создавать ли пустой объект запрашиваемого типа
434 434
      * @return array|mixed|xNop
435 435
      */
436
-    public function jsonDecode($json, $config = array(), $nop = false)
437
-    {
436
+    public function jsonDecode($json, $config = array(), $nop = false)
437
+    {
438 438
         $this->debug->debug('Decode JSON: ' . $this->debug->dumpData($json) . "\r\nwith config: " . $this->debug->dumpData($config),
439 439
             'jsonDecode', 2);
440 440
         $config = jsonHelper::jsonDecode($json, $config, $nop);
@@ -450,10 +450,10 @@  discard block
 block discarded – undo
450 450
      * @param $json string строка с JSON для записи в лог при отладке
451 451
      * @return bool|string
452 452
      */
453
-    public function isErrorJSON($json)
454
-    {
453
+    public function isErrorJSON($json)
454
+    {
455 455
         $error = jsonHelper::json_last_error_msg();
456
-        if (!in_array($error, array('error_none', 'other'))) {
456
+        if (!in_array($error, array('error_none', 'other'))) {
457 457
             $this->debug->error($this->getMsg('json.' . $error) . ": " . $this->debug->dumpData($json, 'code'), 'JSON');
458 458
             $error = true;
459 459
         }
@@ -465,20 +465,20 @@  discard block
 block discarded – undo
465 465
      * Проверка параметров и загрузка необходимых экстендеров
466 466
      * return boolean статус загрузки
467 467
      */
468
-    public function checkDL()
469
-    {
468
+    public function checkDL()
469
+    {
470 470
         $this->debug->debug('Check DocLister parameters', 'checkDL', 2);
471 471
         $flag = true;
472 472
         $extenders = $this->getCFGDef('extender', '');
473 473
         $extenders = explode(",", $extenders);
474 474
         $tmp = $this->getCFGDef('requestActive', '') != '' || in_array('request', $extenders);
475
-        if ($tmp && !$this->_loadExtender('request')) {
475
+        if ($tmp && !$this->_loadExtender('request')) {
476 476
             //OR request in extender's parameter
477 477
             throw new Exception('Error load request extender');
478 478
         }
479 479
 
480 480
         $tmp = $this->getCFGDef('summary', '') != '' || in_array('summary', $extenders);
481
-        if ($tmp && !$this->_loadExtender('summary')) {
481
+        if ($tmp && !$this->_loadExtender('summary')) {
482 482
             //OR summary in extender's parameter
483 483
             throw new Exception('Error load summary extender');
484 484
         }
@@ -491,15 +491,15 @@  discard block
 block discarded – undo
491 491
                 $this->getCFGDef('pageLimit', '') != '' || $this->getCFGDef('pageAdjacents', '') != '' ||
492 492
                 $this->getCFGDef('PaginateClass', '') != '' || $this->getCFGDef('TplNextP', '') != ''
493 493
             ) && !$this->_loadExtender('paginate')
494
-        ) {
494
+        ) {
495 495
             throw new Exception('Error load paginate extender');
496
-        } else {
497
-            if ((int)$this->getCFGDef('display', 0) == 0) {
496
+        } else {
497
+            if ((int)$this->getCFGDef('display', 0) == 0) {
498 498
                 $extenders = $this->unsetArrayVal($extenders, 'paginate');
499 499
             }
500 500
         }
501 501
 
502
-        if ($this->getCFGDef('prepare', '') != '' || $this->getCFGDef('prepareWrap') != '') {
502
+        if ($this->getCFGDef('prepare', '') != '' || $this->getCFGDef('prepareWrap') != '') {
503 503
             $this->_loadExtender('prepare');
504 504
         }
505 505
 
@@ -516,14 +516,14 @@  discard block
 block discarded – undo
516 516
      * @param mixed $val значение которые необходимо удалить из массива
517 517
      * @return array отчищеный массив с данными
518 518
      */
519
-    private function unsetArrayVal($data, $val)
520
-    {
519
+    private function unsetArrayVal($data, $val)
520
+    {
521 521
         $out = array();
522
-        if (is_array($data)) {
523
-            foreach ($data as $item) {
524
-                if ($item != $val) {
522
+        if (is_array($data)) {
523
+            foreach ($data as $item) {
524
+                if ($item != $val) {
525 525
                     $out[] = $item;
526
-                } else {
526
+                } else {
527 527
                     continue;
528 528
                 }
529 529
             }
@@ -538,14 +538,14 @@  discard block
 block discarded – undo
538 538
      * @param int $id уникальный идентификатор страницы
539 539
      * @return string URL страницы
540 540
      */
541
-    public function getUrl($id = 0)
542
-    {
541
+    public function getUrl($id = 0)
542
+    {
543 543
         $id = ((int)$id > 0) ? (int)$id : $this->getCurrentMODXPageID();
544 544
 
545 545
         $link = $this->checkExtender('request') ? $this->extender['request']->getLink() : $this->getRequest();
546
-        if ($id == $this->modx->config['site_start']) {
546
+        if ($id == $this->modx->config['site_start']) {
547 547
             $url = $this->modx->config['site_url'] . ($link != '' ? "?{$link}" : "");
548
-        } else {
548
+        } else {
549 549
             $url = $this->modx->makeUrl($id, '', $link, $this->getCFGDef('urlScheme', ''));
550 550
         }
551 551
 
@@ -573,20 +573,20 @@  discard block
 block discarded – undo
573 573
      * @param string $tpl шаблон
574 574
      * @return string
575 575
      */
576
-    public function render($tpl = '')
577
-    {
576
+    public function render($tpl = '')
577
+    {
578 578
         $this->debug->debug(array('Render data with template ' => $tpl), 'render', 2, array('html'));
579 579
         $out = '';
580
-        if (1 == $this->getCFGDef('tree', '0')) {
581
-            foreach ($this->_tree as $item) {
580
+        if (1 == $this->getCFGDef('tree', '0')) {
581
+            foreach ($this->_tree as $item) {
582 582
                 $out .= $this->renderTree($item);
583 583
             }
584 584
             $out = $this->renderWrap($out);
585
-        } else {
585
+        } else {
586 586
             $out = $this->_render($tpl);
587 587
         }
588 588
 
589
-        if ($out) {
589
+        if ($out) {
590 590
             $this->outData = DLTemplate::getInstance($this->modx)->parseDocumentSource($out);
591 591
         }
592 592
         $this->debug->debugEnd('render');
@@ -603,8 +603,8 @@  discard block
 block discarded – undo
603 603
      *
604 604
      * @return int
605 605
      */
606
-    public function getCurrentMODXPageID()
607
-    {
606
+    public function getCurrentMODXPageID()
607
+    {
608 608
         $id = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0;
609 609
         $docData = isset($this->modx->documentObject) ? $this->modx->documentObject : array();
610 610
 
@@ -620,9 +620,9 @@  discard block
 block discarded – undo
620 620
      * @param integer $line error on line
621 621
      * @param array $trace stack trace
622 622
      */
623
-    public function ErrorLogger($message, $code, $file, $line, $trace)
624
-    {
625
-        if (abs($this->getCFGDef('debug', '0')) == '1') {
623
+    public function ErrorLogger($message, $code, $file, $line, $trace)
624
+    {
625
+        if (abs($this->getCFGDef('debug', '0')) == '1') {
626 626
             $out = "CODE #" . $code . "<br />";
627 627
             $out .= "on file: " . $file . ":" . $line . "<br />";
628 628
             $out .= "<pre>";
@@ -639,8 +639,8 @@  discard block
 block discarded – undo
639 639
      *
640 640
      * @return DocumentParser
641 641
      */
642
-    public function getMODX()
643
-    {
642
+    public function getMODX()
643
+    {
644 644
         return $this->modx;
645 645
     }
646 646
 
@@ -651,13 +651,13 @@  discard block
 block discarded – undo
651 651
      * @return boolean status load extenders
652 652
      * @throws Exception
653 653
      */
654
-    public function loadExtender($ext = '')
655
-    {
654
+    public function loadExtender($ext = '')
655
+    {
656 656
         $out = true;
657
-        if ($ext != '') {
657
+        if ($ext != '') {
658 658
             $ext = explode(",", $ext);
659
-            foreach ($ext as $item) {
660
-                if ($item != '' && !$this->_loadExtender($item)) {
659
+            foreach ($ext as $item) {
660
+                if ($item != '' && !$this->_loadExtender($item)) {
661 661
                     throw new Exception('Error load ' . APIHelpers::e($item) . ' extender');
662 662
                 }
663 663
             }
@@ -673,8 +673,8 @@  discard block
 block discarded – undo
673 673
      * @param mixed $def значение по умолчанию, если в конфиге нет искомого параметра
674 674
      * @return mixed значение из конфига
675 675
      */
676
-    public function getCFGDef($name, $def = null)
677
-    {
676
+    public function getCFGDef($name, $def = null)
677
+    {
678 678
         return $this->config->getCFGDef($name, $def);
679 679
     }
680 680
 
@@ -686,15 +686,15 @@  discard block
 block discarded – undo
686 686
      * @param string $key ключ локального плейсхолдера
687 687
      * @return string
688 688
      */
689
-    public function toPlaceholders($data, $set = 0, $key = 'contentPlaceholder')
690
-    {
689
+    public function toPlaceholders($data, $set = 0, $key = 'contentPlaceholder')
690
+    {
691 691
         $this->debug->debug(null, 'toPlaceholders', 2);
692
-        if ($set == 0) {
692
+        if ($set == 0) {
693 693
             $set = $this->getCFGDef('contentPlaceholder', 0);
694 694
         }
695 695
         $this->_plh[$key] = $data;
696 696
         $id = $this->getCFGDef('id', '');
697
-        if ($id != '') {
697
+        if ($id != '') {
698 698
             $id .= ".";
699 699
         }
700 700
         $out = DLTemplate::getInstance($this->getMODX())->toPlaceholders($data, $set, $key, $id);
@@ -716,14 +716,14 @@  discard block
 block discarded – undo
716 716
      * @param boolean $quote заключать ли данные на выходе в кавычки
717 717
      * @return string обработанная строка
718 718
      */
719
-    public function sanitarIn($data, $sep = ',', $quote = true)
720
-    {
721
-        if (!is_array($data)) {
719
+    public function sanitarIn($data, $sep = ',', $quote = true)
720
+    {
721
+        if (!is_array($data)) {
722 722
             $data = explode($sep, $data);
723 723
         }
724 724
         $out = array();
725
-        foreach ($data as $item) {
726
-            if ($item !== '') {
725
+        foreach ($data as $item) {
726
+            if ($item !== '') {
727 727
                 $out[] = $this->modx->db->escape($item);
728 728
             }
729 729
         }
@@ -744,12 +744,12 @@  discard block
 block discarded – undo
744 744
      * @param string $lang имя языкового пакета
745 745
      * @return array
746 746
      */
747
-    public function getCustomLang($lang = '')
748
-    {
749
-        if (empty($lang)) {
747
+    public function getCustomLang($lang = '')
748
+    {
749
+        if (empty($lang)) {
750 750
             $lang = $this->getCFGDef('lang', $this->modx->config['manager_language']);
751 751
         }
752
-        if (file_exists(dirname(dirname(__FILE__)) . "/lang/" . $lang . ".php")) {
752
+        if (file_exists(dirname(dirname(__FILE__)) . "/lang/" . $lang . ".php")) {
753 753
             $tmp = include(dirname(__FILE__) . "/lang/" . $lang . ".php");
754 754
             $this->_customLang = is_array($tmp) ? $tmp : array();
755 755
         }
@@ -765,25 +765,25 @@  discard block
 block discarded – undo
765 765
      * @param boolean $rename Переименовывать ли элементы массива
766 766
      * @return array массив с лексиконом
767 767
      */
768
-    public function loadLang($name = 'core', $lang = '', $rename = true)
769
-    {
770
-        if (empty($lang)) {
768
+    public function loadLang($name = 'core', $lang = '', $rename = true)
769
+    {
770
+        if (empty($lang)) {
771 771
             $lang = $this->getCFGDef('lang', $this->modx->config['manager_language']);
772 772
         }
773 773
 
774 774
         $this->debug->debug('Load language ' . $this->debug->dumpData($name) . "." . $this->debug->dumpData($lang),
775 775
             'loadlang', 2);
776
-        if (is_scalar($name)) {
776
+        if (is_scalar($name)) {
777 777
             $name = array($name);
778 778
         }
779
-        foreach ($name as $n) {
780
-            if (file_exists(dirname(__FILE__) . "/lang/" . $lang . "/" . $n . ".inc.php")) {
779
+        foreach ($name as $n) {
780
+            if (file_exists(dirname(__FILE__) . "/lang/" . $lang . "/" . $n . ".inc.php")) {
781 781
                 $tmp = include(dirname(__FILE__) . "/lang/" . $lang . "/" . $n . ".inc.php");
782
-                if (is_array($tmp)) {
782
+                if (is_array($tmp)) {
783 783
                     /**
784 784
                      * Переименовыываем элементы массива из array('test'=>'data') в array('name.test'=>'data')
785 785
                      */
786
-                    if ($rename) {
786
+                    if ($rename) {
787 787
                         $tmp = $this->renameKeyArr($tmp, $n, '', '.');
788 788
                     }
789 789
                     $this->_lang = array_merge($this->_lang, $tmp);
@@ -802,11 +802,11 @@  discard block
 block discarded – undo
802 802
      * @param string $def Строка по умолчанию, если запись в языковом пакете не будет обнаружена
803 803
      * @return string строка в соответствии с текущими языковыми настройками
804 804
      */
805
-    public function getMsg($name, $def = '')
806
-    {
807
-        if (isset($this->_customLang[$name])) {
805
+    public function getMsg($name, $def = '')
806
+    {
807
+        if (isset($this->_customLang[$name])) {
808 808
             $say = $this->_customLang[$name];
809
-        } else {
809
+        } else {
810 810
             $say = \APIHelpers::getkey($this->_lang, $name, $def);
811 811
         }
812 812
 
@@ -822,8 +822,8 @@  discard block
 block discarded – undo
822 822
      * @param string $sep разделитель суффиксов, префиксов и ключей массива
823 823
      * @return array массив с переименованными ключами
824 824
      */
825
-    public function renameKeyArr($data, $prefix = '', $suffix = '', $sep = '.')
826
-    {
825
+    public function renameKeyArr($data, $prefix = '', $suffix = '', $sep = '.')
826
+    {
827 827
         return \APIHelpers::renameKeyArr($data, $prefix, $suffix, $sep);
828 828
     }
829 829
 
@@ -833,12 +833,12 @@  discard block
 block discarded – undo
833 833
      * @param string $locale локаль
834 834
      * @return string имя установленной локали
835 835
      */
836
-    public function setLocate($locale = '')
837
-    {
838
-        if ('' == $locale) {
836
+    public function setLocate($locale = '')
837
+    {
838
+        if ('' == $locale) {
839 839
             $locale = $this->getCFGDef('locale', '');
840 840
         }
841
-        if ('' != $locale) {
841
+        if ('' != $locale) {
842 842
             setlocale(LC_ALL, $locale);
843 843
         }
844 844
 
@@ -852,11 +852,11 @@  discard block
 block discarded – undo
852 852
      * @param array $data массив сформированный как дерево
853 853
      * @return string строка для отображения пользователю
854 854
      */
855
-    protected function renderTree($data)
856
-    {
855
+    protected function renderTree($data)
856
+    {
857 857
         $out = '';
858
-        if (!empty($data['#childNodes'])) {
859
-            foreach ($data['#childNodes'] as $item) {
858
+        if (!empty($data['#childNodes'])) {
859
+            foreach ($data['#childNodes'] as $item) {
860 860
                 $out .= $this->renderTree($item);
861 861
             }
862 862
         }
@@ -873,8 +873,8 @@  discard block
 block discarded – undo
873 873
      * @param string $name Template: chunk name || @CODE: template || @FILE: file with template
874 874
      * @return string html template with placeholders without data
875 875
      */
876
-    private function _getChunk($name)
877
-    {
876
+    private function _getChunk($name)
877
+    {
878 878
         $this->debug->debug(array('Get chunk by name' => $name), "getChunk", 2, array('html'));
879 879
         //without trim
880 880
         $tpl = DLTemplate::getInstance($this->getMODX())->getChunk($name);
@@ -891,18 +891,18 @@  discard block
 block discarded – undo
891 891
      * @param string $tpl HTML шаблон
892 892
      * @return string
893 893
      */
894
-    public function parseLang($tpl)
895
-    {
894
+    public function parseLang($tpl)
895
+    {
896 896
         $this->debug->debug(array("parseLang" => $tpl), "parseLang", 2, array('html'));
897
-        if (is_scalar($tpl) && !empty($tpl)) {
898
-            if (preg_match_all("/\[\%([a-zA-Z0-9\.\_\-]+)\%\]/", $tpl, $match)) {
897
+        if (is_scalar($tpl) && !empty($tpl)) {
898
+            if (preg_match_all("/\[\%([a-zA-Z0-9\.\_\-]+)\%\]/", $tpl, $match)) {
899 899
                 $langVal = array();
900
-                foreach ($match[1] as $item) {
900
+                foreach ($match[1] as $item) {
901 901
                     $langVal[] = $this->getMsg($item);
902 902
                 }
903 903
                 $tpl = str_replace($match[0], $langVal, $tpl);
904 904
             }
905
-        } else {
905
+        } else {
906 906
             $tpl = '';
907 907
         }
908 908
         $this->debug->debugEnd("parseLang");
@@ -918,24 +918,24 @@  discard block
 block discarded – undo
918 918
      * @param bool $parseDocumentSource render html template via DocumentParser::parseDocumentSource()
919 919
      * @return string html template with data without placeholders
920 920
      */
921
-    public function parseChunk($name, $data, $parseDocumentSource = false)
922
-    {
921
+    public function parseChunk($name, $data, $parseDocumentSource = false)
922
+    {
923 923
         $this->debug->debug(
924 924
             array("parseChunk" => $name, "With data" => print_r($data, 1)),
925 925
             "parseChunk",
926 926
             2, array('html', null)
927 927
         );
928 928
         $DLTemplate = DLTemplate::getInstance($this->getMODX());
929
-        if ($path = $this->getCFGDef('templatePath')) {
929
+        if ($path = $this->getCFGDef('templatePath')) {
930 930
             $DLTemplate->setTemplatePath($path);
931 931
         }
932
-        if ($ext = $this->getCFGDef('templateExtension')) {
932
+        if ($ext = $this->getCFGDef('templateExtension')) {
933 933
             $DLTemplate->setTemplateExtension($ext);
934 934
         }
935 935
         $DLTemplate->setTwigTemplateVars(array('DocLister' => $this));
936 936
         $out = $DLTemplate->parseChunk($name, $data, $parseDocumentSource);
937 937
         $out = $this->parseLang($out);
938
-        if (empty($out)) {
938
+        if (empty($out)) {
939 939
             $this->debug->debug("Empty chunk: " . $this->debug->dumpData($name), '', 2);
940 940
         }
941 941
         $this->debug->debugEnd("parseChunk");
@@ -951,8 +951,8 @@  discard block
 block discarded – undo
951 951
      *
952 952
      * @return string html template from parameter
953 953
      */
954
-    public function getChunkByParam($name, $val = '')
955
-    {
954
+    public function getChunkByParam($name, $val = '')
955
+    {
956 956
         $data = $this->getCFGDef($name, $val);
957 957
         $data = $this->_getChunk($data);
958 958
 
@@ -965,11 +965,11 @@  discard block
 block discarded – undo
965 965
      * @param string $data html код который нужно обернуть в ownerTPL
966 966
      * @return string результатирующий html код
967 967
      */
968
-    public function renderWrap($data)
969
-    {
968
+    public function renderWrap($data)
969
+    {
970 970
         $out = $data;
971 971
         $docs = count($this->_docs) - $this->skippedDocs;
972
-        if ((($this->getCFGDef("noneWrapOuter", "1") && $docs == 0) || $docs > 0) && !empty($this->ownerTPL)) {
972
+        if ((($this->getCFGDef("noneWrapOuter", "1") && $docs == 0) || $docs > 0) && !empty($this->ownerTPL)) {
973 973
             $this->debug->debug("", "renderWrapTPL", 2);
974 974
             $parse = true;
975 975
             $plh = array($this->getCFGDef("sysKey", "dl") . ".wrap" => $data);
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
              * @var $extPrepare prepare_DL_Extender
978 978
              */
979 979
             $extPrepare = $this->getExtender('prepare');
980
-            if ($extPrepare) {
980
+            if ($extPrepare) {
981 981
                 $params = $extPrepare->init($this, array(
982 982
                     'data'      => array(
983 983
                         'docs'         => $this->_docs,
@@ -986,13 +986,13 @@  discard block
 block discarded – undo
986 986
                     'nameParam' => 'prepareWrap',
987 987
                     'return'    => 'placeholders'
988 988
                 ));
989
-                if (is_bool($params) && $params === false) {
989
+                if (is_bool($params) && $params === false) {
990 990
                     $out = $data;
991 991
                     $parse = false;
992 992
                 }
993 993
                 $plh = $params;
994 994
             }
995
-            if ($parse && !empty($this->ownerTPL)) {
995
+            if ($parse && !empty($this->ownerTPL)) {
996 996
                 $this->debug->updateMessage(
997 997
                     array("render ownerTPL" => $this->ownerTPL, "With data" => print_r($plh, 1)),
998 998
                     "renderWrapTPL",
@@ -1000,7 +1000,7 @@  discard block
 block discarded – undo
1000 1000
                 );
1001 1001
                 $out = $this->parseChunk($this->ownerTPL, $plh);
1002 1002
             }
1003
-            if (empty($this->ownerTPL)) {
1003
+            if (empty($this->ownerTPL)) {
1004 1004
                 $this->debug->updateMessage("empty ownerTPL", "renderWrapTPL");
1005 1005
             }
1006 1006
             $this->debug->debugEnd("renderWrapTPL");
@@ -1016,8 +1016,8 @@  discard block
 block discarded – undo
1016 1016
      * @param int $i номер итерации в цикле
1017 1017
      * @return array массив с данными которые можно использовать в цикле render метода
1018 1018
      */
1019
-    protected function uniformPrepare(&$data, $i = 0)
1020
-    {
1019
+    protected function uniformPrepare(&$data, $i = 0)
1020
+    {
1021 1021
         $class = array();
1022 1022
 
1023 1023
         $iterationName = ($i % 2 == 1) ? 'Odd' : 'Even';
@@ -1031,20 +1031,20 @@  discard block
 block discarded – undo
1031 1031
             "dl") . '.full_iteration'] = ($this->extPaginate) ? ($i + $this->getCFGDef('display',
1032 1032
                 0) * ($this->extPaginate->currentPage() - 1)) : $i;
1033 1033
 
1034
-        if ($i == 1) {
1034
+        if ($i == 1) {
1035 1035
             $this->renderTPL = $this->getCFGDef('tplFirst', $this->renderTPL);
1036 1036
             $class[] = $this->getCFGDef('firstClass', 'first');
1037 1037
         }
1038
-        if ($i == (count($this->_docs) - $this->skippedDocs)) {
1038
+        if ($i == (count($this->_docs) - $this->skippedDocs)) {
1039 1039
             $this->renderTPL = $this->getCFGDef('tplLast', $this->renderTPL);
1040 1040
             $class[] = $this->getCFGDef('lastClass', 'last');
1041 1041
         }
1042
-        if ($this->modx->documentIdentifier == $data['id']) {
1042
+        if ($this->modx->documentIdentifier == $data['id']) {
1043 1043
             $this->renderTPL = $this->getCFGDef('tplCurrent', $this->renderTPL);
1044 1044
             $data[$this->getCFGDef("sysKey",
1045 1045
                 "dl") . '.active'] = 1; //[+active+] - 1 if $modx->documentIdentifer equal ID this element
1046 1046
             $class[] = $this->getCFGDef('currentClass', 'current');
1047
-        } else {
1047
+        } else {
1048 1048
             $data[$this->getCFGDef("sysKey", "dl") . '.active'] = 0;
1049 1049
         }
1050 1050
 
@@ -1055,8 +1055,8 @@  discard block
 block discarded – undo
1055 1055
          * @var $extE e_DL_Extender
1056 1056
          */
1057 1057
         $extE = $this->getExtender('e', true, true);
1058
-        if ($out = $extE->init($this, compact('data'))) {
1059
-            if (is_array($out)) {
1058
+        if ($out = $extE->init($this, compact('data'))) {
1059
+            if (is_array($out)) {
1060 1060
                 $data = $out;
1061 1061
             }
1062 1062
         }
@@ -1072,42 +1072,43 @@  discard block
 block discarded – undo
1072 1072
      * @param array $array данные которые необходимо примешать к ответу на каждой записи $data
1073 1073
      * @return string JSON строка
1074 1074
      */
1075
-    public function getJSON($data, $fields, $array = array())
1076
-    {
1075
+    public function getJSON($data, $fields, $array = array())
1076
+    {
1077 1077
         $out = array();
1078 1078
         $fields = is_array($fields) ? $fields : explode(",", $fields);
1079
-        if (is_array($array) && count($array) > 0) {
1079
+        if (is_array($array) && count($array) > 0) {
1080 1080
             $tmp = array();
1081
-            foreach ($data as $i => $v) { //array_merge not valid work with integer index key
1081
+            foreach ($data as $i => $v) {
1082
+//array_merge not valid work with integer index key
1082 1083
                 $tmp[$i] = (isset($array[$i]) ? array_merge($v, $array[$i]) : $v);
1083 1084
             }
1084 1085
             $data = $tmp;
1085 1086
         }
1086 1087
 
1087
-        foreach ($data as $num => $doc) {
1088
+        foreach ($data as $num => $doc) {
1088 1089
             $tmp = array();
1089
-            foreach ($doc as $name => $value) {
1090
-                if (in_array($name, $fields) || (isset($fields[0]) && $fields[0] == '1')) {
1090
+            foreach ($doc as $name => $value) {
1091
+                if (in_array($name, $fields) || (isset($fields[0]) && $fields[0] == '1')) {
1091 1092
                     $tmp[str_replace(".", "_", $name)] = $value; //JSON element name without dot
1092 1093
                 }
1093 1094
             }
1094 1095
             $out[$num] = $tmp;
1095 1096
         }
1096 1097
 
1097
-        if ('new' == $this->getCFGDef('JSONformat', 'old')) {
1098
+        if ('new' == $this->getCFGDef('JSONformat', 'old')) {
1098 1099
             $return = array();
1099 1100
 
1100 1101
             $return['rows'] = array();
1101
-            foreach ($out as $key => $item) {
1102
+            foreach ($out as $key => $item) {
1102 1103
                 $return['rows'][] = APIHelpers::getkey($item, $key, $item);
1103 1104
             }
1104 1105
             $return['total'] = $this->getChildrenCount();
1105
-        } elseif ('simple' == $this->getCFGDef('JSONformat', 'old')) {
1106
+        } elseif ('simple' == $this->getCFGDef('JSONformat', 'old')) {
1106 1107
             $return = array();
1107
-            foreach ($out as $key => $item) {
1108
+            foreach ($out as $key => $item) {
1108 1109
                 $return[] = APIHelpers::getkey($item, $key, $item);
1109 1110
             }
1110
-        } else {
1111
+        } else {
1111 1112
             $return = $out;
1112 1113
         }
1113 1114
         $this->outData = json_encode($return);
@@ -1123,11 +1124,11 @@  discard block
 block discarded – undo
1123 1124
      * @param string $contentField
1124 1125
      * @return mixed|string
1125 1126
      */
1126
-    protected function getSummary(array $item = array(), $extSummary = null, $introField = '', $contentField = '')
1127
-    {
1127
+    protected function getSummary(array $item = array(), $extSummary = null, $introField = '', $contentField = '')
1128
+    {
1128 1129
         $out = '';
1129 1130
 
1130
-        if (is_null($extSummary)) {
1131
+        if (is_null($extSummary)) {
1131 1132
             /**
1132 1133
              * @var $extSummary summary_DL_Extender
1133 1134
              */
@@ -1136,10 +1137,10 @@  discard block
 block discarded – undo
1136 1137
         $introField = $this->getCFGDef("introField", $introField);
1137 1138
         $contentField = $this->getCFGDef("contentField", $contentField);
1138 1139
 
1139
-        if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1140
+        if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1140 1141
             $out = $item[$introField];
1141
-        } else {
1142
-            if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1142
+        } else {
1143
+            if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1143 1144
                 $out = $extSummary->init($this, array(
1144 1145
                     "content"      => $item[$contentField],
1145 1146
                     "action"       => $this->getCFGDef("summary", ""),
@@ -1157,8 +1158,8 @@  discard block
 block discarded – undo
1157 1158
      * @param string $name extender name
1158 1159
      * @return boolean status extender load
1159 1160
      */
1160
-    public function checkExtender($name)
1161
-    {
1161
+    public function checkExtender($name)
1162
+    {
1162 1163
         return (isset($this->extender[$name]) && $this->extender[$name] instanceof $name . "_DL_Extender");
1163 1164
     }
1164 1165
 
@@ -1166,8 +1167,8 @@  discard block
 block discarded – undo
1166 1167
      * @param $name
1167 1168
      * @param $obj
1168 1169
      */
1169
-    public function setExtender($name, $obj)
1170
-    {
1170
+    public function setExtender($name, $obj)
1171
+    {
1171 1172
         $this->extender[$name] = $obj;
1172 1173
     }
1173 1174
 
@@ -1179,13 +1180,13 @@  discard block
 block discarded – undo
1179 1180
      * @param bool $nop если экстендер не загружен, то загружать ли xNop
1180 1181
      * @return null|xNop
1181 1182
      */
1182
-    public function getExtender($name, $autoload = false, $nop = false)
1183
-    {
1183
+    public function getExtender($name, $autoload = false, $nop = false)
1184
+    {
1184 1185
         $out = null;
1185
-        if ((is_scalar($name) && $this->checkExtender($name)) || ($autoload && $this->_loadExtender($name))) {
1186
+        if ((is_scalar($name) && $this->checkExtender($name)) || ($autoload && $this->_loadExtender($name))) {
1186 1187
             $out = $this->extender[$name];
1187 1188
         }
1188
-        if ($nop && is_null($out)) {
1189
+        if ($nop && is_null($out)) {
1189 1190
             $out = new xNop();
1190 1191
         }
1191 1192
 
@@ -1198,27 +1199,27 @@  discard block
 block discarded – undo
1198 1199
      * @param string $name name extender
1199 1200
      * @return boolean $flag status load extender
1200 1201
      */
1201
-    protected function _loadExtender($name)
1202
-    {
1202
+    protected function _loadExtender($name)
1203
+    {
1203 1204
         $this->debug->debug('Load Extender ' . $this->debug->dumpData($name), 'LoadExtender', 2);
1204 1205
         $flag = false;
1205 1206
 
1206 1207
         $classname = ($name != '') ? $name . "_DL_Extender" : "";
1207
-        if ($classname != '' && isset($this->extender[$name]) && $this->extender[$name] instanceof $classname) {
1208
+        if ($classname != '' && isset($this->extender[$name]) && $this->extender[$name] instanceof $classname) {
1208 1209
             $flag = true;
1209 1210
 
1210
-        } else {
1211
-            if (!class_exists($classname, false) && $classname != '') {
1212
-                if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) {
1211
+        } else {
1212
+            if (!class_exists($classname, false) && $classname != '') {
1213
+                if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) {
1213 1214
                     include_once(dirname(__FILE__) . "/extender/" . $name . ".extender.inc");
1214 1215
                 }
1215 1216
             }
1216
-            if (class_exists($classname, false) && $classname != '') {
1217
+            if (class_exists($classname, false) && $classname != '') {
1217 1218
                 $this->extender[$name] = new $classname($this, $name);
1218 1219
                 $flag = true;
1219 1220
             }
1220 1221
         }
1221
-        if (!$flag) {
1222
+        if (!$flag) {
1222 1223
             $this->debug->debug("Error load Extender " . $this->debug->dumpData($name));
1223 1224
         }
1224 1225
         $this->debug->debugEnd('LoadExtender');
@@ -1236,16 +1237,16 @@  discard block
 block discarded – undo
1236 1237
      * @param mixed $IDs список id документов по которым необходима выборка
1237 1238
      * @return array очищенный массив
1238 1239
      */
1239
-    public function setIDs($IDs)
1240
-    {
1240
+    public function setIDs($IDs)
1241
+    {
1241 1242
         $this->debug->debug('set ID list ' . $this->debug->dumpData($IDs), 'setIDs', 2);
1242 1243
         $IDs = $this->cleanIDs($IDs);
1243 1244
         $type = $this->getCFGDef('idType', 'parents');
1244 1245
         $depth = $this->getCFGDef('depth', '');
1245
-        if ($type == 'parents' && $depth > 0) {
1246
+        if ($type == 'parents' && $depth > 0) {
1246 1247
             $tmp = $IDs;
1247
-            do {
1248
-                if (count($tmp) > 0) {
1248
+            do {
1249
+                if (count($tmp) > 0) {
1249 1250
                     $tmp = $this->getChildrenFolder($tmp);
1250 1251
                     $IDs = array_merge($IDs, $tmp);
1251 1252
                 }
@@ -1259,8 +1260,8 @@  discard block
 block discarded – undo
1259 1260
     /**
1260 1261
      * @return int
1261 1262
      */
1262
-    public function getIDs()
1263
-    {
1263
+    public function getIDs()
1264
+    {
1264 1265
         return $this->IDs;
1265 1266
     }
1266 1267
 
@@ -1271,17 +1272,18 @@  discard block
 block discarded – undo
1271 1272
      * @param string $sep разделитель
1272 1273
      * @return array очищенный массив с данными
1273 1274
      */
1274
-    public function cleanIDs($IDs, $sep = ',')
1275
-    {
1275
+    public function cleanIDs($IDs, $sep = ',')
1276
+    {
1276 1277
         $this->debug->debug('clean IDs ' . $this->debug->dumpData($IDs) . ' with separator ' . $this->debug->dumpData($sep),
1277 1278
             'cleanIDs', 2);
1278 1279
         $out = array();
1279
-        if (!is_array($IDs)) {
1280
+        if (!is_array($IDs)) {
1280 1281
             $IDs = explode($sep, $IDs);
1281 1282
         }
1282
-        foreach ($IDs as $item) {
1283
+        foreach ($IDs as $item) {
1283 1284
             $item = trim($item);
1284
-            if (is_numeric($item) && (int)$item >= 0) { //Fix 0xfffffffff
1285
+            if (is_numeric($item) && (int)$item >= 0) {
1286
+//Fix 0xfffffffff
1285 1287
                 $out[] = (int)$item;
1286 1288
             }
1287 1289
         }
@@ -1295,8 +1297,8 @@  discard block
 block discarded – undo
1295 1297
      * Проверка массива с id-шниками документов для выборки
1296 1298
      * @return boolean пригодны ли данные для дальнейшего использования
1297 1299
      */
1298
-    protected function checkIDs()
1299
-    {
1300
+    protected function checkIDs()
1301
+    {
1300 1302
         return (is_array($this->IDs) && count($this->IDs) > 0) ? true : false;
1301 1303
     }
1302 1304
 
@@ -1308,11 +1310,11 @@  discard block
 block discarded – undo
1308 1310
      * @global array $_docs all documents
1309 1311
      * @return array all field values
1310 1312
      */
1311
-    public function getOneField($userField, $uniq = false)
1312
-    {
1313
+    public function getOneField($userField, $uniq = false)
1314
+    {
1313 1315
         $out = array();
1314
-        foreach ($this->_docs as $doc => $val) {
1315
-            if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) {
1316
+        foreach ($this->_docs as $doc => $val) {
1317
+            if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) {
1316 1318
                 $out[$doc] = $val[$userField];
1317 1319
             }
1318 1320
         }
@@ -1323,8 +1325,8 @@  discard block
 block discarded – undo
1323 1325
     /**
1324 1326
      * @return DLCollection
1325 1327
      */
1326
-    public function docsCollection()
1327
-    {
1328
+    public function docsCollection()
1329
+    {
1328 1330
         return new DLCollection($this->modx, $this->_docs);
1329 1331
     }
1330 1332
 
@@ -1352,10 +1354,10 @@  discard block
 block discarded – undo
1352 1354
      * @param string $group
1353 1355
      * @return string
1354 1356
      */
1355
-    protected function getGroupSQL($group = '')
1356
-    {
1357
+    protected function getGroupSQL($group = '')
1358
+    {
1357 1359
         $out = '';
1358
-        if ($group != '') {
1360
+        if ($group != '') {
1359 1361
             $out = 'GROUP BY ' . $group;
1360 1362
         }
1361 1363
 
@@ -1374,12 +1376,12 @@  discard block
 block discarded – undo
1374 1376
      *
1375 1377
      * @return string Order by for SQL
1376 1378
      */
1377
-    protected function SortOrderSQL($sortName, $orderDef = 'DESC')
1378
-    {
1379
+    protected function SortOrderSQL($sortName, $orderDef = 'DESC')
1380
+    {
1379 1381
         $this->debug->debug('', 'sortORDER', 2);
1380 1382
 
1381 1383
         $sort = '';
1382
-        switch ($this->getCFGDef('sortType', '')) {
1384
+        switch ($this->getCFGDef('sortType', '')) {
1383 1385
             case 'none':
1384 1386
                 break;
1385 1387
             case 'doclist':
@@ -1390,10 +1392,10 @@  discard block
 block discarded – undo
1390 1392
                 break;
1391 1393
             default:
1392 1394
                 $out = array('orderBy' => '', 'order' => '', 'sortBy' => '');
1393
-                if (($tmp = $this->getCFGDef('orderBy', '')) != '') {
1395
+                if (($tmp = $this->getCFGDef('orderBy', '')) != '') {
1394 1396
                     $out['orderBy'] = $tmp;
1395
-                } else {
1396
-                    switch (true) {
1397
+                } else {
1398
+                    switch (true) {
1397 1399
                         case ('' != ($tmp = $this->getCFGDef('sortDir', ''))): //higher priority than order
1398 1400
                             $out['order'] = $tmp;
1399 1401
                         // no break
@@ -1401,7 +1403,7 @@  discard block
 block discarded – undo
1401 1403
                             $out['order'] = $tmp;
1402 1404
                         // no break
1403 1405
                     }
1404
-                    if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1406
+                    if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1405 1407
                         $out['order'] = $orderDef; //Default
1406 1408
                     }
1407 1409
 
@@ -1422,30 +1424,30 @@  discard block
 block discarded – undo
1422 1424
      *
1423 1425
      * @return string LIMIT вставка в SQL запрос
1424 1426
      */
1425
-    protected function LimitSQL($limit = 0, $offset = 0)
1426
-    {
1427
+    protected function LimitSQL($limit = 0, $offset = 0)
1428
+    {
1427 1429
         $this->debug->debug('', 'limitSQL', 2);
1428 1430
         $ret = '';
1429
-        if ($limit == 0) {
1431
+        if ($limit == 0) {
1430 1432
             $limit = $this->getCFGDef('display', 0);
1431 1433
         }
1432 1434
         $maxDocs = $this->getCFGDef('maxDocs',0);
1433
-        if ($maxDocs > 0 && $limit > $maxDocs) {
1435
+        if ($maxDocs > 0 && $limit > $maxDocs) {
1434 1436
             $limit = $maxDocs;
1435 1437
         }
1436
-        if ($offset == 0) {
1438
+        if ($offset == 0) {
1437 1439
             $offset = $this->getCFGDef('offset', 0);
1438 1440
         }
1439 1441
         $offset += $this->getCFGDef('start', 0);
1440 1442
         $total = $this->getCFGDef('total', 0);
1441
-        if ($limit < ($total - $limit)) {
1443
+        if ($limit < ($total - $limit)) {
1442 1444
             $limit = $total - $offset;
1443 1445
         }
1444 1446
 
1445
-        if ($limit != 0) {
1447
+        if ($limit != 0) {
1446 1448
             $ret = "LIMIT " . (int)$offset . "," . (int)$limit;
1447
-        } else {
1448
-            if ($offset != 0) {
1449
+        } else {
1450
+            if ($offset != 0) {
1449 1451
                 /**
1450 1452
                  * 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
1451 1453
                  * @see http://dev.mysql.com/doc/refman/5.0/en/select.html
@@ -1465,8 +1467,8 @@  discard block
 block discarded – undo
1465 1467
      * @param string $charset
1466 1468
      * @return string Clear string
1467 1469
      */
1468
-    public function sanitarData($data, $charset = 'UTF-8')
1469
-    {
1470
+    public function sanitarData($data, $charset = 'UTF-8')
1471
+    {
1470 1472
         return APIHelpers::sanitarTag($data, $charset);
1471 1473
     }
1472 1474
 
@@ -1477,8 +1479,8 @@  discard block
 block discarded – undo
1477 1479
      * @param string $parentField default name parent field
1478 1480
      * @return array
1479 1481
      */
1480
-    public function treeBuild($idField = 'id', $parentField = 'parent')
1481
-    {
1482
+    public function treeBuild($idField = 'id', $parentField = 'parent')
1483
+    {
1482 1484
         return $this->_treeBuild($this->_docs, $this->getCFGDef('idField', $idField),
1483 1485
             $this->getCFGDef('parentField', $parentField));
1484 1486
     }
@@ -1491,16 +1493,16 @@  discard block
 block discarded – undo
1491 1493
      * @param string $pidName name parent field in associative data array
1492 1494
      * @return array
1493 1495
      */
1494
-    private function _treeBuild($data, $idName, $pidName)
1495
-    {
1496
+    private function _treeBuild($data, $idName, $pidName)
1497
+    {
1496 1498
         $children = array(); // children of each ID
1497 1499
         $ids = array();
1498
-        foreach ($data as $i => $r) {
1500
+        foreach ($data as $i => $r) {
1499 1501
             $row =& $data[$i];
1500 1502
             $id = $row[$idName];
1501 1503
             $pid = $row[$pidName];
1502 1504
             $children[$pid][$id] =& $row;
1503
-            if (!isset($children[$id])) {
1505
+            if (!isset($children[$id])) {
1504 1506
                 $children[$id] = array();
1505 1507
             }
1506 1508
             $row['#childNodes'] =& $children[$id];
@@ -1508,9 +1510,9 @@  discard block
 block discarded – undo
1508 1510
         }
1509 1511
         // Root elements are elements with non-found PIDs.
1510 1512
         $this->_tree = array();
1511
-        foreach ($data as $i => $r) {
1513
+        foreach ($data as $i => $r) {
1512 1514
             $row =& $data[$i];
1513
-            if (!isset($ids[$row[$pidName]])) {
1515
+            if (!isset($ids[$row[$pidName]])) {
1514 1516
                 $this->_tree[$row[$idName]] = $row;
1515 1517
             }
1516 1518
         }
@@ -1524,10 +1526,10 @@  discard block
 block discarded – undo
1524 1526
      *
1525 1527
      * @return string PrimaryKey основной таблицы
1526 1528
      */
1527
-    public function getPK()
1528
-    {
1529
+    public function getPK()
1530
+    {
1529 1531
         $idField = isset($this->idField) ? $this->idField : 'id';
1530
-        if (!empty($this->alias)) {
1532
+        if (!empty($this->alias)) {
1531 1533
             $idField = $this->alias . '.' . $idField;
1532 1534
         }
1533 1535
 
@@ -1539,10 +1541,10 @@  discard block
 block discarded – undo
1539 1541
      * По умолчанию это parent. Переопределить можно в контроллере присвоив другое значение переменной parentField
1540 1542
      * @return string Parent Key основной таблицы
1541 1543
      */
1542
-    public function getParentField()
1543
-    {
1544
+    public function getParentField()
1545
+    {
1544 1546
         $parentField = isset($this->parentField) ? $this->parentField : '';
1545
-        if (!empty($parentField) && !empty($this->alias)) {
1547
+        if (!empty($parentField) && !empty($this->alias)) {
1546 1548
             $parentField = $this->alias . '.' . $parentField;
1547 1549
         }
1548 1550
 
@@ -1556,31 +1558,31 @@  discard block
 block discarded – undo
1556 1558
      * @param string $filter_string строка со всеми фильтрами
1557 1559
      * @return mixed результат разбора фильтров
1558 1560
      */
1559
-    protected function getFilters($filter_string)
1560
-    {
1561
+    protected function getFilters($filter_string)
1562
+    {
1561 1563
         $this->debug->debug("getFilters: " . $this->debug->dumpData($filter_string), 'getFilter', 1);
1562 1564
         // the filter parameter tells us, which filters can be used in this query
1563 1565
         $filter_string = trim($filter_string, ' ;');
1564
-        if (!$filter_string) {
1566
+        if (!$filter_string) {
1565 1567
             return;
1566 1568
         }
1567 1569
         $output = array('join' => '', 'where' => '');
1568 1570
         $logic_op_found = false;
1569 1571
         $joins = $wheres = array();
1570
-        foreach ($this->_logic_ops as $op => $sql) {
1571
-            if (strpos($filter_string, $op) === 0) {
1572
+        foreach ($this->_logic_ops as $op => $sql) {
1573
+            if (strpos($filter_string, $op) === 0) {
1572 1574
                 $logic_op_found = true;
1573 1575
                 $subfilters = mb_substr($filter_string, strlen($op) + 1, mb_strlen($filter_string, "UTF-8"), "UTF-8");
1574 1576
                 $subfilters = $this->smartSplit($subfilters);
1575
-                foreach ($subfilters as $subfilter) {
1577
+                foreach ($subfilters as $subfilter) {
1576 1578
                     $subfilter = $this->getFilters(trim($subfilter));
1577
-                    if (!$subfilter) {
1579
+                    if (!$subfilter) {
1578 1580
                         continue;
1579 1581
                     }
1580
-                    if ($subfilter['join']) {
1582
+                    if ($subfilter['join']) {
1581 1583
                         $joins[] = $subfilter['join'];
1582 1584
                     }
1583
-                    if ($subfilter['where']) {
1585
+                    if ($subfilter['where']) {
1584 1586
                         $wheres[] = $subfilter['where'];
1585 1587
                     }
1586 1588
                 }
@@ -1589,12 +1591,12 @@  discard block
 block discarded – undo
1589 1591
             }
1590 1592
         }
1591 1593
 
1592
-        if (!$logic_op_found) {
1594
+        if (!$logic_op_found) {
1593 1595
             $filter = $this->loadFilter($filter_string);
1594
-            if (!$filter) {
1596
+            if (!$filter) {
1595 1597
                 $this->debug->warning('Error while loading DocLister filter "' . $this->debug->dumpData($filter_string) . '": check syntax!');
1596 1598
                 $output = false;
1597
-            } else {
1599
+            } else {
1598 1600
                 $output['join'] = $filter->get_join();
1599 1601
                 $output['where'] = $filter->get_where();
1600 1602
             }
@@ -1607,16 +1609,16 @@  discard block
 block discarded – undo
1607 1609
     /**
1608 1610
      * @return mixed
1609 1611
      */
1610
-    public function filtersWhere()
1611
-    {
1612
+    public function filtersWhere()
1613
+    {
1612 1614
         return APIHelpers::getkey($this->_filters, 'where', '');
1613 1615
     }
1614 1616
 
1615 1617
     /**
1616 1618
      * @return mixed
1617 1619
      */
1618
-    public function filtersJoin()
1619
-    {
1620
+    public function filtersJoin()
1621
+    {
1620 1622
         return APIHelpers::getkey($this->_filters, 'join', '');
1621 1623
     }
1622 1624
 
@@ -1627,10 +1629,10 @@  discard block
 block discarded – undo
1627 1629
      * @param $type string тип фильтрации
1628 1630
      * @return string имя поля с учетом приведения типа
1629 1631
      */
1630
-    public function changeSortType($field, $type)
1631
-    {
1632
+    public function changeSortType($field, $type)
1633
+    {
1632 1634
         $type = trim($type);
1633
-        switch (strtoupper($type)) {
1635
+        switch (strtoupper($type)) {
1634 1636
             case 'DECIMAL':
1635 1637
                 $field = 'CAST(' . $field . ' as DECIMAL(10,2))';
1636 1638
                 break;
@@ -1656,14 +1658,14 @@  discard block
 block discarded – undo
1656 1658
      * @param string $filter срока с параметрами фильтрации
1657 1659
      * @return bool
1658 1660
      */
1659
-    protected function loadFilter($filter)
1660
-    {
1661
+    protected function loadFilter($filter)
1662
+    {
1661 1663
         $this->debug->debug('Load filter ' . $this->debug->dumpData($filter), 'loadFilter', 2);
1662 1664
         $out = false;
1663 1665
         $fltr_params = explode(':', $filter, 2);
1664 1666
         $fltr = APIHelpers::getkey($fltr_params, 0, null);
1665 1667
         // check if the filter is implemented
1666
-        if (!is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1668
+        if (!is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1667 1669
             require_once dirname(__FILE__) . '/filter/' . $fltr . '.filter.php';
1668 1670
             /**
1669 1671
              * @var tv_DL_filter|content_DL_filter $fltr_class
@@ -1671,12 +1673,12 @@  discard block
 block discarded – undo
1671 1673
             $fltr_class = $fltr . '_DL_filter';
1672 1674
             $this->totalFilters++;
1673 1675
             $fltr_obj = new $fltr_class();
1674
-            if ($fltr_obj->init($this, $filter)) {
1676
+            if ($fltr_obj->init($this, $filter)) {
1675 1677
                 $out = $fltr_obj;
1676
-            } else {
1678
+            } else {
1677 1679
                 $this->debug->error("Wrong filter parameter: '{$this->debug->dumpData($filter)}'", 'Filter');
1678 1680
             }
1679
-        } else {
1681
+        } else {
1680 1682
             $this->debug->error("Error load Filter: '{$this->debug->dumpData($filter)}'", 'Filter');
1681 1683
         }
1682 1684
         $this->debug->debugEnd("loadFilter");
@@ -1688,8 +1690,8 @@  discard block
 block discarded – undo
1688 1690
      * Общее число фильтров
1689 1691
      * @return int
1690 1692
      */
1691
-    public function getCountFilters()
1692
-    {
1693
+    public function getCountFilters()
1694
+    {
1693 1695
         return (int)$this->totalFilters;
1694 1696
     }
1695 1697
 
@@ -1697,8 +1699,8 @@  discard block
 block discarded – undo
1697 1699
      * Выполнить SQL запрос
1698 1700
      * @param string $q SQL запрос
1699 1701
      */
1700
-    public function dbQuery($q)
1701
-    {
1702
+    public function dbQuery($q)
1703
+    {
1702 1704
         $this->debug->debug($q, "query", 1, 'sql');
1703 1705
         $out = $this->modx->db->query($q);
1704 1706
         $this->debug->debugEnd("query");
@@ -1716,8 +1718,8 @@  discard block
 block discarded – undo
1716 1718
      * @param string $tpl шаблон подстановки значения в SQL запрос
1717 1719
      * @return string строка для подстановки в SQL запрос
1718 1720
      */
1719
-    public function LikeEscape($field, $value, $escape = '=', $tpl = '%[+value+]%')
1720
-    {
1721
+    public function LikeEscape($field, $value, $escape = '=', $tpl = '%[+value+]%')
1722
+    {
1721 1723
         return sqlHelper::LikeEscape($this->modx, $field, $value, $escape, $tpl);
1722 1724
     }
1723 1725
 
@@ -1725,8 +1727,8 @@  discard block
 block discarded – undo
1725 1727
      * Получение REQUEST_URI без GET-ключа с
1726 1728
      * @return string
1727 1729
      */
1728
-    public function getRequest()
1729
-    {
1730
+    public function getRequest()
1731
+    {
1730 1732
         $URL = null;
1731 1733
         parse_str(parse_url(MODX_SITE_URL . $_SERVER['REQUEST_URI'], PHP_URL_QUERY), $URL);
1732 1734
 
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.
assets/snippets/DocLister/lib/DLphx.class.php 3 patches
Braces   +119 added lines, -117 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * Class DLphx
17 17
  */
18
-class DLphx
19
-{
18
+class DLphx
19
+{
20 20
     public $placeholders = array();
21 21
     public $name = 'PHx';
22 22
     public $version = '2.2.0';
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
      * @param int $debug
44 44
      * @param int $maxpass
45 45
      */
46
-    public function __construct($debug = 0, $maxpass = 50)
47
-    {
46
+    public function __construct($debug = 0, $maxpass = 50)
47
+    {
48 48
         global $modx;
49 49
         $this->user["mgrid"] = isset($_SESSION['mgrInternalKey']) ? intval($_SESSION['mgrInternalKey']) : 0;
50 50
         $this->user["usrid"] = isset($_SESSION['webInternalKey']) ? intval($_SESSION['webInternalKey']) : 0;
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
         $this->maxPasses = ($maxpass != '') ? $maxpass : 50;
56 56
 
57 57
         $modx->setPlaceholder("phx", "&_PHX_INTERNAL_&");
58
-        if (function_exists('mb_internal_encoding')) {
58
+        if (function_exists('mb_internal_encoding')) {
59 59
             mb_internal_encoding($modx->config['modx_charset']);
60 60
         }
61 61
     }
62 62
 
63 63
     // Plugin event hook for MODx
64
-    public function OnParseDocument()
65
-    {
64
+    public function OnParseDocument()
65
+    {
66 66
         global $modx;
67 67
         // Get document output from MODx
68 68
         $template = $modx->documentOutput;
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
      * @param string $template
78 78
      * @return mixed|string
79 79
      */
80
-    public function Parse($template = '')
81
-    {
80
+    public function Parse($template = '')
81
+    {
82 82
         global $modx;
83 83
         // If we already reached max passes don't get at it again.
84
-        if ($this->curPass == $this->maxPasses) {
84
+        if ($this->curPass == $this->maxPasses) {
85 85
             return $template;
86 86
         }
87 87
         // Set template pre-process hash
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         $template = $this->ParseValues($template);
93 93
         // clean up unused placeholders that have modifiers attached (MODx can't clean them)
94 94
         preg_match_all('~(?:=`[^`@]*?)(\[\+([^:\+\[\]]+)([^\[\]]*?)\+\])~s', $template, $matches);
95
-        if ($matches[0]) {
95
+        if ($matches[0]) {
96 96
             $template = str_replace($matches[1], '', $template);
97 97
             $this->Log("Cleaning unsolved tags: \n" . implode("\n", $matches[2]));
98 98
         }
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
         // Set template post-process hash
102 102
         $et = md5($template);
103 103
         // If template has changed, parse it once more...
104
-        if ($st != $et) {
104
+        if ($st != $et) {
105 105
             $template = $this->Parse($template);
106 106
         }
107 107
         // Write an event log if debugging is enabled and there is something to log
108
-        if ($this->debug && $this->debugLog) {
108
+        if ($this->debug && $this->debugLog) {
109 109
             $modx->logEvent($this->curPass, 1, $this->createEventLog(), $this->name . ' ' . $this->version);
110 110
             $this->debugLog = false;
111 111
         }
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
      * @param string $template
120 120
      * @return mixed|string
121 121
      */
122
-    public function ParseValues($template = '')
123
-    {
122
+    public function ParseValues($template = '')
123
+    {
124 124
         global $modx;
125 125
 
126 126
         $this->curPass = $this->curPass + 1;
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
         $this->LogPass();
130 130
 
131 131
         // MODX Chunks
132
-        if (preg_match_all('~(?<!(?:then|else)=`){{([^:\+{}]+)([^{}]*?)}}~s', $template, $matches)) {
132
+        if (preg_match_all('~(?<!(?:then|else)=`){{([^:\+{}]+)([^{}]*?)}}~s', $template, $matches)) {
133 133
             $this->Log('MODX Chunks -> Merging all chunk tags');
134 134
             $count = count($matches[0]);
135 135
             $var_search = array();
136 136
             $var_replace = array();
137
-            for ($i = 0; $i < $count; $i++) {
137
+            for ($i = 0; $i < $count; $i++) {
138 138
                 $var_search[] = $matches[0][$i];
139 139
                 $input = $matches[1][$i];
140 140
                 $this->Log('MODX Chunk: ' . $input);
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 
147 147
         // MODx Snippets
148 148
         //if ( preg_match_all('~\[(\[|!)([^\[]*?)(!|\])\]~s',$template, $matches)) {
149
-        if (preg_match_all('~(?<!(?:then|else)=`)\[(\[)([^\[]*?)(\])\]~s', $template, $matches)) {
149
+        if (preg_match_all('~(?<!(?:then|else)=`)\[(\[)([^\[]*?)(\])\]~s', $template, $matches)) {
150 150
             $count = count($matches[0]);
151 151
             $var_search = array();
152 152
             $var_replace = array();
153 153
 
154 154
             // for each detected snippet
155
-            for ($i = 0; $i < $count; $i++) {
155
+            for ($i = 0; $i < $count; $i++) {
156 156
                 $snippet = $matches[2][$i]; // snippet call
157 157
                 $this->Log("MODx Snippet -> " . $snippet);
158 158
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         }
169 169
 
170 170
         // PHx / MODx Tags
171
-        if (preg_match_all('~\[(\+|\*|\()([^:\+\[\]]+)([^\[\]]*?)(\1|\))\]~s', $template, $matches)) {
171
+        if (preg_match_all('~\[(\+|\*|\()([^:\+\[\]]+)([^\[\]]*?)(\1|\))\]~s', $template, $matches)) {
172 172
 
173 173
             //$matches[0] // Complete string that's need to be replaced
174 174
             //$matches[1] // Type
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
             $count = count($matches[0]);
180 180
             $var_search = array();
181 181
             $var_replace = array();
182
-            for ($i = 0; $i < $count; $i++) {
182
+            for ($i = 0; $i < $count; $i++) {
183 183
                 $input = $matches[2][$i];
184 184
                 $modifiers = $matches[3][$i];
185 185
                 $var_search[] = $matches[0][$i];
186
-                switch ($matches[1][$i]) {
186
+                switch ($matches[1][$i]) {
187 187
                     // Document / Template Variable eXtended
188 188
                     case "*":
189 189
                         $this->Log("MODx TV/DV: " . $input);
@@ -202,10 +202,10 @@  discard block
 block discarded – undo
202 202
                         // Check if placeholder is set
203 203
                         if (!array_key_exists($input, $this->placeholders) && !array_key_exists($input,
204 204
                                 $modx->placeholders)
205
-                        ) {
205
+                        ) {
206 206
                             // not set so try again later.
207 207
                             $input = '';
208
-                        } else {
208
+                        } else {
209 209
                             // is set, get value and run filter
210 210
                             $input = $this->getPHxVariable($input);
211 211
                         }
@@ -219,11 +219,11 @@  discard block
 block discarded – undo
219 219
         $et = md5($template); // Post-process template hash
220 220
 
221 221
         // Log an event if this was the maximum pass
222
-        if ($this->curPass == $this->maxPasses) {
222
+        if ($this->curPass == $this->maxPasses) {
223 223
             $this->Log("Max passes reached. infinite loop protection so exiting.\n If you need the extra passes set the max passes to the highest count of nested tags in your template.");
224 224
         }
225 225
         // If this pass is not at maximum passes and the template hash is not the same, get at it again.
226
-        if (($this->curPass < $this->maxPasses) && ($st != $et)) {
226
+        if (($this->curPass < $this->maxPasses) && ($st != $et)) {
227 227
             $template = $this->ParseValues($template);
228 228
         }
229 229
 
@@ -236,23 +236,23 @@  discard block
 block discarded – undo
236 236
      * @param $modifiers
237 237
      * @return mixed|null|string
238 238
      */
239
-    public function Filter($input, $modifiers)
240
-    {
239
+    public function Filter($input, $modifiers)
240
+    {
241 241
         global $modx;
242 242
         $output = $input;
243 243
         $this->Log("  |--- Input = '" . $output . "'");
244
-        if (preg_match_all('~:([^:=]+)(?:=`(.*?)`(?=:[^:=]+|$))?~s', $modifiers, $matches)) {
244
+        if (preg_match_all('~:([^:=]+)(?:=`(.*?)`(?=:[^:=]+|$))?~s', $modifiers, $matches)) {
245 245
             $modifier_cmd = $matches[1]; // modifier command
246 246
             $modifier_value = $matches[2]; // modifier value
247 247
             $count = count($modifier_cmd);
248 248
             $condition = array();
249
-            for ($i = 0; $i < $count; $i++) {
249
+            for ($i = 0; $i < $count; $i++) {
250 250
                 $output = trim($output);
251 251
                 $this->Log("  |--- Modifier = '" . $modifier_cmd[$i] . "'");
252
-                if ($modifier_value[$i] != '') {
252
+                if ($modifier_value[$i] != '') {
253 253
                     $this->Log("  |--- Options = '" . $modifier_value[$i] . "'");
254 254
                 }
255
-                switch ($modifier_cmd[$i]) {
255
+                switch ($modifier_cmd[$i]) {
256 256
                     #####  Conditional Modifiers
257 257
                     case "input":
258 258
                     case "if":
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
                     case "ir":
295 295
                     case "memberof":
296 296
                     case "mo": // Is Member Of  (same as inrole but this one can be stringed as a conditional)
297
-                        if ($output == "&_PHX_INTERNAL_&") {
297
+                        if ($output == "&_PHX_INTERNAL_&") {
298 298
                             $output = $this->user["id"];
299 299
                         }
300 300
                         $grps = ($this->strlen($modifier_value[$i]) > 0) ? explode(",", $modifier_value[$i]) : array();
@@ -309,23 +309,23 @@  discard block
 block discarded – undo
309 309
                     case "show":
310 310
                         $conditional = implode(' ', $condition);
311 311
                         $isvalid = intval(eval("return (" . $conditional . ");"));
312
-                        if (!$isvalid) {
312
+                        if (!$isvalid) {
313 313
                             $output = null;
314 314
                         }
315 315
                         break;
316 316
                     case "then":
317 317
                         $conditional = implode(' ', $condition);
318 318
                         $isvalid = intval(eval("return (" . $conditional . ");"));
319
-                        if ($isvalid) {
319
+                        if ($isvalid) {
320 320
                             $output = $modifier_value[$i];
321
-                        } else {
321
+                        } else {
322 322
                             $output = null;
323 323
                         }
324 324
                         break;
325 325
                     case "else":
326 326
                         $conditional = implode(' ', $condition);
327 327
                         $isvalid = intval(eval("return (" . $conditional . ");"));
328
-                        if (!$isvalid) {
328
+                        if (!$isvalid) {
329 329
                             $output = $modifier_value[$i];
330 330
                         }
331 331
                         break;
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
                         $raw = explode("&", $modifier_value[$i]);
334 334
                         $map = array();
335 335
                         $count = count($raw);
336
-                        for ($m = 0; $m < $count; $m++) {
336
+                        for ($m = 0; $m < $count; $m++) {
337 337
                             $mi = explode("=", $raw[$m]);
338 338
                             $map[$mi[0]] = $mi[1];
339 339
                         }
@@ -414,13 +414,13 @@  discard block
 block discarded – undo
414 414
                         $output = eval("return " . $filter . ";");
415 415
                         break;
416 416
                     case "isnotempty":
417
-                        if (!empty($output)) {
417
+                        if (!empty($output)) {
418 418
                             $output = $modifier_value[$i];
419 419
                         }
420 420
                         break;
421 421
                     case "isempty":
422 422
                     case "ifempty":
423
-                        if (empty($output)) {
423
+                        if (empty($output)) {
424 424
                             $output = $modifier_value[$i];
425 425
                         }
426 426
                         break;
@@ -432,12 +432,12 @@  discard block
 block discarded – undo
432 432
                         break;
433 433
                     case "set":
434 434
                         $c = $i + 1;
435
-                        if ($count > $c && $modifier_cmd[$c] == "value") {
435
+                        if ($count > $c && $modifier_cmd[$c] == "value") {
436 436
                             $output = preg_replace("~([^a-zA-Z0-9])~", "", $modifier_value[$i]);
437 437
                         }
438 438
                         break;
439 439
                     case "value":
440
-                        if ($i > 0 && $modifier_cmd[$i - 1] == "set") {
440
+                        if ($i > 0 && $modifier_cmd[$i - 1] == "set") {
441 441
                             $modx->SetPlaceholder("phx." . $output, $modifier_value[$i]);
442 442
                         }
443 443
                         $output = null;
@@ -446,13 +446,13 @@  discard block
 block discarded – undo
446 446
                         $output = md5($output);
447 447
                         break;
448 448
                     case "userinfo":
449
-                        if ($output == "&_PHX_INTERNAL_&") {
449
+                        if ($output == "&_PHX_INTERNAL_&") {
450 450
                             $output = $this->user["id"];
451 451
                         }
452 452
                         $output = $this->ModUser($output, $modifier_value[$i]);
453 453
                         break;
454 454
                     case "inrole": // deprecated
455
-                        if ($output == "&_PHX_INTERNAL_&") {
455
+                        if ($output == "&_PHX_INTERNAL_&") {
456 456
                             $output = $this->user["id"];
457 457
                         }
458 458
                         $grps = ($this->strlen($modifier_value[$i]) > 0) ? explode(",", $modifier_value[$i]) : array();
@@ -464,19 +464,21 @@  discard block
 block discarded – undo
464 464
                         $snippet = '';
465 465
                         // modified by Anton Kuzmin (23.06.2010) //
466 466
                         $snippetName = 'phx:' . $modifier_cmd[$i];
467
-                        if (isset($modx->snippetCache[$snippetName])) {
467
+                        if (isset($modx->snippetCache[$snippetName])) {
468 468
                             $snippet = $modx->snippetCache[$snippetName];
469
-                        } else { // not in cache so let's check the db
469
+                        } else {
470
+// not in cache so let's check the db
470 471
                             $sql = "SELECT snippet FROM " . $modx->getFullTableName("site_snippets") . " WHERE " . $modx->getFullTableName("site_snippets") . ".name='" . $modx->db->escape($snippetName) . "';";
471 472
                             $result = $modx->dbQuery($sql);
472
-                            if ($modx->recordCount($result) == 1) {
473
+                            if ($modx->recordCount($result) == 1) {
473 474
                                 $row = $modx->fetchRow($result);
474 475
                                 $snippet = $modx->snippetCache[$row['name']] = $row['snippet'];
475 476
                                 $this->Log("  |--- DB -> Custom Modifier");
476
-                            } else {
477
-                                if ($modx->recordCount($result) == 0) { // If snippet not found, look in the modifiers folder
477
+                            } else {
478
+                                if ($modx->recordCount($result) == 0) {
479
+// If snippet not found, look in the modifiers folder
478 480
                                     $filename = $modx->config['rb_base_dir'] . 'plugins/phx/modifiers/' . $modifier_cmd[$i] . '.phx.php';
479
-                                    if (@file_exists($filename)) {
481
+                                    if (@file_exists($filename)) {
480 482
                                         $file_contents = @file_get_contents($filename);
481 483
                                         $file_contents = str_replace('<' . '?php', '', $file_contents);
482 484
                                         $file_contents = str_replace('?' . '>', '', $file_contents);
@@ -484,7 +486,7 @@  discard block
 block discarded – undo
484 486
                                         $snippet = $modx->snippetCache[$snippetName] = $file_contents;
485 487
                                         $modx->snippetCache[$snippetName . 'Props'] = '';
486 488
                                         $this->Log("  |--- File ($filename) -> Custom Modifier");
487
-                                    } else {
489
+                                    } else {
488 490
                                         $this->Log("  |--- PHX Error:  {$modifier_cmd[$i]} could not be found");
489 491
                                     }
490 492
                                 }
@@ -493,19 +495,19 @@  discard block
 block discarded – undo
493 495
                         $cm = $snippet;
494 496
                         // end //
495 497
 
496
-                        if (!empty($cm)) {
498
+                        if (!empty($cm)) {
497 499
                             ob_start();
498 500
                             $options = $modifier_value[$i];
499 501
                             $custom = eval($cm);
500 502
                             $msg = ob_get_contents();
501 503
                             $output = $msg . $custom;
502 504
                             ob_end_clean();
503
-                        } else {
505
+                        } else {
504 506
                             $output = '';
505 507
                         }
506 508
                         break;
507 509
                 }
508
-                if (count($condition)) {
510
+                if (count($condition)) {
509 511
                     $this->Log("  |--- Condition = '" . $condition[count($condition) - 1] . "'");
510 512
                 }
511 513
                 $this->Log("  |--- Output = '" . $output . "'");
@@ -519,9 +521,9 @@  discard block
 block discarded – undo
519 521
     /**
520 522
      * @return string
521 523
      */
522
-    public function createEventLog()
523
-    {
524
-        if (!empty($this->console)) {
524
+    public function createEventLog()
525
+    {
526
+        if (!empty($this->console)) {
525 527
             $console = implode("\n", $this->console);
526 528
             $this->console = array();
527 529
 
@@ -534,8 +536,8 @@  discard block
 block discarded – undo
534 536
      * @param $string
535 537
      * @return array|mixed|string
536 538
      */
537
-    public function LogClean($string)
538
-    {
539
+    public function LogClean($string)
540
+    {
539 541
         $string = preg_replace("/&amp;(#[0-9]+|[a-z]+);/i", "&$1;", $string);
540 542
         $string = APIHelpers::sanitarTag($string);
541 543
 
@@ -546,9 +548,9 @@  discard block
 block discarded – undo
546 548
     /**
547 549
      * @param $string
548 550
      */
549
-    public function Log($string)
550
-    {
551
-        if ($this->debug) {
551
+    public function Log($string)
552
+    {
553
+        if ($this->debug) {
552 554
             $this->debugLog = true;
553 555
             $this->console[] = (count($this->console) + 1 - $this->curPass) . " [" . strftime("%H:%M:%S",
554 556
                     time()) . "] " . $this->LogClean($string);
@@ -559,9 +561,9 @@  discard block
 block discarded – undo
559 561
     /**
560 562
      * @param $string
561 563
      */
562
-    public function LogSnippet($string)
563
-    {
564
-        if ($this->debug) {
564
+    public function LogSnippet($string)
565
+    {
566
+        if ($this->debug) {
565 567
             $this->debugLog = true;
566 568
             $this->console[] = (count($this->console) + 1 - $this->curPass) . " [" . strftime("%H:%M:%S",
567 569
                     time()) . "] " . "  |--- Returns: <div style='margin: 10px;'>" . $this->LogClean($string) . "</div>";
@@ -569,8 +571,8 @@  discard block
 block discarded – undo
569 571
     }
570 572
 
571 573
     // Log pass
572
-    public function LogPass()
573
-    {
574
+    public function LogPass()
575
+    {
574 576
         $this->console[] = "<div style='margin: 2px;margin-top: 5px;border-bottom: 1px solid black;'>Pass " . $this->curPass . "</div>";
575 577
     }
576 578
 
@@ -578,8 +580,8 @@  discard block
 block discarded – undo
578 580
     /**
579 581
      * @param $string
580 582
      */
581
-    public function LogSource($string)
582
-    {
583
+    public function LogSource($string)
584
+    {
583 585
         $this->console[] = "<div style='margin: 2px;margin-top: 5px;border-bottom: 1px solid black;'>Source:</div>" . $this->LogClean($string);
584 586
     }
585 587
 
@@ -591,17 +593,17 @@  discard block
 block discarded – undo
591 593
      * @param $field
592 594
      * @return mixed
593 595
      */
594
-    public function ModUser($userid, $field)
595
-    {
596
+    public function ModUser($userid, $field)
597
+    {
596 598
         global $modx;
597
-        if (!array_key_exists($userid, $this->cache["ui"])) {
598
-            if (intval($userid) < 0) {
599
+        if (!array_key_exists($userid, $this->cache["ui"])) {
600
+            if (intval($userid) < 0) {
599 601
                 $user = $modx->getWebUserInfo(-($userid));
600
-            } else {
602
+            } else {
601 603
                 $user = $modx->getUserInfo($userid);
602 604
             }
603 605
             $this->cache["ui"][$userid] = $user;
604
-        } else {
606
+        } else {
605 607
             $user = $this->cache["ui"][$userid];
606 608
         }
607 609
 
@@ -614,32 +616,32 @@  discard block
 block discarded – undo
614 616
      * @param array $groupNames
615 617
      * @return bool
616 618
      */
617
-    public function isMemberOfWebGroupByUserId($userid = 0, $groupNames = array())
618
-    {
619
+    public function isMemberOfWebGroupByUserId($userid = 0, $groupNames = array())
620
+    {
619 621
         global $modx;
620 622
 
621 623
         // if $groupNames is not an array return false
622
-        if (!is_array($groupNames)) {
624
+        if (!is_array($groupNames)) {
623 625
             return false;
624 626
         }
625 627
 
626 628
         // if the user id is a negative number make it positive
627
-        if (intval($userid) < 0) {
629
+        if (intval($userid) < 0) {
628 630
             $userid = -($userid);
629 631
         }
630 632
 
631 633
         // Creates an array with all webgroups the user id is in
632
-        if (!array_key_exists($userid, $this->cache["mo"])) {
634
+        if (!array_key_exists($userid, $this->cache["mo"])) {
633 635
             $tbl = $modx->getFullTableName("webgroup_names");
634 636
             $tbl2 = $modx->getFullTableName("web_groups");
635 637
             $sql = "SELECT wgn.name FROM $tbl wgn INNER JOIN $tbl2 wg ON wg.webgroup=wgn.id AND wg.webuser='" . $userid . "'";
636 638
             $this->cache["mo"][$userid] = $grpNames = $modx->db->getColumn("name", $sql);
637
-        } else {
639
+        } else {
638 640
             $grpNames = $this->cache["mo"][$userid];
639 641
         }
640 642
         // Check if a supplied group matches a webgroup from the array we just created
641
-        foreach ($groupNames as $k => $v) {
642
-            if (in_array(trim($v), $grpNames)) {
643
+        foreach ($groupNames as $k => $v) {
644
+            if (in_array(trim($v), $grpNames)) {
643 645
                 return true;
644 646
             }
645 647
         }
@@ -653,14 +655,14 @@  discard block
 block discarded – undo
653 655
      * @param $name
654 656
      * @return mixed|string
655 657
      */
656
-    public function getPHxVariable($name)
657
-    {
658
+    public function getPHxVariable($name)
659
+    {
658 660
         global $modx;
659 661
         // Check if this variable is created by PHx
660
-        if (array_key_exists($name, $this->placeholders)) {
662
+        if (array_key_exists($name, $this->placeholders)) {
661 663
             // Return the value from PHx
662 664
             return $this->placeholders[$name];
663
-        } else {
665
+        } else {
664 666
             // Return the value from MODx
665 667
             return $modx->getPlaceholder($name);
666 668
         }
@@ -671,9 +673,9 @@  discard block
 block discarded – undo
671 673
      * @param $name
672 674
      * @param $value
673 675
      */
674
-    public function setPHxVariable($name, $value)
675
-    {
676
-        if ($name != "phx") {
676
+    public function setPHxVariable($name, $value)
677
+    {
678
+        if ($name != "phx") {
677 679
             $this->placeholders[$name] = $value;
678 680
         }
679 681
     }
@@ -685,9 +687,9 @@  discard block
 block discarded – undo
685 687
      * @param null $l
686 688
      * @return string
687 689
      */
688
-    public function substr($str, $s, $l = null)
689
-    {
690
-        if (function_exists('mb_substr')) {
690
+    public function substr($str, $s, $l = null)
691
+    {
692
+        if (function_exists('mb_substr')) {
691 693
             return mb_substr($str, $s, $l);
692 694
         }
693 695
 
@@ -698,9 +700,9 @@  discard block
 block discarded – undo
698 700
      * @param $str
699 701
      * @return int
700 702
      */
701
-    public function strlen($str)
702
-    {
703
-        if (function_exists('mb_strlen')) {
703
+    public function strlen($str)
704
+    {
705
+        if (function_exists('mb_strlen')) {
704 706
             return mb_strlen($str);
705 707
         }
706 708
 
@@ -711,9 +713,9 @@  discard block
 block discarded – undo
711 713
      * @param $str
712 714
      * @return string
713 715
      */
714
-    public function strtolower($str)
715
-    {
716
-        if (function_exists('mb_strtolower')) {
716
+    public function strtolower($str)
717
+    {
718
+        if (function_exists('mb_strtolower')) {
717 719
             return mb_strtolower($str);
718 720
         }
719 721
 
@@ -724,9 +726,9 @@  discard block
 block discarded – undo
724 726
      * @param $str
725 727
      * @return string
726 728
      */
727
-    public function strtoupper($str)
728
-    {
729
-        if (function_exists('mb_strtoupper')) {
729
+    public function strtoupper($str)
730
+    {
731
+        if (function_exists('mb_strtoupper')) {
730 732
             return mb_strtoupper($str);
731 733
         }
732 734
 
@@ -737,9 +739,9 @@  discard block
 block discarded – undo
737 739
      * @param $str
738 740
      * @return string
739 741
      */
740
-    public function ucfirst($str)
741
-    {
742
-        if (function_exists('mb_strtoupper') && function_exists('mb_substr') && function_exists('mb_strlen')) {
742
+    public function ucfirst($str)
743
+    {
744
+        if (function_exists('mb_strtoupper') && function_exists('mb_substr') && function_exists('mb_strlen')) {
743 745
             return mb_strtoupper(mb_substr($str, 0, 1)) . mb_substr($str, 1, mb_strlen($str));
744 746
         }
745 747
 
@@ -750,9 +752,9 @@  discard block
 block discarded – undo
750 752
      * @param $str
751 753
      * @return string
752 754
      */
753
-    public function lcfirst($str)
754
-    {
755
-        if (function_exists('mb_strtolower') && function_exists('mb_substr') && function_exists('mb_strlen')) {
755
+    public function lcfirst($str)
756
+    {
757
+        if (function_exists('mb_strtolower') && function_exists('mb_substr') && function_exists('mb_strlen')) {
756 758
             return mb_strtolower(mb_substr($str, 0, 1)) . mb_substr($str, 1, mb_strlen($str));
757 759
         }
758 760
 
@@ -763,9 +765,9 @@  discard block
 block discarded – undo
763 765
      * @param $str
764 766
      * @return string
765 767
      */
766
-    public function ucwords($str)
767
-    {
768
-        if (function_exists('mb_convert_case')) {
768
+    public function ucwords($str)
769
+    {
770
+        if (function_exists('mb_convert_case')) {
769 771
             return mb_convert_case($str, MB_CASE_TITLE);
770 772
         }
771 773
 
@@ -776,8 +778,8 @@  discard block
 block discarded – undo
776 778
      * @param $str
777 779
      * @return string
778 780
      */
779
-    public function strrev($str)
780
-    {
781
+    public function strrev($str)
782
+    {
781 783
         preg_match_all('/./us', $str, $ar);
782 784
 
783 785
         return implode(array_reverse($ar[0]));
@@ -787,8 +789,8 @@  discard block
 block discarded – undo
787 789
      * @param $str
788 790
      * @return string
789 791
      */
790
-    public function str_shuffle($str)
791
-    {
792
+    public function str_shuffle($str)
793
+    {
792 794
         preg_match_all('/./us', $str, $ar);
793 795
         shuffle($ar[0]);
794 796
 
@@ -799,8 +801,8 @@  discard block
 block discarded – undo
799 801
      * @param $str
800 802
      * @return int
801 803
      */
802
-    public function str_word_count($str)
803
-    {
804
+    public function str_word_count($str)
805
+    {
804 806
         return count(preg_split('~[^\p{L}\p{N}\']+~u', $str));
805 807
     }
806 808
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
                     default:
201 201
                         $this->Log("MODx / PHx placeholder variable: " . $input);
202 202
                         // Check if placeholder is set
203
-                        if (!array_key_exists($input, $this->placeholders) && !array_key_exists($input,
203
+                        if ( ! array_key_exists($input, $this->placeholders) && ! array_key_exists($input,
204 204
                                 $modx->placeholders)
205 205
                         ) {
206 206
                             // not set so try again later.
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
                     case "show":
310 310
                         $conditional = implode(' ', $condition);
311 311
                         $isvalid = intval(eval("return (" . $conditional . ");"));
312
-                        if (!$isvalid) {
312
+                        if ( ! $isvalid) {
313 313
                             $output = null;
314 314
                         }
315 315
                         break;
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
                     case "else":
326 326
                         $conditional = implode(' ', $condition);
327 327
                         $isvalid = intval(eval("return (" . $conditional . ");"));
328
-                        if (!$isvalid) {
328
+                        if ( ! $isvalid) {
329 329
                             $output = $modifier_value[$i];
330 330
                         }
331 331
                         break;
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
                         break;
392 392
                     case "wordwrap": // default: 70
393 393
                         $wrapat = intval($modifier_value[$i]) ? intval($modifier_value[$i]) : 70;
394
-                        $output = preg_replace_callback("@(\b\w+\b)@",function($m) use($wrapat) {return wordwrap($m[1],$wrapat,' ',1);},$output);
394
+                        $output = preg_replace_callback("@(\b\w+\b)@", function($m) use($wrapat) {return wordwrap($m[1], $wrapat, ' ', 1); },$output);
395 395
                         break;
396 396
                     case "limit": // default: 100
397 397
                         $limit = intval($modifier_value[$i]) ? intval($modifier_value[$i]) : 100;
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
                         $output = eval("return " . $filter . ";");
415 415
                         break;
416 416
                     case "isnotempty":
417
-                        if (!empty($output)) {
417
+                        if ( ! empty($output)) {
418 418
                             $output = $modifier_value[$i];
419 419
                         }
420 420
                         break;
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
                         $cm = $snippet;
494 494
                         // end //
495 495
 
496
-                        if (!empty($cm)) {
496
+                        if ( ! empty($cm)) {
497 497
                             ob_start();
498 498
                             $options = $modifier_value[$i];
499 499
                             $custom = eval($cm);
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
      */
522 522
     public function createEventLog()
523 523
     {
524
-        if (!empty($this->console)) {
524
+        if ( ! empty($this->console)) {
525 525
             $console = implode("\n", $this->console);
526 526
             $this->console = array();
527 527
 
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
     public function ModUser($userid, $field)
595 595
     {
596 596
         global $modx;
597
-        if (!array_key_exists($userid, $this->cache["ui"])) {
597
+        if ( ! array_key_exists($userid, $this->cache["ui"])) {
598 598
             if (intval($userid) < 0) {
599 599
                 $user = $modx->getWebUserInfo(-($userid));
600 600
             } else {
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
         global $modx;
620 620
 
621 621
         // if $groupNames is not an array return false
622
-        if (!is_array($groupNames)) {
622
+        if ( ! is_array($groupNames)) {
623 623
             return false;
624 624
         }
625 625
 
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
         }
630 630
 
631 631
         // Creates an array with all webgroups the user id is in
632
-        if (!array_key_exists($userid, $this->cache["mo"])) {
632
+        if ( ! array_key_exists($userid, $this->cache["mo"])) {
633 633
             $tbl = $modx->getFullTableName("webgroup_names");
634 634
             $tbl2 = $modx->getFullTableName("web_groups");
635 635
             $sql = "SELECT wgn.name FROM $tbl wgn INNER JOIN $tbl2 wg ON wg.webgroup=wgn.id AND wg.webuser='" . $userid . "'";
Please login to merge, or discard this patch.
Doc Comments   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     // Parser: Preparation, cleaning and checkup
76 76
     /**
77 77
      * @param string $template
78
-     * @return mixed|string
78
+     * @return string
79 79
      */
80 80
     public function Parse($template = '')
81 81
     {
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
     // Parser: modifier detection and eXtended processing if needed
234 234
     /**
235 235
      * @param $input
236
-     * @param $modifiers
236
+     * @param string $modifiers
237 237
      * @return mixed|null|string
238 238
      */
239 239
     public function Filter($input, $modifiers)
@@ -588,8 +588,8 @@  discard block
 block discarded – undo
588 588
     // positive userid = manager, negative integer = webuser
589 589
     /**
590 590
      * @param $userid
591
-     * @param $field
592
-     * @return mixed
591
+     * @param string $field
592
+     * @return string
593 593
      */
594 594
     public function ModUser($userid, $field)
595 595
     {
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 
651 651
     // Returns the value of a PHx/MODx placeholder.
652 652
     /**
653
-     * @param $name
653
+     * @param string $name
654 654
      * @return mixed|string
655 655
      */
656 656
     public function getPHxVariable($name)
@@ -668,8 +668,8 @@  discard block
 block discarded – undo
668 668
 
669 669
     // Sets a placeholder variable which can only be access by PHx
670 670
     /**
671
-     * @param $name
672
-     * @param $value
671
+     * @param string $name
672
+     * @param string $value
673 673
      */
674 674
     public function setPHxVariable($name, $value)
675 675
     {
@@ -680,9 +680,9 @@  discard block
 block discarded – undo
680 680
 
681 681
     //mbstring
682 682
     /**
683
-     * @param $str
684
-     * @param $s
685
-     * @param null $l
683
+     * @param string $str
684
+     * @param integer $s
685
+     * @param integer $l
686 686
      * @return string
687 687
      */
688 688
     public function substr($str, $s, $l = null)
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
     }
696 696
 
697 697
     /**
698
-     * @param $str
698
+     * @param string $str
699 699
      * @return int
700 700
      */
701 701
     public function strlen($str)
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
     }
709 709
 
710 710
     /**
711
-     * @param $str
711
+     * @param string $str
712 712
      * @return string
713 713
      */
714 714
     public function strtolower($str)
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
     }
722 722
 
723 723
     /**
724
-     * @param $str
724
+     * @param string $str
725 725
      * @return string
726 726
      */
727 727
     public function strtoupper($str)
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
     }
735 735
 
736 736
     /**
737
-     * @param $str
737
+     * @param string $str
738 738
      * @return string
739 739
      */
740 740
     public function ucfirst($str)
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
     }
748 748
 
749 749
     /**
750
-     * @param $str
750
+     * @param string $str
751 751
      * @return string
752 752
      */
753 753
     public function lcfirst($str)
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
     }
761 761
 
762 762
     /**
763
-     * @param $str
763
+     * @param string $str
764 764
      * @return string
765 765
      */
766 766
     public function ucwords($str)
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
     }
774 774
 
775 775
     /**
776
-     * @param $str
776
+     * @param string $str
777 777
      * @return string
778 778
      */
779 779
     public function strrev($str)
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
     }
785 785
 
786 786
     /**
787
-     * @param $str
787
+     * @param string $str
788 788
      * @return string
789 789
      */
790 790
     public function str_shuffle($str)
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
     }
797 797
 
798 798
     /**
799
-     * @param $str
799
+     * @param string $str
800 800
      * @return int
801 801
      */
802 802
     public function str_word_count($str)
Please login to merge, or discard this patch.