summaryrefslogtreecommitdiff
path: root/inc/template.php
diff options
context:
space:
mode:
authorAnika Henke <anika@selfthinker.org>2012-04-07 14:31:39 -0700
committerAnika Henke <anika@selfthinker.org>2012-04-07 14:31:39 -0700
commitb7c3da9b00f3e44c08c89666e04f2d4de177c134 (patch)
tree0e601dd0b0c5ac87a4706449bb1f57b30a2edeee /inc/template.php
parent5d5aecf82831890f7a6df7874c798445996ebd8a (diff)
parentdbd59867496d5e3c5d37e9c3852db29a6a2370c4 (diff)
downloadrpg-b7c3da9b00f3e44c08c89666e04f2d4de177c134.tar.gz
rpg-b7c3da9b00f3e44c08c89666e04f2d4de177c134.tar.bz2
Merge pull request #82 from splitbrain/new-template
The new default template "dokuwiki", a new era has begun Thanks to Clarence Lee for the initial design, Anika Henke and Andreas Gohr for the hard work, Michael Hamann and Håkan Sandell for testing and many others for valuable feedback.
Diffstat (limited to 'inc/template.php')
-rw-r--r--inc/template.php56
1 files changed, 47 insertions, 9 deletions
diff --git a/inc/template.php b/inc/template.php
index 8ca6defeb..ab6aa925f 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -1348,31 +1348,33 @@ function tpl_actiondropdown($empty='',$button='&gt;'){
* @author Andreas Gohr <andi@splitbrain.org>
* @param string $img - print image? (|button|badge)
* @param bool $return - when true don't print, but return HTML
+ * @param bool $wrap - wrap in div with class="license"?
*/
-function tpl_license($img='badge',$imgonly=false,$return=false){
+function tpl_license($img='badge',$imgonly=false,$return=false,$wrap=true){
global $license;
global $conf;
global $lang;
if(!$conf['license']) return '';
if(!is_array($license[$conf['license']])) return '';
$lic = $license[$conf['license']];
+ $target = ($conf['target']['extern']) ? ' target="'.$conf['target']['extern'].'"' : '';
- $out = '<div class="license">';
+ $out = '';
+ if($wrap) $out .= '<div class="license">';
if($img){
$src = license_img($img);
if($src){
- $out .= '<a href="'.$lic['url'].'" rel="license"';
- if($conf['target']['extern']) $out .= ' target="'.$conf['target']['extern'].'"';
- $out .= '><img src="'.DOKU_BASE.$src.'" class="medialeft lic'.$img.'" alt="'.$lic['name'].'" /></a> ';
+ $out .= '<a href="'.$lic['url'].'" rel="license"'.$target;
+ $out .= '><img src="'.DOKU_BASE.$src.'" alt="'.$lic['name'].'" /></a>';
+ if(!$imgonly) $out .= ' ';
}
}
if(!$imgonly) {
- $out .= $lang['license'];
- $out .= ' <a href="'.$lic['url'].'" rel="license" class="urlextern"';
- if($conf['target']['extern']) $out .= ' target="'.$conf['target']['extern'].'"';
+ $out .= $lang['license'].' ';
+ $out .= '<a href="'.$lic['url'].'" rel="license" class="urlextern"'.$target;
$out .= '>'.$lic['name'].'</a>';
}
- $out .= '</div>';
+ if($wrap) $out .= '</div>';
if($return) return $out;
echo $out;
@@ -1523,6 +1525,42 @@ function tpl_getMediaFile($search, $abs=false, &$imginfo=null){
}
/**
+ * PHP include a file
+ *
+ * either from the conf directory if it exists, otherwise use
+ * file in the template's root directory.
+ *
+ * The function honours config cascade settings and looks for the given
+ * file next to the ´main´ config files, in the order protected, local,
+ * default.
+ *
+ * Note: no escaping or sanity checking is done here. Never pass user input
+ * to this function!
+ *
+ * @author Anika Henke <anika@selfthinker.org>
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function tpl_includeFile($file){
+ global $config_cascade;
+ foreach (array('protected','local','default') as $config_group) {
+ if (empty($config_cascade['main'][$config_group])) continue;
+ foreach ($config_cascade['main'][$config_group] as $conf_file) {
+ $dir = dirname($conf_file);
+ if(file_exists("$dir/$file")){
+ include("$dir/$file");
+ return;
+ }
+ }
+ }
+
+ // still here? try the template dir
+ $file = tpl_incdir().$file;
+ if(file_exists($file)){
+ include($file);
+ }
+}
+
+/**
* Returns icon from data/media root directory if it exists, otherwise
* the one in the template's image directory.
*