--- /dev/null
+<?php
+// +----------------------------------------------------------------------
+// | PHP Source
+// +----------------------------------------------------------------------
+// | Copyright (C) 2007 by Peter keller <peter@silmor.de>
+// +----------------------------------------------------------------------
+// |
+// | Copyright: See COPYING file that comes with this distribution
+// +----------------------------------------------------------------------
+//
+
+class ConfigManager
+{
+ private $configFile;
+ private $config;
+
+ public function __construct($file = "lang.conf")
+ {
+ global $template;
+
+ $this->configFile = $template.$file;
+ $this->readConfig();
+ }
+
+ /** reads the configuration values from the file */
+ private function readConfig()
+ {
+ // check if file really exists
+ if (file_exists($this->configFile)) {
+ $lines = file($this->configFile);
+ $this->config = array();
+
+ foreach ($lines as $line_num => $line) {
+ # Comment?
+ if ( !preg_match("/^#.*/", $line) ) {
+ # Contains non-whitespace?
+ if ( preg_match("/\S/", $line) ) {
+ list( $key, $value ) = explode( "=", trim( $line ), 2);
+ $this->config[trim($key)] = trim($value);
+ }
+ }
+ }
+ }
+ }
+
+ /** returns the value of the given configuration item */
+ public function get($key)
+ {
+ return $this->config[$key];
+ }
+
+ /** can be used to set an alternate path to a config file */
+ public function setConfigFile($file)
+ {
+ $this->configFile = $file;
+ $this->readConfig();
+ }
+}
+
+?>
public function getDescription(){return $this->description;}
/**returns the reason why the event is cancelled if isCancelled() returns true*/
public function getCancelReason(){return $this->cancelreason;}
- /**returns the date of the event*/
- public function getStDate()
- {
- return date("d.m.Y", $this->getStartTime());
- }
- /**returns the time of the event*/
- public function getStTime()
- {
- return date("H:i", $this->getStartTime());
- }
- /**returns the price in euro*/
- public function getPriceInEuro()
- {
- return number_format($this->getDefaultPrice()/100, 2, ",", ".");
- }
/**returns the data in an array*/
public function getParserData()
{
- return array("DATE"=>$this->getStDate(), "TIME"=>$this->getStTime(), "PLACE"=>$this->getRoomId(), "EVENTNAME"=>$this->getTitle(), "ARTIST"=>$this->getArtist(),"PRICE"=>$this->getPriceInEuro(), "ID"=>$this->getEventId(), "DESCRIPTION"=>$this->getDescription());
+ global $lang;
+
+ return array("DATE"=>$lang->getDate($this->getStartTime()), "TIME"=>$lang->getTime($this->getStartTime()), "PLACE"=>$this->getRoomId(), "EVENTNAME"=>$this->getTitle(), "ARTIST"=>$this->getArtist(),"PRICE"=>$lang->getPrice($this->getDefaultPrice()), "ID"=>$this->getEventId(), "DESCRIPTION"=>$this->getDescription());
}
};
{
private $COOKIE_NAME = "ms_lang";
private $lang;
+ private $config;
/** constructor */
public function __construct()
// set default value
$template .= "de/";
}
+
+ $this->config = new ConfigManager("lang.conf");
}
/** set language */
setcookie($this->COOKIE_NAME, $language, 0);
}
- /** get date in current language */
+ /** returns date in current language */
public function getDate($date)
{
-
+ return date($this->config->get("DateFormat"), $date);
}
- /** get time in current language */
+ /** returns time in current language */
public function getTime($time)
{
-
+ return date($this->config->get("TimeFormat"), $time);
}
- /** get price in current language */
+ /** returns price in current language */
public function getPrice($price)
{
+ return number_format($price/100, 2, $this->config->get("DecimalPoint"), $this->config->get("ThousandSeparator"));
+ }
+ /** returns error message for specified number in current language */
+ public function getErrMsg($num)
+ {
+ return $this->config->get("ERR".$num);
}
}
include("./inc/random.php");
include("./inc/order.php");
include("./inc/cart.php");
-include('inc/error.php');
-include('inc/language_manager.php');
-include('inc/parser.php');
+include('./inc/error.php');
+include('./inc/language_manager.php');
+include('./inc/parser.php');
+include('./inc/config_manager.php')
?>
\ No newline at end of file
--- /dev/null
+# Time
+TimeFormat = H:i
+DateFormat = d/m/Y
+
+# Currency
+DecimalPoint = .
+ThousandSeparator = ,
+
+# Error messages
+ERR001 = Test
\ No newline at end of file