From eb934dc39c4d6094ccfd0826267a63547408d5f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Ra=C3=B1a?= Date: Fri, 6 Jul 2012 20:50:57 +0200 Subject: [PATCH 1/7] Feature #5142 adding thumbnails to document tool --- main/document/slideshow.php | 101 ++++++++++++++++++++++++++++++++---- 1 file changed, 90 insertions(+), 11 deletions(-) diff --git a/main/document/slideshow.php b/main/document/slideshow.php index ebb26d1021..aa9dba4aea 100644 --- a/main/document/slideshow.php +++ b/main/document/slideshow.php @@ -178,21 +178,100 @@ if (isset($_SESSION["image_resizing"]) && $_SESSION["image_resizing"] == "resiz // This is for viewing all the images in the slideshow as thumbnails. $image_tag = array (); if ($slide_id == 'all') { - $thumbnail_width = 100; - $thumbnail_height = 100; - $row_items = 4; + + // Create the template_thumbnails folder (if no exist) + if (!$sys_course_path.$_course['path'].'/document'.$folder.'.thumbs/') { + @mkdir($sys_course_path.$_course['path'].'/document'.$folder.'.thumbs/', api_get_permissions_for_new_directories()); + } + + // Config thumbnails + $allowed_types = array('jpg','jpeg','gif','png','bmp');//TODO:check bellow image_files_only + $max_thumbnail_width = 100; + $max_thumbnail_height = 100; + $compression = 85; + $row_items = 4; + + + // check files and thumbnails if (is_array($image_files_only)) { foreach ($image_files_only as $one_image_file) { $image = $sys_course_path.$_course['path'].'/document'.$folder.$one_image_file; + $image_thumbnail= $sys_course_path.$_course['path'].'/document'.$folder.'.thumbs/.'.$one_image_file; + if (file_exists($image)) { - $image_height_width = resize_image($image, $thumbnail_width, $thumbnail_height, 1); - - $image_height = $image_height_width[0]; - $image_width = $image_height_width[1]; - - $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_file : $path.$one_image_file; - - $image_tag[] = ''; + //check thumbnail + $imagetype = explode(".", $image); + $imagetype = strtolower($imagetype[count($imagetype)-1]); + + if(in_array($imagetype,$allowed_types)) { + + if (!file_exists($image_thumbnail)){ + + $original_image_size = api_getimagesize($image); + switch($imagetype) { + case 'gif': + $source_img = imagecreatefromgif($image); + break; + case 'jpg': + $source_img = imagecreatefromjpeg($image); + break; + case 'png': + $source_img = imagecreatefrompng($image); + break; + case 'bmp': + $source_img = imagecreatefromwbmp($image);//TODO:check this + break; + } + + $new_thumbnail_size = api_calculate_image_size($original_image_size['width'], $original_image_size['height'], $max_thumbnail_width, $max_thumbnail_height); + $crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']); + + // preserve transparency + if($imagetype == "gif" or $imagetype == "png"){ + imagecolortransparent($crop, imagecolorallocatealpha($crop, 0, 0, 0, 127)); + //imagealphablending($crop, false);//TODO:check enabled + //imagesavealpha($crop, true);//TODO:check enabled + + //other method + /* + //preserve transparency gif and png + $transindex = imagecolortransparent($image); + + if($transindex >= 0) + { + $transcol = imagecolorsforindex($image, $transindex); + $transindex = imagecolorallocatealpha($crop, $transcol['red'], $transcol['green'], $transcol['blue'], 127); + imagefill($crop, 0, 0, $transindex); + imagecolortransparent($crop, $transindex); + } + + elseif ($imagetype == "png") + { + imagealphablending($crop, false); + $color = imagecolorallocatealpha($crop, 0, 0, 0, 127); + imagefill($crop, 0, 0, $color); + imagesavealpha($crop, true); + } +*/ + } + + imagecopyresampled($crop,$source_img,0,0,0,0,$new_thumbnail_size['width'],$new_thumbnail_size['height'],$original_image_size['width'],$original_image_size['height']); + imagejpeg($crop,$image_thumbnail,$compression); + } + $one_image_thumbnail_file='.thumbs/.'.$one_image_file;//get path thumbnail + + //show thumbnail and link + $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file; + $image_tag[] = ''; + } + else{ + //image format no support, get path original image + $image_height_width = resize_image($image, $thumbnail_width, $thumbnail_height, 1); + $image_height = $image_height_width[0]; + $image_width = $image_height_width[1]; + $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_file : $path.$one_image_file; + $image_tag[] = ''; + } } } } From f9d9debe1dd1070252c815e472c66886a1329ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Ra=C3=B1a?= Date: Sat, 7 Jul 2012 01:11:36 +0200 Subject: [PATCH 2/7] Feature #5142 adding thumbnails to document tool, fix png and gif files --- main/document/slideshow.php | 68 +++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/main/document/slideshow.php b/main/document/slideshow.php index aa9dba4aea..4d868387fe 100644 --- a/main/document/slideshow.php +++ b/main/document/slideshow.php @@ -188,7 +188,8 @@ if ($slide_id == 'all') { $allowed_types = array('jpg','jpeg','gif','png','bmp');//TODO:check bellow image_files_only $max_thumbnail_width = 100; $max_thumbnail_height = 100; - $compression = 85; + $png_compression = 0;//0(none)-9 + $jpg_quality = 75;//from 0 to 100 (default is 75). More queality less compression $row_items = 4; @@ -227,40 +228,47 @@ if ($slide_id == 'all') { $crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']); // preserve transparency - if($imagetype == "gif" or $imagetype == "png"){ - imagecolortransparent($crop, imagecolorallocatealpha($crop, 0, 0, 0, 127)); - //imagealphablending($crop, false);//TODO:check enabled - //imagesavealpha($crop, true);//TODO:check enabled - - //other method - /* - //preserve transparency gif and png - $transindex = imagecolortransparent($image); - - if($transindex >= 0) - { - $transcol = imagecolorsforindex($image, $transindex); - $transindex = imagecolorallocatealpha($crop, $transcol['red'], $transcol['green'], $transcol['blue'], 127); - imagefill($crop, 0, 0, $transindex); - imagecolortransparent($crop, $transindex); - } - - elseif ($imagetype == "png") - { - imagealphablending($crop, false); - $color = imagecolorallocatealpha($crop, 0, 0, 0, 127); - imagefill($crop, 0, 0, $color); - imagesavealpha($crop, true); - } -*/ - } + if($imagetype == "png"){ + imagesavealpha($crop, true); + $color = imagecolorallocatealpha($crop,0x00,0x00,0x00,127); + imagefill($crop, 0, 0, $color); + } + if($imagetype == "gif"){ + $transindex = imagecolortransparent($image); + //GIF89a for transparent and anim (first clip), either GIF87a + if($transindex >= 0){ + $transcol = imagecolorsforindex($image, $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']); - imagejpeg($crop,$image_thumbnail,$compression); + + if($imagetype == ("jpg" || "jpeg")) { + imagejpeg($crop,$image_thumbnail,$jpg_quality); + } + if($imagetype == "png") { + + imagepng($crop,$image_thumbnail,$png_compression); + } + if($imagetype == "gif"){ + imagegif($crop,$image_thumbnail); + } + else{ + imagejpeg($crop,$image_thumbnail);//TODO:check BMP files + } } - $one_image_thumbnail_file='.thumbs/.'.$one_image_file;//get path thumbnail + + //clean memory + imagedestroy($crop); //show thumbnail and link + $one_image_thumbnail_file='.thumbs/.'.$one_image_file;//get path thumbnail $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file; $image_tag[] = ''; } From 0a8bda0c04076ff3327caf9e1cab63bc2395c7be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Ra=C3=B1a?= Date: Sat, 7 Jul 2012 01:19:13 +0200 Subject: [PATCH 3/7] //advanced htmleditor now load thumbnails from disk --- .../ajaxfilemanager/_ajax_get_thumbnail_listing.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_thumbnail_listing.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_thumbnail_listing.php index 7831bdbf59..5db6424ff8 100644 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_thumbnail_listing.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/_ajax_get_thumbnail_listing.php @@ -65,7 +65,16 @@ foreach ($fileList as $file) { switch($file['cssClass']) { case 'filePicture': echo ''; - echo '' . "\n"; + + //improve for Chamilo load thumbnails from disk + $thumbnail_disk= dirname($file['path']).'/.thumbs/.'.basename($file['path']); + + if (file_exists($thumbnail_disk)) { + echo '' . "\n"; + } + else { + echo '' . "\n"; + } break; case 'fileFlash': case 'fileVideo': From 5cb5d48112b55361d1516cbf363ea152ec87f433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Ra=C3=B1a?= Date: Sat, 7 Jul 2012 01:51:03 +0200 Subject: [PATCH 4/7] ajaxfilemanager fix upload processing icon --- .../editor/plugins/ajaxfilemanager/ajaxfilemanager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php index ce555b38ab..5f193d88cc 100644 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php @@ -557,9 +557,9 @@ if(!empty($_GET['view'])) { - + From fc1dc53237e5d9b03a8c7e6df3f5a2ef487df7ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Ra=C3=B1a?= Date: Sat, 7 Jul 2012 03:41:44 +0200 Subject: [PATCH 5/7] improve ui html advanced editor --- .../ajaxfilemanager/ajax_file_upload.php | 1 + .../ajaxfilemanager/ajaxfilemanager.php | 7 +- .../jscripts/ajaxfilemanager.js | 3474 ++++++++--------- .../ajaxfilemanager/jscripts/thickbox.js | 8 +- 4 files changed, 1746 insertions(+), 1744 deletions(-) mode change 100755 => 100644 main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/jscripts/thickbox.js diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_upload.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_upload.php index 818b14ecd9..20e55422a7 100644 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_upload.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_file_upload.php @@ -96,6 +96,7 @@ if(CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_UPLOAD) { $error = ERR_FILE_NOT_AVAILABLE; } } + echo "error:'" . $error . "'"; echo $info; echo "}"; \ No newline at end of file diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php index 5f193d88cc..efac33323a 100644 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php @@ -84,7 +84,7 @@ if(!empty($_GET['view'])) { //end hack } var globalSettings = {'upload_init':false}; - var queryString = ''; + var queryString = ''; var paths = {'root':'', 'root_title':''}; @@ -524,7 +524,8 @@ if(!empty($_GET['view'])) {