dokeos-document
[ class tree: dokeos-document ] [ index: dokeos-document ] [ all elements ]

Source for file document_slideshow.inc.php

Documentation is available at document_slideshow.inc.php

  1. <?php // $Id: document_slideshow.inc.php 15178 2008-04-29 18:35:20Z yannoo $
  2. /*
  3. ==============================================================================
  4.     Dokeos - elearning and course management software
  5.  
  6.     Copyright (c) 2004 Dokeos S.A.
  7.     Copyright (c) 2003 Ghent University (UGent)
  8.     Copyright (c) 2001 Universite catholique de Louvain (UCL)
  9.  
  10.     For a full list of contributors, see "credits.txt".
  11.     The full license can be read in "license.txt".
  12.  
  13.     This program is free software; you can redistribute it and/or
  14.     modify it under the terms of the GNU General Public License
  15.     as published by the Free Software Foundation; either version 2
  16.     of the License, or (at your option) any later version.
  17.  
  18.     See the GNU General Public License for more details.
  19.  
  20.     Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  21. ==============================================================================
  22. */
  23. /**
  24. ==============================================================================
  25. Developped by Patrick Cool
  26. patrick.cool@UGent.be
  27. Ghent University
  28. Mai 2004
  29. http://icto.UGent.be
  30.  
  31. Please bear in mind that this is only an alpha release. 
  32. I wrote this quite quick and didn't think too much about it in advance. 
  33. It is not perfect at all but it is workable and usefull (I think)
  34. Do not consider this as a powerpoint replacement, although it has
  35. the same starting point. 
  36.  
  37. *    This is a plugin for the documents tool. It looks for .jpg, .jpeg, .gif, .png
  38. *    files (since these are the files that can be viewed in a browser) and creates
  39. *    a slideshow with it by allowing to go to the next/previous image.
  40. *    You can also have a quick overview (thumbnail view) of all the images in
  41. *    that particular folder.
  42. *
  43. *    Each slideshow is folder based. Only
  44. *    the images of the chosen folder are shown.
  45. *    
  46. *    This file has two large sections.
  47. *    1. code that belongs in document.php, but to avoid clutter I put the code here
  48. *    (not present) 2. the function resize_image that handles the image resizing
  49. *    
  50. *    @author Patrick Cool, responsible author
  51. *    @author Roan Embrechts, minor cleanup
  52. *    @package dokeos.document
  53. ==============================================================================
  54. */
  55.  
  56. /*
  57. ============================================================================== 
  58.     general code that belongs in document.php 
  59.        
  60.     this code should indeed go in documents.php but since document.php is already a really ugly file with
  61.     too much things in one file , I decided to put the code for document.php here and to include this
  62.     file into document.php
  63. ============================================================================== 
  64. */ 
  65.  
  66. $accepted_extensions array('.jpg','.jpeg','.gif','.png');
  67.  
  68. // resetting the images of the slideshow = destroying the slideshow
  69. if (isset($_GET['action']&& $_GET['action']=="exit_slideshow")
  70. {
  71.     $_SESSION["image_files_only"]=null;
  72.     unset($image_files_only)
  73. }
  74.  
  75. // We check if there are images in this folder by searching the extensions for .jpg, .gif, .png
  76. // grabbing the list of all the documents of this folder
  77. //$all_files=$fileList['name'];
  78. $array_to_search (is_array($docs_and_folders))?$docs_and_folders:array();
  79.  
  80. if(count($array_to_search0{
  81.     while(list ($keyeach ($array_to_search))
  82.     {
  83.         $all_files[basename($array_to_search[$key]['path']);
  84.         //echo basename($array_to_search[$key]['path']).'<br>';
  85.     }
  86. }
  87.  
  88.  
  89. // storing the extension of all the documents in an array 
  90. // and checking if there is a .jpg, .jpeg, .gif or .png file
  91. // if this is the case a slideshow can be made. 
  92. $all_extensions=array()
  93. $image_present=0;
  94.  
  95. if count($all_files)
  96. {
  97.     foreach ($all_files as $file)
  98.     {
  99.         $slideshow_extension=strrchr($file,".")
  100.         $slideshow_extension=strtolower($slideshow_extension)
  101.         $all_extensions[]=$slideshow_extension;
  102.         if (in_array($slideshow_extension,$accepted_extensions))
  103.         {
  104.             $image_present=1;
  105.             $image_files_only[]=$file
  106.         }
  107.     }
  108. }
  109.  
  110. $tablename_column (isset($_GET['tablename_column'])?$_GET['tablename_column']:0);
  111. if($tablename_column==0){
  112.     $tablename_column=1;
  113. }
  114. else{
  115.     $tablename_columnintval($tablename_column)-1;
  116. }
  117. $tablename_direction (isset($_GET['tablename_direction'])?$_GET['tablename_direction']:'ASC');
  118.  
  119. $image_files_only sort_files($array_to_search);
  120. $_SESSION["image_files_only"$image_files_only;
  121.  
  122. function sort_files($table){
  123.     
  124.     global $tablename_direction,$accepted_extensions;
  125.     $temp=array();
  126.     
  127.     foreach($table as $file_array){
  128.         if($file_array['filetype']=='file'){
  129.             $slideshow_extension=strrchr($file_array['path'],".");
  130.             if (in_array($slideshow_extension,$accepted_extensions))
  131.             {
  132.                 $temp[array('file'basename($file_array['path'])$file_array['size']$file_array['insert_date']);
  133.             }
  134.         }
  135.     }
  136.     
  137.     usort($temp'sort_table');
  138.     if($tablename_direction == 'DESC'){
  139.         rsort($temp);
  140.     }
  141.     
  142.     $final_array=array();
  143.     foreach($temp as $file_array){
  144.         $final_array[$file_array[1];
  145.     }
  146.     
  147.     return $final_array;
  148.     
  149. }
  150.  
  151. function sort_table($a$b)
  152. {
  153.     global $tablename_column;
  154.     if($a[$tablename_column$b[$tablename_column]){
  155.         return 1;
  156.     }
  157.     else{
  158.         return -1;
  159.     }
  160. }
  161.  
  162.  
  163.  
  164. ?>

Documentation generated on Thu, 12 Jun 2008 13:20:21 -0500 by phpDocumentor 1.4.1