Page 1 of 1

mosReadDirectory equivalent for Joomla 1.5 ?

Posted: Fri Mar 21, 2008 8:32 am
by carsten888
does anyone know the mosReadDirectory equivalent for Joomla 1.5 ?

Re: mosReadDirectory equivalent for Joomla 1.5 ?

Posted: Fri Mar 21, 2008 11:31 am
by radiant_tech
Perhaps what you are looking for is in joomla_root/libraries/joomla/filesystem/folder.php ...

Code: Select all

	/**
	 * Utility function to read the files in a folder
	 *
	 * @param	string	$path		The path of the folder to read
	 * @param	string	$filter		A filter for file names
	 * @param	mixed	$recurse	True to recursively search into sub-folders, or an integer to specify the maximum depth
	 * @param	boolean	$fullpath	True to return the full path to the file
	 * @param	array	$exclude	Array with names of files which should not be shown in the result
	 * @return	array	Files in the given folder
	 * @since 1.5
	 */
	function files($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS'))
or

Code: Select all

	/**
	 * Utility function to read the folders in a folder
	 *
	 * @param	string	$path		The path of the folder to read
	 * @param	string	$filter		A filter for folder names
	 * @param	mixed	$recurse	True to recursively search into sub-folders, or an integer to specify the maximum depth
	 * @param	boolean	$fullpath	True to return the full path to the folders
	 * @param	array	$exclude	Array with names of folders which should not be shown in the result
	 * @return	array	Folders in the given folder
	 * @since 1.5
	 */
	function folders($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS'))

Re: mosReadDirectory equivalent for Joomla 1.5 ?

Posted: Fri Mar 21, 2008 3:11 pm
by carsten888
Thank you! that was what I was looking for.

to read languages from a folder for all versions of Joomla:

Code: Select all

if( defined('_JEXEC') ){
							//joomla 1.5
							jimport( 'joomla.filesystem.folder' );
							$languages = JFolder::files(dirname(__FILE__).'/../language');
						}else{
							//joomla 1.0.x							
							$languages = mosReadDirectory(dirname(__FILE__).'/../language');
						}
foreach($languages as $language){
							if($language!='index.html'){
								$language = str_replace('.php','',$language);
								$selected = '';
								if($language==$config['language']){
									$selected = ' selected="selected"';
								}
								echo '<option value="'.$language.'"'.$selected.'>'.$language.'</option>';
							}
						}
I did not test the code for joomla 1.0.x yet.