Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmi3yy committed Jan 25, 2018
2 parents afd236c + cc1d569 commit eb5ae03
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 10 deletions.
41 changes: 33 additions & 8 deletions assets/snippets/DocLister/core/controller/onetable.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function getDocs($tvlist = '')
public function _render($tpl = '')
{
$out = '';
$separator = $this->getCFGDef('outputSeparator', '');
if ($tpl == '') {
$tpl = $this->getCFGDef('tpl', '');
}
Expand Down Expand Up @@ -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++;
}
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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)) {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);

Expand All @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 4 additions & 0 deletions assets/snippets/DocLister/core/controller/shopkeeper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:<a href="[+url+]">[+pagetitle+]</a><br />');
}
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion assets/snippets/DocLister/core/controller/site_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function getDocs($tvlist = '')
public function _render($tpl = '')
{
$out = '';
$separator = $this->getCFGDef('outputSeparator', '');
if ($tpl == '') {
$tpl = $this->getCFGDef('tpl', '@CODE:<a href="[+url+]">[+pagetitle+]</a><br />');
}
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion assets/snippets/FormLister/core/FormLister.abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit eb5ae03

Please sign in to comment.