function recursive_listdir($base, $exclude = '') { static $filelist = array(); static $dirlist = array(); if (is_dir($base)) { $dh = opendir($base); while (false !== ($dir = readdir($dh))) { if ($dir !== $exclude && $dir !== '.' && $dir !== '..' && is_dir($base . '/' . $dir) && strtolower($dir) !== 'cvs' && strtolower($dir) !== '.svn') { $subbase = $base . '/' . $dir; $dirlist[] = $subbase; $subdirlist = recursive_listdir($subbase, $exclude); } } closedir($dh); } return $dirlist; }
function recursive_listdir($base) { static $filelist = array(); static $dirlist = array(); if (is_dir($base)) { $dh = opendir($base); while (false !== ($dir = readdir($dh))) { if (is_dir($base . "/" . $dir) && $dir !== '.' && $dir !== '..') { $subbase = $base . FILE_SEPARATOR . $dir; //$dirlist[] = $subbase; $subdirlist = recursive_listdir($subbase); } elseif (is_file($base . "/" . $dir) && $dir !== '.' && $dir !== '..') { if (strtolower(substr($base . FILE_SEPARATOR . $dir, -17)) == ".plugin.class.php") { $filelist[] = $base . FILE_SEPARATOR . $dir; } } } closedir($dh); } //$array['dirs'] = $dirlist; $array['files'] = $filelist; return $filelist; }
/** * Generates an array that contains all files in current directory * and its subdirectories. */ function recursive_listdir($base) { if (is_dir($base)) { $dh = opendir($base); while (false !== ($dir = readdir($dh))) { if (is_dir($base . "/" . $dir) && $dir !== '.' && $dir !== '..') { $subbase = $base . "/" . $dir; $subfilelist = recursive_listdir($subbase); $filelist[] = $subfilelist; } elseif (is_file($base . "/" . $dir) && $dir !== '.' && $dir !== '..') { $filelist[] = $base . "/" . $dir; } } closedir($dh); } return $filelist; }
/** * Show media manager * @param string The image directory to display */ function showMedia($listdir) { global $mosConfig_absolute_path, $mosConfig_live_site; // get list of directories $imgFiles = recursive_listdir($mosConfig_absolute_path . "/images/stories"); $images = array(); $folders = array(); $folders[] = mosHTML::makeOption("/"); foreach ($imgFiles as $file) { $folders[] = mosHTML::makeOption(substr($file, strlen($mosConfig_absolute_path . "/images/stories"))); } if (is_array($folders)) { sort($folders); } // create folder selectlist $dirPath = mosHTML::selectList($folders, 'dirPath', "class=\"inputbox\" size=\"1\" " . "onchange=\"goUpDir()\" ", 'value', 'text', $listdir); HTML_Media::showMedia($dirPath, $listdir); }
function recursive_listdir($base) { static $filelist = array(); static $dirlist = array(); if (is_dir($base)) { $dh = opendir($base); while (false !== ($dir = readdir($dh))) { if (is_dir($base . "\\" . $dir) && $dir !== '.' && $dir !== '..') { $subbase = $base . "\\" . $dir; $dirlist[] = $subbase; $subdirlist = recursive_listdir($subbase); } elseif (is_file($base . "\\" . $dir) && $dir !== '.' && $dir !== '..') { $filelist[] = $base . "\\" . $dir; } } closedir($dh); } $array[dirs] = $dirlist; $array[files] = $filelist; return $array; }
/** * Show media manager * @param string The image directory to display */ function showMedia($listdir) { // get list of directories $imgFiles = recursive_listdir(COM_MEDIA_BASE, 'admin_template'); $images = array(); $folders = array(); $folders[] = html_makeOption("/"); $len = strlen(COM_MEDIA_BASE); foreach ($imgFiles as $file) { $folders[] = html_makeOption(substr($file, $len)); } if (is_array($folders)) { sort($folders); } // create folder selectlist $dirPath = html_selectList($folders, 'dirPath', "class=\"inputbox\" size=\"1\" onchange=\"goUpDir()\" ", 'value', 'text', $listdir); $this->load->view('admin_template/' . $this->media_template, array('dirpath' => $dirPath, 'listdir' => $listdir)); }