summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2012-04-07 20:20:22 +0200
committerAndreas Gohr <andi@splitbrain.org>2012-04-07 20:20:22 +0200
commite5d4768d27336a3af2fc36af663d21a1a57d0ee1 (patch)
treed6755f004a8076f39c46d633d22386e5b1965881
parent42ff673048d169bcbec5e4bb17619d66e6f6f61d (diff)
downloadrpg-e5d4768d27336a3af2fc36af663d21a1a57d0ee1.tar.gz
rpg-e5d4768d27336a3af2fc36af663d21a1a57d0ee1.tar.bz2
added tpl_includeFile() to core
-rw-r--r--inc/template.php36
-rw-r--r--lib/tpl/dokuwiki/detail.php7
-rw-r--r--lib/tpl/dokuwiki/main.php11
-rw-r--r--lib/tpl/dokuwiki/mediamanager.php3
-rw-r--r--lib/tpl/dokuwiki/tpl_footer.php2
-rw-r--r--lib/tpl/dokuwiki/tpl_header.php2
6 files changed, 47 insertions, 14 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.
*
diff --git a/lib/tpl/dokuwiki/detail.php b/lib/tpl/dokuwiki/detail.php
index baa454edc..a3516a7ed 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 9bc221711..57c94f174 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 0651b448d..1f3b9661b 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 6b46234d6..41ddabda2 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 35b3cf636..1d2517ee1 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">