1
0
Fork 0

Implemented new Configuration handling

Dieser Commit ist enthalten in:
DSB 2012-08-04 10:40:48 +00:00
Ursprung 6cfb97b401
Commit edc44e2f30
22 geänderte Dateien mit 730 neuen und 107 gelöschten Zeilen

Datei anzeigen

@ -35,15 +35,36 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
}
/**
*
* Set Firebug_logger in registry
* Initialize configuration.
*
* @return void
*/
public function _initFirbugLogger()
public function _initConfiguration()
{
$writer = new Zend_Log_Writer_Firebug();
$logger = new Zend_Log($writer);
Zend_Registry::set('logger', $logger);
$dynamicConfig = new Msd_Config_Dynamic();
$configFile = $dynamicConfig->getParam('configFile', 'defaultConfig.ini');
$config = new Msd_Config(
'Default',
array('directories' => APPLICATION_PATH . '/configs')
);
$config->load($configFile);
Msd_Registry::setConfig($config);
Msd_Registry::setDynamicConfig($dynamicConfig);
}
/**
* Un-quote a string or array
*
* @param string|array $value The value to strip
*
* @return string|array
*/
public static function stripslashes_deep($value)
{
$value = is_array($value) ? array_map('Bootstrap::stripslashes_deep', $value) : stripslashes($value);
return $value;
}
}

Datei anzeigen

@ -5,19 +5,19 @@ phpSettings.error_reporting = E_ALL
phpSettings.default_charset = "UTF-8"
phpSettings.date.timezone = "Europe/Berlin"
phpSettings.magic_quotes_runtime = 0
includePaths.library = APPLICATION_PATH "" DS ".." DS "library"
bootstrap.path = APPLICATION_PATH "" DS "Bootstrap.php"
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "" DS "controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH "" DS "modules"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.params.displayExceptions = 0
resources.view.basePath = APPLICATION_PATH "" DS "views"
resources.layout.layoutPath = APPLICATION_PATH "" DS "views" DS "layouts"
resources.frontController.actionHelperPaths.Msd_Action_Helper = "Msd" DS "Action" DS "Helper" DS
resources.view.basePath = APPLICATION_PATH "/views"
resources.layout.layoutPath = APPLICATION_PATH "/views/layouts"
resources.frontController.actionHelperPaths.Msd_Action_Helper = "Msd/Action/Helper/"
resources.view.encoding = "UTF-8"
resources.view.helperPath.ZendX_JQuery_View_Helper = "ZendX/JQuery/View/Helper/"
resources.view.helperPath.Msd_View_Helper = APPLICATION_PATH "" DS "views" DS "helpers"
resources.view.helperPath.Msd_View_Helper = APPLICATION_PATH "/views/helpers"
resources.view.doctype = XHTML1_STRICT
; setHelperPath plugin is no longer used, because the paths are set here.
resources.frontController.plugins.loginCheck = "Application_Plugin_LoginCheck"

Datei anzeigen

@ -9,4 +9,4 @@ request.params.a = "get_language_file"
request.params.v = ":version"
request.params.l = ":language"
request.sourceFileKey = "f"
targetBaseDir = APPLICATION_PATH "" DS "language"
targetBaseDir = APPLICATION_PATH "/language"

Datei anzeigen

