Passed
Push — 1.10.x ( 849f97...a21c08 )
by Angel Fernando Quiroz
47:19
created
main/document/slideshow.php 1 patch
Spacing   +48 added lines, -48 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
 
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 	$max_thumbnail_width     = 250;
175 175
 	$max_thumbnail_height    = 250;
176 176
 	$png_compression	     = 0; // 0(none)-9
177
-	$jpg_quality  	         = 75; // from 0 to 100 (default is 75). More quality less compression
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
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 185
 	$thumbnail_height_frame = $max_thumbnail_height;
186 186
 
187 187
 	// Create the template_thumbnails folder (if no exist)
@@ -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;
@@ -229,17 +229,17 @@  discard block
 block discarded – undo
229 229
                             $max_thumbnail_width,
230 230
                             $max_thumbnail_height
231 231
                         );
232
-						if ($max_thumbnail_width>$original_image_size['width'] && $max_thumbnail_height>$original_image_size['height']){
233
-							$new_thumbnail_size['width']=$original_image_size['width'];
234
-							$new_thumbnail_size['height']=$original_image_size['height'];
232
+						if ($max_thumbnail_width > $original_image_size['width'] && $max_thumbnail_height > $original_image_size['height']) {
233
+							$new_thumbnail_size['width'] = $original_image_size['width'];
234
+							$new_thumbnail_size['height'] = $original_image_size['height'];
235 235
 						}
236 236
 
237 237
 						$crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']);
238 238
 
239 239
 						// preserve transparency
240
-						if ($imagetype == "png"){
240
+						if ($imagetype == "png") {
241 241
 							imagesavealpha($crop, true);
242
-							$color = imagecolorallocatealpha($crop,0x00,0x00,0x00,127);
242
+							$color = imagecolorallocatealpha($crop, 0x00, 0x00, 0x00, 127);
243 243
 							imagefill($crop, 0, 0, $color);
244 244
 						}
245 245
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 							$transindex = imagecolortransparent($source_img);
248 248
                             $palletsize = imagecolorstotal($source_img);
249 249
 							 //GIF89a for transparent and anim (first clip), either GIF87a
250
-							 if ($transindex >= 0 && $transindex < $palletsize){
250
+							 if ($transindex >= 0 && $transindex < $palletsize) {
251 251
 								 $transcol = imagecolorsforindex($source_img, $transindex);
252 252
 								 $transindex = imagecolorallocatealpha($crop, $transcol['red'], $transcol['green'], $transcol['blue'], 127);
253 253
 								 imagefill($crop, 0, 0, $transindex);
@@ -271,16 +271,16 @@  discard block
 block discarded – undo
271 271
 
272 272
 						switch ($imagetype) {
273 273
 							case 'gif':
274
-								imagegif($crop,$image_thumbnail);
274
+								imagegif($crop, $image_thumbnail);
275 275
 								break;
276 276
 							case 'jpg':
277
-								imagejpeg($crop,$image_thumbnail,$jpg_quality);
277
+								imagejpeg($crop, $image_thumbnail, $jpg_quality);
278 278
 								break;
279 279
 							case 'jpeg':
280
-								imagejpeg($crop,$image_thumbnail,$jpg_quality);
280
+								imagejpeg($crop, $image_thumbnail, $jpg_quality);
281 281
 								break;
282 282
 							case 'png':
283
-								imagepng($crop,$image_thumbnail,$png_compression);
283
+								imagepng($crop, $image_thumbnail, $png_compression);
284 284
 								break;
285 285
 						}
286 286
 
@@ -290,26 +290,26 @@  discard block
 block discarded – undo
290 290
 
291 291
 					//show thumbnail and link
292 292
 
293
-					$one_image_thumbnail_file='.thumbs/.'.$one_image_file;//get path thumbnail
293
+					$one_image_thumbnail_file = '.thumbs/.'.$one_image_file; //get path thumbnail
294 294
 					$doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file;
295 295
 					$image_tag[] = '<img class="img-gallery" src="download.php?doc_url='.$doc_url.'" border="0" title="'.$one_image_file.'">';
296 296
 				} else {
297 297
 					//if images aren't support by gd (not gif, jpg, jpeg, png)
298
-					if ($imagetype=="bmp") {
298
+					if ($imagetype == "bmp") {
299 299
                         // 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
300 300
 						$original_image_size = getimagesize($image);
301
-						if ($max_thumbnail_width<$original_image_size[0] || $max_thumbnail_height<$original_image_size[1]){
302
-							$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
301
+						if ($max_thumbnail_width < $original_image_size[0] || $max_thumbnail_height < $original_image_size[1]) {
302
+							$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
303 303
 							$image_height = $thumbnail_size['height'];
304 304
 							$image_width  = $thumbnail_size['width'];
305 305
 						} else {
306
-							$image_height=$original_image_size[0];
307
-							$image_width=$original_image_size[1];
306
+							$image_height = $original_image_size[0];
307
+							$image_width = $original_image_size[1];
308 308
 						}
309 309
 					} else {
310 310
 						//example for svg files,...
311
-						$image_width=$max_thumbnail_width;
312
-						$image_height=$max_thumbnail_height;
311
+						$image_width = $max_thumbnail_width;
312
+						$image_height = $max_thumbnail_height;
313 313
 					}
314 314
 
315 315
 					$doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_file : $path.$one_image_file;
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 
326 326
 	$i = 0;
327 327
 	$count_image = count($image_tag);
328
-	$number_iteration = ceil($count_image/$number_image);
328
+	$number_iteration = ceil($count_image / $number_image);
329 329
 	$p = 0;
330 330
     $html = '';
331 331
     $html .= '<div class="gallery">';
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
                             $html .= '<a class="canvas-two" href="slideshow.php?slide_id='.$p.'&curdirpath='.$pathurl.'">';
338 338
                             $html .= '<div class="frame">';
339 339
                             $html .= '<div class="photo">';
340
-                            $html .=  $image_tag[$p];
340
+                            $html .= $image_tag[$p];
341 341
                             $html .= '</div>';
342 342
                             $html .= '</div>';
343 343
                             $html .= '</a>';
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 
393 393
 		list($width, $height) = getimagesize($image);
394 394
 		// Auto resize
395
-		if (isset($_SESSION["image_resizing"]) &&  $_SESSION["image_resizing"] == 'resizing') {
395
+		if (isset($_SESSION["image_resizing"]) && $_SESSION["image_resizing"] == 'resizing') {
396 396
 		?>
397 397
 
398 398
 		<script type="text/javascript">
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 				start_height=initial_height;
410 410
 			}
411 411
 
412
-			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] ;?>">');
412
+			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 413
 
414 414
 			function resizeImage() {
415 415
 
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 		echo '</a>';
454 454
         echo '<div class="caption text-center">';
455 455
         echo Display::tag('h3', $row['title']);
456
-        echo '<p>' . $row['comment'] . '</p>';
456
+        echo '<p>'.$row['comment'].'</p>';
457 457
         echo '</div>';
458 458
         echo '</div>';
459 459
 
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
                 $resize_info = get_lang('Resizing').'<br />';
467 467
                 $resize_width = $_SESSION["image_resizing_width"].' x ';
468 468
                 $resize_height = $_SESSION['image_resizing_height'];
469
-            } elseif (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] != 'noresizing'){
469
+            } elseif (isset($_SESSION['image_resizing']) && $_SESSION['image_resizing'] != 'noresizing') {
470 470
                 $resize_info = get_lang('Resizing').'<br />';
471 471
                 $resize_width = get_lang('Auto').' x ';
472 472
                 $resize_height = get_lang('Auto');
@@ -477,10 +477,10 @@  discard block
 block discarded – undo
477 477
             }
478 478
 
479 479
             echo '<li class="text-center">';
480
-            echo $image_files_only[$slide] . ' ';
480
+            echo $image_files_only[$slide].' ';
481 481
             echo Display::toolbarButton(
482 482
                 get_lang('Modify'),
483
-                'edit_document.php?' . api_get_cidreq() . '&' . http_build_query([
483
+                'edit_document.php?'.api_get_cidreq().'&'.http_build_query([
484 484
                     'id' => $row['id'],
485 485
                     'origin' => 'slideshow',
486 486
                     'origin_opt' => $edit_slide_id,
@@ -492,11 +492,11 @@  discard block
 block discarded – undo
492 492
                 false
493 493
             );
494 494
             echo '</li>';
495
-            echo '<li class="text-center">' . $width.' x '.$height . '</li>';
496
-			echo '<li class="text-center">' . round((filesize($image) / 1024), 2) . ' KB - ' . $ext . '</li>';
497
-            echo '<li class="text-center">' . $resize_info . '</li>';
498
-			echo '<li class="text-center">' . $resize_width . '</li>';
499
-			echo '<li class="text-center">' . $resize_height . '</li>';
495
+            echo '<li class="text-center">'.$width.' x '.$height.'</li>';
496
+			echo '<li class="text-center">'.round((filesize($image) / 1024), 2).' KB - '.$ext.'</li>';
497
+            echo '<li class="text-center">'.$resize_info.'</li>';
498
+			echo '<li class="text-center">'.$resize_width.'</li>';
499
+			echo '<li class="text-center">'.$resize_height.'</li>';
500 500
             echo '</ul>';
501 501
 		}
502 502
 
Please login to merge, or discard this patch.