From 6208c270010bb0d34303e626f05caf5f2f0d6b78 Mon Sep 17 00:00:00 2001 From: Thomas Hempel Date: Wed, 23 Jan 2008 21:04:25 +0000 Subject: [PATCH] * Installer: Improved the installer module. - The result of the previous steps is now displayed - Fixed some issues with "previous" button * Installer: Improved database and table creation git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2955 709f56b5-9817-0410-a4d7-c38de5d9e867 --- ChangeLog | 4 ++ .../install/mod/class.tx_install_view.php | 12 +++--- .../class.tx_install_module_database.php | 37 ++++++++++++++++--- .../install/modules/database/locallang.xml | 7 ++++ .../class.tx_install_module_installer.php | 20 +++++++--- .../install/modules/installer/locallang.xml | 3 ++ .../modules/installer/res/tpl_step.html | 1 + 7 files changed, 66 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index b1d0f509f21f..a5f0220c0845 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ 2008-01-23 Thomas Hempel * Bugfix: removed a needless comma in sysext/cms/ext_tables.sql (line 160) + * Installer: Improved the installer module. + - The result of the previous steps is now displayed + - Fixed some issues with "previous" button + * Installer: Improved database and table creation * Installer: added new option BE/RTE_imageStorageDir. related to issue #7185 * Installer: Added some styles for deliverable lists diff --git a/typo3/sysext/install/mod/class.tx_install_view.php b/typo3/sysext/install/mod/class.tx_install_view.php index 713ec5d15a0a..9505283ab179 100644 --- a/typo3/sysext/install/mod/class.tx_install_view.php +++ b/typo3/sysext/install/mod/class.tx_install_view.php @@ -433,19 +433,19 @@ class tx_install_view { foreach ($data as $singleElement) { switch ($singleElement['status']) { case 'ok': - $style = ' style="list-style-image: url('.$this->pObj->getBasicsObject()->getInstallerWebPath().'imgs/icons/ok.png)"'; + $style = 'list-style-image: url('.$this->pObj->getBasicsObject()->getInstallerWebPath().'imgs/icons/ok.png)'; break; case 'warning': - $style = ' style="list-style-image: url('.$this->pObj->getBasicsObject()->getInstallerWebPath().'imgs/icons/warning.png)"'; + $style = 'list-style-image: url('.$this->pObj->getBasicsObject()->getInstallerWebPath().'imgs/icons/warning.png)'; break; default: $style = ''; break; } - $content .= ''.$this->render($singleElement).''; + $content .= $this->renderTag('li', $this->render($singleElement), array('style' => $style)); } - $content = '
    '.$content.'
