Test Setup Failed
Push — master ( 10eb12...0c385b )
by Angel Fernando Quiroz
213:59 queued 150:07
created
main/document/slideshow.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
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">';
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
             $last = Display::return_icon('action_last_na.png', get_lang('LastSlide'));
106 106
 		} else {
107 107
 			$imgn = 'action_next.png';
108
-			$last = '<a href="slideshow.php?slide_id='.($total_slides-1).'&curdirpath='.$pathurl.'">
108
+			$last = '<a href="slideshow.php?slide_id='.($total_slides - 1).'&curdirpath='.$pathurl.'">
109 109
 			        '.Display::return_icon('action_last.png', get_lang('LastSlide')).'
110 110
                 </a>';
111 111
 		}
@@ -122,18 +122,18 @@  discard block
 block discarded – undo
122 122
 
123 123
 // Exit the slideshow
124 124
 echo '<a href="document.php?action=exit_slideshow&curdirpath='.$pathurl.'&'.api_get_cidreq().'">'.
125
-    Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
125
+    Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
126 126
 
127 127
 // Show thumbnails
128 128
 if ($slide_id != 'all') {
129 129
 	echo '<a href="slideshow.php?slide_id=all&curdirpath='.$pathurl.'&'.api_get_cidreq().'">'.
130
-        Display::return_icon('thumbnails.png',get_lang('ShowThumbnails'),'',ICON_SIZE_MEDIUM).'</a>';
130
+        Display::return_icon('thumbnails.png', get_lang('ShowThumbnails'), '', ICON_SIZE_MEDIUM).'</a>';
131 131
 } else {
132
-	echo Display::return_icon('thumbnails_na.png',get_lang('ShowThumbnails'),'',ICON_SIZE_MEDIUM);
132
+	echo Display::return_icon('thumbnails_na.png', get_lang('ShowThumbnails'), '', ICON_SIZE_MEDIUM);
133 133
 }
134 134
 // Slideshow options
135 135
 echo '<a href="slideshowoptions.php?curdirpath='.$pathurl.'&'.api_get_cidreq().'">'.
136
-    Display::return_icon('settings.png', get_lang('SetSlideshowOptions'),'',ICON_SIZE_MEDIUM).'</a>';
136
+    Display::return_icon('settings.png', get_lang('SetSlideshowOptions'), '', ICON_SIZE_MEDIUM).'</a>';
137 137
 
138 138
 echo '</div>';
139 139
 echo '<br />';
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 }
158 158
 $target_width = $target_height = null;
159 159
 // The target height and width depends if we choose resizing or no resizing
