Internal: Fix platform logo included in PDF files generated - refs BT#21621

pull/5656/head
Angel Fernando Quiroz Campos 1 year ago
parent d76896cc3e
commit 54a820b0b6
No known key found for this signature in database
GPG Key ID: B284841AE3E562CD
  1. 67
      public/img/document/certificates/default.html
  2. 16
      public/main/inc/lib/pdf.lib.php
  3. 7
      public/main/inc/lib/template.lib.php
  4. 13
      public/main/my_space/lp_tracking.php
  5. 4
      public/main/template/default/my_space/pdf_export_student.html.twig
  6. 12
      public/plugin/buycourses/src/invoice.php
  7. 9
      src/CoreBundle/Component/Utils/ChamiloApi.php

@ -1 +1,66 @@
<html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <style type="text/css">a:visited { text-decoration: none;}a:hover { text-decoration: none; color: #f3840d;}a:active { text-decoration: none; color : #3757f7;}footer { background-color: #ED970E; background-image: url(/main/css/beeznest/images/bg-footer.gif); background-repeat:repeat-x; color:#ffffff;}body { background: #264878; }#certif-main { background: #fff; }#certif-header { background-image: url('../../../../main/css/chamilo/images/header-logo.png'); background-repeat: no-repeat; background-position: center;}</style> <style type="text/css"> body{margin:10px;}</style> <link type="text/css" href="./css/frames.css" rel="stylesheet" /> </head> <body dir="ltr"><div id="certif-main"><p style="text-align: center;">&nbsp;</p> <p style="text-align: center;">&nbsp;</p> <table border="0"> <tbody> <tr> <td width="150">&nbsp;</td> <td width="500" height="100" style="text-align: left;" id="certif-header">&nbsp;</td> <td width="150">&nbsp;((date_certificate))</td> </tr> <tr> <td height="300">&nbsp;</td> <td style="text-align: center;font-size: larger;">This document certifies that<br /> ((user_firstname)) ((user_lastname))<br /> has successfully passed the certification exam for the course<br /> ((course_title)) (((course_code)))</td> <td>&nbsp;</td> </tr> <tr> <td height="200">&nbsp;</td> <td style="text-align: center;"><p>- - - - - - - - - - - - - - - - - - -</p> <p>((teacher_firstname)) ((teacher_lastname))</p> <p>((gradebook_sitename)) - ((gradebook_institution))<br /> &nbsp;</p></td> <td>&nbsp;</td> </tr> </tbody> </table></div></body></html>
<!DOCTYPE html>
<html>
<head>
<title>Default certificate</title>
<met charset="utf-8">
<style>a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
color: #f3840d;
}
a:active {
text-decoration: none;
color: #3757f7;
}
body {
background: #264878;
}
#certif-main {
background: #fff;
}
#certif-header {
background-image: url('/themes/chamilo/images/header-logo.png');
background-repeat: no-repeat;
background-position: center;
}</style>
<style type="text/css"> body {
margin: 10px;
}</style>
</head>
<body dir="ltr">
<div id="certif-main"><p style="text-align: center;">&nbsp;</p>
<p style="text-align: center;">&nbsp;</p>
<table border="0">
<tbody>
<tr>
<td width="150">&nbsp;</td>
<td width="500" height="100" style="text-align: left;" id="certif-header">&nbsp;</td>
<td width="150">&nbsp;((date_certificate))</td>
</tr>
<tr>
<td height="300">&nbsp;</td>
<td style="text-align: center;font-size: larger;">This document certifies that<br /> ((user_firstname))
((user_lastname))<br /> has successfully passed the certification exam for the course<br /> ((course_title))
(((course_code)))
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="200">&nbsp;</td>
<td style="text-align: center;"><p>- - - - - - - - - - - - - - - - - - -</p>
<p>((teacher_firstname)) ((teacher_lastname))</p>
<p>((gradebook_sitename)) - ((gradebook_institution))<br /> &nbsp;</p></td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>

