#7148 - CSV Export Improvements in List Module
authorBenni Mack <benni.mack@typo3.org>
Tue, 15 Jan 2008 14:18:13 +0000 (14:18 +0000)
committerBenni Mack <benni.mack@typo3.org>
Tue, 15 Jan 2008 14:18:13 +0000 (14:18 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2897 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/class.db_list_extra.inc

index 107149b..638357d 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
-2008-01-14  Ingo Renner  <ingo@typo3.org>
+2008-01-15  Benjamin Mack  <mack@xnos.org>
+
+       * (bugfix) Fixed #7148 - CSV Export Improvements in List Module
+
+2008-01-15  Ingo Renner  <ingo@typo3.org>
 
        * added feature #5536: Some Hooks for tslib_content
 
index 7c2a7fe..68c87a9 100755 (executable)
@@ -406,6 +406,9 @@ class localRecordList extends recordList {
                }
 
                        // Create the SQL query for selecting the elements in the listing:
+               if ($this->csvOutput) { // do not do paging when outputting as CSV
+                       $this->iLimit = 0;
+               }
                $queryParts = $this->makeQueryArray($table, $id,$addWhere,$selFieldList);       // (API function from class.db_list.inc)
                $this->setTotalItems($queryParts);              // Finding the total amount of records on the page (API function from class.db_list.inc)
 
@@ -415,6 +418,11 @@ class localRecordList extends recordList {
 
                        // If the count query returned any number of records, we perform the real query, selecting records.
                if ($this->totalItems)  {
+                               // set the showLimit to the number of records when outputting as CSV
+                       if ($this->csvOutput) {
+                               $this->showLimit = $this->totalItems;
+                               $this->iLimit = $this->totalItems;
+                       }
                        $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
                        $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
                }
@@ -643,7 +651,9 @@ class localRecordList extends recordList {
                                } elseif ($fCol=='_LOCALIZATION_b') {
                                        // Do nothing, has been done above.
                                } else {
-                                       $theData[$fCol] = $this->linkUrlMail(htmlspecialchars(t3lib_BEfunc::getProcessedValueExtra($table,$fCol,$row[$fCol],100,$row['uid'])),$row[$fCol]);
+                                       $tmpProc = t3lib_BEfunc::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid']);
+                                       $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
+                                       $row[$fCol] = $tmpProc;
                                }
                        }
 
@@ -652,7 +662,9 @@ class localRecordList extends recordList {
                        }
 
                                // Add row to CSV list:
-                       if ($this->csvOutput) $this->addToCSV($row,$table);
+                       if ($this->csvOutput) {
+                               $this->addToCSV($row,$table);
+                       }
 
                                // Create element in table cells:
                        $iOut.=$this->addelement(1,$theIcon,$theData,$row_bgColor);
@@ -1426,16 +1438,20 @@ class localRecordList extends recordList {
                $this->csvLines=array();
 
                        // Getting header line with field names:
-               $csvRow=array();
-               foreach($this->fieldArray as $fN)       {
-                       $csvRow[]=$fN;
+               $csvRow = array();
+               foreach ($this->fieldArray as $fN) {
+                       if ($fN == '_CONTROL_' || $fn == '_CLIPBOARD_') {
+                                       continue;
+                       }
+                       $csvRow[] = $fN;
                }
 
                        // Set the header + an empty row:
                $this->setCsvRow($csvRow);
-               $this->csvLines[]='';
+               $this->csvLines[] = '';
        }
 
+
        /**
         * Adds the content of input array $row to the CSV list:
         *
@@ -1446,14 +1462,25 @@ class localRecordList extends recordList {
        function addToCSV($row,$table)  {
 
                        // Traversing fields, adding values from $row:
-               $csvRow=array();
-               foreach($this->fieldArray as $fN)       {
-                       if ($fN=='_PATH_')      {
-                               $csvRow[]=$this->recPath($row['pid']);
-                       } elseif ($fN=='_REF_') {
-                               $csvRow[]=$this->makeRef($table, $row['uid']);
-                       } else {
-                               $csvRow[]=$row[$fN];
+               $csvRow = array();
+               foreach ($this->fieldArray as $fN) {
+                       switch ($fN) {
+                               case '_PATH':
+                                       $csvRow[] = $this->recPath($row['pid']);
+                                       break;
+
+                               case '_REF_':
+                                       $csvRow[] = $this->makeRef($table, $row['uid']);
+                                       break;
+
+                                       // remove these columns from the CSV view
+                               case '_CONTROL_':
+                               case '_CLIPBOARD_':
+                                       continue;
+                                       break;
+
+                               default:
+                                       $csvRow[] = $row[$fN];
                        }
                }
 
@@ -1461,6 +1488,7 @@ class localRecordList extends recordList {
                $this->setCsvRow($csvRow);
        }
 
+
        /**
         * Adds input row of values to the internal csvLines array as a CSV formatted line
         *