@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /* For licensing terms, see /license.txt */ |
| 3 | 3 | /** |
| 4 | - * @author Patrick Cool [email protected] Ghent University Mai 2004 |
|
| 5 | - * @author Julio Montoya Lots of improvements, cleaning, adding security |
|
| 6 | - * @author Juan Carlos Raña Trabado [email protected] January 2008 |
|
| 7 | - * @package chamilo.document |
|
| 8 | - */ |
|
| 4 | + * @author Patrick Cool [email protected] Ghent University Mai 2004 |
|
| 5 | + * @author Julio Montoya Lots of improvements, cleaning, adding security |
|
| 6 | + * @author Juan Carlos Raña Trabado [email protected] January 2008 |
|
| 7 | + * @package chamilo.document |
|
| 8 | + */ |
|
| 9 | 9 | require_once '../inc/global.inc.php'; |
| 10 | 10 | api_protect_course_script(); |
| 11 | 11 | |
@@ -15,15 +15,15 @@ discard block |
||
| 15 | 15 | $slide_id = isset($_GET['slide_id']) ? Security::remove_XSS($_GET['slide_id']) : null; |
| 16 | 16 | |
| 17 | 17 | if (empty($slide_id)) { |
| 18 | - $edit_slide_id = 1; |
|
| 18 | + $edit_slide_id = 1; |
|
| 19 | 19 | } else { |
| 20 | - $edit_slide_id = $slide_id; |
|
| 20 | + $edit_slide_id = $slide_id; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if ($path != '/') { |
| 24 | - $folder = $path.'/'; |
|
| 24 | + $folder = $path.'/'; |
|
| 25 | 25 | } else { |
| 26 | - $folder = '/'; |
|
| 26 | + $folder = '/'; |
|
| 27 | 27 | } |
| 28 | 28 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
| 29 | 29 | |
@@ -41,15 +41,15 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | // Loading the slides from the session |
| 43 | 43 | if (isset($_SESSION['image_files_only'])) { |
| 44 | - $image_files_only = $_SESSION['image_files_only']; |
|
| 44 | + $image_files_only = $_SESSION['image_files_only']; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // Calculating the current slide, next slide, previous slide and the number of slides |
| 48 | 48 | $slide = null; |
| 49 | 49 | if ($slide_id != 'all') { |
| 50 | - $slide = $slide_id ? $slide_id : 0; |
|
| 51 | - $previous_slide = $slide - 1; |
|
| 52 | - $next_slide = $slide + 1; |
|
| 50 | + $slide = $slide_id ? $slide_id : 0; |
|
| 51 | + $previous_slide = $slide - 1; |
|
| 52 | + $next_slide = $slide + 1; |
|
| 53 | 53 | } |
| 54 | 54 | $total_slides = count($image_files_only); |
| 55 | 55 | ?> |
@@ -62,58 +62,58 @@ discard block |
||
| 62 | 62 | <?php |
| 63 | 63 | |
| 64 | 64 | if ($slide_id != 'all') { |
| 65 | - $image = null; |
|
| 66 | - if (isset($image_files_only[$slide])) { |
|
| 67 | - $image = $sys_course_path . $_course['path'] . '/document' . $folder . $image_files_only[$slide]; |
|
| 68 | - } |
|
| 69 | - if (file_exists($image)) { |
|
| 70 | - echo '<div class="actions-pagination">'; |
|
| 71 | - |
|
| 72 | - // Back forward buttons |
|
| 73 | - if ($slide == 0) { |
|
| 74 | - $imgp = 'action_prev_na.png'; |
|
| 75 | - $first = '<img src="'.api_get_path(WEB_IMG_PATH).'action_first_na.png">'; |
|
| 76 | - } else { |
|
| 77 | - $imgp = 'action_prev.png'; |
|
| 78 | - $first = '<a href="slideshow.php?slide_id=0&curdirpath='.$pathurl.'"> |
|
| 65 | + $image = null; |
|
| 66 | + if (isset($image_files_only[$slide])) { |
|
| 67 | + $image = $sys_course_path . $_course['path'] . '/document' . $folder . $image_files_only[$slide]; |
|
| 68 | + } |
|
| 69 | + if (file_exists($image)) { |
|
| 70 | + echo '<div class="actions-pagination">'; |
|
| 71 | + |
|
| 72 | + // Back forward buttons |
|
| 73 | + if ($slide == 0) { |
|
| 74 | + $imgp = 'action_prev_na.png'; |
|
| 75 | + $first = '<img src="'.api_get_path(WEB_IMG_PATH).'action_first_na.png">'; |
|
| 76 | + } else { |
|
| 77 | + $imgp = 'action_prev.png'; |
|
| 78 | + $first = '<a href="slideshow.php?slide_id=0&curdirpath='.$pathurl.'"> |
|
| 79 | 79 | <img src="'.api_get_path(WEB_IMG_PATH).'action_first.png" title="'.get_lang('FirstSlide').'" alt="'.get_lang('FirstSlide').'"></a>'; |
| 80 | - } |
|
| 81 | - |
|
| 82 | - // First slide |
|
| 83 | - echo $first; |
|
| 84 | - |
|
| 85 | - // Previous slide |
|
| 86 | - if ($slide > 0) { |
|
| 87 | - echo '<a href="slideshow.php?slide_id='.$previous_slide.'&curdirpath='.$pathurl.'">'; |
|
| 88 | - } |
|
| 89 | - echo '<img src="'.api_get_path(WEB_IMG_PATH).$imgp.'" title="'.get_lang('Previous').'" alt="'.get_lang('Previous').'">'; |
|
| 90 | - if ($slide > 0) { |
|
| 91 | - echo '</a>'; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - // Divider |
|
| 95 | - echo ' [ '.$next_slide.'/'.$total_slides.' ] '; |
|
| 96 | - |
|
| 97 | - // Next slide |
|
| 98 | - if ($slide < $total_slides - 1) { |
|
| 99 | - echo '<a href="slideshow.php?slide_id='.$next_slide.'&curdirpath='.$pathurl.'">'; |
|
| 100 | - } |
|
| 101 | - if ($slide == $total_slides - 1) { |
|
| 102 | - $imgn = 'action_next_na.png'; |
|
| 103 | - $last = '<img src="'.api_get_path(WEB_IMG_PATH).'action_last_na.png" title="'.get_lang('LastSlide').'" alt="'.get_lang('LastSlide').'">'; |
|
| 104 | - } else { |
|
| 105 | - $imgn = 'action_next.png'; |
|
| 106 | - $last = '<a href="slideshow.php?slide_id='.($total_slides-1).'&curdirpath='.$pathurl.'"><img src="'.api_get_path(WEB_IMG_PATH).'action_last.png" title="'.get_lang('LastSlide').'" alt="'.get_lang('LastSlide').'"></a>'; |
|
| 107 | - } |
|
| 108 | - echo '<img src="'.api_get_path(WEB_IMG_PATH).$imgn.'" title="'.get_lang('Next').'" alt="'.get_lang('Next').'">'; |
|
| 109 | - if ($slide > 0) { |
|
| 110 | - echo '</a>'; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - // Last slide |
|
| 114 | - echo $last; |
|
| 115 | - echo '</div>'; |
|
| 116 | - } |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + // First slide |
|
| 83 | + echo $first; |
|
| 84 | + |
|
| 85 | + // Previous slide |
|
| 86 | + if ($slide > 0) { |
|
| 87 | + echo '<a href="slideshow.php?slide_id='.$previous_slide.'&curdirpath='.$pathurl.'">'; |
|
| 88 | + } |
|
| 89 | + echo '<img src="'.api_get_path(WEB_IMG_PATH).$imgp.'" title="'.get_lang('Previous').'" alt="'.get_lang('Previous').'">'; |
|
| 90 | + if ($slide > 0) { |
|
| 91 | + echo '</a>'; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + // Divider |
|
| 95 | + echo ' [ '.$next_slide.'/'.$total_slides.' ] '; |
|
| 96 | + |
|
| 97 | + // Next slide |
|
| 98 | + if ($slide < $total_slides - 1) { |
|
| 99 | + echo '<a href="slideshow.php?slide_id='.$next_slide.'&curdirpath='.$pathurl.'">'; |
|
| 100 | + } |
|
| 101 | + if ($slide == $total_slides - 1) { |
|
| 102 | + $imgn = 'action_next_na.png'; |
|
| 103 | + $last = '<img src="'.api_get_path(WEB_IMG_PATH).'action_last_na.png" title="'.get_lang('LastSlide').'" alt="'.get_lang('LastSlide').'">'; |
|
| 104 | + } else { |
|
| 105 | + $imgn = 'action_next.png'; |
|
| 106 | + $last = '<a href="slideshow.php?slide_id='.($total_slides-1).'&curdirpath='.$pathurl.'"><img src="'.api_get_path(WEB_IMG_PATH).'action_last.png" title="'.get_lang('LastSlide').'" alt="'.get_lang('LastSlide').'"></a>'; |
|
| 107 | + } |
|
| 108 | + echo '<img src="'.api_get_path(WEB_IMG_PATH).$imgn.'" title="'.get_lang('Next').'" alt="'.get_lang('Next').'">'; |
|
| 109 | + if ($slide > 0) { |
|
| 110 | + echo '</a>'; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + // Last slide |
|
| 114 | + echo $last; |
|
| 115 | + echo '</div>'; |
|
| 116 | + } |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Exit the slideshow |
@@ -122,10 +122,10 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | // Show thumbnails |
| 124 | 124 | if ($slide_id != 'all') { |
| 125 | - echo '<a href="slideshow.php?slide_id=all&curdirpath='.$pathurl.'&'.api_get_cidreq().'">'. |
|
| 125 | + echo '<a href="slideshow.php?slide_id=all&curdirpath='.$pathurl.'&'.api_get_cidreq().'">'. |
|
| 126 | 126 | Display::return_icon('thumbnails.png',get_lang('ShowThumbnails'),'',ICON_SIZE_MEDIUM).'</a>'; |
| 127 | 127 | } else { |
| 128 | - echo Display::return_icon('thumbnails_na.png',get_lang('ShowThumbnails'),'',ICON_SIZE_MEDIUM); |
|
| 128 | + echo Display::return_icon('thumbnails_na.png',get_lang('ShowThumbnails'),'',ICON_SIZE_MEDIUM); |
|
| 129 | 129 | } |
| 130 | 130 | // Slideshow options |
| 131 | 131 | echo '<a href="slideshowoptions.php?curdirpath='.$pathurl.'&'.api_get_cidreq().'">'. |
@@ -141,24 +141,24 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | // If we come from slideshowoptions.php we sessionize (new word !!! ;-) the options |
| 143 | 143 | if (isset($_POST['Submit'])) { |
| 144 | - // We come from slideshowoptions.php |
|
| 145 | - //$_SESSION["auto_image_resizing"]=Security::remove_XSS($_POST['auto_radio_resizing']); |
|
| 146 | - $_SESSION["image_resizing"] = Security::remove_XSS($_POST['radio_resizing']); |
|
| 147 | - if ($_POST['radio_resizing'] == "resizing" && $_POST['width'] != '' && $_POST['height'] != '') { |
|
| 148 | - //echo "resizing"; |
|
| 149 | - $_SESSION["image_resizing_width"] = Security::remove_XSS($_POST['width']); |
|
| 150 | - $_SESSION["image_resizing_height"] = Security::remove_XSS($_POST['height']); |
|
| 151 | - } else { |
|
| 152 | - //echo "unsetting the session heighte and width"; |
|
| 153 | - $_SESSION["image_resizing_width"] = null; |
|
| 154 | - $_SESSION["image_resizing_height"] = null; |
|
| 155 | - } |
|
| 144 | + // We come from slideshowoptions.php |
|
| 145 | + //$_SESSION["auto_image_resizing"]=Security::remove_XSS($_POST['auto_radio_resizing']); |
|
| 146 | + $_SESSION["image_resizing"] = Security::remove_XSS($_POST['radio_resizing']); |
|
| 147 | + if ($_POST['radio_resizing'] == "resizing" && $_POST['width'] != '' && $_POST['height'] != '') { |
|
| 148 | + //echo "resizing"; |
|
| 149 | + $_SESSION["image_resizing_width"] = Security::remove_XSS($_POST['width']); |
|
| 150 | + $_SESSION["image_resizing_height"] = Security::remove_XSS($_POST['height']); |
|
| 151 | + } else { |
|
| 152 | + //echo "unsetting the session heighte and width"; |
|
| 153 | + $_SESSION["image_resizing_width"] = null; |
|
| 154 | + $_SESSION["image_resizing_height"] = null; |
|
| 155 | + } |
|
| 156 | 156 | } |
| 157 | 157 | $target_width = $target_height = null; |
| 158 | 158 | // The target height and width depends if we choose resizing or no resizing |
| 159 | 159 | if (isset($_SESSION["image_resizing"]) && $_SESSION["image_resizing"] == "resizing") { |
| 160 | - $target_width = $_SESSION["image_resizing_width"]; |
|
| 161 | - $target_height = $_SESSION["image_resizing_height"]; |
|
| 160 | + $target_width = $_SESSION["image_resizing_width"]; |
|
| 161 | + $target_height = $_SESSION["image_resizing_height"]; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /* THUMBNAIL VIEW */ |
@@ -168,59 +168,59 @@ discard block |
||
| 168 | 168 | $html = ''; |
| 169 | 169 | if ($slide_id == 'all') { |
| 170 | 170 | |
| 171 | - // Config for make thumbnails |
|
| 171 | + // Config for make thumbnails |
|
| 172 | 172 | $allowed_thumbnail_types = array('jpg', 'jpeg', 'gif', 'png'); |
| 173 | - $max_thumbnail_width = 250; |
|
| 174 | - $max_thumbnail_height = 250; |
|
| 175 | - $png_compression = 0;//0(none)-9 |
|
| 176 | - $jpg_quality = 100;//from 0 to 100 (default is 75). More quality less compression |
|
| 173 | + $max_thumbnail_width = 250; |
|
| 174 | + $max_thumbnail_height = 250; |
|
| 175 | + $png_compression = 0;//0(none)-9 |
|
| 176 | + $jpg_quality = 100;//from 0 to 100 (default is 75). More quality less compression |
|
| 177 | 177 | |
| 178 | - $directory_thumbnails = $sys_course_path.$_course['path'].'/document'.$folder.'.thumbs/'; |
|
| 178 | + $directory_thumbnails = $sys_course_path.$_course['path'].'/document'.$folder.'.thumbs/'; |
|
| 179 | 179 | |
| 180 | - //Other parameters only for show tumbnails |
|
| 181 | - $row_items = 4;//only in slideshow.php |
|
| 182 | - $number_image = 7;//num icons cols to show |
|
| 183 | - $thumbnail_width_frame = $max_thumbnail_width;//optional $max_thumbnail_width+x |
|
| 184 | - $thumbnail_height_frame = $max_thumbnail_height; |
|
| 180 | + //Other parameters only for show tumbnails |
|
| 181 | + $row_items = 4;//only in slideshow.php |
|
| 182 | + $number_image = 7;//num icons cols to show |
|
| 183 | + $thumbnail_width_frame = $max_thumbnail_width;//optional $max_thumbnail_width+x |
|
| 184 | + $thumbnail_height_frame = $max_thumbnail_height; |
|
| 185 | 185 | |
| 186 | - // Create the template_thumbnails folder (if no exist) |
|
| 186 | + // Create the template_thumbnails folder (if no exist) |
|
| 187 | 187 | |
| 188 | - if (!file_exists($directory_thumbnails)) { |
|
| 189 | - @mkdir($directory_thumbnails, api_get_permissions_for_new_directories()); |
|
| 188 | + if (!file_exists($directory_thumbnails)) { |
|
| 189 | + @mkdir($directory_thumbnails, api_get_permissions_for_new_directories()); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - // check files and thumbnails |
|
| 193 | - if (is_array($image_files_only)) { |
|
| 192 | + // check files and thumbnails |
|
| 193 | + if (is_array($image_files_only)) { |
|
| 194 | 194 | |
| 195 | - foreach ($image_files_only as $one_image_file) { |
|
| 196 | - $image = $sys_course_path.$_course['path'].'/document'.$folder.$one_image_file; |
|
| 197 | - $image_thumbnail= $directory_thumbnails.'.'.$one_image_file; |
|
| 195 | + foreach ($image_files_only as $one_image_file) { |
|
| 196 | + $image = $sys_course_path.$_course['path'].'/document'.$folder.$one_image_file; |
|
| 197 | + $image_thumbnail= $directory_thumbnails.'.'.$one_image_file; |
|
| 198 | 198 | |
| 199 | - if (file_exists($image)) { |
|
| 200 | - //check thumbnail |
|
| 201 | - $imagetype = explode(".", $image); |
|
| 199 | + if (file_exists($image)) { |
|
| 200 | + //check thumbnail |
|
| 201 | + $imagetype = explode(".", $image); |
|
| 202 | 202 | //or check $imagetype = image_type_to_extension(exif_imagetype($image), false); |
| 203 | - $imagetype = strtolower($imagetype[count($imagetype)-1]); |
|
| 203 | + $imagetype = strtolower($imagetype[count($imagetype)-1]); |
|
| 204 | 204 | |
| 205 | - if(in_array($imagetype,$allowed_thumbnail_types)) { |
|
| 206 | - if (!file_exists($image_thumbnail)){ |
|
| 205 | + if(in_array($imagetype,$allowed_thumbnail_types)) { |
|
| 206 | + if (!file_exists($image_thumbnail)){ |
|
| 207 | 207 | //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 |
| 208 | - $original_image_size = api_getimagesize($image); |
|
| 209 | - |
|
| 210 | - switch($imagetype) { |
|
| 211 | - case 'gif': |
|
| 212 | - $source_img = imagecreatefromgif($image); |
|
| 213 | - break; |
|
| 214 | - case 'jpg': |
|
| 215 | - $source_img = imagecreatefromjpeg($image); |
|
| 216 | - break; |
|
| 217 | - case 'jpeg': |
|
| 218 | - $source_img = imagecreatefromjpeg($image); |
|
| 219 | - break; |
|
| 220 | - case 'png': |
|
| 221 | - $source_img = imagecreatefrompng($image); |
|
| 222 | - break; |
|
| 223 | - } |
|
| 208 | + $original_image_size = api_getimagesize($image); |
|
| 209 | + |
|
| 210 | + switch($imagetype) { |
|
| 211 | + case 'gif': |
|
| 212 | + $source_img = imagecreatefromgif($image); |
|
| 213 | + break; |
|
| 214 | + case 'jpg': |
|
| 215 | + $source_img = imagecreatefromjpeg($image); |
|
| 216 | + break; |
|
| 217 | + case 'jpeg': |
|
| 218 | + $source_img = imagecreatefromjpeg($image); |
|
| 219 | + break; |
|
| 220 | + case 'png': |
|
| 221 | + $source_img = imagecreatefrompng($image); |
|
| 222 | + break; |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | 225 | $new_thumbnail_size = api_calculate_image_size( |
| 226 | 226 | $original_image_size['width'], |
@@ -228,33 +228,33 @@ discard block |
||
| 228 | 228 | $max_thumbnail_width, |
| 229 | 229 | $max_thumbnail_height |
| 230 | 230 | ); |
| 231 | - if($max_thumbnail_width>$original_image_size['width'] && $max_thumbnail_height>$original_image_size['height']){ |
|
| 232 | - $new_thumbnail_size['width']=$original_image_size['width']; |
|
| 233 | - $new_thumbnail_size['height']=$original_image_size['height']; |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - $crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']); |
|
| 237 | - |
|
| 238 | - // preserve transparency |
|
| 239 | - if($imagetype == "png"){ |
|
| 240 | - imagesavealpha($crop, true); |
|
| 241 | - $color = imagecolorallocatealpha($crop,0x00,0x00,0x00,127); |
|
| 242 | - imagefill($crop, 0, 0, $color); |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - if ($imagetype == "gif") { |
|
| 246 | - $transindex = imagecolortransparent($source_img); |
|
| 231 | + if($max_thumbnail_width>$original_image_size['width'] && $max_thumbnail_height>$original_image_size['height']){ |
|
| 232 | + $new_thumbnail_size['width']=$original_image_size['width']; |
|
| 233 | + $new_thumbnail_size['height']=$original_image_size['height']; |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + $crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']); |
|
| 237 | + |
|
| 238 | + // preserve transparency |
|
| 239 | + if($imagetype == "png"){ |
|
| 240 | + imagesavealpha($crop, true); |
|
| 241 | + $color = imagecolorallocatealpha($crop,0x00,0x00,0x00,127); |
|
| 242 | + imagefill($crop, 0, 0, $color); |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + if ($imagetype == "gif") { |
|
| 246 | + $transindex = imagecolortransparent($source_img); |
|
| 247 | 247 | $palletsize = imagecolorstotal($source_img); |
| 248 | - //GIF89a for transparent and anim (first clip), either GIF87a |
|
| 249 | - if ($transindex >= 0 && $transindex < $palletsize){ |
|
| 250 | - $transcol = imagecolorsforindex($source_img, $transindex); |
|
| 251 | - $transindex = imagecolorallocatealpha($crop, $transcol['red'], $transcol['green'], $transcol['blue'], 127); |
|
| 252 | - imagefill($crop, 0, 0, $transindex); |
|
| 253 | - imagecolortransparent($crop, $transindex); |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - //resampled image |
|
| 248 | + //GIF89a for transparent and anim (first clip), either GIF87a |
|
| 249 | + if ($transindex >= 0 && $transindex < $palletsize){ |
|
| 250 | + $transcol = imagecolorsforindex($source_img, $transindex); |
|
| 251 | + $transindex = imagecolorallocatealpha($crop, $transcol['red'], $transcol['green'], $transcol['blue'], 127); |
|
| 252 | + imagefill($crop, 0, 0, $transindex); |
|
| 253 | + imagecolortransparent($crop, $transindex); |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + //resampled image |
|
| 258 | 258 | imagecopyresampled( |
| 259 | 259 | $crop, |
| 260 | 260 | $source_img, |
@@ -268,69 +268,69 @@ discard block |
||
| 268 | 268 | $original_image_size['height'] |
| 269 | 269 | ); |
| 270 | 270 | |
| 271 | - switch ($imagetype) { |
|
| 272 | - case 'gif': |
|
| 273 | - imagegif($crop,$image_thumbnail); |
|
| 274 | - break; |
|
| 275 | - case 'jpg': |
|
| 276 | - imagejpeg($crop,$image_thumbnail,$jpg_quality); |
|
| 277 | - break; |
|
| 278 | - case 'jpeg': |
|
| 279 | - imagejpeg($crop,$image_thumbnail,$jpg_quality); |
|
| 280 | - break; |
|
| 281 | - case 'png': |
|
| 282 | - imagepng($crop,$image_thumbnail,$png_compression); |
|
| 283 | - break; |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - //clean memory |
|
| 287 | - imagedestroy($crop); |
|
| 288 | - }//end !exist thumbnail |
|
| 289 | - |
|
| 290 | - //show thumbnail and link |
|
| 291 | - |
|
| 292 | - $one_image_thumbnail_file='.thumbs/.'.$one_image_file;//get path thumbnail |
|
| 293 | - $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file; |
|
| 294 | - $image_tag[] = '<img class="img-gallery" src="download.php?doc_url='.$doc_url.'" border="0" title="'.$one_image_file.'">'; |
|
| 295 | - } else { |
|
| 296 | - //if images aren't support by gd (not gif, jpg, jpeg, png) |
|
| 297 | - if ($imagetype=="bmp") { |
|
| 271 | + switch ($imagetype) { |
|
| 272 | + case 'gif': |
|
| 273 | + imagegif($crop,$image_thumbnail); |
|
| 274 | + break; |
|
| 275 | + case 'jpg': |
|
| 276 | + imagejpeg($crop,$image_thumbnail,$jpg_quality); |
|
| 277 | + break; |
|
| 278 | + case 'jpeg': |
|
| 279 | + imagejpeg($crop,$image_thumbnail,$jpg_quality); |
|
| 280 | + break; |
|
| 281 | + case 'png': |
|
| 282 | + imagepng($crop,$image_thumbnail,$png_compression); |
|
| 283 | + break; |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + //clean memory |
|
| 287 | + imagedestroy($crop); |
|
| 288 | + }//end !exist thumbnail |
|
| 289 | + |
|
| 290 | + //show thumbnail and link |
|
| 291 | + |
|
| 292 | + $one_image_thumbnail_file='.thumbs/.'.$one_image_file;//get path thumbnail |
|
| 293 | + $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file; |
|
| 294 | + $image_tag[] = '<img class="img-gallery" src="download.php?doc_url='.$doc_url.'" border="0" title="'.$one_image_file.'">'; |
|
| 295 | + } else { |
|
| 296 | + //if images aren't support by gd (not gif, jpg, jpeg, png) |
|
| 297 | + if ($imagetype=="bmp") { |
|
| 298 | 298 | // use getimagesize instead api_getimagesize($image); becasuse api_getimagesize doesn't support bmp files. Put here for each show, only for a few bmp files isn't heavy |
| 299 | - $original_image_size = getimagesize($image); |
|
| 300 | - if ($max_thumbnail_width<$original_image_size[0] || $max_thumbnail_height<$original_image_size[1]){ |
|
| 301 | - $thumbnail_size=api_calculate_image_size($original_image_size[0], $original_image_size[1], $max_thumbnail_width, $max_thumbnail_height);//don't use resize_image because doesn't run with bmp files |
|
| 302 | - $image_height = $thumbnail_size['height']; |
|
| 303 | - $image_width = $thumbnail_size['width']; |
|
| 304 | - } else { |
|
| 305 | - $image_height=$original_image_size[0]; |
|
| 306 | - $image_width=$original_image_size[1]; |
|
| 307 | - } |
|
| 308 | - } else { |
|
| 309 | - //example for svg files,... |
|
| 310 | - $image_width=$max_thumbnail_width; |
|
| 311 | - $image_height=$max_thumbnail_height; |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_file : $path.$one_image_file; |
|
| 315 | - $image_tag[] = '<img src="download.php?doc_url='.$doc_url.'" border="0" width="'.$image_width.'" height="'.$image_height.'" title="'.$one_image_file.'">'; |
|
| 316 | - |
|
| 317 | - }//end allowed image types |
|
| 318 | - }//end if exist file image |
|
| 319 | - }//end foreach |
|
| 320 | - }//end image files only |
|
| 321 | - |
|
| 322 | - // Creating the table |
|
| 323 | - $html_table = ''; |
|
| 324 | - |
|
| 325 | - $i = 0; |
|
| 326 | - $count_image = count($image_tag); |
|
| 327 | - $number_iteration = ceil($count_image/$number_image); |
|
| 328 | - $p = 0; |
|
| 299 | + $original_image_size = getimagesize($image); |
|
| 300 | + if ($max_thumbnail_width<$original_image_size[0] || $max_thumbnail_height<$original_image_size[1]){ |
|
| 301 | + $thumbnail_size=api_calculate_image_size($original_image_size[0], $original_image_size[1], $max_thumbnail_width, $max_thumbnail_height);//don't use resize_image because doesn't run with bmp files |
|
| 302 | + $image_height = $thumbnail_size['height']; |
|
| 303 | + $image_width = $thumbnail_size['width']; |
|
| 304 | + } else { |
|
| 305 | + $image_height=$original_image_size[0]; |
|
| 306 | + $image_width=$original_image_size[1]; |
|
| 307 | + } |
|
| 308 | + } else { |
|
| 309 | + //example for svg files,... |
|
| 310 | + $image_width=$max_thumbnail_width; |
|
| 311 | + $image_height=$max_thumbnail_height; |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_file : $path.$one_image_file; |
|
| 315 | + $image_tag[] = '<img src="download.php?doc_url='.$doc_url.'" border="0" width="'.$image_width.'" height="'.$image_height.'" title="'.$one_image_file.'">'; |
|
| 316 | + |
|
| 317 | + }//end allowed image types |
|
| 318 | + }//end if exist file image |
|
| 319 | + }//end foreach |
|
| 320 | + }//end image files only |
|
| 321 | + |
|
| 322 | + // Creating the table |
|
| 323 | + $html_table = ''; |
|
| 324 | + |
|
| 325 | + $i = 0; |
|
| 326 | + $count_image = count($image_tag); |
|
| 327 | + $number_iteration = ceil($count_image/$number_image); |
|
| 328 | + $p = 0; |
|
| 329 | 329 | $html = ''; |
| 330 | 330 | $html .= '<div class="gallery">'; |
| 331 | - for ($k = 0; $k < $number_iteration; $k++) { |
|
| 332 | - for ($i = 0; $i < $number_image; $i++) { |
|
| 333 | - if (isset($image_tag[$p])) { |
|
| 331 | + for ($k = 0; $k < $number_iteration; $k++) { |
|
| 332 | + for ($i = 0; $i < $number_image; $i++) { |
|
| 333 | + if (isset($image_tag[$p])) { |
|
| 334 | 334 | $html .= '<div class="col-xs-6 col-sm-3 col-md-2">'; |
| 335 | 335 | $html .= '<div class="canvas-one">'; |
| 336 | 336 | $html .= '<a class="canvas-two" href="slideshow.php?slide_id='.$p.'&curdirpath='.$pathurl.'">'; |
@@ -342,10 +342,10 @@ discard block |
||
| 342 | 342 | $html .= '</a>'; |
| 343 | 343 | $html .= '</div>'; |
| 344 | 344 | $html .= '</div>'; |
| 345 | - } |
|
| 346 | - $p++; |
|
| 347 | - } |
|
| 348 | - } |
|
| 345 | + } |
|
| 346 | + $p++; |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | 349 | $html .= '</div>'; |
| 350 | 350 | |
| 351 | 351 | }//end slide==all |
@@ -356,45 +356,45 @@ discard block |
||
| 356 | 356 | // This is for viewing all the images in the slideshow one at a time. |
| 357 | 357 | |
| 358 | 358 | if ($slide_id != 'all' && !empty($image_files_only)) { |
| 359 | - if (file_exists($image) && is_file($image)) { |
|
| 360 | - $image_height_width = resize_image($image, $target_width, $target_height); |
|
| 361 | - |
|
| 362 | - $image_height = $image_height_width[0]; |
|
| 363 | - $image_width = $image_height_width[1]; |
|
| 364 | - |
|
| 365 | - $height_width_tags = null; |
|
| 366 | - if (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] == 'resizing') { |
|
| 367 | - $height_width_tags = 'width="'.$image_width.'" height="'.$image_height.'"'; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - // This is done really quickly and should be cleaned up a little bit using the API functions |
|
| 371 | - $tbl_documents = Database::get_course_table(TABLE_DOCUMENT); |
|
| 372 | - if ($path == '/') { |
|
| 373 | - $pathpart = '/'; |
|
| 374 | - } else { |
|
| 375 | - $pathpart = $path.'/'; |
|
| 376 | - } |
|
| 377 | - $sql = "SELECT * FROM $tbl_documents |
|
| 359 | + if (file_exists($image) && is_file($image)) { |
|
| 360 | + $image_height_width = resize_image($image, $target_width, $target_height); |
|
| 361 | + |
|
| 362 | + $image_height = $image_height_width[0]; |
|
| 363 | + $image_width = $image_height_width[1]; |
|
| 364 | + |
|
| 365 | + $height_width_tags = null; |
|
| 366 | + if (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] == 'resizing') { |
|
| 367 | + $height_width_tags = 'width="'.$image_width.'" height="'.$image_height.'"'; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + // This is done really quickly and should be cleaned up a little bit using the API functions |
|
| 371 | + $tbl_documents = Database::get_course_table(TABLE_DOCUMENT); |
|
| 372 | + if ($path == '/') { |
|
| 373 | + $pathpart = '/'; |
|
| 374 | + } else { |
|
| 375 | + $pathpart = $path.'/'; |
|
| 376 | + } |
|
| 377 | + $sql = "SELECT * FROM $tbl_documents |
|
| 378 | 378 | WHERE c_id = $course_id AND path='".Database::escape_string($pathpart.$image_files_only[$slide])."'"; |
| 379 | - $result = Database::query($sql); |
|
| 380 | - $row = Database::fetch_array($result); |
|
| 381 | - |
|
| 382 | - echo '<table align="center" border="0" cellspacing="10">'; |
|
| 383 | - echo '<tr>'; |
|
| 384 | - echo '<td id="td_image" align="center">'; |
|
| 385 | - if ($slide < $total_slides - 1 && $slide_id != 'all') { |
|
| 386 | - echo "<a href='slideshow.php?slide_id=".$next_slide."&curdirpath=$pathurl'>"; |
|
| 387 | - } else { |
|
| 388 | - echo "<a href='slideshow.php?slide_id=0&curdirpath=$pathurl'>"; |
|
| 389 | - } |
|
| 379 | + $result = Database::query($sql); |
|
| 380 | + $row = Database::fetch_array($result); |
|
| 381 | + |
|
| 382 | + echo '<table align="center" border="0" cellspacing="10">'; |
|
| 383 | + echo '<tr>'; |
|
| 384 | + echo '<td id="td_image" align="center">'; |
|
| 385 | + if ($slide < $total_slides - 1 && $slide_id != 'all') { |
|
| 386 | + echo "<a href='slideshow.php?slide_id=".$next_slide."&curdirpath=$pathurl'>"; |
|
| 387 | + } else { |
|
| 388 | + echo "<a href='slideshow.php?slide_id=0&curdirpath=$pathurl'>"; |
|
| 389 | + } |
|
| 390 | 390 | if ($path == '/') { |
| 391 | - $path = ''; |
|
| 391 | + $path = ''; |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - list($width, $height) = getimagesize($image); |
|
| 395 | - // Auto resize |
|
| 396 | - if (isset($_SESSION["image_resizing"]) && $_SESSION["image_resizing"] == 'resizing') { |
|
| 397 | - ?> |
|
| 394 | + list($width, $height) = getimagesize($image); |
|
| 395 | + // Auto resize |
|
| 396 | + if (isset($_SESSION["image_resizing"]) && $_SESSION["image_resizing"] == 'resizing') { |
|
| 397 | + ?> |
|
| 398 | 398 | |
| 399 | 399 | <script type="text/javascript"> |
| 400 | 400 | var initial_width='<?php echo $width; ?>'; |
@@ -447,30 +447,30 @@ discard block |
||
| 447 | 447 | |
| 448 | 448 | </script> |
| 449 | 449 | <?php |
| 450 | - } else { |
|
| 451 | - echo "<img src='download.php?doc_url=$path/".$image_files_only[$slide]."' alt='".$image_files_only[$slide]."' border='0'".$height_width_tags.">"; |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - echo '</a>'; |
|
| 455 | - echo '</td>'; |
|
| 456 | - echo '</tr>'; |
|
| 457 | - echo '<tr>'; |
|
| 458 | - echo '<td>'; |
|
| 459 | - echo $row['comment']; |
|
| 460 | - echo '</td>'; |
|
| 450 | + } else { |
|
| 451 | + echo "<img src='download.php?doc_url=$path/".$image_files_only[$slide]."' alt='".$image_files_only[$slide]."' border='0'".$height_width_tags.">"; |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + echo '</a>'; |
|
| 455 | + echo '</td>'; |
|
| 456 | + echo '</tr>'; |
|
| 457 | + echo '<tr>'; |
|
| 458 | + echo '<td>'; |
|
| 459 | + echo $row['comment']; |
|
| 460 | + echo '</td>'; |
|
| 461 | 461 | |
| 462 | 462 | echo '<tr>'; |
| 463 | 463 | echo '<td style="padding:10px;" align="center">'; |
| 464 | 464 | echo Display::tag('h3', $row['title']); |
| 465 | 465 | echo '</td>'; |
| 466 | 466 | echo '</tr>'; |
| 467 | - echo '</tr>'; |
|
| 468 | - echo '</table>'; |
|
| 467 | + echo '</tr>'; |
|
| 468 | + echo '</table>'; |
|
| 469 | 469 | |
| 470 | - echo '<table align="center" border="0">'; |
|
| 471 | - if (api_is_allowed_to_edit(null, true)) { |
|
| 472 | - $aux = explode('.', htmlspecialchars($image_files_only[$slide])); |
|
| 473 | - $ext = $aux[count($aux) - 1]; |
|
| 470 | + echo '<table align="center" border="0">'; |
|
| 471 | + if (api_is_allowed_to_edit(null, true)) { |
|
| 472 | + $aux = explode('.', htmlspecialchars($image_files_only[$slide])); |
|
| 473 | + $ext = $aux[count($aux) - 1]; |
|
| 474 | 474 | |
| 475 | 475 | if (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] == 'resizing') { |
| 476 | 476 | $resize_info = get_lang('Resizing').'<br />'; |
@@ -482,8 +482,8 @@ discard block |
||
| 482 | 482 | $resize_height = get_lang('Auto'); |
| 483 | 483 | } else { |
| 484 | 484 | $resize_info = get_lang('NoResizing').'<br />'; |
| 485 | - $resize_width = ''; |
|
| 486 | - $resize_height = ''; |
|
| 485 | + $resize_width = ''; |
|
| 486 | + $resize_height = ''; |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | echo '<tr>'; |
@@ -491,25 +491,25 @@ discard block |
||
| 491 | 491 | echo '<a href="edit_document.php?'.api_get_cidreq().'&id='.$row['id'].'&origin=slideshow&origin_opt='.$edit_slide_id.'&"> |
| 492 | 492 | <img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="'.get_lang('Modify').'" /></a><br />'; |
| 493 | 493 | |
| 494 | - echo $image_files_only[$slide].' <br />'; |
|
| 495 | - echo $width.' x '.$height.' <br />'; |
|
| 496 | - echo round((filesize($image)/1024), 2).' KB'; |
|
| 497 | - echo ' - '.$ext; |
|
| 498 | - echo '</td>'; |
|
| 499 | - echo '</tr>'; |
|
| 500 | - echo '<tr>'; |
|
| 501 | - echo '<td align="center">'; |
|
| 502 | - echo $resize_info; |
|
| 503 | - echo $resize_width; |
|
| 504 | - echo $resize_height; |
|
| 505 | - echo '</td>'; |
|
| 506 | - echo '</tr>'; |
|
| 507 | - } |
|
| 508 | - echo '</table>'; |
|
| 509 | - |
|
| 510 | - } else { |
|
| 511 | - Display::display_warning_message(get_lang('FileNotFound')); |
|
| 512 | - } |
|
| 494 | + echo $image_files_only[$slide].' <br />'; |
|
| 495 | + echo $width.' x '.$height.' <br />'; |
|
| 496 | + echo round((filesize($image)/1024), 2).' KB'; |
|
| 497 | + echo ' - '.$ext; |
|
| 498 | + echo '</td>'; |
|
| 499 | + echo '</tr>'; |
|
| 500 | + echo '<tr>'; |
|
| 501 | + echo '<td align="center">'; |
|
| 502 | + echo $resize_info; |
|
| 503 | + echo $resize_width; |
|
| 504 | + echo $resize_height; |
|
| 505 | + echo '</td>'; |
|
| 506 | + echo '</tr>'; |
|
| 507 | + } |
|
| 508 | + echo '</table>'; |
|
| 509 | + |
|
| 510 | + } else { |
|
| 511 | + Display::display_warning_message(get_lang('FileNotFound')); |
|
| 512 | + } |
|
| 513 | 513 | } else { |
| 514 | 514 | if ($slide_id != 'all') { |
| 515 | 515 | Display::display_warning_message(get_lang('NoDataAvailable')); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | if ($slide_id != 'all') { |
| 65 | 65 | $image = null; |
| 66 | 66 | if (isset($image_files_only[$slide])) { |
| 67 | - $image = $sys_course_path . $_course['path'] . '/document' . $folder . $image_files_only[$slide]; |
|
| 67 | + $image = $sys_course_path.$_course['path'].'/document'.$folder.$image_files_only[$slide]; |
|
| 68 | 68 | } |
| 69 | 69 | if (file_exists($image)) { |
| 70 | 70 | echo '<div class="actions-pagination">'; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | $last = '<img src="'.api_get_path(WEB_IMG_PATH).'action_last_na.png" title="'.get_lang('LastSlide').'" alt="'.get_lang('LastSlide').'">'; |
| 104 | 104 | } else { |
| 105 | 105 | $imgn = 'action_next.png'; |
| 106 | - $last = '<a href="slideshow.php?slide_id='.($total_slides-1).'&curdirpath='.$pathurl.'"><img src="'.api_get_path(WEB_IMG_PATH).'action_last.png" title="'.get_lang('LastSlide').'" alt="'.get_lang('LastSlide').'"></a>'; |
|
| 106 | + $last = '<a href="slideshow.php?slide_id='.($total_slides - 1).'&curdirpath='.$pathurl.'"><img src="'.api_get_path(WEB_IMG_PATH).'action_last.png" title="'.get_lang('LastSlide').'" alt="'.get_lang('LastSlide').'"></a>'; |
|
| 107 | 107 | } |
| 108 | 108 | echo '<img src="'.api_get_path(WEB_IMG_PATH).$imgn.'" title="'.get_lang('Next').'" alt="'.get_lang('Next').'">'; |
| 109 | 109 | if ($slide > 0) { |
@@ -118,18 +118,18 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | // Exit the slideshow |
| 120 | 120 | echo '<a href="document.php?action=exit_slideshow&curdirpath='.$pathurl.'&'.api_get_cidreq().'">'. |
| 121 | - Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
| 121 | + Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
| 122 | 122 | |
| 123 | 123 | // Show thumbnails |
| 124 | 124 | if ($slide_id != 'all') { |
| 125 | 125 | echo '<a href="slideshow.php?slide_id=all&curdirpath='.$pathurl.'&'.api_get_cidreq().'">'. |
| 126 | - Display::return_icon('thumbnails.png',get_lang('ShowThumbnails'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
| 126 | + Display::return_icon('thumbnails.png', get_lang('ShowThumbnails'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
| 127 | 127 | } else { |
| 128 | - echo Display::return_icon('thumbnails_na.png',get_lang('ShowThumbnails'),'',ICON_SIZE_MEDIUM); |
|
| 128 | + echo Display::return_icon('thumbnails_na.png', get_lang('ShowThumbnails'), '', ICON_SIZE_MEDIUM); |
|
| 129 | 129 | } |
| 130 | 130 | // Slideshow options |
| 131 | 131 | echo '<a href="slideshowoptions.php?curdirpath='.$pathurl.'&'.api_get_cidreq().'">'. |
| 132 | - Display::return_icon('settings.png',get_lang('SetSlideshowOptions'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
| 132 | + Display::return_icon('settings.png', get_lang('SetSlideshowOptions'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
| 133 | 133 | |
| 134 | 134 | ?> |
| 135 | 135 | </div> |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | $target_width = $target_height = null; |
| 158 | 158 | // The target height and width depends if we choose resizing or no resizing |
| 159 | -if (isset($_SESSION["image_resizing"]) && $_SESSION["image_resizing"] == "resizing") { |
|
| 159 | +if (isset($_SESSION["image_resizing"]) && $_SESSION["image_resizing"] == "resizing") { |
|
| 160 | 160 | $target_width = $_SESSION["image_resizing_width"]; |
| 161 | 161 | $target_height = $_SESSION["image_resizing_height"]; |
| 162 | 162 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | /* THUMBNAIL VIEW */ |
| 165 | 165 | |
| 166 | 166 | // This is for viewing all the images in the slideshow as thumbnails. |
| 167 | -$image_tag = array (); |
|
| 167 | +$image_tag = array(); |
|
| 168 | 168 | $html = ''; |
| 169 | 169 | if ($slide_id == 'all') { |
| 170 | 170 | |
@@ -172,15 +172,15 @@ discard block |
||
| 172 | 172 | $allowed_thumbnail_types = array('jpg', 'jpeg', 'gif', 'png'); |
| 173 | 173 | $max_thumbnail_width = 250; |
| 174 | 174 | $max_thumbnail_height = 250; |
| 175 | - $png_compression = 0;//0(none)-9 |
|
| 176 | - $jpg_quality = 100;//from 0 to 100 (default is 75). More quality less compression |
|
| 175 | + $png_compression = 0; //0(none)-9 |
|
| 176 | + $jpg_quality = 100; //from 0 to 100 (default is 75). More quality less compression |
|
| 177 | 177 | |
| 178 | 178 | $directory_thumbnails = $sys_course_path.$_course['path'].'/document'.$folder.'.thumbs/'; |
| 179 | 179 | |
| 180 | 180 | //Other parameters only for show tumbnails |
| 181 | - $row_items = 4;//only in slideshow.php |
|
| 182 | - $number_image = 7;//num icons cols to show |
|
| 183 | - $thumbnail_width_frame = $max_thumbnail_width;//optional $max_thumbnail_width+x |
|
| 181 | + $row_items = 4; //only in slideshow.php |
|
| 182 | + $number_image = 7; //num icons cols to show |
|
| 183 | + $thumbnail_width_frame = $max_thumbnail_width; //optional $max_thumbnail_width+x |
|
| 184 | 184 | $thumbnail_height_frame = $max_thumbnail_height; |
| 185 | 185 | |
| 186 | 186 | // Create the template_thumbnails folder (if no exist) |
@@ -194,20 +194,20 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | foreach ($image_files_only as $one_image_file) { |
| 196 | 196 | $image = $sys_course_path.$_course['path'].'/document'.$folder.$one_image_file; |
| 197 | - $image_thumbnail= $directory_thumbnails.'.'.$one_image_file; |
|
| 197 | + $image_thumbnail = $directory_thumbnails.'.'.$one_image_file; |
|
| 198 | 198 | |
| 199 | 199 | if (file_exists($image)) { |
| 200 | 200 | //check thumbnail |
| 201 | 201 | $imagetype = explode(".", $image); |
| 202 | 202 | //or check $imagetype = image_type_to_extension(exif_imagetype($image), false); |
| 203 | - $imagetype = strtolower($imagetype[count($imagetype)-1]); |
|
| 203 | + $imagetype = strtolower($imagetype[count($imagetype) - 1]); |
|
| 204 | 204 | |
| 205 | - if(in_array($imagetype,$allowed_thumbnail_types)) { |
|
| 206 | - if (!file_exists($image_thumbnail)){ |
|
| 205 | + if (in_array($imagetype, $allowed_thumbnail_types)) { |
|
| 206 | + if (!file_exists($image_thumbnail)) { |
|
| 207 | 207 | //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 |
| 208 | 208 | $original_image_size = api_getimagesize($image); |
| 209 | 209 | |
| 210 | - switch($imagetype) { |
|
| 210 | + switch ($imagetype) { |
|
| 211 | 211 | case 'gif': |
| 212 | 212 | $source_img = imagecreatefromgif($image); |
| 213 | 213 | break; |
@@ -228,17 +228,17 @@ discard block |
||
| 228 | 228 | $max_thumbnail_width, |
| 229 | 229 | $max_thumbnail_height |
| 230 | 230 | ); |
| 231 | - if($max_thumbnail_width>$original_image_size['width'] && $max_thumbnail_height>$original_image_size['height']){ |
|
| 232 | - $new_thumbnail_size['width']=$original_image_size['width']; |
|
| 233 | - $new_thumbnail_size['height']=$original_image_size['height']; |
|
| 231 | + if ($max_thumbnail_width > $original_image_size['width'] && $max_thumbnail_height > $original_image_size['height']) { |
|
| 232 | + $new_thumbnail_size['width'] = $original_image_size['width']; |
|
| 233 | + $new_thumbnail_size['height'] = $original_image_size['height']; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | $crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']); |
| 237 | 237 | |
| 238 | 238 | // preserve transparency |
| 239 | - if($imagetype == "png"){ |
|
| 239 | + if ($imagetype == "png") { |
|
| 240 | 240 | imagesavealpha($crop, true); |
| 241 | - $color = imagecolorallocatealpha($crop,0x00,0x00,0x00,127); |
|
| 241 | + $color = imagecolorallocatealpha($crop, 0x00, 0x00, 0x00, 127); |
|
| 242 | 242 | imagefill($crop, 0, 0, $color); |
| 243 | 243 | } |
| 244 | 244 | |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | $transindex = imagecolortransparent($source_img); |
| 247 | 247 | $palletsize = imagecolorstotal($source_img); |
| 248 | 248 | //GIF89a for transparent and anim (first clip), either GIF87a |
| 249 | - if ($transindex >= 0 && $transindex < $palletsize){ |
|
| 249 | + if ($transindex >= 0 && $transindex < $palletsize) { |
|
| 250 | 250 | $transcol = imagecolorsforindex($source_img, $transindex); |
| 251 | 251 | $transindex = imagecolorallocatealpha($crop, $transcol['red'], $transcol['green'], $transcol['blue'], 127); |
| 252 | 252 | imagefill($crop, 0, 0, $transindex); |
@@ -270,16 +270,16 @@ discard block |
||
| 270 | 270 | |
| 271 | 271 | switch ($imagetype) { |
| 272 | 272 | case 'gif': |
| 273 | - imagegif($crop,$image_thumbnail); |
|
| 273 | + imagegif($crop, $image_thumbnail); |
|
| 274 | 274 | break; |
| 275 | 275 | case 'jpg': |
| 276 | - imagejpeg($crop,$image_thumbnail,$jpg_quality); |
|
| 276 | + imagejpeg($crop, $image_thumbnail, $jpg_quality); |
|
| 277 | 277 | break; |
| 278 | 278 | case 'jpeg': |
| 279 | - imagejpeg($crop,$image_thumbnail,$jpg_quality); |
|
| 279 | + imagejpeg($crop, $image_thumbnail, $jpg_quality); |
|
| 280 | 280 | break; |
| 281 | 281 | case 'png': |
| 282 | - imagepng($crop,$image_thumbnail,$png_compression); |
|
| 282 | + imagepng($crop, $image_thumbnail, $png_compression); |
|
| 283 | 283 | break; |
| 284 | 284 | } |
| 285 | 285 | |
@@ -289,26 +289,26 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | //show thumbnail and link |
| 291 | 291 | |
| 292 | - $one_image_thumbnail_file='.thumbs/.'.$one_image_file;//get path thumbnail |
|
| 292 | + $one_image_thumbnail_file = '.thumbs/.'.$one_image_file; //get path thumbnail |
|
| 293 | 293 | $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file; |
| 294 | 294 | $image_tag[] = '<img class="img-gallery" src="download.php?doc_url='.$doc_url.'" border="0" title="'.$one_image_file.'">'; |
| 295 | 295 | } else { |
| 296 | 296 | //if images aren't support by gd (not gif, jpg, jpeg, png) |
| 297 | - if ($imagetype=="bmp") { |
|
| 297 | + if ($imagetype == "bmp") { |
|
| 298 | 298 | // use getimagesize instead api_getimagesize($image); becasuse api_getimagesize doesn't support bmp files. Put here for each show, only for a few bmp files isn't heavy |
| 299 | 299 | $original_image_size = getimagesize($image); |
| 300 | - if ($max_thumbnail_width<$original_image_size[0] || $max_thumbnail_height<$original_image_size[1]){ |
|
| 301 | - $thumbnail_size=api_calculate_image_size($original_image_size[0], $original_image_size[1], $max_thumbnail_width, $max_thumbnail_height);//don't use resize_image because doesn't run with bmp files |
|
| 300 | + if ($max_thumbnail_width < $original_image_size[0] || $max_thumbnail_height < $original_image_size[1]) { |
|
| 301 | + $thumbnail_size = api_calculate_image_size($original_image_size[0], $original_image_size[1], $max_thumbnail_width, $max_thumbnail_height); //don't use resize_image because doesn't run with bmp files |
|
| 302 | 302 | $image_height = $thumbnail_size['height']; |
| 303 | 303 | $image_width = $thumbnail_size['width']; |
| 304 | 304 | } else { |
| 305 | - $image_height=$original_image_size[0]; |
|
| 306 | - $image_width=$original_image_size[1]; |
|
| 305 | + $image_height = $original_image_size[0]; |
|
| 306 | + $image_width = $original_image_size[1]; |
|
| 307 | 307 | } |
| 308 | 308 | } else { |
| 309 | 309 | //example for svg files,... |
| 310 | - $image_width=$max_thumbnail_width; |
|
| 311 | - $image_height=$max_thumbnail_height; |
|
| 310 | + $image_width = $max_thumbnail_width; |
|
| 311 | + $image_height = $max_thumbnail_height; |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | $doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_file : $path.$one_image_file; |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | |
| 325 | 325 | $i = 0; |
| 326 | 326 | $count_image = count($image_tag); |
| 327 | - $number_iteration = ceil($count_image/$number_image); |
|
| 327 | + $number_iteration = ceil($count_image / $number_image); |
|
| 328 | 328 | $p = 0; |
| 329 | 329 | $html = ''; |
| 330 | 330 | $html .= '<div class="gallery">'; |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | $html .= '<a class="canvas-two" href="slideshow.php?slide_id='.$p.'&curdirpath='.$pathurl.'">'; |
| 337 | 337 | $html .= '<div class="frame">'; |
| 338 | 338 | $html .= '<div class="photo">'; |
| 339 | - $html .= $image_tag[$p]; |
|
| 339 | + $html .= $image_tag[$p]; |
|
| 340 | 340 | $html .= '</div>'; |
| 341 | 341 | $html .= '</div>'; |
| 342 | 342 | $html .= '</a>'; |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | |
| 394 | 394 | list($width, $height) = getimagesize($image); |
| 395 | 395 | // Auto resize |
| 396 | - if (isset($_SESSION["image_resizing"]) && $_SESSION["image_resizing"] == 'resizing') { |
|
| 396 | + if (isset($_SESSION["image_resizing"]) && $_SESSION["image_resizing"] == 'resizing') { |
|
| 397 | 397 | ?> |
| 398 | 398 | |
| 399 | 399 | <script type="text/javascript"> |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | start_height=initial_height; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - document.write('<img id="image" src="<?php echo 'download.php?doc_url='.$path.'/'.$image_files_only[$slide]; ?>" width="'+start_width+'" height="'+start_height+'" border="0" alt="<?php echo $image_files_only[$slide] ;?>">'); |
|
| 413 | + document.write('<img id="image" src="<?php echo 'download.php?doc_url='.$path.'/'.$image_files_only[$slide]; ?>" width="'+start_width+'" height="'+start_height+'" border="0" alt="<?php echo $image_files_only[$slide]; ?>">'); |
|
| 414 | 414 | |
| 415 | 415 | function resizeImage() { |
| 416 | 416 | |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | $resize_info = get_lang('Resizing').'<br />'; |
| 477 | 477 | $resize_width = $_SESSION["image_resizing_width"].' x '; |
| 478 | 478 | $resize_height = $_SESSION['image_resizing_height']; |
| 479 | - } elseif (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] != 'noresizing'){ |
|
| 479 | + } elseif (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] != 'noresizing') { |
|
| 480 | 480 | $resize_info = get_lang('Resizing').'<br />'; |
| 481 | 481 | $resize_width = get_lang('Auto').' x '; |
| 482 | 482 | $resize_height = get_lang('Auto'); |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | |
| 494 | 494 | echo $image_files_only[$slide].' <br />'; |
| 495 | 495 | echo $width.' x '.$height.' <br />'; |
| 496 | - echo round((filesize($image)/1024), 2).' KB'; |
|
| 496 | + echo round((filesize($image) / 1024), 2).' KB'; |
|
| 497 | 497 | echo ' - '.$ext; |
| 498 | 498 | echo '</td>'; |
| 499 | 499 | echo '</tr>'; |