Removed the final hardcoded paths, changed the reload logic in the Config class, and updated the controller to pass the config file name, not the config file short name.
git-svn-id: http://svn.cleancode.org/svn/pickles@54 4d10bc64-7434-11dc-a737-d2d0f8310089
This commit is contained in:
parent
0fa204a6ad
commit
cbcfc9cc4f
3 changed files with 15 additions and 9 deletions
|
@ -2,8 +2,8 @@
|
|||
|
||||
date_default_timezone_set('America/New_York');
|
||||
|
||||
define('PICKLES_PATH', getcwd() . '/../../pickles/');
|
||||
define('TEMP_PATH', '/tmp/smarty/' . $_SERVER['SERVER_NAME'] . '/');
|
||||
define('PICKLES_PATH', (phpversion() < 5.3 ? dirname(__FILE__) : __DIR__) . '/');
|
||||
define('TEMP_PATH', sys_get_temp_dir() . '/pickles/smarty/' . $_SERVER['SERVER_NAME'] . '/');
|
||||
|
||||
function __autoload($class) {
|
||||
$file = PICKLES_PATH . 'classes/' . str_replace('_', '/', $class) . '.php';
|
||||
|
|
|
@ -23,11 +23,17 @@ class Config extends Singleton {
|
|||
return self::$instance;
|
||||
}
|
||||
|
||||
public function load($site) {
|
||||
// @todo getting warnings on the filemtime
|
||||
if (!isset($this->file) || @filemtime($this->file) > $this->timestamp) {
|
||||
$file = PICKLES_PATH . 'config/' . $site . '.xml';
|
||||
|
||||
public function load($file) {
|
||||
$load = true;
|
||||
if (isset($this->file)) {
|
||||
if (file_exists($this->file) && isset($this->timestamp)) {
|
||||
if (filemtime($this->file) < $this->timestamp) {
|
||||
$load = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($load) {
|
||||
if (file_exists($file)) {
|
||||
$this->file = $file;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ class Controller extends Object {
|
|||
private $controller = null;
|
||||
*/
|
||||
|
||||
public function __construct($site, $controller = 'Web') {
|
||||
public function __construct($file = '../config.xml', $controller = 'Web') {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
|
@ -23,7 +23,7 @@ class Controller extends Object {
|
|||
|
||||
// Load the config for the site passed in
|
||||
$this->config = Config::getInstance();
|
||||
$this->config->load($site);
|
||||
$this->config->load($file);
|
||||
|
||||
// Generate a generic "site down" message
|
||||
if ($this->config->get('disabled')) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue