commit 58e480ae0dd50efc0b51085d855917d611852bd1
parent 77c94be68f44b53d1e701cd784da2f2b665b6e68
Author: Jan Dankert <devnull@localhost>
Date: Fri, 10 Aug 2012 00:32:24 +0200
Doc: Klassen-Dokumentation ergänzt.
Diffstat:
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/util/Preferences.class.php b/util/Preferences.class.php
@@ -1,11 +1,10 @@
<?php
/**
- * Bereitstellen von Methoden fuer das Lesen von Einstellungen
+ * Hilfsmethoden fuer das Lesen von Einstellungen.
*
- * @author $Author$
- * @version $Revision$
- * @package openrat.services
+ * @author Jan Dankert
+ * @package openrat.util
*/
class Preferences
{
@@ -24,19 +23,26 @@ class Preferences
*/
public static function configurationFile()
{
+ // Falls Umgebungsvariable OPENRAT_CONFIG_FILE gesetzt ist,
+ // dann diesen Dateinamen verwenden.
if ( !empty($_SERVER['OPENRAT_CONFIG_FILE']) )
{
$config_filename = $_SERVER['OPENRAT_CONFIG_FILE'];
}
else
{
+ // Falls Umgebungsvariable OPENRAT_CONFIG_DIR gesetzt ist, dann
+ // die Datei in diesem Ordner suchen.
if ( !empty($_SERVER['OPENRAT_CONFIG_DIR']) )
$dir = $_SERVER['OPENRAT_CONFIG_DIR'];
else
$dir = './config/';
-
+
+
if ( !empty($_SERVER['HTTP_HOST']) )
{
+ // Falls es eine Datei config-<hostname>.ini.php gibt, dann diese
+ // vor der Datei config.ini.php bevorzugen.
$vhost_config_file = slashify($dir).'config-'.$_SERVER['HTTP_HOST'].'.ini.php';
if ( is_file($vhost_config_file) )
@@ -44,6 +50,10 @@ class Preferences
else
$config_filename = slashify($dir).'config.ini.php';
}
+ else
+ {
+ $config_filename = slashify($dir).'config.ini.php';
+ }
}
if ( ! is_file($config_filename))
@@ -66,13 +76,12 @@ class Preferences
*/
public static function load()
{
+ // Fest eingebaute Standard-Konfiguration laden.
require('./config/config-default.php');
- //echo "default: "; print_r($conf);
$filename = Preferences::configurationFile();
$ini_values = parse_ini_file( $filename,false );
- //echo "loading ".$config_filename;
foreach ( $ini_values as $key=>$value )
{
$parts = explode('.',$key);
@@ -89,7 +98,8 @@ class Preferences
elseif ( count($parts)==6)
$conf[$parts[0]][$parts[1]][$parts[2]][$parts[3]][$parts[4]][$parts[5]] = $value;
}
-
+
+ // Den Dateinamen der Konfigurationsdatei in die Konfiguration schreiben.
$conf['config']['filename' ] = $filename;
$conf['config']['last_modification'] = Preferences::lastModificationTime();
return $conf;