Follow-up to bugfix #2314: Using the clipboard in the list view shows SQL errors...
authorOliver Hader <oliver.hader@typo3.org>
Wed, 21 Oct 2009 17:32:24 +0000 (17:32 +0000)
committerOliver Hader <oliver.hader@typo3.org>
Wed, 21 Oct 2009 17:32:24 +0000 (17:32 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@6222 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_clipboard.php

index f23481b..5d2d4bb 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,7 @@
        * Cleanup: Updated ext_emconf.php files in system extensions
        * Follow-up to bugfix #539: Tables that cannot be localized at all produce a SQL error on deleting records
        * Cleanup: Fixed non-static function declarations in t3lib_BEfunc
        * Cleanup: Updated ext_emconf.php files in system extensions
        * Follow-up to bugfix #539: Tables that cannot be localized at all produce a SQL error on deleting records
        * Cleanup: Fixed non-static function declarations in t3lib_BEfunc
+       * Follow-up to bugfix #2314: Using the clipboard in the list view shows SQL errors for tables without versioning support
 
 2009-10-21  Steffen Kamper  <info@sk-typo3.de>
 
 
 2009-10-21  Steffen Kamper  <info@sk-typo3.de>
 
index 21545b6..b82a1c0 100644 (file)
@@ -467,7 +467,10 @@ class t3lib_clipboard {
                                                                        '</td>
                                                                </tr>';
 
                                                                        '</td>
                                                                </tr>';
 
-                                                       $lines[] = $this->getLocalisations($table, $rec, $bgColClass, $pad);
+                                                       $localizationData = $this->getLocalizations($table, $rec, $bgColClass, $pad);
+                                                       if ($localizationData) {
+                                                               $lines[] = $localizationData;
+                                                       }
 
                                                } else {
                                                        unset($this->clipData[$pad]['el'][$k]);
 
                                                } else {
                                                        unset($this->clipData[$pad]['el'][$k]);
@@ -491,42 +494,49 @@ class t3lib_clipboard {
 
 
        /**
 
 
        /**
-        * returns all localisations of the current record
+        * Gets all localizations of the current record.
         *
         * @param       string          the table
         * @param       array           the current record
         * @return      string          HTML table rows
         */
         *
         * @param       string          the table
         * @param       array           the current record
         * @return      string          HTML table rows
         */
-       function getLocalisations($table, $parentRec, $bgColClass, $pad) {
-
+       function getLocalizations($table, $parentRec, $bgColClass, $pad) {
                $lines = array();
                $lines = array();
-               if ($table != 'pages' &&
-                               $GLOBALS['TCA'][$table]['ctrl']['languageField'] &&
-                               $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']
-                               && !$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable']) {
-                       $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                               '*',
-                               $table,
-                               $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . '=' . intval($parentRec['uid']) .
-                                       ' AND ' . $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '!=0' .
-                                       ' AND ' . $GLOBALS['TCA'][$table]['ctrl']['delete'] . '=0' .
-                                       ' AND t3ver_wsid=' . $parentRec['t3ver_wsid']
-                       );
+               $tcaCtrl = $GLOBALS['TCA'][$table]['ctrl'];
 
 
-                       foreach ($rows as $rec) {
-                               $lines[]='
-                               <tr>
-                                       <td class="' . $bgColClass . '">' .
-                                               t3lib_iconWorks::getIconImage($table, $rec, $this->backPath,' style="margin-left: 38px;"') . '</td>
-                                       <td class="' . $bgColClass . '" nowrap="nowrap" width="95%">&nbsp;' . htmlspecialchars(
-                                                       t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table, $rec), $GLOBALS['BE_USER']->uc['titleLen'])) .
-                                                       ($pad == 'normal' ? (
-                                                               ' <strong>(' . ($this->clipData['normal']['mode'] == 'copy' ? $this->clLabel('copy', 'cm') :
-                                                               $this->clLabel('cut','cm')).')</strong>') :
-                                                               ''
-                                                       ) . '&nbsp;</td>
-                                       <td class="' . $bgColClass . '" align="center" nowrap="nowrap">&nbsp;</td>
-                               </tr>';
+               if ($table != 'pages' && t3lib_BEfunc::isTableLocalizable($table) && !$tcaCtrl['transOrigPointerTable']) {
+                       $where = array();
+                       $where[] = $tcaCtrl['transOrigPointerField'] . '=' . intval($parentRec['uid']);
+                       $where[] = $tcaCtrl['languageField'] . '!=0';
+
+                       if (isset($tcaCtrl['delete']) && $tcaCtrl['delete']) {
+                               $where[] = $tcaCtrl['delete'] . '=0';
+                       }
+
+                       if (isset($tcaCtrl['versioningWS']) && $tcaCtrl['versioningWS']) {
+                               $where[] = 't3ver_wsid=' . $parentRec['t3ver_wsid'];
+                       }
+
+                       $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $table, implode(' AND ', $where));
+
+                       if (is_array($rows)) {
+                               $modeData = '';
+                               if ($pad == 'normal') {
+                                       $mode = ($this->clipData['normal']['mode'] == 'copy' ? 'copy' : 'cut');
+                                       $modeData = ' <strong>(' . $this->clLabel($mode, 'cm') . ')</strong>';
+                               }
+
+                               foreach ($rows as $rec) {
+                                       $lines[]='
+                                       <tr>
+                                               <td class="' . $bgColClass . '">' .
+                                                       t3lib_iconWorks::getIconImage($table, $rec, $this->backPath,' style="margin-left: 38px;"') . '</td>
+                                               <td class="' . $bgColClass . '" nowrap="nowrap" width="95%">&nbsp;' . htmlspecialchars(
+                                                               t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table, $rec), $GLOBALS['BE_USER']->uc['titleLen'])) .
+                                                               $modeData . '&nbsp;</td>
+                                               <td class="' . $bgColClass . '" align="center" nowrap="nowrap">&nbsp;</td>
+                                       </tr>';
+                               }
                        }
                }
                return implode('',$lines);
                        }
                }
                return implode('',$lines);