@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Class DocLister |
19 | 19 | */ |
20 | -abstract class DocLister |
|
21 | -{ |
|
20 | +abstract class DocLister |
|
21 | +{ |
|
22 | 22 | /** |
23 | 23 | * Ключ в массиве $_REQUEST в котором находится алиас запрашиваемого документа |
24 | 24 | */ |
@@ -188,48 +188,48 @@ discard block |
||
188 | 188 | * @param int $startTime время запуска сниппета |
189 | 189 | * @throws Exception |
190 | 190 | */ |
191 | - public function __construct($modx, $cfg = array(), $startTime = null) |
|
192 | - { |
|
191 | + public function __construct($modx, $cfg = array(), $startTime = null) |
|
192 | + { |
|
193 | 193 | $this->setTimeStart($startTime); |
194 | 194 | |
195 | - if (extension_loaded('mbstring')) { |
|
195 | + if (extension_loaded('mbstring')) { |
|
196 | 196 | mb_internal_encoding("UTF-8"); |
197 | - } else { |
|
197 | + } else { |
|
198 | 198 | throw new Exception('Not found php extension mbstring'); |
199 | 199 | } |
200 | 200 | |
201 | - if ($modx instanceof DocumentParser) { |
|
201 | + if ($modx instanceof DocumentParser) { |
|
202 | 202 | $this->modx = $modx; |
203 | 203 | $this->setDebug(1); |
204 | 204 | |
205 | - if (!is_array($cfg) || empty($cfg)) { |
|
205 | + if (!is_array($cfg) || empty($cfg)) { |
|
206 | 206 | $cfg = $this->modx->Event->params; |
207 | 207 | } |
208 | - } else { |
|
208 | + } else { |
|
209 | 209 | throw new Exception('MODX var is not instaceof DocumentParser'); |
210 | 210 | } |
211 | 211 | |
212 | 212 | $this->FS = \Helpers\FS::getInstance(); |
213 | 213 | $this->config = new \Helpers\Config($cfg); |
214 | 214 | |
215 | - if (isset($cfg['config'])) { |
|
215 | + if (isset($cfg['config'])) { |
|
216 | 216 | $this->config->setPath(dirname(__DIR__))->loadConfig($cfg['config']); |
217 | 217 | } |
218 | 218 | |
219 | - if ($this->config->setConfig($cfg) === false) { |
|
219 | + if ($this->config->setConfig($cfg) === false) { |
|
220 | 220 | throw new Exception('no parameters to run DocLister'); |
221 | 221 | } |
222 | 222 | |
223 | 223 | $this->loadLang(array('core', 'json')); |
224 | 224 | $this->setDebug($this->getCFGDef('debug', 0)); |
225 | 225 | |
226 | - if ($this->checkDL()) { |
|
226 | + if ($this->checkDL()) { |
|
227 | 227 | $cfg = array(); |
228 | 228 | $idType = $this->getCFGDef('idType', ''); |
229 | - if (empty($idType) && $this->getCFGDef('documents', '') != '') { |
|
229 | + if (empty($idType) && $this->getCFGDef('documents', '') != '') { |
|
230 | 230 | $idType = 'documents'; |
231 | 231 | } |
232 | - switch ($idType) { |
|
232 | + switch ($idType) { |
|
233 | 233 | case 'documents': |
234 | 234 | $IDs = $this->getCFGDef('documents'); |
235 | 235 | $cfg['idType'] = "documents"; |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | case 'parents': |
238 | 238 | default: |
239 | 239 | $cfg['idType'] = "parents"; |
240 | - if (($IDs = $this->getCFGDef('parents', '')) === '') { |
|
240 | + if (($IDs = $this->getCFGDef('parents', '')) === '') { |
|
241 | 241 | $IDs = $this->getCurrentMODXPageID(); |
242 | 242 | } |
243 | 243 | break; |
@@ -256,21 +256,21 @@ discard block |
||
256 | 256 | |
257 | 257 | $this->setLocate(); |
258 | 258 | |
259 | - if ($this->getCFGDef("customLang")) { |
|
259 | + if ($this->getCFGDef("customLang")) { |
|
260 | 260 | $this->getCustomLang(); |
261 | 261 | } |
262 | 262 | $this->loadExtender($this->getCFGDef("extender", "")); |
263 | 263 | |
264 | - if ($this->checkExtender('request')) { |
|
264 | + if ($this->checkExtender('request')) { |
|
265 | 265 | $this->extender['request']->init($this, $this->getCFGDef("requestActive", "")); |
266 | 266 | } |
267 | 267 | $this->_filters = $this->getFilters($this->getCFGDef('filters', '')); |
268 | 268 | $this->ownerTPL = $this->getCFGDef("ownerTPL", ""); |
269 | 269 | $DLTemplate = DLTemplate::getInstance($modx); |
270 | - if ($path = $this->getCFGDef('templatePath')) { |
|
270 | + if ($path = $this->getCFGDef('templatePath')) { |
|
271 | 271 | $DLTemplate->setTemplatePath($path); |
272 | 272 | } |
273 | - if ($ext = $this->getCFGDef('templateExtension')) { |
|
273 | + if ($ext = $this->getCFGDef('templateExtension')) { |
|
274 | 274 | $DLTemplate->setTemplateExtension($ext); |
275 | 275 | } |
276 | 276 | $DLTemplate->setTwigTemplateVars(array('DocLister' => $this)); |
@@ -282,25 +282,25 @@ discard block |
||
282 | 282 | * @param string $str строка с фильтром |
283 | 283 | * @return array массив субфильтров |
284 | 284 | */ |
285 | - public function smartSplit($str) |
|
286 | - { |
|
285 | + public function smartSplit($str) |
|
286 | + { |
|
287 | 287 | $res = array(); |
288 | 288 | $cur = ''; |
289 | 289 | $open = 0; |
290 | 290 | $strlen = mb_strlen($str, 'UTF-8'); |
291 | - for ($i = 0; $i <= $strlen; $i++) { |
|
291 | + for ($i = 0; $i <= $strlen; $i++) { |
|
292 | 292 | $e = mb_substr($str, $i, 1, 'UTF-8'); |
293 | - switch ($e) { |
|
293 | + switch ($e) { |
|
294 | 294 | case '\\': |
295 | 295 | $cur .= $e; |
296 | 296 | $cur .= mb_substr($str, ++$i, 1, 'UTF-8'); |
297 | 297 | break; |
298 | 298 | case ')': |
299 | 299 | $open--; |
300 | - if ($open == 0) { |
|
300 | + if ($open == 0) { |
|
301 | 301 | $res[] = $cur . ')'; |
302 | 302 | $cur = ''; |
303 | - } else { |
|
303 | + } else { |
|
304 | 304 | $cur .= $e; |
305 | 305 | } |
306 | 306 | break; |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | $cur .= $e; |
310 | 310 | break; |
311 | 311 | case ';': |
312 | - if ($open == 0) { |
|
312 | + if ($open == 0) { |
|
313 | 313 | $res[] = $cur; |
314 | 314 | $cur = ''; |
315 | - } else { |
|
315 | + } else { |
|
316 | 316 | $cur .= $e; |
317 | 317 | } |
318 | 318 | break; |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | } |
322 | 322 | } |
323 | 323 | $cur = preg_replace("/(\))$/u", '', $cur); |
324 | - if ($cur != '') { |
|
324 | + if ($cur != '') { |
|
325 | 325 | $res[] = $cur; |
326 | 326 | } |
327 | 327 | |
@@ -332,8 +332,8 @@ discard block |
||
332 | 332 | * Трансформация объекта в строку |
333 | 333 | * @return string последний ответ от DocLister'а |
334 | 334 | */ |
335 | - public function __toString() |
|
336 | - { |
|
335 | + public function __toString() |
|
336 | + { |
|
337 | 337 | return $this->outData; |
338 | 338 | } |
339 | 339 | |
@@ -341,8 +341,8 @@ discard block |
||
341 | 341 | * Установить время запуска сниппета |
342 | 342 | * @param float|null $time |
343 | 343 | */ |
344 | - public function setTimeStart($time = null) |
|
345 | - { |
|
344 | + public function setTimeStart($time = null) |
|
345 | + { |
|
346 | 346 | $this->_timeStart = is_null($time) ? microtime(true) : $time; |
347 | 347 | } |
348 | 348 | |
@@ -351,8 +351,8 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @return int |
353 | 353 | */ |
354 | - public function getTimeStart() |
|
355 | - { |
|
354 | + public function getTimeStart() |
|
355 | + { |
|
356 | 356 | return $this->_timeStart; |
357 | 357 | } |
358 | 358 | |
@@ -360,27 +360,27 @@ discard block |
||
360 | 360 | * Установка режима отладки |
361 | 361 | * @param int $flag режим отладки |
362 | 362 | */ |
363 | - public function setDebug($flag = 0) |
|
364 | - { |
|
363 | + public function setDebug($flag = 0) |
|
364 | + { |
|
365 | 365 | $flag = abs((int)$flag); |
366 | - if ($this->_debugMode != $flag) { |
|
366 | + if ($this->_debugMode != $flag) { |
|
367 | 367 | $this->_debugMode = $flag; |
368 | 368 | $this->debug = null; |
369 | - if ($this->_debugMode > 0) { |
|
370 | - if (isset($_SESSION['usertype']) && $_SESSION['usertype'] == 'manager') { |
|
369 | + if ($this->_debugMode > 0) { |
|
370 | + if (isset($_SESSION['usertype']) && $_SESSION['usertype'] == 'manager') { |
|
371 | 371 | error_reporting(E_ALL ^ E_NOTICE); |
372 | 372 | ini_set('display_errors', 1); |
373 | 373 | } |
374 | 374 | $dir = dirname(dirname(__FILE__)); |
375 | - if (file_exists($dir . "/lib/DLdebug.class.php")) { |
|
375 | + if (file_exists($dir . "/lib/DLdebug.class.php")) { |
|
376 | 376 | include_once($dir . "/lib/DLdebug.class.php"); |
377 | - if (class_exists("DLdebug", false)) { |
|
377 | + if (class_exists("DLdebug", false)) { |
|
378 | 378 | $this->debug = new DLdebug($this); |
379 | 379 | } |
380 | 380 | } |
381 | 381 | } |
382 | 382 | |
383 | - if (is_null($this->debug)) { |
|
383 | + if (is_null($this->debug)) { |
|
384 | 384 | $this->debug = new xNop(); |
385 | 385 | $this->_debugMode = 0; |
386 | 386 | error_reporting(0); |
@@ -392,8 +392,8 @@ discard block |
||
392 | 392 | /** |
393 | 393 | * Информация о режиме отладки |
394 | 394 | */ |
395 | - public function getDebug() |
|
396 | - { |
|
395 | + public function getDebug() |
|
396 | + { |
|
397 | 397 | return $this->_debugMode; |
398 | 398 | } |
399 | 399 | |
@@ -404,13 +404,13 @@ discard block |
||
404 | 404 | * @param string $alias желаемый алиас таблицы |
405 | 405 | * @return string имя таблицы с префиксом и алиасом |
406 | 406 | */ |
407 | - public function getTable($name, $alias = '') |
|
408 | - { |
|
409 | - if (!isset($this->_table[$name])) { |
|
407 | + public function getTable($name, $alias = '') |
|
408 | + { |
|
409 | + if (!isset($this->_table[$name])) { |
|
410 | 410 | $this->_table[$name] = $this->modx->getFullTableName($name); |
411 | 411 | } |
412 | 412 | $table = $this->_table[$name]; |
413 | - if (!empty($alias) && is_scalar($alias)) { |
|
413 | + if (!empty($alias) && is_scalar($alias)) { |
|
414 | 414 | $table .= " as `" . $alias . "`"; |
415 | 415 | } |
416 | 416 | |
@@ -423,9 +423,9 @@ discard block |
||
423 | 423 | * @param $alias |
424 | 424 | * @return mixed |
425 | 425 | */ |
426 | - public function TableAlias($name, $table, $alias) |
|
427 | - { |
|
428 | - if (!$this->checkTableAlias($name, $table)) { |
|
426 | + public function TableAlias($name, $table, $alias) |
|
427 | + { |
|
428 | + if (!$this->checkTableAlias($name, $table)) { |
|
429 | 429 | $this->AddTable[$table][$name] = $alias; |
430 | 430 | } |
431 | 431 | |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | * @param $table |
438 | 438 | * @return bool |
439 | 439 | */ |
440 | - public function checkTableAlias($name, $table) |
|
441 | - { |
|
440 | + public function checkTableAlias($name, $table) |
|
441 | + { |
|
442 | 442 | return isset($this->AddTable[$table][$name]); |
443 | 443 | } |
444 | 444 | |
@@ -450,8 +450,8 @@ discard block |
||
450 | 450 | * @param bool $nop создавать ли пустой объект запрашиваемого типа |
451 | 451 | * @return array|mixed|xNop |
452 | 452 | */ |
453 | - public function jsonDecode($json, $config = array(), $nop = false) |
|
454 | - { |
|
453 | + public function jsonDecode($json, $config = array(), $nop = false) |
|
454 | + { |
|
455 | 455 | $this->debug->debug('Decode JSON: ' . $this->debug->dumpData($json) . "\r\nwith config: " . $this->debug->dumpData($config), |
456 | 456 | 'jsonDecode', 2); |
457 | 457 | $config = jsonHelper::jsonDecode($json, $config, $nop); |
@@ -467,10 +467,10 @@ discard block |
||
467 | 467 | * @param $json string строка с JSON для записи в лог при отладке |
468 | 468 | * @return bool|string |
469 | 469 | */ |
470 | - public function isErrorJSON($json) |
|
471 | - { |
|
470 | + public function isErrorJSON($json) |
|
471 | + { |
|
472 | 472 | $error = jsonHelper::json_last_error_msg(); |
473 | - if (!in_array($error, array('error_none', 'other'))) { |
|
473 | + if (!in_array($error, array('error_none', 'other'))) { |
|
474 | 474 | $this->debug->error($this->getMsg('json.' . $error) . ": " . $this->debug->dumpData($json, 'code'), 'JSON'); |
475 | 475 | $error = true; |
476 | 476 | } |
@@ -482,20 +482,20 @@ discard block |
||
482 | 482 | * Проверка параметров и загрузка необходимых экстендеров |
483 | 483 | * return boolean статус загрузки |
484 | 484 | */ |
485 | - public function checkDL() |
|
486 | - { |
|
485 | + public function checkDL() |
|
486 | + { |
|
487 | 487 | $this->debug->debug('Check DocLister parameters', 'checkDL', 2); |
488 | 488 | $flag = true; |
489 | 489 | $extenders = $this->getCFGDef('extender', ''); |
490 | 490 | $extenders = explode(",", $extenders); |
491 | 491 | $tmp = $this->getCFGDef('requestActive', '') != '' || in_array('request', $extenders); |
492 | - if ($tmp && !$this->_loadExtender('request')) { |
|
492 | + if ($tmp && !$this->_loadExtender('request')) { |
|
493 | 493 | //OR request in extender's parameter |
494 | 494 | throw new Exception('Error load request extender'); |
495 | 495 | } |
496 | 496 | |
497 | 497 | $tmp = $this->getCFGDef('summary', '') != '' || in_array('summary', $extenders); |
498 | - if ($tmp && !$this->_loadExtender('summary')) { |
|
498 | + if ($tmp && !$this->_loadExtender('summary')) { |
|
499 | 499 | //OR summary in extender's parameter |
500 | 500 | throw new Exception('Error load summary extender'); |
501 | 501 | } |
@@ -508,15 +508,15 @@ discard block |
||
508 | 508 | $this->getCFGDef('pageLimit', '') != '' || $this->getCFGDef('pageAdjacents', '') != '' || |
509 | 509 | $this->getCFGDef('PaginateClass', '') != '' || $this->getCFGDef('TplNextP', '') != '' |
510 | 510 | ) && !$this->_loadExtender('paginate') |
511 | - ) { |
|
511 | + ) { |
|
512 | 512 | throw new Exception('Error load paginate extender'); |
513 | - } else { |
|
514 | - if ((int)$this->getCFGDef('display', 0) == 0) { |
|
513 | + } else { |
|
514 | + if ((int)$this->getCFGDef('display', 0) == 0) { |
|
515 | 515 | $extenders = $this->unsetArrayVal($extenders, 'paginate'); |
516 | 516 | } |
517 | 517 | } |
518 | 518 | |
519 | - if ($this->getCFGDef('prepare', '') != '' || $this->getCFGDef('prepareWrap') != '') { |
|
519 | + if ($this->getCFGDef('prepare', '') != '' || $this->getCFGDef('prepareWrap') != '') { |
|
520 | 520 | $this->_loadExtender('prepare'); |
521 | 521 | } |
522 | 522 | |
@@ -533,14 +533,14 @@ discard block |
||
533 | 533 | * @param mixed $val значение которые необходимо удалить из массива |
534 | 534 | * @return array отчищеный массив с данными |
535 | 535 | */ |
536 | - private function unsetArrayVal($data, $val) |
|
537 | - { |
|
536 | + private function unsetArrayVal($data, $val) |
|
537 | + { |
|
538 | 538 | $out = array(); |
539 | - if (is_array($data)) { |
|
540 | - foreach ($data as $item) { |
|
541 | - if ($item != $val) { |
|
539 | + if (is_array($data)) { |
|
540 | + foreach ($data as $item) { |
|
541 | + if ($item != $val) { |
|
542 | 542 | $out[] = $item; |
543 | - } else { |
|
543 | + } else { |
|
544 | 544 | continue; |
545 | 545 | } |
546 | 546 | } |
@@ -555,14 +555,14 @@ discard block |
||
555 | 555 | * @param int $id уникальный идентификатор страницы |
556 | 556 | * @return string URL страницы |
557 | 557 | */ |
558 | - public function getUrl($id = 0) |
|
559 | - { |
|
558 | + public function getUrl($id = 0) |
|
559 | + { |
|
560 | 560 | $id = ((int)$id > 0) ? (int)$id : $this->getCurrentMODXPageID(); |
561 | 561 | |
562 | 562 | $link = $this->checkExtender('request') ? $this->extender['request']->getLink() : $this->getRequest(); |
563 | - if ($id == $this->modx->config['site_start']) { |
|
563 | + if ($id == $this->modx->config['site_start']) { |
|
564 | 564 | $url = $this->modx->config['site_url'] . ($link != '' ? "?{$link}" : ""); |
565 | - } else { |
|
565 | + } else { |
|
566 | 566 | $url = $this->modx->makeUrl($id, '', $link, $this->getCFGDef('urlScheme', '')); |
567 | 567 | } |
568 | 568 | |
@@ -590,20 +590,20 @@ discard block |
||
590 | 590 | * @param string $tpl шаблон |
591 | 591 | * @return string |
592 | 592 | */ |
593 | - public function render($tpl = '') |
|
594 | - { |
|
593 | + public function render($tpl = '') |
|
594 | + { |
|
595 | 595 | $this->debug->debug(array('Render data with template ' => $tpl), 'render', 2, array('html')); |
596 | 596 | $out = ''; |
597 | - if (1 == $this->getCFGDef('tree', '0')) { |
|
598 | - foreach ($this->_tree as $item) { |
|
597 | + if (1 == $this->getCFGDef('tree', '0')) { |
|
598 | + foreach ($this->_tree as $item) { |
|
599 | 599 | $out .= $this->renderTree($item); |
600 | 600 | } |
601 | 601 | $out = $this->renderWrap($out); |
602 | - } else { |
|
602 | + } else { |
|
603 | 603 | $out = $this->_render($tpl); |
604 | 604 | } |
605 | 605 | |
606 | - if ($out) { |
|
606 | + if ($out) { |
|
607 | 607 | $this->outData = DLTemplate::getInstance($this->modx)->parseDocumentSource($out); |
608 | 608 | } |
609 | 609 | $this->debug->debugEnd('render'); |
@@ -620,8 +620,8 @@ discard block |
||
620 | 620 | * |
621 | 621 | * @return int |
622 | 622 | */ |
623 | - public function getCurrentMODXPageID() |
|
624 | - { |
|
623 | + public function getCurrentMODXPageID() |
|
624 | + { |
|
625 | 625 | $id = isset($this->modx->documentIdentifier) ? (int)$this->modx->documentIdentifier : 0; |
626 | 626 | $docData = isset($this->modx->documentObject) ? $this->modx->documentObject : array(); |
627 | 627 | |
@@ -637,9 +637,9 @@ discard block |
||
637 | 637 | * @param integer $line error on line |
638 | 638 | * @param array $trace stack trace |
639 | 639 | */ |
640 | - public function ErrorLogger($message, $code, $file, $line, $trace) |
|
641 | - { |
|
642 | - if (abs($this->getCFGDef('debug', '0')) == '1') { |
|
640 | + public function ErrorLogger($message, $code, $file, $line, $trace) |
|
641 | + { |
|
642 | + if (abs($this->getCFGDef('debug', '0')) == '1') { |
|
643 | 643 | $out = "CODE #" . $code . "<br />"; |
644 | 644 | $out .= "on file: " . $file . ":" . $line . "<br />"; |
645 | 645 | $out .= "<pre>"; |
@@ -656,8 +656,8 @@ discard block |
||
656 | 656 | * |
657 | 657 | * @return DocumentParser |
658 | 658 | */ |
659 | - public function getMODX() |
|
660 | - { |
|
659 | + public function getMODX() |
|
660 | + { |
|
661 | 661 | return $this->modx; |
662 | 662 | } |
663 | 663 | |
@@ -668,13 +668,13 @@ discard block |
||
668 | 668 | * @return boolean status load extenders |
669 | 669 | * @throws Exception |
670 | 670 | */ |
671 | - public function loadExtender($ext = '') |
|
672 | - { |
|
671 | + public function loadExtender($ext = '') |
|
672 | + { |
|
673 | 673 | $out = true; |
674 | - if ($ext != '') { |
|
674 | + if ($ext != '') { |
|
675 | 675 | $ext = explode(",", $ext); |
676 | - foreach ($ext as $item) { |
|
677 | - if ($item != '' && !$this->_loadExtender($item)) { |
|
676 | + foreach ($ext as $item) { |
|
677 | + if ($item != '' && !$this->_loadExtender($item)) { |
|
678 | 678 | throw new Exception('Error load ' . APIHelpers::e($item) . ' extender'); |
679 | 679 | } |
680 | 680 | } |
@@ -690,8 +690,8 @@ discard block |
||
690 | 690 | * @param mixed $def значение по умолчанию, если в конфиге нет искомого параметра |
691 | 691 | * @return mixed значение из конфига |
692 | 692 | */ |
693 | - public function getCFGDef($name, $def = null) |
|
694 | - { |
|
693 | + public function getCFGDef($name, $def = null) |
|
694 | + { |
|
695 | 695 | return $this->config->getCFGDef($name, $def); |
696 | 696 | } |
697 | 697 | |
@@ -703,15 +703,15 @@ discard block |
||
703 | 703 | * @param string $key ключ локального плейсхолдера |
704 | 704 | * @return string |
705 | 705 | */ |
706 | - public function toPlaceholders($data, $set = 0, $key = 'contentPlaceholder') |
|
707 | - { |
|
706 | + public function toPlaceholders($data, $set = 0, $key = 'contentPlaceholder') |
|
707 | + { |
|
708 | 708 | $this->debug->debug(null, 'toPlaceholders', 2); |
709 | - if ($set == 0) { |
|
709 | + if ($set == 0) { |
|
710 | 710 | $set = $this->getCFGDef('contentPlaceholder', 0); |
711 | 711 | } |
712 | 712 | $this->_plh[$key] = $data; |
713 | 713 | $id = $this->getCFGDef('id', ''); |
714 | - if ($id != '') { |
|
714 | + if ($id != '') { |
|
715 | 715 | $id .= "."; |
716 | 716 | } |
717 | 717 | $out = DLTemplate::getInstance($this->getMODX())->toPlaceholders($data, $set, $key, $id); |
@@ -733,14 +733,19 @@ discard block |
||
733 | 733 | * @param boolean $quote заключать ли данные на выходе в кавычки |
734 | 734 | * @return string обработанная строка |
735 | 735 | */ |
736 | - public function sanitarIn($data, $sep = ',', $quote = true) |
|
737 | - { |
|
738 | - if(is_scalar($data)) $data = explode($sep, $data); |
|
739 | - if(!is_array($data)) $data = array(); //@TODO: throw |
|
736 | + public function sanitarIn($data, $sep = ',', $quote = true) |
|
737 | + { |
|
738 | + if(is_scalar($data)) { |
|
739 | + $data = explode($sep, $data); |
|
740 | + } |
|
741 | + if(!is_array($data)) { |
|
742 | + $data = array(); |
|
743 | + } |
|
744 | + //@TODO: throw |
|
740 | 745 | |
741 | 746 | $out = array(); |
742 | - foreach ($data as $item) { |
|
743 | - if ($item !== '') { |
|
747 | + foreach ($data as $item) { |
|
748 | + if ($item !== '') { |
|
744 | 749 | $out[] = $this->modx->db->escape($item); |
745 | 750 | } |
746 | 751 | } |
@@ -761,12 +766,12 @@ discard block |
||
761 | 766 | * @param string $lang имя языкового пакета |
762 | 767 | * @return array |
763 | 768 | */ |
764 | - public function getCustomLang($lang = '') |
|
765 | - { |
|
766 | - if (empty($lang)) { |
|
769 | + public function getCustomLang($lang = '') |
|
770 | + { |
|
771 | + if (empty($lang)) { |
|
767 | 772 | $lang = $this->getCFGDef('lang', $this->modx->config['manager_language']); |
768 | 773 | } |
769 | - if (file_exists(dirname(dirname(__FILE__)) . "/lang/" . $lang . ".php")) { |
|
774 | + if (file_exists(dirname(dirname(__FILE__)) . "/lang/" . $lang . ".php")) { |
|
770 | 775 | $tmp = include(dirname(__FILE__) . "/lang/" . $lang . ".php"); |
771 | 776 | $this->_customLang = is_array($tmp) ? $tmp : array(); |
772 | 777 | } |
@@ -782,25 +787,25 @@ discard block |
||
782 | 787 | * @param boolean $rename Переименовывать ли элементы массива |
783 | 788 | * @return array массив с лексиконом |
784 | 789 | */ |
785 | - public function loadLang($name = 'core', $lang = '', $rename = true) |
|
786 | - { |
|
787 | - if (empty($lang)) { |
|
790 | + public function loadLang($name = 'core', $lang = '', $rename = true) |
|
791 | + { |
|
792 | + if (empty($lang)) { |
|
788 | 793 | $lang = $this->getCFGDef('lang', $this->modx->config['manager_language']); |
789 | 794 | } |
790 | 795 | |
791 | 796 | $this->debug->debug('Load language ' . $this->debug->dumpData($name) . "." . $this->debug->dumpData($lang), |
792 | 797 | 'loadlang', 2); |
793 | - if (is_scalar($name)) { |
|
798 | + if (is_scalar($name)) { |
|
794 | 799 | $name = array($name); |
795 | 800 | } |
796 | - foreach ($name as $n) { |
|
797 | - if (file_exists(dirname(__FILE__) . "/lang/" . $lang . "/" . $n . ".inc.php")) { |
|
801 | + foreach ($name as $n) { |
|
802 | + if (file_exists(dirname(__FILE__) . "/lang/" . $lang . "/" . $n . ".inc.php")) { |
|
798 | 803 | $tmp = include(dirname(__FILE__) . "/lang/" . $lang . "/" . $n . ".inc.php"); |
799 | - if (is_array($tmp)) { |
|
804 | + if (is_array($tmp)) { |
|
800 | 805 | /** |
801 | 806 | * Переименовыываем элементы массива из array('test'=>'data') в array('name.test'=>'data') |
802 | 807 | */ |
803 | - if ($rename) { |
|
808 | + if ($rename) { |
|
804 | 809 | $tmp = $this->renameKeyArr($tmp, $n, '', '.'); |
805 | 810 | } |
806 | 811 | $this->_lang = array_merge($this->_lang, $tmp); |
@@ -819,11 +824,11 @@ discard block |
||
819 | 824 | * @param string $def Строка по умолчанию, если запись в языковом пакете не будет обнаружена |
820 | 825 | * @return string строка в соответствии с текущими языковыми настройками |
821 | 826 | */ |
822 | - public function getMsg($name, $def = '') |
|
823 | - { |
|
824 | - if (isset($this->_customLang[$name])) { |
|
827 | + public function getMsg($name, $def = '') |
|
828 | + { |
|
829 | + if (isset($this->_customLang[$name])) { |
|
825 | 830 | $say = $this->_customLang[$name]; |
826 | - } else { |
|
831 | + } else { |
|
827 | 832 | $say = \APIHelpers::getkey($this->_lang, $name, $def); |
828 | 833 | } |
829 | 834 | |
@@ -839,8 +844,8 @@ discard block |
||
839 | 844 | * @param string $sep разделитель суффиксов, префиксов и ключей массива |
840 | 845 | * @return array массив с переименованными ключами |
841 | 846 | */ |
842 | - public function renameKeyArr($data, $prefix = '', $suffix = '', $sep = '.') |
|
843 | - { |
|
847 | + public function renameKeyArr($data, $prefix = '', $suffix = '', $sep = '.') |
|
848 | + { |
|
844 | 849 | return \APIHelpers::renameKeyArr($data, $prefix, $suffix, $sep); |
845 | 850 | } |
846 | 851 | |
@@ -850,12 +855,12 @@ discard block |
||
850 | 855 | * @param string $locale локаль |
851 | 856 | * @return string имя установленной локали |
852 | 857 | */ |
853 | - public function setLocate($locale = '') |
|
854 | - { |
|
855 | - if ('' == $locale) { |
|
858 | + public function setLocate($locale = '') |
|
859 | + { |
|
860 | + if ('' == $locale) { |
|
856 | 861 | $locale = $this->getCFGDef('locale', ''); |
857 | 862 | } |
858 | - if ('' != $locale) { |
|
863 | + if ('' != $locale) { |
|
859 | 864 | setlocale(LC_ALL, $locale); |
860 | 865 | } |
861 | 866 | |
@@ -869,11 +874,11 @@ discard block |
||
869 | 874 | * @param array $data массив сформированный как дерево |
870 | 875 | * @return string строка для отображения пользователю |
871 | 876 | */ |
872 | - protected function renderTree($data) |
|
873 | - { |
|
877 | + protected function renderTree($data) |
|
878 | + { |
|
874 | 879 | $out = ''; |
875 | - if (!empty($data['#childNodes'])) { |
|
876 | - foreach ($data['#childNodes'] as $item) { |
|
880 | + if (!empty($data['#childNodes'])) { |
|
881 | + foreach ($data['#childNodes'] as $item) { |
|
877 | 882 | $out .= $this->renderTree($item); |
878 | 883 | } |
879 | 884 | } |
@@ -890,8 +895,8 @@ discard block |
||
890 | 895 | * @param string $name Template: chunk name || @CODE: template || @FILE: file with template |
891 | 896 | * @return string html template with placeholders without data |
892 | 897 | */ |
893 | - private function _getChunk($name) |
|
894 | - { |
|
898 | + private function _getChunk($name) |
|
899 | + { |
|
895 | 900 | $this->debug->debug(array('Get chunk by name' => $name), "getChunk", 2, array('html')); |
896 | 901 | //without trim |
897 | 902 | $tpl = DLTemplate::getInstance($this->getMODX())->getChunk($name); |
@@ -908,18 +913,18 @@ discard block |
||
908 | 913 | * @param string $tpl HTML шаблон |
909 | 914 | * @return string |
910 | 915 | */ |
911 | - public function parseLang($tpl) |
|
912 | - { |
|
916 | + public function parseLang($tpl) |
|
917 | + { |
|
913 | 918 | $this->debug->debug(array("parseLang" => $tpl), "parseLang", 2, array('html')); |
914 | - if (is_scalar($tpl) && !empty($tpl)) { |
|
915 | - if (preg_match_all("/\[\%([a-zA-Z0-9\.\_\-]+)\%\]/", $tpl, $match)) { |
|
919 | + if (is_scalar($tpl) && !empty($tpl)) { |
|
920 | + if (preg_match_all("/\[\%([a-zA-Z0-9\.\_\-]+)\%\]/", $tpl, $match)) { |
|
916 | 921 | $langVal = array(); |
917 | - foreach ($match[1] as $item) { |
|
922 | + foreach ($match[1] as $item) { |
|
918 | 923 | $langVal[] = $this->getMsg($item); |
919 | 924 | } |
920 | 925 | $tpl = str_replace($match[0], $langVal, $tpl); |
921 | 926 | } |
922 | - } else { |
|
927 | + } else { |
|
923 | 928 | $tpl = ''; |
924 | 929 | } |
925 | 930 | $this->debug->debugEnd("parseLang"); |
@@ -935,8 +940,8 @@ discard block |
||
935 | 940 | * @param bool $parseDocumentSource render html template via DocumentParser::parseDocumentSource() |
936 | 941 | * @return string html template with data without placeholders |
937 | 942 | */ |
938 | - public function parseChunk($name, $data = array(), $parseDocumentSource = false) |
|
939 | - { |
|
943 | + public function parseChunk($name, $data = array(), $parseDocumentSource = false) |
|
944 | + { |
|
940 | 945 | $this->debug->debug( |
941 | 946 | array("parseChunk" => $name, "With data" => print_r($data, 1)), |
942 | 947 | "parseChunk", |
@@ -945,7 +950,7 @@ discard block |
||
945 | 950 | |
946 | 951 | $out = $this->DLTemplate->parseChunk($name, $data, $parseDocumentSource); |
947 | 952 | $out = $this->parseLang($out); |
948 | - if (empty($out)) { |
|
953 | + if (empty($out)) { |
|
949 | 954 | $this->debug->debug("Empty chunk: " . $this->debug->dumpData($name), '', 2); |
950 | 955 | } |
951 | 956 | $this->debug->debugEnd("parseChunk"); |
@@ -961,8 +966,8 @@ discard block |
||
961 | 966 | * |
962 | 967 | * @return string html template from parameter |
963 | 968 | */ |
964 | - public function getChunkByParam($name, $val = '') |
|
965 | - { |
|
969 | + public function getChunkByParam($name, $val = '') |
|
970 | + { |
|
966 | 971 | $data = $this->getCFGDef($name, $val); |
967 | 972 | $data = $this->_getChunk($data); |
968 | 973 | |
@@ -975,11 +980,11 @@ discard block |
||
975 | 980 | * @param string $data html код который нужно обернуть в ownerTPL |
976 | 981 | * @return string результатирующий html код |
977 | 982 | */ |
978 | - public function renderWrap($data) |
|
979 | - { |
|
983 | + public function renderWrap($data) |
|
984 | + { |
|
980 | 985 | $out = $data; |
981 | 986 | $docs = count($this->_docs) - $this->skippedDocs; |
982 | - if ((($this->getCFGDef("noneWrapOuter", "1") && $docs == 0) || $docs > 0) && !empty($this->ownerTPL)) { |
|
987 | + if ((($this->getCFGDef("noneWrapOuter", "1") && $docs == 0) || $docs > 0) && !empty($this->ownerTPL)) { |
|
983 | 988 | $this->debug->debug("", "renderWrapTPL", 2); |
984 | 989 | $parse = true; |
985 | 990 | $plh = array($this->getCFGDef("sysKey", "dl") . ".wrap" => $data); |
@@ -987,7 +992,7 @@ discard block |
||
987 | 992 | * @var $extPrepare prepare_DL_Extender |
988 | 993 | */ |
989 | 994 | $extPrepare = $this->getExtender('prepare'); |
990 | - if ($extPrepare) { |
|
995 | + if ($extPrepare) { |
|
991 | 996 | $params = $extPrepare->init($this, array( |
992 | 997 | 'data' => array( |
993 | 998 | 'docs' => $this->_docs, |
@@ -996,13 +1001,13 @@ discard block |
||
996 | 1001 | 'nameParam' => 'prepareWrap', |
997 | 1002 | 'return' => 'placeholders' |
998 | 1003 | )); |
999 | - if (is_bool($params) && $params === false) { |
|
1004 | + if (is_bool($params) && $params === false) { |
|
1000 | 1005 | $out = $data; |
1001 | 1006 | $parse = false; |
1002 | 1007 | } |
1003 | 1008 | $plh = $params; |
1004 | 1009 | } |
1005 | - if ($parse && !empty($this->ownerTPL)) { |
|
1010 | + if ($parse && !empty($this->ownerTPL)) { |
|
1006 | 1011 | $this->debug->updateMessage( |
1007 | 1012 | array("render ownerTPL" => $this->ownerTPL, "With data" => print_r($plh, 1)), |
1008 | 1013 | "renderWrapTPL", |
@@ -1010,7 +1015,7 @@ discard block |
||
1010 | 1015 | ); |
1011 | 1016 | $out = $this->parseChunk($this->ownerTPL, $plh); |
1012 | 1017 | } |
1013 | - if (empty($this->ownerTPL)) { |
|
1018 | + if (empty($this->ownerTPL)) { |
|
1014 | 1019 | $this->debug->updateMessage("empty ownerTPL", "renderWrapTPL"); |
1015 | 1020 | } |
1016 | 1021 | $this->debug->debugEnd("renderWrapTPL"); |
@@ -1026,8 +1031,8 @@ discard block |
||
1026 | 1031 | * @param int $i номер итерации в цикле |
1027 | 1032 | * @return array массив с данными которые можно использовать в цикле render метода |
1028 | 1033 | */ |
1029 | - protected function uniformPrepare(&$data, $i = 0) |
|
1030 | - { |
|
1034 | + protected function uniformPrepare(&$data, $i = 0) |
|
1035 | + { |
|
1031 | 1036 | $class = array(); |
1032 | 1037 | |
1033 | 1038 | $iterationName = ($i % 2 == 1) ? 'Odd' : 'Even'; |
@@ -1038,13 +1043,13 @@ discard block |
||
1038 | 1043 | $this->renderTPL = $this->getCFGDef('tpl' . $iterationName, $this->renderTPL); |
1039 | 1044 | $iteration = $i; |
1040 | 1045 | |
1041 | - if ($this->extPaginate) { |
|
1046 | + if ($this->extPaginate) { |
|
1042 | 1047 | $offset = $this->getCFGDef('reversePagination', |
1043 | 1048 | 0) && $this->extPaginate->currentPage() > 1 ? $this->extPaginate->totalPage() * $this->getCFGDef('display', |
1044 | 1049 | 0) - $this->extPaginate->totalDocs() : 0; |
1045 | 1050 | if ($this->getCFGDef('maxDocs', 0) && !$this->getCFGDef('reversePagination', |
1046 | 1051 | 0) && $this->extPaginate->currentPage() == $this->extPaginate->totalPage() |
1047 | - ) { |
|
1052 | + ) { |
|
1048 | 1053 | $iteration += $this->getCFGDef('display', 0); |
1049 | 1054 | } |
1050 | 1055 | $iteration += $this->getCFGDef('display', |
@@ -1054,20 +1059,20 @@ discard block |
||
1054 | 1059 | $data[$this->getCFGDef("sysKey", |
1055 | 1060 | "dl") . '.full_iteration'] = $iteration; |
1056 | 1061 | |
1057 | - if ($i == 1) { |
|
1062 | + if ($i == 1) { |
|
1058 | 1063 | $this->renderTPL = $this->getCFGDef('tplFirst', $this->renderTPL); |
1059 | 1064 | $class[] = $this->getCFGDef('firstClass', 'first'); |
1060 | 1065 | } |
1061 | - if ($i == (count($this->_docs) - $this->skippedDocs)) { |
|
1066 | + if ($i == (count($this->_docs) - $this->skippedDocs)) { |
|
1062 | 1067 | $this->renderTPL = $this->getCFGDef('tplLast', $this->renderTPL); |
1063 | 1068 | $class[] = $this->getCFGDef('lastClass', 'last'); |
1064 | 1069 | } |
1065 | - if ($this->modx->documentIdentifier == $data['id']) { |
|
1070 | + if ($this->modx->documentIdentifier == $data['id']) { |
|
1066 | 1071 | $this->renderTPL = $this->getCFGDef('tplCurrent', $this->renderTPL); |
1067 | 1072 | $data[$this->getCFGDef("sysKey", |
1068 | 1073 | "dl") . '.active'] = 1; //[+active+] - 1 if $modx->documentIdentifer equal ID this element |
1069 | 1074 | $class[] = $this->getCFGDef('currentClass', 'current'); |
1070 | - } else { |
|
1075 | + } else { |
|
1071 | 1076 | $data[$this->getCFGDef("sysKey", "dl") . '.active'] = 0; |
1072 | 1077 | } |
1073 | 1078 | |
@@ -1078,8 +1083,8 @@ discard block |
||
1078 | 1083 | * @var $extE e_DL_Extender |
1079 | 1084 | */ |
1080 | 1085 | $extE = $this->getExtender('e', true, true); |
1081 | - if ($out = $extE->init($this, compact('data'))) { |
|
1082 | - if (is_array($out)) { |
|
1086 | + if ($out = $extE->init($this, compact('data'))) { |
|
1087 | + if (is_array($out)) { |
|
1083 | 1088 | $data = $out; |
1084 | 1089 | } |
1085 | 1090 | } |
@@ -1095,42 +1100,43 @@ discard block |
||
1095 | 1100 | * @param array $array данные которые необходимо примешать к ответу на каждой записи $data |
1096 | 1101 | * @return string JSON строка |
1097 | 1102 | */ |
1098 | - public function getJSON($data, $fields, $array = array()) |
|
1099 | - { |
|
1103 | + public function getJSON($data, $fields, $array = array()) |
|
1104 | + { |
|
1100 | 1105 | $out = array(); |
1101 | 1106 | $fields = is_array($fields) ? $fields : explode(",", $fields); |
1102 | - if (is_array($array) && count($array) > 0) { |
|
1107 | + if (is_array($array) && count($array) > 0) { |
|
1103 | 1108 | $tmp = array(); |
1104 | - foreach ($data as $i => $v) { //array_merge not valid work with integer index key |
|
1109 | + foreach ($data as $i => $v) { |
|
1110 | +//array_merge not valid work with integer index key |
|
1105 | 1111 | $tmp[$i] = (isset($array[$i]) ? array_merge($v, $array[$i]) : $v); |
1106 | 1112 | } |
1107 | 1113 | $data = $tmp; |
1108 | 1114 | } |
1109 | 1115 | |
1110 | - foreach ($data as $num => $doc) { |
|
1116 | + foreach ($data as $num => $doc) { |
|
1111 | 1117 | $tmp = array(); |
1112 | - foreach ($doc as $name => $value) { |
|
1113 | - if (in_array($name, $fields) || (isset($fields[0]) && $fields[0] == '1')) { |
|
1118 | + foreach ($doc as $name => $value) { |
|
1119 | + if (in_array($name, $fields) || (isset($fields[0]) && $fields[0] == '1')) { |
|
1114 | 1120 | $tmp[str_replace(".", "_", $name)] = $value; //JSON element name without dot |
1115 | 1121 | } |
1116 | 1122 | } |
1117 | 1123 | $out[$num] = $tmp; |
1118 | 1124 | } |
1119 | 1125 | |
1120 | - if ('new' == $this->getCFGDef('JSONformat', 'old')) { |
|
1126 | + if ('new' == $this->getCFGDef('JSONformat', 'old')) { |
|
1121 | 1127 | $return = array(); |
1122 | 1128 | |
1123 | 1129 | $return['rows'] = array(); |
1124 | - foreach ($out as $key => $item) { |
|
1130 | + foreach ($out as $key => $item) { |
|
1125 | 1131 | $return['rows'][] = $item; |
1126 | 1132 | } |
1127 | 1133 | $return['total'] = $this->getChildrenCount(); |
1128 | - } elseif ('simple' == $this->getCFGDef('JSONformat', 'old')) { |
|
1134 | + } elseif ('simple' == $this->getCFGDef('JSONformat', 'old')) { |
|
1129 | 1135 | $return = array(); |
1130 | - foreach ($out as $key => $item) { |
|
1136 | + foreach ($out as $key => $item) { |
|
1131 | 1137 | $return[] = $item; |
1132 | 1138 | } |
1133 | - } else { |
|
1139 | + } else { |
|
1134 | 1140 | $return = $out; |
1135 | 1141 | } |
1136 | 1142 | $this->outData = json_encode($return); |
@@ -1146,11 +1152,11 @@ discard block |
||
1146 | 1152 | * @param string $contentField |
1147 | 1153 | * @return mixed|string |
1148 | 1154 | */ |
1149 | - protected function getSummary(array $item = array(), $extSummary = null, $introField = '', $contentField = '') |
|
1150 | - { |
|
1155 | + protected function getSummary(array $item = array(), $extSummary = null, $introField = '', $contentField = '') |
|
1156 | + { |
|
1151 | 1157 | $out = ''; |
1152 | 1158 | |
1153 | - if (is_null($extSummary)) { |
|
1159 | + if (is_null($extSummary)) { |
|
1154 | 1160 | /** |
1155 | 1161 | * @var $extSummary summary_DL_Extender |
1156 | 1162 | */ |
@@ -1159,10 +1165,10 @@ discard block |
||
1159 | 1165 | $introField = $this->getCFGDef("introField", $introField); |
1160 | 1166 | $contentField = $this->getCFGDef("contentField", $contentField); |
1161 | 1167 | |
1162 | - if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) { |
|
1168 | + if (!empty($introField) && !empty($item[$introField]) && mb_strlen($item[$introField], 'UTF-8') > 0) { |
|
1163 | 1169 | $out = $item[$introField]; |
1164 | - } else { |
|
1165 | - if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) { |
|
1170 | + } else { |
|
1171 | + if (!empty($contentField) && !empty($item[$contentField]) && mb_strlen($item[$contentField], 'UTF-8') > 0) { |
|
1166 | 1172 | $out = $extSummary->init($this, array( |
1167 | 1173 | "content" => $item[$contentField], |
1168 | 1174 | "action" => $this->getCFGDef("summary", ""), |
@@ -1180,8 +1186,8 @@ discard block |
||
1180 | 1186 | * @param string $name extender name |
1181 | 1187 | * @return boolean status extender load |
1182 | 1188 | */ |
1183 | - public function checkExtender($name) |
|
1184 | - { |
|
1189 | + public function checkExtender($name) |
|
1190 | + { |
|
1185 | 1191 | return (isset($this->extender[$name]) && $this->extender[$name] instanceof $name . "_DL_Extender"); |
1186 | 1192 | } |
1187 | 1193 | |
@@ -1189,8 +1195,8 @@ discard block |
||
1189 | 1195 | * @param $name |
1190 | 1196 | * @param $obj |
1191 | 1197 | */ |
1192 | - public function setExtender($name, $obj) |
|
1193 | - { |
|
1198 | + public function setExtender($name, $obj) |
|
1199 | + { |
|
1194 | 1200 | $this->extender[$name] = $obj; |
1195 | 1201 | } |
1196 | 1202 | |
@@ -1202,13 +1208,13 @@ discard block |
||
1202 | 1208 | * @param bool $nop если экстендер не загружен, то загружать ли xNop |
1203 | 1209 | * @return null|xNop |
1204 | 1210 | */ |
1205 | - public function getExtender($name, $autoload = false, $nop = false) |
|
1206 | - { |
|
1211 | + public function getExtender($name, $autoload = false, $nop = false) |
|
1212 | + { |
|
1207 | 1213 | $out = null; |
1208 | - if ((is_scalar($name) && $this->checkExtender($name)) || ($autoload && $this->_loadExtender($name))) { |
|
1214 | + if ((is_scalar($name) && $this->checkExtender($name)) || ($autoload && $this->_loadExtender($name))) { |
|
1209 | 1215 | $out = $this->extender[$name]; |
1210 | 1216 | } |
1211 | - if ($nop && is_null($out)) { |
|
1217 | + if ($nop && is_null($out)) { |
|
1212 | 1218 | $out = new xNop(); |
1213 | 1219 | } |
1214 | 1220 | |
@@ -1221,27 +1227,27 @@ discard block |
||
1221 | 1227 | * @param string $name name extender |
1222 | 1228 | * @return boolean $flag status load extender |
1223 | 1229 | */ |
1224 | - protected function _loadExtender($name) |
|
1225 | - { |
|
1230 | + protected function _loadExtender($name) |
|
1231 | + { |
|
1226 | 1232 | $this->debug->debug('Load Extender ' . $this->debug->dumpData($name), 'LoadExtender', 2); |
1227 | 1233 | $flag = false; |
1228 | 1234 | |
1229 | 1235 | $classname = ($name != '') ? $name . "_DL_Extender" : ""; |
1230 | - if ($classname != '' && isset($this->extender[$name]) && $this->extender[$name] instanceof $classname) { |
|
1236 | + if ($classname != '' && isset($this->extender[$name]) && $this->extender[$name] instanceof $classname) { |
|
1231 | 1237 | $flag = true; |
1232 | 1238 | |
1233 | - } else { |
|
1234 | - if (!class_exists($classname, false) && $classname != '') { |
|
1235 | - if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) { |
|
1239 | + } else { |
|
1240 | + if (!class_exists($classname, false) && $classname != '') { |
|
1241 | + if (file_exists(dirname(__FILE__) . "/extender/" . $name . ".extender.inc")) { |
|
1236 | 1242 | include_once(dirname(__FILE__) . "/extender/" . $name . ".extender.inc"); |
1237 | 1243 | } |
1238 | 1244 | } |
1239 | - if (class_exists($classname, false) && $classname != '') { |
|
1245 | + if (class_exists($classname, false) && $classname != '') { |
|
1240 | 1246 | $this->extender[$name] = new $classname($this, $name); |
1241 | 1247 | $flag = true; |
1242 | 1248 | } |
1243 | 1249 | } |
1244 | - if (!$flag) { |
|
1250 | + if (!$flag) { |
|
1245 | 1251 | $this->debug->debug("Error load Extender " . $this->debug->dumpData($name)); |
1246 | 1252 | } |
1247 | 1253 | $this->debug->debugEnd('LoadExtender'); |
@@ -1259,16 +1265,16 @@ discard block |
||
1259 | 1265 | * @param mixed $IDs список id документов по которым необходима выборка |
1260 | 1266 | * @return array очищенный массив |
1261 | 1267 | */ |
1262 | - public function setIDs($IDs) |
|
1263 | - { |
|
1268 | + public function setIDs($IDs) |
|
1269 | + { |
|
1264 | 1270 | $this->debug->debug('set ID list ' . $this->debug->dumpData($IDs), 'setIDs', 2); |
1265 | 1271 | $IDs = $this->cleanIDs($IDs); |
1266 | 1272 | $type = $this->getCFGDef('idType', 'parents'); |
1267 | 1273 | $depth = $this->getCFGDef('depth', ''); |
1268 | - if ($type == 'parents' && $depth > 0) { |
|
1274 | + if ($type == 'parents' && $depth > 0) { |
|
1269 | 1275 | $tmp = $IDs; |
1270 | - do { |
|
1271 | - if (count($tmp) > 0) { |
|
1276 | + do { |
|
1277 | + if (count($tmp) > 0) { |
|
1272 | 1278 | $tmp = $this->getChildrenFolder($tmp); |
1273 | 1279 | $IDs = array_merge($IDs, $tmp); |
1274 | 1280 | } |
@@ -1282,8 +1288,8 @@ discard block |
||
1282 | 1288 | /** |
1283 | 1289 | * @return int |
1284 | 1290 | */ |
1285 | - public function getIDs() |
|
1286 | - { |
|
1291 | + public function getIDs() |
|
1292 | + { |
|
1287 | 1293 | return $this->IDs; |
1288 | 1294 | } |
1289 | 1295 | |
@@ -1294,17 +1300,18 @@ discard block |
||
1294 | 1300 | * @param string $sep разделитель |
1295 | 1301 | * @return array очищенный массив с данными |
1296 | 1302 | */ |
1297 | - public function cleanIDs($IDs, $sep = ',') |
|
1298 | - { |
|
1303 | + public function cleanIDs($IDs, $sep = ',') |
|
1304 | + { |
|
1299 | 1305 | $this->debug->debug('clean IDs ' . $this->debug->dumpData($IDs) . ' with separator ' . $this->debug->dumpData($sep), |
1300 | 1306 | 'cleanIDs', 2); |
1301 | 1307 | $out = array(); |
1302 | - if (!is_array($IDs)) { |
|
1308 | + if (!is_array($IDs)) { |
|
1303 | 1309 | $IDs = explode($sep, $IDs); |
1304 | 1310 | } |
1305 | - foreach ($IDs as $item) { |
|
1311 | + foreach ($IDs as $item) { |
|
1306 | 1312 | $item = trim($item); |
1307 | - if (is_numeric($item) && (int)$item >= 0) { //Fix 0xfffffffff |
|
1313 | + if (is_numeric($item) && (int)$item >= 0) { |
|
1314 | +//Fix 0xfffffffff |
|
1308 | 1315 | $out[] = (int)$item; |
1309 | 1316 | } |
1310 | 1317 | } |
@@ -1318,8 +1325,8 @@ discard block |
||
1318 | 1325 | * Проверка массива с id-шниками документов для выборки |
1319 | 1326 | * @return boolean пригодны ли данные для дальнейшего использования |
1320 | 1327 | */ |
1321 | - protected function checkIDs() |
|
1322 | - { |
|
1328 | + protected function checkIDs() |
|
1329 | + { |
|
1323 | 1330 | return (is_array($this->IDs) && count($this->IDs) > 0) ? true : false; |
1324 | 1331 | } |
1325 | 1332 | |
@@ -1331,11 +1338,11 @@ discard block |
||
1331 | 1338 | * @global array $_docs all documents |
1332 | 1339 | * @return array all field values |
1333 | 1340 | */ |
1334 | - public function getOneField($userField, $uniq = false) |
|
1335 | - { |
|
1341 | + public function getOneField($userField, $uniq = false) |
|
1342 | + { |
|
1336 | 1343 | $out = array(); |
1337 | - foreach ($this->_docs as $doc => $val) { |
|
1338 | - if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) { |
|
1344 | + foreach ($this->_docs as $doc => $val) { |
|
1345 | + if (isset($val[$userField]) && (($uniq && !in_array($val[$userField], $out)) || !$uniq)) { |
|
1339 | 1346 | $out[$doc] = $val[$userField]; |
1340 | 1347 | } |
1341 | 1348 | } |
@@ -1346,8 +1353,8 @@ discard block |
||
1346 | 1353 | /** |
1347 | 1354 | * @return DLCollection |
1348 | 1355 | */ |
1349 | - public function docsCollection() |
|
1350 | - { |
|
1356 | + public function docsCollection() |
|
1357 | + { |
|
1351 | 1358 | return new DLCollection($this->modx, $this->_docs); |
1352 | 1359 | } |
1353 | 1360 | |
@@ -1375,10 +1382,10 @@ discard block |
||
1375 | 1382 | * @param string $group |
1376 | 1383 | * @return string |
1377 | 1384 | */ |
1378 | - protected function getGroupSQL($group = '') |
|
1379 | - { |
|
1385 | + protected function getGroupSQL($group = '') |
|
1386 | + { |
|
1380 | 1387 | $out = ''; |
1381 | - if ($group != '') { |
|
1388 | + if ($group != '') { |
|
1382 | 1389 | $out = 'GROUP BY ' . $group; |
1383 | 1390 | } |
1384 | 1391 | |
@@ -1397,12 +1404,12 @@ discard block |
||
1397 | 1404 | * |
1398 | 1405 | * @return string Order by for SQL |
1399 | 1406 | */ |
1400 | - protected function SortOrderSQL($sortName, $orderDef = 'DESC') |
|
1401 | - { |
|
1407 | + protected function SortOrderSQL($sortName, $orderDef = 'DESC') |
|
1408 | + { |
|
1402 | 1409 | $this->debug->debug('', 'sortORDER', 2); |
1403 | 1410 | |
1404 | 1411 | $sort = ''; |
1405 | - switch ($this->getCFGDef('sortType', '')) { |
|
1412 | + switch ($this->getCFGDef('sortType', '')) { |
|
1406 | 1413 | case 'none': |
1407 | 1414 | break; |
1408 | 1415 | case 'doclist': |
@@ -1413,10 +1420,10 @@ discard block |
||
1413 | 1420 | break; |
1414 | 1421 | default: |
1415 | 1422 | $out = array('orderBy' => '', 'order' => '', 'sortBy' => ''); |
1416 | - if (($tmp = $this->getCFGDef('orderBy', '')) != '') { |
|
1423 | + if (($tmp = $this->getCFGDef('orderBy', '')) != '') { |
|
1417 | 1424 | $out['orderBy'] = $tmp; |
1418 | - } else { |
|
1419 | - switch (true) { |
|
1425 | + } else { |
|
1426 | + switch (true) { |
|
1420 | 1427 | case ('' != ($tmp = $this->getCFGDef('sortDir', ''))): //higher priority than order |
1421 | 1428 | $out['order'] = $tmp; |
1422 | 1429 | // no break |
@@ -1424,7 +1431,7 @@ discard block |
||
1424 | 1431 | $out['order'] = $tmp; |
1425 | 1432 | // no break |
1426 | 1433 | } |
1427 | - if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) { |
|
1434 | + if ('' == $out['order'] || !in_array(strtoupper($out['order']), array('ASC', 'DESC'))) { |
|
1428 | 1435 | $out['order'] = $orderDef; //Default |
1429 | 1436 | } |
1430 | 1437 | |
@@ -1445,30 +1452,30 @@ discard block |
||
1445 | 1452 | * |
1446 | 1453 | * @return string LIMIT вставка в SQL запрос |
1447 | 1454 | */ |
1448 | - protected function LimitSQL($limit = 0, $offset = 0) |
|
1449 | - { |
|
1455 | + protected function LimitSQL($limit = 0, $offset = 0) |
|
1456 | + { |
|
1450 | 1457 | $this->debug->debug('', 'limitSQL', 2); |
1451 | 1458 | $ret = ''; |
1452 | - if ($limit == 0) { |
|
1459 | + if ($limit == 0) { |
|
1453 | 1460 | $limit = $this->getCFGDef('display', 0); |
1454 | 1461 | } |
1455 | 1462 | $maxDocs = $this->getCFGDef('maxDocs', 0); |
1456 | - if ($maxDocs > 0 && $limit > $maxDocs) { |
|
1463 | + if ($maxDocs > 0 && $limit > $maxDocs) { |
|
1457 | 1464 | $limit = $maxDocs; |
1458 | 1465 | } |
1459 | - if ($offset == 0) { |
|
1466 | + if ($offset == 0) { |
|
1460 | 1467 | $offset = $this->getCFGDef('offset', 0); |
1461 | 1468 | } |
1462 | 1469 | $offset += $this->getCFGDef('start', 0); |
1463 | 1470 | $total = $this->getCFGDef('total', 0); |
1464 | - if ($limit < ($total - $limit)) { |
|
1471 | + if ($limit < ($total - $limit)) { |
|
1465 | 1472 | $limit = $total - $offset; |
1466 | 1473 | } |
1467 | 1474 | |
1468 | - if ($limit != 0) { |
|
1475 | + if ($limit != 0) { |
|
1469 | 1476 | $ret = "LIMIT " . (int)$offset . "," . (int)$limit; |
1470 | - } else { |
|
1471 | - if ($offset != 0) { |
|
1477 | + } else { |
|
1478 | + if ($offset != 0) { |
|
1472 | 1479 | /** |
1473 | 1480 | * 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 |
1474 | 1481 | * @see http://dev.mysql.com/doc/refman/5.0/en/select.html |
@@ -1488,8 +1495,8 @@ discard block |
||
1488 | 1495 | * @param string $charset |
1489 | 1496 | * @return string Clear string |
1490 | 1497 | */ |
1491 | - public function sanitarData($data, $charset = 'UTF-8') |
|
1492 | - { |
|
1498 | + public function sanitarData($data, $charset = 'UTF-8') |
|
1499 | + { |
|
1493 | 1500 | return APIHelpers::sanitarTag($data, $charset); |
1494 | 1501 | } |
1495 | 1502 | |
@@ -1500,8 +1507,8 @@ discard block |
||
1500 | 1507 | * @param string $parentField default name parent field |
1501 | 1508 | * @return array |
1502 | 1509 | */ |
1503 | - public function treeBuild($idField = 'id', $parentField = 'parent') |
|
1504 | - { |
|
1510 | + public function treeBuild($idField = 'id', $parentField = 'parent') |
|
1511 | + { |
|
1505 | 1512 | return $this->_treeBuild($this->_docs, $this->getCFGDef('idField', $idField), |
1506 | 1513 | $this->getCFGDef('parentField', $parentField)); |
1507 | 1514 | } |
@@ -1514,16 +1521,16 @@ discard block |
||
1514 | 1521 | * @param string $pidName name parent field in associative data array |
1515 | 1522 | * @return array |
1516 | 1523 | */ |
1517 | - private function _treeBuild($data, $idName, $pidName) |
|
1518 | - { |
|
1524 | + private function _treeBuild($data, $idName, $pidName) |
|
1525 | + { |
|
1519 | 1526 | $children = array(); // children of each ID |
1520 | 1527 | $ids = array(); |
1521 | - foreach ($data as $i => $r) { |
|
1528 | + foreach ($data as $i => $r) { |
|
1522 | 1529 | $row =& $data[$i]; |
1523 | 1530 | $id = $row[$idName]; |
1524 | 1531 | $pid = $row[$pidName]; |
1525 | 1532 | $children[$pid][$id] =& $row; |
1526 | - if (!isset($children[$id])) { |
|
1533 | + if (!isset($children[$id])) { |
|
1527 | 1534 | $children[$id] = array(); |
1528 | 1535 | } |
1529 | 1536 | $row['#childNodes'] =& $children[$id]; |
@@ -1531,9 +1538,9 @@ discard block |
||
1531 | 1538 | } |
1532 | 1539 | // Root elements are elements with non-found PIDs. |
1533 | 1540 | $this->_tree = array(); |
1534 | - foreach ($data as $i => $r) { |
|
1541 | + foreach ($data as $i => $r) { |
|
1535 | 1542 | $row =& $data[$i]; |
1536 | - if (!isset($ids[$row[$pidName]])) { |
|
1543 | + if (!isset($ids[$row[$pidName]])) { |
|
1537 | 1544 | $this->_tree[$row[$idName]] = $row; |
1538 | 1545 | } |
1539 | 1546 | } |
@@ -1547,12 +1554,12 @@ discard block |
||
1547 | 1554 | * @param bool $full если true то возвращается значение для подстановки в запрос |
1548 | 1555 | * @return string PrimaryKey основной таблицы |
1549 | 1556 | */ |
1550 | - public function getPK($full = true) |
|
1551 | - { |
|
1557 | + public function getPK($full = true) |
|
1558 | + { |
|
1552 | 1559 | $idField = isset($this->idField) ? $this->idField: 'id'; |
1553 | - if ($full) { |
|
1560 | + if ($full) { |
|
1554 | 1561 | $idField = '`' . $idField . '`'; |
1555 | - if (!empty($this->alias)) { |
|
1562 | + if (!empty($this->alias)) { |
|
1556 | 1563 | $idField = '`' . $this->alias . '`.' . $idField; |
1557 | 1564 | } |
1558 | 1565 | } |
@@ -1566,12 +1573,12 @@ discard block |
||
1566 | 1573 | * @param bool $full если true то возвращается значение для подстановки в запрос |
1567 | 1574 | * @return string Parent Key основной таблицы |
1568 | 1575 | */ |
1569 | - public function getParentField($full = true) |
|
1570 | - { |
|
1576 | + public function getParentField($full = true) |
|
1577 | + { |
|
1571 | 1578 | $parentField = isset($this->parentField) ? $this->parentField : ''; |
1572 | - if ($full && !empty($parentField)) { |
|
1579 | + if ($full && !empty($parentField)) { |
|
1573 | 1580 | $parentField = '`' . $parentField . '`'; |
1574 | - if (!empty($this->alias)) { |
|
1581 | + if (!empty($this->alias)) { |
|
1575 | 1582 | $parentField = '`' . $this->alias . '`.' . $parentField; |
1576 | 1583 | } |
1577 | 1584 | } |
@@ -1586,31 +1593,31 @@ discard block |
||
1586 | 1593 | * @param string $filter_string строка со всеми фильтрами |
1587 | 1594 | * @return mixed результат разбора фильтров |
1588 | 1595 | */ |
1589 | - protected function getFilters($filter_string) |
|
1590 | - { |
|
1596 | + protected function getFilters($filter_string) |
|
1597 | + { |
|
1591 | 1598 | $this->debug->debug("getFilters: " . $this->debug->dumpData($filter_string), 'getFilter', 1); |
1592 | 1599 | // the filter parameter tells us, which filters can be used in this query |
1593 | 1600 | $filter_string = trim($filter_string, ' ;'); |
1594 | - if (!$filter_string) { |
|
1601 | + if (!$filter_string) { |
|
1595 | 1602 | return; |
1596 | 1603 | } |
1597 | 1604 | $output = array('join' => '', 'where' => ''); |
1598 | 1605 | $logic_op_found = false; |
1599 | 1606 | $joins = $wheres = array(); |
1600 | - foreach ($this->_logic_ops as $op => $sql) { |
|
1601 | - if (strpos($filter_string, $op) === 0) { |
|
1607 | + foreach ($this->_logic_ops as $op => $sql) { |
|
1608 | + if (strpos($filter_string, $op) === 0) { |
|
1602 | 1609 | $logic_op_found = true; |
1603 | 1610 | $subfilters = mb_substr($filter_string, strlen($op) + 1, mb_strlen($filter_string, "UTF-8"), "UTF-8"); |
1604 | 1611 | $subfilters = $this->smartSplit($subfilters); |
1605 | - foreach ($subfilters as $subfilter) { |
|
1612 | + foreach ($subfilters as $subfilter) { |
|
1606 | 1613 | $subfilter = $this->getFilters(trim($subfilter)); |
1607 | - if (!$subfilter) { |
|
1614 | + if (!$subfilter) { |
|
1608 | 1615 | continue; |
1609 | 1616 | } |
1610 | - if ($subfilter['join']) { |
|
1617 | + if ($subfilter['join']) { |
|
1611 | 1618 | $joins[] = $subfilter['join']; |
1612 | 1619 | } |
1613 | - if ($subfilter['where']) { |
|
1620 | + if ($subfilter['where']) { |
|
1614 | 1621 | $wheres[] = $subfilter['where']; |
1615 | 1622 | } |
1616 | 1623 | } |
@@ -1619,12 +1626,12 @@ discard block |
||
1619 | 1626 | } |
1620 | 1627 | } |
1621 | 1628 | |
1622 | - if (!$logic_op_found) { |
|
1629 | + if (!$logic_op_found) { |
|
1623 | 1630 | $filter = $this->loadFilter($filter_string); |
1624 | - if (!$filter) { |
|
1631 | + if (!$filter) { |
|
1625 | 1632 | $this->debug->warning('Error while loading DocLister filter "' . $this->debug->dumpData($filter_string) . '": check syntax!'); |
1626 | 1633 | $output = false; |
1627 | - } else { |
|
1634 | + } else { |
|
1628 | 1635 | $output['join'] = $filter->get_join(); |
1629 | 1636 | $output['where'] = stripslashes($filter->get_where()); |
1630 | 1637 | } |
@@ -1637,16 +1644,16 @@ discard block |
||
1637 | 1644 | /** |
1638 | 1645 | * @return mixed |
1639 | 1646 | */ |
1640 | - public function filtersWhere() |
|
1641 | - { |
|
1647 | + public function filtersWhere() |
|
1648 | + { |
|
1642 | 1649 | return APIHelpers::getkey($this->_filters, 'where', ''); |
1643 | 1650 | } |
1644 | 1651 | |
1645 | 1652 | /** |
1646 | 1653 | * @return mixed |
1647 | 1654 | */ |
1648 | - public function filtersJoin() |
|
1649 | - { |
|
1655 | + public function filtersJoin() |
|
1656 | + { |
|
1650 | 1657 | return APIHelpers::getkey($this->_filters, 'join', ''); |
1651 | 1658 | } |
1652 | 1659 | |
@@ -1654,11 +1661,12 @@ discard block |
||
1654 | 1661 | * @param string $join |
1655 | 1662 | * @return $this |
1656 | 1663 | */ |
1657 | - public function setFiltersJoin($join = '') { |
|
1658 | - if (!empty($join)) { |
|
1659 | - if (!empty($this->_filters['join'])) { |
|
1664 | + public function setFiltersJoin($join = '') |
|
1665 | + { |
|
1666 | + if (!empty($join)) { |
|
1667 | + if (!empty($this->_filters['join'])) { |
|
1660 | 1668 | $this->_filters['join'] .= ' ' . $join; |
1661 | - } else { |
|
1669 | + } else { |
|
1662 | 1670 | $this->_filters['join'] = $join; |
1663 | 1671 | } |
1664 | 1672 | } |
@@ -1673,10 +1681,10 @@ discard block |
||
1673 | 1681 | * @param $type string тип фильтрации |
1674 | 1682 | * @return string имя поля с учетом приведения типа |
1675 | 1683 | */ |
1676 | - public function changeSortType($field, $type) |
|
1677 | - { |
|
1684 | + public function changeSortType($field, $type) |
|
1685 | + { |
|
1678 | 1686 | $type = trim($type); |
1679 | - switch (strtoupper($type)) { |
|
1687 | + switch (strtoupper($type)) { |
|
1680 | 1688 | case 'DECIMAL': |
1681 | 1689 | $field = 'CAST(' . $field . ' as DECIMAL(10,2))'; |
1682 | 1690 | break; |
@@ -1702,8 +1710,8 @@ discard block |
||
1702 | 1710 | * @param string $filter срока с параметрами фильтрации |
1703 | 1711 | * @return bool |
1704 | 1712 | */ |
1705 | - protected function loadFilter($filter) |
|
1706 | - { |
|
1713 | + protected function loadFilter($filter) |
|
1714 | + { |
|
1707 | 1715 | $this->debug->debug('Load filter ' . $this->debug->dumpData($filter), 'loadFilter', 2); |
1708 | 1716 | $out = false; |
1709 | 1717 | $fltr_params = explode(':', $filter, 2); |
@@ -1713,21 +1721,21 @@ discard block |
||
1713 | 1721 | */ |
1714 | 1722 | $fltr_class = $fltr . '_DL_filter'; |
1715 | 1723 | // check if the filter is implemented |
1716 | - if (!is_null($fltr)) { |
|
1717 | - if (!class_exists($fltr_class) && file_exists(__DIR__ . '/filter/' . $fltr . '.filter.php')) { |
|
1724 | + if (!is_null($fltr)) { |
|
1725 | + if (!class_exists($fltr_class) && file_exists(__DIR__ . '/filter/' . $fltr . '.filter.php')) { |
|
1718 | 1726 | require_once dirname(__FILE__) . '/filter/' . $fltr . '.filter.php'; |
1719 | 1727 | } |
1720 | - if (class_exists($fltr_class)) { |
|
1728 | + if (class_exists($fltr_class)) { |
|
1721 | 1729 | $this->totalFilters++; |
1722 | 1730 | $fltr_obj = new $fltr_class(); |
1723 | - if ($fltr_obj->init($this, $filter)) { |
|
1731 | + if ($fltr_obj->init($this, $filter)) { |
|
1724 | 1732 | $out = $fltr_obj; |
1725 | - } else { |
|
1733 | + } else { |
|
1726 | 1734 | $this->debug->error("Wrong filter parameter: '{$this->debug->dumpData($filter)}'", 'Filter'); |
1727 | 1735 | } |
1728 | 1736 | } |
1729 | 1737 | } |
1730 | - if (!$out) { |
|
1738 | + if (!$out) { |
|
1731 | 1739 | $this->debug->error("Error load Filter: '{$this->debug->dumpData($filter)}'", 'Filter'); |
1732 | 1740 | } |
1733 | 1741 | |
@@ -1740,8 +1748,8 @@ discard block |
||
1740 | 1748 | * Общее число фильтров |
1741 | 1749 | * @return int |
1742 | 1750 | */ |
1743 | - public function getCountFilters() |
|
1744 | - { |
|
1751 | + public function getCountFilters() |
|
1752 | + { |
|
1745 | 1753 | return (int)$this->totalFilters; |
1746 | 1754 | } |
1747 | 1755 | |
@@ -1749,8 +1757,8 @@ discard block |
||
1749 | 1757 | * Выполнить SQL запрос |
1750 | 1758 | * @param string $q SQL запрос |
1751 | 1759 | */ |
1752 | - public function dbQuery($q) |
|
1753 | - { |
|
1760 | + public function dbQuery($q) |
|
1761 | + { |
|
1754 | 1762 | $this->debug->debug($q, "query", 1, 'sql'); |
1755 | 1763 | $out = $this->modx->db->query($q); |
1756 | 1764 | $this->debug->debugEnd("query"); |
@@ -1768,8 +1776,8 @@ discard block |
||
1768 | 1776 | * @param string $tpl шаблон подстановки значения в SQL запрос |
1769 | 1777 | * @return string строка для подстановки в SQL запрос |
1770 | 1778 | */ |
1771 | - public function LikeEscape($field, $value, $escape = '=', $tpl = '%[+value+]%') |
|
1772 | - { |
|
1779 | + public function LikeEscape($field, $value, $escape = '=', $tpl = '%[+value+]%') |
|
1780 | + { |
|
1773 | 1781 | return sqlHelper::LikeEscape($this->modx, $field, $value, $escape, $tpl); |
1774 | 1782 | } |
1775 | 1783 | |
@@ -1777,8 +1785,8 @@ discard block |
||
1777 | 1785 | * Получение REQUEST_URI без GET-ключа с |
1778 | 1786 | * @return string |
1779 | 1787 | */ |
1780 | - public function getRequest() |
|
1781 | - { |
|
1788 | + public function getRequest() |
|
1789 | + { |
|
1782 | 1790 | $URL = null; |
1783 | 1791 | parse_str(parse_url(MODX_SITE_URL . $_SERVER['REQUEST_URI'], PHP_URL_QUERY), $URL); |
1784 | 1792 |