[svn r14431] fix some bugs in oogie + make oogie working in visioconf

skala
Eric Marguin 18 years ago
parent 02d32c5e90
commit d1c4259047
  1. 62
      main/conference/api.php
  2. 23
      main/newscorm/openoffice_document.class.php
  3. 16
      main/newscorm/openoffice_presentation.class.php
  4. 5
      main/newscorm/openoffice_text_document.class.php

@ -34,6 +34,8 @@ api_block_anonymous_users();
require_once (api_get_path(LIBRARY_PATH)."course.lib.php");
require_once (api_get_path(LIBRARY_PATH)."document.lib.php");
require_once (api_get_path(LIBRARY_PATH)."fileUpload.lib.php");
require_once ("../newscorm/learnpath.class.php");
require_once ("../newscorm/openoffice_presentation.class.php");
/*==== Variables initialisation ====*/
$action = $_REQUEST["action"]; //safe as only used in if()'s
@ -45,7 +47,7 @@ $cidReq = Security::remove_XSS($cidReq);
$user_id = api_get_user_id();
$coursePath = api_get_path(SYS_COURSE_PATH).$cidReq.'/document';
$_course = CourseManager::get_course_information($cidReq);
$_course['path'] = $_course['directory'];
// FIXME: add_document needs this to work
$_course['dbName'] = $_course['db_name'];
@ -86,62 +88,10 @@ else if ($action == "upload")
if ($debug>0) error_log("Can't create ".$destPath." folder",0);
}
}
$newPath = handle_uploaded_document($_course,$_FILES['filedata'],$coursePath,VIDEOCONF_UPLOAD_PATH,$user_id,0,NULL,'',0,'rename',false);
// based on ../newscorm/presentation.class.php
$file_name = (strrpos($newPath,'.')>0 ? substr($newPath, 0, strrpos($newPath,'.')) : $newPath);
$file_extension = (strrpos($newPath,'.')>0 ? substr($newPath, strrpos($newPath,'.'),10) : '');
if (in_array($file_extension, $presentation_extension))
{
if ($debug > 0) error_log("converting $coursePath$newPath", 0);
/* creating output folder */
$created_dir = create_unexisting_directory($_course,$user_id,0,NULL,$coursePath,$file_name);
/* alow user of openoffice to write into the folder */
// FIXME
chmod($coursePath.$created_dir, 0777);
/*
* exec java application
* the parameters of the program are :
* - javacommand on this server ;
* - host where openoffice is running;
* - port with which openoffice is listening
* - file to convert
* - folder where put the slides
* - ftppassword if required
* The program fills $files with the list of slides created
*/
/* building command line */
$classpath = '-cp .:ridl.jar:js.jar:juh.jar:jurt.jar:jut.jar:java_uno.jar:java_uno_accessbridge.jar:edtftpj-1.5.2.jar:unoil.jar';
if(strpos($_ENV['OS'],'Windows') !== false)
{
$classpath = str_replace(':',';',$classpath);
}
$slide_width=640;
$slide_height=480;
if(strpos($_ENV['OS'],'Windows') !== false)
{
$cmd = 'cd '.str_replace('/','\\',api_get_path(SYS_PATH)).'main/inc/lib/ppt2png && java '.$classpath.' DocumentConverter '.api_get_setting('service_ppt2lp','host').' 2002'.' "'.$coursePath.$newPath.'" "'.$coursePath.$created_dir.'"'.' '.$slide_width.' '.$slide_height.' '.api_get_setting('service_ppt2lp','user').' '.api_get_setting('service_ppt2lp','ftp_password');
}
else
{
$cmd = 'cd '.api_get_path(SYS_PATH).'main/inc/lib/ppt2png && java '.$classpath.' DocumentConverter '.api_get_setting('service_ppt2lp','host').' 2002'.' "'.$coursePath.$newPath.'" "'.$coursePath.$created_dir.'"'.' '.$slide_width.' '.$slide_height.' '.api_get_setting('service_ppt2lp','user').' '.api_get_setting('service_ppt2lp','ftp_password');
}
if ($debug>0) error_log($cmd,0);
$take_slide_name = false;
$o_ppt = new OpenofficePresentation($take_slide_name);
$o_ppt -> convert_document($_FILES['filedata'],'add_docs_to_visio');
/* Exec */
$shell = exec($cmd, $files, $return); // files: list of created files, return: shell return code
/* Add Files */
foreach($files as $f)
{
$did = add_document($_course, $created_dir.'/'.$f, 'file', filesize($coursePath.$created_dir.'/'.$f), $f);
if ($did)
api_item_property_update($_course, TOOL_DOCUMENT, $did, 'DocumentAdded', $user_id, 0, NULL);
}
}
echo '<html><body><script language="javascript">setTimeout(1000,window.close());</script></body></html>';
}
else if ($action == "service")

