From: Florent Bruneau Date: Sat, 3 Nov 2007 16:23:58 +0000 (+0100) Subject: Add a 'bootstrap' method to globals to initialize dynamic variables. X-Git-Tag: xorg/0.9.16~224 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=99027475f0946aaa3a17c400351edd683313ba5d;p=platal.git Add a 'bootstrap' method to globals to initialize dynamic variables. Signed-off-by: Florent Bruneau --- diff --git a/include/globals.inc.php.in b/include/globals.inc.php.in index ffa6883..65ceed4 100644 --- a/include/globals.inc.php.in +++ b/include/globals.inc.php.in @@ -91,7 +91,7 @@ class PlatalGlobals $this->read_ini_file($this->spoolroot.'/spool/conf/platal.dynamic.conf'); } } - + /** Writes an ini file separated in categories * @param filename the name of the file to write (overwrite existing) * @param categories an array of categories (array of keys and values) @@ -112,7 +112,7 @@ class PlatalGlobals fwrite($f, '; vim:set syntax=dosini foldmethod=marker:'."\n"); fclose($f); } - + /** Change dynamic config file * @param conf array of keys and values to add or replace * @param category name of category to change @@ -171,6 +171,21 @@ class PlatalGlobals $this->read_ini_file($dynamicfile); } + public function bootstrap($conf, $callback, $category = 'Core') + { + $bootstrap = false; + $category = strtolower($category); + foreach ($conf as $key) { + if (!isset($this->$category->$key)) { + $bootstrap = true; + break; + } + } + if ($bootstrap) { + call_user_func($callback); + } + } + private function setlocale() { setlocale(LC_MESSAGES, $this->locale);