X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fglobals.inc.php.in;h=c5148e43e6239ac8d281b17c43d0d52cba55d803;hb=e0e77c5a55e92d873accf3fe735042eb8b088e34;hp=b5110069e66063c8d82454de11f6d17bbed88f9d;hpb=145006c0ff77fa8a329616c2c8859191b2b236f7;p=platal.git diff --git a/include/globals.inc.php.in b/include/globals.inc.php.in index b511006..c5148e4 100644 --- a/include/globals.inc.php.in +++ b/include/globals.inc.php.in @@ -1,6 +1,6 @@ read_config(); if (isset($_SERVER) && isset($_SERVER['SERVER_NAME'])) { $base = empty($_SERVER['HTTPS']) ? 'http://' : 'https://'; - $this->baseurl = @trim($base.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']), '/'); + $this->baseurl = @trim($base .$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']), '/'); + $this->baseurl_http = @trim('http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']), '/'); } $this->setlocale(); @@ -87,9 +89,11 @@ class PlatalGlobals { $this->read_ini_file($this->spoolroot.'/configs/platal.ini'); $this->read_ini_file($this->spoolroot.'/configs/platal.conf'); - $this->read_ini_file($this->spoolroot.'/spool/conf/platal.dynamic.conf'); + if (file_exists($this->spoolroot.'/spool/conf/platal.dynamic.conf')) { + $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) @@ -110,7 +114,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 @@ -121,7 +125,11 @@ class PlatalGlobals public function change_dynamic_config($conf, $category = 'Core') { $dynamicfile = $this->spoolroot.'/spool/conf/platal.dynamic.conf'; - $array = parse_ini_file($dynamicfile, true); + if (file_exists($dynamicfile)) { + $array = parse_ini_file($dynamicfile, true); + } else { + $array = null; + } if (!is_array($array)) { // dynamic conf is empty $array = array($category => $conf); @@ -165,6 +173,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);