'; + $content = $this->renderTag('ul', $content); } return $content; @@ -982,7 +982,7 @@ class tx_install_view { * @param string message */ public function addMessage($message) { - $this->lastMessage .= $message; + $this->lastMessage .= '
'.$message; } /** @@ -996,7 +996,7 @@ class tx_install_view { if ($clear) { $this->clearLastMessage(); } - return $result; + return empty($result) ? false : $result; } /** diff --git a/typo3/sysext/install/modules/database/class.tx_install_module_database.php b/typo3/sysext/install/modules/database/class.tx_install_module_database.php index caceec205af3..1910231c09c9 100755 --- a/typo3/sysext/install/modules/database/class.tx_install_module_database.php +++ b/typo3/sysext/install/modules/database/class.tx_install_module_database.php @@ -269,7 +269,7 @@ class tx_install_module_database extends tx_install_module_base { return false; } } else { - // database coul not be selected + // database could not be selected return false; } @@ -377,13 +377,27 @@ class tx_install_module_database extends tx_install_module_base { $t3lib_install = t3lib_div::makeInstance('t3lib_install'); $statements = $t3lib_install->getStatementArray($tblFileContent, 1); - list($statements_table, $insertCount) = $t3lib_install->getCreateTables($statements, 1); + // list($statements_table, $insertCount) = $t3lib_install->getCreateTables($statements, 1); // create tables and count them $createCount = 0; - foreach ($statements as $tableName => $query) { + $error = false; + $resultItems = array(); + foreach ($statements as $queryIndex => $query) { + + eregi('^create[[:space:]]*table[[:space:]]*[`]?([[:alnum:]_]*)[`]?',substr($query,0,100),$reg); + $tableName = trim($reg[1]); + $res = $GLOBALS['TYPO3_DB']->admin_query($query); - $createCount++; + if (!$res) { + if (!array_key_exists($tableName, $resultItems)) { + $error = true; + $resultItems[$tableName] = array ('status' => 'warning', 'type' => 'plain', 'value' => sprintf($this->get_LL('msg_database_warning_tablecreatefailed'), $tableName, $GLOBALS['TYPO3_DB']->sql_error(), $query)); + } + } else { + $resultItems[$tableName] = array ('status' => 'ok', 'type' => 'plain', 'value' => sprintf($this->get_LL('label_tablecreated'), $tableName)); + $createCount++; + } } // Make a database comparison because some tables that are defined twice have not been created at this point. This applies to the "pages.*" fields defined in sysext/cms/ext_tables.sql for example. @@ -395,10 +409,19 @@ class tx_install_module_database extends tx_install_module_base { if (is_array($update_statements['add'])) { foreach ($update_statements['add'] as $statement) { $res = $GLOBALS['TYPO3_DB']->admin_query($statement); + if (!$res) { + $this->addError($this->get_LL('msg_database_warning_failedstatement').$statement); + $error = true; + } } } - return true; + $this->pObj->getViewObject()->addMessage($this->pObj->getViewObject()->render(array( + array('type' => 'plain', 'value' => $this->pObj->getViewObject()->renderTag('strong', ($error) ? $this->get_LL('msg_database_warning_failedstatements') : $this->get_LL('msg_database_tablescreated'))), + array('type' => 'list', 'value' => $resultItems))) + ); + + return ($error) ? false : true; } /** @@ -486,7 +509,9 @@ class tx_install_module_database extends tx_install_module_base { ); $GLOBALS['TYPO3_DB']->exec_INSERTquery('be_users', $insertFields); - + + $this->pObj->getViewObject()->addMessage(sprintf($this->get_LL('msg_database_admincreated'), strtolower($this->env['createadmin_username']))); + return true; } diff --git a/typo3/sysext/install/modules/database/locallang.xml b/typo3/sysext/install/modules/database/locallang.xml index a7251ce21ab6..17a031ea07aa 100755 --- a/typo3/sysext/install/modules/database/locallang.xml +++ b/typo3/sysext/install/modules/database/locallang.xml @@ -16,6 +16,7 @@ + @@ -38,6 +39,7 @@ + @@ -51,11 +53,16 @@ + + + + + \ No newline at end of file diff --git a/typo3/sysext/install/modules/installer/class.tx_install_module_installer.php b/typo3/sysext/install/modules/installer/class.tx_install_module_installer.php index 22e819464cba..627c85d4cc9a 100644 --- a/typo3/sysext/install/modules/installer/class.tx_install_module_installer.php +++ b/typo3/sysext/install/modules/installer/class.tx_install_module_installer.php @@ -171,7 +171,7 @@ class tx_install_module_installer extends tx_install_module_base { 'hidden' => array ( 'step' => $this->step-1, 'mode' => '123', - 'state' => 'post' + 'state' => 'pre' ), ) ); @@ -188,7 +188,8 @@ class tx_install_module_installer extends tx_install_module_base { '###MSG_TITLE###' => $this->get_LL('msg_step'.$this->step.'_title'), '###MSG_DESCRIPTION###' => $this->get_LL('msg_step'.$this->step.'_description'), '###BTN_BACK###' => $btnBack, - '###CONTENT###' => $stepResult + '###CONTENT###' => $stepResult, + '###PREV_RESULT###' => $this->pObj->getViewObject()->getLastMessage(true) ); if (count($this->pObj->getViewObject()->getErrors('general')) > 0) { @@ -221,7 +222,7 @@ class tx_install_module_installer extends tx_install_module_base { return false; } - // process pre state + // process pre state - result is true if this state is not configured if (isset($this->stepConfig[$this->step]['pre'])) { $preResult = $this->executeStepState('pre'); } else { @@ -231,7 +232,7 @@ class tx_install_module_installer extends tx_install_module_base { // exit if pre checks are not sucessfull if ($preResult === false) { // depending on preMode we only skip state main or stop here immediately - if (!isset($this->stepConfig[$this->step]['preMode']) &&Ê(!strcmp($this->stepConfig[$this->step]['preMode'], 'skipMain'))) { + if (!isset($this->stepConfig[$this->step]['preMode']) &&Ê($this->stepConfig[$this->step]['preMode'] != 'skipMain')) { return false; } else { $this->env['state'] = 'post'; @@ -243,7 +244,7 @@ class tx_install_module_installer extends tx_install_module_base { if ($this->env['state'] == 'post') { // execute process methods (has to be configured) $processResult = $this->executeStepState('post'); - $this->env['state'] = NULL; + $this->env['state'] = 'pre'; // go to next step if process was ok if ($processResult === true) { @@ -254,7 +255,7 @@ class tx_install_module_installer extends tx_install_module_base { // execute main state (has to be configured!) $mainResult = $this->executeStepState('main'); - + if ($mainResult === false) { return false; } @@ -355,6 +356,13 @@ class tx_install_module_installer extends tx_install_module_base { return $stateResult; } + /** + * Receives a state config and executs the respective method and returns the result + * + * @param mixed $stateMethod: The method to call and the optional the type. + * @param array $formElements: An array that collects the form elements for the step (PASS BY REFERENCE) + * @return False if somethign went wrong, otherwise the result of the called method + */ private function dispatchStateMethod($stateMethod, &$formElements) { $result = true; if ($stateMethod['type'] == 'label') { diff --git a/typo3/sysext/install/modules/installer/locallang.xml b/typo3/sysext/install/modules/installer/locallang.xml index 946a6db79e64..ba832ab9c377 100644 --- a/typo3/sysext/install/modules/installer/locallang.xml +++ b/typo3/sysext/install/modules/installer/locallang.xml @@ -12,6 +12,9 @@ + + + diff --git a/typo3/sysext/install/modules/installer/res/tpl_step.html b/typo3/sysext/install/modules/installer/res/tpl_step.html index feb860b87711..0e684d5f4c29 100644 --- a/typo3/sysext/install/modules/installer/res/tpl_step.html +++ b/typo3/sysext/install/modules/installer/res/tpl_step.html @@ -86,6 +86,7 @@ h3 {

###STEP###

+ ###PREV_RESULT###

###MSG_TITLE###

###MSG_DESCRIPTION###
-- 2.20.1