00001 <?php
00002
00003
00004
00005
00006
00007
00008 class Config {
00009
00010
00011
00012 const VERSION_MAX = 'VERSION_MAX';
00013
00014
00015
00016 const VERSION = 'VERSION';
00017
00018 const TITLE = 'TITLE';
00019 const ITEMS_PER_PAGE = 'ITEMS_PER_PAGE';
00020
00021 const TESTMODE = 'TESTMODE';
00022 const THROW_ON_DB_ERROR = 'THROW_ON_DB_ERROR';
00023 const THROW_ON_WARNING = 'THROW_ON_WARNING';
00024 const DEBUG_QUERIES = 'DEBUG_QUERIES';
00025 const PRINT_DURATION = 'PRINT_DURATION';
00026 const DISABLE_CACHE = 'DISABLE_CACHE';
00027 const ENABLE_HTTPS = 'ENABLE_HTTPS';
00028 const START_SESSION = 'START_SESSION';
00029 const FORCE_FULL_DOMAINNAME = 'FORCE_FULL_DOMAINNAME';
00030
00031
00032
00033 const SESSION_HANDLER = 'SESSION_HANDLER';
00034
00035
00036
00037 const DEFAULT_TEMPLATE_ENGINE = 'DEFAULT_TEMPLATE_ENGINE';
00038 const PAGE_TEMPLATE = 'PAGE_TEMPLATE';
00039 const GZIP_SUPPORT = 'GZIP';
00040
00041
00042
00043 const LOG_QUERIES = 'LOG_QUERIES';
00044 const LOG_FAILED_QUERIES = 'LOG_FAILED_QUERIES';
00045 const LOG_SLOW_QUERIES = 'LOG_SLOW_QUERIES';
00046 const DB_SLOW_QUERY_THRESHOLD = 'DB_SLOW_QUERY_THRESHOLD';
00047 const LOG_TRANSLATIONS = 'LOG_TRANSLATIONS';
00048 const LOG_HTML_ERROR_STATUS = 'LOG_HTML_ERROR_STATUS';
00049 const LOG_HTTPREQUESTS = 'LOG_HTTPREQUESTS';
00050
00051
00052
00053 const MAIL_SUBJECT = 'MAIL_SUBJECT';
00054
00055
00056
00057 const MAIL_SENDER = 'MAIL_SENDER';
00058
00059
00060
00061 const MAIL_ADMIN = 'MAIL_ADMIN';
00062
00063
00064
00065 const MAIL_SUPPORT = 'MAIL_SUPPORT';
00066
00067
00068
00069
00070 const MAILER_TYPE = 'MAILER_TYPE';
00071
00072
00073
00074 const MAILER_SMTP_HOST = 'MAILER_SMTP_HOST';
00075
00076
00077
00078 const MAILER_SMTP_USER = 'MAILER_SMTP_USER';
00079
00080
00081
00082 const MAILER_SMTP_PASSWORD = 'MAILER_SMTP_PASSWORD';
00083
00084
00085
00086 const URL_DOMAIN = 'URL_DOMAIN';
00087 const URL_BASEDIR = 'URL_BASEDIR';
00088 const URL_SERVER = 'URL_SERVER';
00089 const URL_SERVER_SAFE = 'URL_SERVER_SAFE';
00090 const URL_BASEURL = 'URL_BASEURL';
00091 const URL_BASEURL_SAFE = 'URL_BASEURL_SAFE';
00092 const URL_ABSPATH = 'URL_ABSPATH';
00093
00094
00095
00096 const URL_IMAGES_DIR = 'URL_IMAGES_DIR';
00097 const URL_IMAGES = 'URL_IMAGES';
00098
00099
00100
00101 const URL_DEFAULT_PAGE = 'URL_DEFAULT_PAGE';
00102
00103
00104
00105
00106 const DEFAULT_SCHEME = 'DEFAULT_SCHEME';
00107
00108
00109
00110
00111 const VALIDATE_URL = 'VALIDATE_URL';
00112
00113
00114
00115
00116 const TEMP_DIR = 'TEMP_DIR';
00117
00118
00119
00120 const OUT_DIR = 'OUT_DIR';
00121
00122
00123
00124 const THIRDPARTY_DIR = '3RDPARTY_DIR';
00125
00126
00127
00128
00129 const QUERY_PARAM_PATH_INVOKED = 'QUERY_PARAM_PATH_INVOKED';
00130
00131 const FORMVALIDATION_FIELD_NAME = 'FORMVALIDATION_FIELD_NAME';
00132 const FORMVALIDATION_HANDLER_NAME = 'FORMVALIDATION_HANDLER_NAME';
00133 const FORMVALIDATION_EXPIRATION_TIME = 'FORMVALIDATION_EXPIRATION_TIME';
00134
00135 const PAGER_NUM_LINKS = 'PAGER_NUM_LINKS';
00136 const PAGER_CALCULATOR = 'PAGER_CALCULATOR';
00137
00138
00139 const CACHEHEADER_CLASS_CACHED = 'CACHEHEADER_CLASS_CACHED';
00140
00141 const CACHEHEADER_CLASS_UNCACHED = 'CACHEHEADER_CLASS_UNCACHED';
00142
00143
00144
00145
00146
00147
00148 private static $data = array();
00149
00150
00151
00152
00153
00154
00155
00156 public static function has_feature($feature) {
00157 return isset(self::$data[$feature]);
00158 }
00159
00160
00161
00162
00163
00164
00165
00166 public static function set_feature($feature, $enabled) {
00167 if ($enabled) {
00168 self::$data[$feature] = true;
00169 }
00170 else {
00171 unset(self::$data[$feature]);
00172 }
00173 }
00174
00175
00176
00177
00178
00179
00180
00181
00182 public static function set_feature_from_constant($feature, $constant, $default) {
00183 self::set_feature($feature, defined($constant) ? constant($constant) : $default);
00184 }
00185
00186
00187
00188
00189
00190
00191
00192
00193 public static function get_value($feature, $require = false, $default = false) {
00194 if (isset(self::$data[$feature])) {
00195 return self::$data[$feature];
00196 }
00197 else if ($require) {
00198 throw new Exception(tr('Required Config-Value %feature not set', 'core', array('%feature' => $feature)));
00199 }
00200 return $default;
00201 }
00202
00203
00204
00205
00206
00207
00208
00209 public static function set_value($feature, $value) {
00210 self::$data[$feature] = $value;
00211 }
00212
00213
00214
00215
00216
00217
00218
00219
00220 public static function set_value_from_constant($feature, $constant, $default) {
00221 self::set_value($feature, defined($constant) ? constant($constant) : $default);
00222 }
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234 public static function get_url($feature) {
00235 $url = self::get_value($feature, true);
00236 $url = str_replace('%scheme%', self::get_value(self::DEFAULT_SCHEME), $url);
00237 $url = str_replace('%domain%', self::get_value(self::URL_DOMAIN), $url);
00238 $url = str_replace('%basedir%', self::get_value(self::URL_BASEDIR), $url);
00239 return $url;
00240 }
00241
00242
00243
00244
00245
00246
00247 public static function create_fingerprint() {
00248 $ret = '';
00249 foreach(self::$data as $key => $value) {
00250 $ret .= $value;
00251 }
00252 return sha1($ret);
00253 }
00254 }