@@ -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]); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $row['title'] = empty($row['menutitle']) ? $row['pagetitle'] : $row['menutitle']; |
251 | 251 | } |
252 | 252 | } |
253 | - if ((bool)$this->getCFGDef('makeUrl', 1) && (array('1') == $fields || in_array('url',$fields)) |
|
253 | + if ((bool)$this->getCFGDef('makeUrl', 1) && (array('1') == $fields || in_array('url', $fields)) |
|
254 | 254 | ) { |
255 | 255 | if (isset($row['type']) && $row['type'] == 'reference' && isset($row['content'])) { |
256 | 256 | $row['url'] = is_numeric($row['content']) ? $this->modx->makeUrl($row['content'], '', '', |
@@ -297,10 +297,10 @@ discard block |
||
297 | 297 | |
298 | 298 | $where = "WHERE {$where}"; |
299 | 299 | $whereArr = array(); |
300 | - if (!$this->getCFGDef('showNoPublish', 0)) { |
|
300 | + if ( ! $this->getCFGDef('showNoPublish', 0)) { |
|
301 | 301 | $whereArr[] = "c.deleted=0 AND c.published=1"; |
302 | 302 | } |
303 | - else{ |
|
303 | + else { |
|
304 | 304 | $q_true = 1; |
305 | 305 | } |
306 | 306 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | |
356 | 356 | $q_true = $q_true ? $q_true : $group != ''; |
357 | 357 | |
358 | - if ( $q_true ){ |
|
358 | + if ($q_true) { |
|
359 | 359 | $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group}) as `tmp`"); |
360 | 360 | $out = $this->modx->db->getValue($rs); |
361 | 361 | } |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | protected function injectSortByTV($table, $sort) |
463 | 463 | { |
464 | 464 | $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort); |
465 | - if (!is_array($out) || empty($out)) { |
|
465 | + if ( ! is_array($out) || empty($out)) { |
|
466 | 466 | $out = array($table, $sort); |
467 | 467 | } |
468 | 468 | |
@@ -479,12 +479,12 @@ discard block |
||
479 | 479 | |
480 | 480 | $tmpWhere = $this->getCFGDef('addWhereList', ''); |
481 | 481 | $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere); |
482 | - if (!empty($tmpWhere)) { |
|
482 | + if ( ! empty($tmpWhere)) { |
|
483 | 483 | $where[] = $tmpWhere; |
484 | 484 | } |
485 | 485 | |
486 | 486 | $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']); |
487 | - if (!empty($tmpWhere)) { |
|
487 | + if ( ! empty($tmpWhere)) { |
|
488 | 488 | $where[] = $tmpWhere; |
489 | 489 | } |
490 | 490 | |
@@ -517,13 +517,13 @@ discard block |
||
517 | 517 | $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))"; |
518 | 518 | } |
519 | 519 | } |
520 | - if (!empty($tmpWhere)) { |
|
520 | + if ( ! empty($tmpWhere)) { |
|
521 | 521 | $where[] = $tmpWhere; |
522 | 522 | } |
523 | - if (!$this->getCFGDef('showNoPublish', 0)) { |
|
523 | + if ( ! $this->getCFGDef('showNoPublish', 0)) { |
|
524 | 524 | $where[] = "c.deleted=0 AND c.published=1"; |
525 | 525 | } |
526 | - if (!empty($where)) { |
|
526 | + if ( ! empty($where)) { |
|
527 | 527 | $where = "WHERE " . implode(" AND ", $where); |
528 | 528 | } else { |
529 | 529 | $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,50 +224,50 @@ 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('title', $fields)) { |
|
249 | - if (isset($row['pagetitle'])) { |
|
248 | + if (array('1') == $fields || in_array('title', $fields)) { |
|
249 | + if (isset($row['pagetitle'])) { |
|
250 | 250 | $row['title'] = empty($row['menutitle']) ? $row['pagetitle'] : $row['menutitle']; |
251 | 251 | } |
252 | 252 | } |
253 | 253 | if ((bool)$this->getCFGDef('makeUrl', 1) && (array('1') == $fields || in_array('url',$fields)) |
254 | - ) { |
|
255 | - if (isset($row['type']) && $row['type'] == 'reference' && isset($row['content'])) { |
|
254 | + ) { |
|
255 | + if (isset($row['type']) && $row['type'] == 'reference' && isset($row['content'])) { |
|
256 | 256 | $row['url'] = is_numeric($row['content']) ? $this->modx->makeUrl($row['content'], '', '', |
257 | 257 | $this->getCFGDef('urlScheme', '')) : $row['content']; |
258 | - } elseif (isset($row['id'])) { |
|
258 | + } elseif (isset($row['id'])) { |
|
259 | 259 | $row['url'] = $this->modx->makeUrl($row['id'], '', '', $this->getCFGDef('urlScheme', '')); |
260 | 260 | } |
261 | 261 | } |
262 | - if ($extE && $tmp = $extE->init($this, array('data' => $row))) { |
|
263 | - if (is_array($tmp)) { |
|
262 | + if ($extE && $tmp = $extE->init($this, array('data' => $row))) { |
|
263 | + if (is_array($tmp)) { |
|
264 | 264 | $row = $tmp; |
265 | 265 | } |
266 | 266 | } |
267 | 267 | |
268 | - if ($extPrepare) { |
|
268 | + if ($extPrepare) { |
|
269 | 269 | $row = $extPrepare->init($this, array('data' => $row)); |
270 | - if (is_bool($row) && $row === false) { |
|
270 | + if (is_bool($row) && $row === false) { |
|
271 | 271 | continue; |
272 | 272 | } |
273 | 273 | } |
@@ -280,36 +280,35 @@ discard block |
||
280 | 280 | /** |
281 | 281 | * @abstract |
282 | 282 | */ |
283 | - public function getChildrenCount() |
|
284 | - { |
|
283 | + public function getChildrenCount() |
|
284 | + { |
|
285 | 285 | $out = 0; |
286 | 286 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
287 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
287 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
288 | 288 | $q_true = $this->getCFGDef('ignoreEmpty', '0'); |
289 | 289 | $q_true = $q_true ? $q_true : $this->getCFGDef('idType', 'parents') == 'parents'; |
290 | 290 | $where = $this->getCFGDef('addWhereList', ''); |
291 | 291 | $where = sqlHelper::trimLogicalOp($where); |
292 | 292 | $where = ($where ? $where . ' AND ' : '') . $this->_filters['where']; |
293 | - if ($where != '' && $this->_filters['where'] != '') { |
|
293 | + if ($where != '' && $this->_filters['where'] != '') { |
|
294 | 294 | $where .= " AND "; |
295 | 295 | } |
296 | 296 | $where = sqlHelper::trimLogicalOp($where); |
297 | 297 | |
298 | 298 | $where = "WHERE {$where}"; |
299 | 299 | $whereArr = array(); |
300 | - if (!$this->getCFGDef('showNoPublish', 0)) { |
|
300 | + if (!$this->getCFGDef('showNoPublish', 0)) { |
|
301 | 301 | $whereArr[] = "c.deleted=0 AND c.published=1"; |
302 | - } |
|
303 | - else{ |
|
302 | + } else { |
|
304 | 303 | $q_true = 1; |
305 | 304 | } |
306 | 305 | |
307 | 306 | $tbl_site_content = $this->getTable('site_content', 'c'); |
308 | 307 | |
309 | - if ($sanitarInIDs != "''") { |
|
310 | - switch ($this->getCFGDef('idType', 'parents')) { |
|
308 | + if ($sanitarInIDs != "''") { |
|
309 | + switch ($this->getCFGDef('idType', 'parents')) { |
|
311 | 310 | case 'parents': |
312 | - switch ($this->getCFGDef('showParent', '0')) { |
|
311 | + switch ($this->getCFGDef('showParent', '0')) { |
|
313 | 312 | case '-1': |
314 | 313 | $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")"; |
315 | 314 | break; |
@@ -321,10 +320,10 @@ discard block |
||
321 | 320 | $tmpWhere = "(c.parent IN ({$sanitarInIDs}) OR c.id IN({$sanitarInIDs}))"; |
322 | 321 | break; |
323 | 322 | } |
324 | - if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
323 | + if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
325 | 324 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs)); |
326 | 325 | $whereArr[] = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))"; |
327 | - } else { |
|
326 | + } else { |
|
328 | 327 | $whereArr[] = $tmpWhere; |
329 | 328 | } |
330 | 329 | |
@@ -339,14 +338,14 @@ discard block |
||
339 | 338 | |
340 | 339 | $q_true = $q_true ? $q_true : trim($where) != 'WHERE'; |
341 | 340 | |
342 | - if (trim($where) != 'WHERE') { |
|
341 | + if (trim($where) != 'WHERE') { |
|
343 | 342 | $where .= " AND "; |
344 | 343 | } |
345 | 344 | |
346 | 345 | $where .= implode(" AND ", $whereArr); |
347 | 346 | $where = sqlHelper::trimLogicalOp($where); |
348 | 347 | |
349 | - if (trim($where) == 'WHERE') { |
|
348 | + if (trim($where) == 'WHERE') { |
|
350 | 349 | $where = ''; |
351 | 350 | } |
352 | 351 | $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id')); |
@@ -355,11 +354,10 @@ discard block |
||
355 | 354 | |
356 | 355 | $q_true = $q_true ? $q_true : $group != ''; |
357 | 356 | |
358 | - if ( $q_true ){ |
|
357 | + if ( $q_true ) { |
|
359 | 358 | $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group}) as `tmp`"); |
360 | 359 | $out = $this->modx->db->getValue($rs); |
361 | - } |
|
362 | - else { |
|
360 | + } else { |
|
363 | 361 | $out = count($this->IDs); |
364 | 362 | } |
365 | 363 | } |
@@ -370,11 +368,11 @@ discard block |
||
370 | 368 | /** |
371 | 369 | * @return array |
372 | 370 | */ |
373 | - protected function getDocList() |
|
374 | - { |
|
371 | + protected function getDocList() |
|
372 | + { |
|
375 | 373 | $out = array(); |
376 | 374 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
377 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
375 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
378 | 376 | $where = $this->getCFGDef('addWhereList', ''); |
379 | 377 | $where = sqlHelper::trimLogicalOp($where); |
380 | 378 | |
@@ -382,21 +380,21 @@ discard block |
||
382 | 380 | $where = sqlHelper::trimLogicalOp($where); |
383 | 381 | |
384 | 382 | $tbl_site_content = $this->getTable('site_content', 'c'); |
385 | - if ($sanitarInIDs != "''") { |
|
383 | + if ($sanitarInIDs != "''") { |
|
386 | 384 | $where .= ($where ? " AND " : "") . "c.id IN ({$sanitarInIDs}) AND"; |
387 | 385 | } |
388 | 386 | $where = sqlHelper::trimLogicalOp($where); |
389 | 387 | |
390 | - if ($this->getCFGDef('showNoPublish', 0)) { |
|
391 | - if ($where != '') { |
|
388 | + if ($this->getCFGDef('showNoPublish', 0)) { |
|
389 | + if ($where != '') { |
|
392 | 390 | $where = "WHERE {$where}"; |
393 | - } else { |
|
391 | + } else { |
|
394 | 392 | $where = ''; |
395 | 393 | } |
396 | - } else { |
|
397 | - if ($where != '') { |
|
394 | + } else { |
|
395 | + if ($where != '') { |
|
398 | 396 | $where = "WHERE {$where} AND "; |
399 | - } else { |
|
397 | + } else { |
|
400 | 398 | $where = "WHERE {$where} "; |
401 | 399 | } |
402 | 400 | $where .= "c.deleted=0 AND c.published=1"; |
@@ -415,7 +413,7 @@ discard block |
||
415 | 413 | |
416 | 414 | $rows = $this->modx->db->makeArray($rs); |
417 | 415 | |
418 | - foreach ($rows as $item) { |
|
416 | + foreach ($rows as $item) { |
|
419 | 417 | $out[$item['id']] = $item; |
420 | 418 | } |
421 | 419 | } |
@@ -427,19 +425,19 @@ discard block |
||
427 | 425 | * @param string $id |
428 | 426 | * @return array |
429 | 427 | */ |
430 | - public function getChildrenFolder($id) |
|
431 | - { |
|
428 | + public function getChildrenFolder($id) |
|
429 | + { |
|
432 | 430 | $where = $this->getCFGDef('addWhereFolder', ''); |
433 | 431 | $where = sqlHelper::trimLogicalOp($where); |
434 | - if ($where != '') { |
|
432 | + if ($where != '') { |
|
435 | 433 | $where .= " AND "; |
436 | 434 | } |
437 | 435 | |
438 | 436 | $tbl_site_content = $this->getTable('site_content', 'c'); |
439 | 437 | $sanitarInIDs = $this->sanitarIn($id); |
440 | - if ($this->getCFGDef('showNoPublish', 0)) { |
|
438 | + if ($this->getCFGDef('showNoPublish', 0)) { |
|
441 | 439 | $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1"; |
442 | - } else { |
|
440 | + } else { |
|
443 | 441 | $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1"; |
444 | 442 | } |
445 | 443 | |
@@ -447,7 +445,7 @@ discard block |
||
447 | 445 | |
448 | 446 | $rows = $this->modx->db->makeArray($rs); |
449 | 447 | $out = array(); |
450 | - foreach ($rows as $item) { |
|
448 | + foreach ($rows as $item) { |
|
451 | 449 | $out[] = $item['id']; |
452 | 450 | } |
453 | 451 | |
@@ -459,10 +457,10 @@ discard block |
||
459 | 457 | * @param $sort |
460 | 458 | * @return array |
461 | 459 | */ |
462 | - protected function injectSortByTV($table, $sort) |
|
463 | - { |
|
460 | + protected function injectSortByTV($table, $sort) |
|
461 | + { |
|
464 | 462 | $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort); |
465 | - if (!is_array($out) || empty($out)) { |
|
463 | + if (!is_array($out) || empty($out)) { |
|
466 | 464 | $out = array($table, $sort); |
467 | 465 | } |
468 | 466 | |
@@ -472,19 +470,19 @@ discard block |
||
472 | 470 | /** |
473 | 471 | * @return array |
474 | 472 | */ |
475 | - protected function getChildrenList() |
|
476 | - { |
|
473 | + protected function getChildrenList() |
|
474 | + { |
|
477 | 475 | $where = array(); |
478 | 476 | $out = array(); |
479 | 477 | |
480 | 478 | $tmpWhere = $this->getCFGDef('addWhereList', ''); |
481 | 479 | $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere); |
482 | - if (!empty($tmpWhere)) { |
|
480 | + if (!empty($tmpWhere)) { |
|
483 | 481 | $where[] = $tmpWhere; |
484 | 482 | } |
485 | 483 | |
486 | 484 | $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']); |
487 | - if (!empty($tmpWhere)) { |
|
485 | + if (!empty($tmpWhere)) { |
|
488 | 486 | $where[] = $tmpWhere; |
489 | 487 | } |
490 | 488 | |
@@ -495,8 +493,8 @@ discard block |
||
495 | 493 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
496 | 494 | |
497 | 495 | $tmpWhere = null; |
498 | - if ($sanitarInIDs != "''") { |
|
499 | - switch ($this->getCFGDef('showParent', '0')) { |
|
496 | + if ($sanitarInIDs != "''") { |
|
497 | + switch ($this->getCFGDef('showParent', '0')) { |
|
500 | 498 | case '-1': |
501 | 499 | $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")"; |
502 | 500 | break; |
@@ -509,29 +507,29 @@ discard block |
||
509 | 507 | break; |
510 | 508 | } |
511 | 509 | } |
512 | - if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
510 | + if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
513 | 511 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs)); |
514 | - if (empty($tmpWhere)) { |
|
512 | + if (empty($tmpWhere)) { |
|
515 | 513 | $tmpWhere = "c.id IN({$addDocs})"; |
516 | - } else { |
|
514 | + } else { |
|
517 | 515 | $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))"; |
518 | 516 | } |
519 | 517 | } |
520 | - if (!empty($tmpWhere)) { |
|
518 | + if (!empty($tmpWhere)) { |
|
521 | 519 | $where[] = $tmpWhere; |
522 | 520 | } |
523 | - if (!$this->getCFGDef('showNoPublish', 0)) { |
|
521 | + if (!$this->getCFGDef('showNoPublish', 0)) { |
|
524 | 522 | $where[] = "c.deleted=0 AND c.published=1"; |
525 | 523 | } |
526 | - if (!empty($where)) { |
|
524 | + if (!empty($where)) { |
|
527 | 525 | $where = "WHERE " . implode(" AND ", $where); |
528 | - } else { |
|
526 | + } else { |
|
529 | 527 | $where = ''; |
530 | 528 | } |
531 | 529 | $fields = $this->getCFGDef('selectFields', 'c.*'); |
532 | 530 | $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); |
533 | 531 | |
534 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
532 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
535 | 533 | $sql = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " . |
536 | 534 | $group . " " . |
537 | 535 | $sort . " " . |
@@ -540,7 +538,7 @@ discard block |
||
540 | 538 | |
541 | 539 | $rows = $this->modx->db->makeArray($sql); |
542 | 540 | |
543 | - foreach ($rows as $item) { |
|
541 | + foreach ($rows as $item) { |
|
544 | 542 | $out[$item['id']] = $item; |
545 | 543 | } |
546 | 544 | } |
@@ -553,10 +551,10 @@ discard block |
||
553 | 551 | * @param string $type |
554 | 552 | * @return string |
555 | 553 | */ |
556 | - public function changeSortType($field, $type) |
|
557 | - { |
|
554 | + public function changeSortType($field, $type) |
|
555 | + { |
|
558 | 556 | $type = trim($type); |
559 | - switch (strtoupper($type)) { |
|
557 | + switch (strtoupper($type)) { |
|
560 | 558 | case 'TVDATETIME': |
561 | 559 | $field = "STR_TO_DATE(" . $field . ",'%d-%m-%Y %H:%i:%s')"; |
562 | 560 | break; |