Fixing fckeditor when adding images, creating folders

skala
Julio Montoya 13 years ago
parent 7b67758fa6
commit 49e24acd4c
  1. 376
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_thumbnail_listing.php
  2. 4
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_create_folder.php
  3. 12
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_get_file_listing.php
  4. 27
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.manager.php
  5. 4
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/function.base.php

@ -1,198 +1,196 @@
<div id="content"> <div id="content">
<?php <?php
$count = 1; $count = 1;
$thumbnailBaseUrl = CONFIG_URL_IMG_THUMBNAIL; $thumbnailBaseUrl = CONFIG_URL_IMG_THUMBNAIL;
foreach ($fileList as $file) { foreach ($fileList as $file) {
///First step for hidden some type of Chamilo files and folders
///First step for hidden some type of Chamilo files and folders //Juan Carlos Raña Trabado
//Juan Carlos Raña Trabado //hidden files and folders deleted by Chamilo. Hidde folders css, hotpotatoes, chat, certificates
//hidden files and folders deleted by Chamilo. Hidde folders css, hotpotatoes, chat, certificates $deleted_by_chamilo_file = ' DELETED '; // ' DELETED ' not '_DELETED_' because in $file['name'] _ is replaced with blank see class.manager.php
$deleted_by_chamilo_file = ' DELETED '; // ' DELETED ' not '_DELETED_' because in $file['name'] _ is replaced with blank see class.manager.php $deleted_by_chamilo_folder = '_DELETED_';
$deleted_by_chamilo_folder = '_DELETED_'; $css_folder_chamilo = 'css';
$css_folder_chamilo = 'css'; $hotpotatoes_folder_chamilo = 'HotPotatoes_files';
$hotpotatoes_folder_chamilo = 'HotPotatoes_files'; $chat_files_chamilo = 'chat_files';
$chat_files_chamilo = 'chat_files'; $certificates_chamilo = 'certificates';
$certificates_chamilo = 'certificates'; //hidden directory of the group if the user is not a member of the group
//hidden directory of the group if the user is not a member of the group $group_folder = '_groupdocs';
$group_folder = '_groupdocs'; //show group's directory only if I'm member. Or I'm a teacher
$show_doc_group = true;
//show group's directory only if I'm member. Or I'm a teacher if (preg_match("/$group_folder/", $file['path'])) {
$show_doc_group = true; $show_doc_group = false;
if ($is_user_in_group || ( $to_group_id != 0 && api_is_allowed_to_edit())) {
if (preg_match("/$group_folder/", $file['path'])) { $show_doc_group = true;
$show_doc_group = false;
if ($is_user_in_group || ( $to_group_id != 0 && api_is_allowed_to_edit())) {
$show_doc_group = true;
}
} }
}
//show icon sharedfolder
$shared_folder = 'shared folder'; //'shared folder' not 'shared_folder' because in $file['name'] _ is replaced with blank see class.manager.php
///Second step: hiding as the case //show icon sharedfolder
//Juan Carlos Raña Trabado $shared_folder = 'shared folder'; //'shared folder' not 'shared_folder' because in $file['name'] _ is replaced with blank see class.manager.php
if ((!preg_match("/$deleted_by_chamilo_file/", $file['name']) && ///Second step: hiding as the case
!preg_match("/$deleted_by_chamilo_folder/", $file['path'])) && //Juan Carlos Raña Trabado
!preg_match("/$css_folder_chamilo/", $file['path']) && if ((!preg_match("/$deleted_by_chamilo_file/", $file['name']) &&
!preg_match("/$hotpotatoes_folder_chamilo/", $file['path']) && !preg_match("/$deleted_by_chamilo_folder/", $file['path'])) &&
!preg_match("/$chat_files_chamilo/", $file['path']) && !preg_match("/$css_folder_chamilo/", $file['path']) &&
!preg_match("/$certificates_chamilo/", $file['path']) && $show_doc_group && $file['name'][0] != '.') { !preg_match("/$hotpotatoes_folder_chamilo/", $file['path']) &&
//hide Nanogong tag !preg_match("/$chat_files_chamilo/", $file['path']) &&
if (strpos($file['path'], '_chnano_')) { !preg_match("/$certificates_chamilo/", $file['path']) && $show_doc_group && $file['name'][0] != '.') {
$file['path'] = substr_replace($file['path'], '.wav', -12); //into real file name //hide Nanogong tag
$file['name'] = substr_replace($file['name'], '.wav', -12); //into web name if (strpos($file['path'], '_chnano_')) {
} $file['path'] = substr_replace($file['path'], '.wav', -12); //into real file name
$file['name'] = substr_replace($file['name'], '.wav', -12); //into web name
}
?>
<dl class="thumbnailListing" id="dl<?php echo $count; ?>">
<?php
if (preg_match('/shared_folder/', basename($file['path']))) {
//add icon into ajaxfilemanager if sharedfolder is in Chamilo
?> ?>
<dl class="thumbnailListing" id="dl<?php echo $count; ?>"> <dt id="dt<?php echo $count; ?>" class="<?php echo ($file['type'] == 'folder' || empty($file['file']) || empty($file['subdir']) ? 'folderShared' : $file['cssClass']); ?>" class="<?php echo $file['cssClass']; ?>">
<?php <?php
if (preg_match('/shared_folder/', basename($file['path']))) { } elseif (preg_match('/sf_user_/', basename($file['path']))) {
//add icon into ajaxfilemanager if sharedfolder is in Chamilo
?> ?>
<dt id="dt<?php echo $count; ?>" class="<?php echo ($file['type'] == 'folder' || empty($file['file']) || empty($file['subdir']) ? 'folderShared' : $file['cssClass']); ?>" class="<?php echo $file['cssClass']; ?>"> <dt id="dt<?php echo $count; ?>" class="<?php echo ($file['type'] == 'folder' || empty($file['file']) || empty($file['subdir']) ? 'unknownUser' : $file['cssClass']); ?>" class="<?php echo $file['cssClass']; ?>">
<?php <?php
} elseif (preg_match('/sf_user_/', basename($file['path']))) { } else {
?> ?>
<dt id="dt<?php echo $count; ?>" class="<?php echo ($file['type'] == 'folder' || empty($file['file']) || empty($file['subdir']) ? 'unknownUser' : $file['cssClass']); ?>" class="<?php echo $file['cssClass']; ?>"> <dt id="dt<?php echo $count; ?>" class="<?php echo ($file['type'] == 'folder' && empty($file['file']) && empty($file['subdir']) ? 'folderEmpty' : $file['cssClass']); ?>" class="<?php echo $file['cssClass']; ?>">
<?php <?php
} else { }
?> switch ($file['cssClass']) {
<dt id="dt<?php echo $count; ?>" class="<?php echo ($file['type'] == 'folder' && empty($file['file']) && empty($file['subdir']) ? 'folderEmpty' : $file['cssClass']); ?>" class="<?php echo $file['cssClass']; ?>"> case 'filePicture':
<?php echo '<a id="thumbUrl'.$count.'" rel="thumbPhotos" href="'.$file['public_path'].'">';
} /* Chamilo create thumbnail */
switch ($file['cssClass']) { //setting
case 'filePicture': $allowed_thumbnail_types = array('jpg', 'jpeg', 'gif', 'png');
echo '<a id="thumbUrl'.$count.'" rel="thumbPhotos" href="'.$file['public_path'].'">'; $max_thumbnail_width = 100;
/* Chamilo create thumbnail */ $max_thumbnail_height = 100;
//setting $png_compression = 0; //0(none)-9
$allowed_thumbnail_types = array('jpg', 'jpeg', 'gif', 'png'); $jpg_quality = 75; //from 0 to 100 (default is 75). More quality less compression
$max_thumbnail_width = 100;
$max_thumbnail_height = 100; $directory_thumbnails = dirname($file['path']).'/.thumbs/';
$png_compression = 0; //0(none)-9
$jpg_quality = 75; //from 0 to 100 (default is 75). More quality less compression if (!file_exists($directory_thumbnails)) {
@mkdir($directory_thumbnails, api_get_permissions_for_new_directories());
$directory_thumbnails = dirname($file['path']).'/.thumbs/'; }
if (!file_exists($directory_thumbnails)) { //create thumbnails
@mkdir($directory_thumbnails, api_get_permissions_for_new_directories());
} $image = $file['path'];
$image_thumbnail = $directory_thumbnails.'.'.basename($file['path']);
//create thumbnails
if (file_exists($image)) {
$image = $file['path']; //check thumbnail
$image_thumbnail = $directory_thumbnails.'.'.basename($file['path']); $imagetype = explode(".", $image);
$imagetype = strtolower($imagetype[count($imagetype) - 1]); //or check $imagetype = image_type_to_extension(exif_imagetype($image), false);
if (file_exists($image)) {
//check thumbnail if (in_array($imagetype, $allowed_thumbnail_types)) {
$imagetype = explode(".", $image);
$imagetype = strtolower($imagetype[count($imagetype) - 1]); //or check $imagetype = image_type_to_extension(exif_imagetype($image), false); if (!file_exists($image_thumbnail)) {
$original_image_size = api_getimagesize($image); //run each once we view thumbnails is too heavy, then need move into !file_exists($image_thumbnail, and only run when haven't the thumbnail
if (in_array($imagetype, $allowed_thumbnail_types)) {
switch ($imagetype) {
if (!file_exists($image_thumbnail)) { case 'gif':
$original_image_size = api_getimagesize($image); //run each once we view thumbnails is too heavy, then need move into !file_exists($image_thumbnail, and only run when haven't the thumbnail $source_img = imagecreatefromgif($image);
break;
switch ($imagetype) { case 'jpg':
case 'gif': $source_img = imagecreatefromjpeg($image);
$source_img = imagecreatefromgif($image); break;
break; case 'jpeg':
case 'jpg': $source_img = imagecreatefromjpeg($image);
$source_img = imagecreatefromjpeg($image); break;
break; case 'png':
case 'jpeg': $source_img = imagecreatefrompng($image);
$source_img = imagecreatefromjpeg($image); break;
break; }
case 'png':
$source_img = imagecreatefrompng($image); $new_thumbnail_size = api_calculate_image_size($original_image_size['width'], $original_image_size['height'], $max_thumbnail_width, $max_thumbnail_height);
break;
} if ($max_thumbnail_width > $original_image_size['width'] && $max_thumbnail_height > $original_image_size['height']) {
$new_thumbnail_size['width'] = $original_image_size['width'];
$new_thumbnail_size = api_calculate_image_size($original_image_size['width'], $original_image_size['height'], $max_thumbnail_width, $max_thumbnail_height); $new_thumbnail_size['height'] = $original_image_size['height'];
}
if ($max_thumbnail_width > $original_image_size['width'] && $max_thumbnail_height > $original_image_size['height']) {
$new_thumbnail_size['width'] = $original_image_size['width']; $crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']);
$new_thumbnail_size['height'] = $original_image_size['height'];
} // preserve transparency
if ($imagetype == "png") {
$crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']); imagesavealpha($crop, true);
$color = imagecolorallocatealpha($crop, 0x00, 0x00, 0x00, 127);
// preserve transparency imagefill($crop, 0, 0, $color);
if ($imagetype == "png") { }
imagesavealpha($crop, true);
$color = imagecolorallocatealpha($crop, 0x00, 0x00, 0x00, 127); if ($imagetype == "gif") {
imagefill($crop, 0, 0, $color); $transindex = imagecolortransparent($source_img);
} $palletsize = imagecolorstotal($source_img);
if ($imagetype == "gif") { //GIF89a for transparent and anim (first clip), either GIF87a
$transindex = imagecolortransparent($source_img); if ($transindex >= 0 && $transindex < $palletsize) {
$palletsize = imagecolorstotal($source_img); $transcol = imagecolorsforindex($source_img, $transindex);
$transindex = imagecolorallocatealpha($crop, $transcol['red'], $transcol['green'], $transcol['blue'], 127);
//GIF89a for transparent and anim (first clip), either GIF87a imagefill($crop, 0, 0, $transindex);
if ($transindex >= 0 && $transindex < $palletsize) { imagecolortransparent($crop, $transindex);
$transcol = imagecolorsforindex($source_img, $transindex);
$transindex = imagecolorallocatealpha($crop, $transcol['red'], $transcol['green'], $transcol['blue'], 127);
imagefill($crop, 0, 0, $transindex);
imagecolortransparent($crop, $transindex);
}
}
//resampled image
imagecopyresampled($crop, $source_img, 0, 0, 0, 0, $new_thumbnail_size['width'], $new_thumbnail_size['height'], $original_image_size['width'], $original_image_size['height']);
switch ($imagetype) {
case 'gif':
imagegif($crop, $image_thumbnail);
break;
case 'jpg':
imagejpeg($crop, $image_thumbnail, $jpg_quality);
break;
case 'jpeg':
imagejpeg($crop, $image_thumbnail, $jpg_quality);
break;
case 'png':
imagepng($crop, $image_thumbnail, $png_compression);
break;
} }
}
//resampled image
imagecopyresampled($crop, $source_img, 0, 0, 0, 0, $new_thumbnail_size['width'], $new_thumbnail_size['height'], $original_image_size['width'], $original_image_size['height']);
switch ($imagetype) {
case 'gif':
imagegif($crop, $image_thumbnail);
break;
case 'jpg':
imagejpeg($crop, $image_thumbnail, $jpg_quality);
break;
case 'jpeg':
imagejpeg($crop, $image_thumbnail, $jpg_quality);
break;
case 'png':
imagepng($crop, $image_thumbnail, $png_compression);
break;
}
//clean memory
imagedestroy($crop);
}//end !exist thumbnail
//show thumbnail
echo '<img src="'.appendQueryString($thumbnailBaseUrl, ' path='.base64_encode($image_thumbnail)).'" id="thumbImg'.$count.'"></a>'."\n";
} else {
echo '<img src="'.appendQueryString($thumbnailBaseUrl, ' path='.base64_encode($file['path'])).'" id="thumbImg'.$count.'"></a>'."\n";
}//end allowed image types
}//end if exist file image
///////////////////////////////////////// End Chamilo create thumbnail
break;
case 'fileFlash':
case 'fileVideo':
case 'fileMusic':
break;
default:
echo '&nbsp;';
}
//clean memory if (!isset($_GET['editor']) && isset($_GET['editor']) && $_GET['editor'] != 'stand_alone') {
imagedestroy($crop); $path_chamilo_file = '../'.$file['path']; // fix for makes a good show when pressed next on window preview, don't only one image
}//end !exist thumbnail } else {
//show thumbnail $path_chamilo_file = $file['path'];
echo '<img src="'.appendQueryString($thumbnailBaseUrl, ' path='.base64_encode($image_thumbnail)).'" id="thumbImg'.$count.'"></a>'."\n"; }
} else { ?>
</dt>
echo '<img src="'.appendQueryString($thumbnailBaseUrl, ' path='.base64_encode($file['path'])).'" id="thumbImg'.$count.'"></a>'."\n"; <dd id="dd<?php echo $count; ?>" class="thumbnailListing_info">
}//end allowed image types <span id="flag<?php echo $count; ?>" class="<?php echo $file['flag']; ?>">&nbsp;</span>
}//end if exist file image <input id="cb<?php echo $count; ?>" type="checkbox" name="check[]" <?php echo ($file['is_writable'] ? '' : 'disabled'); ?> class="radio" value="<?php echo $file['path']; ?>" />
///////////////////////////////////////// End Chamilo create thumbnail <a <?php echo ($file['cssClass'] == 'filePicture' ? 'rel="orgImg"' : ''); ?> href="<?php echo $path_chamilo_file; // fix for Chamilo ?>" title="<?php echo $file['name']; ?>" id="a<?php echo $count; ?>">
<?php echo shortenFileName($file['name']); ?>
break; </a>
case 'fileFlash': </dd>
case 'fileVideo': </dl>
case 'fileMusic': <?php
break; }//end if hidden files and folders deleted by Chamilo
default: $count++;
echo '&nbsp;';
}
if (!isset($_GET['editor']) && isset($_GET['editor']) && $_GET['editor'] != 'stand_alone') {
$path_chamilo_file = '../'.$file['path']; // fix for makes a good show when pressed next on window preview, don't only one image
} else {
$path_chamilo_file = $file['path'];
}
?>
</dt>
<dd id="dd<?php echo $count; ?>" class="thumbnailListing_info">
<span id="flag<?php echo $count; ?>" class="<?php echo $file['flag']; ?>">&nbsp;</span>
<input id="cb<?php echo $count; ?>" type="checkbox" name="check[]" <?php echo ($file['is_writable'] ? '' : 'disabled'); ?> class="radio" value="<?php echo $file['path']; ?>" />
<a <?php echo ($file['cssClass'] == 'filePicture' ? 'rel="orgImg"' : ''); ?> href="<?php echo $path_chamilo_file; // fix for Chamilo ?>" title="<?php echo $file['name']; ?>" id="a<?php echo $count; ?>">
<?php echo shortenFileName($file['name']); ?>
</a>
</dd>
</dl>
<?php
}//end if hidden files and folders deleted by Chamilo
$count++;
} }
?> ?>
</div> </div>

