2011-06-10 21:55:32 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
|
|
|
* http://www.mysqldumper.net
|
|
|
|
*
|
|
|
|
* @package MySQLDumper
|
|
|
|
* @subpackage Controllers
|
|
|
|
* @version SVN: $Rev$
|
|
|
|
* @author $Author$
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* Assign config- and language to view
|
|
|
|
*
|
|
|
|
* Helper to auto assign the config- and language instance to view instances
|
|
|
|
*
|
|
|
|
* @package MySQLDumper
|
|
|
|
* @subpackage Action_Helper
|
|
|
|
*/
|
2012-08-04 17:09:48 +00:00
|
|
|
class Msd_Action_Helper_AssignConfigAndLanguage extends Zend_Controller_Action_Helper_Abstract
|
2011-06-10 21:55:32 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Actual Zend_View instance
|
|
|
|
* @var Zend_View
|
|
|
|
*/
|
|
|
|
protected $_view;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PreDispatcher
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function preDispatch()
|
|
|
|
{
|
|
|
|
$controllerName = $this->getRequest()->getControllerName();
|
|
|
|
if ($controllerName == 'install') {
|
|
|
|
return;
|
|
|
|
}
|
2012-08-21 20:22:56 +00:00
|
|
|
|
2012-08-22 16:43:15 +00:00
|
|
|
$view = $this->getView();
|
|
|
|
$config = Msd_Registry::getConfig();
|
|
|
|
if ($config->getParam('configFile', 'defaultConfig.ini') == 'defaultConfig.ini') {
|
2012-10-27 13:39:33 +00:00
|
|
|
$configFiles = Msd_File::getConfigNames();
|
|
|
|
if (isset($configFiles[0])) {
|
|
|
|
// we do have saved configurations - load the first one
|
|
|
|
$config->load($configFiles[0]);
|
|
|
|
Msd_Registry::setConfig($config);
|
|
|
|
$dynamicConfig = Msd_Registry::getDynamicConfig();
|
|
|
|
$dynamicConfig->setParam('configFile', $configFiles[0]);
|
|
|
|
Msd_Registry::setDynamicConfig($dynamicConfig);
|
|
|
|
} else {
|
|
|
|
// nothing found -> redirect to installation
|
|
|
|
$redirectUrl = $view->serverUrl() . $view->url(
|
|
|
|
array(
|
|
|
|
'controller' => 'install',
|
|
|
|
'action' => 'index',
|
|
|
|
null,
|
|
|
|
true)
|
|
|
|
);
|
|
|
|
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
|
|
|
|
$redirector->gotoUrl($redirectUrl);
|
|
|
|
}
|
2012-08-21 20:22:56 +00:00
|
|
|
}
|
2012-08-22 16:43:15 +00:00
|
|
|
$view->config = $config;
|
2012-08-04 17:09:48 +00:00
|
|
|
$view->dynamicConfig = Msd_Registry::getDynamicConfig();
|
|
|
|
$view->lang = Msd_Language::getInstance();
|
2011-06-10 21:55:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the view instance of the actual controller
|
|
|
|
*
|
|
|
|
* @return Zend_View
|
|
|
|
*/
|
|
|
|
public function getView()
|
|
|
|
{
|
|
|
|
if (null !== $this->_view) {
|
|
|
|
return $this->_view;
|
|
|
|
} else {
|
2012-08-04 17:09:48 +00:00
|
|
|
$controller = $this->getActionController();
|
2011-06-10 21:55:32 +00:00
|
|
|
$this->_view = $controller->view;
|
|
|
|
return $this->_view;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|