Dotclear


Ignore:
Timestamp:
09/14/18 12:16:17 (7 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

short notation for array (array() → [])

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.blog.php

    r3731 r3874  
    4949    public $public_path; 
    5050 
    51     private $post_status    = array(); 
    52     private $comment_status = array(); 
     51    private $post_status    = []; 
     52    private $comment_status = []; 
    5353 
    5454    private $categories; 
     
    249249            $rs = $this->con->select($strReq); 
    250250 
    251             $affected_posts = array(); 
     251            $affected_posts = []; 
    252252            while ($rs->fetch()) { 
    253253                $affected_posts[] = (integer) $rs->post_id; 
     
    269269        $rs = $this->con->select($strReq); 
    270270 
    271         $posts = array(); 
     271        $posts = []; 
    272272        while ($rs->fetch()) { 
    273273            if ($rs->comment_trackback) { 
     
    320320    @return    <b>record</b> 
    321321     */ 
    322     public function getCategories($params = array()) 
    323     { 
    324         $c_params = array(); 
     322    public function getCategories($params = []) 
     323    { 
     324        $c_params = []; 
    325325        if (isset($params['post_type'])) { 
    326326            $c_params['post_type'] = $params['post_type']; 
     
    341341 
    342342        # Get each categories total posts count 
    343         $data  = array(); 
    344         $stack = array(); 
     343        $data  = []; 
     344        $stack = []; 
    345345        $level = 0; 
    346346        $cols  = $rs->columns(); 
     
    370370            $level = $rs->level; 
    371371 
    372             $t = array(); 
     372            $t = []; 
    373373            foreach ($cols as $c) { 
    374374                $t[$c] = $rs->f($c); 
     
    388388                if ($v['cat_id'] == $params['cat_id']) { 
    389389                    $found = true; 
    390                     $data  = array($v); 
     390                    $data  = [$v]; 
    391391                    break; 
    392392                } 
    393393            } 
    394394            if (!$found) { 
    395                 $data = array(); 
     395                $data = []; 
    396396            } 
    397397        } 
     
    403403                if ($v['cat_url'] == $params['cat_url']) { 
    404404                    $found = true; 
    405                     $data  = array($v); 
     405                    $data  = [$v]; 
    406406                    break; 
    407407                } 
    408408            } 
    409409            if (!$found) { 
    410                 $data = array(); 
     410                $data = []; 
    411411            } 
    412412        } 
     
    423423    public function getCategory($id) 
    424424    { 
    425         return $this->getCategories(array('cat_id' => $id)); 
     425        return $this->getCategories(['cat_id' => $id]); 
    426426    } 
    427427 
     
    456456    public function getCategoryFirstChildren($id) 
    457457    { 
    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 = []) 
    462462    { 
    463463        $strReq = 
     
    478478 
    479479        $rs       = $this->con->select($strReq); 
    480         $counters = array(); 
     480        $counters = []; 
    481481        while ($rs->fetch()) { 
    482482            $counters[$rs->cat_id] = $rs->nb_post; 
     
    499499        } 
    500500 
    501         $url = array(); 
     501        $url = []; 
    502502        if ($parent != 0) { 
    503503            $rs = $this->getCategory($parent); 
    504504            if ($rs->isEmpty()) { 
    505                 $url = array(); 
     505                $url = []; 
    506506            } else { 
    507507                $url[] = $rs->cat_url; 
     
    551551 
    552552        if ($cur->cat_url == '') { 
    553             $url = array(); 
     553            $url = []; 
    554554            $rs  = $this->categories()->getParents($id); 
    555555            while ($rs->fetch()) { 
     
    695695 
    696696            $rs = $this->con->select($strReq); 
    697             $a  = array(); 
     697            $a  = []; 
    698698            while ($rs->fetch()) { 
    699699                $a[] = $rs->cat_url; 
     
    785785    @return    <b>record</b>    A record with some more capabilities or the SQL request 
    786786     */ 
    787     public function getPosts($params = array(), $count_only = false) 
     787    public function getPosts($params = [], $count_only = false) 
    788788    { 
    789789        # --BEHAVIOR-- coreBlogBeforeGetPosts 
     
    860860                array_walk($params['post_id'], function (&$v, $k) {if ($v !== null) {$v = (integer) $v;}}); 
    861861            } else { 
    862                 $params['post_id'] = array((integer) $params['post_id']); 
     862                $params['post_id'] = [(integer) $params['post_id']]; 
    863863            } 
    864864            $strReq .= 'AND P.post_id ' . $this->con->in($params['post_id']); 
     
    869869                array_walk($params['exclude_post_id'], function (&$v, $k) {if ($v !== null) {$v = (integer) $v;}}); 
    870870            } else { 
    871                 $params['exclude_post_id'] = array((integer) $params['exclude_post_id']); 
     871                $params['exclude_post_id'] = [(integer) $params['exclude_post_id']]; 
    872872            } 
    873873            $strReq .= 'AND P.post_id NOT ' . $this->con->in($params['exclude_post_id']); 
     
    884884        if (isset($params['cat_id']) && $params['cat_id'] !== '') { 
    885885            if (!is_array($params['cat_id'])) { 
    886                 $params['cat_id'] = array($params['cat_id']); 
     886                $params['cat_id'] = [$params['cat_id']]; 
    887887            } 
    888888            if (!empty($params['cat_id_not'])) { 
     
    892892        } elseif (isset($params['cat_url']) && $params['cat_url'] !== '') { 
    893893            if (!is_array($params['cat_url'])) { 
    894                 $params['cat_url'] = array($params['cat_url']); 
     894                $params['cat_url'] = [$params['cat_url']]; 
    895895            } 
    896896            if (!empty($params['cat_url_not'])) { 
     
    938938                # --BEHAVIOR-- corePostSearch 
    939939                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]); 
    941941                } 
    942942 
     
    990990        $rs            = $this->con->select($strReq); 
    991991        $rs->core      = $this->core; 
    992         $rs->_nb_media = array(); 
     992        $rs->_nb_media = []; 
    993993        $rs->extend('rsExtPost'); 
    994994 
     
    997997 
    998998        # --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]); 
    10001000        $this->core->callBehavior('coreBlogAfterGetPosts', $rs, $alt); 
    10011001        if ($alt['rs'] instanceof record) { 
     
    10681068    @return    record 
    10691069     */ 
    1070     public function getLangs($params = array()) 
     1070    public function getLangs($params = []) 
    10711071    { 
    10721072        $strReq = 'SELECT COUNT(post_id) as nb_post, post_lang ' . 
     
    11321132    @return    record 
    11331133     */ 
    1134     public function getDates($params = array()) 
     1134    public function getDates($params = []) 
    11351135    { 
    11361136        $dt_f  = '%Y-%m-%d'; 
     
    16101610    public function firstPublicationEntries($ids) 
    16111611    { 
    1612         $posts = $this->getPosts(array( 
     1612        $posts = $this->getPosts([ 
    16131613            'post_id'       => dcUtils::cleanIds($ids), 
    16141614            'post_status'   => 1, 
    16151615            'post_firstpub' => 0 
    1616         )); 
    1617  
    1618         $to_change = array(); 
     1616        ]); 
     1617 
     1618        $to_change = []; 
    16191619        while ($posts->fetch()) { 
    16201620 
     
    16631663        $field = $field == 'cat_id' ? 'cat_id' : 'cat_url'; 
    16641664 
    1665         $sub     = array(); 
    1666         $not     = array(); 
    1667         $queries = array(); 
     1665        $sub     = []; 
     1666        $not     = []; 
     1667        $queries = []; 
    16681668 
    16691669        foreach ($arr as $v) { 
     
    16991699 
    17001700        # Create queries 
    1701         $sql = array( 
    1702             0 => array(), # wanted categories 
    1703             1 => array() # excluded categories 
    1704         ); 
     1701        $sql = [ 
     1702            0 => [], # wanted categories 
     1703            1 => [] # excluded categories 
     1704        ]; 
    17051705 
    17061706        foreach ($queries as $id => $q) { 
     
    18381838 
    18391839        # --BEHAVIOR-- coreAfterPostContentFormat 
    1840         $this->core->callBehavior('coreAfterPostContentFormat', array( 
     1840        $this->core->callBehavior('coreAfterPostContentFormat', [ 
    18411841            'excerpt'       => &$excerpt, 
    18421842            'content'       => &$content, 
    18431843            'excerpt_xhtml' => &$excerpt_xhtml, 
    18441844            'content_xhtml' => &$content_xhtml 
    1845         )); 
     1845        ]); 
    18461846    } 
    18471847 
     
    18601860        $url = trim($url); 
    18611861 
    1862         $url_patterns = array( 
     1862        $url_patterns = [ 
    18631863            '{y}'  => date('Y', strtotime($post_dt)), 
    18641864            '{m}'  => date('m', strtotime($post_dt)), 
     
    18661866            '{t}'  => text::tidyURL($post_title), 
    18671867            '{id}' => (integer) $post_id 
    1868         ); 
     1868        ]; 
    18691869 
    18701870        # If URL is empty, we create a new one 
     
    18961896            } else { 
    18971897                $clause = "LIKE '" . 
    1898                 $this->con->escape(preg_replace(array('%', '_', '!'), array('!%', '!_', '!!'), $url)) . 
     1898                $this->con->escape(preg_replace(['%', '_', '!'], ['!%', '!_', '!!'], $url)) . 
    18991899                    "%' ESCAPE '!'"; 
    19001900            } 
     
    19061906 
    19071907            $rs = $this->con->select($strReq); 
    1908             $a  = array(); 
     1908            $a  = []; 
    19091909            while ($rs->fetch()) { 
    19101910                $a[] = $rs->post_url; 
     
    19611961    @return    <b>record</b>    A record with some more capabilities 
    19621962     */ 
    1963     public function getComments($params = array(), $count_only = false) 
     1963    public function getComments($params = [], $count_only = false) 
    19641964    { 
    19651965        if ($count_only) { 
     
    20302030                array_walk($params['comment_id'], function (&$v, $k) {if ($v !== null) {$v = (integer) $v;}}); 
    20312031            } else { 
    2032                 $params['comment_id'] = array((integer) $params['comment_id']); 
     2032                $params['comment_id'] = [(integer) $params['comment_id']]; 
    20332033            } 
    20342034            $strReq .= 'AND comment_id ' . $this->con->in($params['comment_id']); 
     
    20732073                # --BEHAVIOR coreCommentSearch 
    20742074                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]); 
    20762076                } 
    20772077 
     
    21842184        } 
    21852185 
    2186         $rs = $this->getComments(array('comment_id' => $id)); 
     2186        $rs = $this->getComments(['comment_id' => $id]); 
    21872187 
    21882188        if ($rs->isEmpty()) { 
     
    22892289 
    22902290        # Retrieve posts affected by comments edition 
    2291         $affected_posts = array(); 
     2291        $affected_posts = []; 
    22922292        $strReq         = 
    22932293        'SELECT post_id ' . 
Note: See TracChangeset for help on using the changeset viewer.

Sites map