* Installer: Improved the installer module.
authorThomas Hempel <thomas.hempel@typo3.org>
Wed, 23 Jan 2008 21:04:25 +0000 (21:04 +0000)
committerThomas Hempel <thomas.hempel@typo3.org>
Wed, 23 Jan 2008 21:04:25 +0000 (21:04 +0000)
- 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
typo3/sysext/install/mod/class.tx_install_view.php
typo3/sysext/install/modules/database/class.tx_install_module_database.php
typo3/sysext/install/modules/database/locallang.xml
typo3/sysext/install/modules/installer/class.tx_install_module_installer.php
typo3/sysext/install/modules/installer/locallang.xml
typo3/sysext/install/modules/installer/res/tpl_step.html

index b1d0f50..a5f0220 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,10 @@
 2008-01-23     Thomas Hempel  <thomas@typo3-unleashed.net>
 
        * 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
 
index 713ec5d..9505283 100644 (file)
@@ -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 .= '<li'.$style.'>'.$this->render($singleElement).'</li>';
+                               $content .= $this->renderTag('li', $this->render($singleElement), array('style' => $style));
                        }
                        
-                       $content = '<ul>'.$content.'</ul>';
+                       $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 .= '<br />'.$message;
        }
        
        /**
@@ -996,7 +996,7 @@ class tx_install_view {
                if ($clear)     {
                        $this->clearLastMessage();
                }
-               return $result;
+               return empty($result) ? false : $result;
        }
        
        /**
index caceec2..1910231 100755 (executable)
@@ -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;
        }
        
index a7251ce..17a031e 100755 (executable)
@@ -16,6 +16,7 @@
                        <label index="title_typo_db_username">Database username</label>
                        <label index="title_typo_db_password">Database password</label>
                        <label index="title_typo_db">TYPO3 database</label>
+                       <label index="title_typo_db_new">New Database</label>
 
                        <label index="title_analyze_compareFile">Compare against default database</label>
                        <label index="title_analyze_staticTables">Reload static tables</label>
@@ -38,6 +39,7 @@
                        <label index="label_line">Line</label>
                        <label index="label_selectall">Select all</label>
                        <label index="label_deselectall">Deselect all</label>
+                       <label index="label_tablecreated">The table "%s" where created successfully</label>
 
                        <label index="msg_database_error_cantconnect">Can't connect to database-server!</label>
                        <label index="msg_database_error_cantselectdb">Can't select database "%s"</label>
                        <label index="msg_database_warning_selectdb">Please select a database or fill in a name for a new database.</label>
                        <label index="msg_database_warning_invalidname">The NEW database name "%s" was not alphanumeric, a-zA-Z0-9_-</label>
                        <label index="msg_database_warning_failedstatements">Some statements failed to execute due to SQL errors. They are detailed below.</label>
+                       <label index="msg_database_warning_failedstatement">The following statement could not be executed: </label>
+                       <label index="msg_database_warning_tablecreatefailed">The table "%s" could not be create&lt;br /&gt;Message: %s&lt;br /&gt;Query: %s</label>
                        
                        <label index="msg_database_updateneeded">Table and field definitions should be updated!&lt;br /&gt; There seems to be a number of differences between the database and the selected SQL-file. Please select which statements you want to execute in order to update your database:</label>
                        <label index="msg_database_noupdateneeded">Table and field definitions are OK.&lt;br /&gt;The tables and fields in the current database correspond perfectly to the database in the selected SQL-file.</label>
                        <label index="msg_database_reloadstaticdata">Check in the form below for which static table you want to load or reload the data. Be careful if the table already exists: it will be dropped before the data is loaded, so any changes will be lost.</label>
                        <label index="msg_database_staticdatareloaded">Table "%s" was (re)created successfully and %d rows of data were loaded.</label>
+                       <label index="msg_database_tablescreated">All tables where created successfully. See a list of created tables below.</label>
+                       <label index="msg_database_admincreated">An admin user with username "%s" was created successfully.</label>
+
                </languageKey>
        </data>
 </T3locallang>
\ No newline at end of file
index 22e8194..627c85d 100644 (file)
@@ -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') {
index 946a6db..ba832ab 100644 (file)
@@ -12,6 +12,9 @@
                        <label index="msg_step1_title">Database connection</label>
                        <label index="msg_step1_description">Please enter the information for connecting to your prefered database.</label>
 
+                       <label index="msg_step2_title">Select /create database</label>
+                       <label index="msg_step2_description">Please select an existing database from the dropdown box or enter a name in the input field to create a new database.</label>
+
                        <label index="msg_step4_title">Create admin user</label>
                        <label index="msg_step4_description">Your database is set up sucessfully. Now we have to create an admin account for logging into the backend.</label>
 
index feb860b..0e684d5 100644 (file)
@@ -86,6 +86,7 @@ h3    {
        <body>
                <div id="outer-block">
                        <h1>###STEP###</h1>
+                       ###PREV_RESULT###
                        <h2>###MSG_TITLE###</h2>
                        <div class="description">###MSG_DESCRIPTION###</div>