@@ -1,5 +1,5 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
992 | 992 | } |
993 | 993 | $plh = $params; |
994 | 994 | } |
995 | - if ($parse && !empty($this->ownerTPL)) { |
|
995 | + if ($parse && ! empty($this->ownerTPL)) { |
|
996 | 996 | $this->debug->updateMessage( |
997 | 997 | array("render ownerTPL" => $this->ownerTPL, "With data" => print_r($plh, 1)), |
998 | 998 | "renderWrapTPL", |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | $offset = $this->getCFGDef('reversePagination', |
1033 | 1033 | 0) && $this->extPaginate->currentPage() > 1 ? $this->extPaginate->totalPage() * $this->getCFGDef('display', |
1034 | 1034 | 0) - $this->extPaginate->totalDocs() : 0; |
1035 | - if ($this->getCFGDef('maxDocs', 0) && !$this->getCFGDef('reversePagination', |
|
1035 | + if ($this->getCFGDef('maxDocs', 0) && ! $this->getCFGDef('reversePagination', |
|
1036 | 1036 | 0) && $this->extPaginate->currentPage() == $this->extPaginate->totalPage() |
1037 | 1037 | ) { |
1038 | 1038 | $iteration += $this->getCFGDef('display', 0); |
@@ -1149,10 +1149,10 @@ discard block |
||
1149 | 1149 | $introField = $this->getCFGDef("introField", $introField); |
1150 | 1150 | $contentField = $this->getCFGDef("contentField", $contentField); |
1151 | 1151 | |
1152 | - if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) { |
|
1152 | + if ( ! empty($introField) && ! empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) { |
|
1153 | 1153 | $out = $item[$introField]; |
1154 | 1154 | } else { |
1155 | - if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) { |
|
1155 | + if ( ! empty($contentField) && ! empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) { |
|
1156 | 1156 | $out = $extSummary->init($this, array( |
1157 | 1157 | "content" => $item[$contentField], |
1158 | 1158 | "action" => $this->getCFGDef("summary", ""), |
@@ -1221,7 +1221,7 @@ discard block |
||
1221 | 1221 | $flag = true; |
1222 | 1222 | |
1223 | 1223 | } else { |
1224 | - if (!class_exists($classname, false) && $classname != '') { |
|
1224 | + if ( ! class_exists($classname, false) && $classname != '') { |
|
1225 | 1225 | if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) { |
1226 | 1226 | include_once(dirname(__FILE__) . "/extender/" . $name . ".extender.inc"); |
1227 | 1227 | } |
@@ -1231,7 +1231,7 @@ discard block |
||
1231 | 1231 | $flag = true; |
1232 | 1232 | } |
1233 | 1233 | } |
1234 | - if (!$flag) { |
|
1234 | + if ( ! $flag) { |
|
1235 | 1235 | $this->debug->debug("Error load Extender " . $this->debug->dumpData($name)); |
1236 | 1236 | } |
1237 | 1237 | $this->debug->debugEnd('LoadExtender'); |
@@ -1289,7 +1289,7 @@ discard block |
||
1289 | 1289 | $this->debug->debug('clean IDs ' . $this->debug->dumpData($IDs) . ' with separator ' . $this->debug->dumpData($sep), |
1290 | 1290 | 'cleanIDs', 2); |
1291 | 1291 | $out = array(); |
1292 | - if (!is_array($IDs)) { |
|
1292 | + if ( ! is_array($IDs)) { |
|
1293 | 1293 | $IDs = explode($sep, $IDs); |
1294 | 1294 | } |
1295 | 1295 | foreach ($IDs as $item) { |
@@ -1325,7 +1325,7 @@ discard block |
||
1325 | 1325 | { |
1326 | 1326 | $out = array(); |
1327 | 1327 | foreach ($this->_docs as $doc => $val) { |
1328 | - if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) { |
|
1328 | + if (isset($val[$userField]) && (($uniq && ! in_array($val[$userField], $out)) || ! $uniq)) { |
|
1329 | 1329 | $out[$doc] = $val[$userField]; |
1330 | 1330 | } |
1331 | 1331 | } |
@@ -1414,7 +1414,7 @@ discard block |
||
1414 | 1414 | $out['order'] = $tmp; |
1415 | 1415 | // no break |
1416 | 1416 | } |
1417 | - if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) { |
|
1417 | + if ('' == $out['order'] || ! in_array(strtoupper($out['order']), array('ASC', 'DESC'))) { |
|
1418 | 1418 | $out['order'] = $orderDef; //Default |
1419 | 1419 | } |
1420 | 1420 | |
@@ -1509,21 +1509,21 @@ discard block |
||
1509 | 1509 | $children = array(); // children of each ID |
1510 | 1510 | $ids = array(); |
1511 | 1511 | foreach ($data as $i => $r) { |
1512 | - $row =& $data[$i]; |
|
1512 | + $row = & $data[$i]; |
|
1513 | 1513 | $id = $row[$idName]; |
1514 | 1514 | $pid = $row[$pidName]; |
1515 | - $children[$pid][$id] =& $row; |
|
1516 | - if (!isset($children[$id])) { |
|
1515 | + $children[$pid][$id] = & $row; |
|
1516 | + if ( ! isset($children[$id])) { |
|
1517 | 1517 | $children[$id] = array(); |
1518 | 1518 | } |
1519 | - $row['#childNodes'] =& $children[$id]; |
|
1519 | + $row['#childNodes'] = & $children[$id]; |
|
1520 | 1520 | $ids[$row[$idName]] = true; |
1521 | 1521 | } |
1522 | 1522 | // Root elements are elements with non-found PIDs. |
1523 | 1523 | $this->_tree = array(); |
1524 | 1524 | foreach ($data as $i => $r) { |
1525 | - $row =& $data[$i]; |
|
1526 | - if (!isset($ids[$row[$pidName]])) { |
|
1525 | + $row = & $data[$i]; |
|
1526 | + if ( ! isset($ids[$row[$pidName]])) { |
|
1527 | 1527 | $this->_tree[$row[$idName]] = $row; |
1528 | 1528 | } |
1529 | 1529 | } |
@@ -1539,10 +1539,10 @@ discard block |
||
1539 | 1539 | */ |
1540 | 1540 | public function getPK($full = true) |
1541 | 1541 | { |
1542 | - $idField = isset($this->idField) ? $this->idField: 'id'; |
|
1542 | + $idField = isset($this->idField) ? $this->idField : 'id'; |
|
1543 | 1543 | if ($full) { |
1544 | 1544 | $idField = '`' . $idField . '`'; |
1545 | - if (!empty($this->alias)) { |
|
1545 | + if ( ! empty($this->alias)) { |
|
1546 | 1546 | $idField = '`' . $this->alias . '`.' . $idField; |
1547 | 1547 | } |
1548 | 1548 | } |
@@ -1559,9 +1559,9 @@ discard block |
||
1559 | 1559 | public function getParentField($full = true) |
1560 | 1560 | { |
1561 | 1561 | $parentField = isset($this->parentField) ? $this->parentField : ''; |
1562 | - if ($full && !empty($parentField)) { |
|
1562 | + if ($full && ! empty($parentField)) { |
|
1563 | 1563 | $parentField = '`' . $parentField . '`'; |
1564 | - if (!empty($this->alias)) { |
|
1564 | + if ( ! empty($this->alias)) { |
|
1565 | 1565 | $parentField = '`' . $this->alias . '`.' . $parentField; |
1566 | 1566 | } |
1567 | 1567 | } |
@@ -1581,7 +1581,7 @@ discard block |
||
1581 | 1581 | $this->debug->debug("getFilters: " . $this->debug->dumpData($filter_string), 'getFilter', 1); |
1582 | 1582 | // the filter parameter tells us, which filters can be used in this query |
1583 | 1583 | $filter_string = trim($filter_string, ' ;'); |
1584 | - if (!$filter_string) { |
|
1584 | + if ( ! $filter_string) { |
|
1585 | 1585 | return; |
1586 | 1586 | } |
1587 | 1587 | $output = array('join' => '', 'where' => ''); |
@@ -1594,7 +1594,7 @@ discard block |
||
1594 | 1594 | $subfilters = $this->smartSplit($subfilters); |
1595 | 1595 | foreach ($subfilters as $subfilter) { |
1596 | 1596 | $subfilter = $this->getFilters(trim($subfilter)); |
1597 | - if (!$subfilter) { |
|
1597 | + if ( ! $subfilter) { |
|
1598 | 1598 | continue; |
1599 | 1599 | } |
1600 | 1600 | if ($subfilter['join']) { |
@@ -1604,14 +1604,14 @@ discard block |
||
1604 | 1604 | $wheres[] = $subfilter['where']; |
1605 | 1605 | } |
1606 | 1606 | } |
1607 | - $output['join'] = !empty($joins) ? implode(' ', $joins) : ''; |
|
1608 | - $output['where'] = !empty($wheres) ? '(' . implode($sql, $wheres) . ')' : ''; |
|
1607 | + $output['join'] = ! empty($joins) ? implode(' ', $joins) : ''; |
|
1608 | + $output['where'] = ! empty($wheres) ? '(' . implode($sql, $wheres) . ')' : ''; |
|
1609 | 1609 | } |
1610 | 1610 | } |
1611 | 1611 | |
1612 | - if (!$logic_op_found) { |
|
1612 | + if ( ! $logic_op_found) { |
|
1613 | 1613 | $filter = $this->loadFilter($filter_string); |
1614 | - if (!$filter) { |
|
1614 | + if ( ! $filter) { |
|
1615 | 1615 | $this->debug->warning('Error while loading DocLister filter "' . $this->debug->dumpData($filter_string) . '": check syntax!'); |
1616 | 1616 | $output = false; |
1617 | 1617 | } else { |
@@ -1683,7 +1683,7 @@ discard block |
||
1683 | 1683 | $fltr_params = explode(':', $filter, 2); |
1684 | 1684 | $fltr = APIHelpers::getkey($fltr_params, 0, null); |
1685 | 1685 | // check if the filter is implemented |
1686 | - if (!is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) { |
|
1686 | + if ( ! is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) { |
|
1687 | 1687 | require_once dirname(__FILE__) . '/filter/' . $fltr . '.filter.php'; |
1688 | 1688 | /** |
1689 | 1689 | * @var tv_DL_filter|content_DL_filter $fltr_class |
@@ -1,5 +1,5 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
1016 | 1016 | * @param int $i номер итерации в цикле |
1017 | 1017 | * @return array массив с данными которые можно использовать в цикле render метода |
1018 | 1018 | */ |
1019 | - protected function uniformPrepare(&$data, $i = 0) |
|
1020 | - { |
|
1019 | + protected function uniformPrepare(&$data, $i = 0) |
|
1020 | + { |
|
1021 | 1021 | $class = array(); |
1022 | 1022 | |
1023 | 1023 | $iterationName = ($i % 2 == 1) ? 'Odd' : 'Even'; |
@@ -1028,13 +1028,13 @@ discard block |
||
1028 | 1028 | $this->renderTPL = $this->getCFGDef('tpl' . $iterationName, $this->renderTPL); |
1029 | 1029 | $iteration = $i; |
1030 | 1030 | |
1031 | - if ($this->extPaginate) { |
|
1031 | + if ($this->extPaginate) { |
|
1032 | 1032 | $offset = $this->getCFGDef('reversePagination', |
1033 | 1033 | 0) && $this->extPaginate->currentPage() > 1 ? $this->extPaginate->totalPage() * $this->getCFGDef('display', |
1034 | 1034 | 0) - $this->extPaginate->totalDocs() : 0; |
1035 | 1035 | if ($this->getCFGDef('maxDocs', 0) && !$this->getCFGDef('reversePagination', |
1036 | 1036 | 0) && $this->extPaginate->currentPage() == $this->extPaginate->totalPage() |
1037 | - ) { |
|
1037 | + ) { |
|
1038 | 1038 | $iteration += $this->getCFGDef('display', 0); |
1039 | 1039 | } |
1040 | 1040 | $iteration += $this->getCFGDef('display', |
@@ -1044,20 +1044,20 @@ discard block |
||
1044 | 1044 | $data[$this->getCFGDef("sysKey", |
1045 | 1045 | "dl") . '.full_iteration'] = $iteration; |
1046 | 1046 | |
1047 | - if ($i == 1) { |
|
1047 | + if ($i == 1) { |
|
1048 | 1048 | $this->renderTPL = $this->getCFGDef('tplFirst', $this->renderTPL); |
1049 | 1049 | $class[] = $this->getCFGDef('firstClass', 'first'); |
1050 | 1050 | } |
1051 | - if ($i == (count($this->_docs) - $this->skippedDocs)) { |
|
1051 | + if ($i == (count($this->_docs) - $this->skippedDocs)) { |
|
1052 | 1052 | $this->renderTPL = $this->getCFGDef('tplLast', $this->renderTPL); |
1053 | 1053 | $class[] = $this->getCFGDef('lastClass', 'last'); |
1054 | 1054 | } |
1055 | - if ($this->modx->documentIdentifier == $data['id']) { |
|
1055 | + if ($this->modx->documentIdentifier == $data['id']) { |
|
1056 | 1056 | $this->renderTPL = $this->getCFGDef('tplCurrent', $this->renderTPL); |
1057 | 1057 | $data[$this->getCFGDef("sysKey", |
1058 | 1058 | "dl") . '.active'] = 1; //[+active+] - 1 if $modx->documentIdentifer equal ID this element |
1059 | 1059 | $class[] = $this->getCFGDef('currentClass', 'current'); |
1060 | - } else { |
|
1060 | + } else { |
|
1061 | 1061 | $data[$this->getCFGDef("sysKey", "dl") . '.active'] = 0; |
1062 | 1062 | } |
1063 | 1063 | |
@@ -1068,8 +1068,8 @@ discard block |
||
1068 | 1068 | * @var $extE e_DL_Extender |
1069 | 1069 | */ |
1070 | 1070 | $extE = $this->getExtender('e', true, true); |
1071 | - if ($out = $extE->init($this, compact('data'))) { |
|
1072 | - if (is_array($out)) { |
|
1071 | + if ($out = $extE->init($this, compact('data'))) { |
|
1072 | + if (is_array($out)) { |
|
1073 | 1073 | $data = $out; |
1074 | 1074 | } |
1075 | 1075 | } |
@@ -1085,42 +1085,43 @@ discard block |
||
1085 | 1085 | * @param array $array данные которые необходимо примешать к ответу на каждой записи $data |
1086 | 1086 | * @return string JSON строка |
1087 | 1087 | */ |
1088 | - public function getJSON($data, $fields, $array = array()) |
|
1089 | - { |
|
1088 | + public function getJSON($data, $fields, $array = array()) |
|
1089 | + { |
|
1090 | 1090 | $out = array(); |
1091 | 1091 | $fields = is_array($fields) ? $fields : explode(",", $fields); |
1092 | - if (is_array($array) && count($array) > 0) { |
|
1092 | + if (is_array($array) && count($array) > 0) { |
|
1093 | 1093 | $tmp = array(); |
1094 | - foreach ($data as $i => $v) { //array_merge not valid work with integer index key |
|
1094 | + foreach ($data as $i => $v) { |
|
1095 | +//array_merge not valid work with integer index key |
|
1095 | 1096 | $tmp[$i] = (isset($array[$i]) ? array_merge($v, $array[$i]) : $v); |
1096 | 1097 | } |
1097 | 1098 | $data = $tmp; |
1098 | 1099 | } |
1099 | 1100 | |
1100 | - foreach ($data as $num => $doc) { |
|
1101 | + foreach ($data as $num => $doc) { |
|
1101 | 1102 | $tmp = array(); |
1102 | - foreach ($doc as $name => $value) { |
|
1103 | - if (in_array($name, $fields) || (isset($fields[0]) && $fields[0] == '1')) { |
|
1103 | + foreach ($doc as $name => $value) { |
|
1104 | + if (in_array($name, $fields) || (isset($fields[0]) && $fields[0] == '1')) { |
|
1104 | 1105 | $tmp[str_replace(".", "_", $name)] = $value; //JSON element name without dot |
1105 | 1106 | } |
1106 | 1107 | } |
1107 | 1108 | $out[$num] = $tmp; |
1108 | 1109 | } |
1109 | 1110 | |
1110 | - if ('new' == $this->getCFGDef('JSONformat', 'old')) { |
|
1111 | + if ('new' == $this->getCFGDef('JSONformat', 'old')) { |
|
1111 | 1112 | $return = array(); |
1112 | 1113 | |
1113 | 1114 | $return['rows'] = array(); |
1114 | - foreach ($out as $key => $item) { |
|
1115 | + foreach ($out as $key => $item) { |
|
1115 | 1116 | $return['rows'][] = $item; |
1116 | 1117 | } |
1117 | 1118 | $return['total'] = $this->getChildrenCount(); |
1118 | - } elseif ('simple' == $this->getCFGDef('JSONformat', 'old')) { |
|
1119 | + } elseif ('simple' == $this->getCFGDef('JSONformat', 'old')) { |
|
1119 | 1120 | $return = array(); |
1120 | - foreach ($out as $key => $item) { |
|
1121 | + foreach ($out as $key => $item) { |
|
1121 | 1122 | $return[] = $item; |
1122 | 1123 | } |
1123 | - } else { |
|
1124 | + } else { |
|
1124 | 1125 | $return = $out; |
1125 | 1126 | } |
1126 | 1127 | $this->outData = json_encode($return); |
@@ -1136,11 +1137,11 @@ discard block |
||
1136 | 1137 | * @param string $contentField |
1137 | 1138 | * @return mixed|string |
1138 | 1139 | */ |
1139 | - protected function getSummary(array $item = array(), $extSummary = null, $introField = '', $contentField = '') |
|
1140 | - { |
|
1140 | + protected function getSummary(array $item = array(), $extSummary = null, $introField = '', $contentField = '') |
|
1141 | + { |
|
1141 | 1142 | $out = ''; |
1142 | 1143 | |
1143 | - if (is_null($extSummary)) { |
|
1144 | + if (is_null($extSummary)) { |
|
1144 | 1145 | /** |
1145 | 1146 | * @var $extSummary summary_DL_Extender |
1146 | 1147 | */ |
@@ -1149,10 +1150,10 @@ discard block |
||
1149 | 1150 | $introField = $this->getCFGDef("introField", $introField); |
1150 | 1151 | $contentField = $this->getCFGDef("contentField", $contentField); |
1151 | 1152 | |
1152 | - if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) { |
|
1153 | + if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) { |
|
1153 | 1154 | $out = $item[$introField]; |
1154 | - } else { |
|
1155 | - if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) { |
|
1155 | + } else { |
|
1156 | + if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) { |
|
1156 | 1157 | $out = $extSummary->init($this, array( |
1157 | 1158 | "content" => $item[$contentField], |
1158 | 1159 | "action" => $this->getCFGDef("summary", ""), |
@@ -1170,8 +1171,8 @@ discard block |
||
1170 | 1171 | * @param string $name extender name |
1171 | 1172 | * @return boolean status extender load |
1172 | 1173 | */ |
1173 | - public function checkExtender($name) |
|
1174 | - { |
|
1174 | + public function checkExtender($name) |
|
1175 | + { |
|
1175 | 1176 | return (isset($this->extender[$name]) && $this->extender[$name] instanceof $name . "_DL_Extender"); |
1176 | 1177 | } |
1177 | 1178 | |
@@ -1179,8 +1180,8 @@ discard block |
||
1179 | 1180 | * @param $name |
1180 | 1181 | * @param $obj |
1181 | 1182 | */ |
1182 | - public function setExtender($name, $obj) |
|
1183 | - { |
|
1183 | + public function setExtender($name, $obj) |
|
1184 | + { |
|
1184 | 1185 | $this->extender[$name] = $obj; |
1185 | 1186 | } |
1186 | 1187 | |
@@ -1192,13 +1193,13 @@ discard block |
||
1192 | 1193 | * @param bool $nop если экстендер не загружен, то загружать ли xNop |
1193 | 1194 | * @return null|xNop |
1194 | 1195 | */ |
1195 | - public function getExtender($name, $autoload = false, $nop = false) |
|
1196 | - { |
|
1196 | + public function getExtender($name, $autoload = false, $nop = false) |
|
1197 | + { |
|
1197 | 1198 | $out = null; |
1198 | - if ((is_scalar($name) && $this->checkExtender($name)) || ($autoload && $this->_loadExtender($name))) { |
|
1199 | + if ((is_scalar($name) && $this->checkExtender($name)) || ($autoload && $this->_loadExtender($name))) { |
|
1199 | 1200 | $out = $this->extender[$name]; |
1200 | 1201 | } |
1201 | - if ($nop && is_null($out)) { |
|
1202 | + if ($nop && is_null($out)) { |
|
1202 | 1203 | $out = new xNop(); |
1203 | 1204 | } |
1204 | 1205 | |
@@ -1211,27 +1212,27 @@ discard block |
||
1211 | 1212 | * @param string $name name extender |
1212 | 1213 | * @return boolean $flag status load extender |
1213 | 1214 | */ |
1214 | - protected function _loadExtender($name) |
|
1215 | - { |
|
1215 | + protected function _loadExtender($name) |
|
1216 | + { |
|
1216 | 1217 | $this->debug->debug('Load Extender ' . $this->debug->dumpData($name), 'LoadExtender', 2); |
1217 | 1218 | $flag = false; |
1218 | 1219 | |
1219 | 1220 | $classname = ($name != '') ? $name . "_DL_Extender" : ""; |
1220 | - if ($classname != '' && isset($this->extender[$name]) && $this->extender[$name] instanceof $classname) { |
|
1221 | + if ($classname != '' && isset($this->extender[$name]) && $this->extender[$name] instanceof $classname) { |
|
1221 | 1222 | $flag = true; |
1222 | 1223 | |
1223 | - } else { |
|
1224 | - if (!class_exists($classname, false) && $classname != '') { |
|
1225 | - if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) { |
|
1224 | + } else { |
|
1225 | + if (!class_exists($classname, false) && $classname != '') { |
|
1226 | + if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) { |
|
1226 | 1227 | include_once(dirname(__FILE__) . "/extender/" . $name . ".extender.inc"); |
1227 | 1228 | } |
1228 | 1229 | } |
1229 | - if (class_exists($classname, false) && $classname != '') { |
|
1230 | + if (class_exists($classname, false) && $classname != '') { |
|
1230 | 1231 | $this->extender[$name] = new $classname($this, $name); |
1231 | 1232 | $flag = true; |
1232 | 1233 | } |
1233 | 1234 | } |
1234 | - if (!$flag) { |
|
1235 | + if (!$flag) { |
|
1235 | 1236 | $this->debug->debug("Error load Extender " . $this->debug->dumpData($name)); |
1236 | 1237 | } |
1237 | 1238 | $this->debug->debugEnd('LoadExtender'); |
@@ -1249,16 +1250,16 @@ discard block |
||
1249 | 1250 | * @param mixed $IDs список id документов по которым необходима выборка |
1250 | 1251 | * @return array очищенный массив |
1251 | 1252 | */ |
1252 | - public function setIDs($IDs) |
|
1253 | - { |
|
1253 | + public function setIDs($IDs) |
|
1254 | + { |
|
1254 | 1255 | $this->debug->debug('set ID list ' . $this->debug->dumpData($IDs), 'setIDs', 2); |
1255 | 1256 | $IDs = $this->cleanIDs($IDs); |
1256 | 1257 | $type = $this->getCFGDef('idType', 'parents'); |
1257 | 1258 | $depth = $this->getCFGDef('depth', ''); |
1258 | - if ($type == 'parents' && $depth > 0) { |
|
1259 | + if ($type == 'parents' && $depth > 0) { |
|
1259 | 1260 | $tmp = $IDs; |
1260 | - do { |
|
1261 | - if (count($tmp) > 0) { |
|
1261 | + do { |
|
1262 | + if (count($tmp) > 0) { |
|
1262 | 1263 | $tmp = $this->getChildrenFolder($tmp); |
1263 | 1264 | $IDs = array_merge($IDs, $tmp); |
1264 | 1265 | } |
@@ -1272,8 +1273,8 @@ discard block |
||
1272 | 1273 | /** |
1273 | 1274 | * @return int |
1274 | 1275 | */ |
1275 | - public function getIDs() |
|
1276 | - { |
|
1276 | + public function getIDs() |
|
1277 | + { |
|
1277 | 1278 | return $this->IDs; |
1278 | 1279 | } |
1279 | 1280 | |
@@ -1284,17 +1285,18 @@ discard block |
||
1284 | 1285 | * @param string $sep разделитель |
1285 | 1286 | * @return array очищенный массив с данными |
1286 | 1287 | */ |
1287 | - public function cleanIDs($IDs, $sep = ',') |
|
1288 | - { |
|
1288 | + public function cleanIDs($IDs, $sep = ',') |
|
1289 | + { |
|
1289 | 1290 | $this->debug->debug('clean IDs ' . $this->debug->dumpData($IDs) . ' with separator ' . $this->debug->dumpData($sep), |
1290 | 1291 | 'cleanIDs', 2); |
1291 | 1292 | $out = array(); |
1292 | - if (!is_array($IDs)) { |
|
1293 | + if (!is_array($IDs)) { |
|
1293 | 1294 | $IDs = explode($sep, $IDs); |
1294 | 1295 | } |
1295 | - foreach ($IDs as $item) { |
|
1296 | + foreach ($IDs as $item) { |
|
1296 | 1297 | $item = trim($item); |
1297 | - if (is_numeric($item) && (int)$item >= 0) { //Fix 0xfffffffff |
|
1298 | + if (is_numeric($item) && (int)$item >= 0) { |
|
1299 | +//Fix 0xfffffffff |
|
1298 | 1300 | $out[] = (int)$item; |
1299 | 1301 | } |
1300 | 1302 | } |
@@ -1308,8 +1310,8 @@ discard block |
||
1308 | 1310 | * Проверка массива с id-шниками документов для выборки |
1309 | 1311 | * @return boolean пригодны ли данные для дальнейшего использования |
1310 | 1312 | */ |
1311 | - protected function checkIDs() |
|
1312 | - { |
|
1313 | + protected function checkIDs() |
|
1314 | + { |
|
1313 | 1315 | return (is_array($this->IDs) && count($this->IDs) > 0) ? true : false; |
1314 | 1316 | } |
1315 | 1317 | |
@@ -1321,11 +1323,11 @@ discard block |
||
1321 | 1323 | * @global array $_docs all documents |
1322 | 1324 | * @return array all field values |
1323 | 1325 | */ |
1324 | - public function getOneField($userField, $uniq = false) |
|
1325 | - { |
|
1326 | + public function getOneField($userField, $uniq = false) |
|
1327 | + { |
|
1326 | 1328 | $out = array(); |
1327 | - foreach ($this->_docs as $doc => $val) { |
|
1328 | - if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) { |
|
1329 | + foreach ($this->_docs as $doc => $val) { |
|
1330 | + if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) { |
|
1329 | 1331 | $out[$doc] = $val[$userField]; |
1330 | 1332 | } |
1331 | 1333 | } |
@@ -1336,8 +1338,8 @@ discard block |
||
1336 | 1338 | /** |
1337 | 1339 | * @return DLCollection |
1338 | 1340 | */ |
1339 | - public function docsCollection() |
|
1340 | - { |
|
1341 | + public function docsCollection() |
|
1342 | + { |
|
1341 | 1343 | return new DLCollection($this->modx, $this->_docs); |
1342 | 1344 | } |
1343 | 1345 | |
@@ -1365,10 +1367,10 @@ discard block |
||
1365 | 1367 | * @param string $group |
1366 | 1368 | * @return string |
1367 | 1369 | */ |
1368 | - protected function getGroupSQL($group = '') |
|
1369 | - { |
|
1370 | + protected function getGroupSQL($group = '') |
|
1371 | + { |
|
1370 | 1372 | $out = ''; |
1371 | - if ($group != '') { |
|
1373 | + if ($group != '') { |
|
1372 | 1374 | $out = 'GROUP BY ' . $group; |
1373 | 1375 | } |
1374 | 1376 | |
@@ -1387,12 +1389,12 @@ discard block |
||
1387 | 1389 | * |
1388 | 1390 | * @return string Order by for SQL |
1389 | 1391 | */ |
1390 | - protected function SortOrderSQL($sortName, $orderDef = 'DESC') |
|
1391 | - { |
|
1392 | + protected function SortOrderSQL($sortName, $orderDef = 'DESC') |
|
1393 | + { |
|
1392 | 1394 | $this->debug->debug('', 'sortORDER', 2); |
1393 | 1395 | |
1394 | 1396 | $sort = ''; |
1395 | - switch ($this->getCFGDef('sortType', '')) { |
|
1397 | + switch ($this->getCFGDef('sortType', '')) { |
|
1396 | 1398 | case 'none': |
1397 | 1399 | break; |
1398 | 1400 | case 'doclist': |
@@ -1403,10 +1405,10 @@ discard block |
||
1403 | 1405 | break; |
1404 | 1406 | default: |
1405 | 1407 | $out = array('orderBy' => '', 'order' => '', 'sortBy' => ''); |
1406 | - if (($tmp = $this->getCFGDef('orderBy', '')) != '') { |
|
1408 | + if (($tmp = $this->getCFGDef('orderBy', '')) != '') { |
|
1407 | 1409 | $out['orderBy'] = $tmp; |
1408 | - } else { |
|
1409 | - switch (true) { |
|
1410 | + } else { |
|
1411 | + switch (true) { |
|
1410 | 1412 | case ('' != ($tmp = $this->getCFGDef('sortDir', ''))): //higher priority than order |
1411 | 1413 | $out['order'] = $tmp; |
1412 | 1414 | // no break |
@@ -1414,7 +1416,7 @@ discard block |
||
1414 | 1416 | $out['order'] = $tmp; |
1415 | 1417 | // no break |
1416 | 1418 | } |
1417 | - if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) { |
|
1419 | + if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) { |
|
1418 | 1420 | $out['order'] = $orderDef; //Default |
1419 | 1421 | } |
1420 | 1422 | |
@@ -1435,30 +1437,30 @@ discard block |
||
1435 | 1437 | * |
1436 | 1438 | * @return string LIMIT вставка в SQL запрос |
1437 | 1439 | */ |
1438 | - protected function LimitSQL($limit = 0, $offset = 0) |
|
1439 | - { |
|
1440 | + protected function LimitSQL($limit = 0, $offset = 0) |
|
1441 | + { |
|
1440 | 1442 | $this->debug->debug('', 'limitSQL', 2); |
1441 | 1443 | $ret = ''; |
1442 | - if ($limit == 0) { |
|
1444 | + if ($limit == 0) { |
|
1443 | 1445 | $limit = $this->getCFGDef('display', 0); |
1444 | 1446 | } |
1445 | 1447 | $maxDocs = $this->getCFGDef('maxDocs', 0); |
1446 | - if ($maxDocs > 0 && $limit > $maxDocs) { |
|
1448 | + if ($maxDocs > 0 && $limit > $maxDocs) { |
|
1447 | 1449 | $limit = $maxDocs; |
1448 | 1450 | } |
1449 | - if ($offset == 0) { |
|
1451 | + if ($offset == 0) { |
|
1450 | 1452 | $offset = $this->getCFGDef('offset', 0); |
1451 | 1453 | } |
1452 | 1454 | $offset += $this->getCFGDef('start', 0); |
1453 | 1455 | $total = $this->getCFGDef('total', 0); |
1454 | - if ($limit < ($total - $limit)) { |
|
1456 | + if ($limit < ($total - $limit)) { |
|
1455 | 1457 | $limit = $total - $offset; |
1456 | 1458 | } |
1457 | 1459 | |
1458 | - if ($limit != 0) { |
|
1460 | + if ($limit != 0) { |
|
1459 | 1461 | $ret = "LIMIT " . (int)$offset . "," . (int)$limit; |
1460 | - } else { |
|
1461 | - if ($offset != 0) { |
|
1462 | + } else { |
|
1463 | + if ($offset != 0) { |
|
1462 | 1464 | /** |
1463 | 1465 | * To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter |
1464 | 1466 | * @see http://dev.mysql.com/doc/refman/5.0/en/select.html |
@@ -1478,8 +1480,8 @@ discard block |
||
1478 | 1480 | * @param string $charset |
1479 | 1481 | * @return string Clear string |
1480 | 1482 | */ |
1481 | - public function sanitarData($data, $charset = 'UTF-8') |
|
1482 | - { |
|
1483 | + public function sanitarData($data, $charset = 'UTF-8') |
|
1484 | + { |
|
1483 | 1485 | return APIHelpers::sanitarTag($data, $charset); |
1484 | 1486 | } |
1485 | 1487 | |
@@ -1490,8 +1492,8 @@ discard block |
||
1490 | 1492 | * @param string $parentField default name parent field |
1491 | 1493 | * @return array |
1492 | 1494 | */ |
1493 | - public function treeBuild($idField = 'id', $parentField = 'parent') |
|
1494 | - { |
|
1495 | + public function treeBuild($idField = 'id', $parentField = 'parent') |
|
1496 | + { |
|
1495 | 1497 | return $this->_treeBuild($this->_docs, $this->getCFGDef('idField', $idField), |
1496 | 1498 | $this->getCFGDef('parentField', $parentField)); |
1497 | 1499 | } |
@@ -1504,16 +1506,16 @@ discard block |
||
1504 | 1506 | * @param string $pidName name parent field in associative data array |
1505 | 1507 | * @return array |
1506 | 1508 | */ |
1507 | - private function _treeBuild($data, $idName, $pidName) |
|
1508 | - { |
|
1509 | + private function _treeBuild($data, $idName, $pidName) |
|
1510 | + { |
|
1509 | 1511 | $children = array(); // children of each ID |
1510 | 1512 | $ids = array(); |
1511 | - foreach ($data as $i => $r) { |
|
1513 | + foreach ($data as $i => $r) { |
|
1512 | 1514 | $row =& $data[$i]; |
1513 | 1515 | $id = $row[$idName]; |
1514 | 1516 | $pid = $row[$pidName]; |
1515 | 1517 | $children[$pid][$id] =& $row; |
1516 | - if (!isset($children[$id])) { |
|
1518 | + if (!isset($children[$id])) { |
|
1517 | 1519 | $children[$id] = array(); |
1518 | 1520 | } |
1519 | 1521 | $row['#childNodes'] =& $children[$id]; |
@@ -1521,9 +1523,9 @@ discard block |
||
1521 | 1523 | } |
1522 | 1524 | // Root elements are elements with non-found PIDs. |
1523 | 1525 | $this->_tree = array(); |
1524 | - foreach ($data as $i => $r) { |
|
1526 | + foreach ($data as $i => $r) { |
|
1525 | 1527 | $row =& $data[$i]; |
1526 | - if (!isset($ids[$row[$pidName]])) { |
|
1528 | + if (!isset($ids[$row[$pidName]])) { |
|
1527 | 1529 | $this->_tree[$row[$idName]] = $row; |
1528 | 1530 | } |
1529 | 1531 | } |
@@ -1537,12 +1539,12 @@ discard block |
||
1537 | 1539 | * @param bool $full если true то возвращается значение для подстановки в запрос |
1538 | 1540 | * @return string PrimaryKey основной таблицы |
1539 | 1541 | */ |
1540 | - public function getPK($full = true) |
|
1541 | - { |
|
1542 | + public function getPK($full = true) |
|
1543 | + { |
|
1542 | 1544 | $idField = isset($this->idField) ? $this->idField: 'id'; |
1543 | - if ($full) { |
|
1545 | + if ($full) { |
|
1544 | 1546 | $idField = '`' . $idField . '`'; |
1545 | - if (!empty($this->alias)) { |
|
1547 | + if (!empty($this->alias)) { |
|
1546 | 1548 | $idField = '`' . $this->alias . '`.' . $idField; |
1547 | 1549 | } |
1548 | 1550 | } |
@@ -1556,12 +1558,12 @@ discard block |
||
1556 | 1558 | * @param bool $full если true то возвращается значение для подстановки в запрос |
1557 | 1559 | * @return string Parent Key основной таблицы |
1558 | 1560 | */ |
1559 | - public function getParentField($full = true) |
|
1560 | - { |
|
1561 | + public function getParentField($full = true) |
|
1562 | + { |
|
1561 | 1563 | $parentField = isset($this->parentField) ? $this->parentField : ''; |
1562 | - if ($full && !empty($parentField)) { |
|
1564 | + if ($full && !empty($parentField)) { |
|
1563 | 1565 | $parentField = '`' . $parentField . '`'; |
1564 | - if (!empty($this->alias)) { |
|
1566 | + if (!empty($this->alias)) { |
|
1565 | 1567 | $parentField = '`' . $this->alias . '`.' . $parentField; |
1566 | 1568 | } |
1567 | 1569 | } |
@@ -1576,31 +1578,31 @@ discard block |
||
1576 | 1578 | * @param string $filter_string строка со всеми фильтрами |
1577 | 1579 | * @return mixed результат разбора фильтров |
1578 | 1580 | */ |
1579 | - protected function getFilters($filter_string) |
|
1580 | - { |
|
1581 | + protected function getFilters($filter_string) |
|
1582 | + { |
|
1581 | 1583 | $this->debug->debug("getFilters: " . $this->debug->dumpData($filter_string), 'getFilter', 1); |
1582 | 1584 | // the filter parameter tells us, which filters can be used in this query |
1583 | 1585 | $filter_string = trim($filter_string, ' ;'); |
1584 | - if (!$filter_string) { |
|
1586 | + if (!$filter_string) { |
|
1585 | 1587 | return; |
1586 | 1588 | } |
1587 | 1589 | $output = array('join' => '', 'where' => ''); |
1588 | 1590 | $logic_op_found = false; |
1589 | 1591 | $joins = $wheres = array(); |
1590 | - foreach ($this->_logic_ops as $op => $sql) { |
|
1591 | - if (strpos($filter_string, $op) === 0) { |
|
1592 | + foreach ($this->_logic_ops as $op => $sql) { |
|
1593 | + if (strpos($filter_string, $op) === 0) { |
|
1592 | 1594 | $logic_op_found = true; |
1593 | 1595 | $subfilters = mb_substr($filter_string, strlen($op) + 1, mb_strlen($filter_string, "UTF-8"), "UTF-8"); |
1594 | 1596 | $subfilters = $this->smartSplit($subfilters); |
1595 | - foreach ($subfilters as $subfilter) { |
|
1597 | + foreach ($subfilters as $subfilter) { |
|
1596 | 1598 | $subfilter = $this->getFilters(trim($subfilter)); |
1597 | - if (!$subfilter) { |
|
1599 | + if (!$subfilter) { |
|
1598 | 1600 | continue; |
1599 | 1601 | } |
1600 | - if ($subfilter['join']) { |
|
1602 | + if ($subfilter['join']) { |
|
1601 | 1603 | $joins[] = $subfilter['join']; |
1602 | 1604 | } |
1603 | - if ($subfilter['where']) { |
|
1605 | + if ($subfilter['where']) { |
|
1604 | 1606 | $wheres[] = $subfilter['where']; |
1605 | 1607 | } |
1606 | 1608 | } |
@@ -1609,12 +1611,12 @@ discard block |
||
1609 | 1611 | } |
1610 | 1612 | } |
1611 | 1613 | |
1612 | - if (!$logic_op_found) { |
|
1614 | + if (!$logic_op_found) { |
|
1613 | 1615 | $filter = $this->loadFilter($filter_string); |
1614 | - if (!$filter) { |
|
1616 | + if (!$filter) { |
|
1615 | 1617 | $this->debug->warning('Error while loading DocLister filter "' . $this->debug->dumpData($filter_string) . '": check syntax!'); |
1616 | 1618 | $output = false; |
1617 | - } else { |
|
1619 | + } else { |
|
1618 | 1620 | $output['join'] = $filter->get_join(); |
1619 | 1621 | $output['where'] = $filter->get_where(); |
1620 | 1622 | } |
@@ -1627,16 +1629,16 @@ discard block |
||
1627 | 1629 | /** |
1628 | 1630 | * @return mixed |
1629 | 1631 | */ |
1630 | - public function filtersWhere() |
|
1631 | - { |
|
1632 | + public function filtersWhere() |
|
1633 | + { |
|
1632 | 1634 | return APIHelpers::getkey($this->_filters, 'where', ''); |
1633 | 1635 | } |
1634 | 1636 | |
1635 | 1637 | /** |
1636 | 1638 | * @return mixed |
1637 | 1639 | */ |
1638 | - public function filtersJoin() |
|
1639 | - { |
|
1640 | + public function filtersJoin() |
|
1641 | + { |
|
1640 | 1642 | return APIHelpers::getkey($this->_filters, 'join', ''); |
1641 | 1643 | } |
1642 | 1644 | |
@@ -1647,10 +1649,10 @@ discard block |
||
1647 | 1649 | * @param $type string тип фильтрации |
1648 | 1650 | * @return string имя поля с учетом приведения типа |
1649 | 1651 | */ |
1650 | - public function changeSortType($field, $type) |
|
1651 | - { |
|
1652 | + public function changeSortType($field, $type) |
|
1653 | + { |
|
1652 | 1654 | $type = trim($type); |
1653 | - switch (strtoupper($type)) { |
|
1655 | + switch (strtoupper($type)) { |
|
1654 | 1656 | case 'DECIMAL': |
1655 | 1657 | $field = 'CAST(' . $field . ' as DECIMAL(10,2))'; |
1656 | 1658 | break; |
@@ -1676,14 +1678,14 @@ discard block |
||
1676 | 1678 | * @param string $filter срока с параметрами фильтрации |
1677 | 1679 | * @return bool |
1678 | 1680 | */ |
1679 | - protected function loadFilter($filter) |
|
1680 | - { |
|
1681 | + protected function loadFilter($filter) |
|
1682 | + { |
|
1681 | 1683 | $this->debug->debug('Load filter ' . $this->debug->dumpData($filter), 'loadFilter', 2); |
1682 | 1684 | $out = false; |
1683 | 1685 | $fltr_params = explode(':', $filter, 2); |
1684 | 1686 | $fltr = APIHelpers::getkey($fltr_params, 0, null); |
1685 | 1687 | // check if the filter is implemented |
1686 | - if (!is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) { |
|
1688 | + if (!is_null($fltr) && file_exists(dirname(__FILE__) . '/filter/' . $fltr . '.filter.php')) { |
|
1687 | 1689 | require_once dirname(__FILE__) . '/filter/' . $fltr . '.filter.php'; |
1688 | 1690 | /** |
1689 | 1691 | * @var tv_DL_filter|content_DL_filter $fltr_class |
@@ -1691,12 +1693,12 @@ discard block |
||
1691 | 1693 | $fltr_class = $fltr . '_DL_filter'; |
1692 | 1694 | $this->totalFilters++; |
1693 | 1695 | $fltr_obj = new $fltr_class(); |
1694 | - if ($fltr_obj->init($this, $filter)) { |
|
1696 | + if ($fltr_obj->init($this, $filter)) { |
|
1695 | 1697 | $out = $fltr_obj; |
1696 | - } else { |
|
1698 | + } else { |
|
1697 | 1699 | $this->debug->error("Wrong filter parameter: '{$this->debug->dumpData($filter)}'", 'Filter'); |
1698 | 1700 | } |
1699 | - } else { |
|
1701 | + } else { |
|
1700 | 1702 | $this->debug->error("Error load Filter: '{$this->debug->dumpData($filter)}'", 'Filter'); |
1701 | 1703 | } |
1702 | 1704 | $this->debug->debugEnd("loadFilter"); |
@@ -1708,8 +1710,8 @@ discard block |
||
1708 | 1710 | * Общее число фильтров |
1709 | 1711 | * @return int |
1710 | 1712 | */ |
1711 | - public function getCountFilters() |
|
1712 | - { |
|
1713 | + public function getCountFilters() |
|
1714 | + { |
|
1713 | 1715 | return (int)$this->totalFilters; |
1714 | 1716 | } |
1715 | 1717 | |
@@ -1717,8 +1719,8 @@ discard block |
||
1717 | 1719 | * Выполнить SQL запрос |
1718 | 1720 | * @param string $q SQL запрос |
1719 | 1721 | */ |
1720 | - public function dbQuery($q) |
|
1721 | - { |
|
1722 | + public function dbQuery($q) |
|
1723 | + { |
|
1722 | 1724 | $this->debug->debug($q, "query", 1, 'sql'); |
1723 | 1725 | $out = $this->modx->db->query($q); |
1724 | 1726 | $this->debug->debugEnd("query"); |
@@ -1736,8 +1738,8 @@ discard block |
||
1736 | 1738 | * @param string $tpl шаблон подстановки значения в SQL запрос |
1737 | 1739 | * @return string строка для подстановки в SQL запрос |
1738 | 1740 | */ |
1739 | - public function LikeEscape($field, $value, $escape = '=', $tpl = '%[+value+]%') |
|
1740 | - { |
|
1741 | + public function LikeEscape($field, $value, $escape = '=', $tpl = '%[+value+]%') |
|
1742 | + { |
|
1741 | 1743 | return sqlHelper::LikeEscape($this->modx, $field, $value, $escape, $tpl); |
1742 | 1744 | } |
1743 | 1745 | |
@@ -1745,8 +1747,8 @@ discard block |
||
1745 | 1747 | * Получение REQUEST_URI без GET-ключа с |
1746 | 1748 | * @return string |
1747 | 1749 | */ |
1748 | - public function getRequest() |
|
1749 | - { |
|
1750 | + public function getRequest() |
|
1751 | + { |
|
1750 | 1752 | $URL = null; |
1751 | 1753 | parse_str(parse_url(MODX_SITE_URL . $_SERVER['REQUEST_URI'], PHP_URL_QUERY), $URL); |
1752 | 1754 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('MODX_BASE_PATH')) { |
|
2 | +if ( ! defined('MODX_BASE_PATH')) { |
|
3 | 3 | die('HACK???'); |
4 | 4 | } |
5 | 5 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | $where[] = "{$this->getPK()} IN ({$sanitarInIDs})"; |
221 | 221 | } |
222 | 222 | |
223 | - if (!empty($where)) { |
|
223 | + if ( ! empty($where)) { |
|
224 | 224 | $where = "WHERE " . implode(" AND ", $where); |
225 | 225 | } |
226 | 226 | $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0)); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | |
248 | 248 | $tmpWhere = $this->getCFGDef('addWhereList', ''); |
249 | 249 | $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere); |
250 | - if (!empty($tmpWhere)) { |
|
250 | + if ( ! empty($tmpWhere)) { |
|
251 | 251 | $where[] = $tmpWhere; |
252 | 252 | } |
253 | 253 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
@@ -276,10 +276,10 @@ discard block |
||
276 | 276 | $tmpWhere = "((" . $tmpWhere . ") OR {$this->getPK()} IN({$addDocs}))"; |
277 | 277 | } |
278 | 278 | } |
279 | - if (!empty($tmpWhere)) { |
|
279 | + if ( ! empty($tmpWhere)) { |
|
280 | 280 | $where[] = $tmpWhere; |
281 | 281 | } |
282 | - if (!empty($where)) { |
|
282 | + if ( ! empty($where)) { |
|
283 | 283 | $where = "WHERE " . implode(" AND ", $where); |
284 | 284 | } else { |
285 | 285 | $where = ''; |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | } |
348 | 348 | } |
349 | 349 | } |
350 | - if (!empty($where)) { |
|
350 | + if ( ! empty($where)) { |
|
351 | 351 | $where = "WHERE " . implode(" AND ", $where); |
352 | 352 | } else { |
353 | 353 | $where = ''; |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | |
375 | 375 | $tmp = $this->getCFGDef('addWhereFolder', ''); |
376 | 376 | $where = "{$this->getParentField()} IN ({$sanitarInIDs})"; |
377 | - if (!empty($tmp)) { |
|
377 | + if ( ! empty($tmp)) { |
|
378 | 378 | $where .= " AND " . $tmp; |
379 | 379 | } |
380 | 380 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('MODX_BASE_PATH')) { |
|
2 | +if (!defined('MODX_BASE_PATH')) { |
|
3 | 3 | die('HACK???'); |
4 | 4 | } |
5 | 5 | |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | * @param contentField =`description` //content |
15 | 15 | * @param table =`` //table name |
16 | 16 | */ |
17 | -class onetableDocLister extends DocLister |
|
18 | -{ |
|
17 | +class onetableDocLister extends DocLister |
|
18 | +{ |
|
19 | 19 | /** |
20 | 20 | * @var string |
21 | 21 | */ |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @absctract |
35 | 35 | */ |
36 | - public function getDocs($tvlist = '') |
|
37 | - { |
|
38 | - if ($this->checkExtender('paginate')) { |
|
36 | + public function getDocs($tvlist = '') |
|
37 | + { |
|
38 | + if ($this->checkExtender('paginate')) { |
|
39 | 39 | $this->extender['paginate']->init($this); |
40 | - } else { |
|
40 | + } else { |
|
41 | 41 | $this->config->setConfig(array('start' => 0)); |
42 | 42 | } |
43 | 43 | $type = $this->getCFGDef('idType', 'parents'); |
@@ -50,25 +50,25 @@ discard block |
||
50 | 50 | * @param string $tpl |
51 | 51 | * @return string |
52 | 52 | */ |
53 | - public function _render($tpl = '') |
|
54 | - { |
|
53 | + public function _render($tpl = '') |
|
54 | + { |
|
55 | 55 | $out = ''; |
56 | - if ($tpl == '') { |
|
56 | + if ($tpl == '') { |
|
57 | 57 | $tpl = $this->getCFGDef('tpl', ''); |
58 | 58 | } |
59 | - if ($tpl != '') { |
|
59 | + if ($tpl != '') { |
|
60 | 60 | $this->toPlaceholders(count($this->_docs), 1, "display"); // [+display+] - сколько показано на странице. |
61 | 61 | |
62 | 62 | $i = 1; |
63 | 63 | $sysPlh = $this->renameKeyArr($this->_plh, $this->getCFGDef("sysKey", "dl")); |
64 | 64 | $noneTPL = $this->getCFGDef("noneTPL", ""); |
65 | - if (count($this->_docs) == 0 && $noneTPL != '') { |
|
65 | + if (count($this->_docs) == 0 && $noneTPL != '') { |
|
66 | 66 | $out = $this->parseChunk($noneTPL, $sysPlh); |
67 | - } else { |
|
67 | + } else { |
|
68 | 68 | /** |
69 | 69 | * @var $extUser user_DL_Extender |
70 | 70 | */ |
71 | - if ($extUser = $this->getExtender('user')) { |
|
71 | + if ($extUser = $this->getExtender('user')) { |
|
72 | 72 | $extUser->init($this, array('fields' => $this->getCFGDef("userFields", ""))); |
73 | 73 | } |
74 | 74 | |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | */ |
83 | 83 | $extPrepare = $this->getExtender('prepare'); |
84 | 84 | $this->skippedDocs = 0; |
85 | - foreach ($this->_docs as $item) { |
|
85 | + foreach ($this->_docs as $item) { |
|
86 | 86 | $this->renderTPL = $tpl; |
87 | - if ($extUser) { |
|
87 | + if ($extUser) { |
|
88 | 88 | $item = $extUser->setUserData($item); //[+user.id.createdby+], [+user.fullname.publishedby+], [+dl.user.publishedby+].... |
89 | 89 | } |
90 | 90 | |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | "dl") . '.iteration'] = $i; //[+iteration+] - Number element. Starting from zero |
98 | 98 | |
99 | 99 | $date = $this->getCFGDef('dateSource', 'pub_date'); |
100 | - if (isset($item[$date])) { |
|
100 | + if (isset($item[$date])) { |
|
101 | 101 | $_date = is_numeric($item[$date]) && $item[$date] == (int)$item[$date] ? $item[$date] : strtotime($item[$date]); |
102 | - if ($_date !== false) { |
|
102 | + if ($_date !== false) { |
|
103 | 103 | $_date = $_date + $this->modx->config['server_offset_time']; |
104 | 104 | $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'); |
105 | - if ($dateFormat) { |
|
105 | + if ($dateFormat) { |
|
106 | 106 | $item['date'] = strftime($dateFormat, $_date); |
107 | 107 | } |
108 | 108 | } |
@@ -111,22 +111,22 @@ discard block |
||
111 | 111 | $findTpl = $this->renderTPL; |
112 | 112 | $tmp = $this->uniformPrepare($item, $i); |
113 | 113 | extract($tmp, EXTR_SKIP); |
114 | - if ($this->renderTPL == '') { |
|
114 | + if ($this->renderTPL == '') { |
|
115 | 115 | $this->renderTPL = $findTpl; |
116 | 116 | } |
117 | 117 | |
118 | - if ($extPrepare) { |
|
118 | + if ($extPrepare) { |
|
119 | 119 | $item = $extPrepare->init($this, array( |
120 | 120 | 'data' => $item, |
121 | 121 | 'nameParam' => 'prepare' |
122 | 122 | )); |
123 | - if (is_bool($item) && $item === false) { |
|
123 | + if (is_bool($item) && $item === false) { |
|
124 | 124 | $this->skippedDocs++; |
125 | 125 | continue; |
126 | 126 | } |
127 | 127 | } |
128 | 128 | $tmp = $this->parseChunk($this->renderTPL, $item); |
129 | - if ($this->getCFGDef('contentPlaceholder', 0) !== 0) { |
|
129 | + if ($this->getCFGDef('contentPlaceholder', 0) !== 0) { |
|
130 | 130 | $this->toPlaceholders($tmp, 1, |
131 | 131 | "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page |
132 | 132 | } |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | * @param array $array |
147 | 147 | * @return string |
148 | 148 | */ |
149 | - public function getJSON($data, $fields, $array = array()) |
|
150 | - { |
|
149 | + public function getJSON($data, $fields, $array = array()) |
|
150 | + { |
|
151 | 151 | $out = array(); |
152 | 152 | $fields = is_array($fields) ? $fields : explode(",", $fields); |
153 | 153 | $date = $this->getCFGDef('dateSource', 'pub_date'); |
@@ -166,19 +166,19 @@ discard block |
||
166 | 166 | * @var $extE e_DL_Extender |
167 | 167 | */ |
168 | 168 | $extE = $this->getExtender('e', true, true); |
169 | - foreach ($data as $num => $row) { |
|
169 | + foreach ($data as $num => $row) { |
|
170 | 170 | |
171 | - switch (true) { |
|
171 | + switch (true) { |
|
172 | 172 | case ((array('1') == $fields || in_array('summary', $fields)) && $extSummary): |
173 | 173 | $row['summary'] = $this->getSummary($row, $extSummary, 'introtext'); |
174 | 174 | //without break |
175 | 175 | case ((array('1') == $fields || in_array('date', $fields)) && $date != 'date'): |
176 | - if (isset($row[$date])) { |
|
176 | + if (isset($row[$date])) { |
|
177 | 177 | $_date = is_numeric($row[$date]) && $row[$date] == (int)$row[$date] ? $row[$date] : strtotime($row[$date]); |
178 | - if ($_date !== false) { |
|
178 | + if ($_date !== false) { |
|
179 | 179 | $_date = $_date + $this->modx->config['server_offset_time']; |
180 | 180 | $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'); |
181 | - if ($dateFormat) { |
|
181 | + if ($dateFormat) { |
|
182 | 182 | $row['date'] = strftime($dateFormat, $_date); |
183 | 183 | } |
184 | 184 | } |
@@ -186,15 +186,15 @@ discard block |
||
186 | 186 | //nobreak |
187 | 187 | } |
188 | 188 | |
189 | - if ($extE && $tmp = $extE->init($this, array('data' => $row))) { |
|
190 | - if (is_array($tmp)) { |
|
189 | + if ($extE && $tmp = $extE->init($this, array('data' => $row))) { |
|
190 | + if (is_array($tmp)) { |
|
191 | 191 | $row = $tmp; |
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | - if ($extPrepare) { |
|
195 | + if ($extPrepare) { |
|
196 | 196 | $row = $extPrepare->init($this, array('data' => $row)); |
197 | - if (is_bool($row) && $row === false) { |
|
197 | + if (is_bool($row) && $row === false) { |
|
198 | 198 | continue; |
199 | 199 | } |
200 | 200 | } |
@@ -207,20 +207,20 @@ discard block |
||
207 | 207 | /** |
208 | 208 | * @return array |
209 | 209 | */ |
210 | - protected function getDocList() |
|
211 | - { |
|
210 | + protected function getDocList() |
|
211 | + { |
|
212 | 212 | $out = array(); |
213 | 213 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
214 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
214 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
215 | 215 | $where = $this->getCFGDef('addWhereList', ''); |
216 | - if ($where != '') { |
|
216 | + if ($where != '') { |
|
217 | 217 | $where = array($where); |
218 | 218 | } |
219 | - if ($sanitarInIDs != "''") { |
|
219 | + if ($sanitarInIDs != "''") { |
|
220 | 220 | $where[] = "{$this->getPK()} IN ({$sanitarInIDs})"; |
221 | 221 | } |
222 | 222 | |
223 | - if (!empty($where)) { |
|
223 | + if (!empty($where)) { |
|
224 | 224 | $where = "WHERE " . implode(" AND ", $where); |
225 | 225 | } |
226 | 226 | $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0)); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $rs = $this->dbQuery("SELECT {$fields} FROM {$this->table} {$where} {$group} {$this->SortOrderSQL($this->getPK())} {$limit}"); |
230 | 230 | |
231 | 231 | $pk = $this->getPK(false); |
232 | - while ($item = $this->modx->db->getRow($rs)) { |
|
232 | + while ($item = $this->modx->db->getRow($rs)) { |
|
233 | 233 | $out[$item[$pk]] = $item; |
234 | 234 | } |
235 | 235 | } |
@@ -240,22 +240,22 @@ discard block |
||
240 | 240 | /** |
241 | 241 | * @return array |
242 | 242 | */ |
243 | - protected function getChildrenList() |
|
244 | - { |
|
243 | + protected function getChildrenList() |
|
244 | + { |
|
245 | 245 | $where = array(); |
246 | 246 | $out = array(); |
247 | 247 | |
248 | 248 | $tmpWhere = $this->getCFGDef('addWhereList', ''); |
249 | 249 | $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere); |
250 | - if (!empty($tmpWhere)) { |
|
250 | + if (!empty($tmpWhere)) { |
|
251 | 251 | $where[] = $tmpWhere; |
252 | 252 | } |
253 | 253 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
254 | 254 | |
255 | 255 | $tmpWhere = null; |
256 | - if ($sanitarInIDs != "''") { |
|
256 | + if ($sanitarInIDs != "''") { |
|
257 | 257 | $tmpWhere = "({$this->getParentField()} IN (" . $sanitarInIDs . ")"; |
258 | - switch ($this->getCFGDef('showParent', '0')) { |
|
258 | + switch ($this->getCFGDef('showParent', '0')) { |
|
259 | 259 | case -1: |
260 | 260 | $tmpWhere .= ")"; |
261 | 261 | break; |
@@ -268,25 +268,25 @@ discard block |
||
268 | 268 | break; |
269 | 269 | } |
270 | 270 | } |
271 | - if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
271 | + if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
272 | 272 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs)); |
273 | - if (empty($tmpWhere)) { |
|
273 | + if (empty($tmpWhere)) { |
|
274 | 274 | $tmpWhere = $this->getPK() . " IN({$addDocs})"; |
275 | - } else { |
|
275 | + } else { |
|
276 | 276 | $tmpWhere = "((" . $tmpWhere . ") OR {$this->getPK()} IN({$addDocs}))"; |
277 | 277 | } |
278 | 278 | } |
279 | - if (!empty($tmpWhere)) { |
|
279 | + if (!empty($tmpWhere)) { |
|
280 | 280 | $where[] = $tmpWhere; |
281 | 281 | } |
282 | - if (!empty($where)) { |
|
282 | + if (!empty($where)) { |
|
283 | 283 | $where = "WHERE " . implode(" AND ", $where); |
284 | - } else { |
|
284 | + } else { |
|
285 | 285 | $where = ''; |
286 | 286 | } |
287 | 287 | $fields = $this->getCFGDef('selectFields', '*'); |
288 | 288 | $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); |
289 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
289 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
290 | 290 | $rs = $this->dbQuery("SELECT {$fields} FROM " . $this->table . " " . $where . " " . |
291 | 291 | $group . " " . |
292 | 292 | $this->SortOrderSQL($this->getPK()) . " " . |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | |
296 | 296 | $pk = $this->getPK(false); |
297 | 297 | |
298 | - while ($item = $this->modx->db->getRow($rs)) { |
|
298 | + while ($item = $this->modx->db->getRow($rs)) { |
|
299 | 299 | $out[$item[$pk]] = $item; |
300 | 300 | } |
301 | 301 | |
@@ -307,22 +307,22 @@ discard block |
||
307 | 307 | /** |
308 | 308 | * @absctract |
309 | 309 | */ |
310 | - public function getChildrenCount() |
|
311 | - { |
|
310 | + public function getChildrenCount() |
|
311 | + { |
|
312 | 312 | $out = 0; |
313 | 313 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
314 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
314 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
315 | 315 | $where = $this->getCFGDef('addWhereList', ''); |
316 | - if ($where != '') { |
|
316 | + if ($where != '') { |
|
317 | 317 | $where = array($where); |
318 | - } else { |
|
318 | + } else { |
|
319 | 319 | $where = array(); |
320 | 320 | } |
321 | - if ($sanitarInIDs != "''") { |
|
322 | - if ($sanitarInIDs != "''") { |
|
323 | - switch ($this->getCFGDef('idType', 'parents')) { |
|
321 | + if ($sanitarInIDs != "''") { |
|
322 | + if ($sanitarInIDs != "''") { |
|
323 | + switch ($this->getCFGDef('idType', 'parents')) { |
|
324 | 324 | case 'parents': |
325 | - switch ($this->getCFGDef('showParent', '0')) { |
|
325 | + switch ($this->getCFGDef('showParent', '0')) { |
|
326 | 326 | case '-1': |
327 | 327 | $tmpWhere = "{$this->getParentField()} IN ({$sanitarInIDs})"; |
328 | 328 | break; |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | $tmpWhere = "({$this->getParentField()} IN ({$sanitarInIDs}) OR {$this->getPK()} IN({$sanitarInIDs}))"; |
335 | 335 | break; |
336 | 336 | } |
337 | - if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
337 | + if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
338 | 338 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs)); |
339 | 339 | $where[] = "((" . $tmpWhere . ") OR {$this->getPK()} IN({$addDocs}))"; |
340 | - } else { |
|
340 | + } else { |
|
341 | 341 | $where[] = $tmpWhere; |
342 | 342 | } |
343 | 343 | break; |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | } |
348 | 348 | } |
349 | 349 | } |
350 | - if (!empty($where)) { |
|
350 | + if (!empty($where)) { |
|
351 | 351 | $where = "WHERE " . implode(" AND ", $where); |
352 | - } else { |
|
352 | + } else { |
|
353 | 353 | $where = ''; |
354 | 354 | } |
355 | 355 | |
@@ -367,20 +367,20 @@ discard block |
||
367 | 367 | * @param string $id |
368 | 368 | * @return array |
369 | 369 | */ |
370 | - public function getChildrenFolder($id) |
|
371 | - { |
|
370 | + public function getChildrenFolder($id) |
|
371 | + { |
|
372 | 372 | $out = array(); |
373 | 373 | $sanitarInIDs = $this->sanitarIn($id); |
374 | 374 | |
375 | 375 | $tmp = $this->getCFGDef('addWhereFolder', ''); |
376 | 376 | $where = "{$this->getParentField()} IN ({$sanitarInIDs})"; |
377 | - if (!empty($tmp)) { |
|
377 | + if (!empty($tmp)) { |
|
378 | 378 | $where .= " AND " . $tmp; |
379 | 379 | } |
380 | 380 | |
381 | 381 | $rs = $this->dbQuery("SELECT {$this->getPK()} FROM {$this->table} WHERE {$where}"); |
382 | 382 | $pk = $this->getPK(false); |
383 | - while ($item = $this->modx->db->getRow($rs)) { |
|
383 | + while ($item = $this->modx->db->getRow($rs)) { |
|
384 | 384 | $out[] = $item[$pk]; |
385 | 385 | } |
386 | 386 |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0)); |
227 | 227 | $fields = $this->getCFGDef('selectFields', '*'); |
228 | 228 | $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); |
229 | - $rs = $this->dbQuery("SELECT {$fields} FROM {$this->table} {$where} {$group} {$this->SortOrderSQL($this->getPK())} {$limit}"); |
|
229 | + $rs = $this->dbQuery("select {$fields} FROM {$this->table} {$where} {$group} {$this->SortOrderSQL($this->getPK())} {$limit}"); |
|
230 | 230 | |
231 | 231 | $pk = $this->getPK(false); |
232 | 232 | while ($item = $this->modx->db->getRow($rs)) { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | $fields = $this->getCFGDef('selectFields', '*'); |
288 | 288 | $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); |
289 | 289 | if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
290 | - $rs = $this->dbQuery("SELECT {$fields} FROM " . $this->table . " " . $where . " " . |
|
290 | + $rs = $this->dbQuery("select {$fields} FROM " . $this->table . " " . $where . " " . |
|
291 | 291 | $group . " " . |
292 | 292 | $this->SortOrderSQL($this->getPK()) . " " . |
293 | 293 | $this->LimitSQL($this->getCFGDef('queryLimit', 0)) |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | $where .= " AND " . $tmp; |
379 | 379 | } |
380 | 380 | |
381 | - $rs = $this->dbQuery("SELECT {$this->getPK()} FROM {$this->table} WHERE {$where}"); |
|
381 | + $rs = $this->dbQuery("select {$this->getPK()} FROM {$this->table} WHERE {$where}"); |
|
382 | 382 | $pk = $this->getPK(false); |
383 | 383 | while ($item = $this->modx->db->getRow($rs)) { |
384 | 384 | $out[] = $item[$pk]; |