1<?php
2/**
3 *
4 */
5
6
7define('CONF_SELF', DOKU_PLUGIN.'config/');
8define('PLUGIN_METADATA',CONF_SELF.'settings/config.metadata.php');
9if(!defined('DOKU_PLUGIN_IMAGES')) define('DOKU_PLUGIN_IMAGES',DOKU_BASE.'lib/plugins/config/images/');
10
11require_once(CONF_SELF.'settings/config.class.php');  // main configuration class and generic settings classes
12require_once(CONF_SELF.'settings/extra.class.php');   // settings classes specific to these settings
13
14  class helper_plugin_subconfhelper_config extends configuration {
15
16    var $_name = 'conf';           // name of the config variable found in the files (overridden by $config['varname'])
17    var $_format = 'php';          // format of the config file, supported formats - php (overridden by $config['format'])
18    var $_heading = '';            // heading string written at top of config file - don't include comment indicators
19    var $_loaded = true;          // set to true after configuration files are loaded
20    var $_metadata = array();      // holds metadata describing the settings
21    var $setting = array();        // array of setting objects
22    var $locked = false;           // configuration is considered locked if it can't be updated
23
24    // configuration filenames
25    var $_default_files  = array();
26    var $_local_files = array();      // updated configuration is written to the first file
27    var $_protected_files = array();
28
29    /**
30     *  constructor
31     */
32    function helper_plugin_subconfhelper_config( ) {
33
34    }
35
36    function configuration( $datafile, $local=array( ), $default=array( ), $protected=array( ) ) {
37        global $conf, $config_cascade;
38
39	$this->_data_file	= $datafile;
40        $this->_local_files	= $local;
41        $this->_default_files   = $default;
42        $this->_protected_files = $protected;
43
44        if (!@file_exists($datafile)) {
45          msg('No configuration metadata found at - '.htmlspecialchars($datafile),-1);
46          return;
47        }
48        include($datafile);
49
50        if (isset($config['varname'])) $this->_name = $config['varname'];
51        if (isset($config['format'])) $this->_format = $config['format'];
52        if (isset($config['heading'])) $this->_heading = $config['heading'];
53
54        $this->locked = $this->_is_locked();
55
56        #$this->_metadata = array_merge($meta, $this->get_plugintpl_metadata($conf['template']));
57        $this->_metadata = $meta;
58
59      // retrieve
60        $no_default_check = array('setting_fieldset', 'setting_undefined', 'setting_no_class');
61
62        #$default = array_merge($this->get_plugintpl_default($conf['template']), $this->_read_config_group($this->_default_files));
63        $default = array_merge($this->_read_config_group($this->_default_files));
64        $local = $this->_read_config_group($this->_local_files);
65        $protected = $this->_read_config_group($this->_protected_files);
66
67        $keys = array_merge(array_keys($this->_metadata),array_keys($default), array_keys($local), array_keys($protected));
68        $keys = array_unique($keys);
69
70        foreach ($keys as $key) {
71          if (isset($this->_metadata[$key])) {
72            $class = $this->_metadata[$key][0];
73            $class = ($class && class_exists('setting_'.$class)) ? 'setting_'.$class : 'setting';
74            if ($class=='setting') {
75              $this->setting[] = new setting_no_class($key,$param);
76            }
77
78            $param = $this->_metadata[$key];
79            array_shift($param);
80          } else {
81            $class = 'setting_undefined';
82            $param = NULL;
83          }
84
85          #if (!in_array($class, $no_default_check) && !isset($default[$key])) {
86          #  $this->setting[] = new setting_no_default($key,$param);
87          #}
88
89          $this->setting[$key] = new $class($key,$param);
90          $this->setting[$key]->initialize($default[$key],$local[$key],$protected[$key]);
91        }
92
93        $this->_loaded = true;
94
95    }
96    function isSingleton() {
97        return false;
98    }
99
100
101}
102