dokeos-learnpath-openofficedocument
[ class tree: dokeos-learnpath-openofficedocument ] [ index: dokeos-learnpath-openofficedocument ] [ all elements ]

Source for file openoffice_presentation.class.php

Documentation is available at openoffice_presentation.class.php

  1. <?php //$id:$
  2. /**
  3.  * Defines the OpenOfficeDocument class, which is meant as a conversion
  4.  * tool from Office presentations (.ppt, .sxi, .odp, .pptx) to
  5.  * learning paths
  6.  * @package dokeos.learnpath.openofficedocument
  7.  * @author  Eric Marguin <eric.marguin@dokeos.com>
  8.  * @license GNU/GPL - See Dokeos license directory for details
  9.  */
  10. /**
  11.  * Defines the "OpenofficePresentation" child of class "OpenofficeDocument"
  12.  * @package dokeos.learnpath.openofficedocument
  13.  */
  14. require_once('openoffice_document.class.php');
  15.  
  16.     
  17.     public $take_slide_name;
  18.     
  19.     function OpenofficePresentation($take_slide_name=false$course_code=null$resource_id=null,$user_id=null{
  20.         
  21.         $this -> take_slide_name = $take_slide_name;
  22.         parent::OpenofficeDocument($course_code$resource_id$user_id);
  23.         
  24.     }
  25.  
  26.     
  27.     function make_lp($files=array()) {
  28.     
  29.         global $_course;
  30.    
  31.         $previous 0;
  32.         $i 0;
  33.         
  34.         if(!is_dir($this->base_work_dir.$this->created_dir))
  35.             return false;
  36.         
  37.         
  38.         foreach($files as $file){
  39.             
  40.             list($slide_name,$file_nameexplode('||',$file)// '||' is used as separator between slide name (with accents) and file name (without accents)
  41.             
  42.             //filename is utf8 encoded, but when we decode, some chars are not translated (like quote &rsquo;).
  43.             //so we remove these chars by translating it in htmlentities and the reconvert it in want charset
  44.             $slide_name htmlentities($slide_name,ENT_COMPAT,$this->original_charset)
  45.             $slide_name str_replace('&rsquo;','\'',$slide_name);
  46.             $slide_name mb_convert_encoding($slide_nameapi_get_setting('platform_charset')$this->original_charset);
  47.             $slide_name html_entity_decode($slide_name);
  48.             
  49.             if($this->take_slide_name === true)
  50.             {
  51.                 $slide_name str_replace('_',' ',$slide_name);
  52.                 $slide_name ucfirst($slide_name);
  53.             }
  54.             else
  55.             {
  56.                 $slide_name 'slide'.str_repeat('0',2-strlen($i)).$i;
  57.             }
  58.             
  59.             $i++;    
  60.             // add the png to documents
  61.             $document_id add_document($_course,$this->created_dir.'/'.urlencode($file_name),'file',filesize($this->base_work_dir.$this->created_dir.'/'.$file_name),$slide_name);
  62.             api_item_property_update($_course,TOOL_DOCUMENT,$document_id,'DocumentAdded',$_SESSION['_uid'],0,0);
  63.             
  64.             
  65.             // create an html file
  66.             $html_file $file_name.'.html';
  67.             $fp fopen($this->base_work_dir.$this->created_dir.'/'.$html_file'w+');
  68.             
  69.             fwrite($fp,
  70.                     '<html>
  71.                     <head></head>
  72.                     <body>
  73.                         <img src="'.api_get_path(REL_COURSE_PATH).$_course['path'].'/document/'.$this->created_dir.'/'.utf8_encode($file_name).'" />
  74.                     </body>
  75.                     </html>');
  76.             fclose($fp);
  77.             $document_id add_document($_course,$this->created_dir.'/'.urlencode($html_file),'file',filesize($this->base_work_dir.$this->created_dir.'/'.$html_file),$slide_name);
  78.             if ($document_id){    
  79.                             
  80.                 //put the document in item_property update
  81.                 api_item_property_update($_course,TOOL_DOCUMENT,$document_id,'DocumentAdded',$_SESSION['_uid'],0,0);
  82.                 
  83.                 $previous learnpath::add_item(0$previous'document'$document_id$slide_name'');
  84.                 if($this->first_item == 0){
  85.                     $this->first_item = $previous;
  86.                 }
  87.             }
  88.         }
  89.     }
  90.     
  91.     function add_command_parameters(){
  92.         
  93.         if(empty($this->slide_width|| empty($this->slide_height))
  94.             list($this->slide_width$this->slide_heightexplode('x',api_get_setting('service_ppt2lp','size'));
  95.         return ' -w '.$this->slide_width.' -h '.$this->slide_height.' -d oogie "'.$this->base_work_dir.'/'.$this->file_path.'"  "'.$this->base_work_dir.$this->created_dir.'.html"';
  96.     
  97.     }
  98.     
  99.     function set_slide_size($width,$height)
  100.     {
  101.         $this->slide_width $width;
  102.         $this->slide_height $height;
  103.     }
  104.     
  105.     function add_docs_to_visio ($files=array()){
  106.         
  107.         global $_course;
  108.         /* Add Files */
  109.         
  110.         
  111.         foreach($files as $file){
  112.             
  113.             list($slide_name,$file_nameexplode('||',$file)// '||' is used as separator between slide name (with accents) and file name (without accents)
  114.             $slide_name htmlentities($slide_name,ENT_COMPAT,$this->original_charset)
  115.             $slide_name str_replace('&rsquo;','\'',$slide_name);
  116.             $slide_name mb_convert_encoding($slide_nameapi_get_setting('platform_charset')$this->original_charset);
  117.             $slide_name html_entity_decode($slide_name);
  118.             
  119.             $did add_document($_course$this->created_dir.'/'.urlencode($file_name)'file'filesize($this->base_work_dir.$this->created_dir.'/'.$file_name)$slide_name);
  120.             if ($did)
  121.                 api_item_property_update($_courseTOOL_DOCUMENT$did'DocumentAdded'$_SESSION['_uid']0NULL);
  122.         
  123.         }
  124.         
  125.     }
  126.         
  127.         
  128. }
  129. ?>

Documentation generated on Thu, 12 Jun 2008 14:09:14 -0500 by phpDocumentor 1.4.1