From ce82d46290864fa36072ae198c277dec5235a809 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Mon, 24 Sep 2012 14:17:06 -0400 Subject: [PATCH] Don't skip form validation just because we are skipping SQL execution; style fixes; XHTML compliance fixes. --- .../VuFind/Controller/InstallController.php | 37 ++++++++++++------- .../blueprint/templates/install/showsql.phtml | 22 +++++------ 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/module/VuFind/src/VuFind/Controller/InstallController.php b/module/VuFind/src/VuFind/Controller/InstallController.php index 4e581fbaf32..85b3d3652f9 100644 --- a/module/VuFind/src/VuFind/Controller/InstallController.php +++ b/module/VuFind/src/VuFind/Controller/InstallController.php @@ -298,22 +298,22 @@ class InstallController extends AbstractBase $view->dbuser = $this->params()->fromPost('dbuser', 'vufind'); $view->dbhost = $this->params()->fromPost('dbhost', 'localhost'); $view->dbrootuser = $this->params()->fromPost('dbrootuser', 'root'); - + $skip = $this->params()->fromPost('printsql', 'nope') == 'Skip'; - if (!$skip && !preg_match('/^\w*$/', $view->dbname)) { + if (!preg_match('/^\w*$/', $view->dbname)) { $this->flashMessenger()->setNamespace('error') ->addMessage('Database name must be alphanumeric.'); - } else if (!$skip && !preg_match('/^\w*$/', $view->dbuser)) { + } else if (!preg_match('/^\w*$/', $view->dbuser)) { $this->flashMessenger()->setNamespace('error') ->addMessage('Database user must be alphanumeric.'); } else if ($skip || strlen($this->params()->fromPost('submit', '')) > 0) { $newpass = $this->params()->fromPost('dbpass'); $newpassConf = $this->params()->fromPost('dbpassconfirm'); - if (!$skip && (empty($newpass) || empty($newpassConf))) { + if ((empty($newpass) || empty($newpassConf))) { $this->flashMessenger()->setNamespace('error') ->addMessage('Password fields must not be blank.'); - } else if (!$skip && $newpass != $newpassConf) { + } else if ($newpass != $newpassConf) { $this->flashMessenger()->setNamespace('error') ->addMessage('Password fields must match.'); } else { @@ -335,8 +335,9 @@ class InstallController extends AbstractBase $sql = file_get_contents( APPLICATION_PATH . '/module/VuFind/sql/mysql.sql' ); - if($skip == 'Skip') { - $omnisql = $query .";\n". $grant .";\nFLUSH PRIVILEGES;\n\n". $sql; + if ($skip == 'Skip') { + $omnisql = $query . ";\n". $grant + . ";\nFLUSH PRIVILEGES;\n\n" . $sql; $this->getRequest()->getQuery()->set('sql', $omnisql); return $this->forwardTo('Install', 'showsql'); } else { @@ -358,8 +359,9 @@ class InstallController extends AbstractBase // forward back to the home action! $string = "mysql://{$view->dbuser}:{$newpass}@" . $view->dbhost . '/' . $view->dbname; - $config - = ConfigReader::getLocalConfigPath('config.ini', null, true); + $config = ConfigReader::getLocalConfigPath( + 'config.ini', null, true + ); $writer = new ConfigWriter($config); $writer->set('Database', 'database', $string); if (!$writer->save()) { @@ -375,15 +377,22 @@ class InstallController extends AbstractBase } return $view; } - - protected function showsqlAction() { + + /** + * Display captured SQL commands for database action. + * + * @return mixed + */ + protected function showsqlAction() + { $continue = $this->params()->fromPost('continue', 'nope'); if ($continue == 'Next') { return $this->redirect()->toRoute('install-home'); } - - return $this->createViewModel(array('sql' => $this->params()->fromQuery('sql'))); - return $view; + + return $this->createViewModel( + array('sql' => $this->params()->fromQuery('sql')) + ); } /** diff --git a/themes/blueprint/templates/install/showsql.phtml b/themes/blueprint/templates/install/showsql.phtml index fc2da6eda6d..012efc5ef65 100644 --- a/themes/blueprint/templates/install/showsql.phtml +++ b/themes/blueprint/templates/install/showsql.phtml @@ -4,24 +4,20 @@ // Set up breadcrumbs: $this->layout()->breadcrumbs = '<em>' . $this->transEsc('Install VuFind') . '</em>'; + + // Set up styles: + $this->headstyle()->appendStyle( + ".pre {\n" + . " white-space:pre-wrap; width:90%; overflow-y:visible; padding:8px; margin:1em 2em; background:#EEE; border:1px dashed #CCC;\n" + . "}\n" + ); ?> -<style> - .pre { - width:90%; - overflow-y:visible; - padding:8px; - margin:1em 2em; - background:#EEE; - border:1px dashed #CCC; - white-space:pre-wrap; - } -</style> <h1><?=$this->transEsc('Install VuFind')?></h1> <?=$this->flashmessages()?> <p>Save this SQL somewhere safe:</p> <textarea class="pre" rows="20" readonly onClick="this.select()"><?=trim($this->sql) ?></textarea> -<form method="POST" action="<?=$this->url('install-showsql')?>"> - <input type="submit" name="continue" value="Next"> +<form method="post" action="<?=$this->url('install-showsql')?>"> + <input type="submit" name="continue" value="Next" /> </form> \ No newline at end of file -- GitLab