@ -55,11 +55,10 @@ class IndexController extends Zend_Controller_Action
'badversion',
'install',
'default',
array(
'message' => 'L_PHP_VERSION_TOO_OLD'
)
array('message' => 'L_PHP_VERSION_TOO_OLD')
);
}
try {
$dbo = Msd_Db::getAdapter();
$data = Msd_File::getLatestBackupInfo();

Datei anzeigen

@ -108,8 +108,7 @@ class InstallController extends Zend_Controller_Action
$languagesStatus[$langId] = array(
'langName' => $langName,
'installed' => file_exists(
APPLICATION_PATH . DS . 'language' .
DS . $langId . DS . 'lang.php'
APPLICATION_PATH . '/language/' . $langId . '/lang.php'
)
);
}
@ -197,9 +196,9 @@ class InstallController extends Zend_Controller_Action
->setToken($postData['pass']);
if ($form->isValid($postData)) {
$ini = new Msd_Ini();
$ini->set('name', $postData['user'], '0');
$ini->set('pass', md5($postData['pass']), '0');
$ini->save(APPLICATION_PATH . DS . 'configs' . DS . 'users.ini');
$ini->set('name', $postData['user'], 'user');
$ini->set('pass', md5($postData['pass']), 'user');
$ini->saveFile(APPLICATION_PATH . '/configs/users.ini');
$redirectUrl = $this->view->url(array('controller' => 'install', 'action' => 'step4'), null, true);
$this->_response->setRedirect($redirectUrl);
}
@ -288,8 +287,8 @@ class InstallController extends Zend_Controller_Action
$lang = Msd_Language::getInstance();
$version = new Msd_Version();
$files = array(
'lang' => ':language' . DS . 'lang.php',
'flag' => ':language' . DS . 'flag.gif'
'lang' => ':language/lang.php',
'flag' => ':language/flag.gif'
);
if ($language === null) {
if (!isset($_SESSION['langlist'])) {
@ -305,8 +304,7 @@ class InstallController extends Zend_Controller_Action
return;
}
$update = new Msd_Update(
APPLICATION_PATH . DS . 'configs' .
DS . 'update.ini'
APPLICATION_PATH . '/configs/update.ini'
);
$update->setUpdateParam('language', $language);
$update->setUpdateParam('version', $version->getMsdVersion());

Datei anzeigen

@ -73,8 +73,8 @@ class Msd_View_Helper_GetIcon extends Zend_View_Helper_Abstract
if (!$icons) {
$config = Msd_Configuration::getInstance();
$file = realpath(
APPLICATION_PATH . DS . '..' . DS . 'public'
. DS . $config->get('paths.iconpath') . DS . 'icon.ini'
APPLICATION_PATH . '/../public/'
. $config->get('paths.iconpath') . '/icon.ini'
);
$iconsIni = new Zend_Config_Ini($file, 'icons');
$icons = $iconsIni->toArray();

Datei anzeigen

@ -67,8 +67,8 @@ class Msd_View_Helper_GetIconSrc extends Zend_View_Helper_Abstract
if (!$icons) {
$config = Msd_Configuration::getInstance();
$file = realpath(
APPLICATION_PATH . DS . '..' . DS . 'public'
. DS . $config->get('paths.iconpath') . DS .'icon.ini'
APPLICATION_PATH . '/../public/'
. $config->get('paths.iconpath') . '/icon.ini'
);
$iconsIni = new Zend_Config_Ini($file, 'icons');
$icons = $iconsIni->toArray();

Datei anzeigen

@ -2,7 +2,7 @@
$currentLanguage = $this->language;
$fallbackLanguage = $currentLanguage;
$languages = $this->languages;
$baseLangFile = APPLICATION_PATH . DS . 'language' . DS . '%s' . DS . 'lang.php';
$baseLangFile = APPLICATION_PATH . '/language/%s/lang.php';
?>
<script type="text/javascript">
function changeLang(lang)

Datei anzeigen

@ -42,7 +42,9 @@ class Msd_Auth_Adapter_Ini implements Zend_Auth_Adapter_Interface
*
* @param string $iniFilename Filename for registered users
*
* @return void
* @throws Msd_Exception
*
* @return Msd_Auth_Adapter_Ini
*/
public function __construct($iniFilename)
{
@ -57,6 +59,8 @@ class Msd_Auth_Adapter_Ini implements Zend_Auth_Adapter_Interface
/**
* set the username, which is used for authentication.
*
* @param string $username The username
*
* @return void
*/
public function setUsername($username)
@ -67,6 +71,8 @@ class Msd_Auth_Adapter_Ini implements Zend_Auth_Adapter_Interface
/**
* Set the password, which is used for authentication.
*
* @param string $password The password
*
* @return void
*/
public function setPassword($password)
@ -77,6 +83,8 @@ class Msd_Auth_Adapter_Ini implements Zend_Auth_Adapter_Interface
/**
* Authenticate with the given credentials.
*
* @throws Msd_Exception
*
* @return Zend_Auth_Result
*/
public function authenticate()

193
library/Msd/Config.php Normale Datei
Datei anzeigen

@ -0,0 +1,193 @@
<?php
/**
* This file is part of MySQLDumper released under the GNU/GPL 2 license
* http://www.mysqldumper.net
*
* @package MySQLDumper
* @subpackage Config
* @version SVN: $Rev$
* @author $Author$
*/
/**
* Class to handle the configuration
*
* @throws Msd_Config_Exception
* @package MySQLDumper
* @subpackage Config
*/
class Msd_Config
{
/**
* The configuration itself.
*
* @var array
*/
private $_config = null;
/**
* Instance of the IO-Handler.
*
* @var Msd_Config_IoHandler_Interface
*/
private $_ioHandler = null;
/**
* Status for the automatic configuration saving on class destruction.
* It's disabled by default.
*
* @var bool
*/
private $_autosave = false;
/**
* Class constructor
*
* @param Msd_Config_IoHandler_Interface|string $ioHandler Instance or name of the IO-Handler.
* @param array $handlerOptions Options for the IO-Handler.
*
* @throws Msd_Config_Exception
*/
public function __construct($ioHandler, $handlerOptions = array())
{
if (is_string($ioHandler)) {
$pluginLoader = new Zend_Loader_PluginLoader(
array(
'Msd_Config_IoHandler_' => APPLICATION_PATH . '/../library/Msd/Config/IoHandler/',
'Module_Config_IoHandler_' => APPLICATION_PATH . '/../modules/library/Config/IoHandler/',
)
);
$className = $pluginLoader->load($ioHandler);
$ioHandler = new $className($handlerOptions);
}
if (!$ioHandler instanceof Msd_Config_IoHandler_Interface) {
throw new Msd_Config_Exception(
"Invalid IO-Handler specified; The IO-Handler must implement Msd_Config_IoHandler_Interface"
);
}
$this->_ioHandler = $ioHandler;
}
/**
* Loads the configuration from the IO-Handler.
* The filename is used for static storage.
*
* @param string $configFilename Name of file on the static storage.
*
* @return void
*/
public function load($configFilename)
{
$this->_config = $this->_ioHandler->load($configFilename);
}
/**
* Saves the configuration for the next request.
* The filename is used for static storage.
*
* @return bool
*/
public function save()
{
return $this->_ioHandler->save($this->_config);
}
/**
* Retrieves the value of a configuration parameter.
*
* @param string $paramName Name of the configuration parameter.
* @param mixed $defaultValue Default value to return, if param isn't set.
*
* @return mixed
*/
public function getParam($paramName, $defaultValue = null)
{
if (isset($this->_config[$paramName])) {
return $this->_config[$paramName];
}
return $defaultValue;
}
/**
* Sets a configuration parameter.
* If auto-save is enabled the configuration is also saved.
*
* @param $paramName
* @param $paramValue
*
* @return void
*/
public function setParam($paramName, $paramValue)
{
$this->_config[$paramName] = $paramValue;
if ($this->_autosave) {
$this->save();
}
}
/**
* Class destructor.
* If auto-save is enabled the configuration will be saved.
*/
public function __destruct()
{
if ($this->_autosave) {
$this->save();
}
}
/**
* Sets the whole configuration.
* If auto-save is enabled the configuration is also saved.
*
* @param array $config New configuration.
*/
public function setConfig($config)
{
$this->_config = (array) $config;
if ($this->_autosave) {
$this->save();
}
}
/**
* Returns the whole configuration.
*
* @return array
*/
public function getConfig()
{
return $this->_config;
}
/**
* Enables automatic configuration saving.
*
* @return void
*/
public function enableAutosave()
{
$this->_autosave = true;
}
/**
* Disables automatic configuration saving.
*
* @return void
*/
public function disableAutosave()
{
$this->_autosave = false;
}
/**
* Returns the autosave status.
*
* @return bool
*/
public function isAutosaveActive()
{
return $this->_autosave;
}
}

Datei anzeigen

@ -0,0 +1,67 @@
<?php
/**
* This file is part of MySQLDumper released under the GNU/GPL 2 license
* http://www.mysqldumper.net
*
* @package MySQLDumper
* @subpackage Config
* @version SVN: $Rev$
* @author $Author$
*/
/**
* Class for dynamic (session lifetime) configuration settings.
*
* @package MySQLDumper
* @subpackage Config
*/
class Msd_Config_Dynamic
{
/**
* Instance of Zend_Session_Namespace for session storage.
*
* @var Zend_Session_Namespace
*/
private $_namespace = null;
/**
* Class constructor.
*
* @param string $sessionNsName Name of the session namespace.
*
* @return Msd_Config_Dynamic
*/
public function __construct($sessionNsName = 'Dynamic')
{
$this->_namespace = new Zend_Session_Namespace($sessionNsName);
}
/**
* Retrieves the value of a parameter.
*
* @param string $name Name of the parameter.
* @param mixed $default Default value to return, if param isn't set.
*
* @return mixed
*/
public function getParam($name, $default = null)
{
if (isset($this->_namespace->$name)) {
return $this->_namespace->$name;
}
return $default;
}
/**
* Sets a value for the given parameter.
*
* @param string $name Name of the parameter.
* @param mixed $value Value for the parameter.
*
* @return void
*/
public function setParam($name, $value)
{
$this->_namespace->$name = $value;
}
}

Datei anzeigen

@ -0,0 +1,19 @@
<?php
/**
* This file is part of MySQLDumper released under the GNU/GPL 2 license
* http://www.mysqldumper.net
*
* @package MySQLDumper
* @subpackage Config
* @version SVN: $Rev$
* @author $Author$
*/
/**
* Exception class for configuration class.
*
* @package MySQLDumper
* @subpackage Config
*/
class Msd_Config_Exception extends Msd_Exception
{
}

Datei anzeigen

@ -0,0 +1,128 @@
<?php
/**
* This file is part of MySQLDumper released under the GNU/GPL 2 license
* http://www.mysqldumper.net
*
* @package MySQLDumper
* @subpackage Config_IoHandler
* @version SVN: $Rev$
* @author $Author$
*/
/**
* Class to handle input/output for configuration params.
*
* @package MySQLDumper
* @subpackage Config_IoHandler
*/
class Msd_Config_IoHandler_Default implements Msd_Config_IoHandler_Interface
{
/**
* Array with directories, where config files are located.
*
* @var array
*/
private $_configDirectories = array();
/**
* Handler for .ini files.
*
* @var Msd_Ini
*/
private $_iniConfig = null;
/**
* Name of the .ini file, where the config is stored.
*
* @var string
*/
private $_configFilename = null;
/**
* Configuration namespace in session.
*
* @var Zend_Session_Namespace
*/
private $_sessionNamespace = null;
/**
* Class constructor
*
* @param array $handlerOptions
*
* @return Msd_Config_IoHandler_Default
*/
public function __construct($handlerOptions = array())
{
if (isset($handlerOptions['directories'])) {
$this->_configDirectories = (array) $handlerOptions['directories'];
}
// Create new namespace for session access.
$this->_sessionNamespace = new Zend_Session_Namespace('Config');
}
/**
* Loads and returns a configuration from session or .ini file.
* If the config is read from .ini file, it is also stored to session.
*
* @param string $configFilename Name of the .ini file, where the config is stored.
*
* @return array
*/
public function load($configFilename)
{
// Retrieve config from session
$config = (array) $this->_sessionNamespace->config;
$this->_configFilename = $configFilename;
// Check whether the configuration has been loaded.
if (count($config) == 0) {
// Search for the config file in the given directories.
$this->_initIni();
$config = $this->_iniConfig->getIniData();
// Put configuration into session.
$this->_sessionNamespace->config = $config;
}
return $config;
}
/**
* Saves the configuration to session and .ini file.
*
* @param array $config Configuration to save.
*
* @return bool
*/
public function save($config)
{
if ($this->_iniConfig === null) {
$this->_initIni();
}
// Save config to session
$this->_sessionNamespace->config = $config;
// Save config to .ini file
$this->_iniConfig->setIniData($config);
return $this->_iniConfig->saveFile($this->_configFilename);
}
/**
* Initializes the .ini file handler and sets the full filename of the .ini file.
*
* @return void
*/
private function _initIni()
{
foreach ($this->_configDirectories as $configDir) {
$filename = rtrim($configDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $this->_configFilename;
if (file_exists($filename)) {
$this->_configFilename = $filename;
$this->_iniConfig = new Msd_Ini($filename);
break;
}
}
}
}

Datei anzeigen

@ -0,0 +1,51 @@
<?php
/**
* This file is part of MySQLDumper released under the GNU/GPL 2 license
* http://www.mysqldumper.net
*
* @package MySQLDumper
* @subpackage Config_IoHandler
* @version SVN: $Rev$
* @author $Author$
*/
/**
* Interface for configuration IO-Handler.
*
* @package MySQLDumper
* @subpackage Config_IoHandler
*/
interface Msd_Config_IoHandler_Interface
{
/**
* Class constructor
*
* @abstract
*
* @param array $handlerOptions
*
* @return Msd_Config_IoHandler_Interface
*/
public function __construct($handlerOptions = array());
/**
* Loads and returns the configuration.
*
* @abstract
*
* @param string $configFilename
*
* @return array
*/
public function load($configFilename);
/**
* Saves the configuration.
*
* @abstract
*
* @param array $config
*
* @return bool
*/
public function save($config);
}

Datei anzeigen

@ -198,7 +198,7 @@ class Msd_Configuration
}
$configWriter = new Zend_Config_Writer_Ini(
array(
'filename' => $this->get('paths.config') . DS . $fileName,
'filename' => $this->get('paths.config') . '/' . $fileName,
'config' => $configData,
)
);
@ -253,11 +253,10 @@ class Msd_Configuration
if ($configName != 'defaultConfig') {
$configName .= '.ini';
$configPath = $this->get('paths.config');
$configFile = $configPath . DS . $configName;
$configFile = $configPath . '/' . $configName;
} else {
// special case - defaultConfig.ini is in application/configs
$configFile = realpath(APPLICATION_PATH . DS . 'configs')
. DS . 'defaultConfig.ini';
$configFile = realpath(APPLICATION_PATH . '/configs') . '/defaultConfig.ini';
}
if (!is_readable($configFile)) {
throw new Msd_Exception(
@ -286,7 +285,7 @@ class Msd_Configuration
private function _loadUserDirectories()
{
// set paths
$workRoot = realpath(APPLICATION_PATH . DS . '..') . DS . 'work' . DS;
$workRoot = realpath(APPLICATION_PATH . '/..') . '/work/';
$directories = array(
'work' => $workRoot,
'log' => $workRoot . 'log',

Datei anzeigen

@ -30,12 +30,19 @@ class Msd_Ini
*/
private $_iniFilename = null;
/**
* Determines the escaping of the output.
*
* @var bool
*/
private $_escapeIniOutput = true;
/**
* Class constructor
*
* @param array|string $options Configuration or filename of INI to load
*
* @return void
* @return Msd_Ini
*/
public function __construct($options = array())
{
@ -60,6 +67,8 @@ class Msd_Ini
*
* @param string $filename Name of file to load
*
* @throws Msd_Exception
*
* @return void
*/
public function loadFile($filename = null)
@ -82,9 +91,11 @@ class Msd_Ini
*
* @param string $filename Name of file to save
*
* @return void
* @throws Msd_Exception
*
* @return bool
*/
public function save($filename = null)
public function saveFile($filename = null)
{
if ($filename === null) {
$filename = $this->_iniFilename;
@ -94,20 +105,20 @@ class Msd_Ini
'You must specify a filename to save the INI!'
);
}
$fileHandle = fopen($filename, 'w+');
fwrite($fileHandle, (string) $this);
fclose($fileHandle);
$res = file_put_contents($filename, (string) $this);
return $res === false ? false : true;
}
/**
* Converts an array into the INI file format.
*
* @param array $array Array to convert.
* @param integer $level Current depthlevel in the array.
* @param integer $level Current depth level in the array.
* @param string $prefix Prefix to use for var name.
*
* @return string
*/
private function _arrayToIniString($array = null, $level = -1)
private function _arrayToIniString($array = null, $level = -1, $prefix = '')
{
if ($array === null) {
$array = $this->_iniData;
@ -116,18 +127,27 @@ class Msd_Ini
$resultString = '';
foreach ($array as $key => $value) {
if (is_array($value)) {
$resultString .= ($level == 0) ?
'[' . $key . ']' . "\n" :
$key . '.';
$resultString .= $this->_arrayToIniString($value);
if ($level == 0) {
$resultString .= '[' . $key . ']' . "\n";
$resultString .= $this->_arrayToIniString($value, $level);
} else {
$newValue = str_replace(
$resultString .= $this->_arrayToIniString($value, $level, $key);
}
} else {
$newValue = $value;
if ($this->_escapeIniOutput) {
$newValue = "\"" . str_replace(
array('\\', '"'),
array('\\\\', '\\"'),
$value
);
$resultString .= $key . ' = "' . (string) $newValue . '"';
) . "\"";
}
$resultString .= ltrim("$prefix.$key", '.') . " = $newValue\n";
}
}
if ($level < 2) {
$resultString .= "\n";
}
@ -170,16 +190,6 @@ class Msd_Ini
}
}
/**
* Get the complete INI.
*
* @return array
*/
public function getAll()
{
return $this->_iniData;
}
/**
* Convert this class into a string.
*
@ -189,4 +199,68 @@ class Msd_Ini
{
return $this->_arrayToIniString();
}
/**
* Sets the INI data.
*
* @param array $iniData New INI data.
*
* @return void
*/
public function setIniData($iniData)
{
$this->_iniData = $iniData;
}
/**
* Gets the parsed INI data.
*
* @return array
*/
public function getIniData()
{
return $this->_iniData;
}
/**
* Disables the escaping of the output for the INI file.
*
* @return void
*/
public function disableEscaping()
{
$this->setEscapeIniOutput(false);
}
/**
* Enables the escaping of the output for the INI file.
*
* @return void
*/
public function enableEscaping()
{
$this->setEscapeIniOutput(true);
}
/**
* En-/Disables the escaping of the output for the INI file.
*
* @param boolean $escapeIniOutput TRUE - Escaping enabled (default), FALSE - Escaping disabled
*
* @return void
*/
public function setEscapeIniOutput($escapeIniOutput)
{
$this->_escapeIniOutput = $escapeIniOutput;
}
/**
* Retrieves escaping status of the output for the INI file.
*
* @return boolean
*/
public function getEscapeIniOutput()
{
return $this->_escapeIniOutput;
}
}

Datei anzeigen

@ -60,8 +60,8 @@ class Msd_Language
*/
public function loadLanguage($language)
{
$this->_baseLanguageDir = APPLICATION_PATH . DS . 'language' . DS;
$file = $this->_baseLanguageDir . $language . DS . 'lang.php';
$this->_baseLanguageDir = APPLICATION_PATH . '/language/';
$file = $this->_baseLanguageDir . $language . '/lang.php';
$translator = $this->getTranslator();
if ($translator === null) {
$translator = new Zend_Translate('array', $file, $language);

Datei anzeigen

@ -145,16 +145,16 @@ class Msd_Log
$filename = '';
switch ($file) {
case self::PHP:
$filename = $this->_paths->log . DS . 'php.log';
$filename = $this->_paths->log . '/php.log';
break;
case self::PERL:
$filename = $this->_paths->log . DS . 'perl.log';
$filename = $this->_paths->log . '/perl.log';
break;
case self::PERL_COMPLETE:
$filename = $this->_paths->log . DS . 'perlComplete.log';
$filename = $this->_paths->log . '/perlComplete.log';
break;
case self::ERROR:
$filename = $this->_paths->log . DS . 'phpError.log';
$filename = $this->_paths->log . '/phpError.log';
}
return $filename;
}

76
library/Msd/Registry.php Normale Datei
Datei anzeigen

@ -0,0 +1,76 @@
<?php
/**
* This file is part of MySQLDumper released under the GNU/GPL 2 license
* http://www.mysqldumper.net
*
* @package MySQLDumper
* @subpackage Registry
* @version SVN: $Rev$
* @author $Author$
*/
/**
* Abstract decorator for form elements of Msd_Form
*
* @package MySQLDumper
* @subpackage Registry
*/
class Msd_Registry extends Zend_Registry
{
/**
* Returns the config instance if it has been registered, returns null otherwise.
*
* @return Msd_Config|null
*/
public static function getConfig()
{
if (self::isRegistered('_config')) {
return self::get('_config');
}
return null;
}
/**
* Register a Msd_Config instance.
*
* @static
*
* @param Msd_Config $config Configuration
*
* @return void
*/
public static function setConfig(Msd_Config $config)
{
self::set('_config', $config);
}
/**
* Returns the dynamic config if it has been registered.
*
* @static
*
* @return Msd_Config_Dynamic|null
*/
public static function getDynamicConfig()
{
if (self::isRegistered('_dynamic')) {
return self::get('_dynamic');
}
return null;
}
/**
* Registers the dynamic configuration.
*
* @static
*
* @param Msd_Config_Dynamic $config Dynamic configuration.
*
* @return void
*/
public static function setDynamicConfig(Msd_Config_Dynamic $config)
{
self::set('_dynamic', $config);
}
}

Datei anzeigen

@ -96,12 +96,11 @@ class Msd_User
/**
* Constructor
*
* @return void
* @return Msd_User
*/
public function __construct()
{
$this->_usersFile = APPLICATION_PATH . DS . 'configs' . DS
. 'users.ini';
$this->_usersFile = APPLICATION_PATH . '/configs/users.ini';
$this->_authStorage = new Zend_Auth_Storage_Session();
$auth = $this->_authStorage->read();
if (!empty($auth)) {
@ -157,8 +156,8 @@ class Msd_User
return self::NO_USER_FILE;
}
$usersIni = new Msd_Ini($this->_usersFile);
$users = $usersIni->getAll();
$usersConfig = new Msd_Ini($this->_usersFile);
$users = $usersConfig->get('user');
$hasValidUser = false;
foreach ($users as $user) {
@ -167,7 +166,6 @@ class Msd_User
break;
}
}
if (!$hasValidUser) {
return self::NO_VALID_USER;
}
@ -221,6 +219,7 @@ class Msd_User
// to stay logged in until you logout.
$this->login($username, $pass, true);
}
/**
* Clear the user identity and logout the user.
*

Datei anzeigen

@ -42,7 +42,7 @@ class Msd_Version
* @param array $options Option-array to overwrite required PHP/MySQL
* versions
*
* @return void
* @return Msd_Version
*/
public function __construct($options = array())
{

Datei anzeigen

@ -1,18 +1,13 @@
<?php
define('DS', DIRECTORY_SEPARATOR);
define('WORK_PATH', realpath(dirname(__FILE__) . DS. '..' . DS . 'work'));
define('WORK_PATH', realpath(dirname(__FILE__) . '/../work'));
// Define path to application directory
defined('APPLICATION_PATH') || define(
'APPLICATION_PATH', realpath(
dirname(__FILE__) . DS . '..' . DS . 'application'
)
'APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application')
);
defined('LIBRARY_PATH') || define(
'LIBRARY_PATH', realpath(
dirname(__FILE__) . DS . '..' . DS . 'library'
)
'LIBRARY_PATH', realpath(dirname(__FILE__) . '/../library')
);
// Define application environment
@ -28,11 +23,7 @@ if (!defined('APPLICATION_ENV')) {
// Ensure library/ is on include_path
set_include_path(
implode(
PATH_SEPARATOR, array(realpath(
APPLICATION_PATH . DS . '..' . DS .'library'
),
get_include_path())
implode(PATH_SEPARATOR, array(LIBRARY_PATH, get_include_path())
)
);
@ -47,7 +38,7 @@ require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . DS . 'configs' . DS .'application.ini'
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();