MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mconfigloader.class
Ir para a documentação deste ficheiro.
1<?php
7{
11 private $conf;
12 private $defaultConf;
13
21 function __construct($loadDefaultConf = true)
22 {
23 if ( $loadDefaultConf )
24 {
25 $this->setDefaultConf();
26 }
27 }
28
38 function loadConf($module = '', $diretorio = '')
39 {
40 //$file = ($module == '') ? '../etc/miolo.conf' : '../modules/' . $module . '/etc/module.conf';
41 $dir = substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], '/html'));
42 if ( $module == '' )
43 {
44 $file = $dir . '/etc/miolo.conf';
45 }
46 else
47 {
48 $file = $dir . '/modules/' . $module . '/etc/module.conf';
49 }
50
51 if (strlen($dir) == 0 && strlen($diretorio) > 0)
52 {
53 $file = preg_replace('/(miolo20).*/', 'miolo20', $diretorio) . '/etc/miolo.conf';
54 }
55
56 if( file_exists($file) )
57 {
58 $xml = new MSimpleXML($file);
59 $this->conf = $xml->ToSimpleArray($this->conf);
60 }
61 }
62
72 function getConf($key)
73 {
74 $value = null;
75
76 if ( is_array($this->conf) && array_key_exists($key, $this->conf) && !is_null($this->conf[$key]) )
77 {
78 $value = $this->conf[$key];
79 }
80 else if ( is_array($this->defaultConf) && array_key_exists($key, $this->defaultConf) && !is_null($this->defaultConf[$key]) )
81 {
82 $value = $this->defaultConf[$key];
83 }
84
85 return $value;
86 }
87
98 function setConf($key, $value)
99 {
100 $this->conf[$key] = $value;
101 }
112 function setDefaultConf()
113 {
114 $homeMiolo = $this->getConf("home.miolo");
115
116 if ( !$homeMiolo )
117 {
118 $homeMiolo = dirname(dirname(dirname(__FILE__)));
119 $this->setConf('home.miolo', $homeMiolo);
120 }
121
122 $this->defaultConf = array(
123 "home.classes"=>$homeMiolo."/classes",
124 "home.modules"=>$homeMiolo."/modules",
125 "home.etc"=>$homeMiolo."/etc",
126 "home.logs"=>$homeMiolo."/var/log",
127 "home.trace"=>$homeMiolo."/var/trace",
128 "home.db"=>$homeMiolo."/var/db",
129 "home.html"=>$homeMiolo."/html",
130 "home.themes"=>$homeMiolo."/classes/ui/themes",
131 "home.extensions"=>$homeMiolo."/classes/extensions",
132 "home.reports"=>$homeMiolo."/var/reports",
133 "home.images"=>$homeMiolo."/ui/images",
134
135 "i18n.locale" =>$homeMiolo."/locale",
136
137 "home.url_themes"=>"/themes",
138 "home.url_reports"=>"/reports",
139 "home.module.themes"=>"/ui/themes",
140 "home.module.html"=>"/html",
141 "home.module.images"=>"/html/images",
142
143 "namespace.core"=>"/classes",
144 "namespace.service"=>"/classes/services",
145 "namespace.ui"=>"/classes/ui",
146 "namespace.themes"=>"/ui/themes",
147 "namespace.extensions"=>"/classes/extensions",
148 "namespace.controls"=>"/ui/controls",
149 "namespace.database"=>"/classes/database",
150 "namespace.utils"=>"/classes/utils",
151 "namespace.modules"=>"/modules"
152 );
153 }
154
155
161 function generateConfigXML($data,$confModule = null)
162 {
163 $dom = new DOMDocument('1.0', 'ISO-8859-1'); // standalone="yes"
164 $conf = $dom ->appendChild($dom->createElement('conf'));
165
166 $data['home.miolo' ] != '' ? $homeElements[] = $dom->createElement('miolo' , $data['home.miolo' ] ) : null;
167 $data['home.classes' ] != '' ? $homeElements[] = $dom->createElement('classes' , $data['home.classes' ] ) : null;
168 $data['home.modules' ] != '' ? $homeElements[] = $dom->createElement('modules' , $data['home.modules' ] ) : null;
169 $data['home.etc' ] != '' ? $homeElements[] = $dom->createElement('etc' , $data['home.etc' ] ) : null;
170 $data['home.logs' ] != '' ? $homeElements[] = $dom->createElement('logs' , $data['home.logs' ] ) : null;
171 $data['home.trace' ] != '' ? $homeElements[] = $dom->createElement('trace' , $data['home.trace' ] ) : null;
172 $data['home.db' ] != '' ? $homeElements[] = $dom->createElement('db' , $data['home.db' ] ) : null;
173 $data['home.html' ] != '' ? $homeElements[] = $dom->createElement('html' , $data['home.html' ] ) : null;
174 $data['home.themes' ] != '' ? $homeElements[] = $dom->createElement('themes' , $data['home.themes' ] ) : null;
175 $data['home.extensions' ] != '' ? $homeElements[] = $dom->createElement('extensions' , $data['home.extensions' ] ) : null;
176 $data['home.reports' ] != '' ? $homeElements[] = $dom->createElement('reports' , $data['home.reports' ] ) : null;
177 $data['home.images' ] != '' ? $homeElements[] = $dom->createElement('images' , $data['home.images' ] ) : null;
178 $data['home.url' ] != '' ? $homeElements[] = $dom->createElement('url' , $data['home.url' ] ) : null;
179 $data['home.url_themes' ] != '' ? $homeElements[] = $dom->createElement('url_themes' , $data['home.url_themes' ] ) : null;
180 $data['home.url_reports' ] != '' ? $homeElements[] = $dom->createElement('url_reports' , $data['home.url_reports' ] ) : null;
181 $data['home.module.themes'] != '' ? $homeElements[] = $dom->createElement('module.themes', $data['home.module.themes'] ) : null;
182 $data['home.module.html' ] != '' ? $homeElements[] = $dom->createElement('module.html' , $data['home.module.html' ] ) : null;
183 $data['home.module.images'] != '' ? $homeElements[] = $dom->createElement('module.images', $data['home.module.images'] ) : null;
184 if( $homeElements )
185 {
186 $home = $conf->appendChild($dom->createElement('home'));
187 foreach ( $homeElements as $element )
188 {
189 $home->appendChild($element);
190 }
191 }
192
193 $data['namespace.core' ] != '' ? $namespaceElements[] = $dom->createElement('core' , $data['namespace.core' ]) : null;
194 $data['namespace.service' ] != '' ? $namespaceElements[] = $dom->createElement('service' , $data['namespace.service' ]) : null;
195 $data['namespace.ui' ] != '' ? $namespaceElements[] = $dom->createElement('ui' , $data['namespace.ui' ]) : null;
196 $data['namespace.themes' ] != '' ? $namespaceElements[] = $dom->createElement('themes' , $data['namespace.themes' ]) : null;
197 $data['namespace.extensions'] != '' ? $namespaceElements[] = $dom->createElement('extensions' , $data['namespace.extensions']) : null;
198 $data['namespace.controls' ] != '' ? $namespaceElements[] = $dom->createElement('controls' , $data['namespace.controls' ]) : null;
199 $data['namespace.database' ] != '' ? $namespaceElements[] = $dom->createElement('database' , $data['namespace.database' ]) : null;
200 $data['namespace.utils' ] != '' ? $namespaceElements[] = $dom->createElement('utils' , $data['namespace.utils' ]) : null;
201 $data['namespace.modules' ] != '' ? $namespaceElements[] = $dom->createElement('modules' , $data['namespace.modules' ]) : null;
202 if( $namespaceElements )
203 {
204 $namespace = $conf->appendChild($dom->createElement('namespace'));
205 foreach ( $namespaceElements as $element )
206 {
207 $namespace->appendChild($element);
208 }
209 }
210
211 $data['theme.module' ] != '' ? $themeElements[] = $dom->createElement('module' , $data['theme.module' ]) : null;
212 $data['theme.main' ] != '' ? $themeElements[] = $dom->createElement('main' , $data['theme.main' ]) : null;
213 $data['theme.lookup' ] != '' ? $themeElements[] = $dom->createElement('lookup' , $data['theme.lookup' ]) : null;
214 $data['theme.title' ] != '' ? $themeElements[] = $dom->createElement('title' , $data['theme.title' ]) : null;
215 $data['theme.company'] != '' ? $themeElements[] = $dom->createElement('company', $data['theme.company']) : null;
216 $data['theme.system' ] != '' ? $themeElements[] = $dom->createElement('system' , $data['theme.system' ]) : null;
217 $data['theme.logo' ] != '' ? $themeElements[] = $dom->createElement('logo' , $data['theme.logo' ]) : null;
218 $data['theme.email' ] != '' ? $themeElements[] = $dom->createElement('email' , $data['theme.email' ]) : null;
219 if( $themeElements )
220 {
221 $theme = $conf->appendChild($dom->createElement('theme'));
222 foreach ( $themeElements as $element )
223 {
224 $theme->appendChild($element);
225 }
226 }
227
228 $data['theme.options.close' ] != '' ? $tOptionsElements[] = $dom->createElement('close' , $data['theme.options.close' ]) : null;
229 $data['theme.options.minimize'] != '' ? $tOptionsElements[] = $dom->createElement('minimize', $data['theme.options.minimize']) : null;
230 $data['theme.options.help' ] != '' ? $tOptionsElements[] = $dom->createElement('help' , $data['theme.options.help' ]) : null;
231 $data['theme.options.move' ] != '' ? $tOptionsElements[] = $dom->createElement('move' , $data['theme.options.move' ]) : null;
232 if( $tOptionsElements )
233 {
234 !$theme ? $theme = $conf->appendChild($dom->createElement('theme')) : null;
235 $tOptions = $theme->appendChild($dom->createElement('options'));
236 foreach ( $tOptionsElements as $element )
237 {
238 $tOptions->appendChild($element);
239 }
240 }
241 $data['options.startup' ] != '' ? $optionsElements[] = $dom->createElement('startup' , $data['options.startup' ]) : null;
242 $data['options.common' ] != '' ? $optionsElements[] = $dom->createElement('common' , $data['options.common' ]) : null;
243 $data['options.scramble' ] != '' ? $optionsElements[] = $dom->createElement('scramble' , $data['options.scramble' ]) : null;
244 $data['options.scramble.password' ] != '' ? $optionsElements[] = $dom->createElement('scramble.password' , $data['options.scramble.password' ]) : null;
245 $data['options.dispatch' ] != '' ? $optionsElements[] = $dom->createElement('dispatch' , $data['options.dispatch' ]) : null;
246 $data['options.url.style' ] != '' ? $optionsElements[] = $dom->createElement('url.style' , $data['options.url.style' ]) : null;
247 $data['options.index' ] != '' ? $optionsElements[] = $dom->createElement('index' , $data['options.index' ]) : null;
248 $data['options.mainmenu' ] != '' ? $optionsElements[] = $dom->createElement('mainmenu' , $data['options.mainmenu' ]) : null;
249 $data['options.mainmenu.style' ] != '' ? $optionsElements[] = $dom->createElement('mainmenu.style' , $data['options.mainmenu.style' ]) : null;
250 $data['options.mainmenu.clickopen'] != '' ? $optionsElements[] = $dom->createElement('mainmenu.clickopen' , $data['options.mainmenu.clickopen']) : null;
251 $data['options.dbsession' ] != '' ? $optionsElements[] = $dom->createElement('dbsession' , $data['options.dbsession' ]) : null;
252 $data['options.authmd5' ] != '' ? $optionsElements[] = $dom->createElement('authmd5' , $data['options.authmd5' ]) : null;
253 $data['options.debug' ] != '' ? $optionsElements[] = $dom->createElement('debug' , $data['options.debug' ]) : null;
254 $data['options.autocomplete_alert'] != '' ? $optionsElements[] = $dom->createElement('autocomplete_alert' , $data['options.autocomplete_alert']) : null;
255 if( $optionsElements )
256 {
257 $options = $conf->appendChild($dom->createElement('options'));
258 foreach ( $optionsElements as $element )
259 {
260 $options->appendChild($element);
261 }
262 }
263
264 $data['options.dump.peer' ] != '' ? $oDumpElements[] = $dom->createElement('peer' , $data['options.dump.peer' ]) : null;
265 $data['options.dump.profile' ] != '' ? $oDumpElements[] = $dom->createElement('profile' , $data['options.dump.profile' ]) : null;
266 $data['options.dump.uses' ] != '' ? $oDumpElements[] = $dom->createElement('uses' , $data['options.dump.uses' ]) : null;
267 $data['options.dump.trace' ] != '' ? $oDumpElements[] = $dom->createElement('trace' , $data['options.dump.trace' ]) : null;
268 $data['options.dump.handlers'] != '' ? $oDumpElements[] = $dom->createElement('handlers', $data['options.dump.handlers']) : null;
269 if( $oDumpElements )
270 {
271 !$options ? $options = $conf->appendChild($dom->createElement('options')) : null;
272 $oDump = $options->appendChild($dom->createElement('dump'));
273 foreach ( $oDumpElements as $element )
274 {
275 $oDump->appendChild($element);
276 }
277 }
278 $data['options.loading.show' ] != '' ? $oLoadingElements[] = $dom->createElement('show' , $data['options.loading.show' ]) : null;
279 $data['options.loading.generating'] != '' ? $oLoadingElements[] = $dom->createElement('generating', $data['options.loading.generating']) : null;
280 if( $oLoadingElements )
281 {
282 !$options ? $options = $conf->appendChild($dom->createElement('options')) : null;
283 $oLoading = $options->appendChild($dom->createElement('loading'));
284 foreach ( $oLoadingElements as $element )
285 {
286 $oLoading->appendChild($element);
287 }
288 } $data['options.performance.uri_images' ] != '' ? $oPerformanceElements[] = $dom->createElement('uri_images' , $data['options.performance.uri_images' ]) : null;
289 $data['options.performance.enable_ajax'] != '' ? $oPerformanceElements[] = $dom->createElement('enable_ajax' , $data['options.performance.enable_ajax']) : null;
290 if( $oPerformanceElements )
291 {
292 !$options ? $options = $conf->appendChild($dom->createElement('options')) : null;
293 $oPerformance = $options->appendChild($dom->createElement('performance'));
294 foreach ( $oPerformanceElements as $element )
295 {
296 $oPerformance->appendChild($element);
297 }
298 }
299 $data['i18n.locale' ] != '' ? $oLocaleElements[] = $dom->createElement('locale' , $data['i18n.locale' ]) : null;
300 $data['i18n.language'] != '' ? $oLocaleElements[] = $dom->createElement('language' , $data['i18n.language']) : null;
301 if( $oLocaleElements )
302 {
303 $oLocale = $conf->appendChild($dom->createElement('i18n'));
304 foreach ( $oLocaleElements as $element )
305 {
306 $oLocale->appendChild($element);
307 }
308 }
309
310 $data['mad.module'] != '' ? $madElement = $dom->createElement('module' , $data['mad.module']) : null;
311 if( $madElement )
312 {
313 $mad = $conf->appendChild($dom->createElement('mad'));
314 $mad->appendChild($madElement);
315 }
316 $data['mad.classes.access' ] != '' ? $madClassesElements[] = $dom->createElement('access' , $data['mad.classes.access' ]) : null;
317 $data['mad.classes.group' ] != '' ? $madClassesElements[] = $dom->createElement('group' , $data['mad.classes.group' ]) : null;
318 $data['mad.classes.log' ] != '' ? $madClassesElements[] = $dom->createElement('log' , $data['mad.classes.log' ]) : null;
319 $data['mad.classes.session' ] != '' ? $madClassesElements[] = $dom->createElement('session' , $data['mad.classes.session' ]) : null;
320 $data['mad.classes.transaction'] != '' ? $madClassesElements[] = $dom->createElement('transaction' , $data['mad.classes.transaction']) : null;
321 $data['mad.classes.user' ] != '' ? $madClassesElements[] = $dom->createElement('user' , $data['mad.classes.user' ]) : null;
322 if( $madClassesElements )
323 {
324 !$mad ? $mad = $conf->appendChild($dom->createElement('mad')) : null;
325 $madClasses = $mad->appendChild($dom->createElement('classes'));
326 foreach ( $madClassesElements as $element )
327 {
328 $madClasses->appendChild($element);
329 }
330 }
331 $data['login.module'] != '' ? $loginElements[] = $dom->createElement('module' , $data['login.module']) : null;
332 $data['login.class' ] != '' ? $loginElements[] = $dom->createElement('class' , $data['login.class' ]) : null;
333 $data['login.check' ] != '' ? $loginElements[] = $dom->createElement('check' , $data['login.check' ]) : null;
334 $data['login.shared'] != '' ? $loginElements[] = $dom->createElement('shared' , $data['login.shared']) : null;
335 $data['login.auto' ] != '' ? $loginElements[] = $dom->createElement('auto' , $data['login.auto' ]) : null;
336 if( $loginElements )
337 {
338 $login = $conf->appendChild($dom->createElement('login'));
339 foreach ( $loginElements as $element )
340 {
341 $login->appendChild($element);
342 }
343 }
344 $data['session.handler'] != '' ? $sessionElements[] = $dom->createElement('handler' , $data['session.handler']) : null;
345 $data['session.timeout'] != '' ? $sessionElements[] = $dom->createElement('timeout' , $data['session.timeout']) : null;
346 if( $sessionElements )
347 {
348 $session = $conf->appendChild($dom->createElement('session'));
349 foreach ( $sessionElements as $element )
350 {
351 $session->appendChild($element);
352 }
353 }
354
355 (!$confModule) ? $confModule = MIOLO::_REQUEST('confModule') : null;
356 ! $confModule ? $confModule = 'miolo' : null;
357 $data['db.'.$confModule.'.system' ] != '' ? $dbMioloElements[] = $dom->createElement('system' , $data['db.'.$confModule.'.system' ]) : null;
358 $data['db.'.$confModule.'.host' ] != '' ? $dbMioloElements[] = $dom->createElement('host' , $data['db.'.$confModule.'.host' ]) : null;
359 $data['db.'.$confModule.'.name' ] != '' ? $dbMioloElements[] = $dom->createElement('name' , $data['db.'.$confModule.'.name' ]) : null;
360 $data['db.'.$confModule.'.user' ] != '' ? $dbMioloElements[] = $dom->createElement('user' , $data['db.'.$confModule.'.user' ]) : null;
361 $data['db.'.$confModule.'.password'] != '' ? $dbMioloElements[] = $dom->createElement('password', $data['db.'.$confModule.'.password']) : null;
362 if( $dbMioloElements )
363 {
364 $db = $conf->appendChild($dom->createElement('db'));
365 $dbMiolo = $db ->appendChild($dom->createElement($confModule));
366 foreach ( $dbMioloElements as $element )
367 {
368 $dbMiolo->appendChild($element);
369 }
370 }
371 $data['logs.level' ] != '' ? $logsElements[] = $dom->createElement('level' , $data['logs.level' ]) : null;
372 $data['logs.handler'] != '' ? $logsElements[] = $dom->createElement('handler', $data['logs.handler']) : null;
373 $data['logs.peer' ] != '' ? $logsElements[] = $dom->createElement('peer' , $data['logs.peer' ]) : null;
374 $data['logs.port' ] != '' ? $logsElements[] = $dom->createElement('port' , $data['logs.port' ]) : null;
375 if( $logsElements )
376 {
377 $logs = $conf->appendChild($dom->createElement('logs'));
378 foreach ( $logsElements as $element )
379 {
380 $logs->appendChild($element);
381 }
382 }
383 $dom->formatOutput = true;
384 return $dom->saveXML();
385 }
386
387}
388?>
__construct($loadDefaultConf=true)
setConf($key, $value)
generateConfigXML($data, $confModule=null)
loadConf($module='', $diretorio='')
static _REQUEST( $vars, $from='ALL')
Definição miolo.class:1109