summaryrefslogtreecommitdiff
path: root/inc/template.php
diff options
context:
space:
mode:
authorlupo49 <post@lupo49.de>2011-08-22 19:11:18 +0200
committerlupo49 <post@lupo49.de>2011-08-22 19:11:18 +0200
commitd8f231b5162801fe333f899552b5808a83282634 (patch)
treef8021011b52502521eeff4f33e368628bb73ba89 /inc/template.php
parent8e5a3957cd8de15f48dc27e9c07dfe4033fd6997 (diff)
parent1c5f7481f4e685ad3ffe9ba48ed47ed75196e64a (diff)
downloadrpg-d8f231b5162801fe333f899552b5808a83282634.tar.gz
rpg-d8f231b5162801fe333f899552b5808a83282634.tar.bz2
Merge remote branch 'upstream/master'
Diffstat (limited to 'inc/template.php')
-rw-r--r--inc/template.php41
1 files changed, 35 insertions, 6 deletions
diff --git a/inc/template.php b/inc/template.php
index a476e78ab..5184929b8 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -1340,21 +1340,50 @@ function tpl_flush(){
/**
- * 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.
*
+ * @param bool $abs - if to use absolute URL
+ * @param string $fileName - file name of icon
* @author Anika Henke <anika@selfthinker.org>
*/
-function tpl_getFavicon($abs=false) {
- if (file_exists(mediaFN('favicon.ico'))) {
- return ml('favicon.ico', '', true, '', $abs);
+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/favicon.ico', strlen(DOKU_REL));
+ return DOKU_URL.substr(DOKU_TPL.'images/'.$fileName, strlen(DOKU_REL));
+ }
+ return DOKU_TPL.'images/'.$fileName;
+}
+
+/**
+ * Returns <link> tag for various icon types (favicon|mobile|generic)
+ *
+ * @param array $types - list of icon types to display (favicon|mobile|generic)
+ * @author Anika Henke <anika@selfthinker.org>
+ */
+function tpl_favicon($types=array('favicon')) {
+
+ $return = '';
+
+ foreach ($types as $type) {
+ switch($type) {
+ case 'favicon':
+ $return .= '<link rel="shortcut icon" href="'.tpl_getFavicon().'" />'.NL;
+ break;
+ case 'mobile':
+ $return .= '<link rel="apple-touch-icon" href="'.tpl_getFavicon(false, '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;
+ break;
+ }
}
- return DOKU_TPL.'images/favicon.ico';
+ return $return;
}