From ffb611048868f3ae862f4dc29f9225030db2ec24 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sun, 20 Nov 2011 16:49:58 +0000 Subject: [PATCH] implemented latest tpl_favicon() --- main.php | 2 +- tpl_functions.php | 47 +++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/main.php b/main.php index 4af177c..b22cccc 100644 --- a/main.php +++ b/main.php @@ -19,7 +19,7 @@ $showTools = !tpl_getConf('hideTools') || ( tpl_getConf('hideTools') && $_SERVER <?php tpl_pagetitle() ?> [<?php echo strip_tags($conf['title']) ?>] - + 2011-07-31 can use the core function tpl_favicon() */ ?> diff --git a/tpl_functions.php b/tpl_functions.php index 54b143f..27e8b1c 100644 --- a/tpl_functions.php +++ b/tpl_functions.php @@ -110,18 +110,53 @@ function _tpl_action($type,$link=0,$wrapper=0) { } /** - * Use favicon.ico from data/media root directory if it exists, otherwise use + * Returns icon from data/media root directory if it exists, otherwise * the one in the template's image directory. - * DW versions > 2010-11-12 can use the core function tpl_getFavicon() * + * @param bool $abs - if to use absolute URL + * @param string $fileName - file name of icon * @author Anika Henke */ -function _tpl_getFavicon() { - if (file_exists(mediaFN('favicon.ico'))) - return ml('favicon.ico'); - return DOKU_TPL.'images/favicon.ico'; +function _tpl_getFavicon($abs=false, $fileName='favicon.ico') { + if (file_exists(mediaFN($fileName))) { + return ml($fileName, '', true, '', $abs); + } + + if($abs) { + return DOKU_URL.substr(DOKU_TPL.'images/'.$fileName, strlen(DOKU_REL)); + } + return DOKU_TPL.'images/'.$fileName; +} + +/** + * Returns tag for various icon types (favicon|mobile|generic) + * + * @param array $types - list of icon types to display (favicon|mobile|generic) + * @author Anika Henke + */ +function _tpl_favicon($types=array('favicon')) { + + $return = ''; + + foreach ($types as $type) { + switch($type) { + case 'favicon': + $return .= ''.NL; + break; + case 'mobile': + $return .= ''.NL; + break; + case 'generic': + // ideal world solution, which doesn't work in any browser yet + $return .= ''.NL; + break; + } + } + + return $return; } + /** * Include additional html file from conf directory if it exists, otherwise use * file in the template's root directory.