Extend skin_logo allowing per skin logos (#6273)

pull/6361/head
johndoh 6 years ago committed by Aleksander Machniak
parent 4224ccdaa9
commit 4ea790ba37

@ -379,8 +379,14 @@ $config['support_url'] = '';
// replace Roundcube logo with this image
// specify an URL relative to the document root of this Roundcube installation
// an array can be used to specify different logos for specific template files, '*' for default logo
// for example array("*" => "/images/roundcube_logo.png", "messageprint" => "/images/roundcube_logo_print.png")
// an array can be used to specify different logos for specific template files
// '*' for default logo
// ':favicon' for favicon
// ':print' for logo on all print templates (e.g. messageprint, contactprint)
// ':small' for small screen logo in Elastic
// different logos can be specified for different skins by prefixing the skin name to the array key
// config applied in order: <skin>:<template>, <skin>:*, <template>, *
// for example array("*" => "/images/roundcube_logo.png", "messageprint" => "/images/roundcube_logo_print.png", "elastic:*" => "/images/logo.png")
$config['skin_logo'] = null;
// automatically create a new Roundcube user when log-in the first time.

@ -36,6 +36,7 @@ class rcmail_output_html extends rcmail_output
protected $js_labels = array();
protected $js_commands = array();
protected $skin_paths = array();
protected $skin_name = '';
protected $scripts_path = '';
protected $script_files = array();
protected $css_files = array();
@ -259,6 +260,7 @@ EOF;
$this->skin_paths = array();
$this->load_skin($skin_path);
$this->skin_name = $skin;
$this->set_env('skin', $skin);
}
@ -1263,21 +1265,27 @@ EOF;
else if ($object == 'logo') {
$attrib += array('alt' => $this->xml_command(array('', 'object', 'name="productname"')));
if ($logo = $this->config->get('skin_logo')) {
if (is_array($logo)) {
if ($template_logo = $logo[$this->template_name]) {
$attrib['src'] = $template_logo;
}
elseif ($template_logo = $logo['*']) {
$attrib['src'] = $template_logo;
if (!empty($attrib['type']) && ($template_logo = $this->get_template_logo(':' . $attrib['type'], true)) !== null) {
$attrib['src'] = $template_logo;
}
else if (($template_logo = $this->get_template_logo()) !== null) {
$attrib['src'] = $template_logo;
}
// 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(':' . $matches[1], true)) !== null) {
$attrib[$key] = $template_logo;
}
}
else {
$attrib['src'] = $logo;
$attrib[$key] = !empty($attrib[$key]) ? $this->abs_url($attrib[$key]) : null;
}
}
$content = html::img($attrib);
if ($attrib['src']) {
$content = html::img($attrib);
}
}
else if ($object == 'productname') {
$name = $this->config->get('product_name', 'Roundcube Webmail');
@ -1323,6 +1331,14 @@ EOF;
$content = $this->frame($attrib, true);
}
else if ($object == 'favicon') {
if ($template_logo = $this->get_template_logo(':favicon', true)) {
$content = html::tag('link', array('rel' => 'shortcut icon', 'href' => $template_logo));
}
else if ($file = $this->config->get('favicon', '/images/favicon.ico')) {
$content = html::tag('link', array('rel' => 'shortcut icon', 'href' => $file));
}
}
// exec plugin hooks for this template object
$hook = $this->app->plugins->exec_hook("template_object_$object", $attrib + array('content' => $content));
@ -2309,4 +2325,51 @@ EOF;
return $content;
}
/**
* 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 boolean $strict True if logo should only be returned for specific template
*
* @return string image URL
*/
protected function get_template_logo($name = null, $strict = false)
{
$template_logo = null;
// Use current template if none provided
if (!$name) {
$name = $this->template_name;
}
$template_names = array(
$this->skin_name . ':' . $name,
$this->skin_name . ':*',
$name,
'*',
);
// If strict matching then remove wildcard options
if ($strict) {
$template_names = preg_grep("/\*$/", $template_names, PREG_GREP_INVERT);
}
if ($logo = $this->config->get('skin_logo')) {
if (is_array($logo)) {
foreach ($template_names as $key) {
if (isset($logo[$key])) {
$template_logo = $logo[$key];
break;
}
}
}
else {
$template_logo = $logo;
}
}
return $template_logo;
}
}

@ -1,5 +1,5 @@
<link rel="index" href="$__comm_path" />
<link rel="shortcut icon" href="/images/favicon.ico"/>
<roundcube:object name="favicon" doctype="html4" />
<link rel="stylesheet" type="text/css" href="/common.css" />
<roundcube:if condition="in_array(env:task, array('mail', 'addressbook', 'settings'))" />
<link rel="stylesheet" type="text/css" href="/<roundcube:var name="env:task" />.css" />

@ -2,12 +2,12 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><roundcube:object name="pagetitle" /></title>
<link rel="shortcut icon" href="/images/favicon.ico"/>
<roundcube:object name="favicon" doctype="html4" />
<link rel="stylesheet" type="text/css" href="/print.css" />
</head>
<body>
<roundcube:object name="logo" src="/images/roundcube_logo.png" id="logo" border="0" />
<roundcube:object name="logo" src="/images/roundcube_logo.png" id="logo" border="0" type="print" />
<div id="contact-details">
<div id="contactphoto"><roundcube:object name="contactphoto" id="contactpic" placeholder="/images/contactpic.png" placeholderGroup="/images/contactgroup.png" /></div>

