Completed
Push — master ( 18ab51...e42513 )
by
unknown
02:43 queued 13s
created
assets/snippets/DocLister/core/DocLister.abstract.php 2 patches
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('MODX_BASE_PATH')) {
2
+if ( ! defined('MODX_BASE_PATH')) {
3 3
     die('HACK???');
4 4
 }
5 5
 /**
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
             $this->modx = $modx;
199 199
             $this->setDebug(1);
200 200
 
201
-            if (!is_array($cfg) || empty($cfg)) {
201
+            if ( ! is_array($cfg) || empty($cfg)) {
202 202
                 $cfg = $this->modx->Event->params;
203 203
             }
204 204
         } else {
@@ -389,11 +389,11 @@  discard block
 block discarded – undo
389 389
      */
390 390
     public function getTable($name, $alias = '')
391 391
     {
392
-        if (!isset($this->_table[$name])) {
392
+        if ( ! isset($this->_table[$name])) {
393 393
             $this->_table[$name] = $this->modx->getFullTableName($name);
394 394
         }
395 395
         $table = $this->_table[$name];
396
-        if (!empty($alias) && is_scalar($alias)) {
396
+        if ( ! empty($alias) && is_scalar($alias)) {
397 397
             $table .= " as `" . $alias . "`";
398 398
         }
399 399
 
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
      */
409 409
     public function TableAlias($name, $table, $alias)
410 410
     {
411
-        if (!$this->checkTableAlias($name, $table)) {
411
+        if ( ! $this->checkTableAlias($name, $table)) {
412 412
             $this->AddTable[$table][$name] = $alias;
413 413
         }
414 414
 
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
     public function isErrorJSON($json)
454 454
     {
455 455
         $error = jsonHelper::json_last_error_msg();
456
-        if (!in_array($error, array('error_none', 'other'))) {
456
+        if ( ! in_array($error, array('error_none', 'other'))) {
457 457
             $this->debug->error($this->getMsg('json.' . $error) . ": " . $this->debug->dumpData($json, 'code'), 'JSON');
458 458
             $error = true;
459 459
         }
@@ -472,13 +472,13 @@  discard block
 block discarded – undo
472 472
         $extenders = $this->getCFGDef('extender', '');
473 473
         $extenders = explode(",", $extenders);
474 474
         $tmp = $this->getCFGDef('requestActive', '') != '' || in_array('request', $extenders);
475
-        if ($tmp && !$this->_loadExtender('request')) {
475
+        if ($tmp && ! $this->_loadExtender('request')) {
476 476
             //OR request in extender's parameter
477 477
             throw new Exception('Error load request extender');
478 478
         }
479 479
 
480 480
         $tmp = $this->getCFGDef('summary', '') != '' || in_array('summary', $extenders);
481
-        if ($tmp && !$this->_loadExtender('summary')) {
481
+        if ($tmp && ! $this->_loadExtender('summary')) {
482 482
             //OR summary in extender's parameter
483 483
             throw new Exception('Error load summary extender');
484 484
         }
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
                 $this->getCFGDef('TplCurrentPage', '') != '' || $this->getCFGDef('TplWrapPaginate', '') != '' ||
491 491
                 $this->getCFGDef('pageLimit', '') != '' || $this->getCFGDef('pageAdjacents', '') != '' ||
492 492
                 $this->getCFGDef('PaginateClass', '') != '' || $this->getCFGDef('TplNextP', '') != ''
493
-            ) && !$this->_loadExtender('paginate')
493
+            ) && ! $this->_loadExtender('paginate')
494 494
         ) {
495 495
             throw new Exception('Error load paginate extender');
496 496
         } else {
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
         if ($ext != '') {
658 658
             $ext = explode(",", $ext);
659 659
             foreach ($ext as $item) {
660
-                if ($item != '' && !$this->_loadExtender($item)) {
660
+                if ($item != '' && ! $this->_loadExtender($item)) {
661 661
                     throw new Exception('Error load ' . APIHelpers::e($item) . ' extender');
662 662
                 }
663 663
             }
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
      */
719 719
     public function sanitarIn($data, $sep = ',', $quote = true)
720 720
     {
721
-        if (!is_array($data)) {
721
+        if ( ! is_array($data)) {
722 722
             $data = explode($sep, $data);
723 723
         }
724 724
         $out = array();
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
     protected function renderTree($data)
856 856
     {
857 857
         $out = '';
858
-        if (!empty($data['#childNodes'])) {
858
+        if ( ! empty($data['#childNodes'])) {
859 859
             foreach ($data['#childNodes'] as $item) {
860 860
                 $out .= $this->renderTree($item);
861 861
             }
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
     public function parseLang($tpl)
895 895
     {
896 896
         $this->debug->debug(array("parseLang" => $tpl), "parseLang", 2, array('html'));
897
-        if (is_scalar($tpl) && !empty($tpl)) {
897
+        if (is_scalar($tpl) && ! empty($tpl)) {
898 898
             if (preg_match_all("/\[\%([a-zA-Z0-9\.\_\-]+)\%\]/", $tpl, $match)) {
899 899
                 $langVal = array();
900 900
                 foreach ($match[1] as $item) {
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
     {
970 970
         $out = $data;
971 971
         $docs = count($this->_docs) - $this->skippedDocs;
972
-        if ((($this->getCFGDef("noneWrapOuter", "1") && $docs == 0) || $docs > 0) && !empty($this->ownerTPL)) {
972
+        if ((($this->getCFGDef("noneWrapOuter", "1") && $docs == 0) || $docs > 0) && ! empty($this->ownerTPL)) {
973 973
             $this->debug->debug("", "renderWrapTPL", 2);
974 974
             $parse = true;
975 975
             $plh = array($this->getCFGDef("sysKey", "dl") . ".wrap" => $data);
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
                 }
993 993
                 $plh = $params;
994 994
             }
995
-            if ($parse && !empty($this->ownerTPL)) {
995
+            if ($parse && ! empty($this->ownerTPL)) {
996 996
                 $this->debug->updateMessage(
997 997
                     array("render ownerTPL" => $this->ownerTPL, "With data" => print_r($plh, 1)),
998 998
                     "renderWrapTPL",
@@ -1136,10 +1136,10 @@  discard block
 block discarded – undo
1136 1136
         $introField = $this->getCFGDef("introField", $introField);
1137 1137
         $contentField = $this->getCFGDef("contentField", $contentField);
1138 1138
 
1139
-        if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1139
+        if ( ! empty($introField) && ! empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1140 1140
             $out = $item[$introField];
1141 1141
         } else {
1142
-            if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1142
+            if ( ! empty($contentField) && ! empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1143 1143
                 $out = $extSummary->init($this, array(
1144 1144
                     "content"      => $item[$contentField],
1145 1145
                     "action"       => $this->getCFGDef("summary", ""),
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
             $flag = true;
1209 1209
 
1210 1210
         } else {
1211
-            if (!class_exists($classname, false) && $classname != '') {
1211
+            if ( ! class_exists($classname, false) && $classname != '') {
1212 1212
                 if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) {
1213 1213
                     include_once(dirname(__FILE__) . "/extender/" . $name . ".extender.inc");
1214 1214
                 }
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
                 $flag = true;
1219 1219
             }
1220 1220
         }
1221
-        if (!$flag) {
1221
+        if ( ! $flag) {
1222 1222
             $this->debug->debug("Error load Extender " . $this->debug->dumpData($name));
1223 1223
         }
1224 1224
         $this->debug->debugEnd('LoadExtender');
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
         $this->debug->debug('clean IDs ' . $this->debug->dumpData($IDs) . ' with separator ' . $this->debug->dumpData($sep),
1277 1277
             'cleanIDs', 2);
1278 1278
         $out = array();
1279
-        if (!is_array($IDs)) {
1279
+        if ( ! is_array($IDs)) {
1280 1280
             $IDs = explode($sep, $IDs);
1281 1281
         }
1282 1282
         foreach ($IDs as $item) {
@@ -1312,7 +1312,7 @@  discard block
 block discarded – undo
1312 1312
     {
1313 1313
         $out = array();
1314 1314
         foreach ($this->_docs as $doc => $val) {
1315
-            if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) {
1315
+            if (isset($val[$userField]) && (($uniq && ! in_array($val[$userField], $out)) || ! $uniq)) {
1316 1316
                 $out[$doc] = $val[$userField];
1317 1317
             }
1318 1318
         }
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
                             $out['order'] = $tmp;
1402 1402
                         // no break
1403 1403
                     }
1404
-                    if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1404
+                    if ('' == $out['order'] || ! in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1405 1405
                         $out['order'] = $orderDef; //Default
1406 1406
                     }
1407 1407
 
@@ -1492,21 +1492,21 @@  discard block
 block discarded – undo
1492 1492
         $children = array(); // children of each ID
1493 1493
         $ids = array();
1494 1494
         foreach ($data as $i => $r) {
1495
-            $row =& $data[$i];
1495
+            $row = & $data[$i];
1496 1496
             $id = $row[$idName];
1497 1497
             $pid = $row[$pidName];
1498
-            $children[$pid][$id] =& $row;
1499
-            if (!isset($children[$id])) {
1498
+            $children[$pid][$id] = & $row;
1499
+            if ( ! isset($children[$id])) {
1500 1500
                 $children[$id] = array();
1501 1501
             }
1502
-            $row['#childNodes'] =& $children[$id];
1502
+            $row['#childNodes'] = & $children[$id];
1503 1503
             $ids[$row[$idName]] = true;
1504 1504
         }
1505 1505
         // Root elements are elements with non-found PIDs.
1506 1506
         $this->_tree = array();
1507 1507
         foreach ($data as $i => $r) {
1508
-            $row =& $data[$i];
1509
-            if (!isset($ids[$row[$pidName]])) {
1508
+            $row = & $data[$i];
1509
+            if ( ! isset($ids[$row[$pidName]])) {
1510 1510
                 $this->_tree[$row[$idName]] = $row;
1511 1511
             }
1512 1512
         }
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
     public function getPK()
1524 1524
     {
1525 1525
         $idField = isset($this->idField) ? $this->idField : 'id';
1526
-        if (!empty($this->alias)) {
1526
+        if ( ! empty($this->alias)) {
1527 1527
             $idField = $this->alias . '.' . $idField;
1528 1528
         }
1529 1529
 
@@ -1538,7 +1538,7 @@  discard block
 block discarded – undo
1538 1538
     public function getParentField()
1539 1539
     {
1540 1540
         $parentField = isset($this->parentField) ? $this->parentField : '';
1541
-        if (!empty($parentField) && !empty($this->alias)) {
1541
+        if ( ! empty($parentField) && ! empty($this->alias)) {
1542 1542
             $parentField = $this->alias . '.' . $parentField;
1543 1543
         }
1544 1544
 
@@ -1557,7 +1557,7 @@  discard block
 block discarded – undo
1557 1557
         $this->debug->debug("getFilters: " . $this->debug->dumpData($filter_string), 'getFilter', 1);
1558 1558
         // the filter parameter tells us, which filters can be used in this query
1559 1559
         $filter_string = trim($filter_string, ' ;');
1560
-        if (!$filter_string) {
1560
+        if ( ! $filter_string) {
1561 1561
             return;
1562 1562
         }
1563 1563
         $output = array('join' => '', 'where' => '');
@@ -1570,7 +1570,7 @@  discard block
 block discarded – undo
1570 1570
                 $subfilters = $this->smartSplit($subfilters);
1571 1571
                 foreach ($subfilters as $subfilter) {
1572 1572
                     $subfilter = $this->getFilters(trim($subfilter));
1573
-                    if (!$subfilter) {
1573
+                    if ( ! $subfilter) {
1574 1574
                         continue;
1575 1575
                     }
1576 1576
                     if ($subfilter['join']) {
@@ -1580,14 +1580,14 @@  discard block
 block discarded – undo
1580 1580
                         $wheres[] = $subfilter['where'];
1581 1581
                     }
1582 1582
                 }
1583
-                $output['join'] = !empty($joins) ? implode(' ', $joins) : '';
1584
-                $output['where'] = !empty($wheres) ? '(' . implode($sql, $wheres) . ')' : '';
1583
+                $output['join'] = ! empty($joins) ? implode(' ', $joins) : '';
1584
+                $output['where'] = ! empty($wheres) ? '(' . implode($sql, $wheres) . ')' : '';
1585 1585
             }
1586 1586
         }
1587 1587
 
1588
-        if (!$logic_op_found) {
1588
+        if ( ! $logic_op_found) {
1589 1589
             $filter = $this->loadFilter($filter_string);
1590
-            if (!$filter) {
1590
+            if ( ! $filter) {
1591 1591
                 $this->debug->warning('Error while loading DocLister filter "' . $this->debug->dumpData($filter_string) . '": check syntax!');
1592 1592
                 $output = false;
1593 1593
             } else {
@@ -1659,7 +1659,7 @@  discard block
 block discarded – undo
1659 1659
         $fltr_params = explode(':', $filter, 2);
1660 1660
         $fltr = APIHelpers::getkey($fltr_params, 0, null);
1661 1661
         // check if the filter is implemented
1662
-        if (!is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1662
+        if ( ! is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1663 1663
             require_once dirname(__FILE__) . '/filter/' . $fltr . '.filter.php';
1664 1664
             /**
1665 1665
              * @var tv_DL_filter|content_DL_filter $fltr_class
Please login to merge, or discard this patch.
Braces   +283 added lines, -281 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('MODX_BASE_PATH')) {
2
+if (!defined('MODX_BASE_PATH')) {
3 3
     die('HACK???');
4 4
 }
5 5
 /**
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 /**
21 21
  * Class DocLister
22 22
  */
23
-abstract class DocLister
24
-{
23
+abstract class DocLister
24
+{
25 25
     /**
26 26
      * Ключ в массиве $_REQUEST в котором находится алиас запрашиваемого документа
27 27
      */
@@ -184,48 +184,48 @@  discard block
 block discarded – undo
184 184
      * @param int $startTime время запуска сниппета
185 185
      * @throws Exception
186 186
      */
187
-    public function __construct($modx, $cfg = array(), $startTime = null)
188
-    {
187
+    public function __construct($modx, $cfg = array(), $startTime = null)
188
+    {
189 189
         $this->setTimeStart($startTime);
190 190
 
191
-        if (extension_loaded('mbstring')) {
191
+        if (extension_loaded('mbstring')) {
192 192
             mb_internal_encoding("UTF-8");
193
-        } else {
193
+        } else {
194 194
             throw new Exception('Not found php extension mbstring');
195 195
         }
196 196
 
197
-        if ($modx instanceof DocumentParser) {
197
+        if ($modx instanceof DocumentParser) {
198 198
             $this->modx = $modx;
199 199
             $this->setDebug(1);
200 200
 
201
-            if (!is_array($cfg) || empty($cfg)) {
201
+            if (!is_array($cfg) || empty($cfg)) {
202 202
                 $cfg = $this->modx->Event->params;
203 203
             }
204
-        } else {
204
+        } else {
205 205
             throw new Exception('MODX var is not instaceof DocumentParser');
206 206
         }
207 207
 
208 208
         $this->FS = \Helpers\FS::getInstance();
209 209
         $this->config = new \Helpers\Config($cfg);
210 210
 
211
-        if (isset($cfg['config'])) {
211
+        if (isset($cfg['config'])) {
212 212
             $this->config->setPath(dirname(__DIR__))->loadConfig($cfg['config']);
213 213
         }
214 214
 
215
-        if ($this->config->setConfig($cfg) === false) {
215
+        if ($this->config->setConfig($cfg) === false) {
216 216
             throw new Exception('no parameters to run DocLister');
217 217
         }
218 218
 
219 219
         $this->loadLang(array('core', 'json'));
220 220
         $this->setDebug($this->getCFGDef('debug', 0));
221 221
 
222
-        if ($this->checkDL()) {
222
+        if ($this->checkDL()) {
223 223
             $cfg = array();
224 224
             $idType = $this->getCFGDef('idType', '');
225
-            if (empty($idType) && $this->getCFGDef('documents', '') != '') {
225
+            if (empty($idType) && $this->getCFGDef('documents', '') != '') {
226 226
                 $idType = 'documents';
227 227
             }
228
-            switch ($idType) {
228
+            switch ($idType) {
229 229
                 case 'documents':
230 230
                     $IDs = $this->getCFGDef('documents');
231 231
                     $cfg['idType'] = "documents";
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
                 case 'parents':
234 234
                 default:
235 235
                     $cfg['idType'] = "parents";
236
-                    if (($IDs = $this->getCFGDef('parents')) === null) {
236
+                    if (($IDs = $this->getCFGDef('parents')) === null) {
237 237
                         $IDs = $this->getCurrentMODXPageID();
238 238
                     }
239 239
                     break;
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
 
253 253
         $this->setLocate();
254 254
 
255
-        if ($this->getCFGDef("customLang")) {
255
+        if ($this->getCFGDef("customLang")) {
256 256
             $this->getCustomLang();
257 257
         }
258 258
         $this->loadExtender($this->getCFGDef("extender", ""));
259 259
 
260
-        if ($this->checkExtender('request')) {
260
+        if ($this->checkExtender('request')) {
261 261
             $this->extender['request']->init($this, $this->getCFGDef("requestActive", ""));
262 262
         }
263 263
         $this->_filters = $this->getFilters($this->getCFGDef('filters', ''));
@@ -269,21 +269,21 @@  discard block
 block discarded – undo
269 269
      * @param string $str строка с фильтром
270 270
      * @return array массив субфильтров
271 271
      */
272
-    public function smartSplit($str)
273
-    {
272
+    public function smartSplit($str)
273
+    {
274 274
         $res = array();
275 275
         $cur = '';
276 276
         $open = 0;
277 277
         $strlen = mb_strlen($str, 'UTF-8');
278
-        for ($i = 0; $i <= $strlen; $i++) {
278
+        for ($i = 0; $i <= $strlen; $i++) {
279 279
             $e = mb_substr($str, $i, 1, 'UTF-8');
280
-            switch ($e) {
280
+            switch ($e) {
281 281
                 case ')':
282 282
                     $open--;
283
-                    if ($open == 0) {
283
+                    if ($open == 0) {
284 284
                         $res[] = $cur . ')';
285 285
                         $cur = '';
286
-                    } else {
286
+                    } else {
287 287
                         $cur .= $e;
288 288
                     }
289 289
                     break;
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
                     $cur .= $e;
293 293
                     break;
294 294
                 case ';':
295
-                    if ($open == 0) {
295
+                    if ($open == 0) {
296 296
                         $res[] = $cur;
297 297
                         $cur = '';
298
-                    } else {
298
+                    } else {
299 299
                         $cur .= $e;
300 300
                     }
301 301
                     break;
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
             }
305 305
         }
306 306
         $cur = preg_replace("/(\))$/u", '', $cur);
307
-        if ($cur != '') {
307
+        if ($cur != '') {
308 308
             $res[] = $cur;
309 309
         }
310 310
 
@@ -315,8 +315,8 @@  discard block
 block discarded – undo
315 315
      * Трансформация объекта в строку
316 316
      * @return string последний ответ от DocLister'а
317 317
      */
318
-    public function __toString()
319
-    {
318
+    public function __toString()
319
+    {
320 320
         return $this->outData;
321 321
     }
322 322
 
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
      * Установить время запуска сниппета
325 325
      * @param float|null $time
326 326
      */
327
-    public function setTimeStart($time = null)
328
-    {
327
+    public function setTimeStart($time = null)
328
+    {
329 329
         $this->_timeStart = is_null($time) ? microtime(true) : $time;
330 330
     }
331 331
 
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
      *
335 335
      * @return int
336 336
      */
337
-    public function getTimeStart()
338
-    {
337
+    public function getTimeStart()
338
+    {
339 339
         return $this->_timeStart;
340 340
     }
341 341
 
@@ -343,27 +343,27 @@  discard block
 block discarded – undo
343 343
      * Установка режима отладки
344 344
      * @param int $flag режим отладки
345 345
      */
346
-    public function setDebug($flag = 0)
347
-    {
346
+    public function setDebug($flag = 0)
347
+    {
348 348
         $flag = abs((int)$flag);
349
-        if ($this->_debugMode != $flag) {
349
+        if ($this->_debugMode != $flag) {
350 350
             $this->_debugMode = $flag;
351 351
             $this->debug = null;
352
-            if ($this->_debugMode > 0) {
353
-                if (isset($_SESSION['usertype']) && $_SESSION['usertype'] == 'manager') {
352
+            if ($this->_debugMode > 0) {
353
+                if (isset($_SESSION['usertype']) && $_SESSION['usertype'] == 'manager') {
354 354
                     error_reporting(E_ALL ^ E_NOTICE);
355 355
                     ini_set('display_errors', 1);
356 356
                 }
357 357
                 $dir = dirname(dirname(__FILE__));
358
-                if (file_exists($dir . "/lib/DLdebug.class.php")) {
358
+                if (file_exists($dir . "/lib/DLdebug.class.php")) {
359 359
                     include_once($dir . "/lib/DLdebug.class.php");
360
-                    if (class_exists("DLdebug", false)) {
360
+                    if (class_exists("DLdebug", false)) {
361 361
                         $this->debug = new DLdebug($this);
362 362
                     }
363 363
                 }
364 364
             }
365 365
 
366
-            if (is_null($this->debug)) {
366
+            if (is_null($this->debug)) {
367 367
                 $this->debug = new xNop();
368 368
                 $this->_debugMode = 0;
369 369
                 error_reporting(0);
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
     /**
376 376
      * Информация о режиме отладки
377 377
      */
378
-    public function getDebug()
379
-    {
378
+    public function getDebug()
379
+    {
380 380
         return $this->_debugMode;
381 381
     }
382 382
 
@@ -387,13 +387,13 @@  discard block
 block discarded – undo
387 387
      * @param string $alias желаемый алиас таблицы
388 388
      * @return string имя таблицы с префиксом и алиасом
389 389
      */
390
-    public function getTable($name, $alias = '')
391
-    {
392
-        if (!isset($this->_table[$name])) {
390
+    public function getTable($name, $alias = '')
391
+    {
392
+        if (!isset($this->_table[$name])) {
393 393
             $this->_table[$name] = $this->modx->getFullTableName($name);
394 394
         }
395 395
         $table = $this->_table[$name];
396
-        if (!empty($alias) && is_scalar($alias)) {
396
+        if (!empty($alias) && is_scalar($alias)) {
397 397
             $table .= " as `" . $alias . "`";
398 398
         }
399 399
 
@@ -406,9 +406,9 @@  discard block
 block discarded – undo
406 406
      * @param $alias
407 407
      * @return mixed
408 408
      */
409
-    public function TableAlias($name, $table, $alias)
410
-    {
411
-        if (!$this->checkTableAlias($name, $table)) {
409
+    public function TableAlias($name, $table, $alias)
410
+    {
411
+        if (!$this->checkTableAlias($name, $table)) {
412 412
             $this->AddTable[$table][$name] = $alias;
413 413
         }
414 414
 
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
      * @param $table
421 421
      * @return bool
422 422
      */
423
-    public function checkTableAlias($name, $table)
424
-    {
423
+    public function checkTableAlias($name, $table)
424
+    {
425 425
         return isset($this->AddTable[$table][$name]);
426 426
     }
427 427
 
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
      * @param bool $nop создавать ли пустой объект запрашиваемого типа
434 434
      * @return array|mixed|xNop
435 435
      */
436
-    public function jsonDecode($json, $config = array(), $nop = false)
437
-    {
436
+    public function jsonDecode($json, $config = array(), $nop = false)
437
+    {
438 438
         $this->debug->debug('Decode JSON: ' . $this->debug->dumpData($json) . "\r\nwith config: " . $this->debug->dumpData($config),
439 439
             'jsonDecode', 2);
440 440
         $config = jsonHelper::jsonDecode($json, $config, $nop);
@@ -450,10 +450,10 @@  discard block
 block discarded – undo
450 450
      * @param $json string строка с JSON для записи в лог при отладке
451 451
      * @return bool|string
452 452
      */
453
-    public function isErrorJSON($json)
454
-    {
453
+    public function isErrorJSON($json)
454
+    {
455 455
         $error = jsonHelper::json_last_error_msg();
456
-        if (!in_array($error, array('error_none', 'other'))) {
456
+        if (!in_array($error, array('error_none', 'other'))) {
457 457
             $this->debug->error($this->getMsg('json.' . $error) . ": " . $this->debug->dumpData($json, 'code'), 'JSON');
458 458
             $error = true;
459 459
         }
@@ -465,20 +465,20 @@  discard block
 block discarded – undo
465 465
      * Проверка параметров и загрузка необходимых экстендеров
466 466
      * return boolean статус загрузки
467 467
      */
468
-    public function checkDL()
469
-    {
468
+    public function checkDL()
469
+    {
470 470
         $this->debug->debug('Check DocLister parameters', 'checkDL', 2);
471 471
         $flag = true;
472 472
         $extenders = $this->getCFGDef('extender', '');
473 473
         $extenders = explode(",", $extenders);
474 474
         $tmp = $this->getCFGDef('requestActive', '') != '' || in_array('request', $extenders);
475
-        if ($tmp && !$this->_loadExtender('request')) {
475
+        if ($tmp && !$this->_loadExtender('request')) {
476 476
             //OR request in extender's parameter
477 477
             throw new Exception('Error load request extender');
478 478
         }
479 479
 
480 480
         $tmp = $this->getCFGDef('summary', '') != '' || in_array('summary', $extenders);
481
-        if ($tmp && !$this->_loadExtender('summary')) {
481
+        if ($tmp && !$this->_loadExtender('summary')) {
482 482
             //OR summary in extender's parameter
483 483
             throw new Exception('Error load summary extender');
484 484
         }
@@ -491,15 +491,15 @@  discard block
 block discarded – undo
491 491
                 $this->getCFGDef('pageLimit', '') != '' || $this->getCFGDef('pageAdjacents', '') != '' ||
492 492
                 $this->getCFGDef('PaginateClass', '') != '' || $this->getCFGDef('TplNextP', '') != ''
493 493
             ) && !$this->_loadExtender('paginate')
494
-        ) {
494
+        ) {
495 495
             throw new Exception('Error load paginate extender');
496
-        } else {
497
-            if ((int)$this->getCFGDef('display', 0) == 0) {
496
+        } else {
497
+            if ((int)$this->getCFGDef('display', 0) == 0) {
498 498
                 $extenders = $this->unsetArrayVal($extenders, 'paginate');
499 499
             }
500 500
         }
501 501
 
502
-        if ($this->getCFGDef('prepare', '') != '' || $this->getCFGDef('prepareWrap') != '') {
502
+        if ($this->getCFGDef('prepare', '') != '' || $this->getCFGDef('prepareWrap') != '') {
503 503
             $this->_loadExtender('prepare');
504 504
         }
505 505
 
@@ -516,14 +516,14 @@  discard block
 block discarded – undo
516 516
      * @param mixed $val значение которые необходимо удалить из массива
517 517
      * @return array отчищеный массив с данными
518 518
      */
519
-    private function unsetArrayVal($data, $val)
520
-    {
519
+    private function unsetArrayVal($data, $val)
520
+    {
521 521
         $out = array();
522
-        if (is_array($data)) {
523
-            foreach ($data as $item) {
524
-                if ($item != $val) {
522
+        if (is_array($data)) {
523
+            foreach ($data as $item) {
524
+                if ($item != $val) {
525 525
                     $out[] = $item;
526
-                } else {
526
+                } else {
527 527
                     continue;
528 528
                 }
529 529
             }
@@ -538,14 +538,14 @@  discard block
 block discarded – undo
538 538
      * @param int $id уникальный идентификатор страницы
539 539
      * @return string URL страницы
540 540
      */
541
-    public function getUrl($id = 0)
542
-    {
541
+    public function getUrl($id = 0)
542
+    {
543 543
         $id = ((int)$id > 0) ? (int)$id : $this->getCurrentMODXPageID();
544 544
 
545 545
         $link = $this->checkExtender('request') ? $this->extender['request']->getLink() : $this->getRequest();
546
-        if ($id == $this->modx->config['site_start']) {
546
+        if ($id == $this->modx->config['site_start']) {
547 547
             $url = $this->modx->config['site_url'] . ($link != '' ? "?{$link}" : "");
548
-        } else {
548
+        } else {
549 549
             $url = $this->modx->makeUrl($id, '', $link, $this->getCFGDef('urlScheme', ''));
550 550
         }
551 551
 
@@ -573,20 +573,20 @@  discard block
 block discarded – undo
573 573
      * @param string $tpl шаблон
574 574
      * @return string
575 575
      */
576
-    public function render($tpl = '')
577
-    {
576
+    public function render($tpl = '')
577
+    {
578 578
         $this->debug->debug(array('Render data with template ' => $tpl), 'render', 2, array('html'));
579 579
         $out = '';
580
-        if (1 == $this->getCFGDef('tree', '0')) {
581
-            foreach ($this->_tree as $item) {
580
+        if (1 == $this->getCFGDef('tree', '0')) {
581
+            foreach ($this->_tree as $item) {
582 582
                 $out .= $this->renderTree($item);
583 583
             }
584 584
             $out = $this->renderWrap($out);
585
-        } else {
585
+        } else {
586 586
             $out = $this->_render($tpl);
587 587
         }
588 588
 
589
-        if ($out) {
589
+        if ($out) {
590 590
             $this->outData = DLTemplate::getInstance($this->modx)->parseDocumentSource($out);
591 591
         }
592 592
         $this->debug->debugEnd('render');
@@ -603,8 +603,8 @@  discard block
 block discarded – undo
603 603
      *
604 604
      * @return int
605 605
      */
606
-    public function getCurrentMODXPageID()
607
-    {
606
+    public function getCurrentMODXPageID()
607
+    {
608 608
         $id = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0;
609 609
         $docData = isset($this->modx->documentObject) ? $this->modx->documentObject : array();
610 610
 
@@ -620,9 +620,9 @@  discard block
 block discarded – undo
620 620
      * @param integer $line error on line
621 621
      * @param array $trace stack trace
622 622
      */
623
-    public function ErrorLogger($message, $code, $file, $line, $trace)
624
-    {
625
-        if (abs($this->getCFGDef('debug', '0')) == '1') {
623
+    public function ErrorLogger($message, $code, $file, $line, $trace)
624
+    {
625
+        if (abs($this->getCFGDef('debug', '0')) == '1') {
626 626
             $out = "CODE #" . $code . "<br />";
627 627
             $out .= "on file: " . $file . ":" . $line . "<br />";
628 628
             $out .= "<pre>";
@@ -639,8 +639,8 @@  discard block
 block discarded – undo
639 639
      *
640 640
      * @return DocumentParser
641 641
      */
642
-    public function getMODX()
643
-    {
642
+    public function getMODX()
643
+    {
644 644
         return $this->modx;
645 645
     }
646 646
 
@@ -651,13 +651,13 @@  discard block
 block discarded – undo
651 651
      * @return boolean status load extenders
652 652
      * @throws Exception
653 653
      */
654
-    public function loadExtender($ext = '')
655
-    {
654
+    public function loadExtender($ext = '')
655
+    {
656 656
         $out = true;
657
-        if ($ext != '') {
657
+        if ($ext != '') {
658 658
             $ext = explode(",", $ext);
659
-            foreach ($ext as $item) {
660
-                if ($item != '' && !$this->_loadExtender($item)) {
659
+            foreach ($ext as $item) {
660
+                if ($item != '' && !$this->_loadExtender($item)) {
661 661
                     throw new Exception('Error load ' . APIHelpers::e($item) . ' extender');
662 662
                 }
663 663
             }
@@ -673,8 +673,8 @@  discard block
 block discarded – undo
673 673
      * @param mixed $def значение по умолчанию, если в конфиге нет искомого параметра
674 674
      * @return mixed значение из конфига
675 675
      */
676
-    public function getCFGDef($name, $def = null)
677
-    {
676
+    public function getCFGDef($name, $def = null)
677
+    {
678 678
         return $this->config->getCFGDef($name, $def);
679 679
     }
680 680
 
@@ -686,15 +686,15 @@  discard block
 block discarded – undo
686 686
      * @param string $key ключ локального плейсхолдера
687 687
      * @return string
688 688
      */
689
-    public function toPlaceholders($data, $set = 0, $key = 'contentPlaceholder')
690
-    {
689
+    public function toPlaceholders($data, $set = 0, $key = 'contentPlaceholder')
690
+    {
691 691
         $this->debug->debug(null, 'toPlaceholders', 2);
692
-        if ($set == 0) {
692
+        if ($set == 0) {
693 693
             $set = $this->getCFGDef('contentPlaceholder', 0);
694 694
         }
695 695
         $this->_plh[$key] = $data;
696 696
         $id = $this->getCFGDef('id', '');
697
-        if ($id != '') {
697
+        if ($id != '') {
698 698
             $id .= ".";
699 699
         }
700 700
         $out = DLTemplate::getInstance($this->getMODX())->toPlaceholders($data, $set, $key, $id);
@@ -716,14 +716,14 @@  discard block
 block discarded – undo
716 716
      * @param boolean $quote заключать ли данные на выходе в кавычки
717 717
      * @return string обработанная строка
718 718
      */
719
-    public function sanitarIn($data, $sep = ',', $quote = true)
720
-    {
721
-        if (!is_array($data)) {
719
+    public function sanitarIn($data, $sep = ',', $quote = true)
720
+    {
721
+        if (!is_array($data)) {
722 722
             $data = explode($sep, $data);
723 723
         }
724 724
         $out = array();
725
-        foreach ($data as $item) {
726
-            if ($item !== '') {
725
+        foreach ($data as $item) {
726
+            if ($item !== '') {
727 727
                 $out[] = $this->modx->db->escape($item);
728 728
             }
729 729
         }
@@ -744,12 +744,12 @@  discard block
 block discarded – undo
744 744
      * @param string $lang имя языкового пакета
745 745
      * @return array
746 746
      */
747
-    public function getCustomLang($lang = '')
748
-    {
749
-        if (empty($lang)) {
747
+    public function getCustomLang($lang = '')
748
+    {
749
+        if (empty($lang)) {
750 750
             $lang = $this->getCFGDef('lang', $this->modx->config['manager_language']);
751 751
         }
752
-        if (file_exists(dirname(dirname(__FILE__)) . "/lang/" . $lang . ".php")) {
752
+        if (file_exists(dirname(dirname(__FILE__)) . "/lang/" . $lang . ".php")) {
753 753
             $tmp = include(dirname(__FILE__) . "/lang/" . $lang . ".php");
754 754
             $this->_customLang = is_array($tmp) ? $tmp : array();
755 755
         }
@@ -765,25 +765,25 @@  discard block
 block discarded – undo
765 765
      * @param boolean $rename Переименовывать ли элементы массива
766 766
      * @return array массив с лексиконом
767 767
      */
768
-    public function loadLang($name = 'core', $lang = '', $rename = true)
769
-    {
770
-        if (empty($lang)) {
768
+    public function loadLang($name = 'core', $lang = '', $rename = true)
769
+    {
770
+        if (empty($lang)) {
771 771
             $lang = $this->getCFGDef('lang', $this->modx->config['manager_language']);
772 772
         }
773 773
 
774 774
         $this->debug->debug('Load language ' . $this->debug->dumpData($name) . "." . $this->debug->dumpData($lang),
775 775
             'loadlang', 2);
776
-        if (is_scalar($name)) {
776
+        if (is_scalar($name)) {
777 777
             $name = array($name);
778 778
         }
779
-        foreach ($name as $n) {
780
-            if (file_exists(dirname(__FILE__) . "/lang/" . $lang . "/" . $n . ".inc.php")) {
779
+        foreach ($name as $n) {
780
+            if (file_exists(dirname(__FILE__) . "/lang/" . $lang . "/" . $n . ".inc.php")) {
781 781
                 $tmp = include(dirname(__FILE__) . "/lang/" . $lang . "/" . $n . ".inc.php");
782
-                if (is_array($tmp)) {
782
+                if (is_array($tmp)) {
783 783
                     /**
784 784
                      * Переименовыываем элементы массива из array('test'=>'data') в array('name.test'=>'data')
785 785
                      */
786
-                    if ($rename) {
786
+                    if ($rename) {
787 787
                         $tmp = $this->renameKeyArr($tmp, $n, '', '.');
788 788
                     }
789 789
                     $this->_lang = array_merge($this->_lang, $tmp);
@@ -802,11 +802,11 @@  discard block
 block discarded – undo
802 802
      * @param string $def Строка по умолчанию, если запись в языковом пакете не будет обнаружена
803 803
      * @return string строка в соответствии с текущими языковыми настройками
804 804
      */
805
-    public function getMsg($name, $def = '')
806
-    {
807
-        if (isset($this->_customLang[$name])) {
805
+    public function getMsg($name, $def = '')
806
+    {
807
+        if (isset($this->_customLang[$name])) {
808 808
             $say = $this->_customLang[$name];
809
-        } else {
809
+        } else {
810 810
             $say = \APIHelpers::getkey($this->_lang, $name, $def);
811 811
         }
812 812
 
@@ -822,8 +822,8 @@  discard block
 block discarded – undo
822 822
      * @param string $sep разделитель суффиксов, префиксов и ключей массива
823 823
      * @return array массив с переименованными ключами
824 824
      */
825
-    public function renameKeyArr($data, $prefix = '', $suffix = '', $sep = '.')
826
-    {
825
+    public function renameKeyArr($data, $prefix = '', $suffix = '', $sep = '.')
826
+    {
827 827
         return \APIHelpers::renameKeyArr($data, $prefix, $suffix, $sep);
828 828
     }
829 829
 
@@ -833,12 +833,12 @@  discard block
 block discarded – undo
833 833
      * @param string $locale локаль
834 834
      * @return string имя установленной локали
835 835
      */
836
-    public function setLocate($locale = '')
837
-    {
838
-        if ('' == $locale) {
836
+    public function setLocate($locale = '')
837
+    {
838
+        if ('' == $locale) {
839 839
             $locale = $this->getCFGDef('locale', '');
840 840
         }
841
-        if ('' != $locale) {
841
+        if ('' != $locale) {
842 842
             setlocale(LC_ALL, $locale);
843 843
         }
844 844
 
@@ -852,11 +852,11 @@  discard block
 block discarded – undo
852 852
      * @param array $data массив сформированный как дерево
853 853
      * @return string строка для отображения пользователю
854 854
      */
855
-    protected function renderTree($data)
856
-    {
855
+    protected function renderTree($data)
856
+    {
857 857
         $out = '';
858
-        if (!empty($data['#childNodes'])) {
859
-            foreach ($data['#childNodes'] as $item) {
858
+        if (!empty($data['#childNodes'])) {
859
+            foreach ($data['#childNodes'] as $item) {
860 860
                 $out .= $this->renderTree($item);
861 861
             }
862 862
         }
@@ -873,8 +873,8 @@  discard block
 block discarded – undo
873 873
      * @param string $name Template: chunk name || @CODE: template || @FILE: file with template
874 874
      * @return string html template with placeholders without data
875 875
      */
876
-    private function _getChunk($name)
877
-    {
876
+    private function _getChunk($name)
877
+    {
878 878
         $this->debug->debug(array('Get chunk by name' => $name), "getChunk", 2, array('html'));
879 879
         //without trim
880 880
         $tpl = DLTemplate::getInstance($this->getMODX())->getChunk($name);
@@ -891,18 +891,18 @@  discard block
 block discarded – undo
891 891
      * @param string $tpl HTML шаблон
892 892
      * @return string
893 893
      */
894
-    public function parseLang($tpl)
895
-    {
894
+    public function parseLang($tpl)
895
+    {
896 896
         $this->debug->debug(array("parseLang" => $tpl), "parseLang", 2, array('html'));
897
-        if (is_scalar($tpl) && !empty($tpl)) {
898
-            if (preg_match_all("/\[\%([a-zA-Z0-9\.\_\-]+)\%\]/", $tpl, $match)) {
897
+        if (is_scalar($tpl) && !empty($tpl)) {
898
+            if (preg_match_all("/\[\%([a-zA-Z0-9\.\_\-]+)\%\]/", $tpl, $match)) {
899 899
                 $langVal = array();
900
-                foreach ($match[1] as $item) {
900
+                foreach ($match[1] as $item) {
901 901
                     $langVal[] = $this->getMsg($item);
902 902
                 }
903 903
                 $tpl = str_replace($match[0], $langVal, $tpl);
904 904
             }
905
-        } else {
905
+        } else {
906 906
             $tpl = '';
907 907
         }
908 908
         $this->debug->debugEnd("parseLang");
@@ -918,24 +918,24 @@  discard block
 block discarded – undo
918 918
      * @param bool $parseDocumentSource render html template via DocumentParser::parseDocumentSource()
919 919
      * @return string html template with data without placeholders
920 920
      */
921
-    public function parseChunk($name, $data, $parseDocumentSource = false)
922
-    {
921
+    public function parseChunk($name, $data, $parseDocumentSource = false)
922
+    {
923 923
         $this->debug->debug(
924 924
             array("parseChunk" => $name, "With data" => print_r($data, 1)),
925 925
             "parseChunk",
926 926
             2, array('html', null)
927 927
         );
928 928
         $DLTemplate = DLTemplate::getInstance($this->getMODX());
929
-        if ($path = $this->getCFGDef('templatePath')) {
929
+        if ($path = $this->getCFGDef('templatePath')) {
930 930
             $DLTemplate->setTemplatePath($path);
931 931
         }
932
-        if ($ext = $this->getCFGDef('templateExtension')) {
932
+        if ($ext = $this->getCFGDef('templateExtension')) {
933 933
             $DLTemplate->setTemplateExtension($ext);
934 934
         }
935 935
         $DLTemplate->setTwigTemplateVars(array('DocLister' => $this));
936 936
         $out = $DLTemplate->parseChunk($name, $data, $parseDocumentSource);
937 937
         $out = $this->parseLang($out);
938
-        if (empty($out)) {
938
+        if (empty($out)) {
939 939
             $this->debug->debug("Empty chunk: " . $this->debug->dumpData($name), '', 2);
940 940
         }
941 941
         $this->debug->debugEnd("parseChunk");
@@ -951,8 +951,8 @@  discard block
 block discarded – undo
951 951
      *
952 952
      * @return string html template from parameter
953 953
      */
954
-    public function getChunkByParam($name, $val = '')
955
-    {
954
+    public function getChunkByParam($name, $val = '')
955
+    {
956 956
         $data = $this->getCFGDef($name, $val);
957 957
         $data = $this->_getChunk($data);
958 958
 
@@ -965,11 +965,11 @@  discard block
 block discarded – undo
965 965
      * @param string $data html код который нужно обернуть в ownerTPL
966 966
      * @return string результатирующий html код
967 967
      */
968
-    public function renderWrap($data)
969
-    {
968
+    public function renderWrap($data)
969
+    {
970 970
         $out = $data;
971 971
         $docs = count($this->_docs) - $this->skippedDocs;
972
-        if ((($this->getCFGDef("noneWrapOuter", "1") && $docs == 0) || $docs > 0) && !empty($this->ownerTPL)) {
972
+        if ((($this->getCFGDef("noneWrapOuter", "1") && $docs == 0) || $docs > 0) && !empty($this->ownerTPL)) {
973 973
             $this->debug->debug("", "renderWrapTPL", 2);
974 974
             $parse = true;
975 975
             $plh = array($this->getCFGDef("sysKey", "dl") . ".wrap" => $data);
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
              * @var $extPrepare prepare_DL_Extender
978 978
              */
979 979
             $extPrepare = $this->getExtender('prepare');
980
-            if ($extPrepare) {
980
+            if ($extPrepare) {
981 981
                 $params = $extPrepare->init($this, array(
982 982
                     'data'      => array(
983 983
                         'docs'         => $this->_docs,
@@ -986,13 +986,13 @@  discard block
 block discarded – undo
986 986
                     'nameParam' => 'prepareWrap',
987 987
                     'return'    => 'placeholders'
988 988
                 ));
989
-                if (is_bool($params) && $params === false) {
989
+                if (is_bool($params) && $params === false) {
990 990
                     $out = $data;
991 991
                     $parse = false;
992 992
                 }
993 993
                 $plh = $params;
994 994
             }
995
-            if ($parse && !empty($this->ownerTPL)) {
995
+            if ($parse && !empty($this->ownerTPL)) {
996 996
                 $this->debug->updateMessage(
997 997
                     array("render ownerTPL" => $this->ownerTPL, "With data" => print_r($plh, 1)),
998 998
                     "renderWrapTPL",
@@ -1000,7 +1000,7 @@  discard block
 block discarded – undo
1000 1000
                 );
1001 1001
                 $out = $this->parseChunk($this->ownerTPL, $plh);
1002 1002
             }
1003
-            if (empty($this->ownerTPL)) {
1003
+            if (empty($this->ownerTPL)) {
1004 1004
                 $this->debug->updateMessage("empty ownerTPL", "renderWrapTPL");
1005 1005
             }
1006 1006
             $this->debug->debugEnd("renderWrapTPL");
@@ -1016,8 +1016,8 @@  discard block
 block discarded – undo
1016 1016
      * @param int $i номер итерации в цикле
1017 1017
      * @return array массив с данными которые можно использовать в цикле render метода
1018 1018
      */
1019
-    protected function uniformPrepare(&$data, $i = 0)
1020
-    {
1019
+    protected function uniformPrepare(&$data, $i = 0)
1020
+    {
1021 1021
         $class = array();
1022 1022
 
1023 1023
         $iterationName = ($i % 2 == 1) ? 'Odd' : 'Even';
@@ -1031,20 +1031,20 @@  discard block
 block discarded – undo
1031 1031
             "dl") . '.full_iteration'] = ($this->extPaginate) ? ($i + $this->getCFGDef('display',
1032 1032
                 0) * ($this->extPaginate->currentPage() - 1)) : $i;
1033 1033
 
1034
-        if ($i == 1) {
1034
+        if ($i == 1) {
1035 1035
             $this->renderTPL = $this->getCFGDef('tplFirst', $this->renderTPL);
1036 1036
             $class[] = $this->getCFGDef('firstClass', 'first');
1037 1037
         }
1038
-        if ($i == (count($this->_docs) - $this->skippedDocs)) {
1038
+        if ($i == (count($this->_docs) - $this->skippedDocs)) {
1039 1039
             $this->renderTPL = $this->getCFGDef('tplLast', $this->renderTPL);
1040 1040
             $class[] = $this->getCFGDef('lastClass', 'last');
1041 1041
         }
1042
-        if ($this->modx->documentIdentifier == $data['id']) {
1042
+        if ($this->modx->documentIdentifier == $data['id']) {
1043 1043
             $this->renderTPL = $this->getCFGDef('tplCurrent', $this->renderTPL);
1044 1044
             $data[$this->getCFGDef("sysKey",
1045 1045
                 "dl") . '.active'] = 1; //[+active+] - 1 if $modx->documentIdentifer equal ID this element
1046 1046
             $class[] = $this->getCFGDef('currentClass', 'current');
1047
-        } else {
1047
+        } else {
1048 1048
             $data[$this->getCFGDef("sysKey", "dl") . '.active'] = 0;
1049 1049
         }
1050 1050
 
@@ -1055,8 +1055,8 @@  discard block
 block discarded – undo
1055 1055
          * @var $extE e_DL_Extender
1056 1056
          */
1057 1057
         $extE = $this->getExtender('e', true, true);
1058
-        if ($out = $extE->init($this, compact('data'))) {
1059
-            if (is_array($out)) {
1058
+        if ($out = $extE->init($this, compact('data'))) {
1059
+            if (is_array($out)) {
1060 1060
                 $data = $out;
1061 1061
             }
1062 1062
         }
@@ -1072,42 +1072,43 @@  discard block
 block discarded – undo
1072 1072
      * @param array $array данные которые необходимо примешать к ответу на каждой записи $data
1073 1073
      * @return string JSON строка
1074 1074
      */
1075
-    public function getJSON($data, $fields, $array = array())
1076
-    {
1075
+    public function getJSON($data, $fields, $array = array())
1076
+    {
1077 1077
         $out = array();
1078 1078
         $fields = is_array($fields) ? $fields : explode(",", $fields);
1079
-        if (is_array($array) && count($array) > 0) {
1079
+        if (is_array($array) && count($array) > 0) {
1080 1080
             $tmp = array();
1081
-            foreach ($data as $i => $v) { //array_merge not valid work with integer index key
1081
+            foreach ($data as $i => $v) {
1082
+//array_merge not valid work with integer index key
1082 1083
                 $tmp[$i] = (isset($array[$i]) ? array_merge($v, $array[$i]) : $v);
1083 1084
             }
1084 1085
             $data = $tmp;
1085 1086
         }
1086 1087
 
1087
-        foreach ($data as $num => $doc) {
1088
+        foreach ($data as $num => $doc) {
1088 1089
             $tmp = array();
1089
-            foreach ($doc as $name => $value) {
1090
-                if (in_array($name, $fields) || (isset($fields[0]) && $fields[0] == '1')) {
1090
+            foreach ($doc as $name => $value) {
1091
+                if (in_array($name, $fields) || (isset($fields[0]) && $fields[0] == '1')) {
1091 1092
                     $tmp[str_replace(".", "_", $name)] = $value; //JSON element name without dot
1092 1093
                 }
1093 1094
             }
1094 1095
             $out[$num] = $tmp;
1095 1096
         }
1096 1097
 
1097
-        if ('new' == $this->getCFGDef('JSONformat', 'old')) {
1098
+        if ('new' == $this->getCFGDef('JSONformat', 'old')) {
1098 1099
             $return = array();
1099 1100
 
1100 1101
             $return['rows'] = array();
1101
-            foreach ($out as $key => $item) {
1102
+            foreach ($out as $key => $item) {
1102 1103
                 $return['rows'][] = APIHelpers::getkey($item, $key, $item);
1103 1104
             }
1104 1105
             $return['total'] = $this->getChildrenCount();
1105
-        } elseif ('simple' == $this->getCFGDef('JSONformat', 'old')) {
1106
+        } elseif ('simple' == $this->getCFGDef('JSONformat', 'old')) {
1106 1107
             $return = array();
1107
-            foreach ($out as $key => $item) {
1108
+            foreach ($out as $key => $item) {
1108 1109
                 $return[] = APIHelpers::getkey($item, $key, $item);
1109 1110
             }
1110
-        } else {
1111
+        } else {
1111 1112
             $return = $out;
1112 1113
         }
1113 1114
         $this->outData = json_encode($return);
@@ -1123,11 +1124,11 @@  discard block
 block discarded – undo
1123 1124
      * @param string $contentField
1124 1125
      * @return mixed|string
1125 1126
      */
1126
-    protected function getSummary(array $item = array(), $extSummary = null, $introField = '', $contentField = '')
1127
-    {
1127
+    protected function getSummary(array $item = array(), $extSummary = null, $introField = '', $contentField = '')
1128
+    {
1128 1129
         $out = '';
1129 1130
 
1130
-        if (is_null($extSummary)) {
1131
+        if (is_null($extSummary)) {
1131 1132
             /**
1132 1133
              * @var $extSummary summary_DL_Extender
1133 1134
              */
@@ -1136,10 +1137,10 @@  discard block
 block discarded – undo
1136 1137
         $introField = $this->getCFGDef("introField", $introField);
1137 1138
         $contentField = $this->getCFGDef("contentField", $contentField);
1138 1139
 
1139
-        if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1140
+        if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1140 1141
             $out = $item[$introField];
1141
-        } else {
1142
-            if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1142
+        } else {
1143
+            if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1143 1144
                 $out = $extSummary->init($this, array(
1144 1145
                     "content"      => $item[$contentField],
1145 1146
                     "action"       => $this->getCFGDef("summary", ""),
@@ -1157,8 +1158,8 @@  discard block
 block discarded – undo
1157 1158
      * @param string $name extender name
1158 1159
      * @return boolean status extender load
1159 1160
      */
1160
-    public function checkExtender($name)
1161
-    {
1161
+    public function checkExtender($name)
1162
+    {
1162 1163
         return (isset($this->extender[$name]) && $this->extender[$name] instanceof $name . "_DL_Extender");
1163 1164
     }
1164 1165
 
@@ -1166,8 +1167,8 @@  discard block
 block discarded – undo
1166 1167
      * @param $name
1167 1168
      * @param $obj
1168 1169
      */
1169
-    public function setExtender($name, $obj)
1170
-    {
1170
+    public function setExtender($name, $obj)
1171
+    {
1171 1172
         $this->extender[$name] = $obj;
1172 1173
     }
1173 1174
 
@@ -1179,13 +1180,13 @@  discard block
 block discarded – undo
1179 1180
      * @param bool $nop если экстендер не загружен, то загружать ли xNop
1180 1181
      * @return null|xNop
1181 1182
      */
1182
-    public function getExtender($name, $autoload = false, $nop = false)
1183
-    {
1183
+    public function getExtender($name, $autoload = false, $nop = false)
1184
+    {
1184 1185
         $out = null;
1185
-        if ((is_scalar($name) && $this->checkExtender($name)) || ($autoload && $this->_loadExtender($name))) {
1186
+        if ((is_scalar($name) && $this->checkExtender($name)) || ($autoload && $this->_loadExtender($name))) {
1186 1187
             $out = $this->extender[$name];
1187 1188
         }
1188
-        if ($nop && is_null($out)) {
1189
+        if ($nop && is_null($out)) {
1189 1190
             $out = new xNop();
1190 1191
         }
1191 1192
 
@@ -1198,27 +1199,27 @@  discard block
 block discarded – undo
1198 1199
      * @param string $name name extender
1199 1200
      * @return boolean $flag status load extender
1200 1201
      */
1201
-    protected function _loadExtender($name)
1202
-    {
1202
+    protected function _loadExtender($name)
1203
+    {
1203 1204
         $this->debug->debug('Load Extender ' . $this->debug->dumpData($name), 'LoadExtender', 2);
1204 1205
         $flag = false;
1205 1206
 
1206 1207
         $classname = ($name != '') ? $name . "_DL_Extender" : "";
1207
-        if ($classname != '' && isset($this->extender[$name]) && $this->extender[$name] instanceof $classname) {
1208
+        if ($classname != '' && isset($this->extender[$name]) && $this->extender[$name] instanceof $classname) {
1208 1209
             $flag = true;
1209 1210
 
1210
-        } else {
1211
-            if (!class_exists($classname, false) && $classname != '') {
1212
-                if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) {
1211
+        } else {
1212
+            if (!class_exists($classname, false) && $classname != '') {
1213
+                if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) {
1213 1214
                     include_once(dirname(__FILE__) . "/extender/" . $name . ".extender.inc");
1214 1215
                 }
1215 1216
             }
1216
-            if (class_exists($classname, false) && $classname != '') {
1217
+            if (class_exists($classname, false) && $classname != '') {
1217 1218
                 $this->extender[$name] = new $classname($this, $name);
1218 1219
                 $flag = true;
1219 1220
             }
1220 1221
         }
1221
-        if (!$flag) {
1222
+        if (!$flag) {
1222 1223
             $this->debug->debug("Error load Extender " . $this->debug->dumpData($name));
1223 1224
         }
1224 1225
         $this->debug->debugEnd('LoadExtender');
@@ -1236,16 +1237,16 @@  discard block
 block discarded – undo
1236 1237
      * @param mixed $IDs список id документов по которым необходима выборка
1237 1238
      * @return array очищенный массив
1238 1239
      */
1239
-    public function setIDs($IDs)
1240
-    {
1240
+    public function setIDs($IDs)
1241
+    {
1241 1242
         $this->debug->debug('set ID list ' . $this->debug->dumpData($IDs), 'setIDs', 2);
1242 1243
         $IDs = $this->cleanIDs($IDs);
1243 1244
         $type = $this->getCFGDef('idType', 'parents');
1244 1245
         $depth = $this->getCFGDef('depth', '');
1245
-        if ($type == 'parents' && $depth > 0) {
1246
+        if ($type == 'parents' && $depth > 0) {
1246 1247
             $tmp = $IDs;
1247
-            do {
1248
-                if (count($tmp) > 0) {
1248
+            do {
1249
+                if (count($tmp) > 0) {
1249 1250
                     $tmp = $this->getChildrenFolder($tmp);
1250 1251
                     $IDs = array_merge($IDs, $tmp);
1251 1252
                 }
@@ -1259,8 +1260,8 @@  discard block
 block discarded – undo
1259 1260
     /**
1260 1261
      * @return int
1261 1262
      */
1262
-    public function getIDs()
1263
-    {
1263
+    public function getIDs()
1264
+    {
1264 1265
         return $this->IDs;
1265 1266
     }
1266 1267
 
@@ -1271,17 +1272,18 @@  discard block
 block discarded – undo
1271 1272
      * @param string $sep разделитель
1272 1273
      * @return array очищенный массив с данными
1273 1274
      */
1274
-    public function cleanIDs($IDs, $sep = ',')
1275
-    {
1275
+    public function cleanIDs($IDs, $sep = ',')
1276
+    {
1276 1277
         $this->debug->debug('clean IDs ' . $this->debug->dumpData($IDs) . ' with separator ' . $this->debug->dumpData($sep),
1277 1278
             'cleanIDs', 2);
1278 1279
         $out = array();
1279
-        if (!is_array($IDs)) {
1280
+        if (!is_array($IDs)) {
1280 1281
             $IDs = explode($sep, $IDs);
1281 1282
         }
1282
-        foreach ($IDs as $item) {
1283
+        foreach ($IDs as $item) {
1283 1284
             $item = trim($item);
1284
-            if (is_numeric($item) && (int)$item >= 0) { //Fix 0xfffffffff
1285
+            if (is_numeric($item) && (int)$item >= 0) {
1286
+//Fix 0xfffffffff
1285 1287
                 $out[] = (int)$item;
1286 1288
             }
1287 1289
         }
@@ -1295,8 +1297,8 @@  discard block
 block discarded – undo
1295 1297
      * Проверка массива с id-шниками документов для выборки
1296 1298
      * @return boolean пригодны ли данные для дальнейшего использования
1297 1299
      */
1298
-    protected function checkIDs()
1299
-    {
1300
+    protected function checkIDs()
1301
+    {
1300 1302
         return (is_array($this->IDs) && count($this->IDs) > 0) ? true : false;
1301 1303
     }
1302 1304
 
@@ -1308,11 +1310,11 @@  discard block
 block discarded – undo
1308 1310
      * @global array $_docs all documents
1309 1311
      * @return array all field values
1310 1312
      */
1311
-    public function getOneField($userField, $uniq = false)
1312
-    {
1313
+    public function getOneField($userField, $uniq = false)
1314
+    {
1313 1315
         $out = array();
1314
-        foreach ($this->_docs as $doc => $val) {
1315
-            if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) {
1316
+        foreach ($this->_docs as $doc => $val) {
1317
+            if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) {
1316 1318
                 $out[$doc] = $val[$userField];
1317 1319
             }
1318 1320
         }
@@ -1323,8 +1325,8 @@  discard block
 block discarded – undo
1323 1325
     /**
1324 1326
      * @return DLCollection
1325 1327
      */
1326
-    public function docsCollection()
1327
-    {
1328
+    public function docsCollection()
1329
+    {
1328 1330
         return new DLCollection($this->modx, $this->_docs);
1329 1331
     }
1330 1332
 
@@ -1352,10 +1354,10 @@  discard block
 block discarded – undo
1352 1354
      * @param string $group
1353 1355
      * @return string
1354 1356
      */
1355
-    protected function getGroupSQL($group = '')
1356
-    {
1357
+    protected function getGroupSQL($group = '')
1358
+    {
1357 1359
         $out = '';
1358
-        if ($group != '') {
1360
+        if ($group != '') {
1359 1361
             $out = 'GROUP BY ' . $group;
1360 1362
         }
1361 1363
 
@@ -1374,12 +1376,12 @@  discard block
 block discarded – undo
1374 1376
      *
1375 1377
      * @return string Order by for SQL
1376 1378
      */
1377
-    protected function SortOrderSQL($sortName, $orderDef = 'DESC')
1378
-    {
1379
+    protected function SortOrderSQL($sortName, $orderDef = 'DESC')
1380
+    {
1379 1381
         $this->debug->debug('', 'sortORDER', 2);
1380 1382
 
1381 1383
         $sort = '';
1382
-        switch ($this->getCFGDef('sortType', '')) {
1384
+        switch ($this->getCFGDef('sortType', '')) {
1383 1385
             case 'none':
1384 1386
                 break;
1385 1387
             case 'doclist':
@@ -1390,10 +1392,10 @@  discard block
 block discarded – undo
1390 1392
                 break;
1391 1393
             default:
1392 1394
                 $out = array('orderBy' => '', 'order' => '', 'sortBy' => '');
1393
-                if (($tmp = $this->getCFGDef('orderBy', '')) != '') {
1395
+                if (($tmp = $this->getCFGDef('orderBy', '')) != '') {
1394 1396
                     $out['orderBy'] = $tmp;
1395
-                } else {
1396
-                    switch (true) {
1397
+                } else {
1398
+                    switch (true) {
1397 1399
                         case ('' != ($tmp = $this->getCFGDef('sortDir', ''))): //higher priority than order
1398 1400
                             $out['order'] = $tmp;
1399 1401
                         // no break
@@ -1401,7 +1403,7 @@  discard block
 block discarded – undo
1401 1403
                             $out['order'] = $tmp;
1402 1404
                         // no break
1403 1405
                     }
1404
-                    if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1406
+                    if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1405 1407
                         $out['order'] = $orderDef; //Default
1406 1408
                     }
1407 1409
 
@@ -1422,26 +1424,26 @@  discard block
 block discarded – undo
1422 1424
      *
1423 1425
      * @return string LIMIT вставка в SQL запрос
1424 1426
      */
1425
-    protected function LimitSQL($limit = 0, $offset = 0)
1426
-    {
1427
+    protected function LimitSQL($limit = 0, $offset = 0)
1428
+    {
1427 1429
         $this->debug->debug('', 'limitSQL', 2);
1428 1430
         $ret = '';
1429
-        if ($limit == 0) {
1431
+        if ($limit == 0) {
1430 1432
             $limit = $this->getCFGDef('display', 0);
1431 1433
         }
1432
-        if ($offset == 0) {
1434
+        if ($offset == 0) {
1433 1435
             $offset = $this->getCFGDef('offset', 0);
1434 1436
         }
1435 1437
         $offset += $this->getCFGDef('start', 0);
1436 1438
         $total = $this->getCFGDef('total', 0);
1437
-        if ($limit < ($total - $limit)) {
1439
+        if ($limit < ($total - $limit)) {
1438 1440
             $limit = $total - $offset;
1439 1441
         }
1440 1442
 
1441
-        if ($limit != 0) {
1443
+        if ($limit != 0) {
1442 1444
             $ret = "LIMIT " . (int)$offset . "," . (int)$limit;
1443
-        } else {
1444
-            if ($offset != 0) {
1445
+        } else {
1446
+            if ($offset != 0) {
1445 1447
                 /**
1446 1448
                  * 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
1447 1449
                  * @see http://dev.mysql.com/doc/refman/5.0/en/select.html
@@ -1461,8 +1463,8 @@  discard block
 block discarded – undo
1461 1463
      * @param string $charset
1462 1464
      * @return string Clear string
1463 1465
      */
1464
-    public function sanitarData($data, $charset = 'UTF-8')
1465
-    {
1466
+    public function sanitarData($data, $charset = 'UTF-8')
1467
+    {
1466 1468
         return APIHelpers::sanitarTag($data, $charset);
1467 1469
     }
1468 1470
 
@@ -1473,8 +1475,8 @@  discard block
 block discarded – undo
1473 1475
      * @param string $parentField default name parent field
1474 1476
      * @return array
1475 1477
      */
1476
-    public function treeBuild($idField = 'id', $parentField = 'parent')
1477
-    {
1478
+    public function treeBuild($idField = 'id', $parentField = 'parent')
1479
+    {
1478 1480
         return $this->_treeBuild($this->_docs, $this->getCFGDef('idField', $idField),
1479 1481
             $this->getCFGDef('parentField', $parentField));
1480 1482
     }
@@ -1487,16 +1489,16 @@  discard block
 block discarded – undo
1487 1489
      * @param string $pidName name parent field in associative data array
1488 1490
      * @return array
1489 1491
      */
1490
-    private function _treeBuild($data, $idName, $pidName)
1491
-    {
1492
+    private function _treeBuild($data, $idName, $pidName)
1493
+    {
1492 1494
         $children = array(); // children of each ID
1493 1495
         $ids = array();
1494
-        foreach ($data as $i => $r) {
1496
+        foreach ($data as $i => $r) {
1495 1497
             $row =& $data[$i];
1496 1498
             $id = $row[$idName];
1497 1499
             $pid = $row[$pidName];
1498 1500
             $children[$pid][$id] =& $row;
1499
-            if (!isset($children[$id])) {
1501
+            if (!isset($children[$id])) {
1500 1502
                 $children[$id] = array();
1501 1503
             }
1502 1504
             $row['#childNodes'] =& $children[$id];
@@ -1504,9 +1506,9 @@  discard block
 block discarded – undo
1504 1506
         }
1505 1507
         // Root elements are elements with non-found PIDs.
1506 1508
         $this->_tree = array();
1507
-        foreach ($data as $i => $r) {
1509
+        foreach ($data as $i => $r) {
1508 1510
             $row =& $data[$i];
1509
-            if (!isset($ids[$row[$pidName]])) {
1511
+            if (!isset($ids[$row[$pidName]])) {
1510 1512
                 $this->_tree[$row[$idName]] = $row;
1511 1513
             }
1512 1514
         }
@@ -1520,10 +1522,10 @@  discard block
 block discarded – undo
1520 1522
      *
1521 1523
      * @return string PrimaryKey основной таблицы
1522 1524
      */
1523
-    public function getPK()
1524
-    {
1525
+    public function getPK()
1526
+    {
1525 1527
         $idField = isset($this->idField) ? $this->idField : 'id';
1526
-        if (!empty($this->alias)) {
1528
+        if (!empty($this->alias)) {
1527 1529
             $idField = $this->alias . '.' . $idField;
1528 1530
         }
1529 1531
 
@@ -1535,10 +1537,10 @@  discard block
 block discarded – undo
1535 1537
      * По умолчанию это parent. Переопределить можно в контроллере присвоив другое значение переменной parentField
1536 1538
      * @return string Parent Key основной таблицы
1537 1539
      */
1538
-    public function getParentField()
1539
-    {
1540
+    public function getParentField()
1541
+    {
1540 1542
         $parentField = isset($this->parentField) ? $this->parentField : '';
1541
-        if (!empty($parentField) && !empty($this->alias)) {
1543
+        if (!empty($parentField) && !empty($this->alias)) {
1542 1544
             $parentField = $this->alias . '.' . $parentField;
1543 1545
         }
1544 1546
 
@@ -1552,31 +1554,31 @@  discard block
 block discarded – undo
1552 1554
      * @param string $filter_string строка со всеми фильтрами
1553 1555
      * @return mixed результат разбора фильтров
1554 1556
      */
1555
-    protected function getFilters($filter_string)
1556
-    {
1557
+    protected function getFilters($filter_string)
1558
+    {
1557 1559
         $this->debug->debug("getFilters: " . $this->debug->dumpData($filter_string), 'getFilter', 1);
1558 1560
         // the filter parameter tells us, which filters can be used in this query
1559 1561
         $filter_string = trim($filter_string, ' ;');
1560
-        if (!$filter_string) {
1562
+        if (!$filter_string) {
1561 1563
             return;
1562 1564
         }
1563 1565
         $output = array('join' => '', 'where' => '');
1564 1566
         $logic_op_found = false;
1565 1567
         $joins = $wheres = array();
1566
-        foreach ($this->_logic_ops as $op => $sql) {
1567
-            if (strpos($filter_string, $op) === 0) {
1568
+        foreach ($this->_logic_ops as $op => $sql) {
1569
+            if (strpos($filter_string, $op) === 0) {
1568 1570
                 $logic_op_found = true;
1569 1571
                 $subfilters = mb_substr($filter_string, strlen($op) + 1, mb_strlen($filter_string, "UTF-8"), "UTF-8");
1570 1572
                 $subfilters = $this->smartSplit($subfilters);
1571
-                foreach ($subfilters as $subfilter) {
1573
+                foreach ($subfilters as $subfilter) {
1572 1574
                     $subfilter = $this->getFilters(trim($subfilter));
1573
-                    if (!$subfilter) {
1575
+                    if (!$subfilter) {
1574 1576
                         continue;
1575 1577
                     }
1576
-                    if ($subfilter['join']) {
1578
+                    if ($subfilter['join']) {
1577 1579
                         $joins[] = $subfilter['join'];
1578 1580
                     }
1579
-                    if ($subfilter['where']) {
1581
+                    if ($subfilter['where']) {
1580 1582
                         $wheres[] = $subfilter['where'];
1581 1583
                     }
1582 1584
                 }
@@ -1585,12 +1587,12 @@  discard block
 block discarded – undo
1585 1587
             }
1586 1588
         }
1587 1589
 
1588
-        if (!$logic_op_found) {
1590
+        if (!$logic_op_found) {
1589 1591
             $filter = $this->loadFilter($filter_string);
1590
-            if (!$filter) {
1592
+            if (!$filter) {
1591 1593
                 $this->debug->warning('Error while loading DocLister filter "' . $this->debug->dumpData($filter_string) . '": check syntax!');
1592 1594
                 $output = false;
1593
-            } else {
1595
+            } else {
1594 1596
                 $output['join'] = $filter->get_join();
1595 1597
                 $output['where'] = $filter->get_where();
1596 1598
             }
@@ -1603,16 +1605,16 @@  discard block
 block discarded – undo
1603 1605
     /**
1604 1606
      * @return mixed
1605 1607
      */
1606
-    public function filtersWhere()
1607
-    {
1608
+    public function filtersWhere()
1609
+    {
1608 1610
         return APIHelpers::getkey($this->_filters, 'where', '');
1609 1611
     }
1610 1612
 
1611 1613
     /**
1612 1614
      * @return mixed
1613 1615
      */
1614
-    public function filtersJoin()
1615
-    {
1616
+    public function filtersJoin()
1617
+    {
1616 1618
         return APIHelpers::getkey($this->_filters, 'join', '');
1617 1619
     }
1618 1620
 
@@ -1623,10 +1625,10 @@  discard block
 block discarded – undo
1623 1625
      * @param $type string тип фильтрации
1624 1626
      * @return string имя поля с учетом приведения типа
1625 1627
      */
1626
-    public function changeSortType($field, $type)
1627
-    {
1628
+    public function changeSortType($field, $type)
1629
+    {
1628 1630
         $type = trim($type);
1629
-        switch (strtoupper($type)) {
1631
+        switch (strtoupper($type)) {
1630 1632
             case 'DECIMAL':
1631 1633
                 $field = 'CAST(' . $field . ' as DECIMAL(10,2))';
1632 1634
                 break;
@@ -1652,14 +1654,14 @@  discard block
 block discarded – undo
1652 1654
      * @param string $filter срока с параметрами фильтрации
1653 1655
      * @return bool
1654 1656
      */
1655
-    protected function loadFilter($filter)
1656
-    {
1657
+    protected function loadFilter($filter)
1658
+    {
1657 1659
         $this->debug->debug('Load filter ' . $this->debug->dumpData($filter), 'loadFilter', 2);
1658 1660
         $out = false;
1659 1661
         $fltr_params = explode(':', $filter, 2);
1660 1662
         $fltr = APIHelpers::getkey($fltr_params, 0, null);
1661 1663
         // check if the filter is implemented
1662
-        if (!is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1664
+        if (!is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1663 1665
             require_once dirname(__FILE__) . '/filter/' . $fltr . '.filter.php';
1664 1666
             /**
1665 1667
              * @var tv_DL_filter|content_DL_filter $fltr_class
@@ -1667,12 +1669,12 @@  discard block
 block discarded – undo
1667 1669
             $fltr_class = $fltr . '_DL_filter';
1668 1670
             $this->totalFilters++;
1669 1671
             $fltr_obj = new $fltr_class();
1670
-            if ($fltr_obj->init($this, $filter)) {
1672
+            if ($fltr_obj->init($this, $filter)) {
1671 1673
                 $out = $fltr_obj;
1672
-            } else {
1674
+            } else {
1673 1675
                 $this->debug->error("Wrong filter parameter: '{$this->debug->dumpData($filter)}'", 'Filter');
1674 1676
             }
1675
-        } else {
1677
+        } else {
1676 1678
             $this->debug->error("Error load Filter: '{$this->debug->dumpData($filter)}'", 'Filter');
1677 1679
         }
1678 1680
         $this->debug->debugEnd("loadFilter");
@@ -1684,8 +1686,8 @@  discard block
 block discarded – undo
1684 1686
      * Общее число фильтров
1685 1687
      * @return int
1686 1688
      */
1687
-    public function getCountFilters()
1688
-    {
1689
+    public function getCountFilters()
1690
+    {
1689 1691
         return (int)$this->totalFilters;
1690 1692
     }
1691 1693
 
@@ -1693,8 +1695,8 @@  discard block
 block discarded – undo
1693 1695
      * Выполнить SQL запрос
1694 1696
      * @param string $q SQL запрос
1695 1697
      */
1696
-    public function dbQuery($q)
1697
-    {
1698
+    public function dbQuery($q)
1699
+    {
1698 1700
         $this->debug->debug($q, "query", 1, 'sql');
1699 1701
         $out = $this->modx->db->query($q);
1700 1702
         $this->debug->debugEnd("query");
@@ -1712,8 +1714,8 @@  discard block
 block discarded – undo
1712 1714
      * @param string $tpl шаблон подстановки значения в SQL запрос
1713 1715
      * @return string строка для подстановки в SQL запрос
1714 1716
      */
1715
-    public function LikeEscape($field, $value, $escape = '=', $tpl = '%[+value+]%')
1716
-    {
1717
+    public function LikeEscape($field, $value, $escape = '=', $tpl = '%[+value+]%')
1718
+    {
1717 1719
         return sqlHelper::LikeEscape($this->modx, $field, $value, $escape, $tpl);
1718 1720
     }
1719 1721
 
@@ -1721,8 +1723,8 @@  discard block
 block discarded – undo
1721 1723
      * Получение REQUEST_URI без GET-ключа с
1722 1724
      * @return string
1723 1725
      */
1724
-    public function getRequest()
1725
-    {
1726
+    public function getRequest()
1727
+    {
1726 1728
         $URL = null;
1727 1729
         parse_str(parse_url(MODX_SITE_URL . $_SERVER['REQUEST_URI'], PHP_URL_QUERY), $URL);
1728 1730
 
Please login to merge, or discard this patch.