slideshow.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <?php // $Id: slideshow.php 18106 2009-02-01 00:37:15Z herodoto $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. For a full list of contributors, see "credits.txt".
  9. The full license can be read in "license.txt".
  10. This program is free software; you can redistribute it and/or
  11. modify it under the terms of the GNU General Public License
  12. as published by the Free Software Foundation; either version 2
  13. of the License, or (at your option) any later version.
  14. See the GNU General Public License for more details.
  15. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  16. ==============================================================================
  17. */
  18. /**
  19. ==============================================================================
  20. * @author Patrick Cool
  21. * @package dokeos.document
  22. ==============================================================================
  23. */
  24. /*
  25. ==============================================================================
  26. Developped by Patrick Cool
  27. patrick.cool@UGent.be
  28. Ghent University
  29. Mai 2004
  30. http://icto.UGent.be
  31. ==============================================================================
  32. */
  33. /*
  34. ==============================================================================
  35. Improve by Juan Carlos Raña Trabado
  36. herodoto@telefonica.net
  37. January 2008
  38. ==============================================================================
  39. */
  40. // including the language file
  41. // name of the language file that needs to be included
  42. $language_file = "slideshow";
  43. include ('../inc/global.inc.php');
  44. $noPHP_SELF = true;
  45. $path = $_GET['curdirpath'];
  46. $pathurl = urlencode($path);
  47. $slide_id = $_GET['slide_id'];
  48. if ($path and $path <> "")
  49. {
  50. $folder = $path."/";
  51. }
  52. else
  53. {
  54. $folder = "";
  55. }
  56. $sys_course_path = api_get_path(SYS_COURSE_PATH);
  57. // including the functions for the slideshow
  58. include ('slideshow.inc.php');
  59. // breadcrumb navigation
  60. $url = "document.php?curdirpath=".$pathurl;
  61. $originaltoolname = get_lang('Documents');
  62. $interbreadcrumb[] = array ("url" => $url, "name" => $originaltoolname);
  63. // because $nametools uses $_SERVER['PHP_SELF'] for the breadcrumbs instead of $_SERVER['REQUEST_URI'], I had to
  64. // bypass the $nametools thing and use <b></b> tags in the $interbreadcrump array
  65. $url = "slideshow.php?curdirpath=".$pathurl;
  66. $originaltoolname = get_lang('SlideShow');
  67. //$interbreadcrumb[]= array ("url"=>$url, "name"=>$originaltoolname );
  68. Display :: display_header($originaltoolname, "Doc");
  69. // loading the slides from the session
  70. $image_files_only = $_SESSION["image_files_only"];
  71. // calculating the current slide, next slide, previous slide and the number of slides
  72. if ($slide_id <> "all")
  73. {
  74. if ($slide_id)
  75. {
  76. $slide = $slide_id;
  77. }
  78. else
  79. {
  80. $slide = 0;
  81. }
  82. $previous_slide = $slide -1;
  83. $next_slide = $slide +1;
  84. } // if ($slide_id<>"all")
  85. $total_slides = count($image_files_only);
  86. ?>
  87. <script language="JavaScript" type="text/JavaScript">
  88. <!--
  89. function MM_openBrWindow(theURL,winName,features) { //v2.0
  90. window.open(theURL,winName,features);
  91. }
  92. //-->
  93. </script>
  94. <div class="actions">
  95. <?php
  96. // exit the slideshow
  97. echo '<a href="document.php?action=exit_slideshow&curdirpath='.$pathurl.'"><img src="'.api_get_path(WEB_IMG_PATH).'folder_up.gif" alt="">'.get_lang('_exit_slideshow').'</a>&nbsp;';
  98. // show thumbnails
  99. if ($slide_id <> "all") {
  100. echo '<a href="slideshow.php?slide_id=all&curdirpath='.$pathurl.'"><img src="'.api_get_path(WEB_IMG_PATH).'thumbnails.png" alt="">'.get_lang('_show_thumbnails').'</a>&nbsp;';
  101. } else {
  102. echo '<img src="'.api_get_path(WEB_IMG_PATH).'thumbnails_na.png" alt="">'.get_lang('_show_thumbnails').'&nbsp;';
  103. }
  104. $image = $sys_course_path.$_course['path']."/document/".$folder.$image_files_only[$slide];
  105. // slideshow options
  106. echo '<a href="slideshowoptions.php?curdirpath='.$pathurl.'"><img src="'.api_get_path(WEB_IMG_PATH).'acces_tool.gif" alt="">'.get_lang('_set_slideshow_options').'</a> &nbsp;';
  107. ?>
  108. </div>
  109. <?php
  110. echo '<br />';
  111. // =======================================================================
  112. // TREATING THE POST DATA FROM SLIDESHOW OPTIONS
  113. // =======================================================================
  114. // if we come from slideshowoptions.php we sessionize (new word !!! ;-) the options
  115. if (isset ($_POST['Submit'])) // we come from slideshowoptions.php
  116. {
  117. $_SESSION["image_resizing"] = $_POST['radio_resizing'];
  118. if ($_POST['radio_resizing'] == "resizing" && $_POST['width'] != '' && $_POST['height'] != '')
  119. {
  120. //echo "resizing";
  121. $_SESSION["image_resizing_width"] = $_POST['width'];
  122. $_SESSION["image_resizing_height"] = $_POST['height'];
  123. }
  124. else
  125. {
  126. //echo "unsetting the session heighte and width";
  127. $_SESSION["image_resizing_width"] = null;
  128. $_SESSION["image_resizing_height"] = null;
  129. }
  130. } // if ($submit)
  131. // The target height and width depends if we choose resizing or no resizing
  132. if ($_SESSION["image_resizing"] == "resizing")
  133. {
  134. $target_width = $_SESSION["image_resizing_width"];
  135. $target_height = $_SESSION["image_resizing_height"];
  136. }
  137. else
  138. {
  139. $image_width = $source_width;
  140. $image_height = $source_height;
  141. }
  142. // =======================================================================
  143. // THUMBNAIL VIEW
  144. // =======================================================================
  145. // this is for viewing all the images in the slideshow as thumbnails.
  146. $image_tag = array ();
  147. if ($slide_id == "all")
  148. {
  149. $thumbnail_width = 100;
  150. $thumbnail_height = 100;
  151. $row_items = 4;
  152. foreach ($image_files_only as $one_image_file)
  153. {
  154. $image = $sys_course_path.$_course['path']."/document/".$folder.$one_image_file;
  155. $image_height_width = resize_image($image, $thumbnail_width, $thumbnail_height, 1);
  156. $image_height = $image_height_width[0];
  157. $image_width = $image_height_width[1];
  158. if ($path and $path !== "/")
  159. {
  160. $doc_url = $path."/".$one_image_file;
  161. }
  162. else
  163. {
  164. $doc_url = $path.$one_image_file;
  165. }
  166. $image_tag[] = "<img src='download.php?doc_url=".$doc_url."' border='0' width='".$image_width."' height='".$image_height."' title='".$one_image_file."'>";
  167. } // foreach ($image_files_only as $one_image_file)
  168. } // if ($slide_id=="all")
  169. // creating the table
  170. echo "\n<table align='center' cellspacing='10'>";
  171. $i = 0;
  172. foreach ($image_tag as $image_tag_item)
  173. {
  174. $link=$i;
  175. // starting new table row
  176. if ($i == 0)
  177. {
  178. echo "\n<tr>\n";
  179. $i ++;
  180. }
  181. $link=$i-1;
  182. echo "\t<td align='center' style='display:block; position:relative; top: -3px; left:-3px; padding:5px; background:#FFFFFF; border:1px solid; border-color: #CCCCCC #666666 #666666 #CCCCCC;'><a href='slideshow.php?slide_id=".$link."&curdirpath=".$pathurl."'>".$image_tag_item."</a></td>\n";
  183. if ($i % 6 == 0 and $i !== 0) // 6 cols
  184. {
  185. echo "</tr>\n<tr>\n";
  186. }
  187. $i ++;
  188. }
  189. echo "</table>\n\n";
  190. // =======================================================================
  191. // ONE AT A TIME VIEW
  192. // =======================================================================
  193. // this is for viewing all the images in the slideshow one at a time.
  194. if ($slide_id !== "all")
  195. {
  196. $image = $sys_course_path.$_course['path']."/document/".$folder.$image_files_only[$slide];
  197. $image_height_width = resize_image($image, $target_width, $target_height);
  198. $image_height = $image_height_width[0];
  199. $image_width = $image_height_width[1];
  200. if ($_SESSION["image_resizing"] == "resizing")
  201. {
  202. $height_width_tags = 'width="'.$image_width.'" height="'.$image_height.'"';
  203. //adjust proportions. Juan Carlos Raña Trabado TODO: replace resize_image function ?
  204. $size = @ getimagesize($image);
  205. $height_width_tags = (($size[1] > $image_width) ? 'width="'.$image_width.'"' : '');
  206. $height_width_tags = (($size[1] > $image_height) ? 'height="'.$image_height.'"' : '');
  207. }
  208. // showing the comment of the image, Patrick Cool, 8 april 2005
  209. // this is done really quickly and should be cleaned up a little bit using the API functions
  210. $tbl_documents = Database::get_course_table(TABLE_DOCUMENT);
  211. if ($path=='/')
  212. {
  213. $pathpart='/';
  214. }
  215. else
  216. {
  217. $pathpart=$path.'/';
  218. }
  219. $sql = "SELECT * FROM $tbl_documents WHERE path='".$pathpart.$image_files_only[$slide]."'";
  220. $result = api_sql_query($sql,__FILE__,__LINE__);
  221. $row = mysql_fetch_array($result);
  222. echo '<table align="center" border="0">';
  223. echo '<tr>';
  224. echo '<td align="center">';
  225. echo "<img src='download.php?doc_url=$path/".$image_files_only[$slide]."' alt='".$image_files_only[$slide]."' border='0'".$height_width_tags.">";
  226. echo '</td>';
  227. echo '</tr>';
  228. echo '<tr>';
  229. echo '<td align="center">';
  230. $aux= explode(".", htmlspecialchars($image_files_only[$slide]));
  231. $ext= $aux[count($aux)-1];
  232. echo '<strong>'.basename(htmlspecialchars($image_files_only[$slide]), '.'.$ext).'</strong>';
  233. echo '<br />'.$row['comment'].'<br />';
  234. list($width, $high) = getimagesize($image);
  235. echo $width.' x '.$high.' '.round((filesize($image)/1024),2).' KB';
  236. echo ' - '.$ext;
  237. echo '</td>';
  238. echo '</tr>';
  239. echo '<tr>';
  240. echo '<td align="center">';
  241. // previous slide
  242. if ($slide > 0)
  243. {
  244. echo '<a href="slideshow.php?slide_id='.$previous_slide.'&amp;curdirpath='.$pathurl.'">';
  245. }
  246. echo '&lt;&lt;'.get_lang('_previous_slide');
  247. if ($slide > 0)
  248. {
  249. echo "</a> ";
  250. }
  251. // divider
  252. if ($slide_id <> "all")
  253. {
  254. echo ' '.$next_slide.'/'.$total_slides.' ';
  255. }
  256. // next slide
  257. if ($slide < $total_slides -1 and $slide_id <> "all")
  258. {
  259. echo "<a href='slideshow.php?slide_id=".$next_slide."&curdirpath=$pathurl'>";
  260. }
  261. echo get_lang('_next_slide').'&gt;&gt;';
  262. if ($slide > 0)
  263. {
  264. echo '</a>';
  265. }
  266. echo '</td>';
  267. echo '</tr>';
  268. echo '</table>';
  269. } // if ($slide_id!=="all")
  270. Display :: display_footer();
  271. ?>