@@ -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 | |
@@ -58,7 +58,7 @@ discard block  | 
                                                    ||
| 58 | 58 | $this->_docs = ($type == 'parents') ? $this->getChildrenList() : $this->getDocList();  | 
                                                        
| 59 | 59 |          if ($tvlist != '' && count($this->_docs) > 0) { | 
                                                        
| 60 | 60 | $tv = $this->extTV->getTVList(array_keys($this->_docs), $tvlist);  | 
                                                        
| 61 | -            if (!is_array($tv)) { | 
                                                        |
| 61 | +            if ( ! is_array($tv)) { | 
                                                        |
| 62 | 62 | $tv = array();  | 
                                                        
| 63 | 63 | }  | 
                                                        
| 64 | 64 |              foreach ($tv as $docID => $TVitem) { | 
                                                        
@@ -149,7 +149,7 @@ discard block  | 
                                                    ||
| 149 | 149 | }  | 
                                                        
| 150 | 150 | |
| 151 | 151 |                      if (isset($item[$date])) { | 
                                                        
| 152 | -                        if (!$item[$date] && $date == 'pub_date' && isset($item['createdon'])) { | 
                                                        |
| 152 | +                        if ( ! $item[$date] && $date == 'pub_date' && isset($item['createdon'])) { | 
                                                        |
| 153 | 153 | $date = 'createdon';  | 
                                                        
| 154 | 154 | }  | 
                                                        
| 155 | 155 | $_date = is_numeric($item[$date]) && $item[$date] == (int)$item[$date] ? $item[$date] : strtotime($item[$date]);  | 
                                                        
@@ -231,7 +231,7 @@ discard block  | 
                                                    ||
| 231 | 231 | |
| 232 | 232 |              if (array('1') == $fields || in_array('date', $fields)) { | 
                                                        
| 233 | 233 |                  if (isset($row[$date])) { | 
                                                        
| 234 | -                    if (!$row[$date] && $date == 'pub_date' && isset($row['createdon'])) { | 
                                                        |
| 234 | +                    if ( ! $row[$date] && $date == 'pub_date' && isset($row['createdon'])) { | 
                                                        |
| 235 | 235 | $date = 'createdon';  | 
                                                        
| 236 | 236 | }  | 
                                                        
| 237 | 237 | $_date = is_numeric($row[$date]) && $row[$date] == (int)$row[$date] ? $row[$date] : strtotime($row[$date]);  | 
                                                        
@@ -296,10 +296,10 @@ discard block  | 
                                                    ||
| 296 | 296 | |
| 297 | 297 |              $where = "WHERE {$where}"; | 
                                                        
| 298 | 298 | $whereArr = array();  | 
                                                        
| 299 | -            if (!$this->getCFGDef('showNoPublish', 0)) { | 
                                                        |
| 299 | +            if ( ! $this->getCFGDef('showNoPublish', 0)) { | 
                                                        |
| 300 | 300 | $whereArr[] = "c.deleted=0 AND c.published=1";  | 
                                                        
| 301 | 301 | }  | 
                                                        
| 302 | -            else{ | 
                                                        |
| 302 | +            else { | 
                                                        |
| 303 | 303 | $q_true = 1;  | 
                                                        
| 304 | 304 | }  | 
                                                        
| 305 | 305 | |
@@ -354,7 +354,7 @@ discard block  | 
                                                    ||
| 354 | 354 | |
| 355 | 355 | $q_true = $q_true ? $q_true : $group != '';  | 
                                                        
| 356 | 356 | |
| 357 | -            if ( $q_true ){ | 
                                                        |
| 357 | +            if ($q_true) { | 
                                                        |
| 358 | 358 |                  $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group}) as `tmp`"); | 
                                                        
| 359 | 359 | $out = $this->modx->db->getValue($rs);  | 
                                                        
| 360 | 360 | }  | 
                                                        
@@ -461,7 +461,7 @@ discard block  | 
                                                    ||
| 461 | 461 | protected function injectSortByTV($table, $sort)  | 
                                                        
| 462 | 462 |      { | 
                                                        
| 463 | 463 |          $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort); | 
                                                        
| 464 | -        if (!is_array($out) || empty($out)) { | 
                                                        |
| 464 | +        if ( ! is_array($out) || empty($out)) { | 
                                                        |
| 465 | 465 | $out = array($table, $sort);  | 
                                                        
| 466 | 466 | }  | 
                                                        
| 467 | 467 | |
@@ -478,12 +478,12 @@ discard block  | 
                                                    ||
| 478 | 478 | |
| 479 | 479 |          $tmpWhere = $this->getCFGDef('addWhereList', ''); | 
                                                        
| 480 | 480 | $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);  | 
                                                        
| 481 | -        if (!empty($tmpWhere)) { | 
                                                        |
| 481 | +        if ( ! empty($tmpWhere)) { | 
                                                        |
| 482 | 482 | $where[] = $tmpWhere;  | 
                                                        
| 483 | 483 | }  | 
                                                        
| 484 | 484 | |
| 485 | 485 | $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']);  | 
                                                        
| 486 | -        if (!empty($tmpWhere)) { | 
                                                        |
| 486 | +        if ( ! empty($tmpWhere)) { | 
                                                        |
| 487 | 487 | $where[] = $tmpWhere;  | 
                                                        
| 488 | 488 | }  | 
                                                        
| 489 | 489 | |
@@ -516,13 +516,13 @@ discard block  | 
                                                    ||
| 516 | 516 |                  $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))"; | 
                                                        
| 517 | 517 | }  | 
                                                        
| 518 | 518 | }  | 
                                                        
| 519 | -        if (!empty($tmpWhere)) { | 
                                                        |
| 519 | +        if ( ! empty($tmpWhere)) { | 
                                                        |
| 520 | 520 | $where[] = $tmpWhere;  | 
                                                        
| 521 | 521 | }  | 
                                                        
| 522 | -        if (!$this->getCFGDef('showNoPublish', 0)) { | 
                                                        |
| 522 | +        if ( ! $this->getCFGDef('showNoPublish', 0)) { | 
                                                        |
| 523 | 523 | $where[] = "c.deleted=0 AND c.published=1";  | 
                                                        
| 524 | 524 | }  | 
                                                        
| 525 | -        if (!empty($where)) { | 
                                                        |
| 525 | +        if ( ! empty($where)) { | 
                                                        |
| 526 | 526 |              $where = "WHERE " . implode(" AND ", $where); | 
                                                        
| 527 | 527 |          } else { | 
                                                        
| 528 | 528 | $where = '';  | 
                                                        
@@ -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 | |
@@ -11,8 +11,8 @@ discard block  | 
                                                    ||
| 11 | 11 | * @license GNU General Public License (GPL), http://www.gnu.org/copyleft/gpl.html  | 
                                                        
| 12 | 12 | * @author Agel_Nash <[email protected]>, kabachello <[email protected]>  | 
                                                        
| 13 | 13 | */  | 
                                                        
| 14 | -class site_contentDocLister extends DocLister  | 
                                                        |
| 15 | -{ | 
                                                        |
| 14 | +class site_contentDocLister extends DocLister  | 
                                                        |
| 15 | +{
 | 
                                                        |
| 16 | 16 | /**  | 
                                                        
| 17 | 17 | * Экземпляр экстендера TV  | 
                                                        
| 18 | 18 | *  | 
                                                        
@@ -32,8 +32,8 @@ discard block  | 
                                                    ||
| 32 | 32 | * @param array $cfg  | 
                                                        
| 33 | 33 | * @param null $startTime  | 
                                                        
| 34 | 34 | */  | 
                                                        
| 35 | - public function __construct($modx, $cfg = array(), $startTime = null)  | 
                                                        |
| 36 | -    { | 
                                                        |
| 35 | + public function __construct($modx, $cfg = array(), $startTime = null)  | 
                                                        |
| 36 | +    {
 | 
                                                        |
| 37 | 37 | parent::__construct($modx, $cfg, $startTime);  | 
                                                        
| 38 | 38 |          $this->extTV = $this->getExtender('tv', true, true); | 
                                                        
| 39 | 39 | }  | 
                                                        
@@ -41,35 +41,35 @@ discard block  | 
                                                    ||
| 41 | 41 | /**  | 
                                                        
| 42 | 42 | * @absctract  | 
                                                        
| 43 | 43 | */  | 
                                                        
| 44 | - public function getDocs($tvlist = '')  | 
                                                        |
| 45 | -    { | 
                                                        |
| 46 | -        if ($tvlist == '') { | 
                                                        |
| 44 | + public function getDocs($tvlist = '')  | 
                                                        |
| 45 | +    {
 | 
                                                        |
| 46 | +        if ($tvlist == '') {
 | 
                                                        |
| 47 | 47 |              $tvlist = $this->getCFGDef('tvList', ''); | 
                                                        
| 48 | 48 | }  | 
                                                        
| 49 | 49 | |
| 50 | 50 | $this->extTV->getAllTV_Name();  | 
                                                        
| 51 | 51 | |
| 52 | -        if ($this->extPaginate = $this->getExtender('paginate')) { | 
                                                        |
| 52 | +        if ($this->extPaginate = $this->getExtender('paginate')) {
 | 
                                                        |
| 53 | 53 | $this->extPaginate->init($this);  | 
                                                        
| 54 | -        } else { | 
                                                        |
| 54 | +        } else {
 | 
                                                        |
| 55 | 55 |              $this->config->setConfig(array('start' => 0)); | 
                                                        
| 56 | 56 | }  | 
                                                        
| 57 | 57 |          $type = $this->getCFGDef('idType', 'parents'); | 
                                                        
| 58 | 58 | $this->_docs = ($type == 'parents') ? $this->getChildrenList() : $this->getDocList();  | 
                                                        
| 59 | -        if ($tvlist != '' && count($this->_docs) > 0) { | 
                                                        |
| 59 | +        if ($tvlist != '' && count($this->_docs) > 0) {
 | 
                                                        |
| 60 | 60 | $tv = $this->extTV->getTVList(array_keys($this->_docs), $tvlist);  | 
                                                        
| 61 | -            if (!is_array($tv)) { | 
                                                        |
| 61 | +            if (!is_array($tv)) {
 | 
                                                        |
| 62 | 62 | $tv = array();  | 
                                                        
| 63 | 63 | }  | 
                                                        
| 64 | -            foreach ($tv as $docID => $TVitem) { | 
                                                        |
| 65 | -                if (isset($this->_docs[$docID]) && is_array($this->_docs[$docID])) { | 
                                                        |
| 64 | +            foreach ($tv as $docID => $TVitem) {
 | 
                                                        |
| 65 | +                if (isset($this->_docs[$docID]) && is_array($this->_docs[$docID])) {
 | 
                                                        |
| 66 | 66 | $this->_docs[$docID] = array_merge($this->_docs[$docID], $TVitem);  | 
                                                        
| 67 | -                } else { | 
                                                        |
| 67 | +                } else {
 | 
                                                        |
| 68 | 68 | unset($this->_docs[$docID]);  | 
                                                        
| 69 | 69 | }  | 
                                                        
| 70 | 70 | }  | 
                                                        
| 71 | 71 | }  | 
                                                        
| 72 | -        if (1 == $this->getCFGDef('tree', '0')) { | 
                                                        |
| 72 | +        if (1 == $this->getCFGDef('tree', '0')) {
 | 
                                                        |
| 73 | 73 |              $this->treeBuild('id', 'parent'); | 
                                                        
| 74 | 74 | }  | 
                                                        
| 75 | 75 | |
@@ -80,24 +80,24 @@ discard block  | 
                                                    ||
| 80 | 80 | * @param string $tpl  | 
                                                        
| 81 | 81 | * @return string  | 
                                                        
| 82 | 82 | */  | 
                                                        
| 83 | - public function _render($tpl = '')  | 
                                                        |
| 84 | -    { | 
                                                        |
| 83 | + public function _render($tpl = '')  | 
                                                        |
| 84 | +    {
 | 
                                                        |
| 85 | 85 | $out = '';  | 
                                                        
| 86 | -        if ($tpl == '') { | 
                                                        |
| 86 | +        if ($tpl == '') {
 | 
                                                        |
| 87 | 87 |              $tpl = $this->getCFGDef('tpl', '@CODE:<a href="[+url+]">[+pagetitle+]</a><br />'); | 
                                                        
| 88 | 88 | }  | 
                                                        
| 89 | -        if ($tpl != '') { | 
                                                        |
| 89 | +        if ($tpl != '') {
 | 
                                                        |
| 90 | 90 |              $date = $this->getCFGDef('dateSource', 'pub_date'); | 
                                                        
| 91 | 91 | |
| 92 | 92 | $this->toPlaceholders(count($this->_docs), 1, "display"); // [+display+] - сколько показано на странице.  | 
                                                        
| 93 | 93 | |
| 94 | 94 | $i = 1;  | 
                                                        
| 95 | 95 |              $sysPlh = $this->renameKeyArr($this->_plh, $this->getCFGDef("sysKey", "dl")); | 
                                                        
| 96 | -            if (count($this->_docs) > 0) { | 
                                                        |
| 96 | +            if (count($this->_docs) > 0) {
 | 
                                                        |
| 97 | 97 | /**  | 
                                                        
| 98 | 98 | * @var $extUser user_DL_Extender  | 
                                                        
| 99 | 99 | */  | 
                                                        
| 100 | -                if ($extUser = $this->getExtender('user')) { | 
                                                        |
| 100 | +                if ($extUser = $this->getExtender('user')) {
 | 
                                                        |
| 101 | 101 |                      $extUser->init($this, array('fields' => $this->getCFGDef("userFields", ""))); | 
                                                        
| 102 | 102 | }  | 
                                                        
| 103 | 103 | |
@@ -116,20 +116,20 @@ discard block  | 
                                                    ||
| 116 | 116 | */  | 
                                                        
| 117 | 117 |                  $extJotCount = $this->getCFGdef('jotcount', 0) ? $this->getExtender('jotcount', true) : null; | 
                                                        
| 118 | 118 | |
| 119 | -                if ($extJotCount) { | 
                                                        |
| 119 | +                if ($extJotCount) {
 | 
                                                        |
| 120 | 120 | $comments = $extJotCount->countComments(array_keys($this->_docs));  | 
                                                        
| 121 | 121 | }  | 
                                                        
| 122 | 122 | |
| 123 | 123 | $this->skippedDocs = 0;  | 
                                                        
| 124 | -                foreach ($this->_docs as $item) { | 
                                                        |
| 124 | +                foreach ($this->_docs as $item) {
 | 
                                                        |
| 125 | 125 | $this->renderTPL = $tpl;  | 
                                                        
| 126 | -                    if ($extUser) { | 
                                                        |
| 126 | +                    if ($extUser) {
 | 
                                                        |
| 127 | 127 | $item = $extUser->setUserData($item); //[+user.id.createdby+], [+user.fullname.publishedby+], [+dl.user.publishedby+]....  | 
                                                        
| 128 | 128 | }  | 
                                                        
| 129 | 129 | |
| 130 | 130 | $item['summary'] = $extSummary ? $this->getSummary($item, $extSummary, 'introtext', 'content') : '';  | 
                                                        
| 131 | 131 | |
| 132 | -                    if ($extJotCount) { | 
                                                        |
| 132 | +                    if ($extJotCount) {
 | 
                                                        |
| 133 | 133 | $item['jotcount'] = APIHelpers::getkey($comments, $item['id'], 0);  | 
                                                        
| 134 | 134 | }  | 
                                                        
| 135 | 135 | |
@@ -139,24 +139,24 @@ discard block  | 
                                                    ||
| 139 | 139 | |
| 140 | 140 | $item['title'] = ($item['menutitle'] == '' ? $item['pagetitle'] : $item['menutitle']);  | 
                                                        
| 141 | 141 | |
| 142 | -                    if ($this->getCFGDef('makeUrl', 1)) { | 
                                                        |
| 143 | -                        if ($item['type'] == 'reference') { | 
                                                        |
| 142 | +                    if ($this->getCFGDef('makeUrl', 1)) {
 | 
                                                        |
| 143 | +                        if ($item['type'] == 'reference') {
 | 
                                                        |
| 144 | 144 | $item['url'] = is_numeric($item['content']) ? $this->modx->makeUrl($item['content'], '', '',  | 
                                                        
| 145 | 145 |                                  $this->getCFGDef('urlScheme', '')) : $item['content']; | 
                                                        
| 146 | -                        } else { | 
                                                        |
| 146 | +                        } else {
 | 
                                                        |
| 147 | 147 |                              $item['url'] = $this->modx->makeUrl($item['id'], '', '', $this->getCFGDef('urlScheme', '')); | 
                                                        
| 148 | 148 | }  | 
                                                        
| 149 | 149 | }  | 
                                                        
| 150 | 150 | |
| 151 | -                    if (isset($item[$date])) { | 
                                                        |
| 152 | -                        if (!$item[$date] && $date == 'pub_date' && isset($item['createdon'])) { | 
                                                        |
| 151 | +                    if (isset($item[$date])) {
 | 
                                                        |
| 152 | +                        if (!$item[$date] && $date == 'pub_date' && isset($item['createdon'])) {
 | 
                                                        |
| 153 | 153 | $date = 'createdon';  | 
                                                        
| 154 | 154 | }  | 
                                                        
| 155 | 155 | $_date = is_numeric($item[$date]) && $item[$date] == (int)$item[$date] ? $item[$date] : strtotime($item[$date]);  | 
                                                        
| 156 | -                        if ($_date !== false) { | 
                                                        |
| 156 | +                        if ($_date !== false) {
 | 
                                                        |
| 157 | 157 | $_date = $_date + $this->modx->config['server_offset_time'];  | 
                                                        
| 158 | 158 |                              $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'); | 
                                                        
| 159 | -                            if ($dateFormat) { | 
                                                        |
| 159 | +                            if ($dateFormat) {
 | 
                                                        |
| 160 | 160 | $item['date'] = strftime($dateFormat, $_date);  | 
                                                        
| 161 | 161 | }  | 
                                                        
| 162 | 162 | }  | 
                                                        
@@ -165,30 +165,30 @@ discard block  | 
                                                    ||
| 165 | 165 | $findTpl = $this->renderTPL;  | 
                                                        
| 166 | 166 | $tmp = $this->uniformPrepare($item, $i);  | 
                                                        
| 167 | 167 | extract($tmp, EXTR_SKIP);  | 
                                                        
| 168 | -                    if ($this->renderTPL == '') { | 
                                                        |
| 168 | +                    if ($this->renderTPL == '') {
 | 
                                                        |
| 169 | 169 | $this->renderTPL = $findTpl;  | 
                                                        
| 170 | 170 | }  | 
                                                        
| 171 | 171 | |
| 172 | -                    if ($extPrepare) { | 
                                                        |
| 172 | +                    if ($extPrepare) {
 | 
                                                        |
| 173 | 173 | $item = $extPrepare->init($this, array(  | 
                                                        
| 174 | 174 | 'data' => $item,  | 
                                                        
| 175 | 175 | 'nameParam' => 'prepare'  | 
                                                        
| 176 | 176 | ));  | 
                                                        
| 177 | -                        if (is_bool($item) && $item === false) { | 
                                                        |
| 177 | +                        if (is_bool($item) && $item === false) {
 | 
                                                        |
| 178 | 178 | $this->skippedDocs++;  | 
                                                        
| 179 | 179 | continue;  | 
                                                        
| 180 | 180 | }  | 
                                                        
| 181 | 181 | }  | 
                                                        
| 182 | 182 | $tmp = $this->parseChunk($this->renderTPL, $item);  | 
                                                        
| 183 | 183 | |
| 184 | -                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) { | 
                                                        |
| 184 | +                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
 | 
                                                        |
| 185 | 185 | $this->toPlaceholders($tmp, 1,  | 
                                                        
| 186 | 186 | "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page  | 
                                                        
| 187 | 187 | }  | 
                                                        
| 188 | 188 | $out .= $tmp;  | 
                                                        
| 189 | 189 | $i++;  | 
                                                        
| 190 | 190 | }  | 
                                                        
| 191 | -            } else { | 
                                                        |
| 191 | +            } else {
 | 
                                                        |
| 192 | 192 |                  $noneTPL = $this->getCFGDef("noneTPL", ""); | 
                                                        
| 193 | 193 | $out = ($noneTPL != '') ? $this->parseChunk($noneTPL, $sysPlh) : '';  | 
                                                        
| 194 | 194 | }  | 
                                                        
@@ -204,8 +204,8 @@ discard block  | 
                                                    ||
| 204 | 204 | * @param array $array  | 
                                                        
| 205 | 205 | * @return string  | 
                                                        
| 206 | 206 | */  | 
                                                        
| 207 | - public function getJSON($data, $fields, $array = array())  | 
                                                        |
| 208 | -    { | 
                                                        |
| 207 | + public function getJSON($data, $fields, $array = array())  | 
                                                        |
| 208 | +    {
 | 
                                                        |
| 209 | 209 | $out = array();  | 
                                                        
| 210 | 210 |          $fields = is_array($fields) ? $fields : explode(",", $fields); | 
                                                        
| 211 | 211 |          $date = $this->getCFGDef('dateSource', 'pub_date'); | 
                                                        
@@ -224,49 +224,49 @@ discard block  | 
                                                    ||
| 224 | 224 | */  | 
                                                        
| 225 | 225 |          $extE = $this->getExtender('e', true, true); | 
                                                        
| 226 | 226 | |
| 227 | -        foreach ($data as $num => $row) { | 
                                                        |
| 228 | -            if ((array('1') == $fields || in_array('summary', $fields)) && $extSummary) { | 
                                                        |
| 227 | +        foreach ($data as $num => $row) {
 | 
                                                        |
| 228 | +            if ((array('1') == $fields || in_array('summary', $fields)) && $extSummary) {
 | 
                                                        |
| 229 | 229 | $row['summary'] = $this->getSummary($row, $extSummary, 'introtext', 'content');  | 
                                                        
| 230 | 230 | }  | 
                                                        
| 231 | 231 | |
| 232 | -            if (array('1') == $fields || in_array('date', $fields)) { | 
                                                        |
| 233 | -                if (isset($row[$date])) { | 
                                                        |
| 234 | -                    if (!$row[$date] && $date == 'pub_date' && isset($row['createdon'])) { | 
                                                        |
| 232 | +            if (array('1') == $fields || in_array('date', $fields)) {
 | 
                                                        |
| 233 | +                if (isset($row[$date])) {
 | 
                                                        |
| 234 | +                    if (!$row[$date] && $date == 'pub_date' && isset($row['createdon'])) {
 | 
                                                        |
| 235 | 235 | $date = 'createdon';  | 
                                                        
| 236 | 236 | }  | 
                                                        
| 237 | 237 | $_date = is_numeric($row[$date]) && $row[$date] == (int)$row[$date] ? $row[$date] : strtotime($row[$date]);  | 
                                                        
| 238 | -                    if ($_date !== false) { | 
                                                        |
| 238 | +                    if ($_date !== false) {
 | 
                                                        |
| 239 | 239 | $_date = $_date + $this->modx->config['server_offset_time'];  | 
                                                        
| 240 | 240 |                          $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'); | 
                                                        
| 241 | -                        if ($dateFormat) { | 
                                                        |
| 241 | +                        if ($dateFormat) {
 | 
                                                        |
| 242 | 242 | $row['date'] = strftime($dateFormat, $_date);  | 
                                                        
| 243 | 243 | }  | 
                                                        
| 244 | 244 | }  | 
                                                        
| 245 | 245 | }  | 
                                                        
| 246 | 246 | }  | 
                                                        
| 247 | 247 | |
| 248 | -            if (array('1') == $fields || in_array(array('menutitle', 'pagetitle'), $fields)) { | 
                                                        |
| 248 | +            if (array('1') == $fields || in_array(array('menutitle', 'pagetitle'), $fields)) {
 | 
                                                        |
| 249 | 249 | $row['title'] = ($row['menutitle'] == '' ? $row['pagetitle'] : $row['menutitle']);  | 
                                                        
| 250 | 250 | }  | 
                                                        
| 251 | 251 |              if ((bool)$this->getCFGDef('makeUrl', 1) && (array('1') == $fields || in_array(array('content', 'type'), | 
                                                        
| 252 | 252 | $fields))  | 
                                                        
| 253 | -            ) { | 
                                                        |
| 254 | -                if ($row['type'] == 'reference') { | 
                                                        |
| 253 | +            ) {
 | 
                                                        |
| 254 | +                if ($row['type'] == 'reference') {
 | 
                                                        |
| 255 | 255 | $row['url'] = is_numeric($row['content']) ? $this->modx->makeUrl($row['content'], '', '',  | 
                                                        
| 256 | 256 |                          $this->getCFGDef('urlScheme', '')) : $row['content']; | 
                                                        
| 257 | -                } else { | 
                                                        |
| 257 | +                } else {
 | 
                                                        |
| 258 | 258 |                      $row['url'] = $this->modx->makeUrl($row['id'], '', '', $this->getCFGDef('urlScheme', '')); | 
                                                        
| 259 | 259 | }  | 
                                                        
| 260 | 260 | }  | 
                                                        
| 261 | -            if ($extE && $tmp = $extE->init($this, array('data' => $row))) { | 
                                                        |
| 262 | -                if (is_array($tmp)) { | 
                                                        |
| 261 | +            if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
 | 
                                                        |
| 262 | +                if (is_array($tmp)) {
 | 
                                                        |
| 263 | 263 | $row = $tmp;  | 
                                                        
| 264 | 264 | }  | 
                                                        
| 265 | 265 | }  | 
                                                        
| 266 | 266 | |
| 267 | -            if ($extPrepare) { | 
                                                        |
| 267 | +            if ($extPrepare) {
 | 
                                                        |
| 268 | 268 |                  $row = $extPrepare->init($this, array('data' => $row)); | 
                                                        
| 269 | -                if (is_bool($row) && $row === false) { | 
                                                        |
| 269 | +                if (is_bool($row) && $row === false) {
 | 
                                                        |
| 270 | 270 | continue;  | 
                                                        
| 271 | 271 | }  | 
                                                        
| 272 | 272 | }  | 
                                                        
@@ -279,36 +279,35 @@ discard block  | 
                                                    ||
| 279 | 279 | /**  | 
                                                        
| 280 | 280 | * @abstract  | 
                                                        
| 281 | 281 | */  | 
                                                        
| 282 | - public function getChildrenCount()  | 
                                                        |
| 283 | -    { | 
                                                        |
| 282 | + public function getChildrenCount()  | 
                                                        |
| 283 | +    {
 | 
                                                        |
| 284 | 284 | $out = 0;  | 
                                                        
| 285 | 285 | $sanitarInIDs = $this->sanitarIn($this->IDs);  | 
                                                        
| 286 | -        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { | 
                                                        |
| 286 | +        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
 | 
                                                        |
| 287 | 287 |              $q_true = $this->getCFGDef('ignoreEmpty', '0'); | 
                                                        
| 288 | 288 |              $q_true = $q_true ? $q_true : $this->getCFGDef('idType', 'parents') == 'parents'; | 
                                                        
| 289 | 289 |              $where = $this->getCFGDef('addWhereList', ''); | 
                                                        
| 290 | 290 | $where = sqlHelper::trimLogicalOp($where);  | 
                                                        
| 291 | 291 | $where = ($where ? $where . ' AND ' : '') . $this->_filters['where'];  | 
                                                        
| 292 | -            if ($where != '' && $this->_filters['where'] != '') { | 
                                                        |
| 292 | +            if ($where != '' && $this->_filters['where'] != '') {
 | 
                                                        |
| 293 | 293 | $where .= " AND ";  | 
                                                        
| 294 | 294 | }  | 
                                                        
| 295 | 295 | $where = sqlHelper::trimLogicalOp($where);  | 
                                                        
| 296 | 296 | |
| 297 | 297 |              $where = "WHERE {$where}"; | 
                                                        
| 298 | 298 | $whereArr = array();  | 
                                                        
| 299 | -            if (!$this->getCFGDef('showNoPublish', 0)) { | 
                                                        |
| 299 | +            if (!$this->getCFGDef('showNoPublish', 0)) {
 | 
                                                        |
| 300 | 300 | $whereArr[] = "c.deleted=0 AND c.published=1";  | 
                                                        
| 301 | - }  | 
                                                        |
| 302 | -            else{ | 
                                                        |
| 301 | +            } else {
 | 
                                                        |
| 303 | 302 | $q_true = 1;  | 
                                                        
| 304 | 303 | }  | 
                                                        
| 305 | 304 | |
| 306 | 305 |              $tbl_site_content = $this->getTable('site_content', 'c'); | 
                                                        
| 307 | 306 | |
| 308 | -            if ($sanitarInIDs != "''") { | 
                                                        |
| 309 | -                switch ($this->getCFGDef('idType', 'parents')) { | 
                                                        |
| 307 | +            if ($sanitarInIDs != "''") {
 | 
                                                        |
| 308 | +                switch ($this->getCFGDef('idType', 'parents')) {
 | 
                                                        |
| 310 | 309 | case 'parents':  | 
                                                        
| 311 | -                        switch ($this->getCFGDef('showParent', '0')) { | 
                                                        |
| 310 | +                        switch ($this->getCFGDef('showParent', '0')) {
 | 
                                                        |
| 312 | 311 | case '-1':  | 
                                                        
| 313 | 312 |                                  $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")"; | 
                                                        
| 314 | 313 | break;  | 
                                                        
@@ -320,10 +319,10 @@ discard block  | 
                                                    ||
| 320 | 319 |                                  $tmpWhere = "(c.parent IN ({$sanitarInIDs}) OR c.id IN({$sanitarInIDs}))"; | 
                                                        
| 321 | 320 | break;  | 
                                                        
| 322 | 321 | }  | 
                                                        
| 323 | -                        if (($addDocs = $this->getCFGDef('documents', '')) != '') { | 
                                                        |
| 322 | +                        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
 | 
                                                        |
| 324 | 323 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));  | 
                                                        
| 325 | 324 |                              $whereArr[] = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))"; | 
                                                        
| 326 | -                        } else { | 
                                                        |
| 325 | +                        } else {
 | 
                                                        |
| 327 | 326 | $whereArr[] = $tmpWhere;  | 
                                                        
| 328 | 327 | }  | 
                                                        
| 329 | 328 | |
@@ -338,14 +337,14 @@ discard block  | 
                                                    ||
| 338 | 337 | |
| 339 | 338 | $q_true = $q_true ? $q_true : trim($where) != 'WHERE';  | 
                                                        
| 340 | 339 | |
| 341 | -            if (trim($where) != 'WHERE') { | 
                                                        |
| 340 | +            if (trim($where) != 'WHERE') {
 | 
                                                        |
| 342 | 341 | $where .= " AND ";  | 
                                                        
| 343 | 342 | }  | 
                                                        
| 344 | 343 | |
| 345 | 344 |              $where .= implode(" AND ", $whereArr); | 
                                                        
| 346 | 345 | $where = sqlHelper::trimLogicalOp($where);  | 
                                                        
| 347 | 346 | |
| 348 | -            if (trim($where) == 'WHERE') { | 
                                                        |
| 347 | +            if (trim($where) == 'WHERE') {
 | 
                                                        |
| 349 | 348 | $where = '';  | 
                                                        
| 350 | 349 | }  | 
                                                        
| 351 | 350 |              $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); | 
                                                        
@@ -354,11 +353,10 @@ discard block  | 
                                                    ||
| 354 | 353 | |
| 355 | 354 | $q_true = $q_true ? $q_true : $group != '';  | 
                                                        
| 356 | 355 | |
| 357 | -            if ( $q_true ){ | 
                                                        |
| 356 | +            if ( $q_true ) {
 | 
                                                        |
| 358 | 357 |                  $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group}) as `tmp`"); | 
                                                        
| 359 | 358 | $out = $this->modx->db->getValue($rs);  | 
                                                        
| 360 | - }  | 
                                                        |
| 361 | -            else { | 
                                                        |
| 359 | +            } else {
 | 
                                                        |
| 362 | 360 | $out = count($this->IDs);  | 
                                                        
| 363 | 361 | }  | 
                                                        
| 364 | 362 | }  | 
                                                        
@@ -369,11 +367,11 @@ discard block  | 
                                                    ||
| 369 | 367 | /**  | 
                                                        
| 370 | 368 | * @return array  | 
                                                        
| 371 | 369 | */  | 
                                                        
| 372 | - protected function getDocList()  | 
                                                        |
| 373 | -    { | 
                                                        |
| 370 | + protected function getDocList()  | 
                                                        |
| 371 | +    {
 | 
                                                        |
| 374 | 372 | $out = array();  | 
                                                        
| 375 | 373 | $sanitarInIDs = $this->sanitarIn($this->IDs);  | 
                                                        
| 376 | -        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { | 
                                                        |
| 374 | +        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
 | 
                                                        |
| 377 | 375 |              $where = $this->getCFGDef('addWhereList', ''); | 
                                                        
| 378 | 376 | $where = sqlHelper::trimLogicalOp($where);  | 
                                                        
| 379 | 377 | |
@@ -381,21 +379,21 @@ discard block  | 
                                                    ||
| 381 | 379 | $where = sqlHelper::trimLogicalOp($where);  | 
                                                        
| 382 | 380 | |
| 383 | 381 |              $tbl_site_content = $this->getTable('site_content', 'c'); | 
                                                        
| 384 | -            if ($sanitarInIDs != "''") { | 
                                                        |
| 382 | +            if ($sanitarInIDs != "''") {
 | 
                                                        |
| 385 | 383 |                  $where .= ($where ? " AND " : "") . "c.id IN ({$sanitarInIDs}) AND"; | 
                                                        
| 386 | 384 | }  | 
                                                        
| 387 | 385 | $where = sqlHelper::trimLogicalOp($where);  | 
                                                        
| 388 | 386 | |
| 389 | -            if ($this->getCFGDef('showNoPublish', 0)) { | 
                                                        |
| 390 | -                if ($where != '') { | 
                                                        |
| 387 | +            if ($this->getCFGDef('showNoPublish', 0)) {
 | 
                                                        |
| 388 | +                if ($where != '') {
 | 
                                                        |
| 391 | 389 |                      $where = "WHERE {$where}"; | 
                                                        
| 392 | -                } else { | 
                                                        |
| 390 | +                } else {
 | 
                                                        |
| 393 | 391 | $where = '';  | 
                                                        
| 394 | 392 | }  | 
                                                        
| 395 | -            } else { | 
                                                        |
| 396 | -                if ($where != '') { | 
                                                        |
| 393 | +            } else {
 | 
                                                        |
| 394 | +                if ($where != '') {
 | 
                                                        |
| 397 | 395 |                      $where = "WHERE {$where} AND "; | 
                                                        
| 398 | -                } else { | 
                                                        |
| 396 | +                } else {
 | 
                                                        |
| 399 | 397 |                      $where = "WHERE {$where} "; | 
                                                        
| 400 | 398 | }  | 
                                                        
| 401 | 399 | $where .= "c.deleted=0 AND c.published=1";  | 
                                                        
@@ -414,7 +412,7 @@ discard block  | 
                                                    ||
| 414 | 412 | |
| 415 | 413 | $rows = $this->modx->db->makeArray($rs);  | 
                                                        
| 416 | 414 | |
| 417 | -            foreach ($rows as $item) { | 
                                                        |
| 415 | +            foreach ($rows as $item) {
 | 
                                                        |
| 418 | 416 | $out[$item['id']] = $item;  | 
                                                        
| 419 | 417 | }  | 
                                                        
| 420 | 418 | }  | 
                                                        
@@ -426,19 +424,19 @@ discard block  | 
                                                    ||
| 426 | 424 | * @param string $id  | 
                                                        
| 427 | 425 | * @return array  | 
                                                        
| 428 | 426 | */  | 
                                                        
| 429 | - public function getChildrenFolder($id)  | 
                                                        |
| 430 | -    { | 
                                                        |
| 427 | + public function getChildrenFolder($id)  | 
                                                        |
| 428 | +    {
 | 
                                                        |
| 431 | 429 |          $where = $this->getCFGDef('addWhereFolder', ''); | 
                                                        
| 432 | 430 | $where = sqlHelper::trimLogicalOp($where);  | 
                                                        
| 433 | -        if ($where != '') { | 
                                                        |
| 431 | +        if ($where != '') {
 | 
                                                        |
| 434 | 432 | $where .= " AND ";  | 
                                                        
| 435 | 433 | }  | 
                                                        
| 436 | 434 | |
| 437 | 435 |          $tbl_site_content = $this->getTable('site_content', 'c'); | 
                                                        
| 438 | 436 | $sanitarInIDs = $this->sanitarIn($id);  | 
                                                        
| 439 | -        if ($this->getCFGDef('showNoPublish', 0)) { | 
                                                        |
| 437 | +        if ($this->getCFGDef('showNoPublish', 0)) {
 | 
                                                        |
| 440 | 438 |              $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1"; | 
                                                        
| 441 | -        } else { | 
                                                        |
| 439 | +        } else {
 | 
                                                        |
| 442 | 440 |              $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1"; | 
                                                        
| 443 | 441 | }  | 
                                                        
| 444 | 442 | |
@@ -446,7 +444,7 @@ discard block  | 
                                                    ||
| 446 | 444 | |
| 447 | 445 | $rows = $this->modx->db->makeArray($rs);  | 
                                                        
| 448 | 446 | $out = array();  | 
                                                        
| 449 | -        foreach ($rows as $item) { | 
                                                        |
| 447 | +        foreach ($rows as $item) {
 | 
                                                        |
| 450 | 448 | $out[] = $item['id'];  | 
                                                        
| 451 | 449 | }  | 
                                                        
| 452 | 450 | |
@@ -458,10 +456,10 @@ discard block  | 
                                                    ||
| 458 | 456 | * @param $sort  | 
                                                        
| 459 | 457 | * @return array  | 
                                                        
| 460 | 458 | */  | 
                                                        
| 461 | - protected function injectSortByTV($table, $sort)  | 
                                                        |
| 462 | -    { | 
                                                        |
| 459 | + protected function injectSortByTV($table, $sort)  | 
                                                        |
| 460 | +    {
 | 
                                                        |
| 463 | 461 |          $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort); | 
                                                        
| 464 | -        if (!is_array($out) || empty($out)) { | 
                                                        |
| 462 | +        if (!is_array($out) || empty($out)) {
 | 
                                                        |
| 465 | 463 | $out = array($table, $sort);  | 
                                                        
| 466 | 464 | }  | 
                                                        
| 467 | 465 | |
@@ -471,19 +469,19 @@ discard block  | 
                                                    ||
| 471 | 469 | /**  | 
                                                        
| 472 | 470 | * @return array  | 
                                                        
| 473 | 471 | */  | 
                                                        
| 474 | - protected function getChildrenList()  | 
                                                        |
| 475 | -    { | 
                                                        |
| 472 | + protected function getChildrenList()  | 
                                                        |
| 473 | +    {
 | 
                                                        |
| 476 | 474 | $where = array();  | 
                                                        
| 477 | 475 | $out = array();  | 
                                                        
| 478 | 476 | |
| 479 | 477 |          $tmpWhere = $this->getCFGDef('addWhereList', ''); | 
                                                        
| 480 | 478 | $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);  | 
                                                        
| 481 | -        if (!empty($tmpWhere)) { | 
                                                        |
| 479 | +        if (!empty($tmpWhere)) {
 | 
                                                        |
| 482 | 480 | $where[] = $tmpWhere;  | 
                                                        
| 483 | 481 | }  | 
                                                        
| 484 | 482 | |
| 485 | 483 | $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']);  | 
                                                        
| 486 | -        if (!empty($tmpWhere)) { | 
                                                        |
| 484 | +        if (!empty($tmpWhere)) {
 | 
                                                        |
| 487 | 485 | $where[] = $tmpWhere;  | 
                                                        
| 488 | 486 | }  | 
                                                        
| 489 | 487 | |
@@ -494,8 +492,8 @@ discard block  | 
                                                    ||
| 494 | 492 | $sanitarInIDs = $this->sanitarIn($this->IDs);  | 
                                                        
| 495 | 493 | |
| 496 | 494 | $tmpWhere = null;  | 
                                                        
| 497 | -        if ($sanitarInIDs != "''") { | 
                                                        |
| 498 | -            switch ($this->getCFGDef('showParent', '0')) { | 
                                                        |
| 495 | +        if ($sanitarInIDs != "''") {
 | 
                                                        |
| 496 | +            switch ($this->getCFGDef('showParent', '0')) {
 | 
                                                        |
| 499 | 497 | case '-1':  | 
                                                        
| 500 | 498 |                      $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")"; | 
                                                        
| 501 | 499 | break;  | 
                                                        
@@ -508,29 +506,29 @@ discard block  | 
                                                    ||
| 508 | 506 | break;  | 
                                                        
| 509 | 507 | }  | 
                                                        
| 510 | 508 | }  | 
                                                        
| 511 | -        if (($addDocs = $this->getCFGDef('documents', '')) != '') { | 
                                                        |
| 509 | +        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
 | 
                                                        |
| 512 | 510 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));  | 
                                                        
| 513 | -            if (empty($tmpWhere)) { | 
                                                        |
| 511 | +            if (empty($tmpWhere)) {
 | 
                                                        |
| 514 | 512 |                  $tmpWhere = "c.id IN({$addDocs})"; | 
                                                        
| 515 | -            } else { | 
                                                        |
| 513 | +            } else {
 | 
                                                        |
| 516 | 514 |                  $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))"; | 
                                                        
| 517 | 515 | }  | 
                                                        
| 518 | 516 | }  | 
                                                        
| 519 | -        if (!empty($tmpWhere)) { | 
                                                        |
| 517 | +        if (!empty($tmpWhere)) {
 | 
                                                        |
| 520 | 518 | $where[] = $tmpWhere;  | 
                                                        
| 521 | 519 | }  | 
                                                        
| 522 | -        if (!$this->getCFGDef('showNoPublish', 0)) { | 
                                                        |
| 520 | +        if (!$this->getCFGDef('showNoPublish', 0)) {
 | 
                                                        |
| 523 | 521 | $where[] = "c.deleted=0 AND c.published=1";  | 
                                                        
| 524 | 522 | }  | 
                                                        
| 525 | -        if (!empty($where)) { | 
                                                        |
| 523 | +        if (!empty($where)) {
 | 
                                                        |
| 526 | 524 |              $where = "WHERE " . implode(" AND ", $where); | 
                                                        
| 527 | -        } else { | 
                                                        |
| 525 | +        } else {
 | 
                                                        |
| 528 | 526 | $where = '';  | 
                                                        
| 529 | 527 | }  | 
                                                        
| 530 | 528 |          $fields = $this->getCFGDef('selectFields', 'c.*'); | 
                                                        
| 531 | 529 |          $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); | 
                                                        
| 532 | 530 | |
| 533 | -        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { | 
                                                        |
| 531 | +        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
 | 
                                                        |
| 534 | 532 |              $sql = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " . | 
                                                        
| 535 | 533 | $group . " " .  | 
                                                        
| 536 | 534 | $sort . " " .  | 
                                                        
@@ -539,7 +537,7 @@ discard block  | 
                                                    ||
| 539 | 537 | |
| 540 | 538 | $rows = $this->modx->db->makeArray($sql);  | 
                                                        
| 541 | 539 | |
| 542 | -            foreach ($rows as $item) { | 
                                                        |
| 540 | +            foreach ($rows as $item) {
 | 
                                                        |
| 543 | 541 | $out[$item['id']] = $item;  | 
                                                        
| 544 | 542 | }  | 
                                                        
| 545 | 543 | }  | 
                                                        
@@ -552,10 +550,10 @@ discard block  | 
                                                    ||
| 552 | 550 | * @param string $type  | 
                                                        
| 553 | 551 | * @return string  | 
                                                        
| 554 | 552 | */  | 
                                                        
| 555 | - public function changeSortType($field, $type)  | 
                                                        |
| 556 | -    { | 
                                                        |
| 553 | + public function changeSortType($field, $type)  | 
                                                        |
| 554 | +    {
 | 
                                                        |
| 557 | 555 | $type = trim($type);  | 
                                                        
| 558 | -        switch (strtoupper($type)) { | 
                                                        |
| 556 | +        switch (strtoupper($type)) {
 | 
                                                        |
| 559 | 557 | case 'TVDATETIME':  | 
                                                        
| 560 | 558 |                  $field = "STR_TO_DATE(" . $field . ",'%d-%m-%Y %H:%i:%s')"; | 
                                                        
| 561 | 559 | break;  | 
                                                        
@@ -294,7 +294,7 @@ discard block  | 
                                                    ||
| 294 | 294 | }  | 
                                                        
| 295 | 295 | $where = sqlHelper::trimLogicalOp($where);  | 
                                                        
| 296 | 296 | |
| 297 | -            $where = "WHERE {$where}"; | 
                                                        |
| 297 | +            $where = "where {$where}"; | 
                                                        |
| 298 | 298 | $whereArr = array();  | 
                                                        
| 299 | 299 |              if (!$this->getCFGDef('showNoPublish', 0)) { | 
                                                        
| 300 | 300 | $whereArr[] = "c.deleted=0 AND c.published=1";  | 
                                                        
@@ -388,15 +388,15 @@ discard block  | 
                                                    ||
| 388 | 388 | |
| 389 | 389 |              if ($this->getCFGDef('showNoPublish', 0)) { | 
                                                        
| 390 | 390 |                  if ($where != '') { | 
                                                        
| 391 | -                    $where = "WHERE {$where}"; | 
                                                        |
| 391 | +                    $where = "where {$where}"; | 
                                                        |
| 392 | 392 |                  } else { | 
                                                        
| 393 | 393 | $where = '';  | 
                                                        
| 394 | 394 | }  | 
                                                        
| 395 | 395 |              } else { | 
                                                        
| 396 | 396 |                  if ($where != '') { | 
                                                        
| 397 | -                    $where = "WHERE {$where} AND "; | 
                                                        |
| 397 | +                    $where = "where {$where} AND "; | 
                                                        |
| 398 | 398 |                  } else { | 
                                                        
| 399 | -                    $where = "WHERE {$where} "; | 
                                                        |
| 399 | +                    $where = "where {$where} "; | 
                                                        |
| 400 | 400 | }  | 
                                                        
| 401 | 401 | $where .= "c.deleted=0 AND c.published=1";  | 
                                                        
| 402 | 402 | }  | 
                                                        
@@ -410,7 +410,7 @@ discard block  | 
                                                    ||
| 410 | 410 | |
| 411 | 411 |              $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0)); | 
                                                        
| 412 | 412 | |
| 413 | -            $rs = $this->dbQuery("SELECT {$fields} FROM {$tbl_site_content} {$where} {$group} {$sort} {$limit}"); | 
                                                        |
| 413 | +            $rs = $this->dbQuery("select {$fields} FROM {$tbl_site_content} {$where} {$group} {$sort} {$limit}"); | 
                                                        |
| 414 | 414 | |
| 415 | 415 | $rows = $this->modx->db->makeArray($rs);  | 
                                                        
| 416 | 416 | |
@@ -437,9 +437,9 @@ discard block  | 
                                                    ||
| 437 | 437 |          $tbl_site_content = $this->getTable('site_content', 'c'); | 
                                                        
| 438 | 438 | $sanitarInIDs = $this->sanitarIn($id);  | 
                                                        
| 439 | 439 |          if ($this->getCFGDef('showNoPublish', 0)) { | 
                                                        
| 440 | -            $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1"; | 
                                                        |
| 440 | +            $where = "where {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1"; | 
                                                        |
| 441 | 441 |          } else { | 
                                                        
| 442 | -            $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1"; | 
                                                        |
| 442 | +            $where = "where {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1"; | 
                                                        |
| 443 | 443 | }  | 
                                                        
| 444 | 444 | |
| 445 | 445 |          $rs = $this->dbQuery("SELECT id FROM {$tbl_site_content} {$where}"); | 
                                                        
@@ -531,7 +531,7 @@ discard block  | 
                                                    ||
| 531 | 531 |          $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); | 
                                                        
| 532 | 532 | |
| 533 | 533 |          if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { | 
                                                        
| 534 | -            $sql = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " . | 
                                                        |
| 534 | +            $sql = $this->dbQuery("select {$fields} FROM " . $from . " " . $where . " " . | 
                                                        |
| 535 | 535 | $group . " " .  | 
                                                        
| 536 | 536 | $sort . " " .  | 
                                                        
| 537 | 537 |                  $this->LimitSQL($this->getCFGDef('queryLimit', 0)) | 
                                                        
@@ -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 | */  | 
                                                        
@@ -34,11 +34,11 @@ discard block  | 
                                                    ||
| 34 | 34 | /**  | 
                                                        
| 35 | 35 | * @absctract  | 
                                                        
| 36 | 36 | */  | 
                                                        
| 37 | - public function getDocs($tvlist = '')  | 
                                                        |
| 38 | -    { | 
                                                        |
| 39 | -        if ($this->checkExtender('paginate')) { | 
                                                        |
| 37 | + public function getDocs($tvlist = '')  | 
                                                        |
| 38 | +    {
 | 
                                                        |
| 39 | +        if ($this->checkExtender('paginate')) {
 | 
                                                        |
| 40 | 40 | $this->extender['paginate']->init($this);  | 
                                                        
| 41 | -        } else { | 
                                                        |
| 41 | +        } else {
 | 
                                                        |
| 42 | 42 |              $this->config->setConfig(array('start' => 0)); | 
                                                        
| 43 | 43 | }  | 
                                                        
| 44 | 44 |          $type = $this->getCFGDef('idType', 'parents'); | 
                                                        
@@ -51,25 +51,25 @@ discard block  | 
                                                    ||
| 51 | 51 | * @param string $tpl  | 
                                                        
| 52 | 52 | * @return string  | 
                                                        
| 53 | 53 | */  | 
                                                        
| 54 | - public function _render($tpl = '')  | 
                                                        |
| 55 | -    { | 
                                                        |
| 54 | + public function _render($tpl = '')  | 
                                                        |
| 55 | +    {
 | 
                                                        |
| 56 | 56 | $out = '';  | 
                                                        
| 57 | -        if ($tpl == '') { | 
                                                        |
| 57 | +        if ($tpl == '') {
 | 
                                                        |
| 58 | 58 |              $tpl = $this->getCFGDef('tpl', ''); | 
                                                        
| 59 | 59 | }  | 
                                                        
| 60 | -        if ($tpl != '') { | 
                                                        |
| 60 | +        if ($tpl != '') {
 | 
                                                        |
| 61 | 61 | $this->toPlaceholders(count($this->_docs), 1, "display"); // [+display+] - сколько показано на странице.  | 
                                                        
| 62 | 62 | |
| 63 | 63 | $i = 1;  | 
                                                        
| 64 | 64 |              $sysPlh = $this->renameKeyArr($this->_plh, $this->getCFGDef("sysKey", "dl")); | 
                                                        
| 65 | 65 |              $noneTPL = $this->getCFGDef("noneTPL", ""); | 
                                                        
| 66 | -            if (count($this->_docs) == 0 && $noneTPL != '') { | 
                                                        |
| 66 | +            if (count($this->_docs) == 0 && $noneTPL != '') {
 | 
                                                        |
| 67 | 67 | $out = $this->parseChunk($noneTPL, $sysPlh);  | 
                                                        
| 68 | -            } else { | 
                                                        |
| 68 | +            } else {
 | 
                                                        |
| 69 | 69 | /**  | 
                                                        
| 70 | 70 | * @var $extUser user_DL_Extender  | 
                                                        
| 71 | 71 | */  | 
                                                        
| 72 | -                if ($extUser = $this->getExtender('user')) { | 
                                                        |
| 72 | +                if ($extUser = $this->getExtender('user')) {
 | 
                                                        |
| 73 | 73 |                      $extUser->init($this, array('fields' => $this->getCFGDef("userFields", ""))); | 
                                                        
| 74 | 74 | }  | 
                                                        
| 75 | 75 | |
@@ -83,9 +83,9 @@ discard block  | 
                                                    ||
| 83 | 83 | */  | 
                                                        
| 84 | 84 |                  $extPrepare = $this->getExtender('prepare'); | 
                                                        
| 85 | 85 | $this->skippedDocs = 0;  | 
                                                        
| 86 | -                foreach ($this->_docs as $item) { | 
                                                        |
| 86 | +                foreach ($this->_docs as $item) {
 | 
                                                        |
| 87 | 87 | $this->renderTPL = $tpl;  | 
                                                        
| 88 | -                    if ($extUser) { | 
                                                        |
| 88 | +                    if ($extUser) {
 | 
                                                        |
| 89 | 89 | $item = $extUser->setUserData($item); //[+user.id.createdby+], [+user.fullname.publishedby+], [+dl.user.publishedby+]....  | 
                                                        
| 90 | 90 | }  | 
                                                        
| 91 | 91 | |
@@ -98,12 +98,12 @@ discard block  | 
                                                    ||
| 98 | 98 | "dl") . '.iteration'] = $i; //[+iteration+] - Number element. Starting from zero  | 
                                                        
| 99 | 99 | |
| 100 | 100 |                      $date = $this->getCFGDef('dateSource', 'pub_date'); | 
                                                        
| 101 | -                    if (isset($item[$date])) { | 
                                                        |
| 101 | +                    if (isset($item[$date])) {
 | 
                                                        |
| 102 | 102 | $_date = is_numeric($item[$date]) && $item[$date] == (int)$item[$date] ? $item[$date] : strtotime($item[$date]);  | 
                                                        
| 103 | -                        if ($_date !== false) { | 
                                                        |
| 103 | +                        if ($_date !== false) {
 | 
                                                        |
| 104 | 104 | $_date = $_date + $this->modx->config['server_offset_time'];  | 
                                                        
| 105 | 105 |                              $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'); | 
                                                        
| 106 | -                            if ($dateFormat) { | 
                                                        |
| 106 | +                            if ($dateFormat) {
 | 
                                                        |
| 107 | 107 | $item['date'] = strftime($dateFormat, $_date);  | 
                                                        
| 108 | 108 | }  | 
                                                        
| 109 | 109 | }  | 
                                                        
@@ -112,22 +112,22 @@ discard block  | 
                                                    ||
| 112 | 112 | $findTpl = $this->renderTPL;  | 
                                                        
| 113 | 113 | $tmp = $this->uniformPrepare($item, $i);  | 
                                                        
| 114 | 114 | extract($tmp, EXTR_SKIP);  | 
                                                        
| 115 | -                    if ($this->renderTPL == '') { | 
                                                        |
| 115 | +                    if ($this->renderTPL == '') {
 | 
                                                        |
| 116 | 116 | $this->renderTPL = $findTpl;  | 
                                                        
| 117 | 117 | }  | 
                                                        
| 118 | 118 | |
| 119 | -                    if ($extPrepare) { | 
                                                        |
| 119 | +                    if ($extPrepare) {
 | 
                                                        |
| 120 | 120 | $item = $extPrepare->init($this, array(  | 
                                                        
| 121 | 121 | 'data' => $item,  | 
                                                        
| 122 | 122 | 'nameParam' => 'prepare'  | 
                                                        
| 123 | 123 | ));  | 
                                                        
| 124 | -                        if (is_bool($item) && $item === false) { | 
                                                        |
| 124 | +                        if (is_bool($item) && $item === false) {
 | 
                                                        |
| 125 | 125 | $this->skippedDocs++;  | 
                                                        
| 126 | 126 | continue;  | 
                                                        
| 127 | 127 | }  | 
                                                        
| 128 | 128 | }  | 
                                                        
| 129 | 129 | $tmp = $this->parseChunk($this->renderTPL, $item);  | 
                                                        
| 130 | -                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) { | 
                                                        |
| 130 | +                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
 | 
                                                        |
| 131 | 131 | $this->toPlaceholders($tmp, 1,  | 
                                                        
| 132 | 132 | "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page  | 
                                                        
| 133 | 133 | }  | 
                                                        
@@ -147,8 +147,8 @@ discard block  | 
                                                    ||
| 147 | 147 | * @param array $array  | 
                                                        
| 148 | 148 | * @return string  | 
                                                        
| 149 | 149 | */  | 
                                                        
| 150 | - public function getJSON($data, $fields, $array = array())  | 
                                                        |
| 151 | -    { | 
                                                        |
| 150 | + public function getJSON($data, $fields, $array = array())  | 
                                                        |
| 151 | +    {
 | 
                                                        |
| 152 | 152 | $out = array();  | 
                                                        
| 153 | 153 |          $fields = is_array($fields) ? $fields : explode(",", $fields); | 
                                                        
| 154 | 154 |          $date = $this->getCFGDef('dateSource', 'pub_date'); | 
                                                        
@@ -168,19 +168,19 @@ discard block  | 
                                                    ||
| 168 | 168 | */  | 
                                                        
| 169 | 169 |          $extE = $this->getExtender('e', true, true); | 
                                                        
| 170 | 170 | |
| 171 | -        foreach ($data as $num => $row) { | 
                                                        |
| 171 | +        foreach ($data as $num => $row) {
 | 
                                                        |
| 172 | 172 | |
| 173 | -            switch (true) { | 
                                                        |
| 173 | +            switch (true) {
 | 
                                                        |
| 174 | 174 |                  case ((array('1') == $fields || in_array('summary', $fields)) && $extSummary): | 
                                                        
| 175 | 175 | $row['summary'] = $this->getSummary($row, $extSummary, 'introtext');  | 
                                                        
| 176 | 176 | //without break  | 
                                                        
| 177 | 177 |                  case ((array('1') == $fields || in_array('date', $fields)) && $date != 'date'): | 
                                                        
| 178 | -                    if (isset($row[$date])) { | 
                                                        |
| 178 | +                    if (isset($row[$date])) {
 | 
                                                        |
| 179 | 179 | $_date = is_numeric($row[$date]) && $row[$date] == (int)$row[$date] ? $row[$date] : strtotime($row[$date]);  | 
                                                        
| 180 | -                        if ($_date !== false) { | 
                                                        |
| 180 | +                        if ($_date !== false) {
 | 
                                                        |
| 181 | 181 | $_date = $_date + $this->modx->config['server_offset_time'];  | 
                                                        
| 182 | 182 |                              $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'); | 
                                                        
| 183 | -                            if ($dateFormat) { | 
                                                        |
| 183 | +                            if ($dateFormat) {
 | 
                                                        |
| 184 | 184 | $row['date'] = strftime($dateFormat, $_date);  | 
                                                        
| 185 | 185 | }  | 
                                                        
| 186 | 186 | }  | 
                                                        
@@ -188,15 +188,15 @@ discard block  | 
                                                    ||
| 188 | 188 | //nobreak  | 
                                                        
| 189 | 189 | }  | 
                                                        
| 190 | 190 | |
| 191 | -            if ($extE && $tmp = $extE->init($this, array('data' => $row))) { | 
                                                        |
| 192 | -                if (is_array($tmp)) { | 
                                                        |
| 191 | +            if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
 | 
                                                        |
| 192 | +                if (is_array($tmp)) {
 | 
                                                        |
| 193 | 193 | $row = $tmp;  | 
                                                        
| 194 | 194 | }  | 
                                                        
| 195 | 195 | }  | 
                                                        
| 196 | 196 | |
| 197 | -            if ($extPrepare) { | 
                                                        |
| 197 | +            if ($extPrepare) {
 | 
                                                        |
| 198 | 198 |                  $row = $extPrepare->init($this, array('data' => $row)); | 
                                                        
| 199 | -                if (is_bool($row) && $row === false) { | 
                                                        |
| 199 | +                if (is_bool($row) && $row === false) {
 | 
                                                        |
| 200 | 200 | continue;  | 
                                                        
| 201 | 201 | }  | 
                                                        
| 202 | 202 | }  | 
                                                        
@@ -209,20 +209,20 @@ discard block  | 
                                                    ||
| 209 | 209 | /**  | 
                                                        
| 210 | 210 | * @return array  | 
                                                        
| 211 | 211 | */  | 
                                                        
| 212 | - protected function getDocList()  | 
                                                        |
| 213 | -    { | 
                                                        |
| 212 | + protected function getDocList()  | 
                                                        |
| 213 | +    {
 | 
                                                        |
| 214 | 214 | $out = array();  | 
                                                        
| 215 | 215 | $sanitarInIDs = $this->sanitarIn($this->IDs);  | 
                                                        
| 216 | -        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { | 
                                                        |
| 216 | +        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
 | 
                                                        |
| 217 | 217 |              $where = $this->getCFGDef('addWhereList', ''); | 
                                                        
| 218 | -            if ($where != '') { | 
                                                        |
| 218 | +            if ($where != '') {
 | 
                                                        |
| 219 | 219 | $where = array($where);  | 
                                                        
| 220 | 220 | }  | 
                                                        
| 221 | -            if ($sanitarInIDs != "''") { | 
                                                        |
| 221 | +            if ($sanitarInIDs != "''") {
 | 
                                                        |
| 222 | 222 |                  $where[] = "`{$this->getPK()}` IN ({$sanitarInIDs})"; | 
                                                        
| 223 | 223 | }  | 
                                                        
| 224 | 224 | |
| 225 | -            if (!empty($where)) { | 
                                                        |
| 225 | +            if (!empty($where)) {
 | 
                                                        |
| 226 | 226 |                  $where = "WHERE " . implode(" AND ", $where); | 
                                                        
| 227 | 227 | }  | 
                                                        
| 228 | 228 |              $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0)); | 
                                                        
@@ -232,7 +232,7 @@ discard block  | 
                                                    ||
| 232 | 232 | |
| 233 | 233 | $rows = $this->modx->db->makeArray($rs);  | 
                                                        
| 234 | 234 | $out = array();  | 
                                                        
| 235 | -            foreach ($rows as $item) { | 
                                                        |
| 235 | +            foreach ($rows as $item) {
 | 
                                                        |
| 236 | 236 | $out[$item[$this->getPK()]] = $item;  | 
                                                        
| 237 | 237 | }  | 
                                                        
| 238 | 238 | }  | 
                                                        
@@ -243,22 +243,22 @@ discard block  | 
                                                    ||
| 243 | 243 | /**  | 
                                                        
| 244 | 244 | * @return array  | 
                                                        
| 245 | 245 | */  | 
                                                        
| 246 | - protected function getChildrenList()  | 
                                                        |
| 247 | -    { | 
                                                        |
| 246 | + protected function getChildrenList()  | 
                                                        |
| 247 | +    {
 | 
                                                        |
| 248 | 248 | $where = array();  | 
                                                        
| 249 | 249 | $out = array();  | 
                                                        
| 250 | 250 | |
| 251 | 251 |          $tmpWhere = $this->getCFGDef('addWhereList', ''); | 
                                                        
| 252 | 252 | $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);  | 
                                                        
| 253 | -        if (!empty($tmpWhere)) { | 
                                                        |
| 253 | +        if (!empty($tmpWhere)) {
 | 
                                                        |
| 254 | 254 | $where[] = $tmpWhere;  | 
                                                        
| 255 | 255 | }  | 
                                                        
| 256 | 256 | $sanitarInIDs = $this->sanitarIn($this->IDs);  | 
                                                        
| 257 | 257 | |
| 258 | 258 | $tmpWhere = null;  | 
                                                        
| 259 | -        if ($sanitarInIDs != "''") { | 
                                                        |
| 259 | +        if ($sanitarInIDs != "''") {
 | 
                                                        |
| 260 | 260 |              $tmpWhere = "(`{$this->getParentField()}` IN (" . $sanitarInIDs . ")"; | 
                                                        
| 261 | -            switch ($this->getCFGDef('showParent', '0')) { | 
                                                        |
| 261 | +            switch ($this->getCFGDef('showParent', '0')) {
 | 
                                                        |
| 262 | 262 | case -1:  | 
                                                        
| 263 | 263 | $tmpWhere .= ")";  | 
                                                        
| 264 | 264 | break;  | 
                                                        
@@ -271,32 +271,32 @@ discard block  | 
                                                    ||
| 271 | 271 | break;  | 
                                                        
| 272 | 272 | }  | 
                                                        
| 273 | 273 | }  | 
                                                        
| 274 | -        if (($addDocs = $this->getCFGDef('documents', '')) != '') { | 
                                                        |
| 274 | +        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
 | 
                                                        |
| 275 | 275 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));  | 
                                                        
| 276 | -            if (empty($tmpWhere)) { | 
                                                        |
| 276 | +            if (empty($tmpWhere)) {
 | 
                                                        |
| 277 | 277 |                  $tmpWhere = $this->getPK() . " IN({$addDocs})"; | 
                                                        
| 278 | -            } else { | 
                                                        |
| 278 | +            } else {
 | 
                                                        |
| 279 | 279 |                  $tmpWhere = "((" . $tmpWhere . ") OR {$this->getPK()} IN({$addDocs}))"; | 
                                                        
| 280 | 280 | }  | 
                                                        
| 281 | 281 | }  | 
                                                        
| 282 | -        if (!empty($tmpWhere)) { | 
                                                        |
| 282 | +        if (!empty($tmpWhere)) {
 | 
                                                        |
| 283 | 283 | $where[] = $tmpWhere;  | 
                                                        
| 284 | 284 | }  | 
                                                        
| 285 | -        if (!empty($where)) { | 
                                                        |
| 285 | +        if (!empty($where)) {
 | 
                                                        |
| 286 | 286 |              $where = "WHERE " . implode(" AND ", $where); | 
                                                        
| 287 | -        } else { | 
                                                        |
| 287 | +        } else {
 | 
                                                        |
| 288 | 288 | $where = '';  | 
                                                        
| 289 | 289 | }  | 
                                                        
| 290 | 290 |          $fields = $this->getCFGDef('selectFields', '*'); | 
                                                        
| 291 | 291 |          $group = $this->getGroupSQL($this->getCFGDef('groupBy', "`{$this->getPK()}`")); | 
                                                        
| 292 | -        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { | 
                                                        |
| 292 | +        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
 | 
                                                        |
| 293 | 293 |              $sql = $this->dbQuery("SELECT {$fields} FROM " . $this->table . " " . $where . " " . | 
                                                        
| 294 | 294 | $group . " " .  | 
                                                        
| 295 | 295 | $this->SortOrderSQL($this->getPK()) . " " .  | 
                                                        
| 296 | 296 |                  $this->LimitSQL($this->getCFGDef('queryLimit', 0)) | 
                                                        
| 297 | 297 | );  | 
                                                        
| 298 | 298 | $rows = $this->modx->db->makeArray($sql);  | 
                                                        
| 299 | -            foreach ($rows as $item) { | 
                                                        |
| 299 | +            foreach ($rows as $item) {
 | 
                                                        |
| 300 | 300 | $out[$item[$this->getPK()]] = $item;  | 
                                                        
| 301 | 301 | }  | 
                                                        
| 302 | 302 | }  | 
                                                        
@@ -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 | |
@@ -366,13 +366,13 @@ discard block  | 
                                                    ||
| 366 | 366 | * @param string $id  | 
                                                        
| 367 | 367 | * @return array  | 
                                                        
| 368 | 368 | */  | 
                                                        
| 369 | - public function getChildrenFolder($id)  | 
                                                        |
| 370 | -    { | 
                                                        |
| 369 | + public function getChildrenFolder($id)  | 
                                                        |
| 370 | +    {
 | 
                                                        |
| 371 | 371 | $sanitarInIDs = $this->sanitarIn($id);  | 
                                                        
| 372 | 372 | |
| 373 | 373 |          $tmp = $this->getCFGDef('addWhereFolder', ''); | 
                                                        
| 374 | 374 |          $where = "`{$this->getParentField()}` IN ({$sanitarInIDs})"; | 
                                                        
| 375 | -        if (!empty($tmp)) { | 
                                                        |
| 375 | +        if (!empty($tmp)) {
 | 
                                                        |
| 376 | 376 | $where .= " AND " . $tmp;  | 
                                                        
| 377 | 377 | }  | 
                                                        
| 378 | 378 | |
@@ -380,7 +380,7 @@ discard block  | 
                                                    ||
| 380 | 380 | |
| 381 | 381 | $rows = $this->modx->db->makeArray($rs);  | 
                                                        
| 382 | 382 | $out = array();  | 
                                                        
| 383 | -        foreach ($rows as $item) { | 
                                                        |
| 383 | +        foreach ($rows as $item) {
 | 
                                                        |
| 384 | 384 | $out[] = $item[$this->getPK()];  | 
                                                        
| 385 | 385 | }  | 
                                                        
| 386 | 386 | |
@@ -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 | |
@@ -16,16 +16,16 @@ discard block  | 
                                                    ||
| 16 | 16 | /**  | 
                                                        
| 17 | 17 | * Class shopkeeperDocLister  | 
                                                        
| 18 | 18 | */  | 
                                                        
| 19 | -class shopkeeperDocLister extends site_contentDocLister  | 
                                                        |
| 20 | -{ | 
                                                        |
| 19 | +class shopkeeperDocLister extends site_contentDocLister  | 
                                                        |
| 20 | +{
 | 
                                                        |
| 21 | 21 | /**  | 
                                                        
| 22 | 22 | * shopkeeperDocLister constructor.  | 
                                                        
| 23 | 23 | * @param $modx  | 
                                                        
| 24 | 24 | * @param array $cfg  | 
                                                        
| 25 | 25 | * @param null $startTime  | 
                                                        
| 26 | 26 | */  | 
                                                        
| 27 | - public function __construct($modx, $cfg = array(), $startTime = null)  | 
                                                        |
| 28 | -    { | 
                                                        |
| 27 | + public function __construct($modx, $cfg = array(), $startTime = null)  | 
                                                        |
| 28 | +    {
 | 
                                                        |
| 29 | 29 |          $cfg = array_merge(array('tvValuesTable' => 'catalog_tmplvar_contentvalues'), $cfg); | 
                                                        
| 30 | 30 | parent::__construct($modx, $cfg, $startTime);  | 
                                                        
| 31 | 31 | }  | 
                                                        
@@ -34,22 +34,22 @@ discard block  | 
                                                    ||
| 34 | 34 | * @param string $tpl  | 
                                                        
| 35 | 35 | * @return string  | 
                                                        
| 36 | 36 | */  | 
                                                        
| 37 | - public function _render($tpl = '')  | 
                                                        |
| 38 | -    { | 
                                                        |
| 37 | + public function _render($tpl = '')  | 
                                                        |
| 38 | +    {
 | 
                                                        |
| 39 | 39 | $out = '';  | 
                                                        
| 40 | -        if ($tpl == '') { | 
                                                        |
| 40 | +        if ($tpl == '') {
 | 
                                                        |
| 41 | 41 |              $tpl = $this->getCFGDef('tpl', '@CODE:<a href="[+url+]">[+pagetitle+]</a><br />'); | 
                                                        
| 42 | 42 | }  | 
                                                        
| 43 | -        if ($tpl != '') { | 
                                                        |
| 43 | +        if ($tpl != '') {
 | 
                                                        |
| 44 | 44 | $this->toPlaceholders(count($this->_docs), 1, "display"); // [+display+] - сколько показано на странице.  | 
                                                        
| 45 | 45 | |
| 46 | 46 | $i = 1;  | 
                                                        
| 47 | 47 |              $sysPlh = $this->renameKeyArr($this->_plh, $this->getCFGDef("sysKey", "dl")); | 
                                                        
| 48 | -            if (count($this->_docs) > 0) { | 
                                                        |
| 48 | +            if (count($this->_docs) > 0) {
 | 
                                                        |
| 49 | 49 | /**  | 
                                                        
| 50 | 50 | * @var $extUser user_DL_Extender  | 
                                                        
| 51 | 51 | */  | 
                                                        
| 52 | -                if ($extUser = $this->getExtender('user')) { | 
                                                        |
| 52 | +                if ($extUser = $this->getExtender('user')) {
 | 
                                                        |
| 53 | 53 |                      $extUser->init($this, array('fields' => $this->getCFGDef("userFields", ""))); | 
                                                        
| 54 | 54 | }  | 
                                                        
| 55 | 55 | |
@@ -68,20 +68,20 @@ discard block  | 
                                                    ||
| 68 | 68 | */  | 
                                                        
| 69 | 69 |                  $extJotCount = $this->getCFGdef('jotcount', 0) ? $this->getExtender('jotcount', true) : null; | 
                                                        
| 70 | 70 | |
| 71 | -                if ($extJotCount) { | 
                                                        |
| 71 | +                if ($extJotCount) {
 | 
                                                        |
| 72 | 72 | $comments = $extJotCount->countComments(array_keys($this->_docs));  | 
                                                        
| 73 | 73 | }  | 
                                                        
| 74 | 74 | |
| 75 | 75 | $this->skippedDocs = 0;  | 
                                                        
| 76 | -                foreach ($this->_docs as $item) { | 
                                                        |
| 76 | +                foreach ($this->_docs as $item) {
 | 
                                                        |
| 77 | 77 | $this->renderTPL = $tpl;  | 
                                                        
| 78 | -                    if ($extUser) { | 
                                                        |
| 78 | +                    if ($extUser) {
 | 
                                                        |
| 79 | 79 | $item = $extUser->setUserData($item); //[+user.id.createdby+], [+user.fullname.publishedby+], [+dl.user.publishedby+]....  | 
                                                        
| 80 | 80 | }  | 
                                                        
| 81 | 81 | |
| 82 | 82 | $item['summary'] = $extSummary ? $this->getSummary($item, $extSummary, '', 'content') : '';  | 
                                                        
| 83 | 83 | |
| 84 | -                    if ($extJotCount) { | 
                                                        |
| 84 | +                    if ($extJotCount) {
 | 
                                                        |
| 85 | 85 | $item['jotcount'] = APIHelpers::getkey($comments, $item['id'], 0);  | 
                                                        
| 86 | 86 | }  | 
                                                        
| 87 | 87 | |
@@ -89,47 +89,47 @@ discard block  | 
                                                    ||
| 89 | 89 | $sysPlh); //inside the chunks available all placeholders set via $modx->toPlaceholders with prefix id, and with prefix sysKey  | 
                                                        
| 90 | 90 | $item['iteration'] = $i; //[+iteration+] - Number element. Starting from zero  | 
                                                        
| 91 | 91 | |
| 92 | -                    if ($this->getCFGDef('makeUrl', 1)) { | 
                                                        |
| 93 | -                        if ($item['type'] == 'reference') { | 
                                                        |
| 92 | +                    if ($this->getCFGDef('makeUrl', 1)) {
 | 
                                                        |
| 93 | +                        if ($item['type'] == 'reference') {
 | 
                                                        |
| 94 | 94 | $item['url'] = is_numeric($item['content']) ? $this->modx->makeUrl($item['content'], '', '',  | 
                                                        
| 95 | 95 |                                  $this->getCFGDef('urlScheme', '')) : $item['content']; | 
                                                        
| 96 | -                        } else { | 
                                                        |
| 96 | +                        } else {
 | 
                                                        |
| 97 | 97 |                              $item['url'] = $this->modx->makeUrl($item['id'], '', '', $this->getCFGDef('urlScheme', '')); | 
                                                        
| 98 | 98 | }  | 
                                                        
| 99 | 99 | }  | 
                                                        
| 100 | 100 | |
| 101 | 101 | $item['date'] = $item['createdon'] + $this->modx->config['server_offset_time'];  | 
                                                        
| 102 | -                    if ($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') { | 
                                                        |
| 102 | +                    if ($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') {
 | 
                                                        |
| 103 | 103 |                          $item['date'] = strftime($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'), $item['date']); | 
                                                        
| 104 | 104 | }  | 
                                                        
| 105 | 105 | |
| 106 | 106 | $findTpl = $this->renderTPL;  | 
                                                        
| 107 | 107 | $tmp = $this->uniformPrepare($item, $i);  | 
                                                        
| 108 | 108 | extract($tmp, EXTR_SKIP);  | 
                                                        
| 109 | -                    if ($this->renderTPL == '') { | 
                                                        |
| 109 | +                    if ($this->renderTPL == '') {
 | 
                                                        |
| 110 | 110 | $this->renderTPL = $findTpl;  | 
                                                        
| 111 | 111 | }  | 
                                                        
| 112 | 112 | |
| 113 | -                    if ($extPrepare) { | 
                                                        |
| 113 | +                    if ($extPrepare) {
 | 
                                                        |
| 114 | 114 | $item = $extPrepare->init($this, array(  | 
                                                        
| 115 | 115 | 'data' => $item,  | 
                                                        
| 116 | 116 | 'nameParam' => 'prepare'  | 
                                                        
| 117 | 117 | ));  | 
                                                        
| 118 | -                        if (is_bool($item) && $item === false) { | 
                                                        |
| 118 | +                        if (is_bool($item) && $item === false) {
 | 
                                                        |
| 119 | 119 | $this->skippedDocs++;  | 
                                                        
| 120 | 120 | continue;  | 
                                                        
| 121 | 121 | }  | 
                                                        
| 122 | 122 | }  | 
                                                        
| 123 | 123 | $tmp = $this->parseChunk($this->renderTPL, $item);  | 
                                                        
| 124 | 124 | |
| 125 | -                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) { | 
                                                        |
| 125 | +                    if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
 | 
                                                        |
| 126 | 126 | $this->toPlaceholders($tmp, 1,  | 
                                                        
| 127 | 127 | "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page  | 
                                                        
| 128 | 128 | }  | 
                                                        
| 129 | 129 | $out .= $tmp;  | 
                                                        
| 130 | 130 | $i++;  | 
                                                        
| 131 | 131 | }  | 
                                                        
| 132 | -            } else { | 
                                                        |
| 132 | +            } else {
 | 
                                                        |
| 133 | 133 |                  $noneTPL = $this->getCFGDef("noneTPL", ""); | 
                                                        
| 134 | 134 | $out = ($noneTPL != '') ? $this->parseChunk($noneTPL, $sysPlh) : '';  | 
                                                        
| 135 | 135 | }  | 
                                                        
@@ -142,31 +142,31 @@ discard block  | 
                                                    ||
| 142 | 142 | /**  | 
                                                        
| 143 | 143 | * @absctract  | 
                                                        
| 144 | 144 | */  | 
                                                        
| 145 | - public function getChildrenCount()  | 
                                                        |
| 146 | -    { | 
                                                        |
| 145 | + public function getChildrenCount()  | 
                                                        |
| 146 | +    {
 | 
                                                        |
| 147 | 147 | $out = 0;  | 
                                                        
| 148 | 148 | $sanitarInIDs = $this->sanitarIn($this->IDs);  | 
                                                        
| 149 | -        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { | 
                                                        |
| 149 | +        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
 | 
                                                        |
| 150 | 150 |              $where = $this->getCFGDef('addWhereList', ''); | 
                                                        
| 151 | 151 | $where = sqlHelper::trimLogicalOp($where);  | 
                                                        
| 152 | 152 | $where = ($where ? $where . ' AND ' : '') . $this->_filters['where'];  | 
                                                        
| 153 | -            if ($where != '' && $this->_filters['where'] != '') { | 
                                                        |
| 153 | +            if ($where != '' && $this->_filters['where'] != '') {
 | 
                                                        |
| 154 | 154 | $where .= " AND ";  | 
                                                        
| 155 | 155 | }  | 
                                                        
| 156 | 156 | $where = sqlHelper::trimLogicalOp($where);  | 
                                                        
| 157 | 157 | |
| 158 | 158 |              $where = "WHERE {$where}"; | 
                                                        
| 159 | 159 | $whereArr = array();  | 
                                                        
| 160 | -            if (!$this->getCFGDef('showNoPublish', 0)) { | 
                                                        |
| 160 | +            if (!$this->getCFGDef('showNoPublish', 0)) {
 | 
                                                        |
| 161 | 161 | $whereArr[] = "c.published=1";  | 
                                                        
| 162 | 162 | }  | 
                                                        
| 163 | 163 | |
| 164 | 164 |              $tbl_site_content = $this->getTable('catalog', 'c'); | 
                                                        
| 165 | 165 | |
| 166 | -            if ($sanitarInIDs != "''") { | 
                                                        |
| 167 | -                switch ($this->getCFGDef('idType', 'parents')) { | 
                                                        |
| 166 | +            if ($sanitarInIDs != "''") {
 | 
                                                        |
| 167 | +                switch ($this->getCFGDef('idType', 'parents')) {
 | 
                                                        |
| 168 | 168 | case 'parents':  | 
                                                        
| 169 | -                        switch ($this->getCFGDef('showParent', '0')) { | 
                                                        |
| 169 | +                        switch ($this->getCFGDef('showParent', '0')) {
 | 
                                                        |
| 170 | 170 | case '-1':  | 
                                                        
| 171 | 171 |                                  $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")"; | 
                                                        
| 172 | 172 | break;  | 
                                                        
@@ -178,10 +178,10 @@ discard block  | 
                                                    ||
| 178 | 178 |                                  $tmpWhere = "(c.parent IN ({$sanitarInIDs}) OR c.id IN({$sanitarInIDs}))"; | 
                                                        
| 179 | 179 | break;  | 
                                                        
| 180 | 180 | }  | 
                                                        
| 181 | -                        if (($addDocs = $this->getCFGDef('documents', '')) != '') { | 
                                                        |
| 181 | +                        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
 | 
                                                        |
| 182 | 182 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));  | 
                                                        
| 183 | 183 |                              $whereArr[] = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))"; | 
                                                        
| 184 | -                        } else { | 
                                                        |
| 184 | +                        } else {
 | 
                                                        |
| 185 | 185 | $whereArr[] = $tmpWhere;  | 
                                                        
| 186 | 186 | }  | 
                                                        
| 187 | 187 | break;  | 
                                                        
@@ -193,14 +193,14 @@ discard block  | 
                                                    ||
| 193 | 193 | $from = $tbl_site_content . " " . $this->_filters['join'];  | 
                                                        
| 194 | 194 | $where = sqlHelper::trimLogicalOp($where);  | 
                                                        
| 195 | 195 | |
| 196 | -            if (trim($where) != 'WHERE') { | 
                                                        |
| 196 | +            if (trim($where) != 'WHERE') {
 | 
                                                        |
| 197 | 197 | $where .= " AND ";  | 
                                                        
| 198 | 198 | }  | 
                                                        
| 199 | 199 | |
| 200 | 200 |              $where .= implode(" AND ", $whereArr); | 
                                                        
| 201 | 201 | $where = sqlHelper::trimLogicalOp($where);  | 
                                                        
| 202 | 202 | |
| 203 | -            if (trim($where) == 'WHERE') { | 
                                                        |
| 203 | +            if (trim($where) == 'WHERE') {
 | 
                                                        |
| 204 | 204 | $where = '';  | 
                                                        
| 205 | 205 | }  | 
                                                        
| 206 | 206 |              $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); | 
                                                        
@@ -217,11 +217,11 @@ discard block  | 
                                                    ||
| 217 | 217 | /**  | 
                                                        
| 218 | 218 | * @return array  | 
                                                        
| 219 | 219 | */  | 
                                                        
| 220 | - protected function getDocList()  | 
                                                        |
| 221 | -    { | 
                                                        |
| 220 | + protected function getDocList()  | 
                                                        |
| 221 | +    {
 | 
                                                        |
| 222 | 222 | $out = array();  | 
                                                        
| 223 | 223 | $sanitarInIDs = $this->sanitarIn($this->IDs);  | 
                                                        
| 224 | -        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { | 
                                                        |
| 224 | +        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
 | 
                                                        |
| 225 | 225 |              $where = $this->getCFGDef('addWhereList', ''); | 
                                                        
| 226 | 226 | $where = sqlHelper::trimLogicalOp($where);  | 
                                                        
| 227 | 227 | |
@@ -229,21 +229,21 @@ discard block  | 
                                                    ||
| 229 | 229 | $where = sqlHelper::trimLogicalOp($where);  | 
                                                        
| 230 | 230 | |
| 231 | 231 |              $tbl_site_content = $this->getTable('catalog', 'c'); | 
                                                        
| 232 | -            if ($sanitarInIDs != "''") { | 
                                                        |
| 232 | +            if ($sanitarInIDs != "''") {
 | 
                                                        |
| 233 | 233 |                  $where .= ($where ? " AND " : "") . "c.id IN ({$sanitarInIDs}) AND"; | 
                                                        
| 234 | 234 | }  | 
                                                        
| 235 | 235 | $where = sqlHelper::trimLogicalOp($where);  | 
                                                        
| 236 | 236 | |
| 237 | -            if ($this->getCFGDef('showNoPublish', 0)) { | 
                                                        |
| 238 | -                if ($where != '') { | 
                                                        |
| 237 | +            if ($this->getCFGDef('showNoPublish', 0)) {
 | 
                                                        |
| 238 | +                if ($where != '') {
 | 
                                                        |
| 239 | 239 |                      $where = "WHERE {$where}"; | 
                                                        
| 240 | -                } else { | 
                                                        |
| 240 | +                } else {
 | 
                                                        |
| 241 | 241 | $where = '';  | 
                                                        
| 242 | 242 | }  | 
                                                        
| 243 | -            } else { | 
                                                        |
| 244 | -                if ($where != '') { | 
                                                        |
| 243 | +            } else {
 | 
                                                        |
| 244 | +                if ($where != '') {
 | 
                                                        |
| 245 | 245 |                      $where = "WHERE {$where} AND "; | 
                                                        
| 246 | -                } else { | 
                                                        |
| 246 | +                } else {
 | 
                                                        |
| 247 | 247 |                      $where = "WHERE {$where} "; | 
                                                        
| 248 | 248 | }  | 
                                                        
| 249 | 249 | $where .= "c.published=1";  | 
                                                        
@@ -262,7 +262,7 @@ discard block  | 
                                                    ||
| 262 | 262 | |
| 263 | 263 | $rows = $this->modx->db->makeArray($rs);  | 
                                                        
| 264 | 264 | |
| 265 | -            foreach ($rows as $item) { | 
                                                        |
| 265 | +            foreach ($rows as $item) {
 | 
                                                        |
| 266 | 266 | $out[$item['id']] = $item;  | 
                                                        
| 267 | 267 | }  | 
                                                        
| 268 | 268 | }  | 
                                                        
@@ -274,19 +274,19 @@ discard block  | 
                                                    ||
| 274 | 274 | * @param $id  | 
                                                        
| 275 | 275 | * @return array  | 
                                                        
| 276 | 276 | */  | 
                                                        
| 277 | - public function getChildrenFolder($id)  | 
                                                        |
| 278 | -    { | 
                                                        |
| 277 | + public function getChildrenFolder($id)  | 
                                                        |
| 278 | +    {
 | 
                                                        |
| 279 | 279 |          $where = $this->getCFGDef('addWhereFolder', ''); | 
                                                        
| 280 | 280 | $where = sqlHelper::trimLogicalOp($where);  | 
                                                        
| 281 | -        if ($where != '') { | 
                                                        |
| 281 | +        if ($where != '') {
 | 
                                                        |
| 282 | 282 | $where .= " AND ";  | 
                                                        
| 283 | 283 | }  | 
                                                        
| 284 | 284 | |
| 285 | 285 |          $tbl_site_content = $this->getTable('site_content', 'c'); | 
                                                        
| 286 | 286 | $sanitarInIDs = $this->sanitarIn($id);  | 
                                                        
| 287 | -        if ($this->getCFGDef('showNoPublish', 0)) { | 
                                                        |
| 287 | +        if ($this->getCFGDef('showNoPublish', 0)) {
 | 
                                                        |
| 288 | 288 |              $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}"; | 
                                                        
| 289 | -        } else { | 
                                                        |
| 289 | +        } else {
 | 
                                                        |
| 290 | 290 |              $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1"; | 
                                                        
| 291 | 291 | }  | 
                                                        
| 292 | 292 | |
@@ -295,7 +295,7 @@ discard block  | 
                                                    ||
| 295 | 295 | |
| 296 | 296 | $rows = $this->modx->db->makeArray($rs);  | 
                                                        
| 297 | 297 | $out = array();  | 
                                                        
| 298 | -        foreach ($rows as $item) { | 
                                                        |
| 298 | +        foreach ($rows as $item) {
 | 
                                                        |
| 299 | 299 | $out[] = $item['id'];  | 
                                                        
| 300 | 300 | }  | 
                                                        
| 301 | 301 | |
@@ -305,19 +305,19 @@ discard block  | 
                                                    ||
| 305 | 305 | /**  | 
                                                        
| 306 | 306 | * @return array  | 
                                                        
| 307 | 307 | */  | 
                                                        
| 308 | - protected function getChildrenList()  | 
                                                        |
| 309 | -    { | 
                                                        |
| 308 | + protected function getChildrenList()  | 
                                                        |
| 309 | +    {
 | 
                                                        |
| 310 | 310 | $where = array();  | 
                                                        
| 311 | 311 | $out = array();  | 
                                                        
| 312 | 312 | |
| 313 | 313 |          $tmpWhere = $this->getCFGDef('addWhereList', ''); | 
                                                        
| 314 | 314 | $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere);  | 
                                                        
| 315 | -        if (!empty($tmpWhere)) { | 
                                                        |
| 315 | +        if (!empty($tmpWhere)) {
 | 
                                                        |
| 316 | 316 | $where[] = $tmpWhere;  | 
                                                        
| 317 | 317 | }  | 
                                                        
| 318 | 318 | |
| 319 | 319 | $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']);  | 
                                                        
| 320 | -        if (!empty($tmpWhere)) { | 
                                                        |
| 320 | +        if (!empty($tmpWhere)) {
 | 
                                                        |
| 321 | 321 | $where[] = $tmpWhere;  | 
                                                        
| 322 | 322 | }  | 
                                                        
| 323 | 323 | |
@@ -329,8 +329,8 @@ discard block  | 
                                                    ||
| 329 | 329 | |
| 330 | 330 | $tmpWhere = null;  | 
                                                        
| 331 | 331 | |
| 332 | -        if ($sanitarInIDs != "''") { | 
                                                        |
| 333 | -            switch ($this->getCFGDef('showParent', '0')) { | 
                                                        |
| 332 | +        if ($sanitarInIDs != "''") {
 | 
                                                        |
| 333 | +            switch ($this->getCFGDef('showParent', '0')) {
 | 
                                                        |
| 334 | 334 | case '-1':  | 
                                                        
| 335 | 335 |                      $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")"; | 
                                                        
| 336 | 336 | break;  | 
                                                        
@@ -343,28 +343,28 @@ discard block  | 
                                                    ||
| 343 | 343 | break;  | 
                                                        
| 344 | 344 | }  | 
                                                        
| 345 | 345 | }  | 
                                                        
| 346 | -        if (($addDocs = $this->getCFGDef('documents', '')) != '') { | 
                                                        |
| 346 | +        if (($addDocs = $this->getCFGDef('documents', '')) != '') {
 | 
                                                        |
| 347 | 347 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs));  | 
                                                        
| 348 | -            if (empty($tmpWhere)) { | 
                                                        |
| 348 | +            if (empty($tmpWhere)) {
 | 
                                                        |
| 349 | 349 |                  $tmpWhere = "c.id IN({$addDocs})"; | 
                                                        
| 350 | -            } else { | 
                                                        |
| 350 | +            } else {
 | 
                                                        |
| 351 | 351 |                  $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))"; | 
                                                        
| 352 | 352 | }  | 
                                                        
| 353 | 353 | }  | 
                                                        
| 354 | -        if (!empty($tmpWhere)) { | 
                                                        |
| 354 | +        if (!empty($tmpWhere)) {
 | 
                                                        |
| 355 | 355 | $where[] = $tmpWhere;  | 
                                                        
| 356 | 356 | }  | 
                                                        
| 357 | -        if (!$this->getCFGDef('showNoPublish', 0)) { | 
                                                        |
| 357 | +        if (!$this->getCFGDef('showNoPublish', 0)) {
 | 
                                                        |
| 358 | 358 | $where[] = "c.published=1";  | 
                                                        
| 359 | 359 | }  | 
                                                        
| 360 | -        if (!empty($where)) { | 
                                                        |
| 360 | +        if (!empty($where)) {
 | 
                                                        |
| 361 | 361 |              $where = "WHERE " . implode(" AND ", $where); | 
                                                        
| 362 | -        } else { | 
                                                        |
| 362 | +        } else {
 | 
                                                        |
| 363 | 363 | $where = '';  | 
                                                        
| 364 | 364 | }  | 
                                                        
| 365 | 365 |          $fields = $this->getCFGDef('selectFields', 'c.*'); | 
                                                        
| 366 | 366 |          $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); | 
                                                        
| 367 | -        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { | 
                                                        |
| 367 | +        if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
 | 
                                                        |
| 368 | 368 |              $sql = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " . | 
                                                        
| 369 | 369 | $group . " " .  | 
                                                        
| 370 | 370 | $sort . " " .  | 
                                                        
@@ -372,7 +372,7 @@ discard block  | 
                                                    ||
| 372 | 372 | );  | 
                                                        
| 373 | 373 | |
| 374 | 374 | $rows = $this->modx->db->makeArray($sql);  | 
                                                        
| 375 | -            foreach ($rows as $item) { | 
                                                        |
| 375 | +            foreach ($rows as $item) {
 | 
                                                        |
| 376 | 376 | $out[$item['id']] = $item;  | 
                                                        
| 377 | 377 | }  | 
                                                        
| 378 | 378 | }  | 
                                                        
@@ -155,7 +155,7 @@ discard block  | 
                                                    ||
| 155 | 155 | }  | 
                                                        
| 156 | 156 | $where = sqlHelper::trimLogicalOp($where);  | 
                                                        
| 157 | 157 | |
| 158 | -            $where = "WHERE {$where}"; | 
                                                        |
| 158 | +            $where = "where {$where}"; | 
                                                        |
| 159 | 159 | $whereArr = array();  | 
                                                        
| 160 | 160 |              if (!$this->getCFGDef('showNoPublish', 0)) { | 
                                                        
| 161 | 161 | $whereArr[] = "c.published=1";  | 
                                                        
@@ -236,15 +236,15 @@ discard block  | 
                                                    ||
| 236 | 236 | |
| 237 | 237 |              if ($this->getCFGDef('showNoPublish', 0)) { | 
                                                        
| 238 | 238 |                  if ($where != '') { | 
                                                        
| 239 | -                    $where = "WHERE {$where}"; | 
                                                        |
| 239 | +                    $where = "where {$where}"; | 
                                                        |
| 240 | 240 |                  } else { | 
                                                        
| 241 | 241 | $where = '';  | 
                                                        
| 242 | 242 | }  | 
                                                        
| 243 | 243 |              } else { | 
                                                        
| 244 | 244 |                  if ($where != '') { | 
                                                        
| 245 | -                    $where = "WHERE {$where} AND "; | 
                                                        |
| 245 | +                    $where = "where {$where} AND "; | 
                                                        |
| 246 | 246 |                  } else { | 
                                                        
| 247 | -                    $where = "WHERE {$where} "; | 
                                                        |
| 247 | +                    $where = "where {$where} "; | 
                                                        |
| 248 | 248 | }  | 
                                                        
| 249 | 249 | $where .= "c.published=1";  | 
                                                        
| 250 | 250 | }  | 
                                                        
@@ -258,7 +258,7 @@ discard block  | 
                                                    ||
| 258 | 258 | |
| 259 | 259 |              $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0)); | 
                                                        
| 260 | 260 | |
| 261 | -            $rs = $this->dbQuery("SELECT {$fields} FROM {$tbl_site_content} {$where} {$group} {$sort} {$limit}"); | 
                                                        |
| 261 | +            $rs = $this->dbQuery("select {$fields} FROM {$tbl_site_content} {$where} {$group} {$sort} {$limit}"); | 
                                                        |
| 262 | 262 | |
| 263 | 263 | $rows = $this->modx->db->makeArray($rs);  | 
                                                        
| 264 | 264 | |
@@ -285,9 +285,9 @@ discard block  | 
                                                    ||
| 285 | 285 |          $tbl_site_content = $this->getTable('site_content', 'c'); | 
                                                        
| 286 | 286 | $sanitarInIDs = $this->sanitarIn($id);  | 
                                                        
| 287 | 287 |          if ($this->getCFGDef('showNoPublish', 0)) { | 
                                                        
| 288 | -            $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}"; | 
                                                        |
| 288 | +            $where = "where {$where} c.parent IN ({$sanitarInIDs}"; | 
                                                        |
| 289 | 289 |          } else { | 
                                                        
| 290 | -            $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1"; | 
                                                        |
| 290 | +            $where = "where {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1"; | 
                                                        |
| 291 | 291 | }  | 
                                                        
| 292 | 292 | |
| 293 | 293 |          $rs = $this->dbQuery("SELECT id FROM {$tbl_site_content} {$where} AND c.id IN(SELECT DISTINCT s.parent FROM " . $this->getTable('catalog', | 
                                                        
@@ -365,7 +365,7 @@ discard block  | 
                                                    ||
| 365 | 365 |          $fields = $this->getCFGDef('selectFields', 'c.*'); | 
                                                        
| 366 | 366 |          $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); | 
                                                        
| 367 | 367 |          if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { | 
                                                        
| 368 | -            $sql = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " . | 
                                                        |
| 368 | +            $sql = $this->dbQuery("select {$fields} FROM " . $from . " " . $where . " " . | 
                                                        |
| 369 | 369 | $group . " " .  | 
                                                        
| 370 | 370 | $sort . " " .  | 
                                                        
| 371 | 371 |                  $this->LimitSQL($this->getCFGDef('queryLimit', 0)) |