slideshow.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <?php // $Id: slideshow.php 21107 2009-05-30 16:27:09Z iflorespaz $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2009 Dokeos SPRL
  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. * @author Julio Montoya Lots of improvements, cleaning, adding security
  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. Improve by Juan Carlos Ra�a Trabado
  33. herodoto@telefonica.net
  34. January 2008
  35. ==============================================================================
  36. */
  37. // including the language file
  38. // name of the language file that needs to be included
  39. $language_file = array ('slideshow', 'document');
  40. require_once '../inc/global.inc.php';
  41. $noPHP_SELF = true;
  42. $path = Security::remove_XSS($_GET['curdirpath']);
  43. $pathurl = urlencode($path);
  44. $slide_id = Security::remove_XSS($_GET['slide_id']);
  45. if ($path <> '/') {
  46. $folder = $path.'/';
  47. } else {
  48. $folder = '/';
  49. }
  50. $sys_course_path = api_get_path(SYS_COURSE_PATH);
  51. // including the functions for the slideshow
  52. require_once 'slideshow.inc.php';
  53. // breadcrumb navigation
  54. $url = "document.php?curdirpath=".$pathurl;
  55. $originaltoolname = get_lang('Documents');
  56. $interbreadcrumb[] = array ("url" => Security::remove_XSS($url), "name" => $originaltoolname);
  57. // because $nametools uses $_SERVER['PHP_SELF'] for the breadcrumbs instead of $_SERVER['REQUEST_URI'], I had to
  58. // bypass the $nametools thing and use <b></b> tags in the $interbreadcrump array
  59. //$url = "slideshow.php?curdirpath=".$pathurl;
  60. $originaltoolname = get_lang('SlideShow');
  61. //$interbreadcrumb[]= array ("url"=>$url, "name"=>$originaltoolname );
  62. Display :: display_header($originaltoolname, "Doc");
  63. // loading the slides from the session
  64. if (isset($_SESSION["image_files_only"])) {
  65. $image_files_only = $_SESSION["image_files_only"];
  66. }
  67. // calculating the current slide, next slide, previous slide and the number of slides
  68. if ($slide_id <> "all") {
  69. if ($slide_id) {
  70. $slide = $slide_id;
  71. } else {
  72. $slide = 0;
  73. }
  74. $previous_slide = $slide -1;
  75. $next_slide = $slide +1;
  76. } // if ($slide_id<>"all")
  77. $total_slides = count($image_files_only);
  78. ?>
  79. <script language="JavaScript" type="text/JavaScript">
  80. <!--
  81. function MM_openBrWindow(theURL,winName,features) { //v2.0
  82. window.open(theURL,winName,features);
  83. }
  84. //-->
  85. </script>
  86. <div class="actions">
  87. <?php
  88. // exit the slideshow
  89. echo '<a href="document.php?action=exit_slideshow&curdirpath='.$pathurl.'">'.Display::return_icon('back.png').get_lang('Back').' '.get_lang('To').' '.get_lang('DocumentsOverview').'</a>&nbsp;';
  90. // show thumbnails
  91. if ($slide_id <> "all") {
  92. 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;';
  93. } else {
  94. echo '<img src="'.api_get_path(WEB_IMG_PATH).'thumbnails_na.png" alt="">'.get_lang('_show_thumbnails').'&nbsp;';
  95. }
  96. // slideshow options
  97. 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;';
  98. ?>
  99. </div>
  100. <?php
  101. echo '<br />';
  102. // =======================================================================
  103. // TREATING THE POST DATA FROM SLIDESHOW OPTIONS
  104. // =======================================================================
  105. // if we come from slideshowoptions.php we sessionize (new word !!! ;-) the options
  106. if (isset ($_POST['Submit'])) {
  107. // we come from slideshowoptions.php
  108. $_SESSION["image_resizing"] = Security::remove_XSS($_POST['radio_resizing']);
  109. if ($_POST['radio_resizing'] == "resizing" && $_POST['width'] != '' && $_POST['height'] != '') {
  110. //echo "resizing";
  111. $_SESSION["image_resizing_width"] = Security::remove_XSS($_POST['width']);
  112. $_SESSION["image_resizing_height"] = Security::remove_XSS($_POST['height']);
  113. } else {
  114. //echo "unsetting the session heighte and width";
  115. $_SESSION["image_resizing_width"] = null;
  116. $_SESSION["image_resizing_height"] = null;
  117. }
  118. } // if ($submit)
  119. // The target height and width depends if we choose resizing or no resizing
  120. if ($_SESSION["image_resizing"] == "resizing") {
  121. $target_width = $_SESSION["image_resizing_width"];
  122. $target_height = $_SESSION["image_resizing_height"];
  123. } else {
  124. $image_width = $source_width;
  125. $image_height = $source_height;
  126. }
  127. // =======================================================================
  128. // THUMBNAIL VIEW
  129. // =======================================================================
  130. // this is for viewing all the images in the slideshow as thumbnails.
  131. $image_tag = array ();
  132. if ($slide_id == "all") {
  133. $thumbnail_width = 100;
  134. $thumbnail_height = 100;
  135. $row_items = 4;
  136. if (is_array($image_files_only)) {
  137. foreach ($image_files_only as $one_image_file) {
  138. $image = $sys_course_path.$_course['path']."/document".$folder.$one_image_file;
  139. if (file_exists($image)) {
  140. $image_height_width = resize_image($image, $thumbnail_width, $thumbnail_height, 1);
  141. $image_height = $image_height_width[0];
  142. $image_width = $image_height_width[1];
  143. if ($path and $path !== "/") {
  144. $doc_url = $path."/".$one_image_file;
  145. } else {
  146. $doc_url = $path.$one_image_file;
  147. }
  148. $image_tag[] = "<img src='download.php?doc_url=".$doc_url."' border='0' width='".$image_width."' height='".$image_height."' title='".$one_image_file."'>";
  149. }
  150. } // foreach ($image_files_only as $one_image_file)
  151. }
  152. } // if ($slide_id=="all")
  153. // creating the table
  154. $html_table='';
  155. echo '<table align="center" width="760px" border="0" cellspacing="10">';
  156. $i = 0;
  157. $count_image=count($image_tag);
  158. $number_image=6;
  159. $number_iteration=ceil($count_image/$number_image);
  160. $p=0;
  161. for ($k=0;$k<$number_iteration;$k++) {
  162. echo '<tr height="'.$thumbnail_height.'">';
  163. for ($i=0;$i<$number_image;$i++) {
  164. if (!is_null($image_tag[$p])) {
  165. echo '<td style="border:1px solid; border-color: #CCCCCC #666666 #666666 #CCCCCC;">';
  166. echo '<div align="center"><a href="slideshow.php?slide_id='.$p.'&curdirpath='.$pathurl.' ">'.$image_tag[$p].'</a>';
  167. echo '</div></td>';
  168. }
  169. $p++;
  170. }
  171. echo '</tr>';
  172. }
  173. echo '</table>';
  174. // =======================================================================
  175. // ONE AT A TIME VIEW
  176. // =======================================================================
  177. // this is for viewing all the images in the slideshow one at a time.
  178. if ($slide_id !== "all") {
  179. $image = $sys_course_path.$_course['path']."/document".$folder.$image_files_only[$slide];
  180. if (file_exists($image)) {
  181. $image_height_width = resize_image($image, $target_width, $target_height);
  182. $image_height = $image_height_width[0];
  183. $image_width = $image_height_width[1];
  184. if ($_SESSION["image_resizing"] == "resizing") {
  185. $height_width_tags = 'width="'.$image_width.'" height="'.$image_height.'"';
  186. /* // Removed by Ivan Tcholakov, 04-MAY-2009. After some changes this fragment of code is not needed anymore.
  187. //adjust proportions. Juan Carlos Raсa Trabado TODO: replace resize_image function ?
  188. $size = @ getimagesize($image);
  189. $height_width_tags = (($size[1] > $image_width) ? 'width="'.$image_width.'"' : '');
  190. $height_width_tags = (($size[1] > $image_height) ? 'height="'.$image_height.'"' : '');
  191. */
  192. }
  193. // showing the comment of the image, Patrick Cool, 8 april 2005
  194. // this is done really quickly and should be cleaned up a little bit using the API functions
  195. $tbl_documents = Database::get_course_table(TABLE_DOCUMENT);
  196. if ($path=='/') {
  197. $pathpart='/';
  198. } else {
  199. $pathpart=$path.'/';
  200. }
  201. $sql = "SELECT * FROM $tbl_documents WHERE path='".Database::escape_string($pathpart.$image_files_only[$slide])."'";
  202. $result = api_sql_query($sql,__FILE__,__LINE__);
  203. $row = Database::fetch_array($result);
  204. // back forward buttons
  205. echo '<table align="center" border="0">';
  206. echo '<tr>';
  207. echo '<td align="center" >';
  208. // previous slide
  209. if ($slide > 0) {
  210. echo '<a href="slideshow.php?slide_id='.$previous_slide.'&amp;curdirpath='.$pathurl.'">';
  211. }
  212. echo '<img src="'.api_get_path(WEB_IMG_PATH).'silde_back.gif" alt="">';
  213. if ($slide > 0) {
  214. echo "</a> ";
  215. }
  216. // divider
  217. if ($slide_id <> "all") {
  218. echo '</td><td valign="middle"> [ '.$next_slide.'/'.$total_slides.' ] </td><td>';
  219. }
  220. // next slide
  221. if ($slide < $total_slides -1 and $slide_id <> "all") {
  222. echo "<a href='slideshow.php?slide_id=".$next_slide."&curdirpath=$pathurl'>";
  223. }
  224. echo '<img src="'.api_get_path(WEB_IMG_PATH).'silde_next.gif" alt="">';
  225. if ($slide > 0) {
  226. echo '</a>';
  227. }
  228. echo '</td>';
  229. echo '</tr>';
  230. echo '</table>';
  231. echo '<br/>';
  232. echo '<table align="center" border="0">';
  233. echo '<tr>';
  234. echo '<td align="center">';
  235. echo "<img src='download.php?doc_url=$path/".$image_files_only[$slide]."' alt='".$image_files_only[$slide]."' border='0'".$height_width_tags.">";
  236. echo '</td>';
  237. echo '</tr>';
  238. echo '<tr>';
  239. echo '<td align="center">';
  240. $aux= explode(".", htmlspecialchars($image_files_only[$slide]));
  241. $ext= $aux[count($aux)-1];
  242. echo '<strong>'.basename(htmlspecialchars($image_files_only[$slide]), '.'.$ext).'</strong>';
  243. echo '<br />'.$row['comment'].'<br />';
  244. list($width, $high) = getimagesize($image);
  245. echo $width.' x '.$high.' <br />';
  246. echo round((filesize($image)/1024),2).' KB';
  247. echo ' - '.$ext;
  248. echo '</td>';
  249. echo '</tr>';
  250. echo '</table>';
  251. } else {
  252. Display::display_warning_message(get_lang('FileNotFound'));
  253. }
  254. } // if ($slide_id!=="all")
  255. Display :: display_footer();
  256. ?>