english/administrator/components/com_media/controllers/folder.php
/**
	 * Create a folder
	 *
	 * @param string $path Path of the folder to create
	 * @since 1.5
	 */
Create a folder
@param string $path Path of the folder to create
@since 1.5
Create a folder @param string $path Path of the folder to create @since 1 . 5
function create()
	{
		JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
		$user = JFactory::getUser();
		$folder			= JRequest::getCmd('foldername', '');
		$folderCheck	= JRequest::getVar('foldername', null, '', 'string', JREQUEST_ALLOWRAW);
		$parent			= JRequest::getVar('folderbase', '', '', 'path');
		$this->setRedirect('index.php?option=com_media&folder='.$parent.'&tmpl='.JRequest::getCmd('tmpl', 'index'));
		if (strlen($folder) > 0)
		{
			if (!$user->authorise('core.create','com_media'))
			{
				JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_CREATE_NOT_PERMITTED'));
				return false;
			}
			jimport('joomla.client.helper');
			JClientHelper::setCredentialsFromRequest('ftp');
			JRequest::setVar('folder', $parent);
			if (($folderCheck !== null) && ($folder !== $folderCheck)) {
				$this->setMessage(JText::_('COM_MEDIA_ERROR_UNABLE_TO_CREATE_FOLDER_WARNDIRNAME'));
				return false;
			}
			$path = JPath::clean(COM_MEDIA_BASE . '/' . $parent . '/' . $folder);
			if (!is_dir($path) && !is_file($path))
			{
				$object_file = new JObject(array('filepath' => $path));
				JPluginHelper::importPlugin('content');
				$dispatcher	= JDispatcher::getInstance();
				$result = $dispatcher->trigger('onContentBeforeSave', array('com_media.folder', &$object_file));
				if (in_array(false, $result, true)) {
					JError::raiseWarning(100, JText::plural('COM_MEDIA_ERROR_BEFORE_SAVE', count($errors = $object_file->getErrors()), implode('<br />', $errors)));
					continue;
				}
				JFolder::create($path);
				$data = "<html>\n<body bgcolor=\"#FFFFFF\">\n</body>\n</html>";
				JFile::write($path . "/index.html", $data);
				$dispatcher->trigger('onContentAfterSave', array('com_media.folder', &$object_file, true));
				$this->setMessage(JText::sprintf('COM_MEDIA_CREATE_COMPLETE', substr($path, strlen(COM_MEDIA_BASE))));
			}
			JRequest::setVar('folder', ($parent) ? $parent.'/'.$folder : $folder);
		}
	}
function create ( ) { JRequest :: checkToken ( ) or jexit ( JText :: _ ( 'JINVALID_TOKEN' ) ) ; $ user = JFactory :: getUser ( ) ; $ folder = JRequest :: getCmd ( 'foldername' , '' ) ; $ folderCheck = JRequest :: getVar ( 'foldername' , null , '' , 'string' , JREQUEST_ALLOWRAW ) ; $ parent = JRequest :: getVar ( 'folderbase' , '' , '' , 'path' ) ; $ this -> setRedirect ( 'index.php?option=com_media&folder=' . $ parent . '&tmpl=' . JRequest :: getCmd ( 'tmpl' , 'index' ) ) ; if ( strlen ( $ folder ) > 0 ) { if ( ! $ user -> authorise ( 'core.create' , 'com_media' ) ) { JError :: raiseWarning ( 403 , JText :: _ ( 'JLIB_APPLICATION_ERROR_CREATE_NOT_PERMITTED' ) ) ; return false ; } jimport ( 'joomla.client.helper' ) ; JClientHelper :: setCredentialsFromRequest ( 'ftp' ) ; JRequest :: setVar ( 'folder' , $ parent ) ; if ( ( $ folderCheck !== null ) && ( $ folder !== $ folderCheck ) ) { $ this -> setMessage ( JText :: _ ( 'COM_MEDIA_ERROR_UNABLE_TO_CREATE_FOLDER_WARNDIRNAME' ) ) ; return false ; } $ path = JPath :: clean ( COM_MEDIA_BASE . '/' . $ parent . '/' . $ folder ) ; if ( ! is_dir ( $ path ) && ! is_file ( $ path ) ) { $ object_file = new JObject ( array ( 'filepath' => $ path ) ) ; JPluginHelper :: importPlugin ( 'content' ) ; $ dispatcher = JDispatcher :: getInstance ( ) ; $ result = $ dispatcher -> trigger ( 'onContentBeforeSave' , array ( 'com_media.folder' , & $ object_file ) ) ; if ( in_array ( false , $ result , true ) ) { JError :: raiseWarning ( 100 , JText :: plural ( 'COM_MEDIA_ERROR_BEFORE_SAVE' , count ( $ errors = $ object_file -> getErrors ( ) ) , implode ( '<br />' , $ errors ) ) ) ; continue ; } JFolder :: create ( $ path ) ; $ data = " <html> \n <body bgcolor= \" #FFFFFF \" > \n </body> \n </html> " ; JFile :: write ( $ path . " /index.html " , $ data ) ; $ dispatcher -> trigger ( 'onContentAfterSave' , array ( 'com_media.folder' , & $ object_file , true ) ) ; $ this -> setMessage ( JText :: sprintf ( 'COM_MEDIA_CREATE_COMPLETE' , substr ( $ path , strlen ( COM_MEDIA_BASE ) ) ) ) ; } JRequest :: setVar ( 'folder' , ( $ parent ) ? $ parent . '/' . $ folder : $ folder ) ; } }
Create a folder
 @param string $path Path of the folder to create
 @since 1.5
Create a folder @param string $path Path of the folder to create @since 1 . 5
// Check for request forgeries // User is not authorised to delete // Set FTP credentials, if given // Trigger the onContentBeforeSave event. // There are some errors in the plugins // Trigger the onContentAfterSave event.