Make WordPress Core

Changeset 11934


Ignore:
Timestamp:
09/15/2009 02:21:00 AM (15 years ago)
Author:
azaozz
Message:

Include 'hidden' directories in filesystem dirlist by default, props dd32, fixes #10774

Location:
trunk/wp-admin/includes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-filesystem-direct.php

    r11930 r11934  
    308308    }
    309309
    310     function dirlist($path, $incdot = false, $recursive = false) {
     310    function dirlist($path, $include_hidden = true, $recursive = false) {
    311311        if ( $this->is_file($path) ) {
    312             $limitFile = basename($path);
     312            $limit_file = basename($path);
    313313            $path = dirname($path);
    314314        } else {
    315             $limitFile = false;
    316         }
     315            $limit_file = false;
     316        }
     317
    317318        if ( ! $this->is_dir($path) )
    318319            return false;
    319320
    320         $ret = array();
    321321        $dir = @dir($path);
    322322        if ( ! $dir )
    323323            return false;
     324
     325        $ret = array();
     326
    324327        while (false !== ($entry = $dir->read()) ) {
    325328            $struc = array();
     
    327330
    328331            if ( '.' == $struc['name'] || '..' == $struc['name'] )
    329                 continue; //Do not care about these folders.
    330             if ( '.' == $struc['name'][0] && !$incdot)
    331332                continue;
    332             if ( $limitFile && $struc['name'] != $limitFile)
     333
     334            if ( ! $include_hidden && '.' == $struc['name'][0] )
     335                continue;
     336
     337            if ( $limit_file && $struc['name'] != $limit_file)
    333338                continue;
    334339
     
    346351            if ( 'd' == $struc['type'] ) {
    347352                if ( $recursive )
    348                     $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $incdot, $recursive);
     353                    $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
    349354                else
    350355                    $struc['files'] = array();
  • trunk/wp-admin/includes/class-wp-filesystem-ftpext.php

    r11930 r11934  
    324324    }
    325325
    326     function dirlist($path = '.', $incdot = false, $recursive = false) {
     326    function dirlist($path = '.', $include_hidden = true, $recursive = false) {
    327327        if ( $this->is_file($path) ) {
    328             $limitFile = basename($path);
     328            $limit_file = basename($path);
    329329            $path = dirname($path) . '/';
    330330        } else {
    331             $limitFile = false;
     331            $limit_file = false;
    332332        }
    333333
     
    343343                continue;
    344344
    345             if ( '.' == $entry["name"] || '..' == $entry["name"] )
     345            if ( '.' == $entry['name'] || '..' == $entry['name'] )
    346346                continue;
    347347
     348            if ( ! $include_hidden && '.' == $entry['name'][0] )
     349                continue;
     350
     351            if ( $limit_file && $entry['name'] != $limit_file)
     352                continue;
     353
    348354            $dirlist[ $entry['name'] ] = $entry;
    349355        }
     
    351357        if ( ! $dirlist )
    352358            return false;
    353         if ( empty($dirlist) )
    354             return array();
    355359
    356360        $ret = array();
    357         foreach ( $dirlist as $struc ) {
    358 
     361        foreach ( (array)$dirlist as $struc ) {
    359362            if ( 'd' == $struc['type'] ) {
    360                 $struc['files'] = array();
    361 
    362                 if ( $incdot ) {
    363                     //We're including the doted starts
    364                     if ( '.' != $struc['name'] && '..' != $struc['name'] ) { //Ok, It isnt a special folder
    365                         if ($recursive)
    366                             $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $incdot, $recursive);
    367                     }
    368                 } else { //No dots
    369                     if ($recursive)
    370                         $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $incdot, $recursive);
    371                 }
     363                if ( $recursive )
     364                    $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
     365                else
     366                    $struc['files'] = array();
    372367            }
    373             //File
    374             $ret[$struc['name']] = $struc;
     368
     369            $ret[ $struc['name'] ] = $struc;
    375370        }
    376371        return $ret;
  • trunk/wp-admin/includes/class-wp-filesystem-ftpsockets.php

    r11930 r11934  
    123123
    124124        $temp = wp_tempnam( $file );
    125         if ( ! $temphandle = fopen($temp, 'w+') ){
     125        if ( ! $temphandle = fopen($temp, 'w+') ) {
    126126            unlink($temp);
    127127            return false;
     
    167167            return $this->ftp->chmod($file, $mode);
    168168        }
     169
    169170        //Is a directory, and we want recursive
    170171        $filelist = $this->dirlist($file);
    171         foreach($filelist as $filename){
     172        foreach ( $filelist as $filename )
    172173            $this->chmod($file . '/' . $filename, $mode, $recursive);
    173         }
     174
    174175        return true;
    175176    }
     
    283284    }
    284285
    285     function dirlist($path = '.', $incdot = false, $recursive = false ) {
     286    function dirlist($path = '.', $include_hidden = true, $recursive = false ) {
    286287        if ( $this->is_file($path) ) {
    287             $limitFile = basename($path);
     288            $limit_file = basename($path);
    288289            $path = dirname($path) . '/';
    289290        } else {
    290             $limitFile = false;
     291            $limit_file = false;
    291292        }
    292293
     
    294295        if ( ! $list )
    295296            return false;
    296         if ( empty($list) )
    297             return array();
    298297
    299298        $ret = array();
    300299        foreach ( $list as $struc ) {
    301300
     301            if ( '.' == $struct['name'] || '..' == $struc['name'] )
     302                continue;
     303
     304            if ( ! $include_hidden && '.' == $struc['name'][0] )
     305                continue;
     306
     307            if ( $limit_file && $srtuc['name'] != $limit_file )
     308                continue;
     309
    302310            if ( 'd' == $struc['type'] ) {
    303                 $struc['files'] = array();
    304 
    305                 if ( $incdot ){
    306                     //We're including the doted starts
    307                     if ( '.' != $struc['name'] && '..' != $struc['name'] ){ //Ok, It isnt a special folder
    308                         if ($recursive)
    309                             $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $incdot, $recursive);
    310                     }
    311                 } else { //No dots
    312                     if ($recursive)
    313                         $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $incdot, $recursive);
    314                 }
     311                if ( $recursive )
     312                    $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
     313                else
     314                    $struc['files'] = array();
    315315            }
    316             //File
    317             $ret[$struc['name']] = $struc;
     316
     317            $ret[ $struc['name'] ] = $struc;
    318318        }
    319319        return $ret;
  • trunk/wp-admin/includes/class-wp-filesystem-ssh2.php

    r11930 r11934  
    323323    }
    324324
    325     function dirlist($path, $incdot = false, $recursive = false) {
     325    function dirlist($path, $include_hidden = true, $recursive = false) {
    326326        if ( $this->is_file($path) ) {
    327             $limitFile = basename($path);
     327            $limit_file = basename($path);
    328328            $path = dirname($path);
    329329        } else {
    330             $limitFile = false;
    331         }
     330            $limit_file = false;
     331        }
     332
    332333        if ( ! $this->is_dir($path) )
    333334            return false;
     
    335336        $ret = array();
    336337        $dir = @dir('ssh2.sftp://' . $this->sftp_link .'/' . ltrim($path, '/') );
     338
    337339        if ( ! $dir )
    338340            return false;
     341
    339342        while (false !== ($entry = $dir->read()) ) {
    340343            $struc = array();
     
    343346            if ( '.' == $struc['name'] || '..' == $struc['name'] )
    344347                continue; //Do not care about these folders.
    345             if ( '.' == $struc['name'][0] && !$incdot)
     348
     349            if ( ! $include_hidden && '.' == $struc['name'][0] )
    346350                continue;
    347             if ( $limitFile && $struc['name'] != $limitFile)
     351
     352            if ( $limit_file && $struc['name'] != $limit_file )
    348353                continue;
    349354
     
    361366            if ( 'd' == $struc['type'] ) {
    362367                if ( $recursive )
    363                     $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $incdot, $recursive);
     368                    $struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
    364369                else
    365370                    $struc['files'] = array();
Note: See TracChangeset for help on using the changeset viewer.