Browse Source

[svn r17809] FS#2867 - FCKEditor, simple file manager: Making accessible the root of the document's repository, when in the resource type box "All files" has been selected.

Ivan Tcholakov 16 years ago
parent
commit
005928a775

+ 7 - 3
main/inc/lib/fckeditor/editor/filemanager/browser/default/browser.html

@@ -89,10 +89,14 @@ if ( sServerPath.length > 0 )
 	oConnector.ConnectorUrl += 'ServerPath=' + encodeURIComponent( sServerPath ) + '&' ;
 
 oConnector.ResourceType		= GetUrlParam( 'Type' ) ;
-oConnector.ShowAllTypes		= ( oConnector.ResourceType.length == 0 ) ;
 
-if ( oConnector.ShowAllTypes )
-	oConnector.ResourceType = 'File' ;
+// Modified by Ivan Tcholakov.
+//oConnector.ShowAllTypes		= ( oConnector.ResourceType.length == 0 ) ;
+oConnector.ShowAllTypes = true ;
+
+// Disabled by Ivan Tcholakov.
+//if ( oConnector.ShowAllTypes )
+//	oConnector.ResourceType = 'File' ;
 
 oConnector.SendCommand = function( command, params, callBackFunction )
 {

+ 2 - 0
main/inc/lib/fckeditor/editor/filemanager/browser/default/connectors/php/commands.php

@@ -22,6 +22,8 @@
  * This is the File Manager Connector for PHP.
  */
 
+// Modifications by Ivan Tcholakov, JAN-2009.
+
 function GetFolders( $resourceType, $currentFolder )
 {
 	// Map the virtual path to the local server path.

+ 11 - 1
main/inc/lib/fckeditor/editor/filemanager/browser/default/connectors/php/config.php

@@ -22,6 +22,8 @@
  * Configuration file for the File Manager Connector for PHP.
  */
 
+// Modifications by Ivan Tcholakov, JAN-2009.
+
 // Loading the global initialization file, Dokeos LMS.
 require_once '../../../../../../../../global.inc.php';
 
@@ -127,21 +129,29 @@ $Config['ChmodOnFolderCreate'] = 0777 ;
 
 */
 
-$Config['AllowedExtensions']['File']	= array() ;
+// TODO: Dokeos system's balck and white lists have to be taken into account here.
+
+// Files
+$Config['AllowedExtensions']['File']	= array('7z', 'aiff', 'asf', 'avi', 'bmp', 'csv', 'doc', 'fla', 'flv', 'gif', 'gz', 'gzip', 'jpeg', 'jpg', 'mid', 'mov', 'mp3', 'mp4', 'mpc', 'mpeg', 'mpg', 'ods', 'odt', 'pdf', 'png', 'ppt', 'pxd', 'qt', 'ram', 'rar', 'rm', 'rmi', 'rmvb', 'rtf', 'sdc', 'sitd', 'swf', 'sxc', 'sxw', 'tar', 'tgz', 'tif', 'tiff', 'txt', 'vsd', 'wav', 'wma', 'wmv', 'xls', 'xml', 'zip') ;
 $Config['DeniedExtensions']['File']		= array('php','php3','php4','php5','phtml','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg','cgi') ;
 
+// Images
 $Config['AllowedExtensions']['Images']	= array('jpg','gif','jpeg','png') ;
 $Config['DeniedExtensions']['Images']	= array('php','php3','php4','php5','phtml','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg','cgi') ;
 
+// Flash
 $Config['AllowedExtensions']['Flash']	= array('swf') ;
 $Config['DeniedExtensions']['Flash']	= array('php','php3','php4','php5','phtml','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg','cgi') ;
 
+// MP3 (audio)
 $Config['AllowedExtensions']['MP3']	= array('mp3') ;
 $Config['DeniedExtensions']['MP3']	= array('php','php3','php4','php5','phtml','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg','cgi') ;
 
+// Video
 $Config['AllowedExtensions']['Video']	= array('avi','mpg','mpeg','mp4','mov','wmv','asf') ;
 $Config['DeniedExtensions']['Video']	= array('php','php3','php4','php5','phtml','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg','cgi') ;
 
+// Video/flv
 $Config['AllowedExtensions']['Video/flv']	= array('flv','mp4') ;
 $Config['DeniedExtensions']['Video/flv']	= array('php','php3','php4','php5','phtml','asp','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','dll','reg','cgi') ;
 

+ 18 - 38
main/inc/lib/fckeditor/editor/filemanager/browser/default/connectors/php/io.php

@@ -21,6 +21,9 @@
  *
  * This is the File Manager Connector for PHP.
  */
+
+// Modifications by Ivan Tcholakov, JAN-2009.
+
 function CombinePaths( $sBasePath, $sFolder )
 {
 	return RemoveFromEnd( $sBasePath, '/' ) . '/' . RemoveFromStart( $sFolder, '/' ) ;
@@ -79,24 +82,24 @@ function ServerMapFolder( $resourceType, $folderPath, $sCommand )
 	//this should be fixed
 	$resourceType = strtolower($resourceType);
 
-	/*
-	//$sResourceTypePath = GetResourceTypeDirectory( $resourceType, $sCommand ) ;
-	$sResourceTypePath = $GLOBALS["UserFilesDirectory"] . $resourceType . '/' ;
-
-	// Ensure that the directory exists.
-	$sErrorMsg = CreateServerFolder( $sResourceTypePath ) ;
-	if ( $sErrorMsg != '' )
-		SendError( 1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})" ) ;
-
-	// Return the resource type directory combined with the required path.
-	return CombinePaths( $sResourceTypePath , $folderPath ) ;
-	*/
-
 	// Get the resource type directory.
-	$sResourceTypePath = $GLOBALS["UserFilesDirectory"] . $resourceType . '/' ; 
+	if ( $resourceType != 'file' )
+	{
+		$sResourceTypePath = $GLOBALS["UserFilesDirectory"] . $resourceType . '/' ;
+	}
+	else
+	{
+		$sResourceTypePath = $GLOBALS["UserFilesDirectory"];
+	}
 	
 	// Ensure that the directory exists.
-	CreateServerFolder( $sResourceTypePath ) ;
+	// Modified by Ivan Tcholakov.
+	//CreateServerFolder( $sResourceTypePath ) ;
+	// TODO: To be checked if/when it is necessary.
+	if ( $resourceType != 'file' )
+	{
+		CreateServerFolder( $sResourceTypePath ) ;
+	}
 
 	// Return the resource type directory combined with the required path.
 	return $sResourceTypePath . RemoveFromStart( $folderPath, '/' ) ;	
@@ -172,29 +175,6 @@ function CreateServerFolder( $folderPath, $lastFolder = null )
 
 function GetRootPath()
 {
-	/*
-	if (!isset($_SERVER)) {
-		global $_SERVER;
-	}
-	$sRealPath = realpath( './' ) ;
-	// #2124 ensure that no slash is at the end
-	$sRealPath = rtrim($sRealPath,"\\/");
-
-	$sSelfPath = $_SERVER['PHP_SELF'] ;
-	$sSelfPath = substr( $sSelfPath, 0, strrpos( $sSelfPath, '/' ) ) ;
-
-	$sSelfPath = str_replace( '/', DIRECTORY_SEPARATOR, $sSelfPath ) ;
-
-	$position = strpos( $sRealPath, $sSelfPath ) ;
-
-	// This can check only that this script isn't run from a virtual dir
-	// But it avoids the problems that arise if it isn't checked
-	if ( $position === false || $position <> strlen( $sRealPath ) - strlen( $sSelfPath ) )
-		SendError( 1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".' ) ;
-
-	return substr( $sRealPath, 0, $position ) ;
-	*/
-
 	$sRealPath = realpath( './' ) ;
 	$sSelfPath = htmlentities($_SERVER['PHP_SELF']);
 	$sSelfPath = substr( $sSelfPath, 0, strrpos( $sSelfPath, '/' ) ) ;	

+ 6 - 4
main/inc/lib/fckeditor/editor/filemanager/browser/default/frmresourceslist.html

@@ -122,7 +122,12 @@ function GetFoldersAndFilesCallBack( fckXml )
 	var sCurrentFolderPath	= oFolderNode.attributes.getNamedItem('path').value ;
 	var sCurrentFolderUrl	= oFolderNode.attributes.getNamedItem('url').value ;
 
-//	var dTimer = new Date() ;
+	// Added by Ivan Tcholakov.
+	// For our needs the resource 'file' represents the root folder of the repository.
+	if ( sCurrentFolderUrl.indexOf( 'file/' ) == 0 )
+	{
+		sCurrentFolderUrl = sCurrentFolderUrl.substr( 5 ) ;
+	}
 
 	var oHtml = new StringBuilder( '<table id="tableFiles" cellspacing="1" cellpadding="0" width="100%" border="0">' ) ;
 
@@ -153,9 +158,6 @@ function GetFoldersAndFilesCallBack( fckXml )
 	oHtml.Append( '<\/table>' ) ;
 
 	document.body.innerHTML = oHtml.ToString() ;
-
-//	window.top.document.title = 'Finished processing in ' + ( ( ( new Date() ) - dTimer ) / 1000 ) + ' seconds' ;
-
 }
 
 window.onload = function()

+ 17 - 2
main/inc/lib/fckeditor/editor/filemanager/browser/default/frmresourcetype.html

@@ -35,7 +35,11 @@ function SetResourceType( type )
 }
 
 var aTypes = [
-	['File','File'],
+
+    // Modified by Ivan Tcholakov.
+	//['File','File'],
+	['File','All files'],
+
 	['Images','Images'],
 	['Flash','Flash'],
 	['Video','Video'],
@@ -49,7 +53,18 @@ window.onload = function()
 	for ( var i = 0 ; i < aTypes.length ; i++ )
 	{
 		if ( oConnector.ShowAllTypes || aTypes[i][0] == oConnector.ResourceType )
-			AddSelectOption( oCombo, aTypes[i][1], aTypes[i][0] ) ;
+		{
+			// Modified by Ivan Tcholakov.
+			//AddSelectOption( oCombo, aTypes[i][1], aTypes[i][0] ) ;
+			if ( aTypes[i][0] == oConnector.ResourceType )
+			{
+				AddSelectOption( oCombo, aTypes[i][1], aTypes[i][0], true ) ;
+			}
+			else
+			{
+				AddSelectOption( oCombo, aTypes[i][1], aTypes[i][0] ) ;
+			}
+		}
 	}
 }
 

+ 7 - 1
main/inc/lib/fckeditor/editor/filemanager/browser/default/js/common.js

@@ -55,13 +55,19 @@
 	}
 })() ;
 
-function AddSelectOption( selectElement, optionText, optionValue )
+function AddSelectOption( selectElement, optionText, optionValue, selected )
 {
 	var oOption = document.createElement("OPTION") ;
 
 	oOption.text	= optionText ;
 	oOption.value	= optionValue ;
 
+	// Added by Ivan Tcholakov.
+	if ( selected )
+	{
+		oOption.selected = true ;
+	}
+
 	selectElement.options.add(oOption) ;
 
 	return oOption ;