parent
7b67758fa6
commit
49e24acd4c
@ -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 ' '; |
||||||
|
} |
||||||
|
|
||||||
//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']; ?>"> </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 ' '; |
|
||||||
} |
|
||||||
|
|
||||||
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']; ?>"> </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> |
||||||
Loading…
Reference in new issue