Skip to content
Snippets Groups Projects
Commit 27833958 authored by Anika Henke's avatar Anika Henke
Browse files

added tpl_getMediaFile() to replace tpl_getFavicon()

The function tpl_getFavicon() was doing more than its name was implying. Therefore the new tpl_getMediaFile() was introduced (which is doing nearly exactly the same) and tpl_getFavicon() was deprecated.
tpl_favicon() can still be used, though.
parent 91e90457
No related branches found
No related tags found
No related merge requests found
......@@ -50,7 +50,7 @@ $rss->cssStyleSheet = DOKU_URL.'lib/exe/css.php?s=feed';
$image = new FeedImage();
$image->title = $conf['title'];
$image->url = tpl_getFavicon(true);
$image->url = tpl_getMediaFile('favicon.ico', true);
$image->link = DOKU_URL;
$rss->image = $image;
......
......@@ -1458,16 +1458,15 @@ function tpl_flush(){
flush();
}
/**
* Returns icon from data/media root directory if it exists, otherwise
* the one in the template's image directory.
* Returns link to media file from data/media root directory if it exists,
* otherwise the one in the template's image directory.
*
* @param bool $abs - if to use absolute URL
* @param string $fileName - file name of icon
* @param bool $abs - if to use absolute URL
* @author Anika Henke <anika@selfthinker.org>
*/
function tpl_getFavicon($abs=false, $fileName='favicon.ico') {
function tpl_getMediaFile($fileName, $abs=false) {
if (file_exists(mediaFN($fileName))) {
return ml($fileName, '', true, '', $abs);
}
......@@ -1478,6 +1477,17 @@ function tpl_getFavicon($abs=false, $fileName='favicon.ico') {
return DOKU_TPL.'images/'.$fileName;
}
/**
* Returns icon from data/media root directory if it exists, otherwise
* the one in the template's image directory.
*
* @deprecated Use tpl_getMediaFile() instead
* @author Anika Henke <anika@selfthinker.org>
*/
function tpl_getFavicon($abs=false, $fileName='favicon.ico') {
return tpl_getMediaFile($fileName, $abs);
}
/**
* Returns <link> tag for various icon types (favicon|mobile|generic)
*
......@@ -1491,14 +1501,14 @@ function tpl_favicon($types=array('favicon')) {
foreach ($types as $type) {
switch($type) {
case 'favicon':
$return .= '<link rel="shortcut icon" href="'.tpl_getFavicon().'" />'.NL;
$return .= '<link rel="shortcut icon" href="'.tpl_getMediaFile('favicon.ico').'" />'.NL;
break;
case 'mobile':
$return .= '<link rel="apple-touch-icon" href="'.tpl_getFavicon(false, 'apple-touch-icon.png').'" />'.NL;
$return .= '<link rel="apple-touch-icon" href="'.tpl_getMediaFile('apple-touch-icon.png').'" />'.NL;
break;
case 'generic':
// ideal world solution, which doesn't work in any browser yet
$return .= '<link rel="icon" href="'.tpl_getFavicon(false, 'icon.svg').'" type="image/svg+xml" />'.NL;
$return .= '<link rel="icon" href="'.tpl_getMediaFile('icon.svg').'" type="image/svg+xml" />'.NL;
break;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment