diff options
author | nashe <thomas@chauchefoin.fr> | 2017-05-28 13:49:56 +0200 |
---|---|---|
committer | nashe <thomas@chauchefoin.fr> | 2017-05-28 13:49:56 +0200 |
commit | b3610f17ef53dd3b3455614263ffd809843b101c (patch) | |
tree | 98eae966c33b1abc3e1f606f9953a9a40ebfe35e | |
parent | b3274cae04bc319c71d9d2037384480e8f8dc43c (diff) | |
download | planet-b3610f17ef53dd3b3455614263ffd809843b101c.tar planet-b3610f17ef53dd3b3455614263ffd809843b101c.tar.gz planet-b3610f17ef53dd3b3455614263ffd809843b101c.tar.bz2 planet-b3610f17ef53dd3b3455614263ffd809843b101c.tar.xz planet-b3610f17ef53dd3b3455614263ffd809843b101c.zip |
Move the debug directive to configuration file
-rwxr-xr-x | app/app.php | 13 | ||||
-rw-r--r-- | app/classes/PlanetConfig.php | 37 | ||||
-rwxr-xr-x | install.php | 3 |
3 files changed, 30 insertions, 23 deletions
diff --git a/app/app.php b/app/app.php index ec4e446..dca9bc4 100755 --- a/app/app.php +++ b/app/app.php @@ -1,12 +1,6 @@ <?php -//Debug ? -$debug = isset($_GET['debug']) ? $_GET['debug'] : 0; -if ($debug) { - error_reporting(E_ALL); -} else { - error_reporting(0); -} +error_reporting(0); require_once __DIR__.'/../vendor/autoload.php'; @@ -26,6 +20,11 @@ if (is_file($savedConfig)){ $PlanetConfig = new PlanetConfig($conf); $Planet = new Planet($PlanetConfig); + + if ($conf['debug']) { + error_reporting(E_ALL); + } + } $l10n = new Simplel10n($conf['locale']); diff --git a/app/classes/PlanetConfig.php b/app/classes/PlanetConfig.php index 709bc2e..18ffabd 100644 --- a/app/classes/PlanetConfig.php +++ b/app/classes/PlanetConfig.php @@ -8,27 +8,29 @@ class PlanetConfig public $conf; + protected static $defaultConfig = array( + 'url' => 'http://www.example.com/', + 'name' => '', + 'locale' => 'en', + 'items' => 10, + 'shuffle' => 0, + 'refresh' => 240, + 'cache' => 10, + 'nohtml' => 0, + 'postmaxlength' => 0, + 'categories' => '', + 'cachedir' => './cache', + 'debug' => false + ); + public function __construct($array) { - $defaultConfig = array( - 'url' => 'http://www.example.com/', - 'name' => '', - 'locale' => 'en', - 'items' => 10, - 'shuffle' => 0, - 'refresh' => 240, - 'cache' => 10, - 'nohtml' => 0, - 'postmaxlength' => 0, - 'cachedir' => './cache', - ); - // User config $this->conf = $array; // Complete config with default config - foreach ($defaultConfig as $key => $value) { - if (!isset($this->conf[$key])) { + foreach (self::$defaultConfig as $key => $value) { + if (!array_key_exists($key, $this->conf)) { $this->conf[$key] = $value; } } @@ -91,6 +93,11 @@ class PlanetConfig return Spyc::YAMLDump($this->conf,4); } + public function getDebug() + { + return $this->conf['debug']; + } + /** * Generic accessor for config. */ diff --git a/install.php b/install.php index cc539dd..9f627ae 100755 --- a/install.php +++ b/install.php @@ -25,7 +25,8 @@ if (file_exists(dirname(__FILE__) . '/custom/config.yml') && isset($login) && is 'cache' => 10, 'nohtml' => 0, 'postmaxlength' => 0, - 'cachedir' => './cache' + 'cachedir' => './cache', + 'debug' => false ); $CreatePlanetConfig = new PlanetConfig($config); |