@@ -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) { |
@@ -280,10 +280,10 @@ discard block |
||
280 | 280 | |
281 | 281 | $where = "WHERE {$where}"; |
282 | 282 | $whereArr = array(); |
283 | - if (!$this->getCFGDef('showNoPublish', 0)) { |
|
283 | + if ( ! $this->getCFGDef('showNoPublish', 0)) { |
|
284 | 284 | $whereArr[] = "c.deleted=0 AND c.published=1"; |
285 | 285 | } |
286 | - else{ |
|
286 | + else { |
|
287 | 287 | $q_true = 1; |
288 | 288 | } |
289 | 289 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | |
339 | 339 | $q_true = $q_true ? $q_true : $group != 'GROUP BY c.id'; |
340 | 340 | |
341 | - if ( $q_true ){ |
|
341 | + if ($q_true) { |
|
342 | 342 | $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group}) as `tmp`"); |
343 | 343 | $out = $this->modx->db->getValue($rs); |
344 | 344 | } |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | protected function injectSortByTV($table, $sort) |
446 | 446 | { |
447 | 447 | $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort); |
448 | - if (!is_array($out) || empty($out)) { |
|
448 | + if ( ! is_array($out) || empty($out)) { |
|
449 | 449 | $out = array($table, $sort); |
450 | 450 | } |
451 | 451 | |
@@ -462,12 +462,12 @@ discard block |
||
462 | 462 | |
463 | 463 | $tmpWhere = $this->getCFGDef('addWhereList', ''); |
464 | 464 | $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere); |
465 | - if (!empty($tmpWhere)) { |
|
465 | + if ( ! empty($tmpWhere)) { |
|
466 | 466 | $where[] = $tmpWhere; |
467 | 467 | } |
468 | 468 | |
469 | 469 | $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']); |
470 | - if (!empty($tmpWhere)) { |
|
470 | + if ( ! empty($tmpWhere)) { |
|
471 | 471 | $where[] = $tmpWhere; |
472 | 472 | } |
473 | 473 | |
@@ -500,13 +500,13 @@ discard block |
||
500 | 500 | $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))"; |
501 | 501 | } |
502 | 502 | } |
503 | - if (!empty($tmpWhere)) { |
|
503 | + if ( ! empty($tmpWhere)) { |
|
504 | 504 | $where[] = $tmpWhere; |
505 | 505 | } |
506 | - if (!$this->getCFGDef('showNoPublish', 0)) { |
|
506 | + if ( ! $this->getCFGDef('showNoPublish', 0)) { |
|
507 | 507 | $where[] = "c.deleted=0 AND c.published=1"; |
508 | 508 | } |
509 | - if (!empty($where)) { |
|
509 | + if ( ! empty($where)) { |
|
510 | 510 | $where = "WHERE " . implode(" AND ", $where); |
511 | 511 | } else { |
512 | 512 | $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,20 +139,20 @@ 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])) { |
|
151 | + if (isset($item[$date])) { |
|
152 | 152 | $_date = is_numeric($item[$date]) && $item[$date] == (int)$item[$date] ? $item[$date] : strtotime($item[$date]); |
153 | - if ($_date !== false) { |
|
153 | + if ($_date !== false) { |
|
154 | 154 | $_date = $_date + $this->modx->config['server_offset_time']; |
155 | - if ($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') { |
|
155 | + if ($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') { |
|
156 | 156 | $item['date'] = strftime($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'), $_date); |
157 | 157 | } |
158 | 158 | } |
@@ -161,35 +161,35 @@ discard block |
||
161 | 161 | $findTpl = $this->renderTPL; |
162 | 162 | $tmp = $this->uniformPrepare($item, $i); |
163 | 163 | extract($tmp, EXTR_SKIP); |
164 | - if ($this->renderTPL == '') { |
|
164 | + if ($this->renderTPL == '') { |
|
165 | 165 | $this->renderTPL = $findTpl; |
166 | 166 | } |
167 | 167 | |
168 | - if ($extPrepare) { |
|
168 | + if ($extPrepare) { |
|
169 | 169 | $item = $extPrepare->init($this, array( |
170 | 170 | 'data' => $item, |
171 | 171 | 'nameParam' => 'prepare' |
172 | 172 | )); |
173 | - if (is_bool($item) && $item === false) { |
|
173 | + if (is_bool($item) && $item === false) { |
|
174 | 174 | $this->skippedDocs++; |
175 | 175 | continue; |
176 | 176 | } |
177 | 177 | } |
178 | 178 | $tmp = $this->parseChunk($this->renderTPL, $item); |
179 | 179 | |
180 | - if ($this->getCFGDef('contentPlaceholder', 0) !== 0) { |
|
180 | + if ($this->getCFGDef('contentPlaceholder', 0) !== 0) { |
|
181 | 181 | $this->toPlaceholders($tmp, 1, |
182 | 182 | "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page |
183 | 183 | } |
184 | 184 | $out .= $tmp; |
185 | 185 | $i++; |
186 | 186 | } |
187 | - } else { |
|
187 | + } else { |
|
188 | 188 | $noneTPL = $this->getCFGDef("noneTPL", ""); |
189 | 189 | $out = ($noneTPL != '') ? $this->parseChunk($noneTPL, $sysPlh) : ''; |
190 | 190 | } |
191 | 191 | $out = $this->renderWrap($out); |
192 | - } else { |
|
192 | + } else { |
|
193 | 193 | $out = 'no template'; |
194 | 194 | } |
195 | 195 | |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | * @param array $array |
203 | 203 | * @return string |
204 | 204 | */ |
205 | - public function getJSON($data, $fields, $array = array()) |
|
206 | - { |
|
205 | + public function getJSON($data, $fields, $array = array()) |
|
206 | + { |
|
207 | 207 | $out = array(); |
208 | 208 | $fields = is_array($fields) ? $fields : explode(",", $fields); |
209 | 209 | $date = $this->getCFGDef('dateSource', 'pub_date'); |
@@ -223,44 +223,44 @@ discard block |
||
223 | 223 | */ |
224 | 224 | $extE = $this->getExtender('e', true, true); |
225 | 225 | |
226 | - foreach ($data as $num => $item) { |
|
226 | + foreach ($data as $num => $item) { |
|
227 | 227 | $row = $item; |
228 | - if ((array('1') == $fields || in_array('summary', $fields)) && $extSummary) { |
|
228 | + if ((array('1') == $fields || in_array('summary', $fields)) && $extSummary) { |
|
229 | 229 | $row['summary'] = $this->getSummary($this->_docs[$num], $extSummary, 'introtext', 'content'); |
230 | 230 | } |
231 | - if (array('1') == $fields || in_array('date', $fields)) { |
|
232 | - if (isset($this->_docs[$num][$date])) { |
|
231 | + if (array('1') == $fields || in_array('date', $fields)) { |
|
232 | + if (isset($this->_docs[$num][$date])) { |
|
233 | 233 | $_date = is_numeric($this->_docs[$num][$date]) && $this->_docs[$num][$date] == (int)$this->_docs[$num][$date] ? $this->_docs[$num][$date] : strtotime($this->_docs[$num][$date]); |
234 | - if ($_date !== false) { |
|
234 | + if ($_date !== false) { |
|
235 | 235 | $_date = $_date + $this->modx->config['server_offset_time']; |
236 | - if ($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') { |
|
236 | + if ($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') { |
|
237 | 237 | $row['date'] = strftime($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'), $_date); |
238 | 238 | } |
239 | 239 | } |
240 | 240 | } |
241 | 241 | } |
242 | - if (array('1') == $fields || in_array(array('menutitle', 'pagetitle'), $fields)) { |
|
242 | + if (array('1') == $fields || in_array(array('menutitle', 'pagetitle'), $fields)) { |
|
243 | 243 | $row['title'] = ($row['menutitle'] == '' ? $row['pagetitle'] : $row['menutitle']); |
244 | 244 | } |
245 | 245 | if ((bool)$this->getCFGDef('makeUrl', 1) && (array('1') == $fields || in_array(array('content', 'type'), |
246 | 246 | $fields)) |
247 | - ) { |
|
248 | - if ($row['type'] == 'reference') { |
|
247 | + ) { |
|
248 | + if ($row['type'] == 'reference') { |
|
249 | 249 | $row['url'] = is_numeric($row['content']) ? $this->modx->makeUrl($row['content'], '', '', |
250 | 250 | $this->getCFGDef('urlScheme', '')) : $row['content']; |
251 | - } else { |
|
251 | + } else { |
|
252 | 252 | $row['url'] = $this->modx->makeUrl($row['id'], '', '', $this->getCFGDef('urlScheme', '')); |
253 | 253 | } |
254 | 254 | } |
255 | - if ($extE && $tmp = $extE->init($this, array('data' => $row))) { |
|
256 | - if (is_array($tmp)) { |
|
255 | + if ($extE && $tmp = $extE->init($this, array('data' => $row))) { |
|
256 | + if (is_array($tmp)) { |
|
257 | 257 | $row = $tmp; |
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | - if ($extPrepare) { |
|
261 | + if ($extPrepare) { |
|
262 | 262 | $row = $extPrepare->init($this, array('data' => $row)); |
263 | - if (is_bool($row) && $row === false) { |
|
263 | + if (is_bool($row) && $row === false) { |
|
264 | 264 | continue; |
265 | 265 | } |
266 | 266 | } |
@@ -273,36 +273,35 @@ discard block |
||
273 | 273 | /** |
274 | 274 | * @abstract |
275 | 275 | */ |
276 | - public function getChildrenCount() |
|
277 | - { |
|
276 | + public function getChildrenCount() |
|
277 | + { |
|
278 | 278 | $out = 0; |
279 | 279 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
280 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
280 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
281 | 281 | $q_true = $this->getCFGDef('ignoreEmpty', '0'); |
282 | 282 | $q_true = $q_true ? $q_true : $this->getCFGDef('idType', 'parents') == 'parents'; |
283 | 283 | $where = $this->getCFGDef('addWhereList', ''); |
284 | 284 | $where = sqlHelper::trimLogicalOp($where); |
285 | 285 | $where = ($where ? $where . ' AND ' : '') . $this->_filters['where']; |
286 | - if ($where != '' && $this->_filters['where'] != '') { |
|
286 | + if ($where != '' && $this->_filters['where'] != '') { |
|
287 | 287 | $where .= " AND "; |
288 | 288 | } |
289 | 289 | $where = sqlHelper::trimLogicalOp($where); |
290 | 290 | |
291 | 291 | $where = "WHERE {$where}"; |
292 | 292 | $whereArr = array(); |
293 | - if (!$this->getCFGDef('showNoPublish', 0)) { |
|
293 | + if (!$this->getCFGDef('showNoPublish', 0)) { |
|
294 | 294 | $whereArr[] = "c.deleted=0 AND c.published=1"; |
295 | - } |
|
296 | - else{ |
|
295 | + } else { |
|
297 | 296 | $q_true = 1; |
298 | 297 | } |
299 | 298 | |
300 | 299 | $tbl_site_content = $this->getTable('site_content', 'c'); |
301 | 300 | |
302 | - if ($sanitarInIDs != "''") { |
|
303 | - switch ($this->getCFGDef('idType', 'parents')) { |
|
301 | + if ($sanitarInIDs != "''") { |
|
302 | + switch ($this->getCFGDef('idType', 'parents')) { |
|
304 | 303 | case 'parents': |
305 | - switch ($this->getCFGDef('showParent', '0')) { |
|
304 | + switch ($this->getCFGDef('showParent', '0')) { |
|
306 | 305 | case '-1': |
307 | 306 | $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")"; |
308 | 307 | break; |
@@ -314,10 +313,10 @@ discard block |
||
314 | 313 | $tmpWhere = "(c.parent IN ({$sanitarInIDs}) OR c.id IN({$sanitarInIDs}))"; |
315 | 314 | break; |
316 | 315 | } |
317 | - if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
316 | + if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
318 | 317 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs)); |
319 | 318 | $whereArr[] = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))"; |
320 | - } else { |
|
319 | + } else { |
|
321 | 320 | $whereArr[] = $tmpWhere; |
322 | 321 | } |
323 | 322 | |
@@ -332,14 +331,14 @@ discard block |
||
332 | 331 | |
333 | 332 | $q_true = $q_true ? $q_true : trim($where) != 'WHERE'; |
334 | 333 | |
335 | - if (trim($where) != 'WHERE') { |
|
334 | + if (trim($where) != 'WHERE') { |
|
336 | 335 | $where .= " AND "; |
337 | 336 | } |
338 | 337 | |
339 | 338 | $where .= implode(" AND ", $whereArr); |
340 | 339 | $where = sqlHelper::trimLogicalOp($where); |
341 | 340 | |
342 | - if (trim($where) == 'WHERE') { |
|
341 | + if (trim($where) == 'WHERE') { |
|
343 | 342 | $where = ''; |
344 | 343 | } |
345 | 344 | $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id')); |
@@ -348,11 +347,10 @@ discard block |
||
348 | 347 | |
349 | 348 | $q_true = $q_true ? $q_true : $group != 'GROUP BY c.id'; |
350 | 349 | |
351 | - if ( $q_true ){ |
|
350 | + if ( $q_true ) { |
|
352 | 351 | $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group}) as `tmp`"); |
353 | 352 | $out = $this->modx->db->getValue($rs); |
354 | - } |
|
355 | - else { |
|
353 | + } else { |
|
356 | 354 | $out = count($this->IDs); |
357 | 355 | } |
358 | 356 | } |
@@ -363,11 +361,11 @@ discard block |
||
363 | 361 | /** |
364 | 362 | * @return array |
365 | 363 | */ |
366 | - protected function getDocList() |
|
367 | - { |
|
364 | + protected function getDocList() |
|
365 | + { |
|
368 | 366 | $out = array(); |
369 | 367 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
370 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
368 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
371 | 369 | $where = $this->getCFGDef('addWhereList', ''); |
372 | 370 | $where = sqlHelper::trimLogicalOp($where); |
373 | 371 | |
@@ -375,21 +373,21 @@ discard block |
||
375 | 373 | $where = sqlHelper::trimLogicalOp($where); |
376 | 374 | |
377 | 375 | $tbl_site_content = $this->getTable('site_content', 'c'); |
378 | - if ($sanitarInIDs != "''") { |
|
376 | + if ($sanitarInIDs != "''") { |
|
379 | 377 | $where .= ($where ? " AND " : "") . "c.id IN ({$sanitarInIDs}) AND"; |
380 | 378 | } |
381 | 379 | $where = sqlHelper::trimLogicalOp($where); |
382 | 380 | |
383 | - if ($this->getCFGDef('showNoPublish', 0)) { |
|
384 | - if ($where != '') { |
|
381 | + if ($this->getCFGDef('showNoPublish', 0)) { |
|
382 | + if ($where != '') { |
|
385 | 383 | $where = "WHERE {$where}"; |
386 | - } else { |
|
384 | + } else { |
|
387 | 385 | $where = ''; |
388 | 386 | } |
389 | - } else { |
|
390 | - if ($where != '') { |
|
387 | + } else { |
|
388 | + if ($where != '') { |
|
391 | 389 | $where = "WHERE {$where} AND "; |
392 | - } else { |
|
390 | + } else { |
|
393 | 391 | $where = "WHERE {$where} "; |
394 | 392 | } |
395 | 393 | $where .= "c.deleted=0 AND c.published=1"; |
@@ -408,7 +406,7 @@ discard block |
||
408 | 406 | |
409 | 407 | $rows = $this->modx->db->makeArray($rs); |
410 | 408 | |
411 | - foreach ($rows as $item) { |
|
409 | + foreach ($rows as $item) { |
|
412 | 410 | $out[$item['id']] = $item; |
413 | 411 | } |
414 | 412 | } |
@@ -420,19 +418,19 @@ discard block |
||
420 | 418 | * @param string $id |
421 | 419 | * @return array |
422 | 420 | */ |
423 | - public function getChildrenFolder($id) |
|
424 | - { |
|
421 | + public function getChildrenFolder($id) |
|
422 | + { |
|
425 | 423 | $where = $this->getCFGDef('addWhereFolder', ''); |
426 | 424 | $where = sqlHelper::trimLogicalOp($where); |
427 | - if ($where != '') { |
|
425 | + if ($where != '') { |
|
428 | 426 | $where .= " AND "; |
429 | 427 | } |
430 | 428 | |
431 | 429 | $tbl_site_content = $this->getTable('site_content', 'c'); |
432 | 430 | $sanitarInIDs = $this->sanitarIn($id); |
433 | - if ($this->getCFGDef('showNoPublish', 0)) { |
|
431 | + if ($this->getCFGDef('showNoPublish', 0)) { |
|
434 | 432 | $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1"; |
435 | - } else { |
|
433 | + } else { |
|
436 | 434 | $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1"; |
437 | 435 | } |
438 | 436 | |
@@ -440,7 +438,7 @@ discard block |
||
440 | 438 | |
441 | 439 | $rows = $this->modx->db->makeArray($rs); |
442 | 440 | $out = array(); |
443 | - foreach ($rows as $item) { |
|
441 | + foreach ($rows as $item) { |
|
444 | 442 | $out[] = $item['id']; |
445 | 443 | } |
446 | 444 | |
@@ -452,10 +450,10 @@ discard block |
||
452 | 450 | * @param $sort |
453 | 451 | * @return array |
454 | 452 | */ |
455 | - protected function injectSortByTV($table, $sort) |
|
456 | - { |
|
453 | + protected function injectSortByTV($table, $sort) |
|
454 | + { |
|
457 | 455 | $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort); |
458 | - if (!is_array($out) || empty($out)) { |
|
456 | + if (!is_array($out) || empty($out)) { |
|
459 | 457 | $out = array($table, $sort); |
460 | 458 | } |
461 | 459 | |
@@ -465,19 +463,19 @@ discard block |
||
465 | 463 | /** |
466 | 464 | * @return array |
467 | 465 | */ |
468 | - protected function getChildrenList() |
|
469 | - { |
|
466 | + protected function getChildrenList() |
|
467 | + { |
|
470 | 468 | $where = array(); |
471 | 469 | $out = array(); |
472 | 470 | |
473 | 471 | $tmpWhere = $this->getCFGDef('addWhereList', ''); |
474 | 472 | $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere); |
475 | - if (!empty($tmpWhere)) { |
|
473 | + if (!empty($tmpWhere)) { |
|
476 | 474 | $where[] = $tmpWhere; |
477 | 475 | } |
478 | 476 | |
479 | 477 | $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']); |
480 | - if (!empty($tmpWhere)) { |
|
478 | + if (!empty($tmpWhere)) { |
|
481 | 479 | $where[] = $tmpWhere; |
482 | 480 | } |
483 | 481 | |
@@ -488,8 +486,8 @@ discard block |
||
488 | 486 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
489 | 487 | |
490 | 488 | $tmpWhere = null; |
491 | - if ($sanitarInIDs != "''") { |
|
492 | - switch ($this->getCFGDef('showParent', '0')) { |
|
489 | + if ($sanitarInIDs != "''") { |
|
490 | + switch ($this->getCFGDef('showParent', '0')) { |
|
493 | 491 | case '-1': |
494 | 492 | $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")"; |
495 | 493 | break; |
@@ -502,29 +500,29 @@ discard block |
||
502 | 500 | break; |
503 | 501 | } |
504 | 502 | } |
505 | - if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
503 | + if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
506 | 504 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs)); |
507 | - if (empty($tmpWhere)) { |
|
505 | + if (empty($tmpWhere)) { |
|
508 | 506 | $tmpWhere = "c.id IN({$addDocs})"; |
509 | - } else { |
|
507 | + } else { |
|
510 | 508 | $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))"; |
511 | 509 | } |
512 | 510 | } |
513 | - if (!empty($tmpWhere)) { |
|
511 | + if (!empty($tmpWhere)) { |
|
514 | 512 | $where[] = $tmpWhere; |
515 | 513 | } |
516 | - if (!$this->getCFGDef('showNoPublish', 0)) { |
|
514 | + if (!$this->getCFGDef('showNoPublish', 0)) { |
|
517 | 515 | $where[] = "c.deleted=0 AND c.published=1"; |
518 | 516 | } |
519 | - if (!empty($where)) { |
|
517 | + if (!empty($where)) { |
|
520 | 518 | $where = "WHERE " . implode(" AND ", $where); |
521 | - } else { |
|
519 | + } else { |
|
522 | 520 | $where = ''; |
523 | 521 | } |
524 | 522 | $fields = $this->getCFGDef('selectFields', 'c.*'); |
525 | 523 | $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id')); |
526 | 524 | |
527 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
525 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
528 | 526 | $sql = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " . |
529 | 527 | $group . " " . |
530 | 528 | $sort . " " . |
@@ -533,7 +531,7 @@ discard block |
||
533 | 531 | |
534 | 532 | $rows = $this->modx->db->makeArray($sql); |
535 | 533 | |
536 | - foreach ($rows as $item) { |
|
534 | + foreach ($rows as $item) { |
|
537 | 535 | $out[$item['id']] = $item; |
538 | 536 | } |
539 | 537 | } |
@@ -546,10 +544,10 @@ discard block |
||
546 | 544 | * @param string $type |
547 | 545 | * @return string |
548 | 546 | */ |
549 | - public function changeSortType($field, $type) |
|
550 | - { |
|
547 | + public function changeSortType($field, $type) |
|
548 | + { |
|
551 | 549 | $type = trim($type); |
552 | - switch (strtoupper($type)) { |
|
550 | + switch (strtoupper($type)) { |
|
553 | 551 | case 'TVDATETIME': |
554 | 552 | $field = "STR_TO_DATE(" . $field . ",'%d-%m-%Y %H:%i:%s')"; |
555 | 553 | break; |