diff --git a/inc/template.php b/inc/template.php index 37848b59ae24cbb46087a9fa5782bc00db72dee0..edf3ca3fbc47ded5daa5ff56475be0b25931b914 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 <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. diff --git a/lib/tpl/dokuwiki/detail.php b/lib/tpl/dokuwiki/detail.php index baa454edc323bd86ecadaa5bc193128880a1dd60..a3516a7eda19f03d6f787ab9118d63e5cbcc1c31 100644 --- a/lib/tpl/dokuwiki/detail.php +++ b/lib/tpl/dokuwiki/detail.php @@ -9,7 +9,6 @@ // must be run from within DokuWiki if (!defined('DOKU_INC')) die(); -@require_once(dirname(__FILE__).'/tpl_functions.php'); /* include hook for template functions */ $showSidebar = $conf['sidebar'] && page_exists($conf['sidebar']) && ($ACT=='show'); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" @@ -26,7 +25,7 @@ $showSidebar = $conf['sidebar'] && page_exists($conf['sidebar']) && ($ACT=='show <?php tpl_metaheaders()?> <meta name="viewport" content="width=device-width,initial-scale=1" /> <?php echo tpl_favicon(array('favicon', 'mobile')) ?> - <?php _tpl_include('meta.html') ?> + <?php tpl_includeFile('meta.html') ?> </head> <body> @@ -47,7 +46,7 @@ $showSidebar = $conf['sidebar'] && page_exists($conf['sidebar']) && ($ACT=='show <div class="page group"> <?php tpl_flush() ?> - <?php _tpl_include('pageheader.html') ?> + <?php tpl_includeFile('pageheader.html') ?> <!-- detail start --> <?php if($ERROR): @@ -95,7 +94,7 @@ $showSidebar = $conf['sidebar'] && page_exists($conf['sidebar']) && ($ACT=='show <?php endif; ?> </div> <!-- detail stop --> - <?php _tpl_include('pagefooter.html') ?> + <?php tpl_includeFile('pagefooter.html') ?> <?php tpl_flush() ?> <?php /* doesn't make sense like this; @todo: maybe add tpl_imginfo()? diff --git a/lib/tpl/dokuwiki/main.php b/lib/tpl/dokuwiki/main.php index 9bc22171111c60cb187cd870e3bc7ca233831e88..57c94f174da1488d6124c26e552bfb9ee801aa16 100644 --- a/lib/tpl/dokuwiki/main.php +++ b/lib/tpl/dokuwiki/main.php @@ -9,7 +9,6 @@ */ if (!defined('DOKU_INC')) die(); /* must be run from within DokuWiki */ -@require_once(dirname(__FILE__).'/tpl_functions.php'); /* include hook for template functions */ $showSidebar = $conf['sidebar'] && page_exists($conf['sidebar']) && ($ACT=='show'); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" @@ -23,7 +22,7 @@ $showSidebar = $conf['sidebar'] && page_exists($conf['sidebar']) && ($ACT=='show <?php tpl_metaheaders() ?> <meta name="viewport" content="width=device-width,initial-scale=1" /> <?php echo tpl_favicon(array('favicon', 'mobile')) ?> - <?php _tpl_include('meta.html') ?> + <?php tpl_includeFile('meta.html') ?> </head> <body> @@ -39,9 +38,9 @@ $showSidebar = $conf['sidebar'] && page_exists($conf['sidebar']) && ($ACT=='show <!-- ********** ASIDE ********** --> <div id="dokuwiki__aside"><div class="pad include group"> <?php tpl_flush() ?> - <?php _tpl_include('sidebarheader.html') ?> + <?php tpl_includeFile('sidebarheader.html') ?> <?php tpl_include_page($conf['sidebar']) ?> - <?php _tpl_include('sidebarfooter.html') ?> + <?php tpl_includeFile('sidebarfooter.html') ?> </div></div><!-- /aside --> <?php endif; ?> @@ -52,11 +51,11 @@ $showSidebar = $conf['sidebar'] && page_exists($conf['sidebar']) && ($ACT=='show <div class="page group"> <?php tpl_flush() ?> - <?php _tpl_include('pageheader.html') ?> + <?php tpl_includeFile('pageheader.html') ?> <!-- wikipage start --> <?php tpl_content() ?> <!-- wikipage stop --> - <?php _tpl_include('pagefooter.html') ?> + <?php tpl_includeFile('pagefooter.html') ?> </div> <div class="docInfo"><?php tpl_pageinfo() ?></div> diff --git a/lib/tpl/dokuwiki/mediamanager.php b/lib/tpl/dokuwiki/mediamanager.php index 0651b448dc7a02c3530ee90b390adae785be0191..1f3b9661b3c1b53b04a94c1246fe4bfcbac9bef4 100644 --- a/lib/tpl/dokuwiki/mediamanager.php +++ b/lib/tpl/dokuwiki/mediamanager.php @@ -7,7 +7,6 @@ */ // must be run from within DokuWiki if (!defined('DOKU_INC')) die(); -@require_once(dirname(__FILE__).'/tpl_functions.php'); /* include hook for template functions */ ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> @@ -23,7 +22,7 @@ if (!defined('DOKU_INC')) die(); <?php tpl_metaheaders()?> <meta name="viewport" content="width=device-width,initial-scale=1" /> <?php echo tpl_favicon(array('favicon', 'mobile')) ?> - <?php _tpl_include('meta.html') ?> + <?php tpl_includeFile('meta.html') ?> </head> <body> diff --git a/lib/tpl/dokuwiki/tpl_footer.php b/lib/tpl/dokuwiki/tpl_footer.php index 6b46234d6c80448c2112bb6cb5546c9d99f981a1..41ddabda203839f8c3717321b145aa93fa33b06c 100644 --- a/lib/tpl/dokuwiki/tpl_footer.php +++ b/lib/tpl/dokuwiki/tpl_footer.php @@ -20,4 +20,4 @@ </div> </div></div><!-- /footer --> -<?php _tpl_include('footer.html') ?> +<?php tpl_includeFile('footer.html') ?> diff --git a/lib/tpl/dokuwiki/tpl_header.php b/lib/tpl/dokuwiki/tpl_header.php index 35b3cf6362133c25501ec5d78b90f27762dbee94..1d2517ee1ebbe974ad126aa59d3da5db62a1953c 100644 --- a/lib/tpl/dokuwiki/tpl_header.php +++ b/lib/tpl/dokuwiki/tpl_header.php @@ -2,7 +2,7 @@ <div id="dokuwiki__header"><div class="pad group"> <?php html_msgarea() ?> - <?php _tpl_include('header.html') ?> + <?php tpl_includeFile('header.html') ?> <div class="headings group"> <ul class="a11y skip">