rewrite skin_logo config

pull/6983/head
PhilW 5 years ago
parent ad5a22b9c1
commit 0ae3823853

@ -393,13 +393,35 @@ $config['support_url'] = '';
// replace Roundcube logo with this image // replace Roundcube logo with this image
// specify an URL relative to the document root of this Roundcube installation // 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 // an array can be used to specify different logos for specific template files
// '*' for default logo // the array key specifies the template(s) the logo should be applied to while the
// ':favicon' for favicon // value should be the relative URL of the image.
// ':print' for logo on all print templates (e.g. messageprint, contactprint) //
// ':small' for small screen logo in Elastic // the array key is made up of (up to) 3 parts:
// different logos can be specified for different skins by prefixing the skin name to the array key // the skin name (optional)
// config applied in order: <skin>:<template>, <skin>:*, <template>, * // the template name (or * for all templates)
// for example array("*" => "/images/roundcube_logo.png", "messageprint" => "/images/roundcube_logo_print.png", "elastic:*" => "/images/logo.png") // the logo type (optional) the type attribute is used for logos used on multiple templates
// the available types include '[favicon]' for favicon, '[print]' for logo on all print
// templates (e.g. messageprint, contactprint) and '[small]' for small screen logo in supported skins
//
// config applied in order: <skin>:<template>, <skin>:<template>, <skin>:*, <template>, *
/*
* example config for skin_logo
*
array(
// show the image /images/logo_login_small.png for the Login screen in the Elastic skin on small screens
"elastic:login[small]" => "/images/logo_login_small.png",
// 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",
// 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
"login" => "/images/logo_login.png",
// show the image /images/logo_print.png for all print type logos in all skins
"[print]" => "/images/logo_print.png",
);
*/
$config['skin_logo'] = null; $config['skin_logo'] = null;
// automatically create a new Roundcube user when log-in the first time. // automatically create a new Roundcube user when log-in the first time.

@ -1353,7 +1353,7 @@ EOF;
else if ($object == 'logo') { else if ($object == 'logo') {
$attrib += array('alt' => $this->xml_command(array('', 'object', 'name="productname"'))); $attrib += array('alt' => $this->xml_command(array('', 'object', 'name="productname"')));
if (!empty($attrib['type']) && ($template_logo = $this->get_template_logo(':' . $attrib['type'], true)) !== null) { if (!empty($attrib['type']) && ($template_logo = $this->get_template_logo(null, $attrib['type'], true)) !== null) {
$attrib['src'] = $template_logo; $attrib['src'] = $template_logo;
} }
else if (($template_logo = $this->get_template_logo()) !== null) { else if (($template_logo = $this->get_template_logo()) !== null) {
@ -1363,7 +1363,7 @@ EOF;
// process alternative logos (eg for Elastic small screen) // process alternative logos (eg for Elastic small screen)
foreach ($attrib as $key => $value) { foreach ($attrib as $key => $value) {
if (preg_match('/data-src-(.*)/', $key, $matches)) { if (preg_match('/data-src-(.*)/', $key, $matches)) {
if (($template_logo = $this->get_template_logo(':' . $matches[1], true)) !== null) { if (($template_logo = $this->get_template_logo(null, $matches[1], true)) !== null) {
$attrib[$key] = $template_logo; $attrib[$key] = $template_logo;
} }
@ -1447,7 +1447,7 @@ EOF;
// special handling for favicon // special handling for favicon
if ($object == 'links' && $name == 'shortcut icon' && empty($args[$param])) { if ($object == 'links' && $name == 'shortcut icon' && empty($args[$param])) {
if ($href = $this->get_template_logo(':favicon', true)) { if ($href = $this->get_template_logo(null, 'favicon', true)) {
$args[$param] = $href; $args[$param] = $href;
} }
else if ($href = $this->config->get('favicon', '/images/favicon.ico')) { else if ($href = $this->config->get('favicon', '/images/favicon.ico')) {
@ -2449,11 +2449,13 @@ EOF;
* *
* @param string $name Name of the logo to check for * @param string $name Name of the logo to check for
* default is current template * 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 * @param boolean $strict True if logo should only be returned for specific template
* *
* @return string image URL * @return string image URL
*/ */
protected function get_template_logo($name = null, $strict = false) protected function get_template_logo($name = null, $type = null, $strict = false)
{ {
$template_logo = null; $template_logo = null;
@ -2463,12 +2465,25 @@ EOF;
} }
$template_names = array( $template_names = array(
$this->skin_name . ':' . $name . '[' . $type . ']',
$this->skin_name . ':' . $name, $this->skin_name . ':' . $name,
$this->skin_name . ':*[' . $type . ']',
$this->skin_name . ':*', $this->skin_name . ':*',
$this->skin_name . '[' . $type . ']',
'*:' . $name . '[' . $type . ']',
'*:' . $name,
$name . '[' . $type . ']',
$name, $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 matching then remove wild card options
if ($strict) { if ($strict) {
$template_names = preg_grep("/\*$/", $template_names, PREG_GREP_INVERT); $template_names = preg_grep("/\*$/", $template_names, PREG_GREP_INVERT);

Loading…
Cancel
Save