Make WordPress Core


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.