Completed
Push — master ( 1166c6...ebad6a )
by
unknown
02:05
created
assets/snippets/DocLister/core/DocLister.abstract.php 2 patches
Spacing   +40 added lines, -40 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",
@@ -1031,11 +1031,11 @@  discard block
 block discarded – undo
1031 1031
         if ($this->extPaginate) {
1032 1032
             $offset = $this->getCFGDef('reversePagination', 0) && $this->extPaginate->currentPage() > 1 ? $this->extPaginate->totalPage() * $this->getCFGDef('display',
1033 1033
                     0) - $this->extPaginate->totalDocs() : 0;
1034
-            if ($this->getCFGDef('maxDocs', 0) && !$this->getCFGDef('reversePagination', 0) && $this->extPaginate->currentPage() == $this->extPaginate->totalPage()) {
1034
+            if ($this->getCFGDef('maxDocs', 0) && ! $this->getCFGDef('reversePagination', 0) && $this->extPaginate->currentPage() == $this->extPaginate->totalPage()) {
1035 1035
                 $iteration += $this->getCFGDef('display', 0);
1036 1036
             }
1037 1037
             $iteration += $this->getCFGDef('display',
1038
-                    0) * ($this->extPaginate->currentPage() - 1)  - $offset;
1038
+                    0) * ($this->extPaginate->currentPage() - 1) - $offset;
1039 1039
         }
1040 1040
 
