diff options
author | Andreas Gohr <andi@splitbrain.org> | 2012-04-07 20:20:22 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2012-04-07 20:20:22 +0200 |
commit | e5d4768d27336a3af2fc36af663d21a1a57d0ee1 (patch) | |
tree | d6755f004a8076f39c46d633d22386e5b1965881 /inc | |
parent | 42ff673048d169bcbec5e4bb17619d66e6f6f61d (diff) | |
download | rpg-e5d4768d27336a3af2fc36af663d21a1a57d0ee1.tar.gz rpg-e5d4768d27336a3af2fc36af663d21a1a57d0ee1.tar.bz2 |
added tpl_includeFile() to core
Diffstat (limited to 'inc')
-rw-r--r-- | inc/template.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/inc/template.php b/inc/template.php index 37848b59a..edf3ca3fb 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1527,6 +1527,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. * |