From b1a278d4badb41f23174a79f07b0598251822668 Mon Sep 17 00:00:00 2001 From: dmi3yy Date: Thu, 25 Jan 2018 21:46:27 +0200 Subject: [PATCH 1/2] fix formlister bug --- assets/snippets/FormLister/core/FormLister.abstract.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assets/snippets/FormLister/core/FormLister.abstract.php b/assets/snippets/FormLister/core/FormLister.abstract.php index e5f377e9cc..f663bc0919 100644 --- a/assets/snippets/FormLister/core/FormLister.abstract.php +++ b/assets/snippets/FormLister/core/FormLister.abstract.php @@ -145,10 +145,12 @@ public function __construct(\DocumentParser $modx, $cfg = array()) public function initForm() { $lexicon = $this->getCFGDef('lexicon'); + $langDir = $this->getCFGDef('langDir', 'assets/snippets/FormLister/core/lang/'); + $lang = $this->getCFGDef('lang', $this->modx->config['manager_language']); if ($lexicon) { $_lexicon = $this->config->loadArray($lexicon); if (isset($_lexicon[0])) { - $lang = $this->lexicon->loadLang($_lexicon); + $lang = $this->lexicon->loadLang($_lexicon, $lang, $langDir); } else { $lang = $this->lexicon->fromArray($_lexicon); } From cc1d5697482af8986b5765706f78175393a4545c Mon Sep 17 00:00:00 2001 From: dmi3yy Date: Thu, 25 Jan 2018 21:47:36 +0200 Subject: [PATCH 2/2] update DocLister --- .../DocLister/core/controller/onetable.php | 41 +++++++++++++++---- .../DocLister/core/controller/shopkeeper.php | 4 ++ .../core/controller/site_content.php | 6 ++- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/assets/snippets/DocLister/core/controller/onetable.php b/assets/snippets/DocLister/core/controller/onetable.php index ccf6d28e7c..ee687c557d 100644 --- a/assets/snippets/DocLister/core/controller/onetable.php +++ b/assets/snippets/DocLister/core/controller/onetable.php @@ -49,6 +49,7 @@ public function getDocs($tvlist = '') public function _render($tpl = '') { $out = ''; + $separator = $this->getCFGDef('outputSeparator', ''); if ($tpl == '') { $tpl = $this->getCFGDef('tpl', ''); } @@ -127,6 +128,9 @@ public function _render($tpl = '') "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page } $out .= $tmp; + if (next($this->_docs) !== false) { + $out .= $separator; + } $i++; } } @@ -208,7 +212,15 @@ protected function getDocList() $out = array(); $sanitarInIDs = $this->sanitarIn($this->IDs); if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { + $from = $this->table . " " . $this->_filters['join']; $where = $this->getCFGDef('addWhereList', ''); + + //====== block added by Dreamer to enable filters ====== + $where = ($where ? $where . ' AND ' : '') . $this->_filters['where']; + $where = sqlHelper::trimLogicalOp($where); + //------- end of block ------- + + if ($where != '') { $where = array($where); } @@ -222,7 +234,8 @@ protected function getDocList() $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0)); $fields = $this->getCFGDef('selectFields', '*'); $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); - $rs = $this->dbQuery("SELECT {$fields} FROM {$this->table} {$where} {$group} {$this->SortOrderSQL($this->getPK())} {$limit}"); + $sort = $this->SortOrderSQL($this->getPK()); + $rs = $this->dbQuery("SELECT {$fields} FROM {$from} {$where} {$group} {$sort} {$limit}"); $pk = $this->getPK(false); while ($item = $this->modx->db->getRow($rs)) { @@ -240,9 +253,16 @@ protected function getChildrenList() { $where = array(); $out = array(); - + $from = $this->table . " " . $this->_filters['join']; $tmpWhere = $this->getCFGDef('addWhereList', ''); $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere); + + //====== block added by Dreamer to enable filters ====== + $tmpWhere = ($tmpWhere ? $tmpWhere . ' AND ' : '') . $this->_filters['where']; + $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere); + //------- end of block ------- + + if (!empty($tmpWhere)) { $where[] = $tmpWhere; } @@ -282,12 +302,10 @@ protected function getChildrenList() } $fields = $this->getCFGDef('selectFields', '*'); $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); + $sort = $this->SortOrderSQL($this->getPK()); + $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0)); if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { - $rs = $this->dbQuery("SELECT {$fields} FROM " . $this->table . " " . $where . " " . - $group . " " . - $this->SortOrderSQL($this->getPK()) . " " . - $this->LimitSQL($this->getCFGDef('queryLimit', 0)) - ); + $rs = $this->dbQuery("SELECT {$fields} FROM {$from} {$where} {$group} {$sort} {$limit}"); $pk = $this->getPK(false); @@ -308,7 +326,14 @@ public function getChildrenCount() $out = 0; $sanitarInIDs = $this->sanitarIn($this->IDs); if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { + $from = $this->table . " " . $this->_filters['join']; $where = $this->getCFGDef('addWhereList', ''); + + //====== block added by Dreamer ====== + $where = ($where ? $where . ' AND ' : '') . $this->_filters['where']; + $where = sqlHelper::trimLogicalOp($where); + //------- end of block ------- + if ($where != '') { $where = array($where); } else { @@ -352,7 +377,7 @@ public function getChildrenCount() $group = $this->getGroupSQL($this->getCFGDef('groupBy', $this->getPK())); $maxDocs = $this->getCFGDef('maxDocs', 0); $limit = $maxDocs > 0 ? $this->LimitSQL($this->getCFGDef('maxDocs', 0)) : ''; - $rs = ("SELECT count(*) FROM (SELECT count(*) FROM {$this->table} {$where} {$group} {$limit}) as `tmp`"); + $rs = ("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group} {$limit}) as `tmp`"); $out = $this->modx->db->getValue($rs); } diff --git a/assets/snippets/DocLister/core/controller/shopkeeper.php b/assets/snippets/DocLister/core/controller/shopkeeper.php index 792ea73237..21dec71cd2 100644 --- a/assets/snippets/DocLister/core/controller/shopkeeper.php +++ b/assets/snippets/DocLister/core/controller/shopkeeper.php @@ -33,6 +33,7 @@ public function __construct($modx, $cfg = array(), $startTime = null) public function _render($tpl = '') { $out = ''; + $separator = $this->getCFGDef('outputSeparator', ''); if ($tpl == '') { $tpl = $this->getCFGDef('tpl', '@CODE:[+pagetitle+]
'); } @@ -123,6 +124,9 @@ public function _render($tpl = '') "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page } $out .= $tmp; + if (next($this->_docs) !== false) { + $out .= $separator; + } $i++; } } else { diff --git a/assets/snippets/DocLister/core/controller/site_content.php b/assets/snippets/DocLister/core/controller/site_content.php index b6aae7d5f0..41982c2174 100644 --- a/assets/snippets/DocLister/core/controller/site_content.php +++ b/assets/snippets/DocLister/core/controller/site_content.php @@ -88,6 +88,7 @@ public function getDocs($tvlist = '') public function _render($tpl = '') { $out = ''; + $separator = $this->getCFGDef('outputSeparator', ''); if ($tpl == '') { $tpl = $this->getCFGDef('tpl', '@CODE:[+pagetitle+]
'); } @@ -176,10 +177,13 @@ public function _render($tpl = '') "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page } $out .= $tmp; + if (next($this->_docs) !== false) { + $out .= $separator; + } $i++; } } else { - $noneTPL = $this->getCFGDef("noneTPL", ""); + $noneTPL = $this->getCFGDef('noneTPL', ''); $out = ($noneTPL != '') ? $this->parseChunk($noneTPL, $sysPlh) : ''; } $out = $this->renderWrap($out);