40 if (!class_exists(
'XoopsLoad',
false)) {
41 include __DIR__ .
'/xoopsload.php';
44 $yamlString = file_get_contents(
$config);
45 if ($yamlString ===
false) {
46 throw new \Exception(
'XoopsBaseConfig failed to load configuration.');
48 $loaderPath = $this->
extractLibPath($yamlString) .
'/vendor/autoload.php';
49 if (file_exists($loaderPath)) {
50 include_once $loaderPath;
59 throw new \Exception(
'XoopsBaseConfig lib-path not defined.');
76 static $instance =
false;
78 if (!$instance && !empty(
$config)) {
79 $instance = new \XoopsBaseConfig(
$config);
83 throw new \Exception(
'XoopsBaseConfig failed.');
105 $matched = preg_match(
'/[.\v]*^lib-path\h*\:\h*[\']?([^\'\v]*)[\']?\h*$[.\v]*/m', $filecontents, $match);
107 return $matched ? trim($match[1]) :
'';
117 final public static function get(
$name)
122 trigger_error(
'variable : '.$name.
' not found!', E_USER_ERROR);
155 if (defined(
'XOOPS_ROOT_PATH')) {
160 define(
'XOOPS_ROOT_PATH', self::get(
'root-path'));
164 define(
'XOOPS_PATH', self::get(
'lib-path'));
166 define(
'XOOPS_VAR_PATH', self::get(
'var-path'));
168 define(
"XOOPS_TRUST_PATH", self::get(
'trust-path'));
171 define(
'XOOPS_PROT', self::get(
'prot'));
176 define(
'XOOPS_URL', self::get(
'url'));
183 define(
'XOOPS_DB_TYPE', self::get(
'db-type'));
186 define(
"XOOPS_DB_CHARSET", self::get(
'db-charset'));
190 define(
'XOOPS_DB_PREFIX', self::get(
'db-prefix'));
194 define(
'XOOPS_DB_HOST', self::get(
'db-host'));
198 define(
'XOOPS_DB_USER', self::get(
'db-user'));
202 define(
'XOOPS_DB_PASS', self::get(
'db-pass'));
206 define(
'XOOPS_DB_NAME', self::get(
'db-name'));
209 define(
"XOOPS_DB_PCONNECT", self::get(
'db-pconnect'));
213 define(
'XOOPS_DB_PARAMETERS', serialize(self::get(
'db-parameters')));
226 $path = self::defineDefault(
'XOOPS_ROOT_PATH', basename(__DIR__));
227 $url = (defined(
'XOOPS_URL')) ?
229 ((isset(
$_SERVER[
'HTTPS']) &&
$_SERVER[
'HTTPS'] ==
"on") ?
'https://' :
'http://')
233 $parts = parse_url(
$url .
'/');
234 $host = isset($parts[
'host']) ? $parts[
'host'] :
$_SERVER[
'SERVER_NAME'];
235 $host = ($host==
'localhost') ?
'' : $host;
236 $urlpath = isset($parts[
'path']) ? $parts[
'path'] :
'/';
238 $libpath = self::defineDefault(
'XOOPS_PATH');
239 $varpath = self::defineDefault(
'XOOPS_VAR_PATH');
242 'root-path' =>
$path,
243 'lib-path' => $libpath,
244 'var-path' => $varpath,
245 'trust-path' => $libpath,
247 'prot' => self::defineDefault(
'XOOPS_PROT'),
248 'asset-path' =>
$path .
'/assets',
249 'asset-url' =>
$url .
'/assets',
250 'themes-path' =>
$path .
'/themes',
251 'themes-url' =>
$url .
'/themes',
252 'adminthemes-path' =>
$path .
'/modules/system/themes',
253 'adminthemes-url' =>
$url .
'/modules/system/themes',
254 'media-path' =>
$path .
'/media',
255 'media-url' =>
$url .
'/media',
256 'uploads-path' =>
$path .
'/uploads',
257 'uploads-url' =>
$url .
'/uploads',
258 'cookie-domain' => $host,
259 'cookie-path' => $urlpath,
260 'smarty-cache' => $varpath .
'/caches/smarty_cache',
261 'smarty-compile' => $varpath .
'/caches/smarty_compile',
262 'smarty-xoops-plugins' => $libpath .
'/smarty/xoops_plugins',
263 'db-type' => self::defineDefault(
'XOOPS_DB_TYPE'),
264 'db-charset' =>
'utf8',
265 'db-prefix' => self::defineDefault(
'XOOPS_DB_PREFIX'),
266 'db-host' => self::defineDefault(
'XOOPS_DB_HOST'),
267 'db-user' => self::defineDefault(
'XOOPS_DB_USER'),
268 'db-pass' => self::defineDefault(
'XOOPS_DB_PASS'),
269 'db-name' => self::defineDefault(
'XOOPS_DB_NAME'),
271 'db-parameters' => defined(
'XOOPS_DB_PARAMETERS') ? unserialize(
XOOPS_DB_PARAMETERS) : array(),
287 $default = ($default === null) ? $define : $default;
288 $return = defined($define) ? constant($define) : $default;
static startAutoloader($path)
static establishBCDefines()
extractLibPath($filecontents)
static bootstrapTransition()
static defineDefault($define, $default=null)
static getInstance($config= '')
const XOOPS_DB_PARAMETERS