slideshow.php 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <?php
  2. // $Id: slideshow.php 9246 2006-09-25 13:24:53Z bmol $
  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. $langFile = "slideshow";
  52. include ('../inc/global.inc.php');
  53. $noPHP_SELF = true;
  54. $path = $_GET['curdirpath'];
  55. $pathurl = urlencode($path);
  56. $slide_id = $_GET['slide_id'];
  57. if ($path and $path <> "")
  58. {
  59. $folder = $path."/";
  60. }
  61. else
  62. {
  63. $folder = "";
  64. }
  65. $sys_course_path = api_get_path(SYS_COURSE_PATH);
  66. // including the functions for the slideshow
  67. include ('slideshow.inc.php');
  68. // breadcrumb navigation
  69. $url = "document.php?curdirpath=".$pathurl;
  70. $originaltoolname = get_lang('Documents');
  71. $interbreadcrumb[] = array ("url" => $url, "name" => $originaltoolname);
  72. // because $nametools uses $_SERVER['PHP_SELF'] for the breadcrumbs instead of $_SERVER['REQUEST_URI'], I had to
  73. // bypass the $nametools thing and use <b></b> tags in the $interbreadcrump array
  74. $url = "slideshow.php?curdirpath=".$pathurl;
  75. $originaltoolname = get_lang('lang_slideshow');
  76. //$interbreadcrumb[]= array ("url"=>$url, "name"=>$originaltoolname );
  77. Display :: display_header($originaltoolname, "Doc");
  78. // loading the slides from the session
  79. $image_files_only = $_SESSION["image_files_only"];
  80. // calculating the current slide, next slide, previous slide and the number of slides
  81. if ($slide_id <> "all")
  82. {
  83. if ($slide_id)
  84. {
  85. $slide = $slide_id;
  86. }
  87. else
  88. {
  89. $slide = 0;
  90. }
  91. $previous_slide = $slide -1;
  92. $next_slide = $slide +1;
  93. } // if ($slide_id<>"all")
  94. $total_slides = count($image_files_only);
  95. ?>
  96. <script language="JavaScript" type="text/JavaScript">
  97. <!--
  98. function MM_openBrWindow(theURL,winName,features) { //v2.0
  99. window.open(theURL,winName,features);
  100. }
  101. //-->
  102. </script>
  103. <p></p>
  104. <h3 style="margin-top: 0; margin-bottom: 0"><?php echo get_lang('_slideshow'); ?></h3>
  105. <table width="100%" border="0" cellspacing="0" cellpadding="2">
  106. <tr>
  107. <td>
  108. <?php
  109. if ($slide > 0)
  110. {
  111. echo "<a href='slideshow.php?slide_id=".$previous_slide."&curdirpath=$pathurl'>";
  112. }
  113. ?>
  114. <strong>&lt;&lt; <?php echo get_lang('_previous_slide'); ?></strong> <?php
  115. if ($slide > 0)
  116. {
  117. echo "</a>";
  118. }
  119. ?>
  120. &nbsp;|&nbsp;
  121. <?php
  122. if ($slide < $total_slides -1 and $slide_id <> "all")
  123. {
  124. echo "<a href='slideshow.php?slide_id=".$next_slide."&curdirpath=$pathurl'>";
  125. }
  126. ?>
  127. <strong><?php echo get_lang('_next_slide'); ?> &gt;&gt;</strong>
  128. <?php
  129. if ($slide > 0)
  130. {
  131. echo "</a>";
  132. }
  133. ?>
  134. </td>
  135. <td>
  136. <?php
  137. if ($slide_id <> "all")
  138. {
  139. echo get_lang('_image')." ".$next_slide." ".get_lang('_of')." ".$total_slides;
  140. }
  141. ?>
  142. </td>
  143. <td align="right"><a href="document.php?action=exit_slideshow&curdirpath=<?php echo $pathurl;?>"><?php echo get_lang('_exit_slideshow');?></a> </td>
  144. </tr>
  145. <tr>
  146. <td>
  147. <?php
  148. if ($slide_id <> "all")
  149. {
  150. echo "<a href='slideshow.php?slide_id=all&curdirpath=".$pathurl."'>".get_lang('_show_thumbnails')."</a>";
  151. }
  152. else
  153. {
  154. echo get_lang('_click_thumbnails');
  155. }
  156. $image = $sys_course_path.$_course['path']."/document/".$folder.$image_files_only[$slide];
  157. // EXIF DATA, remove "and 0==1" in the if statement if you want to display the EXIT data in a popup
  158. //if (exif_read_data($image))
  159. // {
  160. // $_SESSION["exif_image"]=$image;
  161. //
  162. // 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>";
  163. // }
  164. ?>
  165. </td>
  166. <td><?php echo htmlspecialchars($image_files_only[$slide]) ?></td>
  167. <td align="right"><a href="slideshowoptions.php?curdirpath=<?php echo $pathurl; ?>"><?php echo get_lang('_set_slideshow_options');?></a></td>
  168. </tr>
  169. </table>
  170. <?php
  171. // =======================================================================
  172. // TREATING THE POST DATA FROM SLIDESHOW OPTIONS
  173. // =======================================================================
  174. // if we come from slideshowoptions.php we sessionize (new word !!! ;-) the options
  175. if (isset ($_POST['Submit'])) // we come from slideshowoptions.php
  176. {
  177. $_SESSION["image_resizing"] = $_POST['radio_resizing'];
  178. if ($_POST['radio_resizing'] == "resizing" && $_POST['width'] != '' && $_POST['height'] != '')
  179. {
  180. //echo "resizing";
  181. $_SESSION["image_resizing_width"] = $_POST['width'];
  182. $_SESSION["image_resizing_height"] = $_POST['height'];
  183. }
  184. else
  185. {
  186. //echo "unsetting the session heighte and width";
  187. $_SESSION["image_resizing_width"] = null;
  188. $_SESSION["image_resizing_height"] = null;
  189. }
  190. } // if ($submit)
  191. // The target height and width depends if we choose resizing or no resizing
  192. if ($_SESSION["image_resizing"] == "resizing")
  193. {
  194. $target_width = $_SESSION["image_resizing_width"];
  195. $target_height = $_SESSION["image_resizing_height"];
  196. }
  197. else
  198. {
  199. $image_width = $source_width;
  200. $image_height = $source_height;
  201. }
  202. // =======================================================================
  203. // THUMBNAIL VIEW
  204. // =======================================================================
  205. // this is for viewing all the images in the slideshow as thumbnails.
  206. $image_tag = array ();
  207. if ($slide_id == "all")
  208. {
  209. $thumbnail_width = 100;
  210. $thumbnail_height = 100;
  211. $row_items = 4;
  212. foreach ($image_files_only as $one_image_file)
  213. {
  214. $image = $sys_course_path.$_course['path']."/document/".$folder.$one_image_file;
  215. $image_height_width = resize_image($image, $thumbnail_width, $thumbnail_height, 1);
  216. $image_height = $image_height_width[0];
  217. $image_width = $image_height_width[1];
  218. if ($path and $path !== "/")
  219. {
  220. $doc_url = $path."/".$one_image_file;
  221. }
  222. else
  223. {
  224. $doc_url = $path.$one_image_file;
  225. }
  226. $image_tag[] = "<img src='download.php?doc_url=".$doc_url."' border='0' width='".$image_width."' height='".$image_height."'>";
  227. } // foreach ($image_files_only as $one_image_file)
  228. } // if ($slide_id=="all")
  229. // creating the table
  230. echo "\n<table align='center'>";
  231. $i = 0;
  232. foreach ($image_tag as $image_tag_item)
  233. {
  234. // starting new table row
  235. if ($i == 0)
  236. {
  237. echo "\n<tr>\n";
  238. }
  239. echo "\t<td><a href='slideshow.php?slide_id=".$i."&curdirpath=".$pathurl."'>".$image_tag_item."</a></td>\n";
  240. if ($i % 3 == 0 and $i !== 0)
  241. {
  242. echo "</tr>\n<tr>\n";
  243. }
  244. $i ++;
  245. }
  246. echo "</table>\n\n";
  247. // =======================================================================
  248. // ONE AT A TIME VIEW
  249. // =======================================================================
  250. // this is for viewing all the images in the slideshow one at a time.
  251. if ($slide_id !== "all")
  252. {
  253. $image = $sys_course_path.$_course['path']."/document/".$folder.$image_files_only[$slide];
  254. $image_height_width = resize_image($image, $target_width, $target_height);
  255. $image_height = $image_height_width[0];
  256. $image_width = $image_height_width[1];
  257. if ($_SESSION["image_resizing"] == "resizing")
  258. {
  259. $height_width_tags = "width='$image_width' height='$image_height'";
  260. }
  261. // showing the comment of the image, Patrick Cool, 8 april 2005
  262. // this is done really quickly and should be cleaned up a little bit using the API functions
  263. $tbl_documents = Database::get_course_table(DOCUMENT_TABLE);
  264. if ($path=='/')
  265. {
  266. $pathpart='/';
  267. }
  268. else
  269. {
  270. $pathpart=$path.'/';
  271. }
  272. $sql = "SELECT * FROM $tbl_documents WHERE path='".$pathpart.$image_files_only[$slide]."'";
  273. $result = api_sql_query($sql,__FILE__,__LINE__);
  274. $row = mysql_fetch_array($result);
  275. echo $row['comment'];
  276. echo "<center><img src='download.php?doc_url=$path/".$image_files_only[$slide]."' border='0' $height_width_tags></center>";
  277. } // if ($slide_id!=="all")
  278. Display :: display_footer();
  279. ?>