1<?php
2/**
3 * DokuWiki plugin template functions
4 *
5 * @license    GPL3 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Samuel Fischer <sf@notomorrow.de>
7 */
8
9/**
10 * include a template file
11 */
12
13function tpl_include( $file, $t=false, $allowphp=true ) {
14    global $conf, $ID, $INFO;
15    static $included_templates;
16    if( !is_array( $included_templates )) $included_templates = array( );
17
18    if( !$t ) { $t = $conf['template']; }
19    if( !$t || ( !$include = getConfigPath( 'template_dir', $t.'/'.$file )) || in_array( $include, $included_templates )) {
20        if( $t != $conf['default_tpl'] )
21            $include = getConfigPath( 'template_dir', $conf['default_tpl'].'/'.$file );
22    }
23
24    if( !$include || in_array( $include, $included_templates )) {
25	$include = getConfigPath( 'template_dir', $conf['base_tpl'].'/'.$file );
26    }
27    if( !$include ) return false;
28
29    if( $allowphp || $conf['tpl_allowphp'] ) {
30        $included_templates[] = $include;
31        include( $include );
32    } else {
33        // TODO, read file
34    }
35    return $include;
36
37}
38