1041 1041
         $data[$this->getCFGDef("sysKey",
@@ -1146,10 +1146,10 @@  discard block
 block discarded – undo
1146 1146
         $introField = $this->getCFGDef("introField", $introField);
1147 1147
         $contentField = $this->getCFGDef("contentField", $contentField);
1148 1148
 
1149
-        if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1149
+        if ( ! empty($introField) && ! empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1150 1150
             $out = $item[$introField];
1151 1151
         } else {
1152
-            if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1152
+            if ( ! empty($contentField) && ! empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1153 1153
                 $out = $extSummary->init($this, array(
1154 1154
                     "content"      => $item[$contentField],
1155 1155
                     "action"       => $this->getCFGDef("summary", ""),
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
             $flag = true;
1219 1219
 
1220 1220
         } else {
1221
-            if (!class_exists($classname, false) && $classname != '') {
1221
+            if ( ! class_exists($classname, false) && $classname != '') {
1222 1222
                 if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) {
1223 1223
                     include_once(dirname(__FILE__) . "/extender/" . $name . ".extender.inc");
1224 1224
                 }
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
                 $flag = true;
1229 1229
             }
1230 1230
         }
1231
-        if (!$flag) {
1231
+        if ( ! $flag) {
1232 1232
             $this->debug->debug("Error load Extender " . $this->debug->dumpData($name));
1233 1233
         }
1234 1234
         $this->debug->debugEnd('LoadExtender');
@@ -1286,7 +1286,7 @@  discard block
 block discarded – undo
1286 1286
         $this->debug->debug('clean IDs ' . $this->debug->dumpData($IDs) . ' with separator ' . $this->debug->dumpData($sep),
1287 1287
             'cleanIDs', 2);
1288 1288
         $out = array();
1289
-        if (!is_array($IDs)) {
1289
+        if ( ! is_array($IDs)) {
1290 1290
             $IDs = explode($sep, $IDs);
1291 1291
         }
1292 1292
         foreach ($IDs as $item) {
@@ -1322,7 +1322,7 @@  discard block
 block discarded – undo
1322 1322
     {
1323 1323
         $out = array();
1324 1324
         foreach ($this->_docs as $doc => $val) {
1325
-            if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) {
1325
+            if (isset($val[$userField]) && (($uniq && ! in_array($val[$userField], $out)) || ! $uniq)) {
1326 1326
                 $out[$doc] = $val[$userField];
1327 1327
             }
1328 1328
         }
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
                             $out['order'] = $tmp;
1412 1412
                         // no break
1413 1413
                     }
1414
-                    if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1414
+                    if ('' == $out['order'] || ! in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1415 1415
                         $out['order'] = $orderDef; //Default
1416 1416
                     }
1417 1417
 
@@ -1439,7 +1439,7 @@  discard block
 block discarded – undo
1439 1439
         if ($limit == 0) {
1440 1440
             $limit = $this->getCFGDef('display', 0);
1441 1441
         }
1442
-        $maxDocs = $this->getCFGDef('maxDocs',0);
1442
+        $maxDocs = $this->getCFGDef('maxDocs', 0);
1443 1443
         if ($maxDocs > 0 && $limit > $maxDocs) {
1444 1444
             $limit = $maxDocs;
1445 1445
         }
@@ -1506,21 +1506,21 @@  discard block
 block discarded – undo
1506 1506
         $children = array(); // children of each ID
1507 1507
         $ids = array();
1508 1508
         foreach ($data as $i => $r) {
1509
-            $row =& $data[$i];
1509
+            $row = & $data[$i];
1510 1510
             $id = $row[$idName];
1511 1511
             $pid = $row[$pidName];
1512
-            $children[$pid][$id] =& $row;
1513
-            if (!isset($children[$id])) {
1512
+            $children[$pid][$id] = & $row;
1513
+            if ( ! isset($children[$id])) {
1514 1514
                 $children[$id] = array();
1515 1515
             }
1516
-            $row['#childNodes'] =& $children[$id];
1516
+            $row['#childNodes'] = & $children[$id];
1517 1517
             $ids[$row[$idName]] = true;
1518 1518
         }
1519 1519
         // Root elements are elements with non-found PIDs.
1520 1520
         $this->_tree = array();
1521 1521
         foreach ($data as $i => $r) {
1522
-            $row =& $data[$i];
1523
-            if (!isset($ids[$row[$pidName]])) {
1522
+            $row = & $data[$i];
1523
+            if ( ! isset($ids[$row[$pidName]])) {
1524 1524
                 $this->_tree[$row[$idName]] = $row;
1525 1525
             }
1526 1526
         }
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
     public function getPK()
1538 1538
     {
1539 1539
         $idField = isset($this->idField) ? $this->idField : 'id';
1540
-        if (!empty($this->alias)) {
1540
+        if ( ! empty($this->alias)) {
1541 1541
             $idField = $this->alias . '.' . $idField;
1542 1542
         }
1543 1543
 
@@ -1552,7 +1552,7 @@  discard block
 block discarded – undo
1552 1552
     public function getParentField()
1553 1553
     {
1554 1554
         $parentField = isset($this->parentField) ? $this->parentField : '';
1555
-        if (!empty($parentField) && !empty($this->alias)) {
1555
+        if ( ! empty($parentField) && ! empty($this->alias)) {
1556 1556
             $parentField = $this->alias . '.' . $parentField;
1557 1557
         }
1558 1558
 
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
         $this->debug->debug("getFilters: " . $this->debug->dumpData($filter_string), 'getFilter', 1);
1572 1572
         // the filter parameter tells us, which filters can be used in this query
1573 1573
         $filter_string = trim($filter_string, ' ;');
1574
-        if (!$filter_string) {
1574
+        if ( ! $filter_string) {
1575 1575
             return;
1576 1576
         }
1577 1577
         $output = array('join' => '', 'where' => '');
@@ -1584,7 +1584,7 @@  discard block
 block discarded – undo
1584 1584
                 $subfilters = $this->smartSplit($subfilters);
1585 1585
                 foreach ($subfilters as $subfilter) {
1586 1586
                     $subfilter = $this->getFilters(trim($subfilter));
1587
-                    if (!$subfilter) {
1587
+                    if ( ! $subfilter) {
1588 1588
                         continue;
1589 1589
                     }
1590 1590
                     if ($subfilter['join']) {
@@ -1594,14 +1594,14 @@  discard block
 block discarded – undo
1594 1594
                         $wheres[] = $subfilter['where'];
1595 1595
                     }
1596 1596
                 }
1597
-                $output['join'] = !empty($joins) ? implode(' ', $joins) : '';
1598
-                $output['where'] = !empty($wheres) ? '(' . implode($sql, $wheres) . ')' : '';
1597
+                $output['join'] = ! empty($joins) ? implode(' ', $joins) : '';
1598
+                $output['where'] = ! empty($wheres) ? '(' . implode($sql, $wheres) . ')' : '';
1599 1599
             }
1600 1600
         }
1601 1601
 
1602
-        if (!$logic_op_found) {
1602
+        if ( ! $logic_op_found) {
1603 1603
             $filter = $this->loadFilter($filter_string);
1604
-            if (!$filter) {
1604
+            if ( ! $filter) {
1605 1605
                 $this->debug->warning('Error while loading DocLister filter "' . $this->debug->dumpData($filter_string) . '": check syntax!');
1606 1606
                 $output = false;
1607 1607
             } else {
@@ -1673,7 +1673,7 @@  discard block
 block discarded – undo
1673 1673
         $fltr_params = explode(':', $filter, 2);
1674 1674
         $fltr = APIHelpers::getkey($fltr_params, 0, null);
1675 1675
         // check if the filter is implemented
1676
-        if (!is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1676
+        if ( ! is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1677 1677
             require_once dirname(__FILE__) . '/filter/' . $fltr . '.filter.php';
1678 1678
             /**
1679 1679
              * @var tv_DL_filter|content_DL_filter $fltr_class
Please login to merge, or discard this patch.
Braces   +286 added lines, -284 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,10 +1028,10 @@  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', 0) && $this->extPaginate->currentPage() > 1 ? $this->extPaginate->totalPage() * $this->getCFGDef('display',
1033 1033
                     0) - $this->extPaginate->totalDocs() : 0;
1034
-            if ($this->getCFGDef('maxDocs', 0) && !$this->getCFGDef('reversePagination', 0) && $this->extPaginate->currentPage() == $this->extPaginate->totalPage()) {
1034
+            if ($this->getCFGDef('maxDocs', 0) && !$this->getCFGDef('reversePagination', 0) && $this->extPaginate->currentPage() == $this->extPaginate->totalPage()) {
1035 1035
                 $iteration += $this->getCFGDef('display', 0);
1036 1036
             }
1037 1037
             $iteration += $this->getCFGDef('display',
@@ -1041,20 +1041,20 @@  discard block
 block discarded – undo
1041 1041
         $data[$this->getCFGDef("sysKey",
1042 1042
             "dl") . '.full_iteration'] = $iteration;
1043 1043
 
1044
-        if ($i == 1) {
1044
+        if ($i == 1) {
1045 1045
             $this->renderTPL = $this->getCFGDef('tplFirst', $this->renderTPL);
1046 1046
             $class[] = $this->getCFGDef('firstClass', 'first');
1047 1047
         }
1048
-        if ($i == (count($this->_docs) - $this->skippedDocs)) {
1048
+        if ($i == (count($this->_docs) - $this->skippedDocs)) {
1049 1049
             $this->renderTPL = $this->getCFGDef('tplLast', $this->renderTPL);
1050 1050
             $class[] = $this->getCFGDef('lastClass', 'last');
1051 1051
         }
1052
-        if ($this->modx->documentIdentifier == $data['id']) {
1052
+        if ($this->modx->documentIdentifier == $data['id']) {
1053 1053
             $this->renderTPL = $this->getCFGDef('tplCurrent', $this->renderTPL);
1054 1054
             $data[$this->getCFGDef("sysKey",
1055 1055
                 "dl") . '.active'] = 1; //[+active+] - 1 if $modx->documentIdentifer equal ID this element
1056 1056
             $class[] = $this->getCFGDef('currentClass', 'current');
1057
-        } else {
1057
+        } else {
1058 1058
             $data[$this->getCFGDef("sysKey", "dl") . '.active'] = 0;
1059 1059
         }
1060 1060
 
@@ -1065,8 +1065,8 @@  discard block
 block discarded – undo
1065 1065
          * @var $extE e_DL_Extender
1066 1066
          */
1067 1067
         $extE = $this->getExtender('e', true, true);
1068
-        if ($out = $extE->init($this, compact('data'))) {
1069
-            if (is_array($out)) {
1068
+        if ($out = $extE->init($this, compact('data'))) {
1069
+            if (is_array($out)) {
1070 1070
                 $data = $out;
1071 1071
             }
1072 1072
         }
@@ -1082,42 +1082,43 @@  discard block
 block discarded – undo
1082 1082
      * @param array $array данные которые необходимо примешать к ответу на каждой записи $data
1083 1083
      * @return string JSON строка
1084 1084
      */
1085
-    public function getJSON($data, $fields, $array = array())
1086
-    {
1085
+    public function getJSON($data, $fields, $array = array())
1086
+    {
1087 1087
         $out = array();
1088 1088
         $fields = is_array($fields) ? $fields : explode(",", $fields);
1089
-        if (is_array($array) && count($array) > 0) {
1089
+        if (is_array($array) && count($array) > 0) {
1090 1090
             $tmp = array();
1091
-            foreach ($data as $i => $v) { //array_merge not valid work with integer index key
1091
+            foreach ($data as $i => $v) {
1092
+//array_merge not valid work with integer index key
1092 1093
                 $tmp[$i] = (isset($array[$i]) ? array_merge($v, $array[$i]) : $v);
1093 1094
             }
1094 1095
             $data = $tmp;
1095 1096
         }
1096 1097
 
1097
-        foreach ($data as $num => $doc) {
1098
+        foreach ($data as $num => $doc) {
1098 1099
             $tmp = array();
1099
-            foreach ($doc as $name => $value) {
1100
-                if (in_array($name, $fields) || (isset($fields[0]) && $fields[0] == '1')) {
1100
+            foreach ($doc as $name => $value) {
1101
+                if (in_array($name, $fields) || (isset($fields[0]) && $fields[0] == '1')) {
1101 1102
                     $tmp[str_replace(".", "_", $name)] = $value; //JSON element name without dot
1102 1103
                 }
1103 1104
             }
1104 1105
             $out[$num] = $tmp;
1105 1106
         }
1106 1107
 
1107
-        if ('new' == $this->getCFGDef('JSONformat', 'old')) {
1108
+        if ('new' == $this->getCFGDef('JSONformat', 'old')) {
1108 1109
             $return = array();
1109 1110
 
1110 1111
             $return['rows'] = array();
1111
-            foreach ($out as $key => $item) {
1112
+            foreach ($out as $key => $item) {
1112 1113
                 $return['rows'][] = APIHelpers::getkey($item, $key, $item);
1113 1114
             }
1114 1115
             $return['total'] = $this->getChildrenCount();
1115
-        } elseif ('simple' == $this->getCFGDef('JSONformat', 'old')) {
1116
+        } elseif ('simple' == $this->getCFGDef('JSONformat', 'old')) {
1116 1117
             $return = array();
1117
-            foreach ($out as $key => $item) {
1118
+            foreach ($out as $key => $item) {
1118 1119
                 $return[] = APIHelpers::getkey($item, $key, $item);
1119 1120
             }
1120
-        } else {
1121
+        } else {
1121 1122
             $return = $out;
1122 1123
         }
1123 1124
         $this->outData = json_encode($return);
@@ -1133,11 +1134,11 @@  discard block
 block discarded – undo
1133 1134
      * @param string $contentField
1134 1135
      * @return mixed|string
1135 1136
      */
1136
-    protected function getSummary(array $item = array(), $extSummary = null, $introField = '', $contentField = '')
1137
-    {
1137
+    protected function getSummary(array $item = array(), $extSummary = null, $introField = '', $contentField = '')
1138
+    {
1138 1139
         $out = '';
1139 1140
 
1140
-        if (is_null($extSummary)) {
1141
+        if (is_null($extSummary)) {
1141 1142
             /**
1142 1143
              * @var $extSummary summary_DL_Extender
1143 1144
              */
@@ -1146,10 +1147,10 @@  discard block
 block discarded – undo
1146 1147
         $introField = $this->getCFGDef("introField", $introField);
1147 1148
         $contentField = $this->getCFGDef("contentField", $contentField);
1148 1149
 
1149
-        if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1150
+        if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) {
1150 1151
             $out = $item[$introField];
1151
-        } else {
1152
-            if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1152
+        } else {
1153
+            if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) {
1153 1154
                 $out = $extSummary->init($this, array(
1154 1155
                     "content"      => $item[$contentField],
1155 1156
                     "action"       => $this->getCFGDef("summary", ""),
@@ -1167,8 +1168,8 @@  discard block
 block discarded – undo
1167 1168
      * @param string $name extender name
1168 1169
      * @return boolean status extender load
1169 1170
      */
1170
-    public function checkExtender($name)
1171
-    {
1171
+    public function checkExtender($name)
1172
+    {
1172 1173
         return (isset($this->extender[$name]) && $this->extender[$name] instanceof $name . "_DL_Extender");
1173 1174
     }
1174 1175
 
@@ -1176,8 +1177,8 @@  discard block
 block discarded – undo
1176 1177
      * @param $name
1177 1178
      * @param $obj
1178 1179
      */
1179
-    public function setExtender($name, $obj)
1180
-    {
1180
+    public function setExtender($name, $obj)
1181
+    {
1181 1182
         $this->extender[$name] = $obj;
1182 1183
     }
1183 1184
 
@@ -1189,13 +1190,13 @@  discard block
 block discarded – undo
1189 1190
      * @param bool $nop если экстендер не загружен, то загружать ли xNop
1190 1191
      * @return null|xNop
1191 1192
      */
1192
-    public function getExtender($name, $autoload = false, $nop = false)
1193
-    {
1193
+    public function getExtender($name, $autoload = false, $nop = false)
1194
+    {
1194 1195
         $out = null;
1195
-        if ((is_scalar($name) && $this->checkExtender($name)) || ($autoload && $this->_loadExtender($name))) {
1196
+        if ((is_scalar($name) && $this->checkExtender($name)) || ($autoload && $this->_loadExtender($name))) {
1196 1197
             $out = $this->extender[$name];
1197 1198
         }
1198
-        if ($nop && is_null($out)) {
1199
+        if ($nop && is_null($out)) {
1199 1200
             $out = new xNop();
1200 1201
         }
1201 1202
 
@@ -1208,27 +1209,27 @@  discard block
 block discarded – undo
1208 1209
      * @param string $name name extender
1209 1210
      * @return boolean $flag status load extender
1210 1211
      */
1211
-    protected function _loadExtender($name)
1212
-    {
1212
+    protected function _loadExtender($name)
1213
+    {
1213 1214
         $this->debug->debug('Load Extender ' . $this->debug->dumpData($name), 'LoadExtender', 2);
1214 1215
         $flag = false;
1215 1216
 
1216 1217
         $classname = ($name != '') ? $name . "_DL_Extender" : "";
1217
-        if ($classname != '' && isset($this->extender[$name]) && $this->extender[$name] instanceof $classname) {
1218
+        if ($classname != '' && isset($this->extender[$name]) && $this->extender[$name] instanceof $classname) {
1218 1219
             $flag = true;
1219 1220
 
1220
-        } else {
1221
-            if (!class_exists($classname, false) && $classname != '') {
1222
-                if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) {
1221
+        } else {
1222
+            if (!class_exists($classname, false) && $classname != '') {
1223
+                if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) {
1223 1224
                     include_once(dirname(__FILE__) . "/extender/" . $name . ".extender.inc");
1224 1225
                 }
1225 1226
             }
1226
-            if (class_exists($classname, false) && $classname != '') {
1227
+            if (class_exists($classname, false) && $classname != '') {
1227 1228
                 $this->extender[$name] = new $classname($this, $name);
1228 1229
                 $flag = true;
1229 1230
             }
1230 1231
         }
1231
-        if (!$flag) {
1232
+        if (!$flag) {
1232 1233
             $this->debug->debug("Error load Extender " . $this->debug->dumpData($name));
1233 1234
         }
1234 1235
         $this->debug->debugEnd('LoadExtender');
@@ -1246,16 +1247,16 @@  discard block
 block discarded – undo
1246 1247
      * @param mixed $IDs список id документов по которым необходима выборка
1247 1248
      * @return array очищенный массив
1248 1249
      */
1249
-    public function setIDs($IDs)
1250
-    {
1250
+    public function setIDs($IDs)
1251
+    {
1251 1252
         $this->debug->debug('set ID list ' . $this->debug->dumpData($IDs), 'setIDs', 2);
1252 1253
         $IDs = $this->cleanIDs($IDs);
1253 1254
         $type = $this->getCFGDef('idType', 'parents');
1254 1255
         $depth = $this->getCFGDef('depth', '');
1255
-        if ($type == 'parents' && $depth > 0) {
1256
+        if ($type == 'parents' && $depth > 0) {
1256 1257
             $tmp = $IDs;
1257
-            do {
1258
-                if (count($tmp) > 0) {
1258
+            do {
1259
+                if (count($tmp) > 0) {
1259 1260
                     $tmp = $this->getChildrenFolder($tmp);
1260 1261
                     $IDs = array_merge($IDs, $tmp);
1261 1262
                 }
@@ -1269,8 +1270,8 @@  discard block
 block discarded – undo
1269 1270
     /**
1270 1271
      * @return int
1271 1272
      */
1272
-    public function getIDs()
1273
-    {
1273
+    public function getIDs()
1274
+    {
1274 1275
         return $this->IDs;
1275 1276
     }
1276 1277
 
@@ -1281,17 +1282,18 @@  discard block
 block discarded – undo
1281 1282
      * @param string $sep разделитель
1282 1283
      * @return array очищенный массив с данными
1283 1284
      */
1284
-    public function cleanIDs($IDs, $sep = ',')
1285
-    {
1285
+    public function cleanIDs($IDs, $sep = ',')
1286
+    {
1286 1287
         $this->debug->debug('clean IDs ' . $this->debug->dumpData($IDs) . ' with separator ' . $this->debug->dumpData($sep),
1287 1288
             'cleanIDs', 2);
1288 1289
         $out = array();
1289
-        if (!is_array($IDs)) {
1290
+        if (!is_array($IDs)) {
1290 1291
             $IDs = explode($sep, $IDs);
1291 1292
         }
1292
-        foreach ($IDs as $item) {
1293
+        foreach ($IDs as $item) {
1293 1294
             $item = trim($item);
1294
-            if (is_numeric($item) && (int)$item >= 0) { //Fix 0xfffffffff
1295
+            if (is_numeric($item) && (int)$item >= 0) {
1296
+//Fix 0xfffffffff
1295 1297
                 $out[] = (int)$item;
1296 1298
             }
1297 1299
         }
@@ -1305,8 +1307,8 @@  discard block
 block discarded – undo
1305 1307
      * Проверка массива с id-шниками документов для выборки
1306 1308
      * @return boolean пригодны ли данные для дальнейшего использования
1307 1309
      */
1308
-    protected function checkIDs()
1309
-    {
1310
+    protected function checkIDs()
1311
+    {
1310 1312
         return (is_array($this->IDs) && count($this->IDs) > 0) ? true : false;
1311 1313
     }
1312 1314
 
@@ -1318,11 +1320,11 @@  discard block
 block discarded – undo
1318 1320
      * @global array $_docs all documents
1319 1321
      * @return array all field values
1320 1322
      */
1321
-    public function getOneField($userField, $uniq = false)
1322
-    {
1323
+    public function getOneField($userField, $uniq = false)
1324
+    {
1323 1325
         $out = array();
1324
-        foreach ($this->_docs as $doc => $val) {
1325
-            if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) {
1326
+        foreach ($this->_docs as $doc => $val) {
1327
+            if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) {
1326 1328
                 $out[$doc] = $val[$userField];
1327 1329
             }
1328 1330
         }
@@ -1333,8 +1335,8 @@  discard block
 block discarded – undo
1333 1335
     /**
1334 1336
      * @return DLCollection
1335 1337
      */
1336
-    public function docsCollection()
1337
-    {
1338
+    public function docsCollection()
1339
+    {
1338 1340
         return new DLCollection($this->modx, $this->_docs);
1339 1341
     }
1340 1342
 
@@ -1362,10 +1364,10 @@  discard block
 block discarded – undo
1362 1364
      * @param string $group
1363 1365
      * @return string
1364 1366
      */
1365
-    protected function getGroupSQL($group = '')
1366
-    {
1367
+    protected function getGroupSQL($group = '')
1368
+    {
1367 1369
         $out = '';
1368
-        if ($group != '') {
1370
+        if ($group != '') {
1369 1371
             $out = 'GROUP BY ' . $group;
1370 1372
         }
1371 1373
 
@@ -1384,12 +1386,12 @@  discard block
 block discarded – undo
1384 1386
      *
1385 1387
      * @return string Order by for SQL
1386 1388
      */
1387
-    protected function SortOrderSQL($sortName, $orderDef = 'DESC')
1388
-    {
1389
+    protected function SortOrderSQL($sortName, $orderDef = 'DESC')
1390
+    {
1389 1391
         $this->debug->debug('', 'sortORDER', 2);
1390 1392
 
1391 1393
         $sort = '';
1392
-        switch ($this->getCFGDef('sortType', '')) {
1394
+        switch ($this->getCFGDef('sortType', '')) {
1393 1395
             case 'none':
1394 1396
                 break;
1395 1397
             case 'doclist':
@@ -1400,10 +1402,10 @@  discard block
 block discarded – undo
1400 1402
                 break;
1401 1403
             default:
1402 1404
                 $out = array('orderBy' => '', 'order' => '', 'sortBy' => '');
1403
-                if (($tmp = $this->getCFGDef('orderBy', '')) != '') {
1405
+                if (($tmp = $this->getCFGDef('orderBy', '')) != '') {
1404 1406
                     $out['orderBy'] = $tmp;
1405
-                } else {
1406
-                    switch (true) {
1407
+                } else {
1408
+                    switch (true) {
1407 1409
                         case ('' != ($tmp = $this->getCFGDef('sortDir', ''))): //higher priority than order
1408 1410
                             $out['order'] = $tmp;
1409 1411
                         // no break
@@ -1411,7 +1413,7 @@  discard block
 block discarded – undo
1411 1413
                             $out['order'] = $tmp;
1412 1414
                         // no break
1413 1415
                     }
1414
-                    if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1416
+                    if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) {
1415 1417
                         $out['order'] = $orderDef; //Default
1416 1418
                     }
1417 1419
 
@@ -1432,30 +1434,30 @@  discard block
 block discarded – undo
1432 1434
      *
1433 1435
      * @return string LIMIT вставка в SQL запрос
1434 1436
      */
1435
-    protected function LimitSQL($limit = 0, $offset = 0)
1436
-    {
1437
+    protected function LimitSQL($limit = 0, $offset = 0)
1438
+    {
1437 1439
         $this->debug->debug('', 'limitSQL', 2);
1438 1440
         $ret = '';
1439
-        if ($limit == 0) {
1441
+        if ($limit == 0) {
1440 1442
             $limit = $this->getCFGDef('display', 0);
1441 1443
         }
1442 1444
         $maxDocs = $this->getCFGDef('maxDocs',0);
1443
-        if ($maxDocs > 0 && $limit > $maxDocs) {
1445
+        if ($maxDocs > 0 && $limit > $maxDocs) {
1444 1446
             $limit = $maxDocs;
1445 1447
         }
1446
-        if ($offset == 0) {
1448
+        if ($offset == 0) {
1447 1449
             $offset = $this->getCFGDef('offset', 0);
1448 1450
         }
1449 1451
         $offset += $this->getCFGDef('start', 0);
1450 1452
         $total = $this->getCFGDef('total', 0);
1451
-        if ($limit < ($total - $limit)) {
1453
+        if ($limit < ($total - $limit)) {
1452 1454
             $limit = $total - $offset;
1453 1455
         }
1454 1456
 
1455
-        if ($limit != 0) {
1457
+        if ($limit != 0) {
1456 1458
             $ret = "LIMIT " . (int)$offset . "," . (int)$limit;
1457
-        } else {
1458
-            if ($offset != 0) {
1459
+        } else {
1460
+            if ($offset != 0) {
1459 1461
                 /**
1460 1462
                  * 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
1461 1463
                  * @see http://dev.mysql.com/doc/refman/5.0/en/select.html
@@ -1475,8 +1477,8 @@  discard block
 block discarded – undo
1475 1477
      * @param string $charset
1476 1478
      * @return string Clear string
1477 1479
      */
1478
-    public function sanitarData($data, $charset = 'UTF-8')
1479
-    {
1480
+    public function sanitarData($data, $charset = 'UTF-8')
1481
+    {
1480 1482
         return APIHelpers::sanitarTag($data, $charset);
1481 1483
     }
1482 1484
 
@@ -1487,8 +1489,8 @@  discard block
 block discarded – undo
1487 1489
      * @param string $parentField default name parent field
1488 1490
      * @return array
1489 1491
      */
1490
-    public function treeBuild($idField = 'id', $parentField = 'parent')
1491
-    {
1492
+    public function treeBuild($idField = 'id', $parentField = 'parent')
1493
+    {
1492 1494
         return $this->_treeBuild($this->_docs, $this->getCFGDef('idField', $idField),
1493 1495
             $this->getCFGDef('parentField', $parentField));
1494 1496
     }
@@ -1501,16 +1503,16 @@  discard block
 block discarded – undo
1501 1503
      * @param string $pidName name parent field in associative data array
1502 1504
      * @return array
1503 1505
      */
1504
-    private function _treeBuild($data, $idName, $pidName)
1505
-    {
1506
+    private function _treeBuild($data, $idName, $pidName)
1507
+    {
1506 1508
         $children = array(); // children of each ID
1507 1509
         $ids = array();
1508
-        foreach ($data as $i => $r) {
1510
+        foreach ($data as $i => $r) {
1509 1511
             $row =& $data[$i];
1510 1512
             $id = $row[$idName];
1511 1513
             $pid = $row[$pidName];
1512 1514
             $children[$pid][$id] =& $row;
1513
-            if (!isset($children[$id])) {
1515
+            if (!isset($children[$id])) {
1514 1516
                 $children[$id] = array();
1515 1517
             }
1516 1518
             $row['#childNodes'] =& $children[$id];
@@ -1518,9 +1520,9 @@  discard block
 block discarded – undo
1518 1520
         }
1519 1521
         // Root elements are elements with non-found PIDs.
1520 1522
         $this->_tree = array();
1521
-        foreach ($data as $i => $r) {
1523
+        foreach ($data as $i => $r) {
1522 1524
             $row =& $data[$i];
1523
-            if (!isset($ids[$row[$pidName]])) {
1525
+            if (!isset($ids[$row[$pidName]])) {
1524 1526
                 $this->_tree[$row[$idName]] = $row;
1525 1527
             }
1526 1528
         }
@@ -1534,10 +1536,10 @@  discard block
 block discarded – undo
1534 1536
      *
1535 1537
      * @return string PrimaryKey основной таблицы
1536 1538
      */
1537
-    public function getPK()
1538
-    {
1539
+    public function getPK()
1540
+    {
1539 1541
         $idField = isset($this->idField) ? $this->idField : 'id';
1540
-        if (!empty($this->alias)) {
1542
+        if (!empty($this->alias)) {
1541 1543
             $idField = $this->alias . '.' . $idField;
1542 1544
         }
1543 1545
 
@@ -1549,10 +1551,10 @@  discard block
 block discarded – undo
1549 1551
      * По умолчанию это parent. Переопределить можно в контроллере присвоив другое значение переменной parentField
1550 1552
      * @return string Parent Key основной таблицы
1551 1553
      */
1552
-    public function getParentField()
1553
-    {
1554
+    public function getParentField()
1555
+    {
1554 1556
         $parentField = isset($this->parentField) ? $this->parentField : '';
1555
-        if (!empty($parentField) && !empty($this->alias)) {
1557
+        if (!empty($parentField) && !empty($this->alias)) {
1556 1558
             $parentField = $this->alias . '.' . $parentField;
1557 1559
         }
1558 1560
 
@@ -1566,31 +1568,31 @@  discard block
 block discarded – undo
1566 1568
      * @param string $filter_string строка со всеми фильтрами
1567 1569
      * @return mixed результат разбора фильтров
1568 1570
      */
1569
-    protected function getFilters($filter_string)
1570
-    {
1571
+    protected function getFilters($filter_string)
1572
+    {
1571 1573
         $this->debug->debug("getFilters: " . $this->debug->dumpData($filter_string), 'getFilter', 1);
1572 1574
         // the filter parameter tells us, which filters can be used in this query
1573 1575
         $filter_string = trim($filter_string, ' ;');
1574
-        if (!$filter_string) {
1576
+        if (!$filter_string) {
1575 1577
             return;
1576 1578
         }
1577 1579
         $output = array('join' => '', 'where' => '');
1578 1580
         $logic_op_found = false;
1579 1581
         $joins = $wheres = array();
1580
-        foreach ($this->_logic_ops as $op => $sql) {
1581
-            if (strpos($filter_string, $op) === 0) {
1582
+        foreach ($this->_logic_ops as $op => $sql) {
1583
+            if (strpos($filter_string, $op) === 0) {
1582 1584
                 $logic_op_found = true;
1583 1585
                 $subfilters = mb_substr($filter_string, strlen($op) + 1, mb_strlen($filter_string, "UTF-8"), "UTF-8");
1584 1586
                 $subfilters = $this->smartSplit($subfilters);
1585
-                foreach ($subfilters as $subfilter) {
1587
+                foreach ($subfilters as $subfilter) {
1586 1588
                     $subfilter = $this->getFilters(trim($subfilter));
1587
-                    if (!$subfilter) {
1589
+                    if (!$subfilter) {
1588 1590
                         continue;
1589 1591
                     }
1590
-                    if ($subfilter['join']) {
1592
+                    if ($subfilter['join']) {
1591 1593
                         $joins[] = $subfilter['join'];
1592 1594
                     }
1593
-                    if ($subfilter['where']) {
1595
+                    if ($subfilter['where']) {
1594 1596
                         $wheres[] = $subfilter['where'];
1595 1597
                     }
1596 1598
                 }
@@ -1599,12 +1601,12 @@  discard block
 block discarded – undo
1599 1601
             }
1600 1602
         }
1601 1603
 
1602
-        if (!$logic_op_found) {
1604
+        if (!$logic_op_found) {
1603 1605
             $filter = $this->loadFilter($filter_string);
1604
-            if (!$filter) {
1606
+            if (!$filter) {
1605 1607
                 $this->debug->warning('Error while loading DocLister filter "' . $this->debug->dumpData($filter_string) . '": check syntax!');
1606 1608
                 $output = false;
1607
-            } else {
1609
+            } else {
1608 1610
                 $output['join'] = $filter->get_join();
1609 1611
                 $output['where'] = $filter->get_where();
1610 1612
             }
@@ -1617,16 +1619,16 @@  discard block
 block discarded – undo
1617 1619
     /**
1618 1620
      * @return mixed
1619 1621
      */
1620
-    public function filtersWhere()
1621
-    {
1622
+    public function filtersWhere()
1623
+    {
1622 1624
         return APIHelpers::getkey($this->_filters, 'where', '');
1623 1625
     }
1624 1626
 
1625 1627
     /**
1626 1628
      * @return mixed
1627 1629
      */
1628
-    public function filtersJoin()
1629
-    {
1630
+    public function filtersJoin()
1631
+    {
1630 1632
         return APIHelpers::getkey($this->_filters, 'join', '');
1631 1633
     }
1632 1634
 
@@ -1637,10 +1639,10 @@  discard block
 block discarded – undo
1637 1639
      * @param $type string тип фильтрации
1638 1640
      * @return string имя поля с учетом приведения типа
1639 1641
      */
1640
-    public function changeSortType($field, $type)
1641
-    {
1642
+    public function changeSortType($field, $type)
1643
+    {
1642 1644
         $type = trim($type);
1643
-        switch (strtoupper($type)) {
1645
+        switch (strtoupper($type)) {
1644 1646
             case 'DECIMAL':
1645 1647
                 $field = 'CAST(' . $field . ' as DECIMAL(10,2))';
1646 1648
                 break;
@@ -1666,14 +1668,14 @@  discard block
 block discarded – undo
1666 1668
      * @param string $filter срока с параметрами фильтрации
1667 1669
      * @return bool
1668 1670
      */
1669
-    protected function loadFilter($filter)
1670
-    {
1671
+    protected function loadFilter($filter)
1672
+    {
1671 1673
         $this->debug->debug('Load filter ' . $this->debug->dumpData($filter), 'loadFilter', 2);
1672 1674
         $out = false;
1673 1675
         $fltr_params = explode(':', $filter, 2);
1674 1676
         $fltr = APIHelpers::getkey($fltr_params, 0, null);
1675 1677
         // check if the filter is implemented
1676
-        if (!is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1678
+        if (!is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) {
1677 1679
             require_once dirname(__FILE__) . '/filter/' . $fltr . '.filter.php';
1678 1680
             /**
1679 1681
              * @var tv_DL_filter|content_DL_filter $fltr_class
@@ -1681,12 +1683,12 @@  discard block
 block discarded – undo
1681 1683
             $fltr_class = $fltr . '_DL_filter';
1682 1684
             $this->totalFilters++;
1683 1685
             $fltr_obj = new $fltr_class();
1684
-            if ($fltr_obj->init($this, $filter)) {
1686
+            if ($fltr_obj->init($this, $filter)) {
1685 1687
                 $out = $fltr_obj;
1686
-            } else {
1688
+            } else {
1687 1689
                 $this->debug->error("Wrong filter parameter: '{$this->debug->dumpData($filter)}'", 'Filter');
1688 1690
             }
1689
-        } else {
1691
+        } else {
1690 1692
             $this->debug->error("Error load Filter: '{$this->debug->dumpData($filter)}'", 'Filter');
1691 1693
         }
1692 1694
         $this->debug->debugEnd("loadFilter");
@@ -1698,8 +1700,8 @@  discard block
 block discarded – undo
1698 1700
      * Общее число фильтров
1699 1701
      * @return int
1700 1702
      */
1701
-    public function getCountFilters()
1702
-    {
1703
+    public function getCountFilters()
1704
+    {
1703 1705
         return (int)$this->totalFilters;
1704 1706
     }
1705 1707
 
@@ -1707,8 +1709,8 @@  discard block
 block discarded – undo
1707 1709
      * Выполнить SQL запрос
1708 1710
      * @param string $q SQL запрос
1709 1711
      */
1710
-    public function dbQuery($q)
1711
-    {
1712
+    public function dbQuery($q)
1713
+    {
1712 1714
         $this->debug->debug($q, "query", 1, 'sql');
1713 1715
         $out = $this->modx->db->query($q);
1714 1716
         $this->debug->debugEnd("query");
@@ -1726,8 +1728,8 @@  discard block
 block discarded – undo
1726 1728
      * @param string $tpl шаблон подстановки значения в SQL запрос
1727 1729
      * @return string строка для подстановки в SQL запрос
1728 1730
      */
1729
-    public function LikeEscape($field, $value, $escape = '=', $tpl = '%[+value+]%')
1730
-    {
1731
+    public function LikeEscape($field, $value, $escape = '=', $tpl = '%[+value+]%')
1732
+    {
1731 1733
         return sqlHelper::LikeEscape($this->modx, $field, $value, $escape, $tpl);
1732 1734
     }
1733 1735
 
@@ -1735,8 +1737,8 @@  discard block
 block discarded – undo
1735 1737
      * Получение REQUEST_URI без GET-ключа с
1736 1738
      * @return string
1737 1739
      */
1738
-    public function getRequest()
1739
-    {
1740
+    public function getRequest()
1741
+    {
1740 1742
         $URL = null;
1741 1743
         parse_str(parse_url(MODX_SITE_URL . $_SERVER['REQUEST_URI'], PHP_URL_QUERY), $URL);
1742 1744
 
Please login to merge, or discard this patch.