@ -31,7 +31,7 @@ abstract class OpenofficeDocument extends learnpath {
}
}
function convert_document($file){
function convert_document($file, $action_after_conversion='make_lp'){
global $_course, $_user, $_configuration;
@ -48,9 +48,11 @@ abstract class OpenofficeDocument extends learnpath {
//create the directory
$this->base_work_dir = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
$this->created_dir = create_unexisting_directory($_course,$_user['user_id'],0,0,$this->base_work_dir,$dir_name);
$visio_dir = ($action_after_conversion=='add_docs_to_visio')?VIDEOCONF_UPLOAD_PATH:'';
$this->created_dir = create_unexisting_directory($_course,$_user['user_id'],0,0,$this->base_work_dir,$visio_dir.$dir_name);
move_uploaded_file($file['tmp_name'],$this->base_work_dir.'/'.$this->file_path);
@ -76,14 +78,14 @@ abstract class OpenofficeDocument extends learnpath {
// call to the function implemented by child
$cmd .= $this -> add_command_parameters();
$cmd .= ' "'.$this->base_work_dir.'/'.$this->file_path.'" "'.$this->base_work_dir.$this->created_dir.'/'.$this->file_name.'.html"';
$cmd .= ' "'.$this->base_work_dir.'/'.$this->file_path.'" "'.$this->base_work_dir.$this->created_dir.'.html"';
// to allow openoffice to manipulate docs.
chmod ($this->base_work_dir.$this->created_dir,0777);
chmod($this->base_work_dir.'/'.$this->file_path,0777);
$shell = exec($cmd, $files, $return);
if($return != 0) { //if the java application returns an error code
DocumentManager::delete_document($_course, $dir_name, $this->base_work_dir);
@ -94,8 +96,14 @@ abstract class OpenofficeDocument extends learnpath {
// create lp
$this->lp_id = learnpath::add_lp($_course['id'], $this->file_name,'','guess','manual');
// call to the function implemented by child
$this -> make_lp($files);
// call to the function implemented by child following action_after_conversion parameter
switch ($action_after_conversion)
{
case 'make_lp':$this -> make_lp($files);
break;
case 'add_docs_to_visio':$this -> add_docs_to_visio($files);
break;
}
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:0770);
@ -106,6 +114,7 @@ abstract class OpenofficeDocument extends learnpath {
abstract function make_lp();
abstract function add_docs_to_visio();
abstract function add_command_parameters();

@ -45,7 +45,7 @@ class OpenofficePresentation extends OpenofficeDocument {
'<html>
<head></head>
<body>
<img src="'.api_get_path(REL_COURSE_PATH).$_course['path'].'/document/'.$this->created_dir.'/'.$this->file_name.'/'.$file.'" />
<img src="'.api_get_path(REL_COURSE_PATH).$_course['path'].'/document/'.$this->created_dir.'/'.$file.'" />
</body>
</html>');
fclose($fp);
@ -79,6 +79,20 @@ class OpenofficePresentation extends OpenofficeDocument {
return " -w $slide_width -h $slide_height -d oogie";
}
function add_docs_to_visio ($files=array()){
global $_course;
/* Add Files */
foreach($files as $f)
{
$did = add_document($_course, $this->created_dir.'/'.$f, 'file', filesize($this->base_work_dir.$this->created_dir.'/'.$f), $f);
if ($did)
api_item_property_update($_course, TOOL_DOCUMENT, $did, 'DocumentAdded', $_SESSION['_uid'], 0, NULL);
}
}
}

@ -246,6 +246,11 @@ class OpenOfficeTextDocument extends OpenofficeDocument {
return $content;
}
function add_docs_to_visio (){
}
}

Loading…
Cancel
Save