Create new meta and links template objects, replace favicon (#6611)

pull/6612/head
johndoh 5 years ago committed by Aleksander Machniak
parent fbdaab714b
commit 8f62aed866

@ -41,6 +41,8 @@ class rcmail_output_html extends rcmail_output
protected $script_files = array();
protected $css_files = array();
protected $scripts = array();
protected $meta_tags = array();
protected $link_tags = array('shortcut icon' => '');
protected $header = '';
protected $footer = '';
protected $body = '';
@ -348,6 +350,10 @@ EOF;
$this->app->load_language($_SESSION['language'], $texts);
}
}
// Use array_merge() here to allow for global default and extended skins
$this->meta_tags = array_merge($this->meta_tags, (array) $meta['meta']);
$this->link_tags = array_merge($this->link_tags, (array) $meta['links']);
}
/**
@ -1371,12 +1377,52 @@ 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 (in_array($object, array('meta', 'links'))) {
if ($object == 'meta') {
$source = 'meta_tags';
$tag = 'meta';
$key = 'name';
$param = 'content';
}
elseif ($object == 'links') {
$source = 'link_tags';
$tag = 'link';
$key = 'rel';
$param = 'href';
}
else if ($file = $this->config->get('favicon', '/images/favicon.ico')) {
$content = html::tag('link', array('rel' => 'shortcut icon', 'href' => $file));
foreach ($this->$source as $name => $vars) {
/*
$vars can be in many forms:
*) string
*) array('key' => 'val')
*) array(string, string)
*) array(array(), string)
*) array(array('key' => 'val'), array('key' => 'val'))
normalise this for processing by checking for string array keys
*/
$vars = is_array($vars) ? (count(array_filter(array_keys($vars), 'is_string')) > 0 ? array($vars) : $vars) : array($vars);
foreach ($vars as $args) {
// skip unset headers e.g. when extending a skin and removing a header defined in the parent
if ($args === false) {
continue;
}
$args = is_array($args) ? $args : array($param => $args);
// special handling for favicon
if ($object == 'links' && $name == 'shortcut icon' && empty($args[$param])) {
if ($href = $this->get_template_logo(':favicon', true)) {
$args[$param] = $href;
}
else if ($href = $this->config->get('favicon', '/images/favicon.ico')) {
$args[$param] = $href;
}
}
$content .= html::tag($tag, array($key => $name, 'nl' => true) + $args);
}
}
}

@ -1,9 +1,10 @@
<link rel="index" href="$__comm_path" />
<roundcube:object name="favicon" doctype="html4" />
<roundcube:object name="meta" />
<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" />
<roundcube:endif />
<roundcube:if condition="browser:safari" />
<link rel="stylesheet" type="text/css" href="/safari.css" />
<roundcube:endif />
<roundcube:endif />
<roundcube:object name="links" />

@ -9,5 +9,10 @@
"embed_css_location": "/styles/embed.css",
"editor_css_location": "/styles/embed.css",
"media_browser_css_location": "none"
},
"meta": {
"viewport": "width=device-width, initial-scale=1.0, shrink-to-fit=no, maximum-scale=1.0",
"theme-color": "#f4f4f4",
"msapplication-navbutton-color": "#f4f4f4"
}
}

@ -15,8 +15,7 @@
<roundcube:endif />
<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">
<roundcube:object name="favicon" />
<roundcube:object name="meta" />
<link rel="stylesheet" href="/deps/bootstrap.min.css">
<roundcube:if condition="config:devel_mode" />
<link rel="stylesheet/less" href="/styles/styles.less">
@ -26,6 +25,7 @@
<link rel="stylesheet" href="/styles/styles.css">
<roundcube:link rel="stylesheet" href="/styles/print.css" condition="env:action == 'print'" />
<roundcube:endif />
<roundcube:object name="links" />
</head>
<body class="task-<roundcube:exp expression="env:error_task ?: env:task ?: 'error'">">
<roundcube:if condition="!env:framed || env:extwin" />

@ -1,9 +1,10 @@
<meta name="viewport" content="" id="viewport" />
<roundcube:object name="favicon" />
<roundcube:object name="meta" />
<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" />
<roundcube:endif />
<roundcube:object name="links" />
<script type="text/javascript" src="/ui.js"></script>
<roundcube:add_label name="errortitle" />
<roundcube:add_label name="toggleadvancedoptions" />

Loading…
Cancel
Save