Changeset 3874:ab8368569446 for inc/core/class.dc.blog.php
- Timestamp:
- 09/14/18 12:16:17 (7 years ago)
- Branch:
- default
- File:
-
- 1 edited
-
inc/core/class.dc.blog.php (modified) (37 diffs)
Legend:
- Unmodified
- Added
- Removed
-
inc/core/class.dc.blog.php
r3731 r3874 49 49 public $public_path; 50 50 51 private $post_status = array();52 private $comment_status = array();51 private $post_status = []; 52 private $comment_status = []; 53 53 54 54 private $categories; … … 249 249 $rs = $this->con->select($strReq); 250 250 251 $affected_posts = array();251 $affected_posts = []; 252 252 while ($rs->fetch()) { 253 253 $affected_posts[] = (integer) $rs->post_id; … … 269 269 $rs = $this->con->select($strReq); 270 270 271 $posts = array();271 $posts = []; 272 272 while ($rs->fetch()) { 273 273 if ($rs->comment_trackback) { … … 320 320 @return <b>record</b> 321 321 */ 322 public function getCategories($params = array())323 { 324 $c_params = array();322 public function getCategories($params = []) 323 { 324 $c_params = []; 325 325 if (isset($params['post_type'])) { 326 326 $c_params['post_type'] = $params['post_type']; … … 341 341 342 342 # Get each categories total posts count 343 $data = array();344 $stack = array();343 $data = []; 344 $stack = []; 345 345 $level = 0; 346 346 $cols = $rs->columns(); … … 370 370 $level = $rs->level; 371 371 372 $t = array();372 $t = []; 373 373 foreach ($cols as $c) { 374 374 $t[$c] = $rs->f($c); … … 388 388 if ($v['cat_id'] == $params['cat_id']) { 389 389 $found = true; 390 $data = array($v);390 $data = [$v]; 391 391 break; 392 392 } 393 393 } 394 394 if (!$found) { 395 $data = array();395 $data = []; 396 396 } 397 397 } … … 403 403 if ($v['cat_url'] == $params['cat_url']) { 404 404 $found = true; 405 $data = array($v);405 $data = [$v]; 406 406 break; 407 407 } 408 408 } 409 409 if (!$found) { 410 $data = array();410 $data = []; 411 411 } 412 412 } … … 423 423 public function getCategory($id) 424 424 { 425 return $this->getCategories( array('cat_id' => $id));425 return $this->getCategories(['cat_id' => $id]); 426 426 } 427 427 … … 456 456 public function getCategoryFirstChildren($id) 457 457 { 458 return $this->getCategories( array('start' => $id, 'level' => $id == 0 ? 1 : 2));459 } 460 461 private function getCategoriesCounter($params = array())458 return $this->getCategories(['start' => $id, 'level' => $id == 0 ? 1 : 2]); 459 } 460 461 private function getCategoriesCounter($params = []) 462 462 { 463 463 $strReq = … … 478 478 479 479 $rs = $this->con->select($strReq); 480 $counters = array();480 $counters = []; 481 481 while ($rs->fetch()) { 482 482 $counters[$rs->cat_id] = $rs->nb_post; … … 499 499 } 500 500 501 $url = array();501 $url = []; 502 502 if ($parent != 0) { 503 503 $rs = $this->getCategory($parent); 504 504 if ($rs->isEmpty()) { 505 $url = array();505 $url = []; 506 506 } else { 507 507 $url[] = $rs->cat_url; … … 551 551 552 552 if ($cur->cat_url == '') { 553 $url = array();553 $url = []; 554 554 $rs = $this->categories()->getParents($id); 555 555 while ($rs->fetch()) { … … 695 695 696 696 $rs = $this->con->select($strReq); 697 $a = array();697 $a = []; 698 698 while ($rs->fetch()) { 699 699 $a[] = $rs->cat_url; … … 785 785 @return <b>record</b> A record with some more capabilities or the SQL request 786 786 */ 787 public function getPosts($params = array(), $count_only = false)787 public function getPosts($params = [], $count_only = false) 788 788 { 789 789 # --BEHAVIOR-- coreBlogBeforeGetPosts … … 860 860 array_walk($params['post_id'], function (&$v, $k) {if ($v !== null) {$v = (integer) $v;}}); 861 861 } else { 862 $params['post_id'] = array((integer) $params['post_id']);862 $params['post_id'] = [(integer) $params['post_id']]; 863 863 } 864 864 $strReq .= 'AND P.post_id ' . $this->con->in($params['post_id']); … … 869 869 array_walk($params['exclude_post_id'], function (&$v, $k) {if ($v !== null) {$v = (integer) $v;}}); 870 870 } else { 871 $params['exclude_post_id'] = array((integer) $params['exclude_post_id']);871 $params['exclude_post_id'] = [(integer) $params['exclude_post_id']]; 872 872 } 873 873 $strReq .= 'AND P.post_id NOT ' . $this->con->in($params['exclude_post_id']); … … 884 884 if (isset($params['cat_id']) && $params['cat_id'] !== '') { 885 885 if (!is_array($params['cat_id'])) { 886 $params['cat_id'] = array($params['cat_id']);886 $params['cat_id'] = [$params['cat_id']]; 887 887 } 888 888 if (!empty($params['cat_id_not'])) { … … 892 892 } elseif (isset($params['cat_url']) && $params['cat_url'] !== '') { 893 893 if (!is_array($params['cat_url'])) { 894 $params['cat_url'] = array($params['cat_url']);894 $params['cat_url'] = [$params['cat_url']]; 895 895 } 896 896 if (!empty($params['cat_url_not'])) { … … 938 938 # --BEHAVIOR-- corePostSearch 939 939 if ($this->core->hasBehavior('corePostSearch')) { 940 $this->core->callBehavior('corePostSearch', $this->core, array(&$words, &$strReq, &$params));940 $this->core->callBehavior('corePostSearch', $this->core, [&$words, &$strReq, &$params]); 941 941 } 942 942 … … 990 990 $rs = $this->con->select($strReq); 991 991 $rs->core = $this->core; 992 $rs->_nb_media = array();992 $rs->_nb_media = []; 993 993 $rs->extend('rsExtPost'); 994 994 … … 997 997 998 998 # --BEHAVIOR-- coreBlogAfterGetPosts 999 $alt = new arrayObject( array('rs' => null, 'params' => $params, 'count_only' => $count_only));999 $alt = new arrayObject(['rs' => null, 'params' => $params, 'count_only' => $count_only]); 1000 1000 $this->core->callBehavior('coreBlogAfterGetPosts', $rs, $alt); 1001 1001 if ($alt['rs'] instanceof record) { … … 1068 1068 @return record 1069 1069 */ 1070 public function getLangs($params = array())1070 public function getLangs($params = []) 1071 1071 { 1072 1072 $strReq = 'SELECT COUNT(post_id) as nb_post, post_lang ' . … … 1132 1132 @return record 1133 1133 */ 1134 public function getDates($params = array())1134 public function getDates($params = []) 1135 1135 { 1136 1136 $dt_f = '%Y-%m-%d'; … … 1610 1610 public function firstPublicationEntries($ids) 1611 1611 { 1612 $posts = $this->getPosts( array(1612 $posts = $this->getPosts([ 1613 1613 'post_id' => dcUtils::cleanIds($ids), 1614 1614 'post_status' => 1, 1615 1615 'post_firstpub' => 0 1616 ));1617 1618 $to_change = array();1616 ]); 1617 1618 $to_change = []; 1619 1619 while ($posts->fetch()) { 1620 1620 … … 1663 1663 $field = $field == 'cat_id' ? 'cat_id' : 'cat_url'; 1664 1664 1665 $sub = array();1666 $not = array();1667 $queries = array();1665 $sub = []; 1666 $not = []; 1667 $queries = []; 1668 1668 1669 1669 foreach ($arr as $v) { … … 1699 1699 1700 1700 # Create queries 1701 $sql = array(1702 0 => array(), # wanted categories1703 1 => array()# excluded categories1704 );1701 $sql = [ 1702 0 => [], # wanted categories 1703 1 => [] # excluded categories 1704 ]; 1705 1705 1706 1706 foreach ($queries as $id => $q) { … … 1838 1838 1839 1839 # --BEHAVIOR-- coreAfterPostContentFormat 1840 $this->core->callBehavior('coreAfterPostContentFormat', array(1840 $this->core->callBehavior('coreAfterPostContentFormat', [ 1841 1841 'excerpt' => &$excerpt, 1842 1842 'content' => &$content, 1843 1843 'excerpt_xhtml' => &$excerpt_xhtml, 1844 1844 'content_xhtml' => &$content_xhtml 1845 ));1845 ]); 1846 1846 } 1847 1847 … … 1860 1860 $url = trim($url); 1861 1861 1862 $url_patterns = array(1862 $url_patterns = [ 1863 1863 '{y}' => date('Y', strtotime($post_dt)), 1864 1864 '{m}' => date('m', strtotime($post_dt)), … … 1866 1866 '{t}' => text::tidyURL($post_title), 1867 1867 '{id}' => (integer) $post_id 1868 );1868 ]; 1869 1869 1870 1870 # If URL is empty, we create a new one … … 1896 1896 } else { 1897 1897 $clause = "LIKE '" . 1898 $this->con->escape(preg_replace( array('%', '_', '!'), array('!%', '!_', '!!'), $url)) .1898 $this->con->escape(preg_replace(['%', '_', '!'], ['!%', '!_', '!!'], $url)) . 1899 1899 "%' ESCAPE '!'"; 1900 1900 } … … 1906 1906 1907 1907 $rs = $this->con->select($strReq); 1908 $a = array();1908 $a = []; 1909 1909 while ($rs->fetch()) { 1910 1910 $a[] = $rs->post_url; … … 1961 1961 @return <b>record</b> A record with some more capabilities 1962 1962 */ 1963 public function getComments($params = array(), $count_only = false)1963 public function getComments($params = [], $count_only = false) 1964 1964 { 1965 1965 if ($count_only) { … … 2030 2030 array_walk($params['comment_id'], function (&$v, $k) {if ($v !== null) {$v = (integer) $v;}}); 2031 2031 } else { 2032 $params['comment_id'] = array((integer) $params['comment_id']);2032 $params['comment_id'] = [(integer) $params['comment_id']]; 2033 2033 } 2034 2034 $strReq .= 'AND comment_id ' . $this->con->in($params['comment_id']); … … 2073 2073 # --BEHAVIOR coreCommentSearch 2074 2074 if ($this->core->hasBehavior('coreCommentSearch')) { 2075 $this->core->callBehavior('coreCommentSearch', $this->core, array(&$words, &$strReq, &$params));2075 $this->core->callBehavior('coreCommentSearch', $this->core, [&$words, &$strReq, &$params]); 2076 2076 } 2077 2077 … … 2184 2184 } 2185 2185 2186 $rs = $this->getComments( array('comment_id' => $id));2186 $rs = $this->getComments(['comment_id' => $id]); 2187 2187 2188 2188 if ($rs->isEmpty()) { … … 2289 2289 2290 2290 # Retrieve posts affected by comments edition 2291 $affected_posts = array();2291 $affected_posts = []; 2292 2292 $strReq = 2293 2293 'SELECT post_id ' .
Note: See TracChangeset
for help on using the changeset viewer.
