2
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
* Helioviewer Configuration Helper Class Definition
6
* This file defines a class which helps to parse Helioviewer's configuration
7
* file, create global constants which can be used to access those configuration
8
* parameters, and fix data types for known parameters.
12
* @category Configuration
13
* @package Helioviewer
14
* @author Keith Hughitt <keith.hughitt@nasa.gov>
15
* @license http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License 1.1
16
* @link http://launchpad.net/helioviewer.org
19
* Helioviewer Configuration Helper
21
* A helper class created to assist in parsing Helioviewer's configuration
22
* file. It creates global constants which can be used to access those configuration
23
* parameters, and fix data types for known parameters.
25
* @category Configuration
26
* @package Helioviewer
27
* @author Keith Hughitt <keith.hughitt@nasa.gov>
28
* @license http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License 1.1
29
* @link http://launchpad.net/helioviewer.org
33
private $_bools = array("local_tiling_enabled", "distributed_tiling_enabled", "disable_cache");
34
private $_ints = array("build_num", "bit_depth", "default_timestep", "prefetch_size", "num_colors",
35
"png_compression_quality", "jpeg_compression_quality", "max_jpx_frames",
37
private $_floats = array("default_image_scale", "min_image_scale", "max_image_scale");
42
* Creates an instance of the Config helper class
44
* @param string $file Path to configuration file
48
public function __construct($file)
50
$this->config = parse_ini_file($file);
54
foreach ($this->config as $key => $value) {
55
if ($key !== "tile_server") {
56
define("HV_" . strtoupper($key), $value);
60
define("HV_TILE_SERVER_0", "api/index.php");
61
foreach ($this->config["tile_server"] as $id => $url) {
62
define("HV_TILE_SERVER_" . ($id + 1), $url);
65
$this->_setAdditionalParams();
67
$this->_setupLogging(true);
69
$dbconfig = substr($file, 0, strripos($file, "/")) . "/Database.php";
71
include_once $dbconfig;
75
* Casts known configuration variables to correct types.
79
private function _fixTypes()
82
foreach ($this->_bools as $boolean) {
83
$this->config[$boolean] = (bool) $this->config[$boolean];
87
foreach ($this->_ints as $int) {
88
$this->config[$int] = (int) $this->config[$int];
92
foreach ($this->_floats as $float) {
93
$this->config[$float] = (float) $this->config[$float];
98
* Makes sure that error log exists and selects desired logging verbosity
100
* @param bool $verbose Whether or not to force verbose logging.
104
private function _setupLogging($verbose)
107
error_reporting(E_ALL | E_STRICT);
109
$errorLog = HV_ERROR_LOG;
110
if (!file_exists($errorLog)) {
116
* Some useful values can be determined automatically...
120
private function _setAdditionalParams()
122
//define("HV_ROOT_DIR", substr(getcwd(), 0, -4));
123
//define("HV_WEB_ROOT_URL", "http://" . $_SERVER["SERVER_NAME"]
124
// . substr($_SERVER["SCRIPT_NAME"], 0, -14));
125
define("HV_CACHE_DIR", HV_ROOT_DIR . "/cache");
126
define("HV_TMP_DIR", HV_ROOT_DIR . "/cache/tmp");
127
define("HV_ERROR_LOG", HV_ROOT_DIR . "/log/error");
128
define("HV_EMPTY_TILE", HV_ROOT_DIR . "/resources/images/transparent_512.png");
129
define("HV_TMP_ROOT_URL", HV_WEB_ROOT_URL . "/cache/tmp");
b'\\ No newline at end of file'