@ -2,12 +2,12 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><roundcube:object name="pagetitle" /></title>
<link rel="shortcut icon" href="/images/favicon.ico"/>
<roundcube:object name="favicon" doctype="html4" />
<link rel="stylesheet" type="text/css" href="/print.css" />
</head>
<body>
<roundcube:object name="logo" src="/images/roundcube_logo.png" id="logo" border="0" />
<roundcube:object name="logo" src="/images/roundcube_logo.png" id="logo" border="0" type="print" />
<div id="printmessageframe">
<roundcube:object name="messageHeaders" class="headers-table" cellspacing="0" cellpadding="2" max="10" />

@ -199,7 +199,7 @@
img {
max-height: @layout-touch-header-height;
max-width: @layout-menu-width;
max-width: @layout-menu-width*2;
}
a {

@ -1,5 +1,7 @@
<roundcube:include file="includes/layout.html" />
<roundcube:object name="logo" id="logo" alt="Logo" type="print" class="float-sm-right" />
<div class="print-content formcontent" role="main">
<div class="contact-header">
<div id="contactphoto" class="contact-photo">

@ -14,7 +14,7 @@
<head>
<title><roundcube:object name="pagetitle" /></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no, maximum-scale=1.0" id="viewport">
<link rel="shortcut icon" href="/images/favicon.ico">
<roundcube:object name="favicon" />
<link rel="stylesheet" href="/deps/bootstrap.min.css">
<roundcube:if condition="config:devel_mode" />
<link rel="stylesheet/less" href="/styles/styles.less">

@ -1,7 +1,7 @@
<div class="menu">
<h2 id="aria-label-tasknav" class="voice"><roundcube:label name="arialabeltasknav" /></h2>
<div class="popover-header">
<roundcube:object name="logo" src="/images/logo.png" id="logo" alt="Logo" />
<roundcube:object name="logo" src="/images/logo.png" data-src-small="0" id="logo" alt="Logo" />
<a class="button icon cancel"><span class="inner"><roundcube:label name="close" /></span></a>
</div>
<div id="taskmenu" role="navigation" aria-labelledby="aria-label-tasknav">

@ -1,5 +1,7 @@
<roundcube:include file="includes/layout.html" />
<roundcube:object name="logo" id="logo" alt="Logo" type="print" class="float-sm-right" />
<div class="print-content" role="main">
<div id="message-header">
<h2 class="subject">

@ -326,6 +326,11 @@ function rcube_elastic_ui()
}
callback();
});
// Store default logo path if not already set
if (!$('#logo').data('src-default')) {
$('#logo').data('src-default', $('#logo').attr('src'));
}
};
/**
@ -1327,6 +1332,7 @@ function rcube_elastic_ui()
case 'large': screen_resize_large(); break;
}
screen_resize_logo(mode);
screen_resize_headers();
// On iOS and Android the content frame height is never correct, fix it
@ -1370,6 +1376,16 @@ function rcube_elastic_ui()
}
};
function screen_resize_logo(mode)
{
if (mode == 'phone' && $('#logo').data('src-small')) {
$('#logo').attr('src', $('#logo').data('src-small'));
}
else {
$('#logo').attr('src', $('#logo').data('src-default'));
}
}
/**
* Sets left and right margin to the header title element to make it
* properly centered depending on the number of buttons on both sides

@ -1,5 +1,5 @@
<meta name="viewport" content="" id="viewport" />
<link rel="shortcut icon" href="/images/favicon.ico"/>
<roundcube:object name="favicon" />
<link rel="stylesheet" type="text/css" href="/styles.css" />
<roundcube:if condition="in_array(env:task, array('mail','addressbook','settings'))" />
<link rel="stylesheet" type="text/css" href="/<roundcube:var name="env:task" />.css" />

@ -2,12 +2,12 @@
<html>
<head>
<title><roundcube:object name="pagetitle" /></title>
<link rel="shortcut icon" href="/images/favicon.ico"/>
<roundcube:object name="favicon" />
<link rel="stylesheet" type="text/css" href="/print.css" />
</head>
<body>
<div id="header"><roundcube:object name="logo" src="/images/roundcube_logo.png" id="toplogo" border="0" alt="Logo" /></div>
<div id="header"><roundcube:object name="logo" src="/images/roundcube_logo.png" id="toplogo" border="0" alt="Logo" type="print" /></div>
<div id="contact-details" class="boxcontent">
<div id="contactphoto"><roundcube:object name="contactphoto" id="contactpic" placeholder="/images/contactpic.png" placeholderGroup="/images/contactgroup.png" /></div>

@ -2,12 +2,12 @@
<html>
<head>
<title><roundcube:object name="pagetitle" /></title>
<link rel="shortcut icon" href="/images/favicon.ico"/>
<roundcube:object name="favicon" />
<link rel="stylesheet" type="text/css" href="/print.css" />
</head>
<body>
<div id="header"><roundcube:object name="logo" src="/images/roundcube_logo.png" id="toplogo" border="0" alt="Logo" /></div>
<div id="header"><roundcube:object name="logo" src="/images/roundcube_logo.png" id="toplogo" border="0" alt="Logo" type="print" /></div>
<div id="printmessageframe">
<roundcube:object name="messageHeaders" class="headers-table" max="10" />

Loading…
Cancel
Save