Skip to content

Commit 30011cc

Browse files
committed
refactor folder loading
1 parent f519adc commit 30011cc

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

classes/uix/ui.php

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -273,28 +273,44 @@ private function get_folder_contents( $path ) {
273273
$items = array();
274274
$uid = opendir( $path );
275275
if ( $uid ) {
276-
while ( true ) {
277-
$item = readdir( $uid );
278-
if ( false === $item ) {
279-
break;
280-
}
281-
if ( substr( $item, 0, 1 ) !== '.' ) {
282-
$items[ $item ] = $path . $item;
283-
}
284-
}
285-
closedir( $uid );
276+
return $this->load_folder_items( $uid, $path );
286277
}
287278

288279
return $items;
289280
}
290281

282+
/**
283+
* Load items from a folder
284+
*
285+
* @since 1.0.0
286+
* @access private
287+
*
288+
* @param string $uid The folder name.
289+
* @param string $path The folder path.
290+
*
291+
* @return array List of items
292+
*/
293+
private function load_folder_items( $uid, $path ) {
294+
$items = array();
295+
while ( true ) {
296+
$item = readdir( $uid );
297+
if ( false === $item ) {
298+
break;
299+
}
300+
if ( substr( $item, 0, 1 ) !== '.' ) {
301+
$items[ $item ] = $path . $item;
302+
}
303+
}
304+
closedir( $uid );
305+
return $items;
306+
}
291307
/**
292308
* Opens a location and gets the file to load for each folder
293309
*
294310
* @since 1.0.0
295311
* @access private
296312
*
297-
* @param string $path The file patch to examine and to fetch contents from
313+
* @param string $path The file patch to examine and to fetch contents from.
298314
*
299315
* @return array List of folders and files
300316
*/

0 commit comments

Comments
 (0)