Last active
December 19, 2015 22:09
-
-
Save kopepasah/6025291 to your computer and use it in GitHub Desktop.
This is will list the files with in a directory, including files within subdirectories. The output is a MediaWiki format list of the files grouped together by similar parts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function list_directory_files( $directory ) { | |
$files = array_diff( scandir( $directory ), array( '.', '..', 'list-files.php', '.DS_Store' ) ); | |
foreach ( $files as $file ) { | |
if ( dirname( __FILE__ ) == $directory ) { | |
if ( is_dir( $directory . '/' . $file ) ) { | |
$folder = $file . '.php'; | |
} | |
if ( $folder != $file ) { | |
if ( is_dir( $file ) ) { | |
echo '</br>=====' . ucwords( str_replace( '-', ' ', $file ) ) . '=====</br>'; | |
echo '*[[Exchange_Theme_Templates:_' . $file . '.php|' . $file . '.php]]</br>'; | |
} else { | |
echo '</br>=====' . ucwords( str_replace( '-', ' ', str_replace( '.php', '', $file ) ) ) . '=====</br>'; | |
echo '*[[Exchange_Theme_Templates:_' . $file . '|' . $file . ']]</br>'; | |
} | |
} | |
} else { | |
if ( ! is_dir( $directory . '/' . $file ) ) { | |
echo '*[[Exchange_Theme_Templates:_' . str_replace( dirname( __FILE__ ) . '/', '', $directory ) . '/' . $file . '|' . str_replace( dirname( __FILE__ ) . '/', '', $directory ) . '/' . $file . ']]</br>'; | |
} | |
} | |
if ( is_dir( $directory . '/' . $file ) ) | |
list_directory_files( $directory . '/' . $file ); | |
} | |
} | |
list_directory_files( dirname( __FILE__ ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment