-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainSettings.php
71 lines (63 loc) · 2.08 KB
/
MainSettings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/*
* Copyright (C) 2010 Richard Kakaš.
* All rights reserved.
* Contact: Richard Kakaš <[email protected]>
*
* @LICENSE_START@
* This file is part of CFD project and it is licensed
* under license that is described in CFD project's LICENSE file.
* See LICENSE file for information about how you can use this file.
* @LICENSE_END@
*/
/**
* @brief Holds main settings for CFD platform.
*
* This class
*/
class MainSettings {
/**
* This variable specifies in which directory core
* classes reside. This property is adjusted automatically
* and can't be adjusted manually.
*/
private static $sCoreDirectory;
/**
* This variable holds path to root of CFD platform.
*/
private static $sRootDirectory;
/**
* @brief Static constructor.
*
* This function is called automatically. User mustn't
* call it. This function sets main settings and does
* some initial setup.
*/
public static function __static() {
// setting up directories
self::$sRootDirectory = dirname(__FILE__);
self::$sCoreDirectory = self::$sRootDirectory . "/core";
if( !is_dir(self::$sCoreDirectory) ) {
die("Low level fatal error: Directory with core files and classes does not exist: " . self::$sCoreDirectory);
}
// overriding PHP's function for autoloading classes
require_once(self::getCoreDirectoryPath() . "/ClassAutoloading.php");
function __autoload($className) {
\cfd\core\ClassAutoloading::autoload($className);
}
}
/**
* @return Absolute path to directory where core files and classes reside.
* There is not trailling "/" at the end of returned string.
*/
public static function getCoreDirectoryPath() {
return self::$sCoreDirectory;
}
/**
* @return Absolute path to root directory of CFD installation.
* There is not trailling "/" at the end of returned string.
*/
public static function getRootDirectoryPath() {
return self::$sRootDirectory;
}
} MainSettings::__static();