160
-if (isset($_SESSION["image_resizing"]) &&  $_SESSION["image_resizing"] == "resizing") {
160
+if (isset($_SESSION["image_resizing"]) && $_SESSION["image_resizing"] == "resizing") {
161 161
 	$target_width = $_SESSION["image_resizing_width"];
162 162
 	$target_height = $_SESSION["image_resizing_height"];
163 163
 }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 /*	THUMBNAIL VIEW */
166 166
 
167 167
 // This is for viewing all the images in the slideshow as thumbnails.
168
-$image_tag = array ();
168
+$image_tag = array();
169 169
 $html = '';
170 170
 if ($slide_id == 'all') {
171 171
 
@@ -173,16 +173,16 @@  discard block
 block discarded – undo
173 173
     $allowed_thumbnail_types = array('jpg', 'jpeg', 'gif', 'png');
174 174
 	$max_thumbnail_width     = 250;
175 175
 	$max_thumbnail_height    = 250;
176
-	$png_compression	     = 0;//0(none)-9
177
-	$jpg_quality  	         = 75;//from 0 to 100 (default is 75). More quality less compression
176
+	$png_compression	     = 0; //0(none)-9
177
+	$jpg_quality = 75; //from 0 to 100 (default is 75). More quality less compression
178 178
 
179 179
 	$directory_thumbnails = $sys_course_path.$_course['path'].'/document'.$folder.'.thumbs/';
180 180
 
181 181
 	//Other parameters only for show tumbnails
182
-	$row_items 			     = 4;//only in slideshow.php
183
-	$number_image 			 = 7;//num icons cols to show
184
-	$thumbnail_width_frame=$max_thumbnail_width;//optional $max_thumbnail_width+x
185
-	$thumbnail_height_frame=$max_thumbnail_height;
182
+	$row_items = 4; //only in slideshow.php
183
+	$number_image = 7; //num icons cols to show
184
+	$thumbnail_width_frame = $max_thumbnail_width; //optional $max_thumbnail_width+x
185
+	$thumbnail_height_frame = $max_thumbnail_height;
186 186
 
187 187
 	// Create the template_thumbnails folder (if no exist)
188 188
 
@@ -195,20 +195,20 @@  discard block
 block discarded – undo
195 195
 
196 196
 		foreach ($image_files_only as $one_image_file) {
197 197
 			$image = $sys_course_path.$_course['path'].'/document'.$folder.$one_image_file;
198
-			$image_thumbnail= $directory_thumbnails.'.'.$one_image_file;
198
+			$image_thumbnail = $directory_thumbnails.'.'.$one_image_file;
199 199
 
200 200
 			if (file_exists($image)) {
201 201
 				//check thumbnail
202 202
 				$imagetype = explode(".", $image);
203 203
                 //or check $imagetype = image_type_to_extension(exif_imagetype($image), false);
204
-				$imagetype = strtolower($imagetype[count($imagetype)-1]);
204
+				$imagetype = strtolower($imagetype[count($imagetype) - 1]);
205 205
 
206
-				if(in_array($imagetype,$allowed_thumbnail_types)) {
207
-					if (!file_exists($image_thumbnail)){
206
+				if (in_array($imagetype, $allowed_thumbnail_types)) {
207
+					if (!file_exists($image_thumbnail)) {
208 208
                         //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
209 209
 						$original_image_size = api_getimagesize($image);
210 210
 
211
-						switch($imagetype) {
211
+						switch ($imagetype) {
212 212
 							case 'gif':
213 213
 								$source_img = imagecreatefromgif($image);
214 214
 								break;
@@ -230,17 +230,17 @@  discard block
 block discarded – undo
230 230
                             $max_thumbnail_height
231 231
                         );
232 232
 
233
-						if($max_thumbnail_width>$original_image_size['width'] && $max_thumbnail_height>$original_image_size['height']){
234
-							$new_thumbnail_size['width']=$original_image_size['width'];
235
-							$new_thumbnail_size['height']=$original_image_size['height'];
233
+						if ($max_thumbnail_width > $original_image_size['width'] && $max_thumbnail_height > $original_image_size['height']) {
234
+							$new_thumbnail_size['width'] = $original_image_size['width'];
235
+							$new_thumbnail_size['height'] = $original_image_size['height'];
236 236
 						}
237 237
 
238 238
 						$crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']);
239 239
 
240 240
 						// preserve transparency
241
-						if($imagetype == "png"){
241
+						if ($imagetype == "png") {
242 242
 							imagesavealpha($crop, true);
243
-							$color = imagecolorallocatealpha($crop,0x00,0x00,0x00,127);
243
+							$color = imagecolorallocatealpha($crop, 0x00, 0x00, 0x00, 127);
244 244
 							imagefill($crop, 0, 0, $color);
245 245
 						}
246 246
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 							$transindex = imagecolortransparent($source_img);
249 249
                             $palletsize = imagecolorstotal($source_img);
250 250
 							 //GIF89a for transparent and anim (first clip), either GIF87a
251
-							 if ($transindex >= 0 && $transindex < $palletsize){
251
+							 if ($transindex >= 0 && $transindex < $palletsize) {
252 252
 								 $transcol = imagecolorsforindex($source_img, $transindex);
253 253
 								 $transindex = imagecolorallocatealpha($crop, $transcol['red'], $transcol['green'], $transcol['blue'], 127);
254 254
 								 imagefill($crop, 0, 0, $transindex);
@@ -272,16 +272,16 @@  discard block
 block discarded – undo
272 272
 
273 273
 						switch ($imagetype) {
274 274
 							case 'gif':
275
-								imagegif($crop,$image_thumbnail);
275
+								imagegif($crop, $image_thumbnail);
276 276
 								break;
277 277
 							case 'jpg':
278
-								imagejpeg($crop,$image_thumbnail,$jpg_quality);
278
+								imagejpeg($crop, $image_thumbnail, $jpg_quality);
279 279
 								break;
280 280
 							case 'jpeg':
281
-								imagejpeg($crop,$image_thumbnail,$jpg_quality);
281
+								imagejpeg($crop, $image_thumbnail, $jpg_quality);
282 282
 								break;
283 283
 							case 'png':
284
-								imagepng($crop,$image_thumbnail,$png_compression);
284
+								imagepng($crop, $image_thumbnail, $png_compression);
285 285
 								break;
286 286
 						}
287 287
 
@@ -291,26 +291,26 @@  discard block
 block discarded – undo
291 291
 
292 292
 					//show thumbnail and link
293 293
 
294
-					$one_image_thumbnail_file='.thumbs/.'.$one_image_file;//get path thumbnail
294
+					$one_image_thumbnail_file = '.thumbs/.'.$one_image_file; //get path thumbnail
295 295
 					$doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file;
296 296
 					$image_tag[] = '<img class="img-gallery" src="download.php?doc_url='.$doc_url.'" border="0" title="'.$one_image_file.'">';
297 297
 				} else {
298 298
 					//if images aren't support by gd (not gif, jpg, jpeg, png)
299
-					if ($imagetype=="bmp") {
299
+					if ($imagetype == "bmp") {
300 300
                         // 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
301 301
 						$original_image_size = getimagesize($image);
302
-						if ($max_thumbnail_width<$original_image_size[0] || $max_thumbnail_height<$original_image_size[1]){
303
-							$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
+						if ($max_thumbnail_width < $original_image_size[0] || $max_thumbnail_height < $original_image_size[1]) {
303
+							$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
304 304
 							$image_height = $thumbnail_size['height'];
305 305
 							$image_width  = $thumbnail_size['width'];
306 306
 						} else {
307
-							$image_height=$original_image_size[0];
308
-							$image_width=$original_image_size[1];
307
+							$image_height = $original_image_size[0];
308
+							$image_width = $original_image_size[1];
309 309
 						}
310 310
 					} else {
311 311
 						//example for svg files,...
312
-						$image_width=$max_thumbnail_width;
313
-						$image_height=$max_thumbnail_height;
312
+						$image_width = $max_thumbnail_width;
313
+						$image_height = $max_thumbnail_height;
314 314
 					}
315 315
 
316 316
 					$doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_file : $path.$one_image_file;
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 
327 327
 	$i = 0;
328 328
 	$count_image = count($image_tag);
329
-	$number_iteration = ceil($count_image/$number_image);
329
+	$number_iteration = ceil($count_image / $number_image);
330 330
 	$p = 0;
331 331
     $html = '';
332 332
     $html .= '<div class="gallery">';
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
                             $html .= '<a class="canvas-two" href="slideshow.php?slide_id='.$p.'&curdirpath='.$pathurl.'">';
339 339
                             $html .= '<div class="frame">';
340 340
                             $html .= '<div class="photo">';
341
-                            $html .=  $image_tag[$p];
341
+                            $html .= $image_tag[$p];
342 342
                             $html .= '</div>';
343 343
                             $html .= '</div>';
344 344
                             $html .= '</a>';
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 		echo '</a>';
455 455
         echo '<div class="caption text-center">';
456 456
         echo Display::tag('h3', $row['title']);
457
-        echo '<p>' . $row['comment'] . '</p>';
457
+        echo '<p>'.$row['comment'].'</p>';
458 458
         echo '</div>';
459 459
         echo '</div>';
460 460
 
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
                 $resize_info = get_lang('Resizing').'<br />';
468 468
                 $resize_width = $_SESSION["image_resizing_width"].' x ';
469 469
                 $resize_height = $_SESSION['image_resizing_height'];
470
-            } elseif (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] != 'noresizing'){
470
+            } elseif (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] != 'noresizing') {
471 471
                 $resize_info = get_lang('Resizing').'<br />';
472 472
                 $resize_width = get_lang('Auto').' x ';
473 473
                 $resize_height = get_lang('Auto');
@@ -478,10 +478,10 @@  discard block
 block discarded – undo
478 478
             }
479 479
 
480 480
             echo '<li class="text-center">';
481
-            echo $image_files_only[$slide] . ' ';
481
+            echo $image_files_only[$slide].' ';
482 482
             echo Display::toolbarButton(
483 483
                 get_lang('Modify'),
484
-                'edit_document.php?' . api_get_cidreq() . '&' . http_build_query([
484
+                'edit_document.php?'.api_get_cidreq().'&'.http_build_query([
485 485
                     'id' => $row['id'],
486 486
                     'origin' => 'slideshow',
487 487
                     'origin_opt' => $edit_slide_id,
@@ -493,11 +493,11 @@  discard block
 block discarded – undo
493 493
                 false
494 494
             );
495 495
             echo '</li>';
496
-            echo '<li class="text-center">' . $width.' x '.$height . '</li>';
497
-			echo '<li class="text-center">' . round((filesize($image) / 1024), 2) . ' KB - ' . $ext . '</li>';
498
-            echo '<li class="text-center">' . $resize_info . '</li>';
499
-			echo '<li class="text-center">' . $resize_width . '</li>';
500
-			echo '<li class="text-center">' . $resize_height . '</li>';
496
+            echo '<li class="text-center">'.$width.' x '.$height.'</li>';
497
+			echo '<li class="text-center">'.round((filesize($image) / 1024), 2).' KB - '.$ext.'</li>';
498
+            echo '<li class="text-center">'.$resize_info.'</li>';
499
+			echo '<li class="text-center">'.$resize_width.'</li>';
500
+			echo '<li class="text-center">'.$resize_height.'</li>';
501 501
             echo '</ul>';
502 502
 		}
503 503
 
Please login to merge, or discard this patch.