/[cvs]/nfo/php/libs/org.netfrag.glib/Application/Config.php
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.glib/Application/Config.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Mon Feb 3 14:41:21 2003 UTC (21 years, 6 months ago) by joko
Branch: MAIN
Changes since 1.2: +39 -1 lines
+ get- and set-methods to access configuration variables
+ recursive merging mechanism

1 <?
2 // ---------------------------------------------------------------------------
3 // $Id: Config.php,v 1.2 2003/02/03 04:59:29 joko Exp $
4 // ---------------------------------------------------------------------------
5 // $Log: Config.php,v $
6 // Revision 1.2 2003/02/03 04:59:29 joko
7 // + fixed: constructor can now get passed variable of *any type*
8 //
9 // Revision 1.1 2003/02/03 03:51:36 joko
10 // + initial commit
11 //
12 // ---------------------------------------------------------------------------
13
14
15 /*
16
17 ------------------------------------------------------------
18 How to use this?
19 ------------------------------------------------------------
20
21 require_once("../etc/defaults.php");
22 require_once("../etc/includes.php");
23
24 $appConfig = mkObject('Application::Config');
25 print "appConfig:<br/>" . Dumper($appConfig) . "<hr/>";
26
27 ------------------------------------------------------------
28
29 */
30
31
32 class Application_Config {
33
34 var $_store;
35
36 function Application_Config($initCfg = null) {
37 //print "Hello World!<hr/>";
38 //print "initCfg:<br/>" . Dumper($initCfg) . "<hr/>";
39 $this->_store = $initCfg;
40 }
41
42 function merge() {
43 //$this->_store[run] = array_merge($this->_store['default'], $this->_store['init']);
44 foreach ($this->_store[_init][configkeys] as $configKey) {
45 //$this->_store[runtime] = array_merge($this->_store[runtime], $this->_store[$configKey]);
46 //$this->_store[runtime] = array_merge_recursive($this->_store[runtime], $this->_store[$configKey]);
47 $this->_store[runtime] = array_join_merge($this->_store[runtime], $this->_store[$configKey]);
48 }
49 //print Dumper($this);
50 }
51
52 function getPart($var = null) {
53 //$this->merge();
54 if ($var) {
55 return $this->getVar("runtime.$var");
56 } else {
57 return $this->getVar("runtime");
58 }
59 }
60
61 function setVar($var, $val) {
62 //$this->_store[runtime][$var] = $val;
63 //$deep = new Data_Deep($this->_store[runtime]);
64 $deep = new Data_Deep($this->_store);
65 $deep->set($var, $val);
66 }
67
68 function getVar($var) {
69 //$this->_store[runtime][$var] = $val;
70 //$deep = new Data_Deep($this->_store[runtime]);
71 $deep = new Data_Deep($this->_store);
72 return $deep->get($var);
73 }
74
75 }
76
77 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed