1
0
Fork 0

Fixed icon path after saving configuration.

Dieser Commit ist enthalten in:
D4rk4ng3l 2012-08-08 22:36:28 +00:00
Ursprung 4f36119278
Commit 88791f1a9c
9 geänderte Dateien mit 235 neuen und 124 gelöschten Zeilen

Datei anzeigen

@ -24,7 +24,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
/** /**
* Start session * Start session
* *
* Anyhing else is set in configs/application.ini * Anything else is set in configs/application.ini
* *
* @return void * @return void
*/ */
@ -34,8 +34,8 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
Zend_Session::start(); Zend_Session::start();
// check if server has magic quotes enabled and normalize params // check if server has magic quotes enabled and normalize params
if ( (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() == 1)) { if ((function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() == 1)) {
$_POST = Bootstrap::stripslashes_deep($_POST); $_POST = Bootstrap::stripSlashesDeep($_POST);
} }
} }
@ -49,6 +49,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{ {
$dynamicConfig = new Msd_Config_Dynamic(); $dynamicConfig = new Msd_Config_Dynamic();
$configFile = $dynamicConfig->getParam('configFile', 'mysqldumper.ini'); $configFile = $dynamicConfig->getParam('configFile', 'mysqldumper.ini');
Msd_Registry::setConfigFilename($configFile);
$config = new Msd_Config( $config = new Msd_Config(
'Default', 'Default',
array('directories' => realpath(APPLICATION_PATH . '/../work/config')) array('directories' => realpath(APPLICATION_PATH . '/../work/config'))
@ -65,9 +66,9 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
* *
* @return string|array * @return string|array
*/ */
public static function stripslashes_deep($value) public static function stripSlashesDeep($value)
{ {
$value = is_array($value) ? array_map('Bootstrap::stripslashes_deep', $value) : stripslashes($value); $value = is_array($value) ? array_map(array('Bootstrap', 'stripSlashesDeep'), $value) : stripslashes($value);
return $value; return $value;
} }

Datei anzeigen

@ -9,9 +9,9 @@
* @author $Author$ * @author $Author$
*/ */
/** /**
* Config Controller * Config Controller.
* *
* Controller to handle actions triggered on configuration screen * Controller to handle actions triggered on configuration screen.
* *
* @package MySQLDumper * @package MySQLDumper
* @subpackage Controllers * @subpackage Controllers
@ -20,6 +20,7 @@ class ConfigController extends Msd_Controller_Action
{ {
/** /**
* Active jQuery tab Id * Active jQuery tab Id
*
* @var string * @var string
*/ */
private $_activeTab = 'tab_general'; private $_activeTab = 'tab_general';
@ -61,7 +62,7 @@ class ConfigController extends Msd_Controller_Action
$formGeneral = $this->_getSubformIni('general'); $formGeneral = $this->_getSubformIni('general');
$elementTitle = $formGeneral->getElement('title'); $elementTitle = $formGeneral->getElement('title');
$elementTitle->setValue( $elementTitle->setValue(
$this->view->config->getParam('general.title') $this->_config->getParam('general.title')
); );
$form->addSubForm($formGeneral, 'general'); $form->addSubForm($formGeneral, 'general');
@ -184,9 +185,9 @@ class ConfigController extends Msd_Controller_Action
// set dynamic actual database if it's changed in the panel // set dynamic actual database if it's changed in the panel
if ($this->_request->isPost()) { if ($this->_request->isPost()) {
$actualDb = $this->view->dynamicConfig->getParam('dbActual'); $actualDb = $this->_dynamicConfig->getParam('dbActual');
if (isset($_POST['defaultDb']) && ($_POST['defaultDb'] != $actualDb)) { if (isset($_POST['defaultDb']) && ($_POST['defaultDb'] != $actualDb)) {
$this->view->dynamicConfig->setParam('dbActual', $_POST['defaultDb']); $this->_dynamicConfig->setParam('dbActual', $_POST['defaultDb']);
} }
} }
@ -196,14 +197,14 @@ class ConfigController extends Msd_Controller_Action
/** /**
* Read ini file and create subform * Read ini file and create subform
* *
* @param string $subform * @param string $subForm
* *
* @return Zend_Form_SubForm * @return Zend_Form_SubForm
*/ */
private function _getSubformIni($subform) private function _getSubformIni($subForm)
{ {
$subFormIni = new Zend_Config_Ini(APPLICATION_PATH . '/forms/Config/' . $subform . '.ini'); $subFormIni = new Zend_Config_Ini(APPLICATION_PATH . '/forms/Config/' . $subForm . '.ini');
$options = array('displayGroupPrefixPath' => $subform . '_'); $options = array('displayGroupPrefixPath' => $subForm . '_');
return new Zend_Form_SubForm($subFormIni, $options); return new Zend_Form_SubForm($subFormIni, $options);
} }
@ -214,7 +215,7 @@ class ConfigController extends Msd_Controller_Action
*/ */
public function addRecipientCcAction() public function addRecipientCcAction()
{ {
$recipientsCc = $this->view->config->Param('email.RecipientCc'); $recipientsCc = $this->_config->Param('email.RecipientCc');
if ($recipientsCc === null) { if ($recipientsCc === null) {
$recipientsCc = array(); $recipientsCc = array();
} }
@ -222,7 +223,7 @@ class ConfigController extends Msd_Controller_Action
$recipientsCc[$index]['Name'] = ''; $recipientsCc[$index]['Name'] = '';
$recipientsCc[$index]['Address'] = ''; $recipientsCc[$index]['Address'] = '';
$recipientsCc = array_values($recipientsCc); $recipientsCc = array_values($recipientsCc);
$this->view->config->setParam('email.RecipientCc', $recipientsCc); $this->_config->setParam('email.RecipientCc', $recipientsCc);
$this->_forward('index'); $this->_forward('index');
} }
@ -233,12 +234,12 @@ class ConfigController extends Msd_Controller_Action
*/ */
public function deleteRecipientCcAction() public function deleteRecipientCcAction()
{ {
$recipientToDelete = (int)$this->_request->getPost('param'); $recipientToDelete = (int) $this->_request->getPost('param');
$recipientsCc = $this->view->config->getParam('email.RecipientCc'); $recipientsCc = $this->_config->getParam('email.RecipientCc');
if (isset($recipientsCc[$recipientToDelete])) { if (isset($recipientsCc[$recipientToDelete])) {
unset($recipientsCc[$recipientToDelete]); unset($recipientsCc[$recipientToDelete]);
} }
$this->view->config->setParam('email.RecipientCc', $recipientsCc); $this->_config->setParam('email.RecipientCc', $recipientsCc);
$this->_forward('index'); $this->_forward('index');
} }
@ -249,7 +250,7 @@ class ConfigController extends Msd_Controller_Action
*/ */
public function addFtpConnectionAction() public function addFtpConnectionAction()
{ {
$ftpConfig = $this->view->config->getParam('ftp'); $ftpConfig = $this->_config->getParam('ftp');
$index = 0; $index = 0;
if (!empty($ftpConfig)) { if (!empty($ftpConfig)) {
$index = max(array_keys($ftpConfig)) + 1; $index = max(array_keys($ftpConfig)) + 1;
@ -266,7 +267,7 @@ class ConfigController extends Msd_Controller_Action
'dir' => "/" 'dir' => "/"
); );
$ftpConfig[$index] = $default; $ftpConfig[$index] = $default;
$this->view->config->setParam('ftp', $ftpConfig); $this->_config->setParam('ftp', $ftpConfig);
$this->_forward('index'); $this->_forward('index');
} }
@ -277,14 +278,14 @@ class ConfigController extends Msd_Controller_Action
*/ */
public function deleteFtpConnectionAction() public function deleteFtpConnectionAction()
{ {
$index = (int)$this->_request->getPost('param'); $index = (int) $this->_request->getPost('param');
$ftpConfig = $this->view->config->getParam('ftp'); $ftpConfig = $this->_config->getParam('ftp');
if (count($ftpConfig) > 1) { if (count($ftpConfig) > 1) {
if (isset($ftpConfig[$index])) { if (isset($ftpConfig[$index])) {
unset($ftpConfig[$index]); unset($ftpConfig[$index]);
sort($ftpConfig); sort($ftpConfig);
} }
$this->view->config->setParam('ftp', $ftpConfig); $this->_config->setParam('ftp', $ftpConfig);
} }
$this->_forward('index'); $this->_forward('index');
} }
@ -301,7 +302,7 @@ class ConfigController extends Msd_Controller_Action
if ($this->_request->isPost()) { if ($this->_request->isPost()) {
$postData = $this->_request->getPost(); $postData = $this->_request->getPost();
$index = (int)$this->_request->getPost('param'); $index = (int) $this->_request->getPost('param');
// fetch the required params // fetch the required params
$server = $postData['ftp_' . $index . '_server']; $server = $postData['ftp_' . $index . '_server'];
@ -330,7 +331,6 @@ class ConfigController extends Msd_Controller_Action
// got resource? // got resource?
if (!is_resource($ftpStream)) { if (!is_resource($ftpStream)) {
$message = sprintf($translator->_('L_FTP_CONNECTION_ERROR'), $server, $port); $message = sprintf($translator->_('L_FTP_CONNECTION_ERROR'), $server, $port);
// connection ok? let's try to login // connection ok? let's try to login
} else if (!ftp_login($ftpStream, $user, $password)) { } else if (!ftp_login($ftpStream, $user, $password)) {
$message = sprintf($translator->_('L_FTP_LOGIN_ERROR'), $user); $message = sprintf($translator->_('L_FTP_LOGIN_ERROR'), $user);
@ -339,7 +339,6 @@ class ConfigController extends Msd_Controller_Action
if ($mode == 'y') { if ($mode == 'y') {
ftp_pasv($ftpStream, true); ftp_pasv($ftpStream, true);
} }
// login ok? let's set/change the ftp upload directory // login ok? let's set/change the ftp upload directory
} else if (!ftp_chdir($ftpStream, $directory)) { } else if (!ftp_chdir($ftpStream, $directory)) {
$message = sprintf($translator->_('L_CHANGEDIRERROR')); $message = sprintf($translator->_('L_CHANGEDIRERROR'));
@ -350,7 +349,6 @@ class ConfigController extends Msd_Controller_Action
// ftp directory exists and chmod ok? let's test the ftp transfer with a test file // ftp directory exists and chmod ok? let's test the ftp transfer with a test file
} else if (!ftp_put($ftpStream, $targetFolder . $name, $filename, FTP_ASCII)) { } else if (!ftp_put($ftpStream, $targetFolder . $name, $filename, FTP_ASCII)) {
$message = sprintf($translator->_('L_FTP_FILE_TRANSFER_ERROR'), $name); $message = sprintf($translator->_('L_FTP_FILE_TRANSFER_ERROR'), $name);
} else { } else {
$upload = true; $upload = true;
$message = sprintf($translator->_('L_FTP_FILE_TRANSFER_SUCCESS'), $name) $message = sprintf($translator->_('L_FTP_FILE_TRANSFER_SUCCESS'), $name)
@ -409,7 +407,7 @@ class ConfigController extends Msd_Controller_Action
foreach ($elements as $element) { foreach ($elements as $element) {
$element = str_replace($group . '_', '', $element); $element = str_replace($group . '_', '', $element);
$element = str_replace('_', '.', $element); $element = str_replace('_', '.', $element);
$value = $this->view->config->getParam($group . '.' . $element); $value = $this->_config->getParam($group . '.' . $element);
if (is_array($value)) { if (is_array($value)) {
list (, $key) = explode('.', $element); list (, $key) = explode('.', $element);
$subForm->setDefault($element, $value[$key]); $subForm->setDefault($element, $value[$key]);
@ -463,7 +461,7 @@ class ConfigController extends Msd_Controller_Action
*/ */
private function _addNonConfigurableConfigParams($configData) private function _addNonConfigurableConfigParams($configData)
{ {
$configData['systemDatabases'] = $this->view->config->getParam('systemDatabases'); $configData['systemDatabases'] = $this->_config->getParam('systemDatabases');
return $configData; return $configData;
} }
@ -486,7 +484,7 @@ class ConfigController extends Msd_Controller_Action
$smtpConfig = $emailForm->getDisplayGroup('smtpConfig'); $smtpConfig = $emailForm->getDisplayGroup('smtpConfig');
$sendmailVisibility = false; $sendmailVisibility = false;
$smtpVisibility = false; $smtpVisibility = false;
switch ($this->view->config->getParam('email.Program')) { switch ($this->_config->getParam('email.Program')) {
case 'sendmail': case 'sendmail':
$sendmailVisibility = true; $sendmailVisibility = true;
break; break;

Datei anzeigen

@ -19,6 +19,13 @@
class Application_Model_Config_FormValidator class Application_Model_Config_FormValidator
{ {
/**
* Current configuration.
*
* @var Msd_Config|null
*/
protected $_config;
/** /**
* Config data to validate * Config data to validate
* @var array * @var array
@ -32,6 +39,7 @@ class Application_Model_Config_FormValidator
*/ */
public function __construct($configData) public function __construct($configData)
{ {
$this->_config = Msd_Registry::getConfig();
// unset values we only used for form handling // unset values we only used for form handling
unset( unset(
$configData['general']['selectedTab'], $configData['general']['selectedTab'],
@ -51,7 +59,6 @@ class Application_Model_Config_FormValidator
public function validateAndSaveConfig(Zend_View $view) public function validateAndSaveConfig(Zend_View $view)
{ {
$saveConfig = false; $saveConfig = false;
$config = Msd_Registry::getConfig();
$translator = Msd_Language::getInstance()->getTranslator(); $translator = Msd_Language::getInstance()->getTranslator();
$db = Msd_Db::getAdapter($this->_configData['dbuser']); $db = Msd_Db::getAdapter($this->_configData['dbuser']);
try { try {
@ -72,13 +79,14 @@ class Application_Model_Config_FormValidator
} }
if ($saveConfig) { if ($saveConfig) {
$config->setConfig($this->_configData); $this->_config->setConfig($this->_configData);
$saved = $config->save(); $saved = $this->_config->save();
$this->_config->load(Msd_Registry::getConfigFilename());
if ($saved === true) { if ($saved === true) {
$view->popUpMessage()->addMessage( $view->popUpMessage()->addMessage(
'save-config', 'save-config',
'L_NOTICE', 'L_NOTICE',
array('L_SAVE_SUCCESS', $view->config->getParam('general.title')), array('L_SAVE_SUCCESS', $this->_config->getParam('general.title')),
array( array(
'modal' => true, 'modal' => true,
'dialogClass' => 'notice' 'dialogClass' => 'notice'

Datei anzeigen

@ -26,7 +26,7 @@ class Msd_View_Helper_GetIcon extends Zend_View_Helper_Abstract
* *
* @return string * @return string
*/ */
public function getIcon($name, $title='', $size='') public function getIcon($name, $title = '', $size = null)
{ {
static $baseUrl = false; static $baseUrl = false;
if (!$baseUrl) { if (!$baseUrl) {
@ -35,13 +35,13 @@ class Msd_View_Helper_GetIcon extends Zend_View_Helper_Abstract
$icons = self::_getIconFilenames(); $icons = self::_getIconFilenames();
if (!isset($icons[$name])) { if (!isset($icons[$name])) {
throw new Msd_Exception( throw new Msd_Exception(
'GetIcon: unknown icon \''.$name .'\' requested' 'GetIcon: unknown icon \'' . $name . '\' requested'
); );
} }
$img = '<img src="'.$baseUrl.'/%s/%s" alt="%s" title="%s" />'; $img = '<img src="' . $baseUrl . '/%s/%s" alt="%s" title="%s" />';
$config = Msd_Registry::getConfig(); $config = Msd_Registry::getConfig();
if ($size>'') { if ($size !== null) {
$img = '<img src="'.$baseUrl.'/%s/%sx%s/%s" alt="%s" title="%s" />'; $img = '<img src="' . $baseUrl . '/%s/%sx%s/%s" alt="%s" title="%s" />';
$ret = sprintf( $ret = sprintf(
$img, $img,
$config->getParam('paths.iconPath'), $config->getParam('paths.iconPath'),
@ -67,7 +67,7 @@ class Msd_View_Helper_GetIcon extends Zend_View_Helper_Abstract
* *
* @return object * @return object
*/ */
private function _getIconFilenames () private function _getIconFilenames()
{ {
static $icons = false; static $icons = false;
if (!$icons) { if (!$icons) {
@ -82,5 +82,4 @@ class Msd_View_Helper_GetIcon extends Zend_View_Helper_Abstract
} }
return $icons; return $icons;
} }
} }

Datei anzeigen

@ -9,9 +9,8 @@
* @author $Author$ * @author $Author$
*/ */
/** /**
* Class to handle the configuration * Class to handle the configuration.
* *
* @throws Msd_Config_Exception
* @package MySQLDumper * @package MySQLDumper
* @subpackage Config * @subpackage Config
*/ */
@ -46,6 +45,8 @@ class Msd_Config
* @param array $handlerOptions Options for the IO-Handler. * @param array $handlerOptions Options for the IO-Handler.
* *
* @throws Msd_Config_Exception * @throws Msd_Config_Exception
*
* @return Msd_Config
*/ */
public function __construct($ioHandler, $handlerOptions = array()) public function __construct($ioHandler, $handlerOptions = array())
{ {
@ -152,7 +153,6 @@ class Msd_Config
if (strpos('paramName', '.') !== false) { if (strpos('paramName', '.') !== false) {
list($section, $paramName) = explode('.', $paramName); list($section, $paramName) = explode('.', $paramName);
$this->_config[$section][$paramName] = $paramValue; $this->_config[$section][$paramName] = $paramValue;
} else { } else {
$this->_config[$paramName] = $paramValue; $this->_config[$paramName] = $paramValue;
} }
@ -165,6 +165,8 @@ class Msd_Config
/** /**
* Class destructor. * Class destructor.
* If auto-save is enabled the configuration will be saved. * If auto-save is enabled the configuration will be saved.
*
* @return void
*/ */
public function __destruct() public function __destruct()
{ {
@ -178,13 +180,16 @@ class Msd_Config
* If auto-save is enabled the configuration is also saved. * If auto-save is enabled the configuration is also saved.
* *
* @param array $config New configuration. * @param array $config New configuration.
*
* @return void
*/ */
public function setConfig($config) public function setConfig($config)
{ {
$this->_config = (array)$config; $this->_config = (array) $config;
if ($this->_autosave) { if ($this->_autosave) {
$this->save(); $this->save();
} }
$this->_setPaths();
} }
/** /**
@ -239,5 +244,4 @@ class Msd_Config
$configData = parse_ini_file($this->getParam('paths.config') . '/' . $fileName . '.ini', true); $configData = parse_ini_file($this->getParam('paths.config') . '/' . $fileName . '.ini', true);
return $configData['general']['title']; return $configData['general']['title'];
} }
} }

Datei anzeigen

@ -18,10 +18,34 @@
abstract class Msd_Db abstract class Msd_Db
{ {
// define result set types // define result set types
const ARRAY_NUMERIC = 0; // return resultset as numeric array /**
const ARRAY_ASSOC = 1; // return resultset as associative array * Return result-set as an numeric array.
const ARRAY_OBJECT = 2; // return resultset as array of object *
const SIMPLE = 3; // return result as boolean * @const int
*/
const ARRAY_NUMERIC = 0;
/**
* Return result-set as an associative array.
*
* @const int
*/
const ARRAY_ASSOC = 1;
/**
* return result-set as an array of objects
*
* @const int
*/
const ARRAY_OBJECT = 2;
/**
* Return the return value of the query function/method.
*
* @const int
*/
const SIMPLE = 3;
/** /**
* SQL-Server * SQL-Server
* *
@ -59,6 +83,7 @@ abstract class Msd_Db
/** /**
* List of databases adn default settings * List of databases adn default settings
*
* @var array * @var array
*/ */
protected $_databases = null; protected $_databases = null;
@ -103,9 +128,9 @@ abstract class Msd_Db
* *
* @param array $options Array containing connection options * @param array $options Array containing connection options
* *
* @return void * @return Msd_Db
*/ */
protected function __construct ($options) protected function __construct($options)
{ {
$this->_server = $options['host']; $this->_server = $options['host'];
$this->_user = $options['user']; $this->_user = $options['user'];
@ -113,13 +138,14 @@ abstract class Msd_Db
$this->_port = (int) $options['port']; $this->_port = (int) $options['port'];
$this->_socket = $options['socket']; $this->_socket = $options['socket'];
} }
/** /**
* Create database adapter * Create database adapter
* *
* @param array $options Connection options * @param array $options Connection options
* @param boolean $forceMysql Whether to force the use of MySQL * @param boolean $forceMysql Whether to force the use of MySQL
* *
* @return MsdDbFactory * @return Msd_Db_MysqlCommon
*/ */
public static function getAdapter($options = null, $forceMysql = false) public static function getAdapter($options = null, $forceMysql = false)
{ {
@ -147,31 +173,36 @@ abstract class Msd_Db
* *
* @return bool if connection is successfull * @return bool if connection is successfull
* */ * */
abstract protected function _dbConnect (); abstract protected function _dbConnect();
/** /**
* Get selected database * Get selected database
* *
* @return string * @return string
*/ */
abstract public function getSelectedDb (); abstract public function getSelectedDb();
/** /**
* Get version nr of sql server * Get version nr of sql server
* *
* @return string * @return string
*/ */
abstract public function getServerInfo (); abstract public function getServerInfo();
/** /**
* Get version nr of sql client * Get version nr of sql client
* *
* @return string * @return string
*/ */
abstract public function getClientInfo (); abstract public function getClientInfo();
/** /**
* Get all known character sets of this SQL-Server. * Get all known character sets of this SQL-Server.
* *
* @return array * @return array
*/ */
abstract public function getCharsets (); abstract public function getCharsets();
/** /**
* Set character set of the MySQL-connection. * Set character set of the MySQL-connection.
* *
@ -179,12 +210,14 @@ abstract class Msd_Db
* Throw Exception on failure. * Throw Exception on failure.
* *
* @param string $charset * @param string $charset
*
* @throws Exception * @throws Exception
* *
* @return string * @return string
*/ */
abstract public function setConnectionCharset ( abstract public function setConnectionCharset(
$charset = 'utf8'); $charset = 'utf8');
/** /**
* Get list of databases * Get list of databases
* *
@ -194,36 +227,39 @@ abstract class Msd_Db
* *
* @return array * @return array
*/ */
abstract public function getDatabases (); abstract public function getDatabases();
/** /**
* Select the given database to use it as the target for following queries. * Select the given database to use it as the target for following queries.
* *
* Returns true if selection was succesfull otherwise false. * Returns true if selection was succesfull otherwise false.
* *
* @throws Exception * @throws Exception
*
* @param string $database * @param string $database
* *
* @return bool * @return bool
*/ */
abstract public function selectDb ($database); abstract public function selectDb($database);
/** /**
* Execute a query and set _resultHandle * Execute a query and set _resultHandle
* *
* If $getRows is true alls rows are fetched and returned * If $getRows is true alls rows are fetched and returned
* *
* @param string $query The query to execute * @param string $query The query to execute
* @param const $kind Type of result set * @param int $kind Type of result set
* @param boolean $getRows Whether to fetch all rows and return them * @param boolean $getRows Whether to fetch all rows and return them
* *
* @return boolean|array * @return boolean|array
*/ */
abstract public function query ($query, abstract public function query($query,
$kind = self::ARRAY_OBJECT, $getRows = true); $kind = self::ARRAY_OBJECT, $getRows = true);
/** /**
* Get next row from result set * Get next row from result set
* *
* @param const $kind * @param int $kind
* *
* @return array|object * @return array|object
*/ */
@ -236,7 +272,8 @@ abstract class Msd_Db
* *
* @return array * @return array
*/ */
abstract public function getTables ($dbName); abstract public function getTables($dbName);
/** /**
* Gets extended table information for one or all tables * Gets extended table information for one or all tables
* *
@ -244,16 +281,19 @@ abstract class Msd_Db
* *
* @return array * @return array
*/ */
abstract public function getTableStatus ($table = false); abstract public function getTableStatus($table = false);
/** /**
* Returns the CREATE Statement of a table. * Returns the CREATE Statement of a table.
* *
* @throws Exception * @throws Exception
*
* @param string $table Get CREATE-Statement for this table * @param string $table Get CREATE-Statement for this table
* *
* @return string Create statement * @return string Create statement
*/ */
abstract public function getTableCreate ($table); abstract public function getTableCreate($table);
/** /**
* Gets the full description of all columns of a table * Gets the full description of all columns of a table
* *
@ -263,19 +303,23 @@ abstract class Msd_Db
* *
* @return array * @return array
*/ */
abstract public function getTableColumns ($table); abstract public function getTableColumns($table);
/** /**
* Gets the number of affected rows of the last query * Gets the number of affected rows of the last query
* *
* @return int * @return int
*/ */
abstract public function getAffectedRows (); abstract public function getAffectedRows();
/** /**
* Gets the servers variables * Gets the servers variables
* *
* @return array * @return array
*/ */
abstract public function getVariables ();
abstract public function getVariables();
/** /**
* Escape a value for inserting it in query * Escape a value for inserting it in query
* *
@ -283,7 +327,8 @@ abstract class Msd_Db
* *
* @return string * @return string
*/ */
abstract public function escape ($val); abstract public function escape($val);
/** /**
* Optimize a table. Returns true on success or MySQL-Error. * Optimize a table. Returns true on success or MySQL-Error.
* *
@ -291,7 +336,9 @@ abstract class Msd_Db
* *
* @return string|bool Returned optimize message or false on error * @return string|bool Returned optimize message or false on error
*/ */
abstract public function optimizeTable ($table);
abstract public function optimizeTable($table);
/** /**
* Creates a new database with the given name, charackter set and collation. * Creates a new database with the given name, charackter set and collation.
* *
@ -308,6 +355,7 @@ abstract class Msd_Db
$databaseCharset = '', $databaseCharset = '',
$databaseCollation = '' $databaseCollation = ''
); );
/** /**
* Retrieves the collations from information schema. * Retrieves the collations from information schema.
* *
@ -316,6 +364,7 @@ abstract class Msd_Db
* @return array * @return array
*/ */
abstract public function getCollations($charsetName = null); abstract public function getCollations($charsetName = null);
/** /**
* Retrieves the default collation for the charset or the given charset. * Retrieves the default collation for the charset or the given charset.
* *
@ -324,22 +373,25 @@ abstract class Msd_Db
* @return array|string * @return array|string
*/ */
abstract public function getDefaultCollations($charsetName = null); abstract public function getDefaultCollations($charsetName = null);
/** /**
* Retrieves the last MySQL error. * Retrieves the last MySQL error.
* *
* @return array * @return array
*/ */
abstract public function getLastError(); abstract public function getLastError();
/** /**
* Handles a SQL-Error * Handles a SQL-Error
* *
* @param string $errmsg * @param string $errmsg
* @param int $errno * @param int $errno
* @throws MsdEception *
* @throws Msd_Exception
* *
* @return void * @return void
*/ */
public function sqlError ($errmsg, $errno) public function sqlError($errmsg, $errno)
{ {
throw new Msd_Exception($errmsg, $errno); throw new Msd_Exception($errmsg, $errno);
} }

Datei anzeigen

@ -148,7 +148,7 @@ class Msd_Db_Mysql extends Msd_Db_MysqlCommon
* is returned. * is returned.
* *
* @param string $query The query to execute * @param string $query The query to execute
* @param const $kind Type of result set * @param int $kind Type of result set
* @param boolean $getRows Wether to fetch all rows and return them * @param boolean $getRows Wether to fetch all rows and return them
* *
* @return boolean|array * @return boolean|array
@ -175,6 +175,8 @@ class Msd_Db_Mysql extends Msd_Db_MysqlCommon
$this->_resultHandle = null; $this->_resultHandle = null;
return $ret; return $ret;
} }
return true;
} }
/** /**
@ -182,7 +184,7 @@ class Msd_Db_Mysql extends Msd_Db_MysqlCommon
* *
* Can be used to walk through result sets. * Can be used to walk through result sets.
* *
* @param const $kind * @param int $kind
* *
* @return array|object * @return array|object
*/ */
@ -199,6 +201,8 @@ class Msd_Db_Mysql extends Msd_Db_MysqlCommon
case self::ARRAY_ASSOC: case self::ARRAY_ASSOC:
return mysql_fetch_array($this->_resultHandle, MYSQL_ASSOC); return mysql_fetch_array($this->_resultHandle, MYSQL_ASSOC);
} }
return false;
} }
/** /**
@ -228,7 +232,7 @@ class Msd_Db_Mysql extends Msd_Db_MysqlCommon
/** /**
* Retrieves the last MySQL error. * Retrieves the last MySQL error.
* *
* @return void * @return array
*/ */
public function getLastError() public function getLastError()
{ {

Datei anzeigen

@ -161,8 +161,7 @@ class Msd_Db_Mysqli extends Msd_Db_MysqlCommon
$this->_getHandle()->errno $this->_getHandle()->errno
); );
} }
if (!$this->_resultHandle instanceof mysqli_result if (!$this->_resultHandle instanceof mysqli_result || $kind === self::SIMPLE) {
|| $kind === self::SIMPLE) {
return $this->_resultHandle; return $this->_resultHandle;
} }
// return result set? // return result set?

Datei anzeigen

@ -16,6 +16,27 @@
*/ */
class Msd_Registry extends Zend_Registry class Msd_Registry extends Zend_Registry
{ {
/**
* Key for the configuration filename. This is used inside the registry.
*
* @const string
*/
const CONFIG_FILENAME_KEY = '_configFilename';
/**
* Key for the dynamic configuration. This is used inside the registry.
*
* @const string
*/
const DYNAMIC_CONFIG_KEY = '_dynamic';
/**
* Key for the configuration. This is used inside the registry.
*
* @const string
*/
const CONFIG_KEY = '_config';
/** /**
* Returns the config instance if it has been registered, returns null otherwise. * Returns the config instance if it has been registered, returns null otherwise.
* *
@ -23,8 +44,8 @@ class Msd_Registry extends Zend_Registry
*/ */
public static function getConfig() public static function getConfig()
{ {
if (self::isRegistered('_config')) { if (self::isRegistered(self::CONFIG_KEY)) {
return self::get('_config'); return self::get(self::CONFIG_KEY);
} }
return null; return null;
@ -41,7 +62,7 @@ class Msd_Registry extends Zend_Registry
*/ */
public static function setConfig(Msd_Config $config) public static function setConfig(Msd_Config $config)
{ {
self::set('_config', $config); self::set(self::CONFIG_KEY . '', $config);
} }
/** /**
@ -53,8 +74,8 @@ class Msd_Registry extends Zend_Registry
*/ */
public static function getDynamicConfig() public static function getDynamicConfig()
{ {
if (self::isRegistered('_dynamic')) { if (self::isRegistered(self::DYNAMIC_CONFIG_KEY)) {
return self::get('_dynamic'); return self::get(self::DYNAMIC_CONFIG_KEY);
} }
return null; return null;
@ -71,6 +92,31 @@ class Msd_Registry extends Zend_Registry
*/ */
public static function setDynamicConfig(Msd_Config_Dynamic $config) public static function setDynamicConfig(Msd_Config_Dynamic $config)
{ {
self::set('_dynamic', $config); self::set(self::DYNAMIC_CONFIG_KEY, $config);
}
/**
* Returns the name of the current configuration file.
*
* @return string
*/
public static function getConfigFilename()
{
if (self::isRegistered(self::CONFIG_FILENAME_KEY)) {
return self::get(self::CONFIG_FILENAME_KEY);
}
return null;
}
/**
* Sets the name of the current configuration file.
*
* @param string $configFilename Name of configuration file.
*
* @return void
*/
public static function setConfigFilename($configFilename)
{
self::set(self::CONFIG_FILENAME_KEY, $configFilename);
} }
} }