Fixing watermark issues see BT#2027

skala
Julio Montoya 15 years ago
parent 62ac918f65
commit dbddca0dfd
  1. 2
      main/admin/settings.php
  2. 23
      main/course_info/infocours.php
  3. 34
      main/inc/lib/pdf.lib.php

@ -374,7 +374,7 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
$url = PDF::get_watermark($course_code);
$form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark'));
if ($url != false) {
$delete_url = '<a href="?delete_watermark">'.Display::return_icon('delete.gif',get_lang('DelImage'), get_lang('DelImage')).'</a>';
$delete_url = '<a href="?delete_watermark">'.Display::return_icon('delete.png',get_lang('DelImage')).'</a>';
$form->addElement('html', '<a href="'.$url.'">'.$url.' '.$delete_url.'</a>');
}
$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');

@ -56,6 +56,16 @@ if (!$is_allowedToEdit) {
api_not_allowed(true);
}
$show_delete_watermark_text_message = false;
if (api_get_setting('pdf_export_watermark_by_course') == 'true') {
if (isset($_GET['delete_watermark'])) {
PDF::delete_watermark($course_code);
$show_delete_watermark_text_message = true;
}
}
$table_course_category = Database :: get_main_table(TABLE_MAIN_CATEGORY);
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$tbl_admin = Database :: get_main_table(TABLE_MAIN_ADMIN);
@ -138,11 +148,11 @@ $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
$form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
if (api_get_setting('pdf_export_watermark_by_course') == 'true') {
$url = PDF::get_watermark($course_code);
$form->add_textfield('pdf_export_watermark_text', get_lang('PDFWaterMarkHeader'), false, array('size' => '60'));
$url = PDF::get_watermark($course_code);
$form->add_textfield('pdf_export_watermark_text', get_lang('PDFExportWatermarkTextTitle'), false, array('size' => '60'));
$form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark'));
if ($url != false) {
$delete_url = '<a href="?delete_watermark">'.Display::return_icon('delete.gif',get_lang('DelImage'), get_lang('DelImage')).'</a>';
if ($url != false) {
$delete_url = '<a href="?delete_watermark">'.Display::return_icon('delete.png',get_lang('DelImage')).'</a>';
$form->addElement('html', '<div class="row"><div class="formw"><a href="'.$url.'">'.$url.' '.$delete_url.'</a></div></div>');
}
$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
@ -378,12 +388,9 @@ if ($form->validate() && is_settings_editable()) {
/* Header */
Display :: display_header($nameTools, MODULE_HELP_NAME);
if (isset($_GET['delete_watermark'])) {
PDF::delete_watermark($course_code);
if ($show_delete_watermark_text_message) {
Display :: display_normal_message(get_lang('FileDeleted'));
}
//api_display_tool_title($nameTools);
if (isset($_GET['action']) && $_GET['action'] == 'show_message') {
Display :: display_normal_message(get_lang('ModifDone'));

@ -249,13 +249,9 @@ class PDF {
$web_path = false;
if (!empty($course_code) && api_get_setting('pdf_export_watermark_by_course') == 'true') {
$course_info = api_get_course_info($course_code);
$store_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/pdf_watermark.png'; // course path
$store_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path
if (file_exists($store_path)) {
$web_path = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/pdf_watermark.png';
} else {
$store_path = api_get_path(SYS_CODE_PATH).'default_course_document/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path
if (file_exists($store_path))
$web_path = api_get_path(WEB_CODE_PATH).'default_course_document/'.api_get_current_access_url_id().'_pdf_watermark.png';
$web_path = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png';
}
} else {
$store_path = api_get_path(SYS_CODE_PATH).'default_course_document/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path
@ -274,7 +270,7 @@ class PDF {
public function delete_watermark($course_code = null) {
if (!empty($course_code) && api_get_setting('pdf_export_watermark_by_course') == 'true') {
$course_info = api_get_course_info($course_code);
$store_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/pdf_watermark.png'; // course path
$store_path = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path
} else {
$store_path = api_get_path(SYS_CODE_PATH).'default_course_document/'.api_get_current_access_url_id().'_pdf_watermark.png'; // course path
}
@ -292,7 +288,7 @@ class PDF {
if (!empty($course_code) && api_get_setting('pdf_export_watermark_by_course') == 'true') {
$course_info = api_get_course_info($course_code);
$store_path = api_get_path(SYS_COURSE_PATH).$course_info['path']; // course path
$web_path = api_get_path(WEB_COURSE_PATH).$course_info['path'].'pdf_watermark.png';
$web_path = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/pdf_watermark.png';
} else {
$store_path = api_get_path(SYS_CODE_PATH).'default_course_document'; // course path
$web_path = api_get_path(WEB_CODE_PATH).'default_course_document/'.api_get_current_access_url_id().'_pdf_watermark.png';
@ -432,15 +428,29 @@ class PDF {
//Adding watermark
if (api_get_setting('pdf_export_watermark_enable') == 'true') {
$watermark_file = self::get_watermark($course_code);
if (!empty($watermark_file)) {
$watermark_file = self::get_watermark($course_code);
if ($watermark_file) {
//http://mpdf1.com/manual/index.php?tid=269&searchstring=watermark
$this->pdf->SetWatermarkImage($watermark_file);
$this->pdf->showWatermarkImage = true;
} else {
$watermark_file = self::get_watermark(null);
if ($watermark_file) {
$this->pdf->SetWatermarkImage($watermark_file);
$this->pdf->showWatermarkImage = true;
}
}
if ($course_code) {
$watermark_text = api_get_course_setting('pdf_export_watermark_text');
if (empty($watermark_text)) {
$watermark_text = api_get_setting('pdf_export_watermark_text');
}
} else {
$watermark_text = api_get_setting('pdf_export_watermark_text');
}
$watermark_text = api_get_setting('pdf_export_watermark_text');
if (!empty($watermark_text)) {
$this->pdf->SetWatermarkText(strcode2utf($watermark_text));
$this->pdf->SetWatermarkText(strcode2utf($watermark_text),0.1);
$this->pdf->showWatermarkText = true;
}
}

Loading…
Cancel
Save