openoffice_presentation.class.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php //$id:$
  2. /**
  3. * Defines the AICC class, which is meant to contain the aicc items (nuclear elements)
  4. * @package dokeos.learnpath.aicc
  5. * @author Yannick Warnier <ywarnier@beeznest.org>
  6. * @license GNU/GPL - See Dokeos license directory for details
  7. */
  8. /**
  9. * Defines the "aicc" child of class "learnpath"
  10. * @package dokeos.learnpath.aicc
  11. */
  12. require_once('openoffice_document.class.php');
  13. class OpenofficePresentation extends OpenofficeDocument {
  14. public $take_slide_name;
  15. function OpenofficePresentation($take_slide_name=false, $course_code=null, $resource_id=null,$user_id=null) {
  16. $this -> take_slide_name = $take_slide_name;
  17. parent::OpenofficeDocument($course_code, $resource_id, $user_id);
  18. }
  19. function make_lp($files=array()) {
  20. global $_course;
  21. $previous = 0;
  22. $i = 0;
  23. if(!is_dir($this->base_work_dir.$this->created_dir))
  24. return false;
  25. foreach($files as $file){
  26. list($slide_name,$file_name) = explode('||',$file); // '||' is used as separator between slide name (with accents) and file name (without accents)
  27. $slide_name = utf8_decode($slide_name); //filename has been written in java, so unicode
  28. if($this->take_slide_name === true)
  29. {
  30. $slide_name = str_replace('_',' ',$slide_name);
  31. $slide_name = ucfirst($slide_name);
  32. }
  33. else
  34. {
  35. $slide_name = 'slide'.str_repeat('0',2-strlen($i)).$i;
  36. }
  37. $i++;
  38. // add the png to documents
  39. $document_id = add_document($_course,$this->created_dir.'/'.urlencode($file_name),'file',filesize($this->base_work_dir.$this->created_dir.'/'.$file_name),$slide_name);
  40. api_item_property_update($_course,TOOL_DOCUMENT,$document_id,'DocumentAdded',$_SESSION['_uid'],0,0);
  41. // create an html file
  42. $html_file = $file_name.'.html';
  43. $fp = fopen($this->base_work_dir.$this->created_dir.'/'.$html_file, 'w+');
  44. fwrite($fp,
  45. '<html>
  46. <head></head>
  47. <body>
  48. <img src="'.api_get_path(REL_COURSE_PATH).$_course['path'].'/document/'.$this->created_dir.'/'.utf8_encode($file_name).'" />
  49. </body>
  50. </html>');
  51. fclose($fp);
  52. $document_id = add_document($_course,$this->created_dir.'/'.urlencode($html_file),'file',filesize($this->base_work_dir.$this->created_dir.'/'.$html_file),$slide_name);
  53. if ($document_id){
  54. //put the document in item_property update
  55. api_item_property_update($_course,TOOL_DOCUMENT,$document_id,'DocumentAdded',$_SESSION['_uid'],0,0);
  56. $previous = learnpath::add_item(0, $previous, 'document', $document_id, $slide_name, '');
  57. if($this->first_item == 0){
  58. $this->first_item = $previous;
  59. }
  60. }
  61. }
  62. }
  63. function add_command_parameters(){
  64. if(empty($this->slide_width) || empty($this->slide_height))
  65. list($this->slide_width, $this->slide_height) = explode('x',api_get_setting('service_ppt2lp','size'));
  66. 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"';
  67. }
  68. function set_slide_size($width,$height)
  69. {
  70. $this->slide_width = $width;
  71. $this->slide_height = $height;
  72. }
  73. function add_docs_to_visio ($files=array()){
  74. global $_course;
  75. /* Add Files */
  76. foreach($files as $file){
  77. list($slide_name,$file_name) = explode('||',$file); // '||' is used as separator between slide name (with accents) and file name (without accents)
  78. $slide_name = utf8_decode($slide_name); //filename has been written in java, so unicode
  79. $did = add_document($_course, $this->created_dir.'/'.urlencode($file_name), 'file', filesize($this->base_work_dir.$this->created_dir.'/'.$file_name), $slide_name);
  80. if ($did)
  81. api_item_property_update($_course, TOOL_DOCUMENT, $did, 'DocumentAdded', $_SESSION['_uid'], 0, NULL);
  82. }
  83. }
  84. }
  85. ?>