diff --git a/config/defaults.inc.php b/config/defaults.inc.php
index a747c7d04..c856bcb85 100644
--- a/config/defaults.inc.php
+++ b/config/defaults.inc.php
@@ -413,7 +413,7 @@ $config['support_url'] = '';
// show the image /images/logo_login.png for the Login screen in the Elastic skin
"elastic:login" => "/images/logo_login.png",
// show the image /images/logo_small.png in the Elastic skin
- "elastic[small]" => "/images/logo_small.png",
+ "elastic:*[small]" => "/images/logo_small.png",
// show the image /images/larry.png in the Larry skin
"larry:*" => "/images/larry.png",
// show the image /images/logo_login.png on the login template in all skins
diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php
index 05b18f8c1..ef66dd83d 100644
--- a/program/include/rcmail_output_html.php
+++ b/program/include/rcmail_output_html.php
@@ -1353,7 +1353,7 @@ EOF;
else if ($object == 'logo') {
$attrib += array('alt' => $this->xml_command(array('', 'object', 'name="productname"')));
- if (!empty($attrib['type']) && ($template_logo = $this->get_template_logo(null, $attrib['type'], true)) !== null) {
+ if (!empty($attrib['type']) && ($template_logo = $this->get_template_logo($attrib['type'])) !== null) {
$attrib['src'] = $template_logo;
}
else if (($template_logo = $this->get_template_logo()) !== null) {
@@ -1363,7 +1363,7 @@ EOF;
// process alternative logos (eg for Elastic small screen)
foreach ($attrib as $key => $value) {
if (preg_match('/data-src-(.*)/', $key, $matches)) {
- if (($template_logo = $this->get_template_logo(null, $matches[1], true)) !== null) {
+ if (($template_logo = $this->get_template_logo($matches[1])) !== null) {
$attrib[$key] = $template_logo;
}
@@ -1447,7 +1447,7 @@ EOF;
// special handling for favicon
if ($object == 'links' && $name == 'shortcut icon' && empty($args[$param])) {
- if ($href = $this->get_template_logo(null, 'favicon', true)) {
+ if ($href = $this->get_template_logo('favicon')) {
$args[$param] = $href;
}
else if ($href = $this->config->get('favicon', '/images/favicon.ico')) {
@@ -2447,50 +2447,43 @@ EOF;
/**
* Get logo URL for current template based on skin_logo config option
*
- * @param string $name Name of the logo to check for
- * default is current template
* @param string $type Type of the logo to check for (e.g. 'print' or 'small')
* default is null (no special type)
- * @param boolean $strict True if logo should only be returned for specific template
*
* @return string image URL
*/
- protected function get_template_logo($name = null, $type = null, $strict = false)
+ protected function get_template_logo($type = null)
{
$template_logo = null;
- // Use current template if none provided
- if (!$name) {
- $name = $this->template_name;
- }
-
- $template_names = array(
- $this->skin_name . ':' . $name . '[' . $type . ']',
- $this->skin_name . ':' . $name,
- $this->skin_name . ':*[' . $type . ']',
- $this->skin_name . ':*',
- $this->skin_name . '[' . $type . ']',
- '*:' . $name . '[' . $type . ']',
- '*:' . $name,
- $name . '[' . $type . ']',
- $name,
- '*[' . $type . ']',
- '*',
- '[' . $type . ']',
- );
-
- // If no type is specified then remove those options from the list
- if (empty($type)) {
- $template_names = preg_grep("/\\[\]$/", $template_names, PREG_GREP_INVERT);
- }
-
- // If strict matching then remove wild card options
- if ($strict) {
- $template_names = preg_grep("/\*$/", $template_names, PREG_GREP_INVERT);
- }
-
if ($logo = $this->config->get('skin_logo')) {
if (is_array($logo)) {
+ $template_names = array(
+ $this->skin_name . ':' . $this->template_name . '[' . $type . ']',
+ $this->skin_name . ':' . $this->template_name,
+ $this->skin_name . ':*[' . $type . ']',
+ $this->skin_name . ':[' . $type . ']',
+ $this->skin_name . ':*',
+ '*:' . $this->template_name . '[' . $type . ']',
+ '*:' . $this->template_name,
+ '*:*[' . $type . ']',
+ '*:[' . $type . ']',
+ $this->template_name . '[' . $type . ']',
+ $this->template_name,
+ '*[' . $type . ']',
+ '[' . $type . ']',
+ '*',
+ );
+
+ if (!empty($type)) {
+ // Use strict matching, remove wild card options
+ $template_names = preg_grep("/\*$/", $template_names, PREG_GREP_INVERT);
+ }
+ else {
+ // No type set so remove those options from the list
+ $template_names = preg_grep("/\\[\]$/", $template_names, PREG_GREP_INVERT);
+ }
+
foreach ($template_names as $key) {
if (isset($logo[$key])) {
$template_logo = $logo[$key];
diff --git a/tests/Rcmail/OutputHtml.php b/tests/Rcmail/OutputHtml.php
new file mode 100644
index 000000000..0aa24c9b4
--- /dev/null
+++ b/tests/Rcmail/OutputHtml.php
@@ -0,0 +1,147 @@
+getProperty('skin_name');
+ $set_template = $reflection->getProperty('template_name');
+ $get_template_logo = $reflection->getMethod('get_template_logo');
+
+ $set_skin->setAccessible(true);
+ $set_template->setAccessible(true);
+ $get_template_logo->setAccessible(true);
+
+ $set_skin->setValue($output, 'elastic');
+
+ $rcmail->config->set('skin_logo', 'img00');
+
+ $set_template->setValue($output, 'login');
+ $result = $get_template_logo->invokeArgs($output, array());
+ $this->assertSame('img00', $result);
+
+ $set_template->setValue($output, 'mail');
+ $result = $get_template_logo->invokeArgs($output, array('small'));
+ $this->assertSame('img00', $result);
+
+ $rcmail->config->set('skin_logo', array(
+ "elastic:login[small]" => "img01",
+ "elastic:login" => "img02",
+ "elastic:*[small]" => "img03",
+ "larry:*" => "img04",
+ "*:login[small]" => "img05",
+ "*:login" => "img06",
+ "*[print]" => "img07",
+ "*" => "img08",
+ ));
+
+ $set_template->setValue($output, 'login');
+ $result = $get_template_logo->invokeArgs($output, array('small'));
+ $this->assertSame('img01', $result);
+
+ $set_template->setValue($output, 'login');
+ $result = $get_template_logo->invokeArgs($output, array());
+ $this->assertSame('img02', $result);
+
+ $set_template->setValue($output, 'mail');
+ $result = $get_template_logo->invokeArgs($output, array('small'));
+ $this->assertSame('img03', $result);
+
+ $set_template->setValue($output, 'mail');
+ $result = $get_template_logo->invokeArgs($output, array());
+ $this->assertSame('img08', $result);
+
+ $set_template->setValue($output, 'mail');
+ $result = $get_template_logo->invokeArgs($output, array('small'));
+ $this->assertSame('img03', $result);
+
+ $set_template->setValue($output, '_test_');
+ $result = $get_template_logo->invokeArgs($output, array());
+ $this->assertSame('img08', $result);
+
+ $set_skin->setValue($output, 'larry');
+
+ $set_template->setValue($output, 'login');
+ $result = $get_template_logo->invokeArgs($output, array('small'));
+ $this->assertSame('img05', $result);
+
+ $set_template->setValue($output, 'login');
+ $result = $get_template_logo->invokeArgs($output, array());
+ $this->assertSame('img04', $result);
+
+ $set_template->setValue($output, '_test_');
+ $result = $get_template_logo->invokeArgs($output, array());
+ $this->assertSame('img04', $result);
+
+ $set_skin->setValue($output, '_test_');
+
+ $set_template->setValue($output, 'login');
+ $result = $get_template_logo->invokeArgs($output, array('small'));
+ $this->assertSame('img05', $result);
+
+ $set_template->setValue($output, 'login');
+ $result = $get_template_logo->invokeArgs($output, array());
+ $this->assertSame('img06', $result);
+
+ $set_template->setValue($output, '_test_');
+ $result = $get_template_logo->invokeArgs($output, array('print'));
+ $this->assertSame('img07', $result);
+
+ $set_template->setValue($output, '_test_');
+ $result = $get_template_logo->invokeArgs($output, array());
+ $this->assertSame('img08', $result);
+
+ $rcmail->config->set('skin_logo', array(
+ "elastic:login[small]" => "img09",
+ "elastic:login" => "img10",
+ "larry:*" => "img11",
+ "elastic[small]" => "img12",
+ "login[small]" => "img13",
+ "login" => "img14",
+ "[print]" => "img15",
+ "*" => "img16",
+ ));
+
+ $set_skin->setValue($output, 'elastic');
+
+ $set_template->setValue($output, 'login');
+ $result = $get_template_logo->invokeArgs($output, array('small'));
+ $this->assertSame('img09', $result);
+
+ $set_template->setValue($output, 'mail');
+ $result = $get_template_logo->invokeArgs($output, array('small'));
+ $this->assertSame(null, $result);
+
+ $set_skin->setValue($output, '_test_');
+
+ $set_template->setValue($output, 'login');
+ $result = $get_template_logo->invokeArgs($output, array('small'));
+ $this->assertSame('img13', $result);
+
+ $set_template->setValue($output, 'login');
+ $result = $get_template_logo->invokeArgs($output, array());
+ $this->assertSame('img14', $result);
+
+ $set_template->setValue($output, '_test_');
+ $result = $get_template_logo->invokeArgs($output, array('print'));
+ $this->assertSame('img15', $result);
+
+ $set_template->setValue($output, '_test_');
+ $result = $get_template_logo->invokeArgs($output, array('_test_'));
+ $this->assertSame(null, $result);
+
+ $set_template->setValue($output, '_test_');
+ $result = $get_template_logo->invokeArgs($output, array());
+ $this->assertSame('img16', $result);
+ }
+}
diff --git a/tests/phpunit.xml b/tests/phpunit.xml
index 8369d6ccc..1369b89c9 100644
--- a/tests/phpunit.xml
+++ b/tests/phpunit.xml
@@ -51,6 +51,7 @@
Framework/VCard.php
Framework/Washtml.php
MailFunc.php
+ Rcmail/OutputHtml.php
Rcmail/Rcmail.php