public function confOk() { $conf = SomeFactory::getConfiguration(); $driver = $conf->get('databasedriver', 'database'); $host = $conf->get('databasehost', 'database'); $database = $conf->get('database', 'database'); //if all ok, try to get select now() as now if (!$driver) { $this->errors[] = "Set configuration databasedriver to pdopostgres or pdomysql"; } if (!$host) { $this->errors[] = "Set configuration databasehost to some host. In cluster host is postgres.cs.uta.fi"; } if (!$database) { $this->errors[] = "Set configuration database to some database name. In cluster database is your account username"; } if (count($this->errors)) { return false; } $database = SomeFactory::getDBO(); $st = $database->query("SELECT NOW() as now"); if ($st->fetch()) { return true; } else { $this->errors[] = "Can not connect to database with {$driver}, {$host} and {$database}"; return false; } }
private function save() { $this->edit(); $conf = SomeFactory::getConfiguration(); foreach ($this->conf_categories as $catname => $v) { foreach ($v as $key => $val) { $value_from_post = SomeRequest::getVar("{$catname}___{$key}", ''); $conf->set($key, $catname, $value_from_post); } } $exportedarray = var_export($conf->getAsArray(), true); file_put_contents(SOME_PATH . DS . 'configuration.php', "<?php\n defined('SOME_PATH') or die('Unauthorized access');\n \$configuration = {$exportedarray};"); $this->edit(); }
/** * get the current debug value. * @return int debug true or false */ public function getDebug() { $conf = SomeFactory::getConfiguration(); return $conf->get('debug', 'debug') ? $conf->get('debug', 'debug') : 0; }
public function loadConfiguration() { //load configuration. $conf = SomeFactory::getConfiguration(); //get it to arrays, for simpler edit. $this->conf_categories = $conf->getAsArray(); return true; }
public static function getLanguage($lang = null) { static $instance; if (!is_object($instance)) { someloader('some.language.language'); $conf = SomeFactory::getConfiguration(); $language = $lang ? $lang : $conf->get('language', 'common'); //echo "new SomeLanguage($language)<br />\n"; $instance = new SomeLanguage($language); } return $instance; }