mosReadDirectory equivalent for Joomla 1.5 ?

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
User avatar
carsten888
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Sat Feb 11, 2006 8:32 am
Location: Tilburg, Holland
Contact:

mosReadDirectory equivalent for Joomla 1.5 ?

Post by carsten888 » Fri Mar 21, 2008 8:32 am

does anyone know the mosReadDirectory equivalent for Joomla 1.5 ?
Last edited by carsten888 on Fri Mar 21, 2008 3:11 pm, edited 1 time in total.

radiant_tech
Joomla! Apprentice
Joomla! Apprentice
Posts: 41
Joined: Sat Dec 15, 2007 3:02 pm
Location: Washington DC Metro

Re: mosReadDirectory equivalent for Joomla 1.5 ?

Post by radiant_tech » Fri Mar 21, 2008 11:31 am

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'))
Denise

User avatar
carsten888
Joomla! Apprentice
Joomla! Apprentice
Posts: 27
Joined: Sat Feb 11, 2006 8:32 am
Location: Tilburg, Holland
Contact:

Re: mosReadDirectory equivalent for Joomla 1.5 ?

Post by carsten888 » Fri Mar 21, 2008 3:11 pm

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.


Post Reply