|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
<?php |
|
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Defines the OpenOfficeDocument class, which is meant as a conversion |
|
|
|
|
* tool from Office text documents (.doc, .sxw, .odt, .docx) to |
|
|
|
@ -15,11 +16,12 @@ require_once 'openoffice_document.class.php'; |
|
|
|
|
require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
|
|
|
require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'; |
|
|
|
|
require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php'; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @package chamilo.learnpath.openofficedocument |
|
|
|
|
*/ |
|
|
|
|
class OpenOfficeTextDocument extends OpenofficeDocument { |
|
|
|
|
|
|
|
|
|
class OpenOfficeTextDocument extends OpenofficeDocument |
|
|
|
|
{ |
|
|
|
|
public $split_steps; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -30,8 +32,13 @@ class OpenOfficeTextDocument extends OpenofficeDocument { |
|
|
|
|
* @param integer Creator user id |
|
|
|
|
* @return void |
|
|
|
|
*/ |
|
|
|
|
public function __construct($split_steps = false, $course_code = null, $resource_id = null, $user_id = null) { |
|
|
|
|
$this -> split_steps = $split_steps; |
|
|
|
|
public function __construct( |
|
|
|
|
$split_steps = false, |
|
|
|
|
$course_code = null, |
|
|
|
|
$resource_id = null, |
|
|
|
|
$user_id = null |
|
|
|
|
) { |
|
|
|
|
$this->split_steps = $split_steps; |
|
|
|
|
parent::__construct($course_code, $resource_id, $user_id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -44,7 +51,9 @@ class OpenOfficeTextDocument extends OpenofficeDocument { |
|
|
|
|
{ |
|
|
|
|
$_course = api_get_course_info(); |
|
|
|
|
// We get a content where ||page_break|| indicates where the page is broken. |
|
|
|
|
if (!file_exists($this->base_work_dir.'/'.$this->created_dir.'/'.$this->file_name.'.html')) { return false; } |
|
|
|
|
if (!file_exists($this->base_work_dir.'/'.$this->created_dir.'/'.$this->file_name.'.html')) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
$content = file_get_contents($this->base_work_dir.'/'.$this->created_dir.'/'.$this->file_name.'.html'); |
|
|
|
|
|
|
|
|
|
unlink($this->base_work_dir.'/'.$this->file_path); |
|
|
|
@ -71,7 +80,9 @@ class OpenOfficeTextDocument extends OpenofficeDocument { |
|
|
|
|
|
|
|
|
|
// Chamilo styles. |
|
|
|
|
$my_style = api_get_setting('stylesheets'); |
|
|
|
|
if (empty($my_style)) { $my_style = 'chamilo'; } |
|
|
|
|
if (empty($my_style)) { |
|
|
|
|
$my_style = 'chamilo'; |
|
|
|
|
} |
|
|
|
|
$style_to_import = "<style type=\"text/css\">\r\n"; |
|
|
|
|
$style_to_import .= '@import "'.api_get_path(WEB_CODE_PATH).'css/'.$my_style.'/default.css";'."\n"; |
|
|
|
|
$style_to_import .= "</style>\r\n"; |
|
|
|
@ -98,10 +109,9 @@ class OpenOfficeTextDocument extends OpenofficeDocument { |
|
|
|
|
* @param string Content |
|
|
|
|
* @return void |
|
|
|
|
*/ |
|
|
|
|
function dealPerChapter($header, $content) |
|
|
|
|
public function dealPerChapter($header, $content) |
|
|
|
|
{ |
|
|
|
|
$_course = api_get_course_info(); |
|
|
|
|
|
|
|
|
|
$content = str_replace('||page_break||', '', $content); |
|
|
|
|
|
|
|
|
|
// Get all the h1. |
|
|
|
@ -122,9 +132,9 @@ class OpenOfficeTextDocument extends OpenofficeDocument { |
|
|
|
|
$items_to_create[get_lang('Introduction')] = $intro_content; |
|
|
|
|
|
|
|
|
|
for ($i = 0; $i < count($matches[0]); $i++) { |
|
|
|
|
|
|
|
|
|
if (empty($matches[1][$i])) |
|
|
|
|
if (empty($matches[1][$i])) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$content = api_strstr($content, $matches[0][$i]); |
|
|
|
|
if ($i + 1 !== count($matches[0])) { |
|
|
|
@ -155,7 +165,6 @@ class OpenOfficeTextDocument extends OpenofficeDocument { |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if ($document_id) { |
|
|
|
|
|
|
|
|
|
// Put the document in item_property update. |
|
|
|
|
api_item_property_update( |
|
|
|
|
$_course, |
|
|
|
@ -188,20 +197,20 @@ class OpenOfficeTextDocument extends OpenofficeDocument { |
|
|
|
|
* @param string Page body |
|
|
|
|
* @return void |
|
|
|
|
*/ |
|
|
|
|
function dealPerPage($header, $body) |
|
|
|
|
public function dealPerPage($header, $body) |
|
|
|
|
{ |
|
|
|
|
$_course = api_get_course_info(); |
|
|
|
|
// Split document to pages. |
|
|
|
|
$pages = explode('||page_break||', $body); |
|
|
|
|
|
|
|
|
|
$first_item = 0; |
|
|
|
|
|
|
|
|
|
foreach ($pages as $key => $page_content) { |
|
|
|
|
// For every pages, we create a new file. |
|
|
|
|
|
|
|
|
|
$key += 1; |
|
|
|
|
|
|
|
|
|
$page_content = $this->format_page_content($header, $page_content, $this->base_work_dir.$this->created_dir); |
|
|
|
|
$page_content = $this->format_page_content( |
|
|
|
|
$header, |
|
|
|
|
$page_content, |
|
|
|
|
$this->base_work_dir.$this->created_dir |
|
|
|
|
); |
|
|
|
|
$html_file = $this->created_dir.'-'.$key.'.html'; |
|
|
|
|
$handle = fopen($this->base_work_dir.$this->created_dir.'/'.$html_file, 'w+'); |
|
|
|
|
fwrite($handle, $page_content); |
|
|
|
@ -243,7 +252,7 @@ class OpenOfficeTextDocument extends OpenofficeDocument { |
|
|
|
|
//echo Display::return_message(print_r($_POST)); |
|
|
|
|
$di = new ChamiloIndexer(); |
|
|
|
|
isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english'; |
|
|
|
|
$di->connectDb(NULL, NULL, $lang); |
|
|
|
|
$di->connectDb(null, null, $lang); |
|
|
|
|
$ic_slide = new IndexableChunk(); |
|
|
|
|
$ic_slide->addValue('title', $slide_name); |
|
|
|
|
$specific_fields = get_specific_field_list(); |
|
|
|
@ -294,7 +303,8 @@ class OpenOfficeTextDocument extends OpenofficeDocument { |
|
|
|
|
* Returns additional Java command parameters |
|
|
|
|
* @return string The additional parameters to be used in the Java call |
|
|
|
|
*/ |
|
|
|
|
function add_command_parameters() { |
|
|
|
|
public function add_command_parameters() |
|
|
|
|
{ |
|
|
|
|
return ' -d woogie "'.$this->base_work_dir.'/'.$this->file_path.'" "'.$this->base_work_dir.$this->created_dir.'/'.$this->file_name.'.html"'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -304,8 +314,8 @@ class OpenOfficeTextDocument extends OpenofficeDocument { |
|
|
|
|
* @param string Page content |
|
|
|
|
* @return string Formatted page content |
|
|
|
|
*/ |
|
|
|
|
function format_page_content($header, $content) { |
|
|
|
|
|
|
|
|
|
public function format_page_content($header, $content) |
|
|
|
|
{ |
|
|
|
|
// Limit the width of the doc. |
|
|
|
|
list($max_width, $max_height) = explode('x', api_get_setting('service_ppt2lp', 'size')); |
|
|
|
|
|
|
|
|
@ -330,7 +340,6 @@ class OpenOfficeTextDocument extends OpenofficeDocument { |
|
|
|
|
$defined_width = preg_match("|width=([^\s]*)|i", $images[0][$key], $img_width); |
|
|
|
|
$img_width = $img_width[1]; |
|
|
|
|
if (!$defined_width) { |
|
|
|
|
|
|
|
|
|
$image_size = api_getimagesize($this->base_work_dir.$this->created_dir.'/'.$image); |
|
|
|
|
$img_width = $image_size['width']; |
|
|
|
|
$img_height = $image_size['height']; |
|
|
|
@ -340,7 +349,6 @@ class OpenOfficeTextDocument extends OpenofficeDocument { |
|
|
|
|
$picture_resized = str_ireplace('<img', '<img width="'.$new_width.'" ', $images[0][$key]); |
|
|
|
|
$content = str_replace($images[0][$key], $picture_resized, $content); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} elseif ($img_width > $max_width - 10) { |
|
|
|
|
$picture_resized = str_ireplace('width='.$img_width, 'width="'.($max_width - 10).'"', $images[0][$key]); |
|
|
|
|
$content = str_replace($images[0][$key], $picture_resized, $content); |
|
|
|
@ -353,7 +361,8 @@ class OpenOfficeTextDocument extends OpenofficeDocument { |
|
|
|
|
/** |
|
|
|
|
* Add documents to the visioconference (to be implemented) |
|
|
|
|
*/ |
|
|
|
|
function add_docs_to_visio() { |
|
|
|
|
public function add_docs_to_visio() |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|