FIxing ajax upload (partial)

skala
Julio Montoya 13 years ago
parent c45cd2f244
commit 4669434352
  1. 10
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_thumbnail_listing.php
  2. 216
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_upload.php
  3. 8
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_image_thumbnail.php
  4. 192
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php
  5. 127
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.manager.php
  6. 154
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/jscripts/ajaxfilemanager.js
  7. 2
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/jscripts/ajaxfilemanager_c.js

@ -1,10 +1,8 @@
<div id="content">
<?php
<?php
$count = 1;
$thumbnailBaseUrl = appendQueryString(CONFIG_URL_IMG_THUMBNAIL, makeQueryString(array('path')));
foreach($fileList as $file)
{
foreach($fileList as $file) {
///First step for hidden some type of Chamilo files and folders
//Juan Carlos Ra<EFBFBD>a
@ -70,8 +68,8 @@
switch($file['cssClass'])
{
case 'filePicture':
echo '<a id="thumbUrl' . $count . '" rel="thumbPhotos" href="' . $file['path'] . '">';
echo '<img src="' . appendQueryString($thumbnailBaseUrl, 'path=' . $file['path']) . '" id="thumbImg' . $count . '"></a>' . "\n";
echo '<a id="thumbUrl' . $count . '" rel="thumbPhotos" href="' . $file['public_path'] . '">';
echo '<img src="' . appendQueryString($thumbnailBaseUrl, 'path=' . base64_encode($file['path'])) . '" id="thumbImg' . $count . '"></a>' . "\n";
break;
case 'fileFlash':
case 'fileVideo':

@ -1,127 +1,101 @@
<?php
/**
* processing the uploaded files
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
* @link www.phpletter.com
* @since 22/May/2007
*
*/
sleep(3);
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
echo "{";
$error = "";
$info = "";
include_once(CLASS_UPLOAD);
$upload = new Upload();
$upload->setInvalidFileExt(explode(",", CONFIG_UPLOAD_INVALID_EXTS));
if(CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_UPLOAD)
{
$error = SYS_DISABLED;
}
elseif(empty($_GET['folder']) || !isUnderRoot($_GET['folder']))
{
$error = ERR_FOLDER_PATH_NOT_ALLOWED;
}else if(!$upload->isFileUploaded('file'))
{
$error = ERR_FILE_NOT_UPLOADED;
}else if(!$upload->moveUploadedFile($_GET['folder']))
{
$error = ERR_FILE_MOVE_FAILED;
}
elseif(!$upload->isPermittedFileExt(explode(",", CONFIG_UPLOAD_VALID_EXTS)))
{
$error = ERR_FILE_TYPE_NOT_ALLOWED;
}elseif(defined('CONFIG_UPLOAD_MAXSIZE') && CONFIG_UPLOAD_MAXSIZE && $upload->isSizeTooBig(CONFIG_UPLOAD_MAXSIZE))
{
$error = sprintf(ERROR_FILE_TOO_BID, transformFileSize(CONFIG_UPLOAD_MAXSIZE));
}else
{
include_once(CLASS_FILE);
$path = $upload->getFilePath();
$obj = new file($path);
$tem = $obj->getFileInfo();
if(sizeof($tem))
{
include_once(CLASS_MANAGER);
$manager = new manager($upload->getFilePath(), false);
$fileType = $manager->getFileType($upload->getFileName());
foreach($fileType as $k=>$v)
{
$tem[$k] = $v;
}
$tem['path'] = backslashToSlash($path);
$tem['type'] = "file";
$tem['size'] = transformFileSize($tem['size']);
$tem['ctime'] = date(DATE_TIME_FORMAT, $tem['ctime']);
$tem['mtime'] = date(DATE_TIME_FORMAT, $tem['mtime']);
$tem['short_name'] = shortenFileName($tem['name']);
$tem['flag'] = 'noFlag';
/**
* Bridge to Chamilo documents tool
* @author Juan Carlos Raña Trabado
*/
if(!empty($_course['path']))
{
//only inside courses
$fullPath= $upload->getFilePath(); //get ajaxmanager. Sample ../../../../../../../courses/TEST/document/Grupo_1_groupdocs/image.jpg
$folderInfo = $manager->getFolderInfo(); //get ajaxmanager
$mainPath= getParentFolderPath($folderInfo['path']);//get ajaxmanager. Sample ../../../../../../../courses/TEST/document/Grupo_1_groupdocs/
$chamiloFolder = substr($fullPath, strlen($mainPath)-strlen($fullPath)-1);
$chamiloFile = $tem['name']; //get ajaxmanager
$chamiloFileSize = filesize($fullPath); //get ajaxmanager
if(!empty($group_properties['directory'])) //get Chamilo
{
$chamiloFolder=$group_properties['directory'].$chamiloFolder;//get Chamilo
}
else
{
if(!api_is_allowed_to_edit())
{
$current_session_id = api_get_session_id();
if($current_session_id==0)
{
$chamiloFolder='/shared_folder/sf_user_'.api_get_user_id().$chamiloFolder;
}
else
{
$chamiloFolder='/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id().$chamiloFolder;
}
}
}
$doc_id = add_document($_course, $chamiloFolder,'file', $chamiloFileSize , $chamiloFile); //get Chamilo
$current_session_id = api_get_session_id();
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', api_get_user_id(),$to_group_id,null,null,null,$current_session_id);//get Chamilo
}
// end bridge
$obj->close();
foreach($tem as $k=>$v)
{
$info .= sprintf(", %s:'%s'", $k, $v);
}
/**
* processing the uploaded files
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
* @link www.phpletter.com
* @since 22/May/2007
*
*/
sleep(3);
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php";
echo "{";
$error = "";
$info = "";
$info .= sprintf(", url:'%s'", getFileUrl($path));
$info .= sprintf(", tipedit:'%s'", TIP_DOC_RENAME);
include_once CLASS_UPLOAD ;
$upload = new Upload();
}else
{
$error = ERR_FILE_NOT_AVAILABLE;
}
$folder = base64_decode($_GET['folder']);
//$folder = ($_GET['folder']);
$upload->setInvalidFileExt(explode(",", CONFIG_UPLOAD_INVALID_EXTS));
if(CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_UPLOAD) {
$error = SYS_DISABLED;
} elseif(empty($folder) || !isUnderRoot($folder)) {
$error = ERR_FOLDER_PATH_NOT_ALLOWED;
} else if(!$upload->isFileUploaded('file')) {
$error = ERR_FILE_NOT_UPLOADED;
}else if(!$upload->moveUploadedFile($folder)) {
$error = ERR_FILE_MOVE_FAILED;
} elseif(!$upload->isPermittedFileExt(explode(",", CONFIG_UPLOAD_VALID_EXTS))) {
$error = ERR_FILE_TYPE_NOT_ALLOWED;
} elseif(defined('CONFIG_UPLOAD_MAXSIZE') && CONFIG_UPLOAD_MAXSIZE && $upload->isSizeTooBig(CONFIG_UPLOAD_MAXSIZE)) {
$error = sprintf(ERROR_FILE_TOO_BID, transformFileSize(CONFIG_UPLOAD_MAXSIZE));
} else {
include_once(CLASS_FILE);
$path = $upload->getFilePath();
$obj = new file($path);
$tem = $obj->getFileInfo();
if (sizeof($tem)) {
include_once(CLASS_MANAGER);
$manager = new manager($upload->getFilePath(), false);
$fileType = $manager->getFileType($upload->getFileName());
foreach($fileType as $k=>$v) {
$tem[$k] = $v;
}
$tem['path'] = backslashToSlash($path);
$tem['type'] = "file";
$tem['size'] = transformFileSize($tem['size']);
$tem['ctime'] = date(DATE_TIME_FORMAT, $tem['ctime']);
$tem['mtime'] = date(DATE_TIME_FORMAT, $tem['mtime']);
$tem['short_name'] = shortenFileName($tem['name']);
$tem['flag'] = 'noFlag';
/**
* Bridge to Chamilo documents tool
* @author Juan Carlos Raña Trabado
*/
if(!empty($_course['path'])) {
//only inside courses
$fullPath= $upload->getFilePath(); //get ajaxmanager. Sample ../../../../../../../courses/TEST/document/Grupo_1_groupdocs/image.jpg
$folderInfo = $manager->getFolderInfo(); //get ajaxmanager
$mainPath= getParentFolderPath($folderInfo['path']);//get ajaxmanager. Sample ../../../../../../../courses/TEST/document/Grupo_1_groupdocs/
$chamiloFolder = substr($fullPath, strlen($mainPath)-strlen($fullPath)-1);
$chamiloFile = $tem['name']; //get ajaxmanager
$chamiloFileSize = filesize($fullPath); //get ajaxmanager
//get Chamilo
if(!empty($group_properties['directory'])) {
$chamiloFolder=$group_properties['directory'].$chamiloFolder;//get Chamilo
} else {
if(!api_is_allowed_to_edit()) {
$current_session_id = api_get_session_id();
if($current_session_id==0) {
$chamiloFolder='/shared_folder/sf_user_'.api_get_user_id().$chamiloFolder;
} else {
$chamiloFolder='/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id().$chamiloFolder;
}
}
}
$doc_id = add_document($_course, $chamiloFolder,'file', $chamiloFileSize , $chamiloFile); //get Chamilo
$current_session_id = api_get_session_id();
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', api_get_user_id(),$to_group_id,null,null,null,$current_session_id);//get Chamilo
}
// end bridge
$obj->close();
foreach($tem as $k=>$v) {
$info .= sprintf(", %s:'%s'", $k, $v);
}
$info .= sprintf(", url:'%s'", getFileUrl($path));
$info .= sprintf(", tipedit:'%s'", TIP_DOC_RENAME);
} else {
$error = ERR_FILE_NOT_AVAILABLE;
}
echo "error:'" . $error . "'";
echo $info;
echo "}";
?>
}
echo "error:'" . $error . "'";
echo $info;
echo "}";

@ -6,11 +6,13 @@
* @since 22/April/2007
*
*/
include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
if(!empty($_GET['path']) && file_exists($_GET['path']) && is_file($_GET['path'])) {
require_once CLASS_IMAGE;
$path = base64_decode($_GET['path']);
if(!empty($path) && file_exists($path) && is_file($path)) {
require_once CLASS_IMAGE;
$image = new ImageAjaxFileManager(true);
if($image->loadImage($_GET['path'])) {
if($image->loadImage($path)) {
if($image->resize(CONFIG_IMG_THUMBNAIL_MAX_X, CONFIG_IMG_THUMBNAIL_MAX_Y, true, true)) {
$image->showImage();
} else {

@ -1,57 +1,57 @@
<?php
/**
* file manager platform
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
* @link www.phpletter.com
* @since 22/May/2007
*
* Modify system config setting for Chamilo
* @author Juan Carlos Raña Trabado
* @since 31/December/2008
*/
/**
* file manager platform
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
* @link www.phpletter.com
* @since 22/May/2007
*
* Modify system config setting for Chamilo
* @author Juan Carlos Raña Trabado
* @since 31/December/2008
*/
include '../../../../../../inc/global.inc.php'; // Integrating with Chamilo
api_block_anonymous_users();// from Chamilo
include '../../../../../../inc/global.inc.php'; // Integrating with Chamilo
api_block_anonymous_users();// from Chamilo
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php";
//$session->gc(); // Disabled for integration with Chamilo
require_once CLASS_SESSION_ACTION;
$sessionAction = new SessionAction();
if (CONFIG_LOAD_DOC_LATTER) {
$fileList = array();
$folderInfo = array('path'=>getCurrentFolderPath());
} else {
require_once(CLASS_MANAGER);
$manager = new manager();
$manager->setSessionAction($sessionAction);
$fileList = $manager->getFileList();
$folderInfo = $manager->getFolderInfo();
}
if(CONFIG_SYS_THUMBNAIL_VIEW_ENABLE) {
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php";
//$session->gc(); // Disabled for integration with Chamilo
require_once CLASS_SESSION_ACTION;
$sessionAction = new SessionAction();
if (CONFIG_LOAD_DOC_LATTER) {
$fileList = array();
$folderInfo = array('path'=>getCurrentFolderPath());
} else {
require_once(CLASS_MANAGER);
$manager = new manager();
$manager->setSessionAction($sessionAction);
$fileList = $manager->getFileList();
$folderInfo = $manager->getFolderInfo();
}
if(CONFIG_SYS_THUMBNAIL_VIEW_ENABLE) {
$views = array(
'detail'=>LBL_BTN_VIEW_DETAILS,
'thumbnail'=>LBL_BTN_VIEW_THUMBNAIL,
);
} else {
$views = array(
'detail'=>LBL_BTN_VIEW_DETAILS,
);
}
);
} else {
$views = array(
'detail'=>LBL_BTN_VIEW_DETAILS,
);
}
if(!empty($_GET['view'])) {
switch($_GET['view']) {
case 'detail':
case 'thumbnail':
$view = Security::remove_XSS($_GET['view']);
break;
default:
$view = CONFIG_DEFAULT_VIEW;
}
} else {
$view = CONFIG_DEFAULT_VIEW;
}
if(!empty($_GET['view'])) {
switch($_GET['view']) {
case 'detail':
case 'thumbnail':
$view = Security::remove_XSS($_GET['view']);
break;
default:
$view = CONFIG_DEFAULT_VIEW;
}
} else {
$view = CONFIG_DEFAULT_VIEW;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@ -59,8 +59,8 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ajax File Manager</title>
<script type="text/javascript" src="jscripts/ajaxfilemanager_c.js"></script>
<!--<script type="text/javascript" src="jscripts/jquery.js"></script>
<script type="text/javascript" src="jscripts/jquery.js"></script>
<script type="text/javascript" src="jscripts/form.js"></script>
<script type="text/javascript" src="jscripts/select.js"></script>
<script type="text/javascript" src="jscripts/thickbox.js"></script>
@ -68,7 +68,7 @@
<script type="text/javascript" src="jscripts/contextmenu.js"></script>
<script type="text/javascript" src="jscripts/media.js"></script>
<script type="text/javascript" src="jscripts/ajaxfileupload.js"></script>
<script type="text/javascript" src="jscripts/ajaxfilemanager.js"></script>-->
<script type="text/javascript" src="jscripts/ajaxfilemanager.js"></script>
<script type="text/javascript">
var mode_editor = '<?php echo Security::remove_XSS($_GET['editor']);?>';<!-- Chamilo hack for general my files users -->
@ -121,7 +121,14 @@
'home':'<?php echo CONFIG_URL_HOME; ?>',
'view':'<?php echo CONFIG_URL_LIST_LISTING; ?>'
};
var permits = {'del':<?php echo (CONFIG_OPTIONS_DELETE?1:0); ?>, 'cut':<?php echo (CONFIG_OPTIONS_CUT?'1':'0'); ?>, 'copy':<?php echo (CONFIG_OPTIONS_COPY?1:0); ?>, 'newfolder':<?php echo (CONFIG_OPTIONS_NEWFOLDER?1:0); ?>, 'rename':<?php echo (CONFIG_OPTIONS_RENAME?1:0); ?>, 'upload':<?php echo (CONFIG_OPTIONS_UPLOAD?1:0); ?>, 'edit':<?php echo (CONFIG_OPTIONS_EDITABLE?1:0); ?>, 'view_only':<?php echo (CONFIG_SYS_VIEW_ONLY?1:0); ?>};
var permits = { 'del':<?php echo (CONFIG_OPTIONS_DELETE?1:0); ?>,
'cut':<?php echo (CONFIG_OPTIONS_CUT?'1':'0'); ?>,
'copy':<?php echo (CONFIG_OPTIONS_COPY?1:0); ?>,
'newfolder':<?php echo (CONFIG_OPTIONS_NEWFOLDER?1:0); ?>,
'rename':<?php echo (CONFIG_OPTIONS_RENAME?1:0); ?>,
'upload':<?php echo (CONFIG_OPTIONS_UPLOAD?1:0); ?>,
'edit':<?php echo (CONFIG_OPTIONS_EDITABLE?1:0); ?>,
'view_only':<?php echo (CONFIG_SYS_VIEW_ONLY?1:0); ?>};
var currentFolder = {};
var warningDelete = '<?php echo WARNING_DELETE; ?>';
var newFile = {'num':1, 'label':'<?php echo FILE_LABEL_SELECT; ?>', 'upload':'<?php echo FILE_LBL_UPLOAD; ?>'};
@ -163,27 +170,21 @@
var files = {};
$(document).ready(
function()
{
function() {
jQuery(document).bind('keypress', function(event) {
var code=event.charCode || event.keyCode;
if(code && code == 13) {// if enter is pressed
event.preventDefault(); //prevent browser from following the actual href
};
});
if(typeof(cancelSelectFile) != 'undefined')
{
if(typeof(cancelSelectFile) != 'undefined') {
$('#linkClose').show();
}
$('input[@name=view]').each(
function()
{
if(this.value == '<?php echo $view; ?>')
{
function() {
if(this.value == '<?php echo $view; ?>') {
this.checked = true;
}else
{
} else {
this.checked = false;
}
}
@ -198,20 +199,15 @@
popUpCal.dayNames = new Array('<?php echo CALENDAR_SUN; ?>','<?php echo CALENDAR_MON; ?>','<?php echo CALENDAR_TUE; ?>','<?php echo CALENDAR_WED; ?>','<?php echo CALENDAR_THU; ?>','<?php echo CALENDAR_FRI; ?>','<?php echo CALENDAR_SAT; ?>');
popUpCal.monthNames = new Array('<?php echo CALENDAR_JAN; ?>','<?php echo CALENDAR_FEB; ?>','<?php echo CALENDAR_MAR; ?>','<?php echo CALENDAR_APR; ?>','<?php echo CALENDAR_MAY; ?>','<?php echo CALENDAR_JUN; ?>','<?php echo CALENDAR_JUL; ?>','<?php echo CALENDAR_AUG; ?>','<?php echo CALENDAR_SEP; ?>','<?php echo CALENDAR_OCT; ?>','<?php echo CALENDAR_NOV; ?>','<?php echo CALENDAR_DEC; ?>');
popUpCal.dateFormat = 'YMD-';
$('.inputMtime').calendar({autoPopUp:'both', buttonImage:'theme/<?php echo CONFIG_THEME_NAME; ?>/images/date_picker.png'});
$('.inputMtime').calendar({autoPopUp:'both', buttonImage:'theme/<?php echo CONFIG_THEME_NAME; ?>/images/date_picker.png'});
initAfterListingLoaded();
//addMoreFile();
} );
</script>
<?php
if(file_exists(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'jscripts' . DIRECTORY_SEPARATOR . 'for_' . CONFIG_EDITOR_NAME . ".js")
{
if(file_exists(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'jscripts' . DIRECTORY_SEPARATOR . 'for_' . CONFIG_EDITOR_NAME . ".js") {
?>
<script type="text/javascript" src="jscripts/<?php echo 'for_' . CONFIG_EDITOR_NAME . '.js'; ?>"></script>
<script type="text/javascript" src="jscripts/<?php echo 'for_' . CONFIG_EDITOR_NAME . '.js'; ?>"></script>
<?php
}
?>
@ -290,11 +286,6 @@
<?php
}
?>
<!-- <li><a href="#" id="actionClose" onclick="closeWindow('<?php echo IMG_WARING_WIN_CLOSE; ?>');"><?php echo IMG_BTN_CLOSE; ?></a></li>-->
<!--<li><a href="#" class="thickbox" id="actionInfo" onclick="return infoWin(this);"><span>Info</span></a></li> -->
@ -302,11 +293,13 @@
<li ><a href="#" id="actionZip"><span>Zip</span></a><li>
<li ><a href="#" id="actionUnzip"><span>Unzip</span></a><li>-->
</ul>
<form action="" method="post" name="formAction" id="formAction"><input type="hidden" name="currentFolderPath" id="currentFolderPathVal" value="" /><select name="selectedDoc[]" id="selectedDoc" style="display:none;" multiple="multiple"></select><input type="hidden" name="action_value" value="" id="action_value" /></form>
</div>
<div id="body">
<form action="" method="post" name="formAction" id="formAction">
<input type="hidden" name="currentFolderPath" id="currentFolderPathVal" value="" />
<select name="selectedDoc[]" id="selectedDoc" style="display:none;" multiple="multiple"></select>
<input type="hidden" name="action_value" value="" id="action_value" />
</form>
</div>
<div id="body">
<div id="rightCol">
<?php
if(CONFIG_LOAD_DOC_LATTER )
@ -315,7 +308,7 @@
?>
<script type="text/javascript">
parentFolder = {path:'<?php echo getParentFolderPath($currentPath); ?>'};
parentFolder = {'path':'<?php echo getParentFolderPath($currentPath); ?>'};
currentFolder = {'friendly_path':'<?php echo transformFilePath($currentPath); ?>'};
$(document).ready(
function()
@ -424,22 +417,17 @@
</tbody>
</table>
<p class="searchButtons" id="returnCurrentUrl">
<p class="searchButtons" id="returnCurrentUrl">
<span class="right" id="linkSelect">
<input type="button" value="<?php echo MENU_SELECT; ?>" id="selectCurrentUrl" class="select_button"><!-- Change button class by Chamilo select_button class -->
</span>
<input type="button" value="<?php echo MENU_SELECT; ?>" id="selectCurrentUrl" class="select_button">
<!-- Change button class by Chamilo select_button class -->
</span>
</p>
</fieldset>
</fieldset>
<fieldset class="boxSearch">
<legend><?php echo LBL_SEARCH; ?></legend>
<table cellpadding="0" cellspacing="0" class="tableSearch">
<tbody>
<tr>
@ -533,11 +521,16 @@
</div>
</div>
<div class="clear"></div>
<div id="ajaxLoading" style="display:none"><img class="ajaxLoadingImg" src="theme/<?php echo CONFIG_THEME_NAME; ?>/images/ajaxLoading.gif" /></div>
<div id="ajaxLoading" style="display:none">
<img class="ajaxLoadingImg" src="theme/<?php echo CONFIG_THEME_NAME; ?>/images/ajaxLoading.gif" /></div>
<div id="winUpload" style="display:none">
<div class="jqmContainer">
<div class="jqmHeader">
<a href="#" onclick="tb_remove();"><img src="theme/default/images/flagno.png"title="<?php echo LBL_ACTION_CLOSE; ?>"><?php echo LBL_ACTION_CLOSE; ?></a><!-- Add close image for Chamilo -->
<a href="#" onclick="tb_remove();">
<img src="theme/default/images/flagno.png"title="<?php echo LBL_ACTION_CLOSE; ?>">
<?php echo LBL_ACTION_CLOSE; ?>
</a>
<!-- Add close image for Chamilo -->
</div>
<div class="jqmBody">
<form id="formUpload" name="formUpload" method="post" enctype="multipart/form-data" action="">
@ -570,19 +563,11 @@
</a>
<span class="uploadProcessing" style="display:none">&nbsp;</span>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>&nbsp;</th>
<td></td>
</tr>
</tfoot>
</tbody>
</table>
</form>
</div>
</div>
</div>
<div id="winNewFolder" style="display:none">
@ -614,9 +599,6 @@
</table>
</form>
</div>
</div>
</div>
<div id="winPlay" style="display:none">

@ -11,8 +11,7 @@
*/
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "class.file.php");
class manager
{
class manager {
var $currentFolderPath;
var $sessionAction = null; //object to session action
var $flags = array('no'=>'noFlag', 'cut'=>'cutFlag', 'copy'=>'copyFlag');
@ -129,8 +128,10 @@ class manager
$this->currentFolderInfo['ctime']=$folderInfo['ctime'];
$this->currentFolderInfo['mtime']=$folderInfo['mtime'];
$this->currentFolderInfo['is_readable']=$folderInfo['is_readable'];
$this->currentFolderInfo['is_writable']=$folderInfo['is_writable'];
$this->currentFolderInfo['path'] = $this->currentFolderPath;
$this->currentFolderInfo['is_writable']=$folderInfo['is_writable'];
$this->currentFolderInfo['path'] = $this->currentFolderPath;
$this->currentFolderInfo['path_base64'] = base64_encode($this->currentFolderPath);
$this->currentFolderInfo['friendly_path'] = transformFilePath($this->currentFolderPath);
$this->currentFolderInfo['type'] = "folder";
$this->currentFolderInfo['cssClass']='folder';
@ -141,7 +142,7 @@ class manager
if($calculateSubdir && !file_exists($this->currentFolderPath))
{
die(ERR_FOLDER_NOT_FOUND . $this->currentFolderPath);
}
}
}
function setSessionAction(&$session)
@ -174,31 +175,24 @@ class manager
$folders = array();
$tem = array();
$dirHandler = @opendir($this->currentFolderPath);
if($dirHandler)
{
while(false !== ($file = readdir($dirHandler)))
{
if($file != '.' && $file != '..')
{
$flag = $this->flags['no'];
if($this->sessionAction->getFolder() == $this->currentFolderPath)
{//check if any flag associated with this folder or file
if ($dirHandler) {
while(false !== ($file = readdir($dirHandler))) {
if($file != '.' && $file != '..') {
$flag = $this->flags['no'];
if ($this->sessionAction->getFolder() == $this->currentFolderPath) {
//check if any flag associated with this folder or file
$folder = addTrailingSlash(backslashToSlash($this->currentFolderPath));
if(in_array($folder . $file, $this->sessionAction->get()))
{
if($this->sessionAction->getAction() == "copy")
{
if(in_array($folder . $file, $this->sessionAction->get())) {
if($this->sessionAction->getAction() == "copy") {
$flag = $this->flags['copy'];
}else
{
} else {
$flag = $this->flags['cut'];
}
}
}
}
$path=$this->currentFolderPath.$file;
if(is_dir($path) && isListingDocument($path) )
{
if (is_dir($path) && isListingDocument($path) ) {
$this->currentFolderInfo['subdir']++;
//fix count left folders for Chamilo
$deleted_by_Chamilo_folder='_DELETED_';
@ -225,56 +219,48 @@ class manager
}
//end fix for Chamilo
if(!$this->calculateSubdir)
{
}else
{
$folder = $this->getFolderInfo($path);
$folder['flag'] = $flag;
$folders[$file] = $folder;
$outputs[$file] = $folders[$file];
}
}elseif(is_file($path) && isListingDocument($path))
{
$obj = new file($path);
$tem = $obj->getFileInfo();
if(sizeof($tem))
if(!$this->calculateSubdir) {
} else {
$folder = $this->getFolderInfo($path);
$folder['flag'] = $flag;
$folders[$file] = $folder;
$outputs[$file] = $folders[$file];
}
} elseif(is_file($path) && isListingDocument($path)) {
$obj = new file($path);
$tem = $obj->getFileInfo();
if (sizeof($tem)) {
$fileType = $this->getFileType($file);
foreach($fileType as $k=>$v)
{
$fileType = $this->getFileType($file);
foreach($fileType as $k=>$v)
{
$tem[$k] = $v;
}
$this->currentFolderInfo['size'] += $tem['size'];
$this->currentFolderInfo['file']++;
//fix count left files for Chamilo
$deleted_by_Chamilo_file=' DELETED '; // ' DELETED ' not '_DELETED_' because in $file['name'] _ is replaced with blank see class.manager.php
if(ereg($deleted_by_Chamilo_file, $tem['name']) || $tem['name'][0]=='.')
{
$this->currentFolderInfo['file']=$this->currentFolderInfo['file']-1;
}
///end fix for Chamilo
$tem['path'] = backslashToSlash($path);
$tem['type'] = "file";
$tem['flag'] = $flag;
$files[$file] = $tem;
$outputs[$file] = $tem;
$tem = array();
$obj->close();
}
$tem[$k] = $v;
}
$this->currentFolderInfo['size'] += $tem['size'];
$this->currentFolderInfo['file']++;
//fix count left files for Chamilo
$deleted_by_Chamilo_file=' DELETED '; // ' DELETED ' not '_DELETED_' because in $file['name'] _ is replaced with blank see class.manager.php
if(ereg($deleted_by_Chamilo_file, $tem['name']) || $tem['name'][0]=='.')
{
$this->currentFolderInfo['file']=$this->currentFolderInfo['file']-1;
}
///end fix for Chamilo
$tem['path'] = backslashToSlash($path);
$pos = strpos($this->currentFolderPath, 'courses/');
$tem['public_path'] = api_get_path(WEB_PATH).substr($this->currentFolderPath, $pos, strlen($this->currentFolderPath)).$file;
//error_log($tem['public_path'] );
$tem['type'] = "file";
$tem['flag'] = $flag;
$files[$file] = $tem;
$outputs[$file] = $tem;
$tem = array();
$obj->close();
}
}
}
}
if($this->forceFolderOnTop)
{
if($this->forceFolderOnTop) {
uksort($folders, "strnatcasecmp");
uksort($files, "strnatcasecmp");
$outputs = array();
@ -292,8 +278,7 @@ class manager
}
@closedir($dirHandler);
}else
{
} else {
trigger_error('Unable to locate the folder ' . $this->currentFolderPath, E_NOTICE);
}
return $outputs;

@ -53,19 +53,14 @@ Array.prototype.inArray = function (value,caseSensitive)
/**
* enable left click to preview certain files
*/
function enablePreview(elem, num)
{
$(elem).each(
function()
{
$(this).click(function ()
{
function enablePreview(elem, num) {
$(elem).each(
function() {
$(this).click(function () {
//alert('single click');
var num = getNum(this.id);
var path = files[num].path;
var path = files[num].public_path;
//alert('now: ' + now + '; dcat: ' + dcAt + '; dcDelay: ' + dcDelay);
if (hadDoubleClick())
{
@ -75,7 +70,7 @@ function enablePreview(elem, num)
linkElem = $('#a' + num).get(0);
}
d = new Date();
d = new Date();
savEvtTime = d.getTime();
savTO = setTimeout(function()
{
@ -105,16 +100,12 @@ function enablePreview(elem, num)
{
case 'fileVideo':
case 'fileMusic':
case 'fileFlash':
case 'fileFlash':
$('#playGround').html('<a id="playGround' + num + '" href="' + files[num].path + '"><div id="player">&nbsp;this is mine</div></a> ');
$('#playGround' + num).html('');
$('#playGround' + num).media({ width: 255, height: 210, autoplay: true });
//alert($('#playGround' + num).html());
showThickBox($('#a' + num).get(0), appendQueryString('#TB_inline', 'height=250' + '&width=256' + '&inlineId=winPlay&modal=true'));
showThickBox($('#a' + num).get(0), appendQueryString('#TB_inline', 'height=250' + '&width=256' + '&inlineId=winPlay&modal=true'));
break;
default:
showThickBox(linkElem, appendQueryString(path, 'KeepThis=true&TB_iframe=true&height=' + thickbox.height + '&width=' + thickbox.width));
@ -130,9 +121,9 @@ function enablePreview(elem, num)
}, dcTime);
return false;
});
return false;
});
$(this).dblclick(function()
{
var d = new Date();
@ -280,9 +271,7 @@ function changeView()
return true;
};
function goParentFolder()
{
function goParentFolder() {
searchRequired = false;
var url = appendQueryString(getUrl('view', true, true), 'path=' + parentFolder.path , ['path']);
$('#rightCol').empty();
@ -983,10 +972,9 @@ function addMoreFile()
var newFileUpload = $($('div#TB_window #fileUploadBody tr').get(0)).clone();
do
{
do {
var elementId = 'upload' + generateUniqueId(10);
}while(fileUploadElemIds.inArray(elementId));
} while(fileUploadElemIds.inArray(elementId));
fileUploadElemIds[fileUploadElemIds.length] = elementId;
@ -1030,9 +1018,7 @@ function cancelFileUpload(elementId)
/**
* upload file
*/
function uploadFile(elementId)
{
function uploadFile(elementId) {
var ext = getFileExtension($('#' + elementId).val());
if(ext == '')
{
@ -1060,10 +1046,10 @@ function uploadFile(elementId)
$('#ajax' + elementId).hide();
$('#ajax' + elementId).show();
$.ajaxFileUpload
(
{
url:appendQueryString(getUrl('upload', false, false), 'folder=' + currentFolder.path, ['folder']),
$.ajaxFileUpload ( {
url: appendQueryString(getUrl('upload', false, false), 'folder=' + currentFolder.path_base64, ['folder']),
secureuri:false,
fileElementId:elementId,
dataType: 'json',
@ -1724,91 +1710,65 @@ function enableShowDocInfo(num)
* show up the selected document information
* @param type root or doc
*/
function setDocInfo(type, num)
{
function setDocInfo(type, num) {
var info = {};
if(type == 'root')
{
if(type == 'root'){
info = currentFolder;
}else
{
} else {
info = files[num];
}
if(info.type=="folder")
if(info.type=="folder") {
$('#folderPath').text(info.name);
$('#folderFile').text(info.file);
$('#folderSubdir').text(info.subdir);
$('#folderCtime').text(info.ctime);
$('#folderMtime').text(info.mtime);
if(info.is_readable == '1')
{
$('#folderPath').text(info.name);
$('#folderFile').text(info.file);
$('#folderSubdir').text(info.subdir);
$('#folderCtime').text(info.ctime);
$('#folderMtime').text(info.mtime);
if(info.is_readable == '1')
{
$('#folderReadable').html("<span class=\"flagYes\">&nbsp;</span>");
}else
{
$('#folderReadable').html("<span class=\"flagNo\">&nbsp;</span>");
}
if(info.is_writable == '1')
{
$('#folderWritable').html("<span class=\"flagYes\">&nbsp;</span>");
}else
{
$('#folderWritable').html("<span class=\"flagNo\">&nbsp;</span>");
}
$('#folderFieldSet').css('display', '');
$('#fileFieldSet').css('display', 'none');
$('#folderReadable').html("<span class=\"flagYes\">&nbsp;</span>");
}else
{
$('#folderReadable').html("<span class=\"flagNo\">&nbsp;</span>");
}
if(info.is_writable == '1')
{
$('#folderWritable').html("<span class=\"flagYes\">&nbsp;</span>");
}else
{
$('#folderWritable').html("<span class=\"flagNo\">&nbsp;</span>");
}
$('#folderFieldSet').css('display', '');
$('#fileFieldSet').css('display', 'none');
} else {
$('#fileName').text(info.name);
$('#fileSize').text(info.size);
$('#fileType').text(info.fileType);
$('#fileCtime').text(info.ctime);
$('#fileMtime').text(info.mtime);
if(info.is_readable == '1')
{
if(info.is_readable == '1') {
$('#fileReadable').html("<span class=\"flagYes\">&nbsp;</span>");
}else
{
} else {
$('#fileReadable').html("<span class=\"flagNo\">&nbsp;</span>");
}
if(info.is_writable == '1')
{
}
if(info.is_writable == '1') {
$('#fileWritable').html("<span class=\"flagYes\">&nbsp;</span>");
}else
{
} else {
$('#fileWritable').html("<span class=\"flagNo\">&nbsp;</span>");
}
$('#folderFieldSet').css('display', 'none');
$('#fileFieldSet').css('display', '');
if(typeof(selectFile) != 'undefined' && $('#fileList input[@type=checkbox][@checked]').length==1)
{
$('#selectCurrentUrl').unbind('click').click(
function()
{
selectFile(info.url);
}
);
$('#returnCurrentUrl').show();
}else
{
$('#returnCurrentUrl').hide();
}
}
if (typeof(selectFile) != 'undefined' && $('#fileList input[@type=checkbox][@checked]').length==1 || $('#rightCol dl.thumbnailListing input[@type=checkbox][@checked]').length==1 ) {
$('#selectCurrentUrl').unbind('click').click(function() {
selectFile(info.url);
}
);
$('#returnCurrentUrl').show();
} else {
$('#returnCurrentUrl').hide();
}
}
};
function search()
{

@ -321,7 +321,7 @@ var supportedExts=supportedUploadExts.split(",");var isSupportedExt=false;for(i
if(!isSupportedExt)
{alert(msgInvalidExt);return false;}
$('#ajax'+elementId).hide();$('#ajax'+elementId).show();$.ajaxFileUpload
({url:appendQueryString(getUrl('upload',false,false),'folder='+currentFolder.path,['folder']),secureuri:false,fileElementId:elementId,dataType:'json',success:function(data,status)
({url:appendQueryString(getUrl('upload',false,false),'folder='+currentFolder.path_base64,['folder']),secureuri:false,fileElementId:elementId,dataType:'json',success:function(data,status)
{if(typeof(data.error)!='undefined')
{if(data.error!='')
{alert(data.error);$('#ajax'+elementId).hide();}else

Loading…
Cancel
Save