Completed
Push — master ( c2d4ba...2895c3 )
by
unknown
02:24
created
assets/lib/Helpers/Config.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     }
23 23
 
24 24
     /**
25
-     * @param $path
25
+     * @param string $path
26 26
      * @return $this
27 27
      */
28 28
     public function setPath($path) {
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     }
100 100
 
101 101
     /**
102
-     * @param $name
102
+     * @param string $name
103 103
      * @param null $def
104 104
      * @return mixed
105 105
      */
Please login to merge, or discard this patch.
Braces   +29 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@  discard block
 block discarded – undo
1 1
 <?php namespace Helpers;
2 2
 
3
-if (!defined('MODX_BASE_PATH')) {
3
+if (!defined('MODX_BASE_PATH')) {
4 4
     die();
5 5
 }
6 6
 include_once(MODX_BASE_PATH . 'assets/lib/Helpers/FS.php');
7 7
 include_once(MODX_BASE_PATH . 'assets/lib/APIHelpers.class.php');
8 8
 require_once(MODX_BASE_PATH . "assets/snippets/DocLister/lib/jsonHelper.class.php");
9 9
 
10
-class Config
11
-{
10
+class Config
11
+{
12 12
     private $_cfg = array();
13 13
     protected $fs = null;
14 14
     protected $path = '';
15 15
 
16
-    public function __construct($cfg = array())
17
-    {
18
-        if ($cfg) {
16
+    public function __construct($cfg = array())
17
+    {
18
+        if ($cfg) {
19 19
             $this->setConfig($cfg);
20 20
         }
21 21
         $this->fs = \Helpers\FS::getInstance();
@@ -25,7 +25,8 @@  discard block
 block discarded – undo
25 25
      * @param $path
26 26
      * @return $this
27 27
      */
28
-    public function setPath($path) {
28
+    public function setPath($path)
29
+    {
29 30
         $this->path = $path;
30 31
 
31 32
         return $this;
@@ -37,21 +38,21 @@  discard block
 block discarded – undo
37 38
      * @param $name string имя конфига
38 39
      * @return array массив с настройками
39 40
      */
40
-    public function loadConfig($name)
41
-    {
41
+    public function loadConfig($name)
42
+    {
42 43
         //$this->debug->debug('Load json config: ' . $this->debug->dumpData($name), 'loadconfig', 2);
43
-        if (!is_scalar($name)) {
44
+        if (!is_scalar($name)) {
44 45
             $name = '';
45 46
         }
46 47
         $config = array();
47 48
         $name = explode(";", $name);
48
-        foreach ($name as $cfgName) {
49
+        foreach ($name as $cfgName) {
49 50
             $cfgName = explode(":", $cfgName, 2);
50
-            if (empty($cfgName[1])) {
51
+            if (empty($cfgName[1])) {
51 52
                 $cfgName[1] = 'custom';
52 53
             }
53 54
             $cfgName[1] = rtrim($cfgName[1], '/');
54
-            switch ($cfgName[1]) {
55
+            switch ($cfgName[1]) {
55 56
                 case 'custom':
56 57
                 case 'core':
57 58
                     $configFile = $this->fs->relativePath($this->path) . "/config/{$cfgName[1]}/{$cfgName[0]}.json";
@@ -61,7 +62,7 @@  discard block
 block discarded – undo
61 62
                     break;
62 63
             }
63 64
 
64
-            if ($this->fs->checkFile($configFile)) {
65
+            if ($this->fs->checkFile($configFile)) {
65 66
                 $json = file_get_contents(MODX_BASE_PATH . $configFile);
66 67
                 $config = array_merge($config, \jsonHelper::jsonDecode($json, array('assoc' => true), true));
67 68
             }
@@ -76,8 +77,8 @@  discard block
 block discarded – undo
76 77
      * Получение всего списка настроек
77 78
      * @return array
78 79
      */
79
-    public function getConfig()
80
-    {
80
+    public function getConfig()
81
+    {
81 82
         return $this->_cfg;
82 83
     }
83 84
 
@@ -86,12 +87,12 @@  discard block
 block discarded – undo
86 87
      * @param array $cfg массив настроек
87 88
      * @return int результат сохранения настроек
88 89
      */
89
-    public function setConfig($cfg, $overwrite = false)
90
-    {
91
-        if (is_array($cfg)) {
90
+    public function setConfig($cfg, $overwrite = false)
91
+    {
92
+        if (is_array($cfg)) {
92 93
             $this->_cfg = $overwrite ? $cfg : array_merge($this->_cfg, $cfg);
93 94
             $ret = count($this->_cfg);
94
-        } else {
95
+        } else {
95 96
             $ret = false;
96 97
         }
97 98
 
@@ -103,8 +104,8 @@  discard block
 block discarded – undo
103 104
      * @param null $def
104 105
      * @return mixed
105 106
      */
106
-    public function getCFGDef($name, $def = null)
107
-    {
107
+    public function getCFGDef($name, $def = null)
108
+    {
108 109
         return \APIhelpers::getkey($this->_cfg, $name, $def);
109 110
     }
110 111
 
@@ -115,19 +116,19 @@  discard block
 block discarded – undo
115 116
      * @param string $sep
116 117
      * @return array|mixed|\xNop
117 118
      */
118
-    public function loadArray($arr, $sep = ',')
119
-    {
119
+    public function loadArray($arr, $sep = ',')
120
+    {
120 121
 
121
-        if (is_scalar($arr)) {
122
+        if (is_scalar($arr)) {
122 123
             $out = \jsonHelper::jsonDecode($arr, array('assoc' => true));
123
-            if (is_null($out) && $sep) {
124
+            if (is_null($out) && $sep) {
124 125
                 $out = array_filter(explode($sep, $arr));
125 126
             }
126 127
 
127 128
             return $out;
128
-        } elseif (is_array($arr)) {
129
+        } elseif (is_array($arr)) {
129 130
             return $arr;
130
-        } else {
131
+        } else {
131 132
             return array();
132 133
         }
133 134
     }
Please login to merge, or discard this patch.
assets/lib/Helpers/Mailer.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
     /**
105 105
      * @param $report
106
-     * @return bool
106
+     * @return boolean|string
107 107
      */
108 108
     public function toQueue($report)
109 109
     {
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     }
150 150
 
151 151
     /**
152
-     * @return mixed
152
+     * @return string|boolean
153 153
      */
154 154
     protected function saveMessage()
155 155
     {
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     /**
223 223
      * @param string $param
224 224
      * @param mixed $default
225
-     * @return mixed
225
+     * @return string
226 226
      */
227 227
     public function getCFGDef($param, $default = null)
228 228
     {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function addAddressToMailer($type, $addr)
43 43
     {
44
-        if (!empty($addr)) {
44
+        if ( ! empty($addr)) {
45 45
             $a = array_filter(array_map('trim', explode(',', $addr)));
46 46
             foreach ($a as $address) {
47 47
                 switch ($type) {
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     public function send($report)
85 85
     {
86 86
         //если отправлять некуда или незачем, то делаем вид, что отправили
87
-        if (!$this->getCFGDef('to') || $this->getCFGDef('noemail')) {
87
+        if ( ! $this->getCFGDef('to') || $this->getCFGDef('noemail')) {
88 88
             return true;
89 89
         } elseif (empty($report)) {
90 90
             return false;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     public function toQueue($report)
109 109
     {
110 110
         //если отправлять некуда или незачем, то делаем вид, что отправили
111
-        if (!$this->getCFGDef('to') || $this->getCFGDef('noemail')) {
111
+        if ( ! $this->getCFGDef('to') || $this->getCFGDef('noemail')) {
112 112
             return true;
113 113
         } elseif (empty($report)) {
114 114
             return false;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      * @return bool
141 141
      */
142 142
     public function setQueuePath($path = '') {
143
-        if (!empty($path)) {
143
+        if ( ! empty($path)) {
144 144
             $this->queuePath = $path;
145 145
             return true;
146 146
         } else {
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         ));
161 161
         $file = $this->getFileName();
162 162
         $dir = MODX_BASE_PATH . $this->queuePath;
163
-        if (!is_dir($dir)) {
163
+        if ( ! is_dir($dir)) {
164 164
             @mkdir($dir);
165 165
         }
166 166
         $result = @file_put_contents($dir . $file, $data) !== false;
Please login to merge, or discard this patch.
Braces   +42 added lines, -40 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
  * Class Mailer
8 8
  * @package Helpers
9 9
  */
10
-class Mailer
11
-{
10
+class Mailer
11
+{
12 12
     /**
13 13
      * @var \PHPMailer $mail
14 14
      */
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
      * @param $cfg
25 25
      * @param bool $debug
26 26
      */
27
-    public function __construct(\DocumentParser $modx, $cfg, $debug = false)
28
-    {
27
+    public function __construct(\DocumentParser $modx, $cfg, $debug = false)
28
+    {
29 29
         $this->modx = $modx;
30 30
         $this->mail = new \MODxMailer();
31 31
         $this->mail->init($modx);
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
      * @param string $addr
40 40
      * @return $this
41 41
      */
42
-    public function addAddressToMailer($type, $addr)
43
-    {
44
-        if (!empty($addr)) {
42
+    public function addAddressToMailer($type, $addr)
43
+    {
44
+        if (!empty($addr)) {
45 45
             $a = array_filter(array_map('trim', explode(',', $addr)));
46
-            foreach ($a as $address) {
47
-                switch ($type) {
46
+            foreach ($a as $address) {
47
+                switch ($type) {
48 48
                     case 'to':
49 49
                         $this->mail->AddAddress($address);
50 50
                         break;
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
      * @param array $filelist
68 68
      * @return $this
69 69
      */
70
-    public function attachFiles($filelist = array())
71
-    {
70
+    public function attachFiles($filelist = array())
71
+    {
72 72
         $contentType = "application/octetstream";
73
-        foreach ($filelist as $file) {
73
+        foreach ($filelist as $file) {
74 74
             $this->mail->AddAttachment($file['filepath'], $file['filename'], "base64", $contentType);
75 75
         }
76 76
 
@@ -81,19 +81,19 @@  discard block
 block discarded – undo
81 81
      * @param $report
82 82
      * @return bool
83 83
      */
84
-    public function send($report)
85
-    {
84
+    public function send($report)
85
+    {
86 86
         //если отправлять некуда или незачем, то делаем вид, что отправили
87
-        if (!$this->getCFGDef('to') || $this->getCFGDef('noemail')) {
87
+        if (!$this->getCFGDef('to') || $this->getCFGDef('noemail')) {
88 88
             return true;
89
-        } elseif (empty($report)) {
89
+        } elseif (empty($report)) {
90 90
             return false;
91 91
         }
92 92
 
93 93
         $this->mail->Body = $report;
94 94
 
95 95
         $result = $this->mail->send();
96
-        if ($result) {
96
+        if ($result) {
97 97
             $this->mail->ClearAllRecipients();
98 98
             $this->mail->ClearAttachments();
99 99
         }
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
      * @param $report
106 106
      * @return bool
107 107
      */
108
-    public function toQueue($report)
109
-    {
108
+    public function toQueue($report)
109
+    {
110 110
         //если отправлять некуда или незачем, то делаем вид, что отправили
111
-        if (!$this->getCFGDef('to') || $this->getCFGDef('noemail')) {
111
+        if (!$this->getCFGDef('to') || $this->getCFGDef('noemail')) {
112 112
             return true;
113
-        } elseif (empty($report)) {
113
+        } elseif (empty($report)) {
114 114
             return false;
115 115
         }
116 116
 
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
 
119 119
         $this->Body = $this->modx->removeSanitizeSeed($this->mail->Body);
120 120
         $this->Subject = $this->modx->removeSanitizeSeed($this->mail->Subject);
121
-        try {
121
+        try {
122 122
             $result = $this->mail->preSend() && $this->saveMessage();
123
-        } catch (\phpmailerException $e) {
123
+        } catch (\phpmailerException $e) {
124 124
             $this->mail->SetError($e->getMessage());
125 125
 
126 126
             $result = false;
127 127
         }
128 128
 
129
-        if ($result) {
129
+        if ($result) {
130 130
             $this->mail->ClearAllRecipients();
131 131
             $this->mail->ClearAttachments();
132 132
             $result = $this->getFileName();
@@ -139,11 +139,12 @@  discard block
 block discarded – undo
139 139
      * @param string $path
140 140
      * @return bool
141 141
      */
142
-    public function setQueuePath($path = '') {
143
-        if (!empty($path)) {
142
+    public function setQueuePath($path = '')
143
+    {
144
+        if (!empty($path)) {
144 145
             $this->queuePath = $path;
145 146
             return true;
146
-        } else {
147
+        } else {
147 148
             return false;
148 149
         }
149 150
     }
@@ -151,8 +152,8 @@  discard block
 block discarded – undo
151 152
     /**
152 153
      * @return mixed
153 154
      */
154
-    protected function saveMessage()
155
-    {
155
+    protected function saveMessage()
156
+    {
156 157
         $data = serialize(array(
157 158
             "header" => $this->mail->getMIMEHeader(),
158 159
             "body"   => $this->mail->getMIMEBody(),
@@ -160,11 +161,11 @@  discard block
 block discarded – undo
160 161
         ));
161 162
         $file = $this->getFileName();
162 163
         $dir = MODX_BASE_PATH . $this->queuePath;
163
-        if (!is_dir($dir)) {
164
+        if (!is_dir($dir)) {
164 165
             @mkdir($dir);
165 166
         }
166 167
         $result = @file_put_contents($dir . $file, $data) !== false;
167
-        if ($result) {
168
+        if ($result) {
168 169
             $result = $file;
169 170
         }
170 171
 
@@ -174,7 +175,8 @@  discard block
 block discarded – undo
174 175
     /**
175 176
      * @return string
176 177
      */
177
-    protected function getFileName() {
178
+    protected function getFileName()
179
+    {
178 180
         return $this->mail->getMessageID() . '.eml';
179 181
     }
180 182
 
@@ -182,18 +184,18 @@  discard block
 block discarded – undo
182 184
      * @param $file
183 185
      * @return bool
184 186
      */
185
-    public function fromQueue($file)
186
-    {
187
+    public function fromQueue($file)
188
+    {
187 189
         $result = false;
188 190
         $dir = MODX_BASE_PATH . $this->queuePath;
189
-        if (file_exists($dir . $file) && is_readable($dir . $file)) {
191
+        if (file_exists($dir . $file) && is_readable($dir . $file)) {
190 192
             $message = unserialize(file_get_contents($dir . $file));
191 193
             $this->config = $message['config'];
192 194
             $this->applyMailConfig();
193 195
             $this->mail->setMIMEHeader($message['header'])->setMIMEBody($message['body']);
194 196
             unset($message);
195 197
             $result = $this->mail->postSend();
196
-            if ($result) {
198
+            if ($result) {
197 199
                 $this->mail->setMIMEBody()->setMIMEHeader();
198 200
                 @unlink($dir . $file);
199 201
             }
@@ -205,8 +207,8 @@  discard block
 block discarded – undo
205 207
     /**
206 208
      * @return $this
207 209
      */
208
-    protected function applyMailConfig()
209
-    {
210
+    protected function applyMailConfig()
211
+    {
210 212
         $this->mail->IsHTML($this->getCFGDef('isHtml', 1));
211 213
         $this->mail->From = $this->getCFGDef('from', $this->modx->config['emailsender']);
212 214
         $this->mail->FromName = $this->getCFGDef('fromName', $this->modx->config['site_name']);
@@ -224,8 +226,8 @@  discard block
 block discarded – undo
224 226
      * @param mixed $default
225 227
      * @return mixed
226 228
      */
227
-    public function getCFGDef($param, $default = null)
228
-    {
229
+    public function getCFGDef($param, $default = null)
230
+    {
229 231
         return \APIhelpers::getkey($this->config, $param, $default);
230 232
     }
231 233
 }
Please login to merge, or discard this patch.
assets/snippets/DocLister/core/controller/site_content.php 1 patch
Braces   +108 added lines, -110 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,9 +41,9 @@  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
         
@@ -54,31 +54,31 @@  discard block
 block discarded – undo
54 54
          */
55 55
         $extJotCount = $this->getCFGdef('jotcount', 0) ? $this->getExtender('jotcount', true) : null;
56 56
 
57
-        if ($extJotCount) {
57
+        if ($extJotCount) {
58 58
             $extJotCount->init($this);
59 59
         }
60 60
 
61
-        if ($this->extPaginate = $this->getExtender('paginate')) {
61
+        if ($this->extPaginate = $this->getExtender('paginate')) {
62 62
             $this->extPaginate->init($this);
63
-        } else {
63
+        } else {
64 64
             $this->config->setConfig(array('start' => 0));
65 65
         }
66 66
         $type = $this->getCFGDef('idType', 'parents');
67 67
         $this->_docs = ($type == 'parents') ? $this->getChildrenList() : $this->getDocList();
68
-        if ($tvlist != '' && count($this->_docs) > 0) {
68
+        if ($tvlist != '' && count($this->_docs) > 0) {
69 69
             $tv = $this->extTV->getTVList(array_keys($this->_docs), $tvlist);
70
-            if (!is_array($tv)) {
70
+            if (!is_array($tv)) {
71 71
                 $tv = array();
72 72
             }
73
-            foreach ($tv as $docID => $TVitem) {
74
-                if (isset($this->_docs[$docID]) && is_array($this->_docs[$docID])) {
73
+            foreach ($tv as $docID => $TVitem) {
74
+                if (isset($this->_docs[$docID]) && is_array($this->_docs[$docID])) {
75 75
                     $this->_docs[$docID] = array_merge($this->_docs[$docID], $TVitem);
76
-                } else {
76
+                } else {
77 77
                     unset($this->_docs[$docID]);
78 78
                 }
79 79
             }
80 80
         }
81
-        if (1 == $this->getCFGDef('tree', '0')) {
81
+        if (1 == $this->getCFGDef('tree', '0')) {
82 82
             $this->treeBuild('id', 'parent');
83 83
         }
84 84
 
@@ -89,24 +89,24 @@  discard block
 block discarded – undo
89 89
      * @param string $tpl
90 90
      * @return string
91 91
      */
92
-    public function _render($tpl = '')
93
-    {
92
+    public function _render($tpl = '')
93
+    {
94 94
         $out = '';
95
-        if ($tpl == '') {
95
+        if ($tpl == '') {
96 96
             $tpl = $this->getCFGDef('tpl', '@CODE:<a href="[+url+]">[+pagetitle+]</a><br />');
97 97
         }
98
-        if ($tpl != '') {
98
+        if ($tpl != '') {
99 99
             $date = $this->getCFGDef('dateSource', 'pub_date');
100 100
 
101 101
             $this->toPlaceholders(count($this->_docs), 1, "display"); // [+display+] - сколько показано на странице.
102 102
 
103 103
             $i = 1;
104 104
             $sysPlh = $this->renameKeyArr($this->_plh, $this->getCFGDef("sysKey", "dl"));
105
-            if (count($this->_docs) > 0) {
105
+            if (count($this->_docs) > 0) {
106 106
                 /**
107 107
                  * @var $extUser user_DL_Extender
108 108
                  */
109
-                if ($extUser = $this->getExtender('user')) {
109
+                if ($extUser = $this->getExtender('user')) {
110 110
                     $extUser->init($this, array('fields' => $this->getCFGDef("userFields", "")));
111 111
                 }
112 112
 
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
                 $extPrepare = $this->getExtender('prepare');
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
 
@@ -135,24 +135,24 @@  discard block
 block discarded – undo
135 135
 
136 136
                     $item['title'] = ($item['menutitle'] == '' ? $item['pagetitle'] : $item['menutitle']);
137 137
 
138
-                    if ($this->getCFGDef('makeUrl', 1)) {
139
-                        if ($item['type'] == 'reference') {
138
+                    if ($this->getCFGDef('makeUrl', 1)) {
139
+                        if ($item['type'] == 'reference') {
140 140
                             $item['url'] = is_numeric($item['content']) ? $this->modx->makeUrl($item['content'], '', '',
141 141
                                 $this->getCFGDef('urlScheme', '')) : $item['content'];
142
-                        } else {
142
+                        } else {
143 143
                             $item['url'] = $this->modx->makeUrl($item['id'], '', '', $this->getCFGDef('urlScheme', ''));
144 144
                         }
145 145
                     }
146 146
 
147
-                    if (isset($item[$date])) {
148
-                        if (!$item[$date] && $date == 'pub_date' && isset($item['createdon'])) {
147
+                    if (isset($item[$date])) {
148
+                        if (!$item[$date] && $date == 'pub_date' && isset($item['createdon'])) {
149 149
                             $date = 'createdon';
150 150
                         }
151 151
                         $_date = is_numeric($item[$date]) && $item[$date] == (int)$item[$date] ? $item[$date] : strtotime($item[$date]);
152
-                        if ($_date !== false) {
152
+                        if ($_date !== false) {
153 153
                             $_date = $_date + $this->modx->config['server_offset_time'];
154 154
                             $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M');
155
-                            if ($dateFormat) {
155
+                            if ($dateFormat) {
156 156
                                 $item['date'] = strftime($dateFormat, $_date);
157 157
                             }
158 158
                         }
@@ -161,30 +161,30 @@  discard block
 block discarded – undo
161 161
                     $findTpl = $this->renderTPL;
162 162
                     $tmp = $this->uniformPrepare($item, $i);
163 163
                     extract($tmp, EXTR_SKIP);
164
-                    if ($this->renderTPL == '') {
164
+                    if ($this->renderTPL == '') {
165 165
                         $this->renderTPL = $findTpl;
166 166
                     }
167 167
 
168
-                    if ($extPrepare) {
168
+                    if ($extPrepare) {
169 169
                         $item = $extPrepare->init($this, array(
170 170
                             'data'      => $item,
171 171
                             'nameParam' => 'prepare'
172 172
                         ));
173
-                        if (is_bool($item) && $item === false) {
173
+                        if (is_bool($item) && $item === false) {
174 174
                             $this->skippedDocs++;
175 175
                             continue;
176 176
                         }
177 177
                     }
178 178
                     $tmp = $this->parseChunk($this->renderTPL, $item);
179 179
 
180
-                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
180
+                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
181 181
                         $this->toPlaceholders($tmp, 1,
182 182
                             "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page
183 183
                     }
184 184
                     $out .= $tmp;
185 185
                     $i++;
186 186
                 }
187
-            } else {
187
+            } else {
188 188
                 $noneTPL = $this->getCFGDef("noneTPL", "");
189 189
                 $out = ($noneTPL != '') ? $this->parseChunk($noneTPL, $sysPlh) : '';
190 190
             }
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
      * @param array $array
201 201
      * @return string
202 202
      */
203
-    public function getJSON($data, $fields, $array = array())
204
-    {
203
+    public function getJSON($data, $fields, $array = array())
204
+    {
205 205
         $out = array();
206 206
         $fields = is_array($fields) ? $fields : explode(",", $fields);
207 207
         $date = $this->getCFGDef('dateSource', 'pub_date');
@@ -220,50 +220,50 @@  discard block
 block discarded – undo
220 220
          */
221 221
         $extE = $this->getExtender('e', true, true);
222 222
 
223
-        foreach ($data as $num => $row) {
224
-            if ((array('1') == $fields || in_array('summary', $fields)) && $extSummary) {
223
+        foreach ($data as $num => $row) {
224
+            if ((array('1') == $fields || in_array('summary', $fields)) && $extSummary) {
225 225
                 $row['summary'] = $this->getSummary($row, $extSummary, 'introtext', 'content');
226 226
             }
227 227
 
228
-            if (array('1') == $fields || in_array('date', $fields)) {
229
-                if (isset($row[$date])) {
230
-                    if (!$row[$date] && $date == 'pub_date' && isset($row['createdon'])) {
228
+            if (array('1') == $fields || in_array('date', $fields)) {
229
+                if (isset($row[$date])) {
230
+                    if (!$row[$date] && $date == 'pub_date' && isset($row['createdon'])) {
231 231
                         $date = 'createdon';
232 232
                     }   
233 233
                     $_date = is_numeric($row[$date]) && $row[$date] == (int)$row[$date] ? $row[$date] : strtotime($row[$date]);
234
-                    if ($_date !== false) {
234
+                    if ($_date !== false) {
235 235
                         $_date = $_date + $this->modx->config['server_offset_time'];
236 236
                         $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M');
237
-                        if ($dateFormat) {
237
+                        if ($dateFormat) {
238 238
                             $row['date'] = strftime($dateFormat, $_date);
239 239
                         }
240 240
                     }
241 241
                 }
242 242
             }
243 243
 
244
-            if (array('1') == $fields || in_array('title', $fields)) {
245
-                if (isset($row['pagetitle'])) {
244
+            if (array('1') == $fields || in_array('title', $fields)) {
245
+                if (isset($row['pagetitle'])) {
246 246
                     $row['title'] = empty($row['menutitle']) ? $row['pagetitle'] : $row['menutitle'];
247 247
                 }
248 248
             }
249 249
             if ((bool)$this->getCFGDef('makeUrl', 1) && (array('1') == $fields || in_array('url',$fields))
250
-            ) {
251
-                if (isset($row['type']) && $row['type'] == 'reference' && isset($row['content'])) {
250
+            ) {
251
+                if (isset($row['type']) && $row['type'] == 'reference' && isset($row['content'])) {
252 252
                     $row['url'] = is_numeric($row['content']) ? $this->modx->makeUrl($row['content'], '', '',
253 253
                         $this->getCFGDef('urlScheme', '')) : $row['content'];
254
-                } elseif (isset($row['id'])) {
254
+                } elseif (isset($row['id'])) {
255 255
                     $row['url'] = $this->modx->makeUrl($row['id'], '', '', $this->getCFGDef('urlScheme', ''));
256 256
                 }
257 257
             }
258
-            if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
259
-                if (is_array($tmp)) {
258
+            if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
259
+                if (is_array($tmp)) {
260 260
                     $row = $tmp;
261 261
                 }
262 262
             }
263 263
 
264
-            if ($extPrepare) {
264
+            if ($extPrepare) {
265 265
                 $row = $extPrepare->init($this, array('data' => $row));
266
-                if (is_bool($row) && $row === false) {
266
+                if (is_bool($row) && $row === false) {
267 267
                     continue;
268 268
                 }
269 269
             }
@@ -276,36 +276,35 @@  discard block
 block discarded – undo
276 276
     /**
277 277
      * @abstract
278 278
      */
279
-    public function getChildrenCount()
280
-    {
279
+    public function getChildrenCount()
280
+    {
281 281
         $out = 0;
282 282
         $sanitarInIDs = $this->sanitarIn($this->IDs);
283
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
283
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
284 284
             $q_true = $this->getCFGDef('ignoreEmpty', '0');
285 285
             $q_true = $q_true ? $q_true : $this->getCFGDef('idType', 'parents') == 'parents';
286 286
             $where = $this->getCFGDef('addWhereList', '');
287 287
             $where = sqlHelper::trimLogicalOp($where);
288 288
             $where = ($where ? $where . ' AND ' : '') . $this->_filters['where'];
289
-            if ($where != '' && $this->_filters['where'] != '') {
289
+            if ($where != '' && $this->_filters['where'] != '') {
290 290
                 $where .= " AND ";
291 291
             }
292 292
             $where = sqlHelper::trimLogicalOp($where);
293 293
 
294 294
             $where = "WHERE {$where}";
295 295
             $whereArr = array();
296
-            if (!$this->getCFGDef('showNoPublish', 0)) {
296
+            if (!$this->getCFGDef('showNoPublish', 0)) {
297 297
                 $whereArr[] = "c.deleted=0 AND c.published=1";
298
-            }
299
-            else{
298
+            } else {
300 299
                 $q_true = 1;
301 300
             }
302 301
 
303 302
             $tbl_site_content = $this->getTable('site_content', 'c');
304 303
 
305
-            if ($sanitarInIDs != "''") {
306
-                switch ($this->getCFGDef('idType', 'parents')) {
304
+            if ($sanitarInIDs != "''") {
305
+                switch ($this->getCFGDef('idType', 'parents')) {
307 306
                     case 'parents':
308
-                        switch ($this->getCFGDef('showParent', '0')) {
307
+                        switch ($this->getCFGDef('showParent', '0')) {
309 308
                             case '-1':
310 309
                                 $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")";
311 310
                                 break;
@@ -317,10 +316,10 @@  discard block
 block discarded – undo
317 316
                                 $tmpWhere = "(c.parent IN ({$sanitarInIDs}) OR c.id IN({$sanitarInIDs}))";
318 317
                                 break;
319 318
                         }
320
-                        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
319
+                        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
321 320
                             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
322 321
                             $whereArr[] = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
323
-                        } else {
322
+                        } else {
324 323
                             $whereArr[] = $tmpWhere;
325 324
                         }
326 325
 
@@ -335,26 +334,25 @@  discard block
 block discarded – undo
335 334
 
336 335
             $q_true = $q_true ? $q_true : trim($where) != 'WHERE';
337 336
 
338
-            if (trim($where) != 'WHERE') {
337
+            if (trim($where) != 'WHERE') {
339 338
                 $where .= " AND ";
340 339
             }
341 340
 
342 341
             $where .= implode(" AND ", $whereArr);
343 342
             $where = sqlHelper::trimLogicalOp($where);
344 343
 
345
-            if (trim($where) == 'WHERE') {
344
+            if (trim($where) == 'WHERE') {
346 345
                 $where = '';
347 346
             }
348 347
             $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id'));
349 348
 
350 349
             $q_true = $q_true ? $q_true : $group != '';
351
-            if ( $q_true ){
350
+            if ( $q_true ) {
352 351
                 $maxDocs = $this->getCFGDef('maxDocs', 0);
353 352
                 $limit = $maxDocs > 0 ? $this->LimitSQL($this->getCFGDef('maxDocs', 0)) : '';
354 353
                 $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group} {$limit}) as `tmp`");
355 354
                 $out = $this->modx->db->getValue($rs);
356
-            }
357
-            else {
355
+            } else {
358 356
                 $out = count($this->IDs);
359 357
             }
360 358
         }
@@ -365,11 +363,11 @@  discard block
 block discarded – undo
365 363
     /**
366 364
      * @return array
367 365
      */
368
-    protected function getDocList()
369
-    {
366
+    protected function getDocList()
367
+    {
370 368
         $out = array();
371 369
         $sanitarInIDs = $this->sanitarIn($this->IDs);
372
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
370
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
373 371
             $where = $this->getCFGDef('addWhereList', '');
374 372
             $where = sqlHelper::trimLogicalOp($where);
375 373
 
@@ -377,21 +375,21 @@  discard block
 block discarded – undo
377 375
             $where = sqlHelper::trimLogicalOp($where);
378 376
 
379 377
             $tbl_site_content = $this->getTable('site_content', 'c');
380
-            if ($sanitarInIDs != "''") {
378
+            if ($sanitarInIDs != "''") {
381 379
                 $where .= ($where ? " AND " : "") . "c.id IN ({$sanitarInIDs}) AND";
382 380
             }
383 381
             $where = sqlHelper::trimLogicalOp($where);
384 382
 
385
-            if ($this->getCFGDef('showNoPublish', 0)) {
386
-                if ($where != '') {
383
+            if ($this->getCFGDef('showNoPublish', 0)) {
384
+                if ($where != '') {
387 385
                     $where = "WHERE {$where}";
388
-                } else {
386
+                } else {
389 387
                     $where = '';
390 388
                 }
391
-            } else {
392
-                if ($where != '') {
389
+            } else {
390
+                if ($where != '') {
393 391
                     $where = "WHERE {$where} AND ";
394
-                } else {
392
+                } else {
395 393
                     $where = "WHERE {$where} ";
396 394
                 }
397 395
                 $where .= "c.deleted=0 AND c.published=1";
@@ -408,7 +406,7 @@  discard block
 block discarded – undo
408 406
 
409 407
             $rs = $this->dbQuery("SELECT {$fields} FROM {$tbl_site_content} {$where} {$group} {$sort} {$limit}");
410 408
 
411
-            while ($item = $this->modx->db->getRow($rs)) {
409
+            while ($item = $this->modx->db->getRow($rs)) {
412 410
                 $out[$item['id']] = $item;
413 411
             };
414 412
         }
@@ -420,26 +418,26 @@  discard block
 block discarded – undo
420 418
      * @param string $id
421 419
      * @return array
422 420
      */
423
-    public function getChildrenFolder($id)
424
-    {
421
+    public function getChildrenFolder($id)
422
+    {
425 423
         $out = array();
426 424
         $where = $this->getCFGDef('addWhereFolder', '');
427 425
         $where = sqlHelper::trimLogicalOp($where);
428
-        if ($where != '') {
426
+        if ($where != '') {
429 427
             $where .= " AND ";
430 428
         }
431 429
 
432 430
         $tbl_site_content = $this->getTable('site_content', 'c');
433 431
         $sanitarInIDs = $this->sanitarIn($id);
434
-        if ($this->getCFGDef('showNoPublish', 0)) {
432
+        if ($this->getCFGDef('showNoPublish', 0)) {
435 433
             $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1";
436
-        } else {
434
+        } else {
437 435
             $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1";
438 436
         }
439 437
 
440 438
         $rs = $this->dbQuery("SELECT id FROM {$tbl_site_content} {$where}");
441 439
 
442
-        while ($item = $this->modx->db->getRow($rs)) {
440
+        while ($item = $this->modx->db->getRow($rs)) {
443 441
             $out[] = $item['id'];
444 442
         }
445 443
 
@@ -451,10 +449,10 @@  discard block
 block discarded – undo
451 449
      * @param $sort
452 450
      * @return array
453 451
      */
454
-    protected function injectSortByTV($table, $sort)
455
-    {
452
+    protected function injectSortByTV($table, $sort)
453
+    {
456 454
         $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort);
457
-        if (!is_array($out) || empty($out)) {
455
+        if (!is_array($out) || empty($out)) {
458 456
             $out = array($table, $sort);
459 457
         }
460 458
 
@@ -464,19 +462,19 @@  discard block
 block discarded – undo
464 462
     /**
465 463
      * @return array
466 464
      */
467
-    protected function getChildrenList()
468
-    {
465
+    protected function getChildrenList()
466
+    {
469 467
         $where = array();
470 468
         $out = array();
471 469
 
472 470
         $tmpWhere = $this->getCFGDef('addWhereList', '');
473 471
         $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);
474
-        if (!empty($tmpWhere)) {
472
+        if (!empty($tmpWhere)) {
475 473
             $where[] = $tmpWhere;
476 474
         }
477 475
 
478 476
         $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']);
479
-        if (!empty($tmpWhere)) {
477
+        if (!empty($tmpWhere)) {
480 478
             $where[] = $tmpWhere;
481 479
         }
482 480
 
@@ -487,8 +485,8 @@  discard block
 block discarded – undo
487 485
         $sanitarInIDs = $this->sanitarIn($this->IDs);
488 486
 
489 487
         $tmpWhere = null;
490
-        if ($sanitarInIDs != "''") {
491
-            switch ($this->getCFGDef('showParent', '0')) {
488
+        if ($sanitarInIDs != "''") {
489
+            switch ($this->getCFGDef('showParent', '0')) {
492 490
                 case '-1':
493 491
                     $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")";
494 492
                     break;
@@ -501,36 +499,36 @@  discard block
 block discarded – undo
501 499
                     break;
502 500
             }
503 501
         }
504
-        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
502
+        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
505 503
             $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));
506
-            if (empty($tmpWhere)) {
504
+            if (empty($tmpWhere)) {
507 505
                 $tmpWhere = "c.id IN({$addDocs})";
508
-            } else {
506
+            } else {
509 507
                 $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))";
510 508
             }
511 509
         }
512
-        if (!empty($tmpWhere)) {
510
+        if (!empty($tmpWhere)) {
513 511
             $where[] = $tmpWhere;
514 512
         }
515
-        if (!$this->getCFGDef('showNoPublish', 0)) {
513
+        if (!$this->getCFGDef('showNoPublish', 0)) {
516 514
             $where[] = "c.deleted=0 AND c.published=1";
517 515
         }
518
-        if (!empty($where)) {
516
+        if (!empty($where)) {
519 517
             $where = "WHERE " . implode(" AND ", $where);
520
-        } else {
518
+        } else {
521 519
             $where = '';
522 520
         }
523 521
         $fields = $this->getCFGDef('selectFields', 'c.*');
524 522
         $group = $this->getGroupSQL($this->getCFGDef('groupBy', ''));
525 523
 
526
-        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
524
+        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
527 525
             $rs = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " .
528 526
                 $group . " " .
529 527
                 $sort . " " .
530 528
                 $this->LimitSQL($this->getCFGDef('queryLimit', 0))
531 529
             );
532 530
 
533
-            while ($item = $this->modx->db->getRow($rs)) {
531
+            while ($item = $this->modx->db->getRow($rs)) {
534 532
                 $out[$item['id']] = $item;
535 533
             }
536 534
         }
@@ -543,10 +541,10 @@  discard block
 block discarded – undo
543 541
      * @param string $type
544 542
      * @return string
545 543
      */
546
-    public function changeSortType($field, $type)
547
-    {
544
+    public function changeSortType($field, $type)
545
+    {
548 546
         $type = trim($type);
549
-        switch (strtoupper($type)) {
547
+        switch (strtoupper($type)) {
550 548
             case 'TVDATETIME':
551 549
                 $field = "STR_TO_DATE(" . $field . ",'%d-%m-%Y %H:%i:%s')";
552 550
                 break;
Please login to merge, or discard this patch.
assets/snippets/DocLister/core/DocLister.abstract.php 2 patches
Spacing   +42 added lines, -42 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",
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
             $offset = $this->getCFGDef('reversePagination',
1033 1033
                 0) && $this->extPaginate->currentPage() > 1 ? $this->extPaginate->totalPage() * $this->getCFGDef('display',
1034 1034
                     0) - $this->extPaginate->totalDocs() : 0;
1035
-            if ($this->getCFGDef('maxDocs', 0) && !$this->getCFGDef('reversePagination',
1035
+            if ($this->getCFGDef('maxDocs', 0) && ! $this->getCFGDef('reversePagination',
1036 1036
                     0) && $this->extPaginate->currentPage() == $this->extPaginate->totalPage()
1037 1037
             ) {
1038 1038
                 $iteration += $this->getCFGDef('display', 0);
@@ -1149,10 +1149,10 @@  discard block
 block discarded – undo
1149 1149
         $introField = $this->getCFGDef("introField", $introField);
1150 1150
         $contentField = $this->getCFGDef("contentField", $contentField);
1151 1151
 
1152
-        if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1152
+        if ( ! empty($introField) && ! empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1153 1153
             $out = $item[$introField];
1154 1154
         } else {
1155
-            if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1155
+            if ( ! empty($contentField) && ! empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1156 1156
                 $out = $extSummary->init($this, array(
1157 1157
                     "content"      => $item[$contentField],
1158 1158
                     "action"       => $this->getCFGDef("summary", ""),
@@ -1221,7 +1221,7 @@  discard block
 block discarded – undo
1221 1221
             $flag = true;
1222 1222
 
1223 1223
         } else {
1224
-            if (!class_exists($classname, false) && $classname != '') {
1224
+            if ( ! class_exists($classname, false) && $classname != '') {
1225 1225
                 if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) {
1226 1226
                     include_once(dirname(__FILE__) . "/extender/" . $name . ".extender.inc");
1227 1227
                 }
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
                 $flag = true;
1232 1232
             }
1233 1233
         }
1234
-        if (!$flag) {
1234
+        if ( ! $flag) {
1235 1235
             $this->debug->debug("Error load Extender " . $this->debug->dumpData($name));
1236 1236
         }
1237 1237
         $this->debug->debugEnd('LoadExtender');
@@ -1289,7 +1289,7 @@  discard block
 block discarded – undo
1289 1289
         $this->debug->debug('clean IDs ' . $this->debug->dumpData($IDs) . ' with separator ' . $this->debug->dumpData($sep),
1290 1290
             'cleanIDs', 2);
1291 1291
         $out = array();
1292
-        if (!is_array($IDs)) {
1292
+        if ( ! is_array($IDs)) {
1293 1293
             $IDs = explode($sep, $IDs);
1294 1294
         }
1295 1295
         foreach ($IDs as $item) {
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
     {
1326 1326
         $out = array();
1327 1327
         foreach ($this->_docs as $doc => $val) {
1328
-            if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) {
1328
+            if (isset($val[$userField]) && (($uniq && ! in_array($val[$userField], $out)) || ! $uniq)) {
1329 1329
                 $out[$doc] = $val[$userField];
1330 1330
             }
1331 1331
         }
@@ -1414,7 +1414,7 @@  discard block
 block discarded – undo
1414 1414
                             $out['order'] = $tmp;
1415 1415
                         // no break
1416 1416
                     }
1417
-                    if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1417
+                    if ('' == $out['order'] || ! in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1418 1418
                         $out['order'] = $orderDef; //Default
1419 1419
                     }
1420 1420
 
@@ -1509,21 +1509,21 @@  discard block
 block discarded – undo
1509 1509
         $children = array(); // children of each ID
1510 1510
         $ids = array();
1511 1511
         foreach ($data as $i => $r) {
1512
-            $row =& $data[$i];
1512
+            $row = & $data[$i];
1513 1513
             $id = $row[$idName];
1514 1514
             $pid = $row[$pidName];
1515
-            $children[$pid][$id] =& $row;
1516
-            if (!isset($children[$id])) {
1515
+            $children[$pid][$id] = & $row;
1516
+            if ( ! isset($children[$id])) {
1517 1517
                 $children[$id] = array();
1518 1518
             }
1519
-            $row['#childNodes'] =& $children[$id];
1519
+            $row['#childNodes'] = & $children[$id];
1520 1520
             $ids[$row[$idName]] = true;
1521 1521
         }
1522 1522
         // Root elements are elements with non-found PIDs.
1523 1523
         $this->_tree = array();
1524 1524
         foreach ($data as $i => $r) {
1525
-            $row =& $data[$i];
1526
-            if (!isset($ids[$row[$pidName]])) {
1525
+            $row = & $data[$i];
1526
+            if ( ! isset($ids[$row[$pidName]])) {
1527 1527
                 $this->_tree[$row[$idName]] = $row;
1528 1528
             }
1529 1529
         }
@@ -1539,10 +1539,10 @@  discard block
 block discarded – undo
1539 1539
      */
1540 1540
     public function getPK($full = true)
1541 1541
     {
1542
-        $idField = isset($this->idField) ? $this->idField: 'id';
1542
+        $idField = isset($this->idField) ? $this->idField : 'id';
1543 1543
         if ($full) {
1544 1544
             $idField = '`' . $idField . '`';
1545
-            if (!empty($this->alias)) {
1545
+            if ( ! empty($this->alias)) {
1546 1546
                 $idField = '`' . $this->alias . '`.' . $idField;
1547 1547
             }
1548 1548
         }
@@ -1559,9 +1559,9 @@  discard block
 block discarded – undo
1559 1559
     public function getParentField($full = true)
1560 1560
     {
1561 1561
         $parentField = isset($this->parentField) ? $this->parentField : '';
1562
-        if ($full && !empty($parentField)) {
1562
+        if ($full && ! empty($parentField)) {
1563 1563
             $parentField = '`' . $parentField . '`';
1564
-            if (!empty($this->alias)) {
1564
+            if ( ! empty($this->alias)) {
1565 1565
                 $parentField = '`' . $this->alias . '`.' . $parentField;
1566 1566
             }
1567 1567
         }
@@ -1581,7 +1581,7 @@  discard block
 block discarded – undo
1581 1581
         $this->debug->debug("getFilters: " . $this->debug->dumpData($filter_string), 'getFilter', 1);
1582 1582
         // the filter parameter tells us, which filters can be used in this query
1583 1583
         $filter_string = trim($filter_string, ' ;');
1584
-        if (!$filter_string) {
1584
+        if ( ! $filter_string) {
1585 1585
             return;
1586 1586
         }
1587 1587
         $output = array('join' => '', 'where' => '');
@@ -1594,7 +1594,7 @@  discard block
 block discarded – undo
1594 1594
                 $subfilters = $this->smartSplit($subfilters);
1595 1595
                 foreach ($subfilters as $subfilter) {
1596 1596
                     $subfilter = $this->getFilters(trim($subfilter));
1597
-                    if (!$subfilter) {
1597
+                    if ( ! $subfilter) {
1598 1598
                         continue;
1599 1599
                     }
1600 1600
                     if ($subfilter['join']) {
@@ -1604,14 +1604,14 @@  discard block
 block discarded – undo
1604 1604
                         $wheres[] = $subfilter['where'];
1605 1605
                     }
1606 1606
                 }
1607
-                $output['join'] = !empty($joins) ? implode(' ', $joins) : '';
1608
-                $output['where'] = !empty($wheres) ? '(' . implode($sql, $wheres) . ')' : '';
1607
+                $output['join'] = ! empty($joins) ? implode(' ', $joins) : '';
1608
+                $output['where'] = ! empty($wheres) ? '(' . implode($sql, $wheres) . ')' : '';
1609 1609
             }
1610 1610
         }
1611 1611
 
1612
-        if (!$logic_op_found) {
1612
+        if ( ! $logic_op_found) {
1613 1613
             $filter = $this->loadFilter($filter_string);
1614
-            if (!$filter) {
1614
+            if ( ! $filter) {
1615 1615
                 $this->debug->warning('Error while loading DocLister filter "' . $this->debug->dumpData($filter_string) . '": check syntax!');
1616 1616
                 $output = false;
1617 1617
             } else {
@@ -1645,8 +1645,8 @@  discard block
 block discarded – undo
1645 1645
      * @return $this
1646 1646
      */
1647 1647
     public function setFiltersJoin($join = '') {
1648
-        if (!empty($join)) {
1649
-            if (!empty($this->_filters['join'])) {
1648
+        if ( ! empty($join)) {
1649
+            if ( ! empty($this->_filters['join'])) {
1650 1650
                 $this->_filters['join'] .= ' ' . $join;
1651 1651
             } else {
1652 1652
                 $this->_filters['join'] = $join;
@@ -1699,7 +1699,7 @@  discard block
 block discarded – undo
1699 1699
         $fltr_params = explode(':', $filter, 2);
1700 1700
         $fltr = APIHelpers::getkey($fltr_params, 0, null);
1701 1701
         // check if the filter is implemented
1702
-        if (!is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1702
+        if ( ! is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1703 1703
             require_once dirname(__FILE__) . '/filter/' . $fltr . '.filter.php';
1704 1704
             /**
1705 1705
              * @var tv_DL_filter|content_DL_filter $fltr_class
Please login to merge, or discard this patch.
Braces   +293 added lines, -290 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';
@@ -1028,13 +1028,13 @@  discard block
 block discarded – undo
1028 1028
         $this->renderTPL = $this->getCFGDef('tpl' . $iterationName, $this->renderTPL);
1029 1029
         $iteration = $i;
1030 1030
 
1031
-        if ($this->extPaginate) {
1031
+        if ($this->extPaginate) {
1032 1032
             $offset = $this->getCFGDef('reversePagination',
1033 1033
                 0) && $this->extPaginate->currentPage() > 1 ? $this->extPaginate->totalPage() * $this->getCFGDef('display',
1034 1034
                     0) - $this->extPaginate->totalDocs() : 0;
1035 1035
             if ($this->getCFGDef('maxDocs', 0) && !$this->getCFGDef('reversePagination',
1036 1036
                     0) && $this->extPaginate->currentPage() == $this->extPaginate->totalPage()
1037
-            ) {
1037
+            ) {
1038 1038
                 $iteration += $this->getCFGDef('display', 0);
1039 1039
             }
1040 1040
             $iteration += $this->getCFGDef('display',
@@ -1044,20 +1044,20 @@  discard block
 block discarded – undo
1044 1044
         $data[$this->getCFGDef("sysKey",
1045 1045
             "dl") . '.full_iteration'] = $iteration;
1046 1046
 
1047
-        if ($i == 1) {
1047
+        if ($i == 1) {
1048 1048
             $this->renderTPL = $this->getCFGDef('tplFirst', $this->renderTPL);
1049 1049
             $class[] = $this->getCFGDef('firstClass', 'first');
1050 1050
         }
1051
-        if ($i == (count($this->_docs) - $this->skippedDocs)) {
1051
+        if ($i == (count($this->_docs) - $this->skippedDocs)) {
1052 1052
             $this->renderTPL = $this->getCFGDef('tplLast', $this->renderTPL);
1053 1053
             $class[] = $this->getCFGDef('lastClass', 'last');
1054 1054
         }
1055
-        if ($this->modx->documentIdentifier == $data['id']) {
1055
+        if ($this->modx->documentIdentifier == $data['id']) {
1056 1056
             $this->renderTPL = $this->getCFGDef('tplCurrent', $this->renderTPL);
1057 1057
             $data[$this->getCFGDef("sysKey",
1058 1058
                 "dl") . '.active'] = 1; //[+active+] - 1 if $modx->documentIdentifer equal ID this element
1059 1059
             $class[] = $this->getCFGDef('currentClass', 'current');
1060
-        } else {
1060
+        } else {
1061 1061
             $data[$this->getCFGDef("sysKey", "dl") . '.active'] = 0;
1062 1062
         }
1063 1063
 
@@ -1068,8 +1068,8 @@  discard block
 block discarded – undo
1068 1068
          * @var $extE e_DL_Extender
1069 1069
          */
1070 1070
         $extE = $this->getExtender('e', true, true);
1071
-        if ($out = $extE->init($this, compact('data'))) {
1072
-            if (is_array($out)) {
1071
+        if ($out = $extE->init($this, compact('data'))) {
1072
+            if (is_array($out)) {
1073 1073
                 $data = $out;
1074 1074
             }
1075 1075
         }
@@ -1085,42 +1085,43 @@  discard block
 block discarded – undo
1085 1085
      * @param array $array данные которые необходимо примешать к ответу на каждой записи $data
1086 1086
      * @return string JSON строка
1087 1087
      */
1088
-    public function getJSON($data, $fields, $array = array())
1089
-    {
1088
+    public function getJSON($data, $fields, $array = array())
1089
+    {
1090 1090
         $out = array();
1091 1091
         $fields = is_array($fields) ? $fields : explode(",", $fields);
1092
-        if (is_array($array) && count($array) > 0) {
1092
+        if (is_array($array) && count($array) > 0) {
1093 1093
             $tmp = array();
1094
-            foreach ($data as $i => $v) { //array_merge not valid work with integer index key
1094
+            foreach ($data as $i => $v) {
1095
+//array_merge not valid work with integer index key
1095 1096
                 $tmp[$i] = (isset($array[$i]) ? array_merge($v, $array[$i]) : $v);
1096 1097
             }
1097 1098
             $data = $tmp;
1098 1099
         }
1099 1100
 
1100
-        foreach ($data as $num => $doc) {
1101
+        foreach ($data as $num => $doc) {
1101 1102
             $tmp = array();
1102
-            foreach ($doc as $name => $value) {
1103
-                if (in_array($name, $fields) || (isset($fields[0]) && $fields[0] == '1')) {
1103
+            foreach ($doc as $name => $value) {
1104
+                if (in_array($name, $fields) || (isset($fields[0]) && $fields[0] == '1')) {
1104 1105
                     $tmp[str_replace(".", "_", $name)] = $value; //JSON element name without dot
1105 1106
                 }
1106 1107
             }
1107 1108
             $out[$num] = $tmp;
1108 1109
         }
1109 1110
 
1110
-        if ('new' == $this->getCFGDef('JSONformat', 'old')) {
1111
+        if ('new' == $this->getCFGDef('JSONformat', 'old')) {
1111 1112
             $return = array();
1112 1113
 
1113 1114
             $return['rows'] = array();
1114
-            foreach ($out as $key => $item) {
1115
+            foreach ($out as $key => $item) {
1115 1116
                 $return['rows'][] = $item;
1116 1117
             }
1117 1118
             $return['total'] = $this->getChildrenCount();
1118
-        } elseif ('simple' == $this->getCFGDef('JSONformat', 'old')) {
1119
+        } elseif ('simple' == $this->getCFGDef('JSONformat', 'old')) {
1119 1120
             $return = array();
1120
-            foreach ($out as $key => $item) {
1121
+            foreach ($out as $key => $item) {
1121 1122
                 $return[] = $item;
1122 1123
             }
1123
-        } else {
1124
+        } else {
1124 1125
             $return = $out;
1125 1126
         }
1126 1127
         $this->outData = json_encode($return);
@@ -1136,11 +1137,11 @@  discard block
 block discarded – undo
1136 1137
      * @param string $contentField
1137 1138
      * @return mixed|string
1138 1139
      */
1139
-    protected function getSummary(array $item = array(), $extSummary = null, $introField = '', $contentField = '')
1140
-    {
1140
+    protected function getSummary(array $item = array(), $extSummary = null, $introField = '', $contentField = '')
1141
+    {
1141 1142
         $out = '';
1142 1143
 
1143
-        if (is_null($extSummary)) {
1144
+        if (is_null($extSummary)) {
1144 1145
             /**
1145 1146
              * @var $extSummary summary_DL_Extender
1146 1147
              */
@@ -1149,10 +1150,10 @@  discard block
 block discarded – undo
1149 1150
         $introField = $this->getCFGDef("introField", $introField);
1150 1151
         $contentField = $this->getCFGDef("contentField", $contentField);
1151 1152
 
1152
-        if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1153
+        if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1153 1154
             $out = $item[$introField];
1154
-        } else {
1155
-            if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1155
+        } else {
1156
+            if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1156 1157
                 $out = $extSummary->init($this, array(
1157 1158
                     "content"      => $item[$contentField],
1158 1159
                     "action"       => $this->getCFGDef("summary", ""),
@@ -1170,8 +1171,8 @@  discard block
 block discarded – undo
1170 1171
      * @param string $name extender name
1171 1172
      * @return boolean status extender load
1172 1173
      */
1173
-    public function checkExtender($name)
1174
-    {
1174
+    public function checkExtender($name)
1175
+    {
1175 1176
         return (isset($this->extender[$name]) && $this->extender[$name] instanceof $name . "_DL_Extender");
1176 1177
     }
1177 1178
 
@@ -1179,8 +1180,8 @@  discard block
 block discarded – undo
1179 1180
      * @param $name
1180 1181
      * @param $obj
1181 1182
      */
1182
-    public function setExtender($name, $obj)
1183
-    {
1183
+    public function setExtender($name, $obj)
1184
+    {
1184 1185
         $this->extender[$name] = $obj;
1185 1186
     }
1186 1187
 
@@ -1192,13 +1193,13 @@  discard block
 block discarded – undo
1192 1193
      * @param bool $nop если экстендер не загружен, то загружать ли xNop
1193 1194
      * @return null|xNop
1194 1195
      */
1195
-    public function getExtender($name, $autoload = false, $nop = false)
1196
-    {
1196
+    public function getExtender($name, $autoload = false, $nop = false)
1197
+    {
1197 1198
         $out = null;
1198
-        if ((is_scalar($name) && $this->checkExtender($name)) || ($autoload && $this->_loadExtender($name))) {
1199
+        if ((is_scalar($name) && $this->checkExtender($name)) || ($autoload && $this->_loadExtender($name))) {
1199 1200
             $out = $this->extender[$name];
1200 1201
         }
1201
-        if ($nop && is_null($out)) {
1202
+        if ($nop && is_null($out)) {
1202 1203
             $out = new xNop();
1203 1204
         }
1204 1205
 
@@ -1211,27 +1212,27 @@  discard block
 block discarded – undo
1211 1212
      * @param string $name name extender
1212 1213
      * @return boolean $flag status load extender
1213 1214
      */
1214
-    protected function _loadExtender($name)
1215
-    {
1215
+    protected function _loadExtender($name)
1216
+    {
1216 1217
         $this->debug->debug('Load Extender ' . $this->debug->dumpData($name), 'LoadExtender', 2);
1217 1218
         $flag = false;
1218 1219
 
1219 1220
         $classname = ($name != '') ? $name . "_DL_Extender" : "";
1220
-        if ($classname != '' && isset($this->extender[$name]) && $this->extender[$name] instanceof $classname) {
1221
+        if ($classname != '' && isset($this->extender[$name]) && $this->extender[$name] instanceof $classname) {
1221 1222
             $flag = true;
1222 1223
 
1223
-        } else {
1224
-            if (!class_exists($classname, false) && $classname != '') {
1225
-                if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) {
1224
+        } else {
1225
+            if (!class_exists($classname, false) && $classname != '') {
1226
+                if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) {
1226 1227
                     include_once(dirname(__FILE__) . "/extender/" . $name . ".extender.inc");
1227 1228
                 }
1228 1229
             }
1229
-            if (class_exists($classname, false) && $classname != '') {
1230
+            if (class_exists($classname, false) && $classname != '') {
1230 1231
                 $this->extender[$name] = new $classname($this, $name);
1231 1232
                 $flag = true;
1232 1233
             }
1233 1234
         }
1234
-        if (!$flag) {
1235
+        if (!$flag) {
1235 1236
             $this->debug->debug("Error load Extender " . $this->debug->dumpData($name));
1236 1237
         }
1237 1238
         $this->debug->debugEnd('LoadExtender');
@@ -1249,16 +1250,16 @@  discard block
 block discarded – undo
1249 1250
      * @param mixed $IDs список id документов по которым необходима выборка
1250 1251
      * @return array очищенный массив
1251 1252
      */
1252
-    public function setIDs($IDs)
1253
-    {
1253
+    public function setIDs($IDs)
1254
+    {
1254 1255
         $this->debug->debug('set ID list ' . $this->debug->dumpData($IDs), 'setIDs', 2);
1255 1256
         $IDs = $this->cleanIDs($IDs);
1256 1257
         $type = $this->getCFGDef('idType', 'parents');
1257 1258
         $depth = $this->getCFGDef('depth', '');
1258
-        if ($type == 'parents' && $depth > 0) {
1259
+        if ($type == 'parents' && $depth > 0) {
1259 1260
             $tmp = $IDs;
1260
-            do {
1261
-                if (count($tmp) > 0) {
1261
+            do {
1262
+                if (count($tmp) > 0) {
1262 1263
                     $tmp = $this->getChildrenFolder($tmp);
1263 1264
                     $IDs = array_merge($IDs, $tmp);
1264 1265
                 }
@@ -1272,8 +1273,8 @@  discard block
 block discarded – undo
1272 1273
     /**
1273 1274
      * @return int
1274 1275
      */
1275
-    public function getIDs()
1276
-    {
1276
+    public function getIDs()
1277
+    {
1277 1278
         return $this->IDs;
1278 1279
     }
1279 1280
 
@@ -1284,17 +1285,18 @@  discard block
 block discarded – undo
1284 1285
      * @param string $sep разделитель
1285 1286
      * @return array очищенный массив с данными
1286 1287
      */
1287
-    public function cleanIDs($IDs, $sep = ',')
1288
-    {
1288
+    public function cleanIDs($IDs, $sep = ',')
1289
+    {
1289 1290
         $this->debug->debug('clean IDs ' . $this->debug->dumpData($IDs) . ' with separator ' . $this->debug->dumpData($sep),
1290 1291
             'cleanIDs', 2);
1291 1292
         $out = array();
1292
-        if (!is_array($IDs)) {
1293
+        if (!is_array($IDs)) {
1293 1294
             $IDs = explode($sep, $IDs);
1294 1295
         }
1295
-        foreach ($IDs as $item) {
1296
+        foreach ($IDs as $item) {
1296 1297
             $item = trim($item);
1297
-            if (is_numeric($item) && (int)$item >= 0) { //Fix 0xfffffffff
1298
+            if (is_numeric($item) && (int)$item >= 0) {
1299
+//Fix 0xfffffffff
1298 1300
                 $out[] = (int)$item;
1299 1301
             }
1300 1302
         }
@@ -1308,8 +1310,8 @@  discard block
 block discarded – undo
1308 1310
      * Проверка массива с id-шниками документов для выборки
1309 1311
      * @return boolean пригодны ли данные для дальнейшего использования
1310 1312
      */
1311
-    protected function checkIDs()
1312
-    {
1313
+    protected function checkIDs()
1314
+    {
1313 1315
         return (is_array($this->IDs) && count($this->IDs) > 0) ? true : false;
1314 1316
     }
1315 1317
 
@@ -1321,11 +1323,11 @@  discard block
 block discarded – undo
1321 1323
      * @global array $_docs all documents
1322 1324
      * @return array all field values
1323 1325
      */
1324
-    public function getOneField($userField, $uniq = false)
1325
-    {
1326
+    public function getOneField($userField, $uniq = false)
1327
+    {
1326 1328
         $out = array();
1327
-        foreach ($this->_docs as $doc => $val) {
1328
-            if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) {
1329
+        foreach ($this->_docs as $doc => $val) {
1330
+            if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) {
1329 1331
                 $out[$doc] = $val[$userField];
1330 1332
             }
1331 1333
         }
@@ -1336,8 +1338,8 @@  discard block
 block discarded – undo
1336 1338
     /**
1337 1339
      * @return DLCollection
1338 1340
      */
1339
-    public function docsCollection()
1340
-    {
1341
+    public function docsCollection()
1342
+    {
1341 1343
         return new DLCollection($this->modx, $this->_docs);
1342 1344
     }
1343 1345
 
@@ -1365,10 +1367,10 @@  discard block
 block discarded – undo
1365 1367
      * @param string $group
1366 1368
      * @return string
1367 1369
      */
1368
-    protected function getGroupSQL($group = '')
1369
-    {
1370
+    protected function getGroupSQL($group = '')
1371
+    {
1370 1372
         $out = '';
1371
-        if ($group != '') {
1373
+        if ($group != '') {
1372 1374
             $out = 'GROUP BY ' . $group;
1373 1375
         }
1374 1376
 
@@ -1387,12 +1389,12 @@  discard block
 block discarded – undo
1387 1389
      *
1388 1390
      * @return string Order by for SQL
1389 1391
      */
1390
-    protected function SortOrderSQL($sortName, $orderDef = 'DESC')
1391
-    {
1392
+    protected function SortOrderSQL($sortName, $orderDef = 'DESC')
1393
+    {
1392 1394
         $this->debug->debug('', 'sortORDER', 2);
1393 1395
 
1394 1396
         $sort = '';
1395
-        switch ($this->getCFGDef('sortType', '')) {
1397
+        switch ($this->getCFGDef('sortType', '')) {
1396 1398
             case 'none':
1397 1399
                 break;
1398 1400
             case 'doclist':
@@ -1403,10 +1405,10 @@  discard block
 block discarded – undo
1403 1405
                 break;
1404 1406
             default:
1405 1407
                 $out = array('orderBy' => '', 'order' => '', 'sortBy' => '');
1406
-                if (($tmp = $this->getCFGDef('orderBy', '')) != '') {
1408
+                if (($tmp = $this->getCFGDef('orderBy', '')) != '') {
1407 1409
                     $out['orderBy'] = $tmp;
1408
-                } else {
1409
-                    switch (true) {
1410
+                } else {
1411
+                    switch (true) {
1410 1412
                         case ('' != ($tmp = $this->getCFGDef('sortDir', ''))): //higher priority than order
1411 1413
                             $out['order'] = $tmp;
1412 1414
                         // no break
@@ -1414,7 +1416,7 @@  discard block
 block discarded – undo
1414 1416
                             $out['order'] = $tmp;
1415 1417
                         // no break
1416 1418
                     }
1417
-                    if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1419
+                    if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1418 1420
                         $out['order'] = $orderDef; //Default
1419 1421
                     }
1420 1422
 
@@ -1435,30 +1437,30 @@  discard block
 block discarded – undo
1435 1437
      *
1436 1438
      * @return string LIMIT вставка в SQL запрос
1437 1439
      */
1438
-    protected function LimitSQL($limit = 0, $offset = 0)
1439
-    {
1440
+    protected function LimitSQL($limit = 0, $offset = 0)
1441
+    {
1440 1442
         $this->debug->debug('', 'limitSQL', 2);
1441 1443
         $ret = '';
1442
-        if ($limit == 0) {
1444
+        if ($limit == 0) {
1443 1445
             $limit = $this->getCFGDef('display', 0);
1444 1446
         }
1445 1447
         $maxDocs = $this->getCFGDef('maxDocs', 0);
1446
-        if ($maxDocs > 0 && $limit > $maxDocs) {
1448
+        if ($maxDocs > 0 && $limit > $maxDocs) {
1447 1449
             $limit = $maxDocs;
1448 1450
         }
1449
-        if ($offset == 0) {
1451
+        if ($offset == 0) {
1450 1452
             $offset = $this->getCFGDef('offset', 0);
1451 1453
         }
1452 1454
         $offset += $this->getCFGDef('start', 0);
1453 1455
         $total = $this->getCFGDef('total', 0);
1454
-        if ($limit < ($total - $limit)) {
1456
+        if ($limit < ($total - $limit)) {
1455 1457
             $limit = $total - $offset;
1456 1458
         }
1457 1459
 
1458
-        if ($limit != 0) {
1460
+        if ($limit != 0) {
1459 1461
             $ret = "LIMIT " . (int)$offset . "," . (int)$limit;
1460
-        } else {
1461
-            if ($offset != 0) {
1462
+        } else {
1463
+            if ($offset != 0) {
1462 1464
                 /**
1463 1465
                  * 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
1464 1466
                  * @see http://dev.mysql.com/doc/refman/5.0/en/select.html
@@ -1478,8 +1480,8 @@  discard block
 block discarded – undo
1478 1480
      * @param string $charset
1479 1481
      * @return string Clear string
1480 1482
      */
1481
-    public function sanitarData($data, $charset = 'UTF-8')
1482
-    {
1483
+    public function sanitarData($data, $charset = 'UTF-8')
1484
+    {
1483 1485
         return APIHelpers::sanitarTag($data, $charset);
1484 1486
     }
1485 1487
 
@@ -1490,8 +1492,8 @@  discard block
 block discarded – undo
1490 1492
      * @param string $parentField default name parent field
1491 1493
      * @return array
1492 1494
      */
1493
-    public function treeBuild($idField = 'id', $parentField = 'parent')
1494
-    {
1495
+    public function treeBuild($idField = 'id', $parentField = 'parent')
1496
+    {
1495 1497
         return $this->_treeBuild($this->_docs, $this->getCFGDef('idField', $idField),
1496 1498
             $this->getCFGDef('parentField', $parentField));
1497 1499
     }
@@ -1504,16 +1506,16 @@  discard block
 block discarded – undo
1504 1506
      * @param string $pidName name parent field in associative data array
1505 1507
      * @return array
1506 1508
      */
1507
-    private function _treeBuild($data, $idName, $pidName)
1508
-    {
1509
+    private function _treeBuild($data, $idName, $pidName)
1510
+    {
1509 1511
         $children = array(); // children of each ID
1510 1512
         $ids = array();
1511
-        foreach ($data as $i => $r) {
1513
+        foreach ($data as $i => $r) {
1512 1514
             $row =& $data[$i];
1513 1515
             $id = $row[$idName];
1514 1516
             $pid = $row[$pidName];
1515 1517
             $children[$pid][$id] =& $row;
1516
-            if (!isset($children[$id])) {
1518
+            if (!isset($children[$id])) {
1517 1519
                 $children[$id] = array();
1518 1520
             }
1519 1521
             $row['#childNodes'] =& $children[$id];
@@ -1521,9 +1523,9 @@  discard block
 block discarded – undo
1521 1523
         }
1522 1524
         // Root elements are elements with non-found PIDs.
1523 1525
         $this->_tree = array();
1524
-        foreach ($data as $i => $r) {
1526
+        foreach ($data as $i => $r) {
1525 1527
             $row =& $data[$i];
1526
-            if (!isset($ids[$row[$pidName]])) {
1528
+            if (!isset($ids[$row[$pidName]])) {
1527 1529
                 $this->_tree[$row[$idName]] = $row;
1528 1530
             }
1529 1531
         }
@@ -1537,12 +1539,12 @@  discard block
 block discarded – undo
1537 1539
      * @param bool $full если true то возвращается значение для подстановки в запрос
1538 1540
      * @return string PrimaryKey основной таблицы
1539 1541
      */
1540
-    public function getPK($full = true)
1541
-    {
1542
+    public function getPK($full = true)
1543
+    {
1542 1544
         $idField = isset($this->idField) ? $this->idField: 'id';
1543
-        if ($full) {
1545
+        if ($full) {
1544 1546
             $idField = '`' . $idField . '`';
1545
-            if (!empty($this->alias)) {
1547
+            if (!empty($this->alias)) {
1546 1548
                 $idField = '`' . $this->alias . '`.' . $idField;
1547 1549
             }
1548 1550
         }
@@ -1556,12 +1558,12 @@  discard block
 block discarded – undo
1556 1558
      * @param bool $full если true то возвращается значение для подстановки в запрос
1557 1559
      * @return string Parent Key основной таблицы
1558 1560
      */
1559
-    public function getParentField($full = true)
1560
-    {
1561
+    public function getParentField($full = true)
1562
+    {
1561 1563
         $parentField = isset($this->parentField) ? $this->parentField : '';
1562
-        if ($full && !empty($parentField)) {
1564
+        if ($full && !empty($parentField)) {
1563 1565
             $parentField = '`' . $parentField . '`';
1564
-            if (!empty($this->alias)) {
1566
+            if (!empty($this->alias)) {
1565 1567
                 $parentField = '`' . $this->alias . '`.' . $parentField;
1566 1568
             }
1567 1569
         }
@@ -1576,31 +1578,31 @@  discard block
 block discarded – undo
1576 1578
      * @param string $filter_string строка со всеми фильтрами
1577 1579
      * @return mixed результат разбора фильтров
1578 1580
      */
1579
-    protected function getFilters($filter_string)
1580
-    {
1581
+    protected function getFilters($filter_string)
1582
+    {
1581 1583
         $this->debug->debug("getFilters: " . $this->debug->dumpData($filter_string), 'getFilter', 1);
1582 1584
         // the filter parameter tells us, which filters can be used in this query
1583 1585
         $filter_string = trim($filter_string, ' ;');
1584
-        if (!$filter_string) {
1586
+        if (!$filter_string) {
1585 1587
             return;
1586 1588
         }
1587 1589
         $output = array('join' => '', 'where' => '');
1588 1590
         $logic_op_found = false;
1589 1591
         $joins = $wheres = array();
1590
-        foreach ($this->_logic_ops as $op => $sql) {
1591
-            if (strpos($filter_string, $op) === 0) {
1592
+        foreach ($this->_logic_ops as $op => $sql) {
1593
+            if (strpos($filter_string, $op) === 0) {
1592 1594
                 $logic_op_found = true;
1593 1595
                 $subfilters = mb_substr($filter_string, strlen($op) + 1, mb_strlen($filter_string, "UTF-8"), "UTF-8");
1594 1596
                 $subfilters = $this->smartSplit($subfilters);
1595
-                foreach ($subfilters as $subfilter) {
1597
+                foreach ($subfilters as $subfilter) {
1596 1598
                     $subfilter = $this->getFilters(trim($subfilter));
1597
-                    if (!$subfilter) {
1599
+                    if (!$subfilter) {
1598 1600
                         continue;
1599 1601
                     }
1600
-                    if ($subfilter['join']) {
1602
+                    if ($subfilter['join']) {
1601 1603
                         $joins[] = $subfilter['join'];
1602 1604
                     }
1603
-                    if ($subfilter['where']) {
1605
+                    if ($subfilter['where']) {
1604 1606
                         $wheres[] = $subfilter['where'];
1605 1607
                     }
1606 1608
                 }
@@ -1609,12 +1611,12 @@  discard block
 block discarded – undo
1609 1611
             }
1610 1612
         }
1611 1613
 
1612
-        if (!$logic_op_found) {
1614
+        if (!$logic_op_found) {
1613 1615
             $filter = $this->loadFilter($filter_string);
1614
-            if (!$filter) {
1616
+            if (!$filter) {
1615 1617
                 $this->debug->warning('Error while loading DocLister filter "' . $this->debug->dumpData($filter_string) . '": check syntax!');
1616 1618
                 $output = false;
1617
-            } else {
1619
+            } else {
1618 1620
                 $output['join'] = $filter->get_join();
1619 1621
                 $output['where'] = $filter->get_where();
1620 1622
             }
@@ -1627,16 +1629,16 @@  discard block
 block discarded – undo
1627 1629
     /**
1628 1630
      * @return mixed
1629 1631
      */
1630
-    public function filtersWhere()
1631
-    {
1632
+    public function filtersWhere()
1633
+    {
1632 1634
         return APIHelpers::getkey($this->_filters, 'where', '');
1633 1635
     }
1634 1636
 
1635 1637
     /**
1636 1638
      * @return mixed
1637 1639
      */
1638
-    public function filtersJoin()
1639
-    {
1640
+    public function filtersJoin()
1641
+    {
1640 1642
         return APIHelpers::getkey($this->_filters, 'join', '');
1641 1643
     }
1642 1644
 
@@ -1644,11 +1646,12 @@  discard block
 block discarded – undo
1644 1646
      * @param string $join
1645 1647
      * @return $this
1646 1648
      */
1647
-    public function setFiltersJoin($join = '') {
1648
-        if (!empty($join)) {
1649
-            if (!empty($this->_filters['join'])) {
1649
+    public function setFiltersJoin($join = '')
1650
+    {
1651
+        if (!empty($join)) {
1652
+            if (!empty($this->_filters['join'])) {
1650 1653
                 $this->_filters['join'] .= ' ' . $join;
1651
-            } else {
1654
+            } else {
1652 1655
                 $this->_filters['join'] = $join;
1653 1656
             }
1654 1657
         }
@@ -1663,10 +1666,10 @@  discard block
 block discarded – undo
1663 1666
      * @param $type string тип фильтрации
1664 1667
      * @return string имя поля с учетом приведения типа
1665 1668
      */
1666
-    public function changeSortType($field, $type)
1667
-    {
1669
+    public function changeSortType($field, $type)
1670
+    {
1668 1671
         $type = trim($type);
1669
-        switch (strtoupper($type)) {
1672
+        switch (strtoupper($type)) {
1670 1673
             case 'DECIMAL':
1671 1674
                 $field = 'CAST(' . $field . ' as DECIMAL(10,2))';
1672 1675
                 break;
@@ -1692,14 +1695,14 @@  discard block
 block discarded – undo
1692 1695
      * @param string $filter срока с параметрами фильтрации
1693 1696
      * @return bool
1694 1697
      */
1695
-    protected function loadFilter($filter)
1696
-    {
1698
+    protected function loadFilter($filter)
1699
+    {
1697 1700
         $this->debug->debug('Load filter ' . $this->debug->dumpData($filter), 'loadFilter', 2);
1698 1701
         $out = false;
1699 1702
         $fltr_params = explode(':', $filter, 2);
1700 1703
         $fltr = APIHelpers::getkey($fltr_params, 0, null);
1701 1704
         // check if the filter is implemented
1702
-        if (!is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1705
+        if (!is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1703 1706
             require_once dirname(__FILE__) . '/filter/' . $fltr . '.filter.php';
1704 1707
             /**
1705 1708
              * @var tv_DL_filter|content_DL_filter $fltr_class
@@ -1707,12 +1710,12 @@  discard block
 block discarded – undo
1707 1710
             $fltr_class = $fltr . '_DL_filter';
1708 1711
             $this->totalFilters++;
1709 1712
             $fltr_obj = new $fltr_class();
1710
-            if ($fltr_obj->init($this, $filter)) {
1713
+            if ($fltr_obj->init($this, $filter)) {
1711 1714
                 $out = $fltr_obj;
1712
-            } else {
1715
+            } else {
1713 1716
                 $this->debug->error("Wrong filter parameter: '{$this->debug->dumpData($filter)}'", 'Filter');
1714 1717
             }
1715
-        } else {
1718
+        } else {
1716 1719
             $this->debug->error("Error load Filter: '{$this->debug->dumpData($filter)}'", 'Filter');
1717 1720
         }
1718 1721
         $this->debug->debugEnd("loadFilter");
@@ -1724,8 +1727,8 @@  discard block
 block discarded – undo
1724 1727
      * Общее число фильтров
1725 1728
      * @return int
1726 1729
      */
1727
-    public function getCountFilters()
1728
-    {
1730
+    public function getCountFilters()
1731
+    {
1729 1732
         return (int)$this->totalFilters;
1730 1733
     }
1731 1734
 
@@ -1733,8 +1736,8 @@  discard block
 block discarded – undo
1733 1736
      * Выполнить SQL запрос
1734 1737
      * @param string $q SQL запрос
1735 1738
      */
1736
-    public function dbQuery($q)
1737
-    {
1739
+    public function dbQuery($q)
1740
+    {
1738 1741
         $this->debug->debug($q, "query", 1, 'sql');
1739 1742
         $out = $this->modx->db->query($q);
1740 1743
         $this->debug->debugEnd("query");
@@ -1752,8 +1755,8 @@  discard block
 block discarded – undo
1752 1755
      * @param string $tpl шаблон подстановки значения в SQL запрос
1753 1756
      * @return string строка для подстановки в SQL запрос
1754 1757
      */
1755
-    public function LikeEscape($field, $value, $escape = '=', $tpl = '%[+value+]%')
1756
-    {
1758
+    public function LikeEscape($field, $value, $escape = '=', $tpl = '%[+value+]%')
1759
+    {
1757 1760
         return sqlHelper::LikeEscape($this->modx, $field, $value, $escape, $tpl);
1758 1761
     }
1759 1762
 
@@ -1761,8 +1764,8 @@  discard block
 block discarded – undo
1761 1764
      * Получение REQUEST_URI без GET-ключа с
1762 1765
      * @return string
1763 1766
      */
1764
-    public function getRequest()
1765
-    {
1767
+    public function getRequest()
1768
+    {
1766 1769
         $URL = null;
1767 1770
         parse_str(parse_url(MODX_SITE_URL . $_SERVER['REQUEST_URI'], PHP_URL_QUERY), $URL);
1768 1771
 
Please login to merge, or discard this patch.