Browse Source

Merge pull request #1347 from jloguercio/1.11.x

Added custom logo to mails and pdf export header - Refs BT#11486
José Loguercio 8 years ago
parent
commit
ff9faa6e4a
3 changed files with 13 additions and 7 deletions
  1. 10 4
      main/inc/lib/pdf.lib.php
  2. 2 0
      main/inc/lib/template.lib.php
  3. 1 3
      main/template/default/mail/header.tpl

+ 10 - 4
main/inc/lib/pdf.lib.php

@@ -87,16 +87,22 @@ class PDF
         } else {
             $tpl = $this->template;
         }
-        // Assignments
+
+        $theme = api_get_visual_theme();
+
         // Assignments
         $tpl->assign('pdf_content', $content);
 
         $organization = api_get_setting('Institution');
-        $img = api_get_path(SYS_CSS_PATH).'themes/'.api_get_visual_theme().'/images/header-logo.png';
+        $img = api_get_path(SYS_CSS_PATH).'themes/' . $theme . '/images/header-logo.png';
+        $customImg = api_get_path(SYS_PUBLIC_PATH).'css/themes/' . $theme . '/images/header-logo-custom.png';
 
         // Search for classic logo
-        if (file_exists($img)) {
-            $img = api_get_path(WEB_CSS_PATH).'themes/'.api_get_visual_theme().'/images/header-logo.png';
+        if (file_exists($customImg)) {
+            $img = api_get_path(WEB_CSS_PATH).'themes/' . $theme . '/images/header-logo-custom.png';
+            $organization = "<img src='$img'>";
+        } else if (file_exists($img)) {
+            $img = api_get_path(WEB_CSS_PATH).'themes/' . $theme . '/images/header-logo.png';
             $organization = "<img src='$img'>";
         } else {
             // Just use the platform title.

+ 2 - 0
main/inc/lib/template.lib.php

@@ -124,6 +124,7 @@ class Template
         $this->twig->addFilter('get_path', new Twig_Filter_Function('api_get_path'));
         $this->twig->addFilter('get_setting', new Twig_Filter_Function('api_get_setting'));
         $this->twig->addFilter('var_dump', new Twig_Filter_Function('var_dump'));
+        $this->twig->addFilter('return_logo', new Twig_Filter_Function('return_logo'));
         $this->twig->addFilter('return_message', new Twig_Filter_Function('Display::return_message_and_translate'));
         $this->twig->addFilter('display_page_header', new Twig_Filter_Function('Display::page_header_and_translate'));
         $this->twig->addFilter(
@@ -221,6 +222,7 @@ class Template
     {
         return Display::return_icon($image, $name, array(), $size);
     }
+
     /**
      * @param string $timestamp
      * @param string $format

+ 1 - 3
main/template/default/mail/header.tpl

@@ -1,9 +1,7 @@
 <table border="0" cellpadding="10" cellspacing="0" width="100%">
     <tr>
         <td width="245">
-            <a href="{{ _p.web }}">
-                <img src="{{ _p.web_css_theme ~ 'images/header-logo.png' }}" alt="{{ _s.site_name }}">
-            </a>
+            {{ css_styles | return_logo }}
         </td>
         <td width="100%">
             &nbsp;