@@ -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 = $item[$date] != 0 && $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)) { |
|
| 231 | + if (array('1') == $fields || in_array('date', $fields)) {
|
|
| 232 | 232 | if (isset(isset($this->_docs[$num][$date])) { |
| 233 | 233 | $_date = isset($this->_docs[$num][$date] != 0 && isset($this->_docs[$num][$date] == (int)isset($this->_docs[$num][$date] ? isset($this->_docs[$num][$date] : strtotime(isset($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,31 +273,31 @@ 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 | $where = $this->getCFGDef('addWhereList', ''); |
| 282 | 282 | $where = sqlHelper::trimLogicalOp($where); |
| 283 | 283 | $where = ($where ? $where . ' AND ' : '') . $this->_filters['where']; |
| 284 | - if ($where != '' && $this->_filters['where'] != '') { |
|
| 284 | + if ($where != '' && $this->_filters['where'] != '') {
|
|
| 285 | 285 | $where .= " AND "; |
| 286 | 286 | } |
| 287 | 287 | $where = sqlHelper::trimLogicalOp($where); |
| 288 | 288 | |
| 289 | 289 | $where = "WHERE {$where}"; |
| 290 | 290 | $whereArr = array(); |
| 291 | - if (!$this->getCFGDef('showNoPublish', 0)) { |
|
| 291 | + if (!$this->getCFGDef('showNoPublish', 0)) {
|
|
| 292 | 292 | $whereArr[] = "c.deleted=0 AND c.published=1"; |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | $tbl_site_content = $this->getTable('site_content', 'c'); |
| 296 | 296 | |
| 297 | - if ($sanitarInIDs != "''") { |
|
| 298 | - switch ($this->getCFGDef('idType', 'parents')) { |
|
| 297 | + if ($sanitarInIDs != "''") {
|
|
| 298 | + switch ($this->getCFGDef('idType', 'parents')) {
|
|
| 299 | 299 | case 'parents': |
| 300 | - switch ($this->getCFGDef('showParent', '0')) { |
|
| 300 | + switch ($this->getCFGDef('showParent', '0')) {
|
|
| 301 | 301 | case '-1': |
| 302 | 302 | $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")"; |
| 303 | 303 | break; |
@@ -309,10 +309,10 @@ discard block |
||
| 309 | 309 | $tmpWhere = "(c.parent IN ({$sanitarInIDs}) OR c.id IN({$sanitarInIDs}))"; |
| 310 | 310 | break; |
| 311 | 311 | } |
| 312 | - if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
| 312 | + if (($addDocs = $this->getCFGDef('documents', '')) != '') {
|
|
| 313 | 313 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs)); |
| 314 | 314 | $whereArr[] = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))"; |
| 315 | - } else { |
|
| 315 | + } else {
|
|
| 316 | 316 | $whereArr[] = $tmpWhere; |
| 317 | 317 | } |
| 318 | 318 | |
@@ -325,14 +325,14 @@ discard block |
||
| 325 | 325 | $from = $tbl_site_content . " " . $this->_filters['join']; |
| 326 | 326 | $where = sqlHelper::trimLogicalOp($where); |
| 327 | 327 | |
| 328 | - if (trim($where) != 'WHERE') { |
|
| 328 | + if (trim($where) != 'WHERE') {
|
|
| 329 | 329 | $where .= " AND "; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | $where .= implode(" AND ", $whereArr); |
| 333 | 333 | $where = sqlHelper::trimLogicalOp($where); |
| 334 | 334 | |
| 335 | - if (trim($where) == 'WHERE') { |
|
| 335 | + if (trim($where) == 'WHERE') {
|
|
| 336 | 336 | $where = ''; |
| 337 | 337 | } |
| 338 | 338 | $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id')); |
@@ -349,11 +349,11 @@ discard block |
||
| 349 | 349 | /** |
| 350 | 350 | * @return array |
| 351 | 351 | */ |
| 352 | - protected function getDocList() |
|
| 353 | - { |
|
| 352 | + protected function getDocList() |
|
| 353 | + {
|
|
| 354 | 354 | $out = array(); |
| 355 | 355 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
| 356 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
| 356 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
|
|
| 357 | 357 | $where = $this->getCFGDef('addWhereList', ''); |
| 358 | 358 | $where = sqlHelper::trimLogicalOp($where); |
| 359 | 359 | |
@@ -361,21 +361,21 @@ discard block |
||
| 361 | 361 | $where = sqlHelper::trimLogicalOp($where); |
| 362 | 362 | |
| 363 | 363 | $tbl_site_content = $this->getTable('site_content', 'c'); |
| 364 | - if ($sanitarInIDs != "''") { |
|
| 364 | + if ($sanitarInIDs != "''") {
|
|
| 365 | 365 | $where .= ($where ? " AND " : "") . "c.id IN ({$sanitarInIDs}) AND"; |
| 366 | 366 | } |
| 367 | 367 | $where = sqlHelper::trimLogicalOp($where); |
| 368 | 368 | |
| 369 | - if ($this->getCFGDef('showNoPublish', 0)) { |
|
| 370 | - if ($where != '') { |
|
| 369 | + if ($this->getCFGDef('showNoPublish', 0)) {
|
|
| 370 | + if ($where != '') {
|
|
| 371 | 371 | $where = "WHERE {$where}"; |
| 372 | - } else { |
|
| 372 | + } else {
|
|
| 373 | 373 | $where = ''; |
| 374 | 374 | } |
| 375 | - } else { |
|
| 376 | - if ($where != '') { |
|
| 375 | + } else {
|
|
| 376 | + if ($where != '') {
|
|
| 377 | 377 | $where = "WHERE {$where} AND "; |
| 378 | - } else { |
|
| 378 | + } else {
|
|
| 379 | 379 | $where = "WHERE {$where} "; |
| 380 | 380 | } |
| 381 | 381 | $where .= "c.deleted=0 AND c.published=1"; |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | |
| 395 | 395 | $rows = $this->modx->db->makeArray($rs); |
| 396 | 396 | |
| 397 | - foreach ($rows as $item) { |
|
| 397 | + foreach ($rows as $item) {
|
|
| 398 | 398 | $out[$item['id']] = $item; |
| 399 | 399 | } |
| 400 | 400 | } |
@@ -406,19 +406,19 @@ discard block |
||
| 406 | 406 | * @param string $id |
| 407 | 407 | * @return array |
| 408 | 408 | */ |
| 409 | - public function getChildrenFolder($id) |
|
| 410 | - { |
|
| 409 | + public function getChildrenFolder($id) |
|
| 410 | + {
|
|
| 411 | 411 | $where = $this->getCFGDef('addWhereFolder', ''); |
| 412 | 412 | $where = sqlHelper::trimLogicalOp($where); |
| 413 | - if ($where != '') { |
|
| 413 | + if ($where != '') {
|
|
| 414 | 414 | $where .= " AND "; |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | $tbl_site_content = $this->getTable('site_content', 'c'); |
| 418 | 418 | $sanitarInIDs = $this->sanitarIn($id); |
| 419 | - if ($this->getCFGDef('showNoPublish', 0)) { |
|
| 419 | + if ($this->getCFGDef('showNoPublish', 0)) {
|
|
| 420 | 420 | $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.isfolder=1"; |
| 421 | - } else { |
|
| 421 | + } else {
|
|
| 422 | 422 | $where = "WHERE {$where} c.parent IN ({$sanitarInIDs}) AND c.deleted=0 AND c.published=1 AND c.isfolder=1"; |
| 423 | 423 | } |
| 424 | 424 | |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | |
| 427 | 427 | $rows = $this->modx->db->makeArray($rs); |
| 428 | 428 | $out = array(); |
| 429 | - foreach ($rows as $item) { |
|
| 429 | + foreach ($rows as $item) {
|
|
| 430 | 430 | $out[] = $item['id']; |
| 431 | 431 | } |
| 432 | 432 | |
@@ -438,10 +438,10 @@ discard block |
||
| 438 | 438 | * @param $sort |
| 439 | 439 | * @return array |
| 440 | 440 | */ |
| 441 | - protected function injectSortByTV($table, $sort) |
|
| 442 | - { |
|
| 441 | + protected function injectSortByTV($table, $sort) |
|
| 442 | + {
|
|
| 443 | 443 | $out = $this->getExtender('tv', true, true)->injectSortByTV($table, $sort); |
| 444 | - if (!is_array($out) || empty($out)) { |
|
| 444 | + if (!is_array($out) || empty($out)) {
|
|
| 445 | 445 | $out = array($table, $sort); |
| 446 | 446 | } |
| 447 | 447 | |
@@ -451,19 +451,19 @@ discard block |
||
| 451 | 451 | /** |
| 452 | 452 | * @return array |
| 453 | 453 | */ |
| 454 | - protected function getChildrenList() |
|
| 455 | - { |
|
| 454 | + protected function getChildrenList() |
|
| 455 | + {
|
|
| 456 | 456 | $where = array(); |
| 457 | 457 | $out = array(); |
| 458 | 458 | |
| 459 | 459 | $tmpWhere = $this->getCFGDef('addWhereList', ''); |
| 460 | 460 | $tmpWhere = sqlHelper::trimLogicalOp($tmpWhere); |
| 461 | - if (!empty($tmpWhere)) { |
|
| 461 | + if (!empty($tmpWhere)) {
|
|
| 462 | 462 | $where[] = $tmpWhere; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | $tmpWhere = sqlHelper::trimLogicalOp($this->_filters['where']); |
| 466 | - if (!empty($tmpWhere)) { |
|
| 466 | + if (!empty($tmpWhere)) {
|
|
| 467 | 467 | $where[] = $tmpWhere; |
| 468 | 468 | } |
| 469 | 469 | |
@@ -474,8 +474,8 @@ discard block |
||
| 474 | 474 | $sanitarInIDs = $this->sanitarIn($this->IDs); |
| 475 | 475 | |
| 476 | 476 | $tmpWhere = null; |
| 477 | - if ($sanitarInIDs != "''") { |
|
| 478 | - switch ($this->getCFGDef('showParent', '0')) { |
|
| 477 | + if ($sanitarInIDs != "''") {
|
|
| 478 | + switch ($this->getCFGDef('showParent', '0')) {
|
|
| 479 | 479 | case '-1': |
| 480 | 480 | $tmpWhere = "c.parent IN (" . $sanitarInIDs . ")"; |
| 481 | 481 | break; |
@@ -488,29 +488,29 @@ discard block |
||
| 488 | 488 | break; |
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | - if (($addDocs = $this->getCFGDef('documents', '')) != '') { |
|
| 491 | + if (($addDocs = $this->getCFGDef('documents', '')) != '') {
|
|
| 492 | 492 | $addDocs = $this->sanitarIn($this->cleanIDs($addDocs)); |
| 493 | - if (empty($tmpWhere)) { |
|
| 493 | + if (empty($tmpWhere)) {
|
|
| 494 | 494 | $tmpWhere = "c.id IN({$addDocs})"; |
| 495 | - } else { |
|
| 495 | + } else {
|
|
| 496 | 496 | $tmpWhere = "((" . $tmpWhere . ") OR c.id IN({$addDocs}))"; |
| 497 | 497 | } |
| 498 | 498 | } |
| 499 | - if (!empty($tmpWhere)) { |
|
| 499 | + if (!empty($tmpWhere)) {
|
|
| 500 | 500 | $where[] = $tmpWhere; |
| 501 | 501 | } |
| 502 | - if (!$this->getCFGDef('showNoPublish', 0)) { |
|
| 502 | + if (!$this->getCFGDef('showNoPublish', 0)) {
|
|
| 503 | 503 | $where[] = "c.deleted=0 AND c.published=1"; |
| 504 | 504 | } |
| 505 | - if (!empty($where)) { |
|
| 505 | + if (!empty($where)) {
|
|
| 506 | 506 | $where = "WHERE " . implode(" AND ", $where); |
| 507 | - } else { |
|
| 507 | + } else {
|
|
| 508 | 508 | $where = ''; |
| 509 | 509 | } |
| 510 | 510 | $fields = $this->getCFGDef('selectFields', 'c.*'); |
| 511 | 511 | $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id')); |
| 512 | 512 | |
| 513 | - if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { |
|
| 513 | + if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) {
|
|
| 514 | 514 | $sql = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " . |
| 515 | 515 | $group . " " . |
| 516 | 516 | $sort . " " . |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | |
| 520 | 520 | $rows = $this->modx->db->makeArray($sql); |
| 521 | 521 | |
| 522 | - foreach ($rows as $item) { |
|
| 522 | + foreach ($rows as $item) {
|
|
| 523 | 523 | $out[$item['id']] = $item; |
| 524 | 524 | } |
| 525 | 525 | } |
@@ -532,10 +532,10 @@ discard block |
||
| 532 | 532 | * @param string $type |
| 533 | 533 | * @return string |
| 534 | 534 | */ |
| 535 | - public function changeSortType($field, $type) |
|
| 536 | - { |
|
| 535 | + public function changeSortType($field, $type) |
|
| 536 | + {
|
|
| 537 | 537 | $type = trim($type); |
| 538 | - switch (strtoupper($type)) { |
|
| 538 | + switch (strtoupper($type)) {
|
|
| 539 | 539 | case 'TVDATETIME': |
| 540 | 540 | $field = "STR_TO_DATE(" . $field . ",'%d-%m-%Y %H:%i:%s')"; |
| 541 | 541 | break; |