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') 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