slideshow.php 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <?php
  2. // $Id: slideshow.php 11766 2007-03-29 08:39:27Z elixir_julian $
  3. /*
  4. ==============================================================================
  5. Dokeos - elearning and course management software
  6. Copyright (c) 2004 Dokeos S.A.
  7. Copyright (c) 2003 Ghent University (UGent)
  8. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * @author Patrick Cool
  22. * @package dokeos.document
  23. ==============================================================================
  24. */
  25. /*
  26. ==============================================================================
  27. Developped by Patrick Cool
  28. patrick.cool@UGent.be
  29. Ghent University
  30. Mai 2004
  31. http://icto.UGent.be
  32. Please bear in mind that this is only an alpha release.
  33. I wrote this quite quick and didn't think too much about it in advance.
  34. It is not perfect at all but it is workable and usefull (I think)
  35. Do not consider this as a powerpoint replacement, although it has
  36. the same starting point.
  37. ==============================================================================
  38. */
  39. /*
  40. ==============================================================================
  41. Description:
  42. This is a plugin for the documents tool. It looks for .jpg, .jpeg, .gif, .png
  43. files (since these are the files that can be viewed in a browser) and creates
  44. a slideshow with it by allowing to go to the next/previous image.
  45. You can also have a quick overview (thumbnail view) of all the images in
  46. that particular folder.
  47. Each slideshow is folder based. Only the images of the chosen folder are shown.
  48. ==============================================================================
  49. */
  50. // including the language file
  51. // name of the language file that needs to be included
  52. $language_file = "slideshow";
  53. include ('../inc/global.inc.php');
  54. $noPHP_SELF = true;
  55. $path = $_GET['curdirpath'];
  56. $pathurl = urlencode($path);
  57. $slide_id = $_GET['slide_id'];
  58. if ($path and $path <> "")
  59. {
  60. $folder = $path."/";
  61. }
  62. else
  63. {
  64. $folder = "";
  65. }
  66. $sys_course_path = api_get_path(SYS_COURSE_PATH);
  67. // including the functions for the slideshow
  68. include ('slideshow.inc.php');
  69. // breadcrumb navigation
  70. $url = "document.php?curdirpath=".$pathurl;
  71. $originaltoolname = get_lang('Documents');
  72. $interbreadcrumb[] = array ("url" => $url, "name" => $originaltoolname);
  73. // because $nametools uses $_SERVER['PHP_SELF'] for the breadcrumbs instead of $_SERVER['REQUEST_URI'], I had to
  74. // bypass the $nametools thing and use <b></b> tags in the $interbreadcrump array
  75. $url = "slideshow.php?curdirpath=".$pathurl;
  76. $originaltoolname = get_lang('SlideShow');
  77. //$interbreadcrumb[]= array ("url"=>$url, "name"=>$originaltoolname );
  78. Display :: display_header($originaltoolname, "Doc");
  79. // loading the slides from the session
  80. $image_files_only = $_SESSION["image_files_only"];
  81. // calculating the current slide, next slide, previous slide and the number of slides
  82. if ($slide_id <> "all")
  83. {
  84. if ($slide_id)
  85. {
  86. $slide = $slide_id;
  87. }
  88. else
  89. {
  90. $slide = 0;
  91. }
  92. $previous_slide = $slide -1;
  93. $next_slide = $slide +1;
  94. } // if ($slide_id<>"all")
  95. $total_slides = count($image_files_only);
  96. ?>
  97. <script language="JavaScript" type="text/JavaScript">
  98. <!--
  99. function MM_openBrWindow(theURL,winName,features) { //v2.0
  100. window.open(theURL,winName,features);
  101. }
  102. //-->
  103. </script>
  104. <p></p>
  105. <h3 style="margin-top: 0; margin-bottom: 0"><?php echo get_lang('SlideShow'); ?></h3>
  106. <table width="100%" border="0" cellspacing="0" cellpadding="2">
  107. <tr>
  108. <td>
  109. <?php
  110. if ($slide > 0)
  111. {
  112. echo "<a href='slideshow.php?slide_id=".$previous_slide."&curdirpath=$pathurl'>";
  113. }
  114. ?>
  115. <strong>&lt;&lt; <?php echo get_lang('_previous_slide'); ?></strong> <?php
  116. if ($slide > 0)
  117. {
  118. echo "</a>";
  119. }
  120. ?>
  121. &nbsp;|&nbsp;
  122. <?php
  123. if ($slide < $total_slides -1 and $slide_id <> "all")
  124. {
  125. echo "<a href='slideshow.php?slide_id=".$next_slide."&curdirpath=$pathurl'>";
  126. }
  127. ?>
  128. <strong><?php echo get_lang('_next_slide'); ?> &gt;&gt;</strong>
  129. <?php
  130. if ($slide > 0)
  131. {
  132. echo "</a>";
  133. }
  134. ?>
  135. </td>
  136. <td>
  137. <?php
  138. if ($slide_id <> "all")
  139. {
  140. echo get_lang('_image')." ".$next_slide." ".get_lang('_of')." ".$total_slides;
  141. }
  142. ?>
  143. </td>
  144. <td align="right"><a href="document.php?action=exit_slideshow&curdirpath=<?php echo $pathurl;?>"><?php echo get_lang('_exit_slideshow');?></a> </td>
  145. </tr>
  146. <tr>
  147. <td>
  148. <?php
  149. if ($slide_id <> "all")
  150. {
  151. echo "<a href='slideshow.php?slide_id=all&curdirpath=".$pathurl."'>".get_lang('_show_thumbnails')."</a>";
  152. }
  153. else
  154. {
  155. echo get_lang('_click_thumbnails');
  156. }
  157. $image = $sys_course_path.$_course['path']."/document/".$folder.$image_files_only[$slide];
  158. // EXIF DATA, remove "and 0==1" in the if statement if you want to display the EXIT data in a popup
  159. //if (exif_read_data($image))
  160. // {
  161. // $_SESSION["exif_image"]=$image;
  162. //
  163. // echo "| <a href='#' onClick='MM_openBrWindow('exifinfo.php?image=".$slide."&amp;path=".$path."','exifinfo','scrollbars=yes,resizable=yes,width=500,height=400')'>Show Exif metadata</a>";
  164. // }
  165. ?>
  166. </td>
  167. <td><?php echo htmlspecialchars($image_files_only[$slide]) ?></td>
  168. <td align="right"><a href="slideshowoptions.php?curdirpath=<?php echo $pathurl; ?>"><?php echo get_lang('_set_slideshow_options');?></a></td>
  169. </tr>
  170. </table>
  171. <?php
  172. // =======================================================================
  173. // TREATING THE POST DATA FROM SLIDESHOW OPTIONS
  174. // =======================================================================
  175. // if we come from slideshowoptions.php we sessionize (new word !!! ;-) the options
  176. if (isset ($_POST['Submit'])) // we come from slideshowoptions.php
  177. {
  178. $_SESSION["image_resizing"] = $_POST['radio_resizing'];
  179. if ($_POST['radio_resizing'] == "resizing" && $_POST['width'] != '' && $_POST['height'] != '')
  180. {
  181. //echo "resizing";
  182. $_SESSION["image_resizing_width"] = $_POST['width'];
  183. $_SESSION["image_resizing_height"] = $_POST['height'];
  184. }
  185. else
  186. {
  187. //echo "unsetting the session heighte and width";
  188. $_SESSION["image_resizing_width"] = null;
  189. $_SESSION["image_resizing_height"] = null;
  190. }
  191. } // if ($submit)
  192. // The target height and width depends if we choose resizing or no resizing
  193. if ($_SESSION["image_resizing"] == "resizing")
  194. {
  195. $target_width = $_SESSION["image_resizing_width"];
  196. $target_height = $_SESSION["image_resizing_height"];
  197. }
  198. else
  199. {
  200. $image_width = $source_width;
  201. $image_height = $source_height;
  202. }
  203. // =======================================================================
  204. // THUMBNAIL VIEW
  205. // =======================================================================
  206. // this is for viewing all the images in the slideshow as thumbnails.
  207. $image_tag = array ();
  208. if ($slide_id == "all")
  209. {
  210. $thumbnail_width = 100;
  211. $thumbnail_height = 100;
  212. $row_items = 4;
  213. foreach ($image_files_only as $one_image_file)
  214. {
  215. $image = $sys_course_path.$_course['path']."/document/".$folder.$one_image_file;
  216. $image_height_width = resize_image($image, $thumbnail_width, $thumbnail_height, 1);
  217. $image_height = $image_height_width[0];
  218. $image_width = $image_height_width[1];
  219. if ($path and $path !== "/")
  220. {
  221. $doc_url = $path."/".$one_image_file;
  222. }
  223. else
  224. {
  225. $doc_url = $path.$one_image_file;
  226. }
  227. $image_tag[] = "<img src='download.php?doc_url=".$doc_url."' border='0' width='".$image_width."' height='".$image_height."'>";
  228. } // foreach ($image_files_only as $one_image_file)
  229. } // if ($slide_id=="all")
  230. // creating the table
  231. echo "\n<table align='center'>";
  232. $i = 0;
  233. foreach ($image_tag as $image_tag_item)
  234. {
  235. // starting new table row
  236. if ($i == 0)
  237. {
  238. echo "\n<tr>\n";
  239. }
  240. echo "\t<td><a href='slideshow.php?slide_id=".$i."&curdirpath=".$pathurl."'>".$image_tag_item."</a></td>\n";
  241. if ($i % 3 == 0 and $i !== 0)
  242. {
  243. echo "</tr>\n<tr>\n";
  244. }
  245. $i ++;
  246. }
  247. echo "</table>\n\n";
  248. // =======================================================================
  249. // ONE AT A TIME VIEW
  250. // =======================================================================
  251. // this is for viewing all the images in the slideshow one at a time.
  252. if ($slide_id !== "all")
  253. {
  254. $image = $sys_course_path.$_course['path']."/document/".$folder.$image_files_only[$slide];
  255. $image_height_width = resize_image($image, $target_width, $target_height);
  256. $image_height = $image_height_width[0];
  257. $image_width = $image_height_width[1];
  258. if ($_SESSION["image_resizing"] == "resizing")
  259. {
  260. $height_width_tags = "width='$image_width' height='$image_height'";
  261. }
  262. // showing the comment of the image, Patrick Cool, 8 april 2005
  263. // this is done really quickly and should be cleaned up a little bit using the API functions
  264. $tbl_documents = Database::get_course_table(TABLE_DOCUMENT);
  265. if ($path=='/')
  266. {
  267. $pathpart='/';
  268. }
  269. else
  270. {
  271. $pathpart=$path.'/';
  272. }
  273. $sql = "SELECT * FROM $tbl_documents WHERE path='".$pathpart.$image_files_only[$slide]."'";
  274. $result = api_sql_query($sql,__FILE__,__LINE__);
  275. $row = mysql_fetch_array($result);
  276. echo $row['comment'];
  277. echo "<center><img src='download.php?doc_url=$path/".$image_files_only[$slide]."' border='0' $height_width_tags></center>";
  278. } // if ($slide_id!=="all")
  279. Display :: display_footer();
  280. ?>