slideshow.inc.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @author Patrick Cool
  5. * @package ghamilo.document
  6. * @todo convert comments to be understandable to phpDocumentor
  7. */
  8. /*
  9. Developped by Patrick Cool
  10. patrick.cool@UGent.be
  11. Ghent University
  12. Mai 2004
  13. http://icto.UGent.be
  14. Please bear in mind that this is only an alpha release.
  15. I wrote this quite quick and didn't think too much about it in advance.
  16. It is not perfect at all but it is workable and usefull (I think)
  17. Do not consider this as a powerpoint replacement, although it has
  18. the same starting point.
  19. */
  20. /*
  21. Description:
  22. This is a plugin for the documents tool. It looks for .jpg, .jpeg, .gif, .png
  23. files (since these are the files that can be viewed in a browser) and creates
  24. a slideshow with it by allowing to go to the next/previous image.
  25. You can also have a quick overview (thumbnail view) of all the images in
  26. that particular folder.
  27. Maybe it is important to notice that each slideshow is folder based. Only
  28. the images of the chosen folder are shown.
  29. This file has two large sections.
  30. 1. code that belongs in document.php, but to avoid clutter I put the code here
  31. 2. the function resize_image that handles the image resizing
  32. */
  33. /**
  34. * This function calculates the resized width and resized heigt according to the source and target widths
  35. * and heights, height so that no distortions occur
  36. * parameters
  37. * $image = the absolute path to the image
  38. * $target_width = how large do you want your resized image
  39. * $target_height = how large do you want your resized image
  40. * $slideshow (default=0) = indicates weither we are generating images for a slideshow or not, t
  41. * this overrides the $_SESSION["image_resizing"] a bit so that a thumbnail
  42. * view is also possible when you choose not to resize the source images
  43. */
  44. function resize_image($image, $target_width, $target_height, $slideshow = 0) {
  45. // Modifications by Ivan Tcholakov, 04-MAY-2009.
  46. $result = array();
  47. if ($_SESSION['image_resizing'] == 'resizing' or $slideshow == 1) {
  48. $new_sizes = api_resize_image($image, $target_width, $target_height);
  49. $result[] = $new_sizes['height'];
  50. $result[] = $new_sizes['width'];
  51. } else {
  52. $result[] = $image_height;
  53. $result[] = $image_width;
  54. }
  55. return $result;
  56. }