@ -1,5 +1,4 @@
<?php <?php
/** /**
* create a folder * create a folder
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn) * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
@ -10,7 +9,8 @@
* @author Juan Carlos Ra<EFBFBD>a * @author Juan Carlos Ra<EFBFBD>a
* @since 18/January/2009 * @since 18/January/2009
*/ */
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR."inc".DIRECTORY_SEPARATOR."config.php"); require_once dirname(__FILE__).DIRECTORY_SEPARATOR."inc".DIRECTORY_SEPARATOR."config.php";
//@ob_start(); //Disabled for integration with Chamilo //@ob_start(); //Disabled for integration with Chamilo
//displayArray($_POST); //Disabled for integration with Chamilo //displayArray($_POST); //Disabled for integration with Chamilo
//writeInfo(@ob_get_clean()); //Disabled for integration with Chamilo //writeInfo(@ob_get_clean()); //Disabled for integration with Chamilo

@ -13,6 +13,7 @@
require_once '../../../../../../inc/global.inc.php'; // Integrating with Chamilo require_once '../../../../../../inc/global.inc.php'; // Integrating with Chamilo
if (!isset($manager)) { if (!isset($manager)) {
/** /**
* this is part of script for processing file paste * this is part of script for processing file paste
*/ */
@ -45,8 +46,8 @@ if (!isset($manager)) {
include_once(CLASS_SESSION_ACTION); include_once(CLASS_SESSION_ACTION);
$sessionAction = new SessionAction(); $sessionAction = new SessionAction();
include_once(DIR_AJAX_INC."class.manager.php"); include_once(DIR_AJAX_INC."class.manager.php");
$path = isset($_REQUEST['path']) ? base64_decode($_REQUEST['path']) : null;
$manager = new manager(); $manager = new manager($path);
$manager->setSessionAction($sessionAction); $manager->setSessionAction($sessionAction);
$fileList = $manager->getFileList(); $fileList = $manager->getFileList();
@ -64,6 +65,7 @@ $pagination->setPreviousText(PAGINATION_PREVIOUS);
$pagination->setNextText(PAGINATION_NEXT); $pagination->setNextText(PAGINATION_NEXT);
$pagination->setLastText(PAGINATION_LAST); $pagination->setLastText(PAGINATION_LAST);
$pagination->setLimit(!empty($_GET['limit']) ? intval($_GET['limit']) : CONFIG_DEFAULT_PAGINATION_LIMIT); $pagination->setLimit(!empty($_GET['limit']) ? intval($_GET['limit']) : CONFIG_DEFAULT_PAGINATION_LIMIT);
echo $pagination->getPaginationHTML(); echo $pagination->getPaginationHTML();
// Chamilo fix for count hidden folders // Chamilo fix for count hidden folders
@ -77,11 +79,9 @@ $chat_files_Chamilo = 'chat_files';
$certificates_Chamilo = 'certificates'; $certificates_Chamilo = 'certificates';
//end previous fix for count hidden folders //end previous fix for count hidden folders
echo "<script>"; echo "<script>";
echo "parentFolder = {path_base64:'".base64_encode(getParentFolderPath($folderInfo['path']))."', path:'".getParentFolderPath($folderInfo['path'])."'};"; echo "parentFolder = {path_base64:'".base64_encode(getParentFolderPath($folderInfo['path']))."', path:'".getParentFolderPath($folderInfo['path'])."'};";
echo 'currentFolder ={'; echo 'currentFolder = {';
$count = 1; $count = 1;
foreach ($folderInfo as $k => $v) { foreach ($folderInfo as $k => $v) {
echo ($count++ == 1 ? '' : ',')."'".$k."':'".($k == 'ctime' || $k == 'mtime' ? date(DATE_TIME_FORMAT, $v) : $v)."'"; echo ($count++ == 1 ? '' : ',')."'".$k."':'".($k == 'ctime' || $k == 'mtime' ? date(DATE_TIME_FORMAT, $v) : $v)."'";
@ -130,7 +130,6 @@ foreach ($fileList as $file) {
echo "}\n"; echo "}\n";
} }
$fileList = array_slice($fileList, $pagination->getPageOffset(), $pagination->getLimit()); //Chamilo fix for hidden files added +$count_hideItem $fileList = array_slice($fileList, $pagination->getPageOffset(), $pagination->getLimit()); //Chamilo fix for hidden files added +$count_hideItem
echo "};</script>"; echo "};</script>";
if (!empty($_GET['view'])) { if (!empty($_GET['view'])) {
switch ($_GET['view']) { switch ($_GET['view']) {
@ -145,7 +144,6 @@ if (!empty($_GET['view'])) {
} else { } else {
$view = CONFIG_DEFAULT_VIEW; $view = CONFIG_DEFAULT_VIEW;
} }
switch ($view) { switch ($view) {
case 'text': case 'text':
//list file name only //list file name only

@ -58,7 +58,8 @@ class manager
array(array("ods", "ots", "sxc", "stc"), "fileODS", SEARCH_TYPE_ODS, 1), array(array("ods", "ots", "sxc", "stc"), "fileODS", SEARCH_TYPE_ODS, 1),
array(array("odg", "otg", "sxd", "std"), "fileODG", SEARCH_TYPE_ODG, 1), array(array("odg", "otg", "sxd", "std"), "fileODG", SEARCH_TYPE_ODG, 1),
array(array("mm"), "freemind", SEARCH_TYPE_PDF, 0) array(array("mm"), "freemind", SEARCH_TYPE_PDF, 0)
); // Added mm, svg, svgz, pps, docx, pptx, xlsx, midi, ogg, ogv, oga,(odt,ods,odp,odg and extra) types to Chamilo, and change flv from flash to video );
// Added mm, svg, svgz, pps, docx, pptx, xlsx, midi, ogg, ogv, oga,(odt,ods,odp,odg and extra) types to Chamilo, and change flv from flash to video
/** /**
* constructor * constructor
@ -79,11 +80,10 @@ class manager
} elseif (isset($_SESSION[$this->lastVisitedFolderPathIndex]) && file_exists($_SESSION[$this->lastVisitedFolderPathIndex]) && !is_file($_SESSION[$this->lastVisitedFolderPathIndex])) { } elseif (isset($_SESSION[$this->lastVisitedFolderPathIndex]) && file_exists($_SESSION[$this->lastVisitedFolderPathIndex]) && !is_file($_SESSION[$this->lastVisitedFolderPathIndex])) {
$this->currentFolderPath = $_SESSION[$this->lastVisitedFolderPathIndex]; $this->currentFolderPath = $_SESSION[$this->lastVisitedFolderPathIndex];
} else { } else {
$this->currentFolderPath = base64_encode(CONFIG_SYS_DEFAULT_PATH); $this->currentFolderPath = CONFIG_SYS_DEFAULT_PATH;
} }
$this->currentFolderPath = (isUnderRoot($this->getCurrentFolderPath()) ? backslashToSlash((addTrailingSlash($this->getCurrentFolderPath()))) : CONFIG_SYS_DEFAULT_PATH); $this->currentFolderPath = (isUnderRoot($this->getCurrentFolderPath()) ? backslashToSlash((addTrailingSlash($this->getCurrentFolderPath()))) : CONFIG_SYS_DEFAULT_PATH);
$this->currentFolderPath = base64_encode($this->currentFolderPath);
if ($this->calculateSubdir) { if ($this->calculateSubdir) {
// keep track of this folder path in session // keep track of this folder path in session
@ -148,23 +148,25 @@ class manager
* @return string * @return string
*/ */
function getCurrentFolderPath() { function getCurrentFolderPath() {
return base64_decode($this->currentFolderPath); return $this->currentFolderPath;
} }
/** /**
* get the list of files and folders under this current fold * get the list of files and folders under this current fold
* @return array * @return array
*/ */
function getFileList() { function getFileList()
{
$outputs = array(); $outputs = array();
$files = array(); $files = array();
$folders = array(); $folders = array();
$tem = array();
$dirHandler = @opendir($this->getCurrentFolderPath()); $dirHandler = @opendir($this->getCurrentFolderPath());
if ($dirHandler) { if ($dirHandler) {
while (false !== ($file = readdir($dirHandler))) { while (false !== ($file = readdir($dirHandler))) {
if ($file != '.' && $file != '..') { if ($file != '.' && $file != '..') {
$flag = $this->flags['no']; $flag = $this->flags['no'];
if ($this->sessionAction->getFolder() == $this->getCurrentFolderPath()) { if ($this->sessionAction->getFolder() == $this->getCurrentFolderPath()) {
//check if any flag associated with this folder or file //check if any flag associated with this folder or file
@ -179,9 +181,10 @@ class manager
} }
$path = $this->getCurrentFolderPath().$file; $path = $this->getCurrentFolderPath().$file;
if (is_dir($path) && isListingDocument($path)) { if (is_dir($path) && isListingDocument($path)) {
$this->currentFolderInfo['subdir']++; $this->currentFolderInfo['subdir']++;
//fix count left folders for Chamilo //fix count left folders for Chamilo
$deleted_by_Chamilo_folder = '_DELETED_'; $deleted_by_Chamilo_folder = '_DELETED_';
$css_folder_Chamilo = 'css'; $css_folder_Chamilo = 'css';
@ -190,7 +193,7 @@ class manager
$certificates_Chamilo = 'certificates'; $certificates_Chamilo = 'certificates';
//show group's directory only if I'm member. Or if I'm a teacher. //show group's directory only if I'm member. Or if I'm a teacher.
//@todo: check groups not necessary because the student dont have access to main folder documents (only to document/group or document/shared_folder). //@todo: check groups not necessary because the student don't have access to main folder documents (only to document/group or document/shared_folder).
//Teachers can access to all groups ? //Teachers can access to all groups ?
$group_folder = '_groupdocs'; $group_folder = '_groupdocs';
$hide_doc_group = false; $hide_doc_group = false;
@ -207,7 +210,8 @@ class manager
preg_match("/$hotpotatoes_folder_Chamilo/", $path) || preg_match("/$hotpotatoes_folder_Chamilo/", $path) ||
preg_match("/$chat_files_Chamilo/", $path) || preg_match("/$chat_files_Chamilo/", $path) ||
preg_match("/$certificates_Chamilo/", $path) || preg_match("/$certificates_Chamilo/", $path) ||
$hide_doc_group || $file[0] == '.') { $hide_doc_group || $file[0] == '.')
{
$this->currentFolderInfo['subdir'] = $this->currentFolderInfo['subdir'] - 1; $this->currentFolderInfo['subdir'] = $this->currentFolderInfo['subdir'] - 1;
} }
//end fix for Chamilo //end fix for Chamilo
@ -220,6 +224,9 @@ class manager
$folders[$file] = $folder; $folders[$file] = $folder;
$outputs[$file] = $folders[$file]; $outputs[$file] = $folders[$file];
} }
} elseif (is_file($path) && isListingDocument($path)) { } elseif (is_file($path) && isListingDocument($path)) {
$obj = new file($path); $obj = new file($path);
$tem = $obj->getFileInfo(); $tem = $obj->getFileInfo();
@ -279,6 +286,7 @@ class manager
} else { } else {
trigger_error('Unable to locate the folder '.$this->getCurrentFolderPath(), E_NOTICE); trigger_error('Unable to locate the folder '.$this->getCurrentFolderPath(), E_NOTICE);
} }
return $outputs; return $outputs;
} }
@ -292,7 +300,6 @@ class manager
if (is_null($path)) { if (is_null($path)) {
return $this->currentFolderInfo; return $this->currentFolderInfo;
} else { } else {
$path = base64_encode($path);
$obj = new manager($path, false); $obj = new manager($path, false);
$obj->setSessionAction($this->sessionAction); $obj->setSessionAction($this->sessionAction);
$obj->getFileList(); $obj->getFileList();

@ -13,7 +13,6 @@ require_once dirname(__FILE__).DIRECTORY_SEPARATOR."config.php";
* force to ensure existence of stripos * force to ensure existence of stripos
*/ */
if (!function_exists("stripos")) { if (!function_exists("stripos")) {
function stripos($str, $needle, $offset = 0) { function stripos($str, $needle, $offset = 0) {
return @strpos(strtolower($str), strtolower($needle), $offset); return @strpos(strtolower($str), strtolower($needle), $offset);
} }
@ -811,7 +810,8 @@ function isListingDocument($path) {
} }
return true; return true;
} }
} else {//regular expression } else {
//regular expression
if (is_dir($path)) { if (is_dir($path)) {
if (isValidPattern(CONFIG_SYS_INC_DIR_PATTERN, $path) && !isInvalidPattern(CONFIG_SYS_EXC_DIR_PATTERN, $path)) { if (isValidPattern(CONFIG_SYS_INC_DIR_PATTERN, $path) && !isInvalidPattern(CONFIG_SYS_EXC_DIR_PATTERN, $path)) {
return true; return true;

Loading…
Cancel
Save