Skip to content

Commit

Permalink
refactor folder loading
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidCramer committed Jun 21, 2018
1 parent f519adc commit 30011cc
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions classes/uix/ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,28 +273,44 @@ private function get_folder_contents( $path ) {
$items = array();
$uid = opendir( $path );
if ( $uid ) {
while ( true ) {
$item = readdir( $uid );
if ( false === $item ) {
break;
}
if ( substr( $item, 0, 1 ) !== '.' ) {
$items[ $item ] = $path . $item;
}
}
closedir( $uid );
return $this->load_folder_items( $uid, $path );
}

return $items;
}

/**
* Load items from a folder
*
* @since 1.0.0
* @access private
*
* @param string $uid The folder name.
* @param string $path The folder path.
*
* @return array List of items
*/
private function load_folder_items( $uid, $path ) {
$items = array();
while ( true ) {
$item = readdir( $uid );
if ( false === $item ) {
break;
}
if ( substr( $item, 0, 1 ) !== '.' ) {
$items[ $item ] = $path . $item;
}
}
closedir( $uid );
return $items;
}
/**
* Opens a location and gets the file to load for each folder
*
* @since 1.0.0
* @access private
*
* @param string $path The file patch to examine and to fetch contents from
* @param string $path The file patch to examine and to fetch contents from.
*
* @return array List of folders and files
*/
Expand Down

0 comments on commit 30011cc

Please # to comment.