Fixed bug #14005: Moving a page with IRRE records misplaces IRRE records
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_install.php
index 685cefb..933f9bc 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2010 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -71,7 +71,6 @@
 
 
 
-require_once(PATH_t3lib.'class.t3lib_sqlparser.php');
 
 /**
  * Class to setup values in localconf.php and verify the TYPO3 DB tables/fields
@@ -141,6 +140,9 @@ class t3lib_install {
                $tokenSet = ($this->localconf_editPointToken && !$inArray);             // Flag is set if the token should be set but is not yet...
                $stopAtToken = ($this->localconf_editPointToken && $inArray);
                $comment = ' Modified or inserted by '.$this->updateIdentity.'.';
+               $replace = array('["', '"]');
+               $search = array('[\'', '\']');
+               $varDoubleQuotes = str_replace($search, $replace, $variable);
 
                        // Search for variable name:
                if (!$this->localconf_addLinesOnly && !$tokenSet)       {
@@ -157,7 +159,21 @@ class t3lib_install {
                                                $found = 1;
                                                break;
                                        }
-                               }
+                               } elseif (!strcmp(substr($v2, 0, strlen($varDoubleQuotes . ' ')), $varDoubleQuotes . ' ')) {
+                                               // Due to a bug in the update wizard (fixed in TYPO3 4.1.7) it is possible
+                                               // that $TYPO3_CONF_VARS['SYS']['compat_version'] was enclosed by "" (double
+                                               // quotes) instead of the expected '' (single quotes) when is was written to
+                                               // localconf.php. The following code was added to make sure that values with
+                                               // double quotes are updated, too.
+                                       $mainparts = explode($varDoubleQuotes, $v, 2);
+                                       if (count($mainparts) == 2) { // should ALWAYS be....
+                                               $subparts = explode('//', $mainparts[1], 2);
+                                               $line_array[$k] = $mainparts[0] . $variable . " = '" . $this->slashValueForSingleDashes($value) . "';   " . ('//' . $comment . str_replace($comment, '', $subparts[1]));
+                                               $this->touchedLine = count($line_array) - $k - 1;
+                                               $found = 1;
+                                               break;
+                                       }
+                               }
                        }
                        $line_array = array_reverse($line_array);
                }
@@ -169,7 +185,11 @@ class t3lib_install {
                        $line_array[] = $variable." = '".$this->slashValueForSingleDashes($value)."';   // ".$comment;
                        $this->touchedLine = -1;
                }
-               $this->messages[] = $variable." = '".htmlspecialchars($value)."'";
+               if ($variable == '$typo_db_password') {
+                       $this->messages[] = 'Updated ' . $variable;
+               } else {
+                       $this->messages[] = $variable . " = '" . htmlspecialchars($value) . "'";
+               }
                $this->setLocalconf = 1;
        }
 
@@ -183,6 +203,7 @@ class t3lib_install {
         */
        function writeToLocalconf_control($inlines='',$absFullPath='')  {
                $tmpExt = '.TMP.php';
+               $writeToLocalconf_dat = array();
                $writeToLocalconf_dat['file'] = $absFullPath ? $absFullPath : PATH_typo3conf.'localconf.php';
                $writeToLocalconf_dat['tmpfile'] = $writeToLocalconf_dat['file'].$tmpExt;
 
@@ -303,8 +324,8 @@ class t3lib_install {
                        }
 
                        if (!strlen($table)) {
-                               $parts = explode(' ',$value);
-                               if ($parts[0]=='CREATE' && $parts[1]=='TABLE')  {
+                               $parts = t3lib_div::trimExplode(' ', $value, TRUE);
+                               if (strtoupper($parts[0]) === 'CREATE' && strtoupper($parts[1]) === 'TABLE') {
                                        $table = str_replace( '`', '', $parts[2]);
                                        if (TYPO3_OS=='WIN') {  // tablenames are always lowercase on windows!
                                                $table = strtolower($table);
@@ -939,6 +960,17 @@ class t3lib_install {
        function generateUpdateDatabaseForm_checkboxes($arr,$label,$checked=1,$iconDis=0,$currentValue=array(),$cVfullMsg=0)    {
                $out = array();
                if (is_array($arr))     {
+                       $tableId = uniqid('table');
+                       if (count($arr) > 1) {
+                               $out[] = '
+                                       <tr class="update-db-fields-batch">
+                                               <td valign="top">
+                                                       <input type="checkbox" id="' . $tableId . '-checkbox"' . ($checked ? ' checked="checked"' : '') . '
+                                                        onclick="$(\'' . $tableId . '\').select(\'input[type=checkbox]\').invoke(\'setValue\', $(this).checked);" />
+                                               </td>
+                                               <td nowrap="nowrap"><label for="' . $tableId . '-checkbox" style="cursor:pointer"><strong>select/deselect all</strong></label></td>
+                                       </tr>';
+                       }
                        foreach($arr as $key => $string)        {
                                $ico = '';
                                $warnings = array();
@@ -964,7 +996,7 @@ class t3lib_install {
                                        $out[]='
                                        <tr>
                                                <td valign="top"></td>
-                                               <td nowrap="nowrap" style="color : #666666;">'.nl2br((!$cVfullMsg?"Current value: ":"").'<em>'.$currentValue[$key].'</em>').'</td>
+                                               <td nowrap="nowrap" style="color:#666666;">'.nl2br((!$cVfullMsg?"Current value: ":"").'<em>'.$currentValue[$key].'</em>').'</td>
                                        </tr>';
                                }
                        }
@@ -972,7 +1004,7 @@ class t3lib_install {
                                $out[] = '
                                        <tr>
                                                <td valign="top"></td>
-                                               <td style="color : #666666;"><em>' . implode('<br />',$warnings) . '</em></td>
+                                               <td style="color:#666666;"><em>' . implode('<br />',$warnings) . '</em></td>
                                        </tr>';
                        }
 
@@ -980,7 +1012,7 @@ class t3lib_install {
                        $content = '
                                <!-- Update database fields / tables -->
                                <h3>'.$label.'</h3>
-                               <table border="0" cellpadding="2" cellspacing="2" class="update-db-fields">'.implode('',$out).'
+                               <table border="0" cellpadding="2" cellspacing="2" id="' . $tableId . '" class="update-db-fields">' . implode('', $out) . '
                                </table>';
                }
 
@@ -992,9 +1024,11 @@ class t3lib_install {
         *
         * @param       string          Should be a string read from an SQL-file made with 'mysqldump [database_name] -d'
         * @return      array           Array with information about table.
-        * @deprecated  since TYPO3 4.2 Use ->getFieldDefinitions_fileContent() instead!
+        * @deprecated  since TYPO3 4.2, this function will be removed in TYPO3 4.5, use ->getFieldDefinitions_fileContent() instead!
         */
        function getFieldDefinitions_sqlContent($fileContent)   {
+               t3lib_div::logDeprecatedFunction();
+
                return $this->getFieldDefinitions_fileContent($fileContent);
        }
 }