Fixed bug #9758: Write Configuration to extTables.php
authorSteffen Kamper <info@sk-typo3.de>
Fri, 30 Apr 2010 16:13:26 +0000 (16:13 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Fri, 30 Apr 2010 16:13:26 +0000 (16:13 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@7462 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/lowlevel/config/index.php
typo3/sysext/lowlevel/config/locallang.xml

index c5ca1da..1160175 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,7 @@
 
 2010-04-30  Steffen Kamper  <info@sk-typo3.de>
 
+       * Fixed bug #9758: Write Configuration to extTables.php
        * Fixed bug #14212: Better styling of BE login news (thanks to Georg Ringer)
        * Fixed bug #14116: Selecting/deselecting all records does not work with translated records (thanks to Reinhard F├╝hricht)
 
index a563584..2630b77 100755 (executable)
@@ -253,12 +253,47 @@ class SC_mod_tools_config_index {
 
                        // Variable name:
                if (t3lib_div::_GP('varname'))  {
+                       $line = t3lib_div::_GP('_') ? t3lib_div::_GP('_') : t3lib_div::_GP('varname');
+                       if (t3lib_div::_GP('writetoexttables')) { // Write the line to extTables.php
+                                       // change value to $GLOBALS
+                               $length = strpos($line, '[');
+                               $var = substr($line, 0, $length);
+                               $changedLine = '$GLOBALS[\'' . substr($line, 1, $length - 1) . '\']' . substr($line, $length);
+                                       // insert line  in extTables.php
+                               $extTables = t3lib_div::getURL(PATH_typo3conf . TYPO3_extTableDef_script);
+                               $extTables = '<?php' . preg_replace('/<\?php|\?>/is', '', $extTables) . $changedLine . LF . '?>';
+                               $success = t3lib_div::writeFile(PATH_typo3conf . TYPO3_extTableDef_script, $extTables);
+                               if ($success) {
+                                               // show flash message
+                                       $flashMessage = t3lib_div::makeInstance(
+                                               't3lib_FlashMessage',
+                                               '',
+                                               sprintf($GLOBALS['LANG']->getLL('writeMessage', TRUE), TYPO3_extTableDef_script,  '<br />', '<strong>' . $changedLine . '</strong>'),
+                                               t3lib_FlashMessage::OK
+                                       );
+                               } else {
+                                       // Error: show flash message
+                                       $flashMessage = t3lib_div::makeInstance(
+                                               't3lib_FlashMessage',
+                                               '',
+                                               sprintf($GLOBALS['LANG']->getLL('writeMessageFailed', TRUE), TYPO3_extTableDef_script),
+                                               t3lib_FlashMessage::ERROR
+                                       );
+                               }
+                               $this->content .= $flashMessage->render();
+                       }
                        $this->content .= '<div id="lowlevel-config-var">
-                       <strong>' . $GLOBALS['LANG']->getLL('variable', true) . '</strong><br />
-                               <input type="text" name="_" value="' . trim(htmlspecialchars(t3lib_div::_GP('varname'))) . '" size="120" /><br />
-                               ' . $GLOBALS['LANG']->getLL('copyPaste', true) . '
-                       </div>
-                       ';
+                               <strong>' . $GLOBALS['LANG']->getLL('variable', TRUE) . '</strong><br />
+                               <input type="text" name="_" value="'.trim(htmlspecialchars($line)).'" size="120" /><br/>';
+
+                       if (TYPO3_extTableDef_script !== '' && ($this->MOD_SETTINGS['function'] === '1' || $this->MOD_SETTINGS['function'] === '4')) {
+                                       // write only for $TCA and TBE_STYLES if  TYPO3_extTableDef_script is defined
+                               $this->content .= '<br /><input type="submit" name="writetoexttables" value="' .
+                                       $GLOBALS['LANG']->getLL('writeValue', TRUE) . '" /></div>';
+                       } else {
+                               $this->content .= $GLOBALS['LANG']->getLL('copyPaste', TRUE) . LF . '</div>';
+                       }
+
                }
 
                $this->content.= '<br /><table border="0" cellpadding="1" cellspacing="0">';
index 74f7a26..8906740 100644 (file)
@@ -23,6 +23,9 @@
                        <label index="enterSearchPhrase">Enter search phrase:</label>
                        <label index="search">Search</label>
                        <label index="useRegExp">Use regular expression</label>
+                       <label index="writeValue">Write value to configuration file</label>
+                       <label index="writeMessage">Following line was added to configuration file (%s): %s%s</label>
+                       <label index="writeMessageFailed">Write to configuration file failed (%s)!</label>
                </languageKey>
        </data>
 </T3locallang>