@@ -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,53 +139,53 @@ 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 | 151 | $item['date'] = (isset($item[$date]) && $date != 'createdon' && $item[$date] != 0 && $item[$date] == (int)$item[$date]) ? $item[$date] : $item['createdon']; |
| 152 | 152 | $item['date'] = $item['date'] + $this->modx->config['server_offset_time']; |
| 153 | - if ($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') { |
|
| 153 | + if ($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M') != '') {
|
|
| 154 | 154 | $item['date'] = strftime($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'), $item['date']); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | $findTpl = $this->renderTPL; |
| 158 | 158 | $tmp = $this->uniformPrepare($item, $i); |
| 159 | 159 | extract($tmp, EXTR_SKIP); |
| 160 | - if ($this->renderTPL == '') { |
|
| 160 | + if ($this->renderTPL == '') {
|
|
| 161 | 161 | $this->renderTPL = $findTpl; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - if ($extPrepare) { |
|
| 164 | + if ($extPrepare) {
|
|
| 165 | 165 | $item = $extPrepare->init($this, array( |
| 166 | 166 | 'data' => $item, |
| 167 | 167 | 'nameParam' => 'prepare' |
| 168 | 168 | )); |
| 169 | - if (is_bool($item) && $item === false) { |
|
| 169 | + if (is_bool($item) && $item === false) {
|
|
| 170 | 170 | $this->skippedDocs++; |
| 171 | 171 | continue; |
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | $tmp = $this->parseChunk($this->renderTPL, $item); |
| 175 | 175 | |
| 176 | - if ($this->getCFGDef('contentPlaceholder', 0) !== 0) { |
|
| 176 | + if ($this->getCFGDef('contentPlaceholder', 0) !== 0) {
|
|
| 177 | 177 | $this->toPlaceholders($tmp, 1, |
| 178 | 178 | "item[" . $i . "]"); // [+item[x]+] – individual placeholder for each iteration documents on this page |
| 179 | 179 | } |
| 180 | 180 | $out .= $tmp; |
| 181 | 181 | $i++; |
| 182 | 182 | } |
| 183 | - } else { |
|
| 183 | + } else {
|
|
| 184 | 184 | $noneTPL = $this->getCFGDef("noneTPL", ""); |
| 185 | 185 | $out = ($noneTPL != '') ? $this->parseChunk($noneTPL, $sysPlh) : ''; |
| 186 | 186 | } |
| 187 | 187 | $out = $this->renderWrap($out); |
| 188 | - } else { |
|
| 188 | + } else {
|
|
| 189 | 189 | $out = 'no template'; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -198,8 +198,8 @@ discard block |
||
| 198 | 198 | * @param array $array |
| 199 | 199 | * @return string |
| 200 | 200 | */ |
| 201 | - public function getJSON($data, $fields, $array = array()) |
|
| 202 | - { |
|
| 201 | + public function getJSON($data, $fields, $array = array()) |
|
| 202 | + {
|
|
| 203 | 203 | $out = array(); |
| 204 | 204 | $fields = is_array($fields) ? $fields : explode(",", $fields); |
| 205 | 205 | $date = $this->getCFGDef('dateSource', 'pub_date'); |
@@ -219,37 +219,37 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | $extE = $this->getExtender('e', true, true); |
| 221 | 221 | |
| 222 | - foreach ($data as $num => $item) { |
|
| 222 | + foreach ($data as $num => $item) {
|
|
| 223 | 223 | $row = $item; |
| 224 | - if ((array('1') == $fields || in_array('summary', $fields)) && $extSummary) { |
|
| 224 | + if ((array('1') == $fields || in_array('summary', $fields)) && $extSummary) {
|
|
| 225 | 225 | $row['summary'] = $this->getSummary($this->_docs[$num], $extSummary, 'introtext', 'content'); |
| 226 | 226 | } |
| 227 | - if (array('1') == $fields || in_array('date', $fields)) { |
|
| 227 | + if (array('1') == $fields || in_array('date', $fields)) {
|
|
| 228 | 228 | $tmp = (isset($this->_docs[$num][$date]) && $date != 'createdon' && $this->_docs[$num][$date] != 0 && $this->_docs[$num][$date] == (int)$this->_docs[$num][$date]) ? $this->_docs[$num][$date] : $this->_docs[$num]['createdon']; |
| 229 | 229 | $row['date'] = strftime($this->getCFGDef('dateFormat', '%d.%b.%y %H:%M'), |
| 230 | 230 | $tmp + $this->modx->config['server_offset_time']); |
| 231 | 231 | } |
| 232 | - if (array('1') == $fields || in_array(array('menutitle', 'pagetitle'), $fields)) { |
|
| 232 | + if (array('1') == $fields || in_array(array('menutitle', 'pagetitle'), $fields)) {
|
|
| 233 | 233 | $row['title'] = ($row['menutitle'] == '' ? $row['pagetitle'] : $row['menutitle']); |
| 234 | 234 | } |
| 235 | 235 | if ((bool)$this->getCFGDef('makeUrl', 1) && (array('1') == $fields || in_array('type', $fields)) |
| 236 | - ) { |
|
| 236 | + ) {
|
|
| 237 | 237 | if ($row['type'] == 'reference' && (array('1') == $fields || in_array('content', $fields)) { |
| 238 | 238 | $row['url'] = is_numeric($row['content']) ? $this->modx->makeUrl($row['content'], '', '', |
| 239 | 239 | $this->getCFGDef('urlScheme', '')) : $row['content']; |
| 240 | - } else { |
|
| 240 | + } else {
|
|
| 241 | 241 | $row['url'] = $this->modx->makeUrl($row['id'], '', '', $this->getCFGDef('urlScheme', '')); |
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | - if ($extE && $tmp = $extE->init($this, array('data' => $row))) { |
|
| 245 | - if (is_array($tmp)) { |
|
| 244 | + if ($extE && $tmp = $extE->init($this, array('data' => $row))) {
|
|
| 245 | + if (is_array($tmp)) {
|
|
| 246 | 246 | $row = $tmp; |
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - if ($extPrepare) { |
|
| 250 | + if ($extPrepare) {
|
|
| 251 | 251 | $row = $extPrepare->init($this, array('data' => $row)); |
| 252 | - if (is_bool($row) && $row === false) { |
|
| 252 | + if (is_bool($row) && $row === false) {
|
|
| 253 | 253 | continue; |
| 254 | 254 | } |
| 255 | 255 | } |
@@ -262,31 +262,31 @@ discard block |
||
| 262 | 262 | /** |
| 263 | 263 | * @abstract |
| 264 | 264 | */ |
| 265 | - public function getChildrenCount() |
|
| 266 | - { |
|
| 265 | + public function getChildrenCount() |
|
| 266 | + {
|
|
| 267 | 267 | $out = 0; |
| 268 | 268 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
| 269 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
| 269 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
|
|
| 270 | 270 | $where = $this->getCFGDef('addWhereList', ''); |
| 271 | 271 | $where = sqlHelper::trimLogicalOp($where); |
| 272 | 272 | $where = ($where ? $where . ' AND ' : '') . $this->_filters['where']; |
| 273 | - if ($where != '' && $this->_filters['where'] != '') { |
|
| 273 | + if ($where != '' && $this->_filters['where'] != '') {
|
|
| 274 | 274 | $where .= " AND "; |
| 275 | 275 | } |
| 276 | 276 | $where = sqlHelper::trimLogicalOp($where); |
| 277 | 277 | |
| 278 | 278 | $where = "WHERE {$where}"; |
| 279 | 279 | $whereArr = array(); |
| 280 | - if (!$this->getCFGDef('showNoPublish', 0)) { |
|
| 280 | + if (!$this->getCFGDef('showNoPublish', 0)) {
|
|
| 281 | 281 | $whereArr[] = "c.deleted=0 AND c.published=1"; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | $tbl_site_content = $this->getTable('site_content', 'c'); |
| 285 | 285 | |
| 286 | - if ($sanitarInIDs != "''") { |
|
| 287 | - switch ($this->getCFGDef('idType', 'parents')) { |
|
| 286 | + if ($sanitarInIDs != "''") {
|
|
| 287 | + switch ($this->getCFGDef('idType', 'parents')) {
|
|
| 288 | 288 | case 'parents': |
| 289 | - switch ($this->getCFGDef('showParent', '0')) { |
|
| 289 | + switch ($this->getCFGDef('showParent', '0')) {
|
|
| 290 | 290 | case '-1': |
| 291 | 291 | $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")"; |
| 292 | 292 | break; |
@@ -298,10 +298,10 @@ discard block |
||
| 298 | 298 | $tmpWhere = "(c.parent IN ({$sanitarInIDs}) OR c.id IN({$sanitarInIDs}))"; |
| 299 | 299 | break; |
| 300 | 300 | } |
| 301 | - if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
| 301 | + if (($addDocs = $this->getCFGDef('documents', '')) != '') {
|
|
| 302 | 302 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs)); |
| 303 | 303 | $whereArr[] = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))"; |
| 304 | - } else { |
|
| 304 | + } else {
|
|
| 305 | 305 | $whereArr[] = $tmpWhere; |
| 306 | 306 | } |
| 307 | 307 | |
@@ -314,14 +314,14 @@ discard block |
||
| 314 | 314 | $from = $tbl_site_content . " " . $this->_filters['join']; |
| 315 | 315 | $where = sqlHelper::trimLogicalOp($where); |
| 316 | 316 | |
| 317 | - if (trim($where) != 'WHERE') { |
|
| 317 | + if (trim($where) != 'WHERE') {
|
|
| 318 | 318 | $where .= " AND "; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | $where .= implode(" AND ", $whereArr); |
| 322 | 322 | $where = sqlHelper::trimLogicalOp($where); |
| 323 | 323 | |
| 324 | - if (trim($where) == 'WHERE') { |
|
| 324 | + if (trim($where) == 'WHERE') {
|
|
| 325 | 325 | $where = ''; |
| 326 | 326 | } |
| 327 | 327 | $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id')); |
@@ -338,11 +338,11 @@ discard block |
||
| 338 | 338 | /** |
| 339 | 339 | * @return array |
| 340 | 340 | */ |
| 341 | - protected function getDocList() |
|
| 342 | - { |
|
| 341 | + protected function getDocList() |
|
| 342 | + {
|
|
| 343 | 343 | $out = array(); |
| 344 | 344 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
| 345 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
| 345 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
|
|
| 346 | 346 | $where = $this->getCFGDef('addWhereList', ''); |
| 347 | 347 | $where = sqlHelper::trimLogicalOp($where); |
| 348 | 348 | |
@@ -350,21 +350,21 @@ discard block |
||
| 350 | 350 | $where = sqlHelper::trimLogicalOp($where); |
| 351 | 351 | |
| 352 | 352 | $tbl_site_content = $this->getTable('site_content', 'c'); |
| 353 | - if ($sanitarInIDs != "''") { |
|
| 353 | + if ($sanitarInIDs != "''") {
|
|
| 354 | 354 | $where .= ($where ? " AND " : "") . "c.id IN ({$sanitarInIDs}) AND"; |
| 355 | 355 | } |
| 356 | 356 | $where = sqlHelper::trimLogicalOp($where); |
| 357 | 357 | |
| 358 | - if ($this->getCFGDef('showNoPublish', 0)) { |
|
| 359 | - if ($where != '') { |
|
| 358 | + if ($this->getCFGDef('showNoPublish', 0)) {
|
|
| 359 | + if ($where != '') {
|
|
| 360 | 360 | $where = "WHERE {$where}"; |
| 361 | - } else { |
|
| 361 | + } else {
|
|
| 362 | 362 | $where = ''; |
| 363 | 363 | } |
| 364 | - } else { |
|
| 365 | - if ($where != '') { |
|
| 364 | + } else {
|
|
| 365 | + if ($where != '') {
|
|
| 366 | 366 | $where = "WHERE {$where} AND "; |
| 367 | - } else { |
|
| 367 | + } else {
|
|
| 368 | 368 | $where = "WHERE {$where} "; |
| 369 | 369 | } |
| 370 | 370 | $where .= "c.deleted=0 AND c.published=1"; |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | |
| 384 | 384 | $rows = $this->modx->db->makeArray($rs); |
| 385 | 385 | |
| 386 | - foreach ($rows as $item) { |
|
| 386 | + foreach ($rows as $item) {
|
|
| 387 | 387 | $out[$item['id']] = $item; |
| 388 | 388 | } |
| 389 | 389 | } |
@@ -395,19 +395,19 @@ discard block |
||
| 395 | 395 | * @param string $id |
| 396 | 396 | * @return array |
| 397 | 397 | */ |
| 398 | - public function getChildrenFolder($id) |
|
| 399 | - { |
|
| 398 | + public function getChildrenFolder($id) |
|
| 399 | + {
|
|
| 400 | 400 | $where = $this->getCFGDef('addWhereFolder', ''); |
| 401 | 401 | $where = sqlHelper::trimLogicalOp($where); |
| 402 | - if ($where != '') { |
|
| 402 | + if ($where != '') {
|
|
| 403 | 403 | $where .= " AND "; |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | $tbl_site_content = $this->getTable('site_content', 'c'); |
| 407 | 407 | $sanitarInIDs = $this->sanitarIn($id); |
| 408 | - if ($this->getCFGDef('showNoPublish', 0)) { |
|
| 408 | + if ($this->getCFGDef('showNoPublish', 0)) {
|
|
| 409 | 409 | $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1"; |
| 410 | - } else { |
|
| 410 | + } else {
|
|
| 411 | 411 | $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1"; |
| 412 | 412 | } |
| 413 | 413 | |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | |
| 416 | 416 | $rows = $this->modx->db->makeArray($rs); |
| 417 | 417 | $out = array(); |
| 418 | - foreach ($rows as $item) { |
|
| 418 | + foreach ($rows as $item) {
|
|
| 419 | 419 | $out[] = $item['id']; |
| 420 | 420 | } |
| 421 | 421 | |
@@ -427,10 +427,10 @@ discard block |
||
| 427 | 427 | * @param $sort |
| 428 | 428 | * @return array |
| 429 | 429 | */ |
| 430 | - protected function injectSortByTV($table, $sort) |
|
| 431 | - { |
|
| 430 | + protected function injectSortByTV($table, $sort) |
|
| 431 | + {
|
|
| 432 | 432 | $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort); |
| 433 | - if (!is_array($out) || empty($out)) { |
|
| 433 | + if (!is_array($out) || empty($out)) {
|
|
| 434 | 434 | $out = array($table, $sort); |
| 435 | 435 | } |
| 436 | 436 | |
@@ -440,19 +440,19 @@ discard block |
||
| 440 | 440 | /** |
| 441 | 441 | * @return array |
| 442 | 442 | */ |
| 443 | - protected function getChildrenList() |
|
| 444 | - { |
|
| 443 | + protected function getChildrenList() |
|
| 444 | + {
|
|
| 445 | 445 | $where = array(); |
| 446 | 446 | $out = array(); |
| 447 | 447 | |
| 448 | 448 | $tmpWhere = $this->getCFGDef('addWhereList', ''); |
| 449 | 449 | $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere); |
| 450 | - if (!empty($tmpWhere)) { |
|
| 450 | + if (!empty($tmpWhere)) {
|
|
| 451 | 451 | $where[] = $tmpWhere; |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']); |
| 455 | - if (!empty($tmpWhere)) { |
|
| 455 | + if (!empty($tmpWhere)) {
|
|
| 456 | 456 | $where[] = $tmpWhere; |
| 457 | 457 | } |
| 458 | 458 | |
@@ -463,8 +463,8 @@ discard block |
||
| 463 | 463 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
| 464 | 464 | |
| 465 | 465 | $tmpWhere = null; |
| 466 | - if ($sanitarInIDs != "''") { |
|
| 467 | - switch ($this->getCFGDef('showParent', '0')) { |
|
| 466 | + if ($sanitarInIDs != "''") {
|
|
| 467 | + switch ($this->getCFGDef('showParent', '0')) {
|
|
| 468 | 468 | case '-1': |
| 469 | 469 | $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")"; |
| 470 | 470 | break; |
@@ -477,29 +477,29 @@ discard block |
||
| 477 | 477 | break; |
| 478 | 478 | } |
| 479 | 479 | } |
| 480 | - if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
| 480 | + if (($addDocs = $this->getCFGDef('documents', '')) != '') {
|
|
| 481 | 481 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs)); |
| 482 | - if (empty($tmpWhere)) { |
|
| 482 | + if (empty($tmpWhere)) {
|
|
| 483 | 483 | $tmpWhere = "c.id IN({$addDocs})"; |
| 484 | - } else { |
|
| 484 | + } else {
|
|
| 485 | 485 | $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))"; |
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | - if (!empty($tmpWhere)) { |
|
| 488 | + if (!empty($tmpWhere)) {
|
|
| 489 | 489 | $where[] = $tmpWhere; |
| 490 | 490 | } |
| 491 | - if (!$this->getCFGDef('showNoPublish', 0)) { |
|
| 491 | + if (!$this->getCFGDef('showNoPublish', 0)) {
|
|
| 492 | 492 | $where[] = "c.deleted=0 AND c.published=1"; |
| 493 | 493 | } |
| 494 | - if (!empty($where)) { |
|
| 494 | + if (!empty($where)) {
|
|
| 495 | 495 | $where = "WHERE " . implode(" AND ", $where); |
| 496 | - } else { |
|
| 496 | + } else {
|
|
| 497 | 497 | $where = ''; |
| 498 | 498 | } |
| 499 | 499 | $fields = $this->getCFGDef('selectFields', 'c.*'); |
| 500 | 500 | $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id')); |
| 501 | 501 | |
| 502 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
| 502 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
|
|
| 503 | 503 | $sql = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " . |
| 504 | 504 | $group . " " . |
| 505 | 505 | $sort . " " . |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | |
| 509 | 509 | $rows = $this->modx->db->makeArray($sql); |
| 510 | 510 | |
| 511 | - foreach ($rows as $item) { |
|
| 511 | + foreach ($rows as $item) {
|
|
| 512 | 512 | $out[$item['id']] = $item; |
| 513 | 513 | } |
| 514 | 514 | } |
@@ -521,10 +521,10 @@ discard block |
||
| 521 | 521 | * @param string $type |
| 522 | 522 | * @return string |
| 523 | 523 | */ |
| 524 | - public function changeSortType($field, $type) |
|
| 525 | - { |
|
| 524 | + public function changeSortType($field, $type) |
|
| 525 | + {
|
|
| 526 | 526 | $type = trim($type); |
| 527 | - switch (strtoupper($type)) { |
|
| 527 | + switch (strtoupper($type)) {
|
|
| 528 | 528 | case 'TVDATETIME': |
| 529 | 529 | $field = "STR_TO_DATE(" . $field . ",'%d-%m-%Y %H:%i:%s')"; |
| 530 | 530 | break; |