@ -399,7 +399,7 @@ class PDF
// Formatting the pdf
$courseInfo = api_get_course_info($courseCode);
self::format_pdf($courseInfo, $completeHeader, $disablePagination);
$this->format_pdf($courseInfo, $completeHeader, $disablePagination);
$document_html = preg_replace($clean_search, '', $document_html);
$document_html = str_replace('../../', '', $document_html);
@ -697,17 +697,15 @@ class PDF
}
}
$organization = ChamiloApi::getPlatformLogo('', [], true);
$logoSrc = Container::getThemeHelper()->getAssetBase64Encoded('images/header-logo.png');
// Use custom logo image.
$pdfLogo = api_get_setting('pdf_logo_header');
$pdfLogo = api_get_setting('platform.pdf_logo_header');
if ('true' === $pdfLogo) {
$visualTheme = api_get_visual_theme();
$img = api_get_path(SYS_CSS_PATH).'themes/'.$visualTheme.'/images/pdf_logo_header.png';
if (file_exists($img)) {
$organization = "<img src='$img'>";
}
$logoSrc = Container::getThemeHelper()->getAssetBase64Encoded('images/pdf_logo_header.png') ?: $logoSrc;
}
$organization = "<img src='$logoSrc'>";
$view = new Template('', false, false, false, true, false, false);
$view->assign('teacher_name', $teachers);
$view->assign('organization', $organization);
@ -789,7 +787,7 @@ class PDF
$this->pdf->SetHTMLFooter('');
} else {
if (empty($this->custom_header)) {
self::set_header($courseInfo);
$this->set_header($courseInfo);
} else {
$this->pdf->SetHTMLHeader($this->custom_header, 'E');
$this->pdf->SetHTMLHeader($this->custom_header, 'O');

@ -1269,7 +1269,12 @@ class Template
$portalImageMeta .= '<meta property="twitter:image:alt" content="'.$imageAlt.'" />'."\n";
}
} else {
$logo = ChamiloApi::getPlatformLogoPath($this->theme);
$logo = Container::getThemeHelper()->getThemeAssetUrl('images/header-logo.svg');
if (empty($logo)) {
$logo = Container::getThemeHelper()->getThemeAssetUrl('images/header-logo.png');
}
if (!empty($logo)) {
$portalImageMeta = '<meta property="og:image" content="'.$logo.'" />'."\n";
$portalImageMeta .= '<meta property="twitter:image" content="'.$logo.'" />'."\n";

@ -240,24 +240,15 @@ switch ($action) {
$pdf = new PDF('A4', 'P', ['margin_footer' => 4, 'top' => 40, 'bottom' => 25]);
$table = new HTML_Table(['class' => 'table', 'style' => 'display: block; margin-bottom: 50px;']);
$logo = ChamiloApi::getPlatformLogo(
api_get_visual_theme(),
[
'title' => '',
'style' => 'max-width:180px, margin-bottom: 100px;',
'id' => 'header-logo',
]
);
$table->setCellContents(0, 0, $logo);
$addLogo = (isset($_GET['add_logo']) && 1 === (int) $_GET['add_logo']);
if ($addLogo) {
$secondLogo = api_get_path(SYS_PATH).'custompages/url-images/'.api_get_current_access_url_id().'_url_image_2.png';
$logo2 = Display::img($secondLogo, null, ['style' => 'height:70px;']);
$table->setCellContents(0, 1, $logo2);
$table->setCellContents(0, 0, $logo2);
}
$table->setCellAttributes(0, 1, ['style' => 'display:block;float:right;text-align:right']);
$table->setCellAttributes(0, 0, ['style' => 'display:block;float:right;text-align:right']);
$pdf->set_custom_header($table->toHtml());
$background = api_get_path(SYS_PATH).'custompages/url-images/'.api_get_current_access_url_id().'_pdf_background.png';

@ -1,7 +1,3 @@
<div style="position: absolute; top: 30px; right: 50px;">
<img src="{{ _p.web_css_theme }}images/header-logo.png" width="200">
</div>
<h1 style="color:#000000; background-color:#fff;font-size: 22px; text-align: center; font-weight: bold; padding: 5px 10px;">
{{ title }}
</h1>

@ -39,18 +39,6 @@ $htmlText .= '<link rel="stylesheet" type="text/css" href="plugin.css">';
$htmlText .= '<link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_CSS_PATH).'base.css">';
$htmlText .= '<body>';
$organization = ChamiloApi::getPlatformLogo('', [], true);
// Use custom logo image.
$pdfLogo = api_get_setting('pdf_logo_header');
if ('true' === $pdfLogo) {
$visualTheme = api_get_visual_theme();
$img = api_get_path(SYS_CSS_PATH).'themes/'.$visualTheme.'/images/pdf_logo_header.png';
if (file_exists($img)) {
$organization = "<img src='$img'>";
}
}
$htmlText .= $organization;
// Seller and customer info
$htmlText .= '<table width="100%">';
$htmlText .= '<tr>';

@ -69,6 +69,8 @@ class ChamiloApi
/**
* Get the platform logo path.
*
* @deprecated
*
* @throws Exception
*/
public static function getPlatformLogoPath(
@ -152,7 +154,12 @@ class ChamiloApi
bool $getSysPath = false,
bool $forcedGetter = false
): string {
$logoPath = self::getPlatformLogoPath($theme, $getSysPath, $forcedGetter);
$logoPath = Container::getThemeHelper()->getThemeAssetUrl('images/header-logo.svg');
if (empty($logo)) {
$logoPath = Container::getThemeHelper()->getThemeAssetUrl('images/header-logo.png');
}
$institution = api_get_setting('Institution');
$institutionUrl = api_get_setting('InstitutionUrl');
$siteName = api_get_setting('siteName');

Loading…
Cancel
Save