panel admina
[watermeloncms.git] / wtrmln / libs / config.php
blob397a8c708b01fbb34a49130dc72e197481bdd993
1 <?php
2 /********************************************************************
4 Watermelon CMS
6 Copyright 2008-2009 Radosław Pietruszewski
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 version 2 as published by the Free Software Foundation.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 ********************************************************************/
24 * Lib Config
25 * wersja 2.0.0
27 * zarządzanie konfiguracją
30 class Config
32 public static $siteName;
33 public static $siteSlogan;
34 public static $hashAlgo;
35 public static $defaultHashAlgo;
36 public static $defaultController;
37 public static $theme;
38 private static $superusers = null;
39 private static $dbconfig = array();
40 private static $dbconfigLoaded = false;
43 * public static void setSuperusers(string[] $superusers)
45 * ustawia listę administratorów na $superusers
48 public static function setSuperusers(array $superusers)
50 if(self::$superusers === NULL)
52 self::$superusers = $superusers;
57 * public static string[] getSuperusers()
59 * zwraca listę administratorów
62 public static function getSuperusers()
64 return self::$superusers;
68 * public static mixed getConf(string $fieldname)
70 * pobiera z bazy danych wartość konfiguracji $fieldname i zwraca ją
73 public static function getConf($fieldname)
75 if(!self::$dbconfigLoaded)
77 $data = DB::query("SELECT * FROM `__config`");
79 while($field = $data->to_obj())
81 self::$dbconfig[$field->field] = $field->value;
84 self::$dbconfigLoaded = true;
87 return self::$dbconfig[$fieldname];
91 * public static void setConf(string $fieldname, string $fieldvalue)
93 * ustawia w bazie danych wartość pola $fieldname na $fieldvalue
96 public static function setConf($fieldname, $fieldvalue)
98 self::$dbconfig[$fieldname] = $fieldvalue;
100 DB::query("INSERT INTO `__config` (`field`, `value`) VALUES ('%1', '%2') ON DUPLICATE KEY UPDATE `value` = '%2'", $fieldname, $fieldvalue);