1<?php
2/**
3 * DokuWiki plugin config functions
4 *
5 * @license    GPL3 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Samuel Fischer <sf@notomorrow.de>
7 */
8
9
10/**
11 * return the path for non overriding config files
12 *
13 * @author Samuel Fischer <sf@notomorrow.de>
14 *
15 * @param  string   $type     the configuration settings to be read, must correspond to a key/array in $config_cascade
16 * @param  string   $file     the name of the wanted file
17 * @return string             the full path to the first occurence of the file, searching in this order: protected, local, default
18 */
19function getConfigPath($type, $file) {
20  global $config_cascade;
21
22  if (!is_array($config_cascade[$type])) trigger_error('Missing config cascade for "'.$type.'"',E_USER_WARNING);
23  foreach (array('protected', 'local','default') as $config_group) {
24    if (empty($config_cascade[$type][$config_group])) continue;
25    foreach( $config_cascade[$type][$config_group] as $path ) {
26## DEBUG
27#echo "check $path$file<br>\n";
28        if( file_exists( $path.$file ) && !in_array( $path.$file, get_included_files( ))) {
29#echo "return $path$file<br>\n";
30            return $path.$file;
31        }
32    }
33  }
34}
35
36