From ae87af916f30fb06e40719b25da1676b2b7c1dd5 Mon Sep 17 00:00:00 2001 From: DSB Date: Sat, 4 Aug 2012 17:09:48 +0000 Subject: [PATCH] Continued to switch the old configuration handling to the new one. --- application/Bootstrap.php | 24 ++-- application/controllers/ConfigController.php | 36 +++--- application/controllers/DumpController.php | 5 +- application/controllers/FilesController.php | 2 +- application/controllers/IndexController.php | 93 +++++++------- application/controllers/InstallController.php | 2 +- application/controllers/LogController.php | 4 +- application/controllers/RestoreController.php | 2 +- application/controllers/SqlController.php | 48 ++++---- .../controllers/SqlServerController.php | 2 +- application/forms/Config/Email.php | 4 +- application/forms/Config/Ftp.php | 4 +- application/models/Config/FormValidator.php | 6 +- application/models/Sqlbox.php | 4 +- application/views/helpers/GetConfigTitle.php | 4 +- application/views/helpers/GetIcon.php | 10 +- application/views/helpers/GetIconSrc.php | 10 +- application/views/helpers/Menu.php | 10 +- application/views/helpers/PopUpMessage.php | 3 +- application/views/layouts/layout.phtml | 6 +- application/views/layouts/mobile.phtml | 9 +- .../views/mobile/scripts/index/index.phtml | 4 +- .../views/scripts/config/databases.phtml | 4 +- application/views/scripts/config/index.phtml | 6 +- application/views/scripts/dump/email.phtml | 2 +- application/views/scripts/dump/ftp.phtml | 5 +- application/views/scripts/dump/index.phtml | 10 +- .../views/scripts/dump/multipart.phtml | 4 +- application/views/scripts/dump/settings.phtml | 6 +- .../views/scripts/dump/start-dump.phtml | 4 +- application/views/scripts/error/error.phtml | 6 +- application/views/scripts/index/index.phtml | 16 +-- application/views/scripts/index/menu.phtml | 18 +-- .../sql/databases/show-databases.phtml | 6 +- .../views/scripts/sql/sql-head-navi.phtml | 10 +- .../views/scripts/sql/sqlbox/sqlbox.phtml | 4 +- .../scripts/sql/tables/show-tables.phtml | 2 +- .../Action/Helper/AssignConfigAndLanguage.php | 12 +- library/Msd/Config.php | 58 ++++++++- library/Msd/Config/Dynamic.php | 115 ++++++++++++++++++ library/Msd/ConfigurationPhpValues.php | 4 +- library/Msd/Controller/Action.php | 66 ++++++++++ library/Msd/Db.php | 12 +- library/Msd/Dump.php | 8 +- library/Msd/File.php | 9 +- library/Msd/File/Dump.php | 4 +- library/Msd/Language.php | 34 +++--- library/Msd/Log.php | 6 +- library/Msd/TaskManager.php | 21 ++-- library/Msd/User.php | 3 +- library/Zend/Config/Ini.php | 1 + tests/fixtures/sessions/sessionTester.txt | Bin 6418 -> 6420 bytes .../application/models/SqlboxTest.php | 4 +- .../application/views/helpers/MenuTest.php | 18 +-- 54 files changed, 501 insertions(+), 269 deletions(-) create mode 100644 library/Msd/Controller/Action.php diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 4a0fc85..3819ff1 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -41,16 +41,22 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap */ public function _initConfiguration() { - $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); + $dynamicConfig = Msd_Registry::getDynamicConfig(); + if ($dynamicConfig === null) { + $dynamicConfig = new Msd_Config_Dynamic(); + Msd_Registry::setDynamicConfig($dynamicConfig); + } - Msd_Registry::setDynamicConfig($dynamicConfig); + $config = Msd_Registry::getConfig(); + if ($config === null) { + $configFile = $dynamicConfig->getParam('configFile', 'defaultConfig.ini'); + $config = new Msd_Config( + 'Default', + array('directories' => APPLICATION_PATH . '/configs') + ); + $config->load($configFile); + } + Msd_Registry::setConfig($config); } /** diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index f68a3d9..822d1b2 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -16,7 +16,7 @@ * @package MySQLDumper * @subpackage Controllers */ -class ConfigController extends Zend_Controller_Action +class ConfigController extends Msd_Controller_Action { /** * Active jQuery tab Id @@ -61,7 +61,7 @@ class ConfigController extends Zend_Controller_Action $formGeneral = $this->_getSubformIni('general'); $elementTitle = $formGeneral->getElement('title'); $elementTitle->setValue( - $this->view->config->get('config.general.title') + $this->view->config->getParam('general.title') ); $form->addSubForm($formGeneral, 'general'); @@ -184,9 +184,9 @@ class ConfigController extends Zend_Controller_Action // set dynamic actual database if it's changed in the panel if ($this->_request->isPost()) { - $actualDb = $this->view->config->get('dynamic.dbActual'); + $actualDb = $this->view->dynamicConfig->getParam('dbActual'); if (isset($_POST['defaultDb']) && ($_POST['defaultDb'] != $actualDb)) { - $this->view->config->set('dynamic.dbActual', $_POST['defaultDb']); + $this->view->dynamicConfig->setParam('dbActual', $_POST['defaultDb']); } } @@ -214,7 +214,7 @@ class ConfigController extends Zend_Controller_Action */ public function addRecipientCcAction() { - $recipientsCc = $this->view->config->get('config.email.RecipientCc'); + $recipientsCc = $this->view->config->Param('email.RecipientCc'); if ($recipientsCc === null) { $recipientsCc = array(); } @@ -222,7 +222,7 @@ class ConfigController extends Zend_Controller_Action $recipientsCc[$index]['Name'] = ''; $recipientsCc[$index]['Address'] = ''; $recipientsCc = array_values($recipientsCc); - $this->view->config->set('config.email.RecipientCc', $recipientsCc); + $this->view->config->setParam('email.RecipientCc', $recipientsCc); $this->_forward('index'); } @@ -234,11 +234,11 @@ class ConfigController extends Zend_Controller_Action public function deleteRecipientCcAction() { $recipientToDelete = (int)$this->_request->getPost('param'); - $recipientsCc = $this->view->config->get('config.email.RecipientCc'); + $recipientsCc = $this->view->config->getParam('email.RecipientCc'); if (isset($recipientsCc[$recipientToDelete])) { unset($recipientsCc[$recipientToDelete]); } - $this->view->config->set('config.email.RecipientCc', $recipientsCc); + $this->view->config->setParam('email.RecipientCc', $recipientsCc); $this->_forward('index'); } @@ -249,18 +249,15 @@ class ConfigController extends Zend_Controller_Action */ public function addFtpConnectionAction() { - $ftpConfig = $this->view->config->get('config.ftp'); + $ftpConfig = $this->view->config->getParam('ftp'); $index = 0; if (!empty($ftpConfig)) { $index = max(array_keys($ftpConfig)) + 1; } - $default = $this->view->config->loadConfiguration( - 'defaultConfig', - false - ); + $default = $this->view->config->load('defaultConfig'); $default = $default->toArray(); $ftpConfig[$index] = $default['ftp'][0]; - $this->view->config->set('config.ftp', $ftpConfig); + $this->view->config->Param('ftp', $ftpConfig); $this->_forward('index'); } @@ -272,13 +269,13 @@ class ConfigController extends Zend_Controller_Action public function deleteFtpConnectionAction() { $index = (int)$this->_request->getPost('param'); - $ftpConfig = $this->view->config->get('config.ftp'); + $ftpConfig = $this->view->config->getParam('ftp'); if (count($ftpConfig) > 1) { if (isset($ftpConfig[$index])) { unset($ftpConfig[$index]); sort($ftpConfig); } - $this->view->config->set('config.ftp', $ftpConfig); + $this->view->config->setParam('ftp', $ftpConfig); } $this->_forward('index'); } @@ -403,7 +400,7 @@ class ConfigController extends Zend_Controller_Action foreach ($elements as $element) { $element = str_replace($group . '_', '', $element); $element = str_replace('_', '.', $element); - $value = $this->view->config->get('config.' . $group . '.' . $element); + $value = $this->view->config->getParam($group . '.' . $element); if ($value !== null) { $subForm->setDefault($element, $value); } @@ -455,8 +452,7 @@ class ConfigController extends Zend_Controller_Action */ private function _addNonConfigurableConfigParams($configData) { - $config = Msd_Configuration::getInstance(); - $configData['systemDatabases'] = $config->get('config.systemDatabases'); + $configData['systemDatabases'] = $this->view->config->getParam('systemDatabases'); return $configData; } @@ -479,7 +475,7 @@ class ConfigController extends Zend_Controller_Action $smtpConfig = $emailForm->getDisplayGroup('smtpConfig'); $sendmailVisibility = false; $smtpVisibility = false; - switch ($this->view->config->get('config.email.Program')) { + switch ($this->view->config->getParam('email.Program')) { case 'sendmail': $sendmailVisibility = true; break; diff --git a/application/controllers/DumpController.php b/application/controllers/DumpController.php index 8c73a18..96d620f 100644 --- a/application/controllers/DumpController.php +++ b/application/controllers/DumpController.php @@ -16,7 +16,7 @@ * @package MySQLDumper * @subpackage Controllers */ -class DumpController extends Zend_Controller_Action +class DumpController extends Msd_Controller_Action { /** * Show dump page @@ -46,7 +46,6 @@ class DumpController extends Zend_Controller_Action { $taskList = Msd_TaskManager::getInstance('backupTasks'); $tasks = $taskList->getTasks(); - $this->view->config = Msd_Configuration::getInstance(); $this->view->sessionId = Zend_Session::getId(); } @@ -63,7 +62,7 @@ class DumpController extends Zend_Controller_Action $tasks = $taskList->getTasks(); $ret = array( 'backup_in_progress' => false, - 'config_file' => $this->view->config->get('dynamic.configFile') + 'config_file' => $this->view->dynamicConfig->getParam('configFile') ); echo json_encode($ret); diff --git a/application/controllers/FilesController.php b/application/controllers/FilesController.php index e1027c5..fbdb1b3 100644 --- a/application/controllers/FilesController.php +++ b/application/controllers/FilesController.php @@ -16,7 +16,7 @@ * @package MySQLDumper * @subpackage Controllers */ -class FilesController extends Zend_Controller_Action +class FilesController extends Msd_Controller_Action { public function indexAction() diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index b88b240..5f3fcfd 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -16,7 +16,7 @@ * @package MySQLDumper * @subpackage Controllers */ -class IndexController extends Zend_Controller_Action +class IndexController extends Msd_Controller_Action { /** * Remember last controler @@ -37,9 +37,9 @@ class IndexController extends Zend_Controller_Action */ public function init() { - $request = $this->getRequest(); + $request = $this->getRequest(); $this->_lastController = $request->getParam('lastController', 'index'); - $this->_lastAction = $request->getParam('lastAction', 'index'); + $this->_lastAction = $request->getParam('lastAction', 'index'); } /** @@ -60,22 +60,21 @@ class IndexController extends Zend_Controller_Action } try { - $dbo = Msd_Db::getAdapter(); + $dbo = Msd_Db::getAdapter(); $data = Msd_File::getLatestBackupInfo(); if (!empty($data)) { - $statusline = Msd_File_Dump::getStatusline($data['filename']); + $statusline = Msd_File_Dump::getStatusline($data['filename']); $data['filename'] = $statusline['dbname']; } else { $data['filename'] = ''; } - $data['mysqlServerVersion'] = $dbo->getServerInfo(); - $data['mysqlClientVersion'] = $dbo->getClientInfo(); - $data['serverMaxExecutionTime'] = - (int)@get_cfg_var('max_execution_time'); + $data['mysqlServerVersion'] = $dbo->getServerInfo(); + $data['mysqlClientVersion'] = $dbo->getClientInfo(); + $data['serverMaxExecutionTime'] = (int)@get_cfg_var('max_execution_time'); $this->view->assign($data); - if ($this->view->config->get('dynamic.dbActual') == '') { + if ($this->view->dynamicConfig->getParam('dbActual', '') == '') { $dbNames = $dbo->getDatabaseNames(); - $this->view->config->set('dynamic.dbActual', $dbNames[0]); + $this->view->dynamicConfig->setParam('dbActual', $dbNames[0]); } } catch (Exception $e) { $configNames = Msd_File::getConfigNames(); @@ -97,7 +96,7 @@ class IndexController extends Zend_Controller_Action array('message' => 'L_MYSQL_VERSION_TOO_OLD') ); } - $this->view->version = $version; + $this->view->version = $version; $this->view->dbAdapter = get_class($dbo); } @@ -112,9 +111,9 @@ class IndexController extends Zend_Controller_Action { $this->_helper->viewRenderer->setNoRender(true); $request = $this->getRequest(); - $file = base64_decode($request->getParam('selectedConfig')); - $this->view->config = Msd_Configuration::getInstance(); - $this->view->config->loadConfiguration($file); + $file = base64_decode($request->getParam('selectedConfig')); + $this->_config->load($file); + $this->view->config->load($file); if ($this->_lastAction != 'switchconfig') { //prevent endless loop $this->_forward($this->_lastAction, $this->_lastController); } @@ -128,14 +127,14 @@ class IndexController extends Zend_Controller_Action public function selectdbAction() { $this->_helper->viewRenderer->setNoRender(true); - $request = $this->getRequest(); + $request = $this->getRequest(); $selectedDb = base64_decode($request->getParam('selectedDb')); - $this->view->config->set('dynamic.dbActual', $selectedDb); + $this->view->dynamicConfig->setParam('dbActual', $selectedDb); if ($this->_lastAction != 'selectdb') { //prevent endless loop $redirectUrl = $this->view->url( array( - 'controller' => $this->_lastController, - 'action' => $this->_lastAction, + 'controller' => $this->_lastController, + 'action' => $this->_lastAction, ), null, true @@ -152,19 +151,19 @@ class IndexController extends Zend_Controller_Action public function dbrefreshAction() { $this->_helper->viewRenderer->setNoRender(true); - $dbo = Msd_Db::getAdapter(); + $dbo = Msd_Db::getAdapter(); $databases = $dbo->getDatabaseNames(); - $this->view->config->set('dynamic.databases', $databases); - $actualDb = $this->view->config->get('dynamic.dbActual'); + $this->view->dynamicConfig->setParam('databases', $databases); + $actualDb = $this->view->dynamicConfig->getParam('dbActual'); if ($dbo->selectDb($actualDb) !== true) { //actual db is no longer available -> switch to first one - $this->view->config->set('dynamic.dbActual', $databases[0]); + $this->view->dynamicConfig->setParam('dbActual', $databases[0]); } if ($this->_lastAction != 'refreshdb') { //prevent endless loop $redirectUrl = $this->view->url( array( - 'controller' => $this->_lastController, - 'action' => $this->_lastAction, + 'controller' => $this->_lastController, + 'action' => $this->_lastAction, ), null, true @@ -208,8 +207,8 @@ class IndexController extends Zend_Controller_Action } $this->_doRedirect( array( - 'controller' => 'index', - 'action' => 'login' + 'controller' => 'index', + 'action' => 'login' ) ); } @@ -223,11 +222,11 @@ class IndexController extends Zend_Controller_Action { $form = new Application_Form_Login(); if ($this->_request->isPost()) { - $user = new Msd_User(); + $user = new Msd_User(); $postData = $this->_request->getParams(); if ($form->isValid($postData)) { - $autoLogin = ($postData['autologin'] == 1) ? true : false; - $loginResult = $user->login( + $autoLogin = ($postData['autologin'] == 1) ? true : false; + $loginResult = $user->login( $postData['user'], $postData['pass'], $autoLogin @@ -239,8 +238,8 @@ class IndexController extends Zend_Controller_Action // users.ini doesn't exist or doesn't have entries $this->_doRedirect( array( - 'controller' => 'install', - 'action' => 'index' + 'controller' => 'install', + 'action' => 'index' ) ); break; @@ -248,21 +247,17 @@ class IndexController extends Zend_Controller_Action // user is not listed in users.ini break; case Msd_User::SUCCESS: - $defaultDb = $this->view->config->get( - 'config.dbuser.defaultDb' + $defaultDb = $this->view->config->getParam('dbuser.defaultDb' ); // set actualDb to defaultDb if ($defaultDb != '') { - $this->view->config->set( - 'dynamic.dbActual', - $defaultDb - ); + $this->view->dynamicConfig->setParam('dbActual', $defaultDb); } $this->_doRedirect( array( - 'controller' => 'index', - 'action' => 'index' + 'controller' => 'index', + 'action' => 'index' ) ); return; @@ -270,15 +265,15 @@ class IndexController extends Zend_Controller_Action } // if we get here wrong credentials are given $this->view->popUpMessage() - ->addMessage( - 'login-message', - 'L_LOGIN', - $user->getAuthMessages(), - array( - 'modal' => true, - 'dialogClass' => 'error' - ) - ); + ->addMessage( + 'login-message', + 'L_LOGIN', + $user->getAuthMessages(), + array( + 'modal' => true, + 'dialogClass' => 'error' + ) + ); } } $this->view->form = $form; diff --git a/application/controllers/InstallController.php b/application/controllers/InstallController.php index 5e572c0..0f0d10d 100644 --- a/application/controllers/InstallController.php +++ b/application/controllers/InstallController.php @@ -143,7 +143,7 @@ class InstallController extends Zend_Controller_Action 'config' => $config->get('paths.config'), 'log' => $config->get('paths.log'), 'backup' => $config->get('paths.backup'), - 'iconpath' => $config->get('paths.iconpath') + 'iconpath' => $config->get('paths.iconPath') ); foreach ($checkDirs as $checkDir) { diff --git a/application/controllers/LogController.php b/application/controllers/LogController.php index 615a1fd..b93ba9d 100644 --- a/application/controllers/LogController.php +++ b/application/controllers/LogController.php @@ -16,7 +16,7 @@ * @package MySQLDumper * @subpackage Controllers */ -class LogController extends Zend_Controller_Action +class LogController extends Msd_Controller_Action { /** * Delete a log file @@ -78,7 +78,7 @@ class LogController extends Zend_Controller_Action $reverse = $this->_getParam('reverse', 0); $page = $this->_getParam('offset', 1); $entriesPerPage = - $this->view->config->get('config.interface.recordsPerPage'); + $this->view->config->getParam('interface.recordsPerPage'); $this->_helper->layout()->disableLayout(); $logger = Msd_Log::getInstance(); $lines = $logger->read($logType, $reverse); diff --git a/application/controllers/RestoreController.php b/application/controllers/RestoreController.php index bbbf489..3eb47dd 100644 --- a/application/controllers/RestoreController.php +++ b/application/controllers/RestoreController.php @@ -16,7 +16,7 @@ * @package MySQLDumper * @subpackage Controllers */ -class RestoreController extends Zend_Controller_Action +class RestoreController extends Msd_Controller_Action { public function indexAction() { diff --git a/application/controllers/SqlController.php b/application/controllers/SqlController.php index 5436d17..9c4348b 100644 --- a/application/controllers/SqlController.php +++ b/application/controllers/SqlController.php @@ -16,7 +16,7 @@ * @package MySQLDumper * @subpackage Controllers */ -class SqlController extends Zend_Controller_Action +class SqlController extends Msd_Controller_Action { /** * Db-handle @@ -54,7 +54,7 @@ class SqlController extends Zend_Controller_Action $this->_helper->viewRenderer('databases/show-databases'); $databases = $this->_db->getDatabases(true); $dbNames = $this->_db->getDatabaseNames(); - $dbActual = $this->view->config->get('dynamic.dbActual'); + $dbActual = $this->view->dynamicConfig->getParam('dbActual'); //Fallback to first found db if actual db doesn't exist if (!in_array($dbActual, $dbNames)) { $dbActual = $dbNames[0]; @@ -72,13 +72,11 @@ class SqlController extends Zend_Controller_Action { $this->_helper->viewRenderer('tables/show-tables'); $pageNum = $this->_getParam('offset', 1); - $itemCountPerPage = $this->view->config->get( - 'config.interface.recordsPerPage' - ); + $itemCountPerPage = $this->view->config->getParam('interface.recordsPerPage'); $dbActual = $this->_getParam( 'database', - $this->view->config->get('dynamic.dbActual') + $this->view->dynamicConfig->getParam('dbActual') ); if ($this->_getParam('dbName') !== null) { $dbActual = base64_decode($this->_getParam('dbName')); @@ -106,11 +104,11 @@ class SqlController extends Zend_Controller_Action public function showTableDataAction() { $this->_getDynamicParams(); - $dbName = $this->view->config->get('dynamic.dbActual'); + $dbName = $this->view->dynamicConfig->getParam('dbActual'); $offset = (int)$this->_getParam('offset', 0); - $limit = $this->view->config->get('config.interface.recordsPerPage'); + $limit = $this->view->config->getParam('interface.recordsPerPage'); $this->_db->selectDb($dbName); - $tableName = $this->view->config->get('dynamic.tableActual'); + $tableName = $this->view->dynamicConfig->getParam('tableActual'); try { $this->view->columns = $this->_db->getTableColumns($tableName); $tables = $this->_db->getTableStatus($tableName); @@ -127,7 +125,7 @@ class SqlController extends Zend_Controller_Action $tableName = ''; } } - $this->view->config->set('dynamic.tableActual', $tableName); + $this->view->dynamicConfig->setParam('tableActual', $tableName); if (!empty($tables)) { $query = sprintf( 'SELECT SQL_CALC_FOUND_ROWS * FROM `%s` LIMIT %s, %s', @@ -253,7 +251,7 @@ class SqlController extends Zend_Controller_Action $tables = $this->_request->getParam('tables', array()); $optimizeResults = array(); $this->view->action = $this->view->lang->L_OPTIMIZE; - $database = $this->view->config->get('dynamic.dbActual'); + $database = $this->view->dynamicConfig->getParam('dbActual'); $this->_db->selectDb($database); if ($this->_request->isPost() && !empty($tables)) { @@ -278,7 +276,7 @@ class SqlController extends Zend_Controller_Action $tables = $this->_request->getParam('tables', array()); $analyzeResults = array(); $this->view->action = $this->view->lang->L_ANALYZE; - $database = $this->view->config->get('dynamic.dbActual'); + $database = $this->view->dynamicConfig->getParam('dbActual'); $this->_db->selectDb($database); if ($this->_request->isPost() && !empty($tables)) { @@ -303,7 +301,7 @@ class SqlController extends Zend_Controller_Action $tables = $this->_request->getParam('tables', array()); $analyzeResults = array(); $this->view->action = $this->view->lang->L_ANALYZE; - $database = $this->view->config->get('dynamic.dbActual'); + $database = $this->view->dynamicConfig->getParam('dbActual'); $this->_db->selectDb($database); if ($this->_request->isPost() && !empty($tables)) { @@ -328,7 +326,7 @@ class SqlController extends Zend_Controller_Action $tables = $this->_request->getParam('tables', array()); $analyzeResults = array(); $this->view->action = $this->view->lang->L_ANALYZE; - $database = $this->view->config->get('dynamic.dbActual'); + $database = $this->view->dynamicConfig->getParam('dbActual'); $this->_db->selectDb($database); if ($this->_request->isPost() && !empty($tables)) { @@ -353,7 +351,7 @@ class SqlController extends Zend_Controller_Action $tables = $this->_request->getParam('tables', array()); $truncateResults = array(); $this->view->action = $this->view->lang->L_TRUNCATE; - $database = $this->view->config->get('dynamic.dbActual'); + $database = $this->view->dynamicConfig->getParam('dbActual'); $this->_db->selectDb($database); if ($this->_request->isPost() && !empty($tables)) { @@ -377,17 +375,17 @@ class SqlController extends Zend_Controller_Action $sqlboxModel = new Application_Model_Sqlbox(); $this->view->tableSelectBox = $sqlboxModel->getTableSelectBox(); $request = $this->getRequest(); - $config = $this->view->config; + $dynamicConfig = $this->view->dynamicConfig; $query = ''; - if ($lastQuery = $config->get('dynamic.sqlboxQuery')) { + if ($lastQuery = $dynamicConfig->getParam('sqlboxQuery')) { $query = $lastQuery; } if ($request->isPost()) { $query = $request->getParam('sqltextarea', ''); - $config->set('dynamic.sqlboxQuery', $query); + $dynamicConfig->setParam('sqlboxQuery', $query); $query = trim($query); if ($query > '') { - $this->_db->selectDb($config->get('dynamic.dbActual')); + $this->_db->selectDb($dynamicConfig->getParam('dbActual')); $sqlObject = new Msd_Sql_Object($query); $parser = new Msd_Sql_Parser($sqlObject, true); $parser->parse(); @@ -430,7 +428,7 @@ class SqlController extends Zend_Controller_Action private function _refreshDbList() { $databases = $this->_db->getDatabaseNames(); - $this->view->config->set('dynamic.databases', $databases); + $this->view->dynamicConfig->setParam('databases', $databases); } /** @@ -444,10 +442,10 @@ class SqlController extends Zend_Controller_Action private function _setDynamicParams($dbActual = false, $tableActual = '') { if ($dbActual === false) { - $dbActual = $this->view->config->get('dynamic.dbActual'); + $dbActual = $this->view->dynamicConfig->getParam('dbActual'); } - $this->view->config->set('dynamic.dbActual', $dbActual); - $this->view->config->set('dynamic.tableActual', $tableActual); + $this->view->dynamicConfig->setParam('dbActual', $dbActual); + $this->view->dynamicConfig->setParam('tableActual', $tableActual); } /** @@ -460,12 +458,12 @@ class SqlController extends Zend_Controller_Action $params = $this->_request->getParams(); if (isset($params['dbName'])) { $dbName = base64_decode($params['dbName']); - $this->view->config->set('dynamic.dbActual', $dbName); + $this->view->dynamicConfig->setParam('dbActual', $dbName); } if (isset($params['tableName'])) { $dbName = base64_decode($params['tableName']); - $this->view->config->set('dynamic.tableActual', $dbName); + $this->view->dynamicConfig->setParam('tableActual', $dbName); } } } diff --git a/application/controllers/SqlServerController.php b/application/controllers/SqlServerController.php index 3afb193..8963d30 100644 --- a/application/controllers/SqlServerController.php +++ b/application/controllers/SqlServerController.php @@ -16,7 +16,7 @@ * @package MySQLDumper * @subpackage Controllers */ -class SqlServerController extends Zend_Controller_Action +class SqlServerController extends Msd_Controller_Action { /** * Init diff --git a/application/forms/Config/Email.php b/application/forms/Config/Email.php index 9bba8a1..2e020dd 100644 --- a/application/forms/Config/Email.php +++ b/application/forms/Config/Email.php @@ -36,7 +36,7 @@ class Application_Form_Config_Email extends Zend_Form_SubForm */ public function init() { - $this->_config = Msd_Configuration::getInstance(); + $this->_config = Msd_Registry::getConfig(); $this->_lang = Msd_Language::getInstance(); $this->setDisableLoadDefaultDecorators(true); $this->setDecorators(array('SubForm')); @@ -58,7 +58,7 @@ class Application_Form_Config_Email extends Zend_Form_SubForm // add Recipients CC $ccElements = $this->_setRecipientCc( - $this->_config->get('config.email.RecipientCc'), + $this->_config->getParam('email.RecipientCc'), $activateValidator ); diff --git a/application/forms/Config/Ftp.php b/application/forms/Config/Ftp.php index 095ef69..f17d529 100644 --- a/application/forms/Config/Ftp.php +++ b/application/forms/Config/Ftp.php @@ -29,7 +29,7 @@ class Application_Form_Config_Ftp extends Zend_Form_SubForm */ public function init() { - $config = Msd_Configuration::getInstance(); + $config = Msd_Registry::getConfig(); $this->_lang = Msd_Language::getInstance(); $this->setDisableLoadDefaultDecorators(true); $this->setDecorators(array('SubForm')); @@ -40,7 +40,7 @@ class Application_Form_Config_Ftp extends Zend_Form_SubForm $this->setDisplayGroupDecorators(array('DisplayGroup')); $this->_addButtonFtpAdd(); - $ftpConfig = $config->get('config.ftp'); + $ftpConfig = $config->getParam('ftp'); $ftpKeys = array_keys($ftpConfig); $nrOfFtpProfiles = count($ftpKeys, 1); foreach ($ftpKeys as $ftpConnectionId) { diff --git a/application/models/Config/FormValidator.php b/application/models/Config/FormValidator.php index 0e3e150..0007f84 100644 --- a/application/models/Config/FormValidator.php +++ b/application/models/Config/FormValidator.php @@ -51,7 +51,7 @@ class Application_Model_Config_FormValidator public function validate(Zend_View $view) { $saveConfig = false; - $config = Msd_Configuration::getInstance(); + $config = $view->config; $translator = Msd_Language::getInstance()->getTranslator(); $db = Msd_Db::getAdapter($this->_configData['dbuser']); try { @@ -73,13 +73,13 @@ class Application_Model_Config_FormValidator if ($saveConfig) { $config->save( - $config->get('dynamic.configFile'), + $view->dynamicConfig->getParam('configFile'), $this->_configData ); $view->popUpMessage()->addMessage( 'save-config', 'L_NOTICE', - array('L_SAVE_SUCCESS', $config->get('dynamic.configFile')), + array('L_SAVE_SUCCESS', $view->dynamicConfig->getParam('configFile')), array( 'modal' => true, 'dialogClass' => 'notice' diff --git a/application/models/Sqlbox.php b/application/models/Sqlbox.php index 6df44d0..8540586 100644 --- a/application/models/Sqlbox.php +++ b/application/models/Sqlbox.php @@ -21,8 +21,8 @@ class Application_Model_Sqlbox public function getTableSelectBox() { $this->_db = Msd_Db::getAdapter(); - $config = Msd_Configuration::getInstance(); - $db = $config->get('dynamic.dbActual'); + $dynamicConfig = Msd_Registry::getDynamicConfig(); + $db = $dynamicConfig->getParam('dbActual'); $tableNames = $this->_db->getTables($db); $options = array(); foreach ($tableNames as $table) { diff --git a/application/views/helpers/GetConfigTitle.php b/application/views/helpers/GetConfigTitle.php index 418758b..178ac4c 100644 --- a/application/views/helpers/GetConfigTitle.php +++ b/application/views/helpers/GetConfigTitle.php @@ -19,8 +19,6 @@ class Msd_View_Helper_GetConfigTitle extends Zend_View_Helper_Abstract { public function getConfigTitle($configName) { - $config = Msd_Configuration::getInstance(); - $configData = $config->loadConfiguration($configName, false); - return $configData->general->title; + return $this->view->config->getConfigTitle($configName); } } diff --git a/application/views/helpers/GetIcon.php b/application/views/helpers/GetIcon.php index 13b7c73..da22517 100644 --- a/application/views/helpers/GetIcon.php +++ b/application/views/helpers/GetIcon.php @@ -28,6 +28,7 @@ class Msd_View_Helper_GetIcon extends Zend_View_Helper_Abstract */ public function getIcon($name, $title='', $size='') { + //return true; static $baseUrl = false; if (!$baseUrl) { $baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl(); @@ -38,13 +39,12 @@ class Msd_View_Helper_GetIcon extends Zend_View_Helper_Abstract 'GetIcon: unknown icon \''.$name .'\' requested' ); } - $config = Msd_Configuration::getInstance(); $img = '%s'; if ($size>'') { $img = '%s'; $ret = sprintf( $img, - $config->get('paths.iconpath'), + $this->view->config->getParam('paths.iconPath'), $size, $size, $icons[$name], @@ -53,7 +53,7 @@ class Msd_View_Helper_GetIcon extends Zend_View_Helper_Abstract } else { $ret = sprintf( $img, - $config->get('paths.iconpath'), + $this->view->config->getParam('paths.iconPath'), $icons[$name], $title, $title @@ -71,10 +71,10 @@ class Msd_View_Helper_GetIcon extends Zend_View_Helper_Abstract { static $icons = false; if (!$icons) { - $config = Msd_Configuration::getInstance(); + $config = $this->view->config; $file = realpath( APPLICATION_PATH . '/../public/' - . $config->get('paths.iconpath') . '/icon.ini' + . $config->getParam('paths.iconPath') . '/icon.ini' ); $iconsIni = new Zend_Config_Ini($file, 'icons'); $icons = $iconsIni->toArray(); diff --git a/application/views/helpers/GetIconSrc.php b/application/views/helpers/GetIconSrc.php index df90277..aaf5fc9 100644 --- a/application/views/helpers/GetIconSrc.php +++ b/application/views/helpers/GetIconSrc.php @@ -37,20 +37,20 @@ class Msd_View_Helper_GetIconSrc extends Zend_View_Helper_Abstract 'GetIconSrc: unknown icon \''.$name . '\' requested' ); } - $config = Msd_Configuration::getInstance(); + $config = Msd_Registry::getConfig(); $img = $baseUrl.'/%s/%s'; if ($size>'') { $img = $baseUrl.'/%s/%sx%s/%s'; $ret = sprintf( $img, - $config->get('paths.iconpath'), + $config->getParam('paths.iconPath'), $size, $size, $icons[$name] ); } else { $ret = sprintf( - $img, $config->get('paths.iconpath'), $icons[$name] + $img, $config->getParam('paths.iconPath'), $icons[$name] ); } return $ret; @@ -65,10 +65,10 @@ class Msd_View_Helper_GetIconSrc extends Zend_View_Helper_Abstract { static $icons = false; if (!$icons) { - $config = Msd_Configuration::getInstance(); + $config = Msd_Registry::getConfig(); $file = realpath( APPLICATION_PATH . '/../public/' - . $config->get('paths.iconpath') . '/icon.ini' + . $config->getParam('paths.iconPath') . '/icon.ini' ); $iconsIni = new Zend_Config_Ini($file, 'icons'); $icons = $iconsIni->toArray(); diff --git a/application/views/helpers/Menu.php b/application/views/helpers/Menu.php index c869009..447addf 100644 --- a/application/views/helpers/Menu.php +++ b/application/views/helpers/Menu.php @@ -53,15 +53,15 @@ class Msd_View_Helper_Menu extends Zend_View_Helper_Abstract */ private function _getDatabases() { - $actualDb = $this->view->config->get('dynamic.dbActual'); - $databases = $this->view->config->get('dynamic.databases'); + $actualDb = $this->view->dynamicConfig->getParam('dbActual'); + $databases = $this->view->dynamicConfig->getParam('databases', array()); $dbo = Msd_Db::getAdapter(); if (empty($databases) || $dbo->selectDb($actualDb) !== true) { // couldn't connect to db - refresh db-list $databases = $dbo->getDatabaseNames(); // if database was deleted or is not accessible by user // fallback to default db - $defaultDb = $this->view->config->get('config.dbuser.defaultDb'); + $defaultDb = $this->view->config->getParam('dbuser.defaultDb'); if ($defaultDb != '') { $actualDb = $defaultDb; if ($dbo->selectDb($actualDb) !== true) { @@ -70,8 +70,8 @@ class Msd_View_Helper_Menu extends Zend_View_Helper_Abstract $dbo->selectDb($actualDb); } } - $this->view->config->set('dynamic.dbActual', $actualDb); - $this->view->config->set('dynamic.databases', $databases); + $this->view->dynamicConfig->setParam('dbActual', $actualDb); + $this->view->dynamicConfig->setParam('databases', $databases); } return $databases; } diff --git a/application/views/helpers/PopUpMessage.php b/application/views/helpers/PopUpMessage.php index aa39ed8..a95281b 100644 --- a/application/views/helpers/PopUpMessage.php +++ b/application/views/helpers/PopUpMessage.php @@ -167,8 +167,7 @@ class Msd_View_Helper_PopUpMessage extends Zend_View_Helper_Abstract */ private function _getDefaultPosition() { - $config = Msd_Configuration::getInstance(); - $position = $config->get('config.interface.notificationWindowPosition'); + $position = $this->view->config->getParam('interface.notificationWindowPosition'); if (isset($this->_positions[$position])) { $position = $this->_positions[$position]; } diff --git a/application/views/layouts/layout.phtml b/application/views/layouts/layout.phtml index 7c708a7..7844d9e 100644 --- a/application/views/layouts/layout.phtml +++ b/application/views/layouts/layout.phtml @@ -1,9 +1,9 @@ get('config.interface.theme'); -$language = $config->get('config.interface.language'); +$theme = $config->getParam('interface.theme'); +$language = $config->getParam('interface.language'); $this->headMeta()->appendHttpEquiv('content-language', $language); $this->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=utf-8') ->appendHttpEquiv('expires', 'Wed, 26 Feb 1997 08:21:57 GMT') diff --git a/application/views/layouts/mobile.phtml b/application/views/layouts/mobile.phtml index 279ddb4..e1bc2b0 100644 --- a/application/views/layouts/mobile.phtml +++ b/application/views/layouts/mobile.phtml @@ -1,10 +1,9 @@ - get('config.interface.theme'); //@todo why theme? -$language = $config->get('config.interface.language'); +$theme = $config->getParam('interface.theme'); //@todo why theme? +$language = $config->getParam('interface.language'); $this->headMeta()->appendHttpEquiv('content-language', $language); $this->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=utf-8') ->appendHttpEquiv('expires', 'Wed, 26 Feb 1997 08:21:57 GMT') @@ -47,4 +46,4 @@ $messages = (string) $this->popUpMessage(); echo $this->layout()->content; ?> - \ No newline at end of file + diff --git a/application/views/mobile/scripts/index/index.phtml b/application/views/mobile/scripts/index/index.phtml index 814cc36..51d1d0c 100644 --- a/application/views/mobile/scripts/index/index.phtml +++ b/application/views/mobile/scripts/index/index.phtml @@ -146,7 +146,7 @@ $t = Msd_Language::getInstance()->getTranslator(); databases as $db) { echo ''; @@ -173,7 +173,7 @@ $t = Msd_Language::getInstance()->getTranslator(); $this->configFiles = Msd_File::getConfigNames(); foreach ($this->configFiles as $file) { echo "\n" . ''; diff --git a/application/views/scripts/config/databases.phtml b/application/views/scripts/config/databases.phtml index 1d10967..c9f686e 100644 --- a/application/views/scripts/config/databases.phtml +++ b/application/views/scripts/config/databases.phtml @@ -109,11 +109,11 @@ config->get('config.databases'); +$dbs = $this->config->getParam('databases'); echo $this->partial( 'config/databases/listDbs.phtml', array('databases' => $dbs, - 'dbActual' => $this->config->get('dynamic.dbActual'), + 'dbActual' => $this->dynamicConfig->getParam('dbActual'), 'parent' => $this, ) ); diff --git a/application/views/scripts/config/index.phtml b/application/views/scripts/config/index.phtml index c13bd1c..b9aa778 100644 --- a/application/views/scripts/config/index.phtml +++ b/application/views/scripts/config/index.phtml @@ -189,8 +189,8 @@ $testFtpConnectionUrl = $this->url(
-

lang->L_CONFIG_HEADLINE;?>: config->get('dynamic.configFile');?> -(lang->L_MSD_MODE;?>: config->get('config.general.mode');?>)

+

lang->L_CONFIG_HEADLINE;?>: dynamicConfig->getParam('configFile');?> +(lang->L_MSD_MODE;?>: config->getParam('general.mode');?>)

/* config->get('dynamic.databases')) == 0): ?> + dynamicConfig->getParam('databases')) == 0): ?> mySlideDown('connection-params'); /*]]>*/ diff --git a/application/views/scripts/dump/email.phtml b/application/views/scripts/dump/email.phtml index f8d4dc8..ccd867b 100644 --- a/application/views/scripts/dump/email.phtml +++ b/application/views/scripts/dump/email.phtml @@ -6,7 +6,7 @@ $this->lang = $this->parent->lang; lang->L_SEND_MAIL_FORM?>: config->get('config.email.sendMail') == 0) { + if ($this->config->getParam('email.sendMail') == 0) { echo $this->lang->L_NO; } else { echo $this->lang->L_YES; diff --git a/application/views/scripts/dump/ftp.phtml b/application/views/scripts/dump/ftp.phtml index ce230f4..48d8f9d 100644 --- a/application/views/scripts/dump/ftp.phtml +++ b/application/views/scripts/dump/ftp.phtml @@ -2,9 +2,10 @@ $this->config = $this->parent->config; $this->lang = $this->parent->lang; -if (count($this->config->get('config.ftp'))>0) { +$ftpConfigurations = $this->config->getParam('ftp'); +if (count($ftpConfigurations) > 0) { $ftpNr = 1; - foreach ($this->config->get('config.ftp') as $ftp) { + foreach ($ftpConfigurations as $ftp) { if ($ftp['use'] == 'y') { ?> diff --git a/application/views/scripts/dump/index.phtml b/application/views/scripts/dump/index.phtml index 2d33d7d..fca6ef8 100644 --- a/application/views/scripts/dump/index.phtml +++ b/application/views/scripts/dump/index.phtml @@ -54,7 +54,7 @@ $d = $this->dumpData; - config->get('config.mode') > 0) { ?> + config->getParam('mode', 0) > 0) { ?> @@ -76,10 +76,14 @@ $d = $this->dumpData;

partial('dump/settings.phtml',array('parent' => $this)); +echo $this->partial('dump/settings.phtml', array( + 'parent' => $this, + 'config' => $this->config, + 'dynamicConfig' => $this->dynamicConfig) +); ?> \ No newline at end of file + diff --git a/application/views/scripts/dump/start-dump.phtml b/application/views/scripts/dump/start-dump.phtml index 9594bc0..d07fa3c 100644 --- a/application/views/scripts/dump/start-dump.phtml +++ b/application/views/scripts/dump/start-dump.phtml @@ -102,7 +102,7 @@ $(document).ready( function () { lang->L_CONFIG;?>: - config->get('dynamic.configFile')?> + dynamicConfig->getParam('configFile')?> @@ -274,4 +274,4 @@ $(document).ready( function () {

lang->L_LOG;?>:

-

\ No newline at end of file +

diff --git a/application/views/scripts/error/error.phtml b/application/views/scripts/error/error.phtml index 18dd225..843a47b 100644 --- a/application/views/scripts/error/error.phtml +++ b/application/views/scripts/error/error.phtml @@ -12,7 +12,7 @@ $version = new Msd_Version(); displayErrors == 1) { +//if ($this->displayErrors == 1) { ?>

An error occurred

message ?>

@@ -47,7 +47,7 @@ if ($this->displayErrors == 1) {
request->getParams(), true) ?>
   
- \ No newline at end of file + diff --git a/application/views/scripts/index/index.phtml b/application/views/scripts/index/index.phtml index ac9ca9f..e3b1282 100644 --- a/application/views/scripts/index/index.phtml +++ b/application/views/scripts/index/index.phtml @@ -5,7 +5,7 @@

lang->L_VERSIONSINFORMATIONEN;?>

-love your data @@ -28,7 +28,7 @@ @@ -37,7 +37,7 @@ @@ -49,9 +49,9 @@ - -config->get('dynamic.disabledPhpFunctions') > '') { ?> +dynamicConfig->getParam('disabledPhpFunctions') > '') { ?> - +
lang->L_MEMORY;?>: - byteOutput($this->config->get('dynamic.phpRam')*1024*1024, 0);?> + byteOutput($this->dynamicConfig->getParam('phpRam')*1024*1024, 0);?>
serverMaxExecutionTime;?> lang->L_SECONDS;?> - (config->get('dynamic.maxExecutionTime');?> + (dynamicConfig->getParam('maxExecutionTime');?> lang->L_SECONDS;?>)
lang->L_PHP_EXTENSIONS;?>:config->get('dynamic.phpextensions');?> + dynamicConfig->getParam('phpExtensions');?> config->get('dynamic.compression')) { ?> + if (!$this->dynamicConfig->getParam('compression')) { ?>
lang->L_NOGZPOSSIBLE;?> @@ -59,10 +59,10 @@
lang->L_DISABLEDFUNCTIONS;?>:config->get('dynamic.disabledPhpFunctions');?>dynamicConfig->getParam('disabledPhpFunctions');?>
@@ -83,7 +83,7 @@ lang->L_INFO_ACTDB;?>: - config->get('dynamic.dbActual');?> + dynamicConfig->getParam('dbActual');?> lang->L_FM_FREESPACE;?>: diff --git a/application/views/scripts/index/menu.phtml b/application/views/scripts/index/menu.phtml index cdc51cd..847cd0c 100644 --- a/application/views/scripts/index/menu.phtml +++ b/application/views/scripts/index/menu.phtml @@ -1,5 +1,5 @@ config->get('config.interface.theme'); +$theme = $this->config->getParam('interface.theme', 'msd'); $request = Zend_Controller_Front::getInstance()->getRequest(); $this->controller = $request->getControllerName(); $this->action = $request->getActionName(); @@ -41,7 +41,7 @@ $('#fadeMenuIn').click(function() { return false; }); config->get('config.interface.showTooltips') == 'y') { ?> + if ($this->config->getParam('interface.showTooltips') == 'y') { ?> SetupTooltips(); jQuery()->onLoadCaptureEnd(); @@ -58,11 +58,11 @@ $this->jQuery()->onLoadCaptureEnd();
- <?php echo $this->lang->L_MENU_HIDE;?>
Version msdVersion;?> - config->get('config.general.mode') == 'easy') {?> + config->getParam('general.mode') == 'easy') {?> @@ -143,7 +143,7 @@ $this->jQuery()->onLoadCaptureEnd(); $this->databases = $dbAdapter->getDatabaseNames(); foreach ($this->databases as $db) { echo ''; @@ -165,16 +165,16 @@ $this->jQuery()->onLoadCaptureEnd(); $this->configFiles = Msd_File::getConfigNames(); foreach ($this->configFiles as $file) { echo "\n" . ''; + echo '>'. $this->config->getConfigTitle($file) . ''; } ?> - config->get('config.interface.language'), array('de', 'ch'))) {; ?> + config->getParam('interface.language'), array('de', 'ch'))) {; ?>

@@ -198,7 +198,7 @@ $this->jQuery()->onLoadCaptureEnd();

config->get('config.interface.showServerCaption') == "y") { +if ($this->config->getParam('interface.showServerCaption') == "y") { ?>
lang->L_SERVER;?>: diff --git a/application/views/scripts/sql/databases/show-databases.phtml b/application/views/scripts/sql/databases/show-databases.phtml index 932e0ed..83c2be5 100644 --- a/application/views/scripts/sql/databases/show-databases.phtml +++ b/application/views/scripts/sql/databases/show-databases.phtml @@ -1,10 +1,10 @@ config->get('config.systemDatabases'); +$systemDatabases = $this->config->getParam('systemDatabases'); $formUrl = $this->url(array('controller'=>'sql','action'=>'index')); $cycleHelper = $this->getHelper('cycle')->cycle(array('row-even', 'row-odd')); ?>
-

lang->L_DATABASES_OF_USER;?> 'config->get('config.dbuser.user').'\'@\''.$this->config->get('config.dbuser.host');?>'

+

lang->L_DATABASES_OF_USER;?> 'config->getParam('dbuser.user').'\'@\''.$this->config->getParam('dbuser.host');?>'

sqlHeadNavi(); ?> actionResults)) { @@ -100,7 +100,7 @@ if (isset($this->actionResults)) { ?> getIcon('Server', '', 16) - . $this->config->get('config.dbuser.user') .'@' - . $this->config->get('config.dbuser.host'); - $port = $this->config->get('config.dbuser.port'); + . $this->config->getParam('dbuser.user') .'@' + . $this->config->getParam('dbuser.host'); + $port = $this->config->getParam('dbuser.port'); if ($port > 0) { echo ':' . $port; } @@ -34,11 +34,11 @@ $this->jQuery()->javascriptCaptureStart(); ?>
  • getIcon('Database', '', 16);?> - out($this->config->get('dynamic.dbActual'));?> + out($this->dynamicConfig->getParam('dbActual'));?>
  • config->get('dynamic.tableActual'); + $actualTable = $this->dynamicConfig->getParam('tableActual'); if ($actualTable > '') { ?>
  • diff --git a/application/views/scripts/sql/sqlbox/sqlbox.phtml b/application/views/scripts/sql/sqlbox/sqlbox.phtml index eb3835f..9382374 100644 --- a/application/views/scripts/sql/sqlbox/sqlbox.phtml +++ b/application/views/scripts/sql/sqlbox/sqlbox.phtml @@ -25,7 +25,7 @@ $('#sqltextarea').bind('keyup', function(e){
  • - +
    lang->L_SQL_WARNING;?>
    @@ -130,4 +130,4 @@ if (isset($this->resultSummary)) { -
    \ No newline at end of file + diff --git a/application/views/scripts/sql/tables/show-tables.phtml b/application/views/scripts/sql/tables/show-tables.phtml index b07b7cc..195840d 100644 --- a/application/views/scripts/sql/tables/show-tables.phtml +++ b/application/views/scripts/sql/tables/show-tables.phtml @@ -1,5 +1,5 @@
    -

    lang->L_SQL_TABLESOFDB;?> `config->get('dynamic.dbActual');?>` +

    lang->L_SQL_TABLESOFDB;?> `dynamicConfig->getParam('dbActual');?>`

    sqlHeadNavi(); diff --git a/library/Msd/Action/Helper/AssignConfigAndLanguage.php b/library/Msd/Action/Helper/AssignConfigAndLanguage.php index a9b0e6d..15a2163 100644 --- a/library/Msd/Action/Helper/AssignConfigAndLanguage.php +++ b/library/Msd/Action/Helper/AssignConfigAndLanguage.php @@ -16,8 +16,7 @@ * @package MySQLDumper * @subpackage Action_Helper */ -class Msd_Action_Helper_AssignConfigAndLanguage - extends Zend_Controller_Action_Helper_Abstract +class Msd_Action_Helper_AssignConfigAndLanguage extends Zend_Controller_Action_Helper_Abstract { /** * Actual Zend_View instance @@ -36,9 +35,10 @@ class Msd_Action_Helper_AssignConfigAndLanguage if ($controllerName == 'install') { return; } - $view = $this->getView(); - $view->config = Msd_Configuration::getInstance(); - $view->lang = Msd_Language::getInstance(); + $view = $this->getView(); + $view->config = Msd_Registry::getConfig(); + $view->dynamicConfig = Msd_Registry::getDynamicConfig(); + $view->lang = Msd_Language::getInstance(); } /** @@ -51,7 +51,7 @@ class Msd_Action_Helper_AssignConfigAndLanguage if (null !== $this->_view) { return $this->_view; } else { - $controller = $this->getActionController(); + $controller = $this->getActionController(); $this->_view = $controller->view; return $this->_view; } diff --git a/library/Msd/Config.php b/library/Msd/Config.php index 7b95cf2..3725bc9 100644 --- a/library/Msd/Config.php +++ b/library/Msd/Config.php @@ -52,7 +52,7 @@ class Msd_Config if (is_string($ioHandler)) { $pluginLoader = new Zend_Loader_PluginLoader( array( - 'Msd_Config_IoHandler_' => APPLICATION_PATH . '/../library/Msd/Config/IoHandler/', + 'Msd_Config_IoHandler_' => APPLICATION_PATH . '/../library/Msd/Config/IoHandler/', 'Module_Config_IoHandler_' => APPLICATION_PATH . '/../modules/library/Config/IoHandler/', ) ); @@ -79,6 +79,25 @@ class Msd_Config public function load($configFilename) { $this->_config = $this->_ioHandler->load($configFilename); + $this->_setPaths(); + } + + /** + * Add paths to config + * + * @return void + */ + private function _setPaths() + { + $workRoot = realpath(APPLICATION_PATH . '/..') . '/work/'; + $directories = array( + 'work' => $workRoot, + 'log' => $workRoot . 'log', + 'backup' => $workRoot . 'backup', + 'config' => $workRoot . 'config', + 'iconPath' => 'css/' . $this->getParam('interface.theme', 'msd') . '/icons' + ); + $this->setParam('paths', $directories); } /** @@ -95,13 +114,23 @@ class Msd_Config /** * Retrieves the value of a configuration parameter. * - * @param string $paramName Name of the configuration parameter. + * @param string $paramName Name of the configuration parameter. May be prefixed with section. * @param mixed $defaultValue Default value to return, if param isn't set. * * @return mixed */ public function getParam($paramName, $defaultValue = null) { + // check for section e.g. interface.theme + if (strpos($paramName, '.') !== false) { + list($section, $paramName) = explode('.', $paramName); + if (isset($this->_config[$section][$paramName])) { + return $this->_config[$section][$paramName]; + } else { + return $defaultValue; + } + } + if (isset($this->_config[$paramName])) { return $this->_config[$paramName]; } @@ -120,7 +149,14 @@ class Msd_Config */ public function setParam($paramName, $paramValue) { - $this->_config[$paramName] = $paramValue; + if (strpos('paramName', '.') !== false) { + list($section, $paramName) = explode('.', $paramName); + $this->_config[$section][$paramName] = $paramValue; + + } else { + $this->_config[$paramName] = $paramValue; + } + if ($this->_autosave) { $this->save(); } @@ -145,7 +181,7 @@ class Msd_Config */ public function setConfig($config) { - $this->_config = (array) $config; + $this->_config = (array)$config; if ($this->_autosave) { $this->save(); } @@ -190,4 +226,18 @@ class Msd_Config { return $this->_autosave; } + + /** + * Get the title from a configuration file without aplying it. + * + * @param string $fileName The file name of the configuration + * + * @return string + */ + public function getConfigTitle($fileName) + { + $configData = parse_ini_file($this->getParam('paths.config') . '/' . $fileName . '.ini', true); + return $configData['general']['title']; + } + } diff --git a/library/Msd/Config/Dynamic.php b/library/Msd/Config/Dynamic.php index adabbd7..0684508 100644 --- a/library/Msd/Config/Dynamic.php +++ b/library/Msd/Config/Dynamic.php @@ -33,6 +33,7 @@ class Msd_Config_Dynamic public function __construct($sessionNsName = 'Dynamic') { $this->_namespace = new Zend_Session_Namespace($sessionNsName); + $this->getDynamicValues(); } /** @@ -64,4 +65,118 @@ class Msd_Config_Dynamic { $this->_namespace->$name = $value; } + + /** + * Read dynamic PHP config values + * + * @return Zend_Config + */ + public function getDynamicValues () + { + $this->setParam('compression', self::_hasZlib()); + $this->setParam('phpExtensions', str_replace(',', ', ', implode(', ', get_loaded_extensions()))); + $phpRam = $this->_getPhpRam(); + $this->setParam('phpRam', $phpRam); + $this->setParam('memoryLimit', round($phpRam * 1024 * 1024 * 0.9, 0)); + $this->setParam('sendmailCall', $this->_getConfigSetting('sendmail_path')); + $this->setParam('safeMode', $this->_getConfigSetting('safe_mode', true)); + $this->setParam('magicQuotesGpc', get_magic_quotes_gpc()); + $disabledPhpFunctions = $this->_getConfigSetting('disable_functions'); + $this->setParam('disabledPhpFunctions', str_replace(',', ', ', $disabledPhpFunctions)); + $this->setParam('maxExecutionTime', $this->_getMaxExecutionTime()); + $this->setParam('uploadMaxFilesize', $this->_getUploadMaxFilesize()); + } + + /** + * Read PHP's max_execution_time + * + * @return int + */ + private function _getMaxExecutionTime() + { + $maxExecutionTime = + $this->_getConfigSetting('max_execution_time', true); + if ($maxExecutionTime <= 5) { + // we didn't get the real value from the server - some deliver "-1" + $maxExecutionTime = 30; + } elseif ($maxExecutionTime > 30) { + // we don't use more than 30 seconds to avoid brower timeouts + $maxExecutionTime = 30; + } + return $maxExecutionTime; + } + + /** + * Get PHP's upload_max_filesize + * + * @return int + */ + private function _getUploadMaxFilesize() + { + $uploadMaxFilesize = $this->_getConfigSetting('upload_max_filesize'); + // Is value in Megabytes? If yes create output + if (strpos($uploadMaxFilesize, 'M')) { + $uploadMaxFilesize = str_replace('M', '', $uploadMaxFilesize); + $uploadMaxFilesize = trim($uploadMaxFilesize); + // re-calculate to Bytes + $uploadMaxFilesize *= 1024 * 1024; + } + return (int) $uploadMaxFilesize;; + } + + /** + * Get PHP's ram size + * + * @return integer The memory limit in MB + */ + private function _getPhpRam() + { + $ram = $this->_getConfigSetting('memory_limit'); + // we don't trust the value delivered by server config if < 16 + if ($ram < 16) { + $ram = 16; + } + return $ram; + } + + /** + * Detect if zlib is installed + * + * @return boolean + */ + private function _hasZlib() + { + $zlib = false; + $extensions = get_loaded_extensions(); + if (in_array('zlib', $extensions)) { + $zlib = true; + }; + return (boolean) $zlib; + } + + /** + * Returns a PHP-Setting from ini + * + * First try to read via ini_get(), then fall back to get_cfg_var() + * + * @param string $varName The name of the setting to read + * @param bool $returnAsInt Whether to return value as integer + * + * @return mixed + */ + private function _getConfigSetting($varName, $returnAsInt = false) + { + $value = @ini_get($varName); + + // fallback if ini_get doesn't work + if ($value == '' || $value === null) { + $value = @get_cfg_var($varName); + } + + if ($returnAsInt) { + $value = (int) $value; + } + return $value; + } + } diff --git a/library/Msd/ConfigurationPhpValues.php b/library/Msd/ConfigurationPhpValues.php index fc520f3..6ead210 100644 --- a/library/Msd/ConfigurationPhpValues.php +++ b/library/Msd/ConfigurationPhpValues.php @@ -117,7 +117,9 @@ class Msd_ConfigurationPhpValues * First try to read via ini_get(), then fall back to get_cfg_var() * * @param string $varName The name of the setting to read - * @param boolean $returnAsInt Whether to return value as integer + * @param bool $returnAsInt Whether to return value as integer + * + * @return mixed */ private function _getConfigSetting($varName, $returnAsInt = false) { diff --git a/library/Msd/Controller/Action.php b/library/Msd/Controller/Action.php new file mode 100644 index 0000000..ad811e6 --- /dev/null +++ b/library/Msd/Controller/Action.php @@ -0,0 +1,66 @@ +_config = Msd_Registry::getConfig(); + $this->_dynamicConfig = Msd_Registry::getDynamicConfig(); + parent::__construct($request, $response, $invokeArgs); + } +} diff --git a/library/Msd/Db.php b/library/Msd/Db.php index 39a52e0..509bbce 100644 --- a/library/Msd/Db.php +++ b/library/Msd/Db.php @@ -124,13 +124,13 @@ abstract class Msd_Db public static function getAdapter($options = null, $forceMysql = false) { if ($options === null) { - $config = Msd_Configuration::getInstance(); + $config = Msd_Registry::getConfig(); $options = array( - 'host' => $config->get('config.dbuser.host'), - 'user' => $config->get('config.dbuser.user'), - 'pass' => $config->get('config.dbuser.pass'), - 'port' => (int) $config->get('config.dbuser.port'), - 'socket' => $config->get('config.dbuser.socket'), + 'host' => $config->getParam('dbuser.host'), + 'user' => $config->getParam('dbuser.user'), + 'pass' => $config->getParam('dbuser.pass'), + 'port' => (int) $config->getParam('dbuser.port'), + 'socket' => $config->getParam('dbuser.socket'), ); } if (function_exists('mysqli_connect') && !$forceMysql) { diff --git a/library/Msd/Dump.php b/library/Msd/Dump.php index faa90e3..2ee5b23 100644 --- a/library/Msd/Dump.php +++ b/library/Msd/Dump.php @@ -62,8 +62,8 @@ class Msd_Dump */ private function _getDbsToBackup() { - $config = Msd_Configuration::getInstance(); - $databases = $config->get('dynamic.databases'); + $dynamicConfig = Msd_Registry::getDynamicConfig(); + $databases = $dynamicConfig->getParam('dynamic.databases'); // first check if any db is marked to be dumped $dbToDumpExists = false; if (!empty($databases)) { @@ -77,7 +77,7 @@ class Msd_Dump } if (!$dbToDumpExists) { // no db selected for dump -> set actual db to be dumped - $index = $config->get('dynamic.dbActual'); + $index = $dynamicConfig->getParam('dbActual'); $this->dbsToBackup[$index] = array(); $this->dbsToBackup[$index]['dump'] = 1; } @@ -203,4 +203,4 @@ class Msd_Dump ); } } -} \ No newline at end of file +} diff --git a/library/Msd/File.php b/library/Msd/File.php index b76b907..f13d6c2 100644 --- a/library/Msd/File.php +++ b/library/Msd/File.php @@ -58,9 +58,9 @@ class Msd_File */ public static function getLatestBackupInfo() { - $config = Msd_Configuration::getInstance(); + $config = Msd_Registry::getConfig(); $latestBackup = array(); - $dir = new DirectoryIterator($config->get('paths.backup')); + $dir = new DirectoryIterator($config->getParam('paths.backup')); foreach ($dir as $file) { if ($file->isFile()) { $fileMtime = $file->getMTime(); @@ -84,11 +84,12 @@ class Msd_File */ public static function getConfigNames() { - $config = Msd_Configuration::getInstance(); - $configPath = $config->get('paths.config'); + $config = Msd_Registry::getConfig(); + $configPath = $config->getParam('paths.config'); if (!is_readable($configPath)) { return array(); } + $dir = new DirectoryIterator($configPath); $files = array(); foreach ($dir as $file) { diff --git a/library/Msd/File/Dump.php b/library/Msd/File/Dump.php index bd154ce..66b7567 100644 --- a/library/Msd/File/Dump.php +++ b/library/Msd/File/Dump.php @@ -28,8 +28,8 @@ class Msd_File_Dump extends Msd_File */ public static function getStatusline($filename) { - $config = Msd_Configuration::getInstance(); - $path = $config->get('paths.backup'). DS; + $config = Msd_Registry::getConfig(); + $path = $config->getParam('paths.backup'). '/'; if (strtolower(substr($filename, -3)) == '.gz') { $fileHandle = gzopen($path . $filename, "r"); if ($fileHandle === false) { diff --git a/library/Msd/Language.php b/library/Msd/Language.php index 8a80807..c7fd7e0 100644 --- a/library/Msd/Language.php +++ b/library/Msd/Language.php @@ -21,7 +21,7 @@ class Msd_Language /** * Instance * - * @var Msd_Configuration + * @var Msd_Language */ private static $_instance = NULL; @@ -42,12 +42,12 @@ class Msd_Language /** * Constructor gets the configuration params * - * @return array + * @return Msd_Language */ - private function __construct () + private function __construct() { - $config = Msd_Configuration::getInstance(); - $language = $config->get('config.interface.language'); + $config = Msd_Registry::getConfig(); + $language = $config->getParam('interface.language', 'en'); $this->loadLanguage($language); } @@ -61,8 +61,8 @@ class Msd_Language public function loadLanguage($language) { $this->_baseLanguageDir = APPLICATION_PATH . '/language/'; - $file = $this->_baseLanguageDir . $language . '/lang.php'; - $translator = $this->getTranslator(); + $file = $this->_baseLanguageDir . $language . '/lang.php'; + $translator = $this->getTranslator(); if ($translator === null) { $translator = new Zend_Translate('array', $file, $language); } else { @@ -70,16 +70,19 @@ class Msd_Language array( 'adapter' => 'array', 'content' => $file, - 'locale' => $language + 'locale' => $language ) ); } $this->setTranslator($translator); Zend_Registry::set('Zend_Translate', $translator); } + /** * No cloning for singleton * + * @throws Msd_Exception + * * @return void */ public function __clone() @@ -90,25 +93,26 @@ class Msd_Language /** * Magic getter to keep syntax in rest of script short * - * @param mixed $var + * @param mixed $name Name of language var to translate * * @return mixed */ - public function __get ($property) + public function __get($name) { - $translated = $this->getTranslator()->_($property); - if ($translated == $property && substr($property, 0, 2) == 'L_') { + $translated = $this->getTranslator()->_($name); + if ($translated == $name && substr($name, 0, 2) == 'L_') { // no translation found -> remove prefix L_ - return substr($property, 2); + return substr($name, 2); } return $translated; } + /** * Returns the single instance * * @return Msd_Language */ - public static function getInstance () + public static function getInstance() { if (NULL == self::$_instance) { self::$_instance = new self; @@ -126,7 +130,7 @@ class Msd_Language */ public function translateZendId($zendMessageId, $messageText = '') { - if (substr($zendMessageId, 0, 6) =='access' && $messageText > '') { + if (substr($zendMessageId, 0, 6) == 'access' && $messageText > '') { // message is already translated by validator access return $messageText; } diff --git a/library/Msd/Log.php b/library/Msd/Log.php index 2ae0b0a..ffd9f2d 100644 --- a/library/Msd/Log.php +++ b/library/Msd/Log.php @@ -29,7 +29,7 @@ class Msd_Log /** * Init file handles * - * @return void + * @return Msd_Log */ public function __construct() { @@ -41,8 +41,8 @@ class Msd_Log $this->handle[self::ERROR] = false; // get config - $config = Msd_Configuration::getInstance(); - $this->_paths = (object)$config->get('paths'); + $config = Msd_Registry::getConfig(); + $this->_paths = (object) $config->getParam('paths'); } /** diff --git a/library/Msd/TaskManager.php b/library/Msd/TaskManager.php index 68ef5f6..2d0967c 100644 --- a/library/Msd/TaskManager.php +++ b/library/Msd/TaskManager.php @@ -31,7 +31,7 @@ class Msd_TaskManager /** * Instance * - * @var Msd_Configuration + * @var Msd_TaskManager */ private static $_instance = NULL; @@ -48,12 +48,10 @@ class Msd_TaskManager * * Get task list from session or init an empty list. * - * @param string $taskType Task type to get or create. - * Defaults to "backupTasks". - * @param boolean Whether to create a new task list and delete all entries - * or to get it from the session + * @param string $taskType The name of the task type + * @param boolean $clear Whether to clear all tasks * - * @return void + * @return Msd_TaskManager */ private function __construct($taskType, $clear = false) { @@ -69,15 +67,12 @@ class Msd_TaskManager /** * Returns the task manager instance * - * @param string $configname The name of the configuration file to load. - * If not set we will load the config from - * session if present. - * @param boolean $forceLoading If set the config will be read from file. + * @param string $taskType The name of the task type + * @param boolean $clear Whether to clear all tasks * - * @return Msd_Configuration + * @return Msd_TaskManager */ - public static function getInstance($taskType = 'backupTasks', - $clear = false) + public static function getInstance($taskType = 'backupTasks', $clear = false) { if (null == self::$_instance) { self::$_instance = new self($taskType, $clear); diff --git a/library/Msd/User.php b/library/Msd/User.php index 557fedc..6b59891 100644 --- a/library/Msd/User.php +++ b/library/Msd/User.php @@ -246,6 +246,7 @@ class Msd_User $configFile = $files[0]; } } - Msd_Configuration::getInstance($configFile, true); + $config = Msd_Registry::getConfig(); + $config->load($configFile . '.ini'); } } diff --git a/library/Zend/Config/Ini.php b/library/Zend/Config/Ini.php index c1845b7..ae9edfb 100644 --- a/library/Zend/Config/Ini.php +++ b/library/Zend/Config/Ini.php @@ -100,6 +100,7 @@ class Zend_Config_Ini extends Zend_Config public function __construct($filename, $section = null, $options = false) { if (empty($filename)) { + var_export(debug_backtrace()); /** * @see Zend_Config_Exception */ diff --git a/tests/fixtures/sessions/sessionTester.txt b/tests/fixtures/sessions/sessionTester.txt index 168ab76c6246c77328eb18730daca282fcc4bba4..e0b27f54c671aa7dfcc93fd1733b20e293322659 100644 GIT binary patch delta 16 XcmbPaG{tB`lLTYHset('dynamic.dbActual', 'information_schema'); + $dynamicConfig = Msd_Registry::getDynamicConfig(); + $dynamicConfig->setParam('dbActual', 'information_schema'); $selectBox = $model->getTableSelectBox(); $tables = array('CHARACTER_SETS', 'COLLATIONS', 'COLLATION_CHARACTER_SET_APPLICABILITY', 'COLUMNS', 'COLUMN_PRIVILEGES', 'ENGINES' diff --git a/tests/functional/application/views/helpers/MenuTest.php b/tests/functional/application/views/helpers/MenuTest.php index 7be26b1..3eea3d3 100644 --- a/tests/functional/application/views/helpers/MenuTest.php +++ b/tests/functional/application/views/helpers/MenuTest.php @@ -20,8 +20,8 @@ class MenuTest extends ControllerTestCase public function testCanRenderMenuWithInvalidActualDatabase() { $this->loginUser(); - $config = Msd_Configuration::getInstance(); - $config->set('dynamic.dbActual', -1); + $dynamicConfig = Msd_Registry::getDynamicConfig(); + $dynamicConfig->setParam('dbActual', -1); $this->dispatch('/'); $this->assertQueryContentContains('#selectedDb', 'information_schema'); } @@ -29,9 +29,10 @@ class MenuTest extends ControllerTestCase public function testCanFallbackToDefaultDbIfActualDbIsInvalid() { $this->loginUser(); - $config = Msd_Configuration::getInstance(); - $config->set('dynamic.dbActual', 'i_dont_exist'); - $config->set('config.dbuser.defaultDb', 'information_schema'); + $dynamicConfig = Msd_Registry::getDynamicConfig(); + $dynamicConfig->setParam('dbActual', 'i_dont_exist'); + $config = Msd_Registry::getConfig(); + $config->set('dbuser.defaultDb', 'information_schema'); $this->dispatch('/'); $this->assertQueryContentContains('#selectedDb', 'information_schema'); } @@ -39,9 +40,10 @@ class MenuTest extends ControllerTestCase public function testCanFallbackToFirstDbIfActualAndDefaultDbsAreInvalid() { $this->loginUser(); - $config = Msd_Configuration::getInstance(); - $config->set('dynamic.dbActual', 'i_dont_exist'); - $config->set('config.dbuser.defaultDb', 'I_dont_exist'); + $dynamicConfig = Msd_Registry::getDynamicConfig(); + $dynamicConfig->setParam('dbActual', 'i_dont_exist'); + $config = Msd_Registry::getConfig(); + $config->setParam('dbuser.defaultDb', 'I_dont_exist'); $this->dispatch('/'); $this->assertQueryContentContains('#selectedDb', 'information_schema'); }