From 80083a41ce7a4ccf3132621757c333c535179dbe Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 10 Mar 2012 17:25:02 +0100 Subject: made tpl_license a bit more flexible This way there's less custom code for the footer buttons needed --- inc/template.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index c23fd14c1..02e039b2d 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1350,8 +1350,9 @@ function tpl_actiondropdown($empty='',$button='>'){ * @author Andreas Gohr * @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; @@ -1359,22 +1360,29 @@ function tpl_license($img='badge',$imgonly=false,$return=false){ if(!is_array($license[$conf['license']])) return ''; $lic = $license[$conf['license']]; - $out = '
'; + $out = ''; + if($wrap) $out .= '
'; if($img){ $src = license_img($img); if($src){ + if(!$imgonly){ + $left = 'medialeft'; + }else{ + $left = ''; + } + $out .= ' '; + $out .= '>'.$lic['name'].' '; } } if(!$imgonly) { $out .= $lang['license']; - $out .= ' '; } - $out .= '
'; + if($wrap) $out .= '
'; if($return) return $out; echo $out; -- cgit v1.2.3 From 53e15c8ba5cc2fd8ac7ed5a7f8dd4df684dba28a Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sat, 10 Mar 2012 20:58:38 +0000 Subject: improved tpl_license() (removed unnecessary class, fixed space issues) --- inc/template.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index 02e039b2d..37848b59a 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1359,27 +1359,21 @@ function tpl_license($img='badge',$imgonly=false,$return=false,$wrap=true){ if(!$conf['license']) return ''; if(!is_array($license[$conf['license']])) return ''; $lic = $license[$conf['license']]; + $target = ($conf['target']['extern']) ? ' target="'.$conf['target']['extern'].'"' : ''; $out = ''; if($wrap) $out .= '
'; if($img){ $src = license_img($img); if($src){ - if(!$imgonly){ - $left = 'medialeft'; - }else{ - $left = ''; - } - - $out .= ' '; + $out .= ''; + if(!$imgonly) $out .= ' '; } } if(!$imgonly) { - $out .= $lang['license']; - $out .= ''; } if($wrap) $out .= '
'; -- cgit v1.2.3 From e5d4768d27336a3af2fc36af663d21a1a57d0ee1 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 7 Apr 2012 20:20:22 +0200 Subject: added tpl_includeFile() to core --- inc/template.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index 37848b59a..edf3ca3fb 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1526,6 +1526,42 @@ function tpl_getMediaFile($search, $abs=false, &$imginfo=null){ return $url; } +/** + * 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 + * @author Andreas Gohr + */ +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. -- cgit v1.2.3 From f3a1225fae9b5d3b72f691efd61a993c92c0d581 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sat, 7 Apr 2012 22:12:29 +0100 Subject: removed comments from accidentally commented lines in tpl_includeFile() --- inc/template.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index edf3ca3fb..27163f076 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1549,7 +1549,7 @@ function tpl_includeFile($file){ foreach ($config_cascade['main'][$config_group] as $conf_file) { $dir = dirname($conf_file); if(file_exists("$dir/$file")){ - // include("$dir/$file"); + include("$dir/$file"); return; } } @@ -1558,7 +1558,7 @@ function tpl_includeFile($file){ // still here? try the template dir $file = tpl_incdir().$file; if(file_exists($file)){ - //include($file); + include($file); } } -- cgit v1.2.3