@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $where[] = "{$this->getPK()} IN ({$sanitarInIDs})"; |
229 | 229 | } |
230 | 230 | |
231 | - if (!empty($where)) { |
|
231 | + if ( ! empty($where)) { |
|
232 | 232 | $where = "WHERE " . implode(" AND ", $where); |
233 | 233 | } else { |
234 | 234 | $where = ''; |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | //------- end of block ------- |
267 | 267 | |
268 | 268 | |
269 | - if (!empty($tmpWhere)) { |
|
269 | + if ( ! empty($tmpWhere)) { |
|
270 | 270 | $where[] = $tmpWhere; |
271 | 271 | } |
272 | 272 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
@@ -295,10 +295,10 @@ discard block |
||
295 | 295 | $tmpWhere = "((" . $tmpWhere . ") OR {$this->getPK()} IN({$addDocs}))"; |
296 | 296 | } |
297 | 297 | } |
298 | - if (!empty($tmpWhere)) { |
|
298 | + if ( ! empty($tmpWhere)) { |
|
299 | 299 | $where[] = $tmpWhere; |
300 | 300 | } |
301 | - if (!empty($where)) { |
|
301 | + if ( ! empty($where)) { |
|
302 | 302 | $where = "WHERE " . implode(" AND ", $where); |
303 | 303 | } else { |
304 | 304 | $where = ''; |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | } |
372 | 372 | } |
373 | 373 | } |
374 | - if (!empty($where)) { |
|
374 | + if ( ! empty($where)) { |
|
375 | 375 | $where = "WHERE " . implode(" AND ", $where); |
376 | 376 | } else { |
377 | 377 | $where = ''; |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | |
399 | 399 | $tmp = $this->getCFGDef('addWhereFolder', ''); |
400 | 400 | $where = "{$this->getParentField()} IN ({$sanitarInIDs})"; |
401 | - if (!empty($tmp)) { |
|
401 | + if ( ! empty($tmp)) { |
|
402 | 402 | $where .= " AND " . $tmp; |
403 | 403 | } |
404 | 404 |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | * @param contentField =`description` //content |
11 | 11 | * @param table =`` //table name |
12 | 12 | */ |
13 | -class onetableDocLister extends DocLister |
|
14 | -{ |
|
13 | +class onetableDocLister extends DocLister |
|
14 | +{ |
|
15 | 15 | /** |
16 | 16 | * @var string |
17 | 17 | */ |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * @absctract |
31 | 31 | */ |
32 | - public function getDocs($tvlist = '') |
|
33 | - { |
|
34 | - if ($this->checkExtender('paginate')) { |
|
32 | + public function getDocs($tvlist = '') |
|
33 | + { |
|
34 | + if ($this->checkExtender('paginate')) { |
|
35 | 35 | $this->extender['paginate']->init($this); |
36 | 36 | } |
37 | 37 | $type = $this->getCFGDef('idType', 'parents'); |
@@ -44,26 +44,26 @@ discard block |
||
44 | 44 | * @param string $tpl |
45 | 45 | * @return string |
46 | 46 | */ |
47 | - public function _render($tpl = '') |
|
48 | - { |
|
47 | + public function _render($tpl = '') |
|
48 | + { |
|
49 | 49 | $out = ''; |
50 | 50 | $separator = $this->getCFGDef('outputSeparator', ''); |
51 | - if ($tpl == '') { |
|
51 | + if ($tpl == '') { |
|
52 | 52 | $tpl = $this->getCFGDef('tpl', ''); |
53 | 53 | } |
54 | - if ($tpl != '') { |
|
54 | + if ($tpl != '') { |
|
55 | 55 | $this->toPlaceholders(count($this->_docs), 1, "display"); // [+display+] - сколько показано на странице. |
56 | 56 | |
57 | 57 | $i = 1; |
58 | 58 | $sysPlh = $this->renameKeyArr($this->_plh, $this->getCFGDef("sysKey", "dl")); |
59 | 59 | $noneTPL = $this->getCFGDef("noneTPL", ""); |
60 | - if (count($this->_docs) == 0 && $noneTPL != '') { |
|
60 | + if (count($this->_docs) == 0 && $noneTPL != '') { |
|
61 | 61 | $out = $this->parseChunk($noneTPL, $sysPlh); |
62 | - } else { |
|
62 | + } else { |
|
63 | 63 | /** |
64 | 64 | * @var $extUser user_DL_Extender |
65 | 65 | */ |
66 | - if ($extUser = $this->getExtender('user')) { |
|
66 | + if ($extUser = $this->getExtender('user')) { |
|
67 | 67 | $extUser->init($this, array('fields' => $this->getCFGDef("userFields", ""))); |
68 | 68 | } |
69 | 69 | |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | */ |
78 | 78 | $extPrepare = $this->getExtender('prepare'); |
79 | 79 | $this->skippedDocs = 0; |
80 | - foreach ($this->_docs as $item) { |
|
80 | + foreach ($this->_docs as $item) { |
|
81 | 81 | $this->renderTPL = $tpl; |
82 | - if ($extUser) { |
|
82 | + if ($extUser) { |
|
83 | 83 | $item = $extUser->setUserData($item); //[+user.id.createdby+], [+user.fullname.publishedby+], [+dl.user.publishedby+].... |
84 | 84 | } |
85 | 85 | |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | "dl") . '.iteration'] = $i; //[+iteration+] - Number element. Starting from zero |
93 | 93 | |
94 | 94 | $date = $this->getCFGDef('dateSource', 'pub_date'); |
95 | - if (isset($item[$date])) { |
|
95 | + if (isset($item[$date])) { |
|
96 | 96 | $_date = is_numeric($item[$date]) && $item[$date] == (int)$item[$date] ? $item[$date] : strtotime($item[$date]); |
97 | - if ($_date !== false) { |
|
97 | + if ($_date !== false) { |
|
98 | 98 | $_date = $_date + $this->modx->config['server_offset_time']; |
99 | 99 | $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'); |
100 | - if ($dateFormat) { |
|
100 | + if ($dateFormat) { |
|
101 | 101 | $item['date'] = strftime($dateFormat, $_date); |
102 | 102 | } |
103 | 103 | } |
@@ -106,27 +106,27 @@ discard block |
||
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 | - if ($this->getCFGDef('contentPlaceholder', 0) !== 0) { |
|
124 | + if ($this->getCFGDef('contentPlaceholder', 0) !== 0) { |
|
125 | 125 | $this->toPlaceholders($tmp, 1, |
126 | 126 | "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page |
127 | 127 | } |
128 | 128 | $out .= $tmp; |
129 | - if (next($this->_docs) !== false) { |
|
129 | + if (next($this->_docs) !== false) { |
|
130 | 130 | $out .= $separator; |
131 | 131 | } |
132 | 132 | $i++; |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | * @param array $array |
145 | 145 | * @return string |
146 | 146 | */ |
147 | - public function getJSON($data, $fields, $array = array()) |
|
148 | - { |
|
147 | + public function getJSON($data, $fields, $array = array()) |
|
148 | + { |
|
149 | 149 | $out = array(); |
150 | 150 | $fields = is_array($fields) ? $fields : explode(",", $fields); |
151 | 151 | $date = $this->getCFGDef('dateSource', 'pub_date'); |
@@ -164,19 +164,19 @@ discard block |
||
164 | 164 | * @var $extE e_DL_Extender |
165 | 165 | */ |
166 | 166 | $extE = $this->getExtender('e', true, true); |
167 | - foreach ($data as $num => $row) { |
|
167 | + foreach ($data as $num => $row) { |
|
168 | 168 | |
169 | - switch (true) { |
|
169 | + switch (true) { |
|
170 | 170 | case ((array('1') == $fields || in_array('summary', $fields)) && $extSummary): |
171 | 171 | $row['summary'] = $this->getSummary($row, $extSummary, 'introtext'); |
172 | 172 | //without break |
173 | 173 | case ((array('1') == $fields || in_array('date', $fields)) && $date != 'date'): |
174 | - if (isset($row[$date])) { |
|
174 | + if (isset($row[$date])) { |
|
175 | 175 | $_date = is_numeric($row[$date]) && $row[$date] == (int)$row[$date] ? $row[$date] : strtotime($row[$date]); |
176 | - if ($_date !== false) { |
|
176 | + if ($_date !== false) { |
|
177 | 177 | $_date = $_date + $this->modx->config['server_offset_time']; |
178 | 178 | $dateFormat = $this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'); |
179 | - if ($dateFormat) { |
|
179 | + if ($dateFormat) { |
|
180 | 180 | $row['date'] = strftime($dateFormat, $_date); |
181 | 181 | } |
182 | 182 | } |
@@ -184,15 +184,15 @@ discard block |
||
184 | 184 | //nobreak |
185 | 185 | } |
186 | 186 | |
187 | - if ($extE && $tmp = $extE->init($this, array('data' => $row))) { |
|
188 | - if (is_array($tmp)) { |
|
187 | + if ($extE && $tmp = $extE->init($this, array('data' => $row))) { |
|
188 | + if (is_array($tmp)) { |
|
189 | 189 | $row = $tmp; |
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
193 | - if ($extPrepare) { |
|
193 | + if ($extPrepare) { |
|
194 | 194 | $row = $extPrepare->init($this, array('data' => $row)); |
195 | - if (is_bool($row) && $row === false) { |
|
195 | + if (is_bool($row) && $row === false) { |
|
196 | 196 | continue; |
197 | 197 | } |
198 | 198 | } |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | /** |
206 | 206 | * @return array |
207 | 207 | */ |
208 | - protected function getDocList() |
|
209 | - { |
|
208 | + protected function getDocList() |
|
209 | + { |
|
210 | 210 | $out = array(); |
211 | 211 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
212 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
212 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
213 | 213 | $from = $this->table . " " . $this->_filters['join']; |
214 | 214 | $where = $this->getCFGDef('addWhereList', ''); |
215 | 215 | |
@@ -219,18 +219,18 @@ discard block |
||
219 | 219 | //------- end of block ------- |
220 | 220 | |
221 | 221 | |
222 | - if ($where != '') { |
|
222 | + if ($where != '') { |
|
223 | 223 | $where = array($where); |
224 | - } else { |
|
224 | + } else { |
|
225 | 225 | $where = array(); |
226 | 226 | } |
227 | - if ($sanitarInIDs != "''") { |
|
227 | + if ($sanitarInIDs != "''") { |
|
228 | 228 | $where[] = "{$this->getPK()} IN ({$sanitarInIDs})"; |
229 | 229 | } |
230 | 230 | |
231 | - if (!empty($where)) { |
|
231 | + if (!empty($where)) { |
|
232 | 232 | $where = "WHERE " . implode(" AND ", $where); |
233 | - } else { |
|
233 | + } else { |
|
234 | 234 | $where = ''; |
235 | 235 | } |
236 | 236 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $rs = $this->dbQuery("SELECT {$fields} FROM {$from} {$where} {$group} {$sort} {$limit}"); |
242 | 242 | |
243 | 243 | $pk = $this->getPK(false); |
244 | - while ($item = $this->modx->db->getRow($rs)) { |
|
244 | + while ($item = $this->modx->db->getRow($rs)) { |
|
245 | 245 | $out[$item[$pk]] = $item; |
246 | 246 | } |
247 | 247 | } |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | /** |
253 | 253 | * @return array |
254 | 254 | */ |
255 | - protected function getChildrenList() |
|
256 | - { |
|
255 | + protected function getChildrenList() |
|
256 | + { |
|
257 | 257 | $where = array(); |
258 | 258 | $out = array(); |
259 | 259 | $from = $this->table . " " . $this->_filters['join']; |
@@ -266,15 +266,15 @@ discard block |
||
266 | 266 | //------- end of block ------- |
267 | 267 | |
268 | 268 | |
269 | - if (!empty($tmpWhere)) { |
|
269 | + if (!empty($tmpWhere)) { |
|
270 | 270 | $where[] = $tmpWhere; |
271 | 271 | } |
272 | 272 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
273 | 273 | |
274 | 274 | $tmpWhere = null; |
275 | - if ($sanitarInIDs != "''") { |
|
275 | + if ($sanitarInIDs != "''") { |
|
276 | 276 | $tmpWhere = "({$this->getParentField()} IN (" . $sanitarInIDs . ")"; |
277 | - switch ($this->getCFGDef('showParent', '0')) { |
|
277 | + switch ($this->getCFGDef('showParent', '0')) { |
|
278 | 278 | case -1: |
279 | 279 | $tmpWhere .= ")"; |
280 | 280 | break; |
@@ -287,32 +287,32 @@ discard block |
||
287 | 287 | break; |
288 | 288 | } |
289 | 289 | } |
290 | - if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
290 | + if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
291 | 291 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs)); |
292 | - if (empty($tmpWhere)) { |
|
292 | + if (empty($tmpWhere)) { |
|
293 | 293 | $tmpWhere = $this->getPK() . " IN({$addDocs})"; |
294 | - } else { |
|
294 | + } else { |
|
295 | 295 | $tmpWhere = "((" . $tmpWhere . ") OR {$this->getPK()} IN({$addDocs}))"; |
296 | 296 | } |
297 | 297 | } |
298 | - if (!empty($tmpWhere)) { |
|
298 | + if (!empty($tmpWhere)) { |
|
299 | 299 | $where[] = $tmpWhere; |
300 | 300 | } |
301 | - if (!empty($where)) { |
|
301 | + if (!empty($where)) { |
|
302 | 302 | $where = "WHERE " . implode(" AND ", $where); |
303 | - } else { |
|
303 | + } else { |
|
304 | 304 | $where = ''; |
305 | 305 | } |
306 | 306 | $fields = $this->getCFGDef('selectFields', '*'); |
307 | 307 | $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); |
308 | 308 | $sort = $this->SortOrderSQL($this->getPK()); |
309 | 309 | $limit = $this->LimitSQL($this->getCFGDef('queryLimit', 0)); |
310 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
310 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
311 | 311 | $rs = $this->dbQuery("SELECT {$fields} FROM {$from} {$where} {$group} {$sort} {$limit}"); |
312 | 312 | |
313 | 313 | $pk = $this->getPK(false); |
314 | 314 | |
315 | - while ($item = $this->modx->db->getRow($rs)) { |
|
315 | + while ($item = $this->modx->db->getRow($rs)) { |
|
316 | 316 | $out[$item[$pk]] = $item; |
317 | 317 | } |
318 | 318 | |
@@ -324,11 +324,11 @@ discard block |
||
324 | 324 | /** |
325 | 325 | * @absctract |
326 | 326 | */ |
327 | - public function getChildrenCount() |
|
328 | - { |
|
327 | + public function getChildrenCount() |
|
328 | + { |
|
329 | 329 | $out = 0; |
330 | 330 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
331 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
331 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
332 | 332 | $from = $this->table . " " . $this->_filters['join']; |
333 | 333 | $where = $this->getCFGDef('addWhereList', ''); |
334 | 334 | |
@@ -337,16 +337,16 @@ discard block |
||
337 | 337 | $where = sqlHelper::trimLogicalOp($where); |
338 | 338 | //------- end of block ------- |
339 | 339 | |
340 | - if ($where != '') { |
|
340 | + if ($where != '') { |
|
341 | 341 | $where = array($where); |
342 | - } else { |
|
342 | + } else { |
|
343 | 343 | $where = array(); |
344 | 344 | } |
345 | - if ($sanitarInIDs != "''") { |
|
346 | - if ($sanitarInIDs != "''") { |
|
347 | - switch ($this->getCFGDef('idType', 'parents')) { |
|
345 | + if ($sanitarInIDs != "''") { |
|
346 | + if ($sanitarInIDs != "''") { |
|
347 | + switch ($this->getCFGDef('idType', 'parents')) { |
|
348 | 348 | case 'parents': |
349 | - switch ($this->getCFGDef('showParent', '0')) { |
|
349 | + switch ($this->getCFGDef('showParent', '0')) { |
|
350 | 350 | case '-1': |
351 | 351 | $tmpWhere = "{$this->getParentField()} IN ({$sanitarInIDs})"; |
352 | 352 | break; |
@@ -358,10 +358,10 @@ discard block |
||
358 | 358 | $tmpWhere = "({$this->getParentField()} IN ({$sanitarInIDs}) OR {$this->getPK()} IN({$sanitarInIDs}))"; |
359 | 359 | break; |
360 | 360 | } |
361 | - if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
361 | + if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
362 | 362 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs)); |
363 | 363 | $where[] = "((" . $tmpWhere . ") OR {$this->getPK()} IN({$addDocs}))"; |
364 | - } else { |
|
364 | + } else { |
|
365 | 365 | $where[] = $tmpWhere; |
366 | 366 | } |
367 | 367 | break; |
@@ -371,9 +371,9 @@ discard block |
||
371 | 371 | } |
372 | 372 | } |
373 | 373 | } |
374 | - if (!empty($where)) { |
|
374 | + if (!empty($where)) { |
|
375 | 375 | $where = "WHERE " . implode(" AND ", $where); |
376 | - } else { |
|
376 | + } else { |
|
377 | 377 | $where = ''; |
378 | 378 | } |
379 | 379 | |
@@ -391,20 +391,20 @@ discard block |
||
391 | 391 | * @param string $id |
392 | 392 | * @return array |
393 | 393 | */ |
394 | - public function getChildrenFolder($id) |
|
395 | - { |
|
394 | + public function getChildrenFolder($id) |
|
395 | + { |
|
396 | 396 | $out = array(); |
397 | 397 | $sanitarInIDs = $this->sanitarIn($id); |
398 | 398 | |
399 | 399 | $tmp = $this->getCFGDef('addWhereFolder', ''); |
400 | 400 | $where = "{$this->getParentField()} IN ({$sanitarInIDs})"; |
401 | - if (!empty($tmp)) { |
|
401 | + if (!empty($tmp)) { |
|
402 | 402 | $where .= " AND " . $tmp; |
403 | 403 | } |
404 | 404 | |
405 | 405 | $rs = $this->dbQuery("SELECT {$this->getPK()} FROM {$this->table} WHERE {$where}"); |
406 | 406 | $pk = $this->getPK(false); |
407 | - while ($item = $this->modx->db->getRow($rs)) { |
|
407 | + while ($item = $this->modx->db->getRow($rs)) { |
|
408 | 408 | $out[] = $item[$pk]; |
409 | 409 | } |
410 | 410 |