Implemented versioning API, phase 1 (tcemain). See changelog
[Packages/TYPO3.CMS.git] / typo3 / class.db_list_extra.inc
index ab132cb..dfa1f49 100755 (executable)
@@ -1,22 +1,22 @@
 <?php
 /***************************************************************
 *  Copyright notice
-*  
-*  (c) 1999-2003 Kasper Skaarhoj (kasper@typo3.com)
+*
+*  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
 *  All rights reserved
 *
-*  This script is part of the TYPO3 project. The TYPO3 project is 
+*  This script is part of the TYPO3 project. The TYPO3 project is
 *  free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
-* 
+*
 *  The GNU General Public License can be found at
 *  http://www.gnu.org/copyleft/gpl.html.
-*  A copy is found in the textfile GPL.txt and important notices to the license 
+*  A copy is found in the textfile GPL.txt and important notices to the license
 *  from the author is found in LICENSE.txt distributed with these scripts.
 *
-* 
+*
 *  This script is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@@ -24,7 +24,7 @@
 *
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/
-/** 
+/**
  * Include file extending recordList which extended t3lib_recordList
  * Used specifically for the Web>List module (db_list.php)
  *
  *
  *
  *
- *   89: class localRecordList extends recordList 
- *  121:     function writeTop($row,$path)     
- *  295:     function getTable($table,$id,$rowlist)    
- *  476:     function renderListRow($table,$row,$cc,$titleCol,$thumbsCol)      
- *  539:     function renderListHeader($table,$currentIdList)  
+ *   89: class localRecordList extends recordList
+ *  121:     function writeTop($row,$path)
+ *  295:     function getTable($table,$id,$rowlist)
+ *  476:     function renderListRow($table,$row,$cc,$titleCol,$thumbsCol)
+ *  539:     function renderListHeader($table,$currentIdList)
  *
  *              SECTION: Rendering of various elements
- *  673:     function makeControl($table,$row) 
- *  847:     function makeClip($table,$row)    
- *  916:     function fieldSelectBox($table,$formFields=1)     
+ *  678:     function makeControl($table,$row)
+ *  852:     function makeClip($table,$row)
+ *  921:     function fieldSelectBox($table,$formFields=1)
  *
  *              SECTION: Helper functions
- *  995:     function linkClipboardHeaderIcon($string,$table,$cmd,$warning='') 
- * 1006:     function clipNumPane()    
- * 1020:     function addSortLink($code,$field,$table) 
- * 1045:     function recPath($pid)    
- * 1058:     function showNewRecLink($table)   
- * 1068:     function makeReturnUrl()  
+ * 1000:     function linkClipboardHeaderIcon($string,$table,$cmd,$warning='')
+ * 1011:     function clipNumPane()
+ * 1025:     function addSortLink($code,$field,$table)
+ * 1050:     function recPath($pid)
+ * 1063:     function showNewRecLink($table)
+ * 1073:     function makeReturnUrl()
  *
  *              SECTION: CSV related functions
- * 1092:     function initCSV()        
- * 1114:     function addToCSV($row)   
- * 1136:     function setCsvRow($csvRow)       
- * 1147:     function outputCSV($prefix)       
+ * 1097:     function initCSV()
+ * 1119:     function addToCSV($row)
+ * 1141:     function setCsvRow($csvRow)
+ * 1152:     function outputCSV($prefix)
  *
  * TOTAL FUNCTIONS: 17
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
 
+
+
+
+
+
+
+
 
 
 
 /**
  * Class for rendering of Web>List module
- * 
+ *
  * @author     Kasper Skaarhoj <kasper@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
 class localRecordList extends recordList {
-       
+
                // External:
        var $alternateBgColors=FALSE;                   // If true, table rows in the list will alternate in background colors (and have background colors at all!)
        var $allowedNewTables=array();                  // Used to indicate which tables (values in the array) that can have a create-new-record link. If the array is empty, all tables are allowed.
@@ -113,36 +113,35 @@ class localRecordList extends recordList {
 
        /**
         * Writes the top of the full listing
-        * 
+        *
         * @param       array           Current page record
-        * @param       string          Path string (the page root line visually...)
         * @return      void            (Adds content to internal variable, $this->HTMLcode)
         */
-       function writeTop($row,$path)   {
+       function writeTop($row) {
                global $LANG;
-               
+
                        // Makes the code for the pageicon in the top
-               $this->pageRow=$row;
+               $this->pageRow = $row;
                $this->counter++;
                $alttext = t3lib_BEfunc::getRecordIconAltText($row,'pages');
                $iconImg = t3lib_iconWorks::getIconImage('pages',$row,$this->backPath,'title="'.htmlspecialchars($alttext).'"');
-               $titleCol='test';       // pseudo title column name
+               $titleCol = 'test';     // pseudo title column name
                $this->fieldArray = Array($titleCol,'up');              // Setting the fields to display in the list (this is of course "pseudo fields" since this is the top!)
-               
-               
+
+
                        // Filling in the pseudo data array:
                $theData = Array();
                $theData[$titleCol] = $this->widthGif;
 
                        // Get users permissions for this row:
                $localCalcPerms = $GLOBALS['BE_USER']->calcPerms($row);
-               
+
                $theData['up']=array();
 
                        // Initialize control panel for currect page ($this->id):
                        // Some of the controls are added only if $this->id is set - since they make sense only on a real page, not root level.
                $theCtrlPanel =array();
-               
+
                        // "View page" icon is added:
                $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($this->id,'',t3lib_BEfunc::BEgetRootLine($this->id))).'">'.
                                                '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom.gif','width="12" height="12"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPage',1).'" alt="" />'.
@@ -158,7 +157,7 @@ class localRecordList extends recordList {
                                                                '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('editPage',1).'" alt="" />'.
                                                                '</a>';
                        }
-                               
+
                                // Adding "New record" icon:
                        if (!$GLOBALS['SOBE']->modTSconfig['properties']['noCreateRecordsLink'])        {
                                $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\'db_new.php?id='.$this->id.'\');').'">'.
@@ -180,7 +179,7 @@ class localRecordList extends recordList {
                                                                        '</a>';
                                }
                        }
-                       
+
                                // Adding "move page" button:
                        if ($this->id)  {
                                $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\'move_el.php?table=pages&uid='.$row['uid'].'\');').'">'.
@@ -188,7 +187,7 @@ class localRecordList extends recordList {
                                                                '</a>';
                        }
                }
-               
+
                        // "Paste into page" link:
                if (($localCalcPerms&8) || ($localCalcPerms&16))        {
                        $elFromTable = $this->clipObj->elFromTable('');
@@ -198,11 +197,11 @@ class localRecordList extends recordList {
                                                                '</a>';
                        }
                }
-               
+
                        // Finally, compile all elements of the control panel into table cells:
                if (count($theCtrlPanel))       {
                        $theData['up'][]='
-                       
+
                                <!--
                                        Control panel for page
                                -->
@@ -213,7 +212,7 @@ class localRecordList extends recordList {
                                        </tr>
                                </table>';
                }
-               
+
 
                        // Add "clear-cache" link:
                $theData['up'][]='<a href="'.htmlspecialchars($this->listURL().'&clear_cache=1').'">'.
@@ -231,13 +230,13 @@ class localRecordList extends recordList {
                $theData['up'][]='<a href="'.htmlspecialchars($this->listURL()).'">'.
                                                '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/refresh_n.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.reload',1).'" alt="" />'.
                                                '</a>';
-                                               
+
 
                        // Add icon with clickmenu, etc:
                if ($this->id)  {       // If there IS a real page...:
-               
+
                                // Setting title of page + the "Go up" link:
-                       $theData[$titleCol].='<br />'.htmlspecialchars(t3lib_div::fixed_lgd_pre($path,$this->fixedL));
+                       $theData[$titleCol].='<br /><span title="'.htmlspecialchars($row['_thePathFull']).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($row['_thePath'],-$this->fixedL)).'</span>';
                        $theData['up'][]='<a href="'.htmlspecialchars($this->listURL($row['pid'])).'">'.
                                                        '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/pages_up.gif','width="18" height="16"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel',1).'" alt="" />'.
                                                        '</a>';
@@ -245,12 +244,12 @@ class localRecordList extends recordList {
                                // Make Icon:
                        $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg,'pages',$this->id);
                } else {        // On root-level of page tree:
-               
+
                                // Setting title of root (sitename):
-                       $theData[$titleCol].='<br />'.htmlspecialchars(t3lib_div::fixed_lgd_pre($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],$this->fixedL));
+                       $theData[$titleCol].='<br />'.htmlspecialchars(t3lib_div::fixed_lgd_cs($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],-$this->fixedL));
 
                                // Make Icon:
-                       $theIcon='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_website.gif','width="18" height="16"').' alt="" />';
+                       $theIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_website.gif','width="18" height="16"').' alt="" />';
                }
 
                        // If there is a returnUrl given, add a back-link:
@@ -259,7 +258,7 @@ class localRecordList extends recordList {
                                                        '<img'.t3lib_iconWorks::skinImg($GLOBALS["BACK_PATH"],'gfx/goback.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.goBack',1).'" alt="" />'.
                                                        '</a>';
                }
-               
+
                        // Finally, the "up" pseudo field is compiled into a table - has been accumulated in an array:
                $theData['up']='
                        <table border="0" cellpadding="0" cellspacing="0">
@@ -268,14 +267,14 @@ class localRecordList extends recordList {
                                        <td>',$theData['up']).'</td>
                                </tr>
                        </table>';
-               
+
                        // ... and the element row is created:
-               $out.=$this->addelement(1,'',$theData,'',$this->leftMargin,$theIcon);
+               $out.=$this->addelement(1,'',$theData,'',$this->leftMargin, $theIcon);
 
                        // ... and wrapped into a table and added to the internal ->HTMLcode variable:
                $this->HTMLcode.='
 
-                       
+
                <!--
                        Page header for db_list:
                -->
@@ -286,7 +285,7 @@ class localRecordList extends recordList {
 
        /**
         * Creates the listing of records from a single table
-        * 
+        *
         * @param       string          Table name
         * @param       integer         Page id
         * @param       string          List of fields to show in the listing. Pseudo fields will be added including the record header.
@@ -322,7 +321,7 @@ class localRecordList extends recordList {
                        unset($tempArray['_CLIPBOARD_']);
                        $this->fieldArray = array_keys($tempArray);
                }
-               
+
                        // Creating the list of fields to include in the SQL query:
                $selectFields = $this->fieldArray;
                $selectFields[] = 'uid';
@@ -344,6 +343,9 @@ class localRecordList extends recordList {
                if ($TCA[$table]['ctrl']['typeicon_column'])    {
                        $selectFields[] = $TCA[$table]['ctrl']['typeicon_column'];
                }
+               if ($TCA[$table]['ctrl']['versioning']) {
+                       $selectFields[] = 't3ver_id';
+               }
                if ($TCA[$table]['ctrl']['label_alt'])  {
                        $selectFields = array_merge($selectFields,t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['label_alt'],1));
                }
@@ -352,32 +354,35 @@ class localRecordList extends recordList {
                $selFieldList = implode(',',$selectFields);             // implode it into a list of fields for the SQL-statement.
 
                        // Create the SQL query for selecting the elements in the listing:
-               $query = $this->makeQuery($table, $id,'',$selFieldList);        // (API function from class.db_list.inc)
-               $this->setTotalItems();         // Finding the total amount of records on the page (API function from class.db_list.inc)
+               $queryParts = $this->makeQueryArray($table, $id,'',$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)
 
                        // Init:
-               $dbCount=0;     
-               $out='';
+               $dbCount = 0;
+               $out = '';
 
-                       // If the count query returned any number of records, we perform the real query, selecting records.             
+                       // If the count query returned any number of records, we perform the real query, selecting records.
                if ($this->totalItems)  {
-                       $result = mysql(TYPO3_db,$query);
-                       if (mysql_error()) {echo mysql_error(); debug($query);}
-                       $dbCount = mysql_num_rows($result);
+                       $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
+                       $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
                }
-                       
+
+               $LOISmode = $this->listOnlyInSingleTableMode && !$this->table;
+
                        // If any records was selected, render the list:
                if ($dbCount)   {
 
                                // Half line is drawn between tables:
-                       $theData = Array();
-                       if (!$this->table && !$rowlist) {
-                               $theData[$titleCol] = '<img src="clear.gif" width="'.($GLOBALS['SOBE']->MOD_SETTINGS['bigControlPanel']?'230':'350').'" height="1" alt="" />';
-                               if (in_array('_CONTROL_',$this->fieldArray))    $theData['_CONTROL_']='';
-                               if (in_array('_CLIPBOARD_',$this->fieldArray))  $theData['_CLIPBOARD_']='';
+                       if (!$LOISmode) {
+                               $theData = Array();
+                               if (!$this->table && !$rowlist) {
+                                       $theData[$titleCol] = '<img src="clear.gif" width="'.($GLOBALS['SOBE']->MOD_SETTINGS['bigControlPanel']?'230':'350').'" height="1" alt="" />';
+                                       if (in_array('_CONTROL_',$this->fieldArray))    $theData['_CONTROL_']='';
+                                       if (in_array('_CLIPBOARD_',$this->fieldArray))  $theData['_CLIPBOARD_']='';
+                               }
+                               $out.=$this->addelement(0,'',$theData,'',$this->leftMargin);
                        }
-                       $out.=$this->addelement(0,'',$theData,'',$this->leftMargin);
-       
+
                                // Header line is drawn
                        $theData = Array();
                        if ($this->disableSingleTableView)      {
@@ -385,85 +390,111 @@ class localRecordList extends recordList {
                        } else {
                                $theData[$titleCol] = $this->linkWrapTable($table,'<span class="c-table">'.$GLOBALS['LANG']->sL($TCA[$table]['ctrl']['title'],1).'</span> ('.$this->totalItems.') <img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/'.($this->table?'minus':'plus').'bullet_list.gif','width="18" height="12"').' hspace="10" class="absmiddle" title="'.$GLOBALS['LANG']->getLL(!$this->table?'expandView':'contractView',1).'" alt="" />');
                        }
-                       $theUpIcon = ($table=='pages'&&$this->id&&isset($this->pageRow['pid'])) ? '<a href="'.htmlspecialchars($this->listURL($this->pageRow['pid'])).'"><img'.t3lib_iconWorks::skinImg('','gfx/i/pages_up.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel',1).'" alt="" /></a>':'';
-                       $out.=$this->addelement(1,$theUpIcon,$theData,' class="c-headLineTable"','');
-       
-                               // Fixing a order table for sortby tables
-                       $this->currentTable=array();
-                       $currentIdList=array();
-                       $doSort = ($TCA[$table]['ctrl']['sortby'] && !$this->sortField);
-
-                       $prevUid=0;
-                       $prevPrevUid=0;
-                       while($row = mysql_fetch_assoc($result))        {
-                               $currentIdList[] = $row['uid'];
-                               if ($doSort)    {
-                                       if ($prevUid)   {
-                                               $this->currentTable['prev'][$row['uid']]=$prevPrevUid;
-                                               $this->currentTable['next'][$prevUid]='-'.$row['uid'];
-                                               $this->currentTable['prevUid'][$row['uid']]=$prevUid;
+
+                               // CSH:
+                       $theData[$titleCol].= t3lib_BEfunc::cshItem($table,'',$this->backPath,'',FALSE,'margin-bottom:0px; white-space: normal;');
+
+                       if ($LOISmode)  {
+                               $out.='
+                                       <tr>
+                                               <td class="c-headLineTable" style="width:95%;">'.$theData[$titleCol].'</td>
+                                       </tr>';
+
+                               if ($GLOBALS['BE_USER']->uc["edit_showFieldHelp"])      {
+                                       $GLOBALS['LANG']->loadSingleTableDescription($table);
+                                       if (isset($GLOBALS['TCA_DESCR'][$table]['columns']['']))        {
+                                               $onClick = 'vHWin=window.open(\'view_help.php?tfID='.$table.'.\',\'viewFieldHelp\',\'height=400,width=600,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;';
+                                               $out.='
+                                       <tr>
+                                               <td class="c-tableDescription">'.t3lib_BEfunc::helpTextIcon($table,'',$this->backPath,TRUE).$GLOBALS['TCA_DESCR'][$table]['columns']['']['description'].'</td>
+                                       </tr>';
                                        }
-                                       $prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
-                                       $prevUid=$row['uid'];
                                }
+                       } else {
+                               $theUpIcon = ($table=='pages'&&$this->id&&isset($this->pageRow['pid'])) ? '<a href="'.htmlspecialchars($this->listURL($this->pageRow['pid'])).'"><img'.t3lib_iconWorks::skinImg('','gfx/i/pages_up.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel',1).'" alt="" /></a>':'';
+                               $out.=$this->addelement(1,$theUpIcon,$theData,' class="c-headLineTable"','');
                        }
-                       mysql_data_seek($result,0);
-       
-                               // CSV initiated
-                       if ($this->csvOutput) $this->initCSV();
-       
-                               // Render items:
-                       $this->CBnames=array();
-                       $this->duplicateStack=array();
-                       $this->eCounter=$this->firstElementNumber;
-                       
-                       $iOut='';
-                       $cc=0;
-                       while ($row = mysql_fetch_assoc($result))       {
-
-                                       // Forward/Backwards navigation links:
-                               list($flag,$code) = $this->fwd_rwd_nav($table);
-                               $iOut.=$code;
-
-                                       // If render item, increment counter and call function
-                               if ($flag)      {
-                                       $cc++;
-                                       $iOut.=$this->renderListRow($table,$row,$cc,$titleCol,$thumbsCol);
+
+                       If (!$LOISmode) {
+                                       // Fixing a order table for sortby tables
+                               $this->currentTable = array();
+                               $currentIdList = array();
+                               $doSort = ($TCA[$table]['ctrl']['sortby'] && !$this->sortField);
+
+                               $prevUid = 0;
+                               $prevPrevUid = 0;
+                               $accRows = array();     // Accumulate rows here
+                               while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result))    {
+                                       $accRows[] = $row;
+                                       $currentIdList[] = $row['uid'];
+                                       if ($doSort)    {
+                                               if ($prevUid)   {
+                                                       $this->currentTable['prev'][$row['uid']] = $prevPrevUid;
+                                                       $this->currentTable['next'][$prevUid] = '-'.$row['uid'];
+                                                       $this->currentTable['prevUid'][$row['uid']] = $prevUid;
+                                               }
+                                               $prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
+                                               $prevUid=$row['uid'];
+                                       }
                                }
-                               
-                                       // Counter of total rows incremented:
-                               $this->eCounter++;      
+                               $GLOBALS['TYPO3_DB']->sql_free_result($result);
+
+                                       // CSV initiated
+                               if ($this->csvOutput) $this->initCSV();
+
+                                       // Render items:
+                               $this->CBnames=array();
+                               $this->duplicateStack=array();
+                               $this->eCounter=$this->firstElementNumber;
+
+                               $iOut = '';
+                               $cc = 0;
+                               foreach($accRows as $row)       {
+
+                                               // Forward/Backwards navigation links:
+                                       list($flag,$code) = $this->fwd_rwd_nav($table);
+                                       $iOut.=$code;
+
+                                               // If render item, increment counter and call function
+                                       if ($flag)      {
+                                               $cc++;
+                                               $iOut.=$this->renderListRow($table,$row,$cc,$titleCol,$thumbsCol);
+                                       }
+
+                                               // Counter of total rows incremented:
+                                       $this->eCounter++;
+                               }
+
+                                       // The header row for the table is now created:
+                               $out.=$this->renderListHeader($table,$currentIdList);
                        }
-       
-                               // The header row for the table is now created:
-                       $out.=$this->renderListHeader($table,$currentIdList);
 
                                // The list of records is added after the header:
                        $out.=$iOut;
-       
+
                                // ... and it is all wrapped in a table:
                        $out='
-                       
-                               
-                               
+
+
+
                        <!--
                                DB listing of elements: "'.htmlspecialchars($table).'"
-                       -->     
-                               <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">
+                       -->
+                               <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist'.($LOISmode?' typo3-dblist-overview':'').'">
                                        '.$out.'
-                               </table>';      
-       
+                               </table>';
+
                                // Output csv if...
-                       if ($this->csvOutput)   $this->outputCSV($table);       // This ends the page with exit.        
+                       if ($this->csvOutput)   $this->outputCSV($table);       // This ends the page with exit.
                }
-               
+
                        // Return content:
                return $out;
        }
 
        /**
         * Rendering a single row for the list
-        * 
+        *
         * @param       string          Table name
         * @param       array           Current record
         * @param       integer         Counter, counting for each time an element is rendered (used for alternating colors)
@@ -475,28 +506,27 @@ class localRecordList extends recordList {
         */
        function renderListRow($table,$row,$cc,$titleCol,$thumbsCol)    {
                $iOut = '';
-               
+
                        // Background color, if any:
                $row_bgColor=
-                       $this->alternateBgColors ? 
+                       $this->alternateBgColors ?
                        (($cc%2)?'' :' bgcolor="'.t3lib_div::modifyHTMLColor($GLOBALS['SOBE']->doc->bgColor4,+10,+10,+10).'"') :
                        '';
 
                        // Initialization
                $alttext = t3lib_BEfunc::getRecordIconAltText($row,$table);
                $recTitle = t3lib_BEfunc::getRecordTitle($table,$row);
-               
+
                        // Incr. counter.
                $this->counter++;
 
-                       // The icon with link   
+                       // The icon with link
                $iconImg = t3lib_iconWorks::getIconImage($table,$row,$this->backPath,'title="'.htmlspecialchars($alttext).'"');
                $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg,$table,$row['uid']);
 
                        // Preparing and getting the data-array
                $theData = Array();
-               reset($this->fieldArray);
-               while(list(,$fCol)=each($this->fieldArray))     {
+               foreach($this->fieldArray as $fCol)     {
                        if ($fCol==$titleCol)   {
                                $theData[$fCol] = $this->linkWrapItems($table,$row['uid'],$recTitle,$row);
                        } elseif ($fCol=='pid') {
@@ -508,28 +538,28 @@ class localRecordList extends recordList {
                        } elseif ($fCol=='_CLIPBOARD_') {
                                $theData[$fCol]=$this->makeClip($table,$row);
                        } else {
-                               $theData[$fCol]=t3lib_BEfunc::getProcessedValueExtra($table,$fCol,$row[$fCol],100);
+                               $theData[$fCol]=htmlspecialchars(t3lib_BEfunc::getProcessedValueExtra($table,$fCol,$row[$fCol],100));
                        }
                }
 
                        // Add row to CSV list:
                if ($this->csvOutput) $this->addToCSV($row);
-               
+
                        // Create element in table cells:
                $iOut.=$this->addelement(1,$theIcon,$theData,$row_bgColor);
-               
+
                        // Render thumbsnails if a thumbnail column exists and there is content in it:
                if ($this->thumbs && trim($row[$thumbsCol]))    {
                        $iOut.=$this->addelement(4,'', Array($titleCol=>$this->thumbCode($row,$table,$thumbsCol)),$row_bgColor);
                }
-               
+
                        // Finally, return table row element:
                return $iOut;
        }
 
        /**
         * Rendering the header row for a table
-        * 
+        *
         * @param       string          Table name
         * @param       array           Array of the currectly displayed uids of the table
         * @return      string          Header table row
@@ -538,23 +568,23 @@ class localRecordList extends recordList {
         */
        function renderListHeader($table,$currentIdList)        {
                global $TCA, $LANG;
-               
+
                        // Init:
                $theData = Array();
 
                        // Traverse the fields:
                foreach($this->fieldArray as $fCol)     {
-               
+
                                // Calculate users permissions to edit records in the table:
                        $permsEdit = $this->calcPerms & ($table=='pages'?2:16);
-                       
+
                        switch((string)$fCol)   {
                                case '_PATH_':                  // Path
                                        $theData[$fCol]='<i>['.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels._PATH_',1).']</i>';
                                break;
                                case '_CLIPBOARD_':             // Clipboard:
                                        $cells=array();
-                                       
+
                                                // If there are elements on the clipboard for this table, then display the "paste into" icon:
                                        $elFromTable = $this->clipObj->elFromTable($table);
                                        if (count($elFromTable))        {
@@ -562,24 +592,24 @@ class localRecordList extends recordList {
                                                                '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteafter.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_paste',1).'" alt="" />'.
                                                                '</a>';
                                        }
-                                       
+
                                                // If the numeric clipboard pads are enabled, display the control icons for that:
                                        if ($this->clipObj->current!='normal')  {
-                                                       
+
                                                        // The "select" link:
                                                $cells[]=$this->linkClipboardHeaderIcon('<img'.t3lib_iconWorks::skinImg('','gfx/clip_copy.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_selectMarked',1).'" alt="" />',$table,'setCB');
 
-                                                       // The "edit marked" link:      
+                                                       // The "edit marked" link:
                                                $editIdList = implode(',',$currentIdList);
                                                $editIdList = "'+editList('".$table."','".$editIdList."')+'";
                                                $params='&edit['.$table.']['.$editIdList.']=edit&disHelp=1';
                                                $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
                                                                '<img'.t3lib_iconWorks::skinImg('','gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('clip_editMarked',1).'" alt="" />'.
                                                                '</a>';
-       
+
                                                        // The "Delete marked" link:
                                                $cells[]=$this->linkClipboardHeaderIcon('<img'.t3lib_iconWorks::skinImg('','gfx/garbage.gif','width="11" height="12"').' title="'.$LANG->getLL('clip_deleteMarked',1).'" alt="" />',$table,'delete',sprintf($LANG->getLL('clip_deleteMarkedWarning'),$LANG->sL($TCA[$table]['ctrl']['title'])));
-                                               
+
                                                        // The "Select all" link:
                                                $cells[]='<a href="#" onclick="'.htmlspecialchars('checkOffCB(\''.implode(',',$this->CBnames).'\'); return false;').'">'.
                                                                '<img'.t3lib_iconWorks::skinImg('','gfx/clip_select.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_markRecords',1).'" alt="" />'.
@@ -595,7 +625,12 @@ class localRecordList extends recordList {
                                                        // If new records can be created on this page, add links:
                                                if ($this->calcPerms&($table=='pages'?8:16) && $this->showNewRecLink($table))   {
                                                        if ($table=="tt_content" && $this->newWizards)  {
-                                                               $theData[$fCol]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\'sysext/cms/layout/db_new_content_el.php?id='.$this->id.'\');').'">'.
+                                                                       //  If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
+                                                               $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
+                                                               $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
+                                                               $newContentWizScriptPath = t3lib_extMgm::isLoaded($tmpTSc) ? (t3lib_extMgm::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
+
+                                                               $theData[$fCol]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$newContentWizScriptPath.'?id='.$this->id.'\');').'">'.
                                                                                                '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_'.($table=='pages'?'page':'el').'.gif','width="'.($table=='pages'?13:11).'" height="12"').' title="'.$LANG->getLL('new',1).'" alt="" />'.
                                                                                                '</a>';
                                                        } elseif ($table=='pages' && $this->newWizards) {
@@ -609,7 +644,7 @@ class localRecordList extends recordList {
                                                                                                '</a>';
                                                        }
                                                }
-                                               
+
                                                        // If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
                                                if ($permsEdit && $this->table && is_array($currentIdList))     {
                                                        $editIdList = implode(',',$currentIdList);
@@ -624,14 +659,14 @@ class localRecordList extends recordList {
                                default:                        // Regular fields header:
                                        $theData[$fCol]='';
                                        if ($this->table && is_array($currentIdList))   {
-                                                       
+
                                                        // If the numeric clipboard pads are selected, show duplicate sorting link:
                                                if ($this->clipNumPane()) {
                                                        $theData[$fCol].='<a href="'.htmlspecialchars($this->listURL('',-1).'&duplicateField='.$fCol).'">'.
                                                                                        '<img'.t3lib_iconWorks::skinImg('','gfx/select_duplicates.gif','width="11" height="11"').' title="'.$LANG->getLL('clip_duplicates',1).'" alt="" />'.
                                                                                        '</a>';
                                                }
-                                               
+
                                                        // If the table can be edited, add link for editing THIS field for all listed records:
                                                if (!$TCA[$table]['ctrl']['readOnly'] && $permsEdit && $TCA[$table]['columns'][$fCol])  {
                                                        $editIdList = implode(',',$currentIdList);
@@ -665,14 +700,14 @@ class localRecordList extends recordList {
 
        /**
         * Creates the control panel for a single record in the listing.
-        * 
+        *
         * @param       string          The table
         * @param       array           The record for which to make the control panel.
         * @return      string          HTML table with the control panel (unless disabled)
         */
        function makeControl($table,$row)       {
                global $TCA, $LANG, $SOBE;
-               
+
                        // Return blank, if disabled:
                if ($this->dontShowClipControlPanels)   return '';
 
@@ -684,10 +719,10 @@ class localRecordList extends recordList {
                if ($table=='pages')    {
                        $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid']));
                }
-               
+
                        // This expresses the edit permissions for this particular element:
                $permsEdit = ($table=='pages' && ($localCalcPerms&2)) || ($table!='pages' && ($this->calcPerms&16));
-               
+
                        // "Show" link (only pages and tt_content elements)
                if ($table=='pages' || $table=='tt_content')    {
                        $params='&edit['.$table.']['.$row['uid'].']=edit';
@@ -695,7 +730,7 @@ class localRecordList extends recordList {
                                        '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom.gif','width="12" height="12"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPage',1).'" alt="" />'.
                                        '</a>';
                }
-               
+
                        // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
                if ($permsEdit) {
                        $params='&edit['.$table.']['.$row['uid'].']=edit';
@@ -704,21 +739,21 @@ class localRecordList extends recordList {
                                        '</a>';
                }
 
-                       // "Move" wizard link for pages/tt_content elements:            
+                       // "Move" wizard link for pages/tt_content elements:
                if (($table=="tt_content" && $permsEdit) || ($table=='pages'))  {
                        $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\'move_el.php?table='.$table.'&uid='.$row['uid'].'\');').'">'.
                                        '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/move_'.($table=='tt_content'?'record':'page').'.gif','width="11" height="12"').' title="'.$LANG->getLL('move_'.($table=='tt_content'?'record':'page'),1).'" alt="" />'.
                                        '</a>';
                }
 
-                       // If the extended control panel is enabled OR if we are seeing a single table:         
+                       // If the extended control panel is enabled OR if we are seeing a single table:
                if ($SOBE->MOD_SETTINGS['bigControlPanel'] || $this->table)     {
 
                                // "Info": (All records)
                        $cells[]='<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$table.'\', \''.$row['uid'].'\'); return false;').'">'.
                                        '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom2.gif','width="12" height="12"').' title="'.$LANG->getLL('showInfo',1).'" alt="" />'.
                                        '</a>';
-       
+
                                // If the table is NOT a read-only table, then show these links:
                        if (!$TCA[$table]['ctrl']['readOnly'])  {
 
@@ -733,20 +768,20 @@ class localRecordList extends recordList {
                                                        '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/perm.gif','width="7" height="12"').' title="'.$LANG->getLL('permissions',1).'" alt="" />'.
                                                        '</a>';
                                }
-       
+
                                        // "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row or if default values can depend on previous record):
                                if ($TCA[$table]['ctrl']['sortby'] || $TCA[$table]['ctrl']['useColumnsForDefaultValues'])       {
                                        if (
                                                ($table!='pages' && ($this->calcPerms&16)) ||   // For NON-pages, must have permission to edit content on this parent page
                                                ($table=='pages' && ($this->calcPerms&8))               // For pages, must have permission to create new pages here.
-                                               )       {       
+                                               )       {
                                                if ($this->showNewRecLink($table))      {
                                                        $params='&edit['.$table.']['.(-$row['uid']).']=new';
                                                        $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
                                                                        '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_'.($table=='pages'?'page':'el').'.gif','width="'.($table=='pages'?13:11).'" height="12"').' title="'.$LANG->getLL('new'.($table=='pages'?'Page':'Record'),1).'" alt="" />'.
                                                                        '</a>';
                                                }
-                                       } 
+                                       }
                                }
 
                                        // "Up/Down" links
@@ -768,7 +803,7 @@ class localRecordList extends recordList {
                                                $cells[]='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"',2).' alt="" />';
                                        }
                                }
-               
+
                                        // "Hide/Unhide" links:
                                $hiddenField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
                                if ($permsEdit && $hiddenField && $TCA[$table]['columns'][$hiddenField] && (!$TCA[$table]['columns'][$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$table.':'.$hiddenField)))     {
@@ -784,7 +819,7 @@ class localRecordList extends recordList {
                                                                '</a>';
                                        }
                                }
-               
+
                                        // "Delete" link:
                                if (
                                        ($table=='pages' && ($localCalcPerms&4)) || ($table!='pages' && ($this->calcPerms&16))
@@ -794,7 +829,7 @@ class localRecordList extends recordList {
                                                        '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/garbage.gif','width="11" height="12"').' title="'.$LANG->getLL('delete',1).'" alt="" />'.
                                                        '</a>';
                                }
-               
+
                                        // "Levels" links: Moving pages into new levels...
                                if ($permsEdit && $table=='pages' && !$this->searchLevels)      {
 
@@ -822,14 +857,14 @@ class localRecordList extends recordList {
                                }
                        }
                }
-               
+
                        // If the record is edit-locked by another user, we will show a little warning sign:
                if ($lockInfo=t3lib_BEfunc::isRecordLocked($table,$row['uid'])) {
                        $cells[]='<a href="#" onclick="'.htmlspecialchars('alert('.$LANG->JScharCode($lockInfo['msg']).');return false;').'">'.
                                        '<img'.t3lib_iconWorks::skinImg('','gfx/recordlock_warning3.gif','width="17" height="12"').' title="'.htmlspecialchars($lockInfo['msg']).'" alt="" />'.
                                        '</a>';
                }
-               
+
 
                        // Compile items into a DIV-element:
                return '
@@ -839,14 +874,14 @@ class localRecordList extends recordList {
 
        /**
         * Creates the clipboard panel for a single record in the listing.
-        * 
+        *
         * @param       string          The table
         * @param       array           The record for which to make the clipboard panel.
         * @return      string          HTML table with the clipboard panel (unless disabled)
         */
        function makeClip($table,$row)  {
                global $TCA, $LANG;
-               
+
                        // Return blank, if disabled:
                if ($this->dontShowClipControlPanels)   return '';
                $cells=array();
@@ -864,7 +899,7 @@ class localRecordList extends recordList {
                                        '</a>';
 
                } else {        // For the numeric clipboard pads (showing checkboxes where one can select elements on/off)
-               
+
                                // Setting name of the element in ->CBnames array:
                        $n=$table.'|'.$row['uid'];
                        $this->CBnames[]=$n;
@@ -880,12 +915,12 @@ class localRecordList extends recordList {
                                }
                                $this->duplicateStack[] = $row[$this->duplicateField];
                        }
-                               
-                               // Adding the checkbox to the panel:                    
+
+                               // Adding the checkbox to the panel:
                        $cells[]='<input type="hidden" name="CBH['.$n.']" value="0" /><input type="checkbox" name="CBC['.$n.']" value="1" class="smallCheckboxes"'.$checked.' />';
                }
 
-                       // Now, looking for selected elements from the current table:           
+                       // Now, looking for selected elements from the current table:
                $elFromTable = $this->clipObj->elFromTable($table);
                if (count($elFromTable) && $TCA[$table]['ctrl']['sortby'])      {       // IF elements are found and they can be individually ordered, then add a "paste after" icon:
                        $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl($table,-$row['uid'])).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg($table,$row,'after',$elFromTable)).'">'.
@@ -908,14 +943,14 @@ class localRecordList extends recordList {
 
        /**
         * Create the selector box for selecting fields to display from a table:
-        * 
+        *
         * @param       string          Table name
         * @param       boolean         If true, form-fields will be wrapped around the table.
         * @return      string          HTML table with the selector box (name: displayFields['.$table.'][])
         */
        function fieldSelectBox($table,$formFields=1)   {
                global $TCA, $LANG;
-               
+
                        // Init:
                t3lib_div::loadTCA($table);
                $formElements=array('','');
@@ -945,10 +980,10 @@ class localRecordList extends recordList {
 
                        // Compile the options into a multiple selector box:
                $lMenu = '
-                                                                               <select size='.t3lib_div::intInRange(count($fields)+1,3,20).' multiple="multiple" name="displayFields['.$table.'][]">'.implode('',$opt).'
+                                                                               <select size="'.t3lib_div::intInRange(count($fields)+1,3,20).'" multiple="multiple" name="displayFields['.$table.'][]">'.implode('',$opt).'
                                                                                </select>
                                ';
-               
+
                        // Table with the field selector::
                $content.= '
                        '.$formElements[0].'
@@ -961,7 +996,7 @@ class localRecordList extends recordList {
                                                <td>'.$lMenu.'</td>
                                                <td><input type="submit" name="search" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.setFields',1).'" /></td>
                                        </tr>
-                               </table>                        
+                               </table>
                        '.$formElements[1];
                return $content;
        }
@@ -985,7 +1020,7 @@ class localRecordList extends recordList {
        /**
         * Creates a link around $string. The link contains an onclick action which submits the script with some clipboard action.
         * Currently, this is used for setting elements / delete elements.
-        * 
+        *
         * @param       string          The HTML content to link (image/text)
         * @param       string          Table name
         * @param       string          Clipboard command (eg. "setCB" or "delete")
@@ -1000,35 +1035,35 @@ class localRecordList extends recordList {
 
        /**
         * Returns true if a numeric clipboard pad is selected/active
-        * 
-        * @return      boolean         
+        *
+        * @return      boolean
         */
        function clipNumPane()  {
                return in_Array('_CLIPBOARD_',$this->fieldArray) && $this->clipObj->current!='normal';
        }
 
        /**
-        * Creates a sort-by link on the input string ($code). 
+        * Creates a sort-by link on the input string ($code).
         * It will automatically detect if sorting should be ascending or descending depending on $this->sortRev.
         * Also some fields will not be possible to sort (including if single-table-view is disabled).
-        * 
+        *
         * @param       string          The string to link (text)
         * @param       string          The fieldname represented by the title ($code)
         * @param       string          Table name
         * @return      string          Linked $code variable
         */
        function addSortLink($code,$field,$table)       {
-                       
+
                        // Certain circumstances just return string right away (no links):
                if ($field=='_CONTROL_' || $field=='_CLIPBOARD_' || $this->disableSingleTableView)      return $code;
-               
+
                        // If "_PATH_" (showing record path) is selected, force sorting by pid field (will at least group the records!)
                if ($field=='_PATH_')   $field=pid;
-               
+
                        //       Create the sort link:
                $sortUrl = $this->listURL('',-1,'sortField,sortRev,table').'&table='.$table.'&sortField='.$field.'&sortRev='.($this->sortRev || ($this->sortField!=$field)?0:1);
                $sortArrow = ($this->sortField==$field?'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/red'.($this->sortRev?'up':'down').'.gif','width="7" height="4"').' alt="" />':'');
-               
+
                        // Return linked field:
                return '<a href="'.htmlspecialchars($sortUrl).'">'.$code.
                                $sortArrow.
@@ -1038,7 +1073,7 @@ class localRecordList extends recordList {
        /**
         * Returns the path for a certain pid
         * The result is cached internally for the session, thus you can call this function as much as you like without performance problems.
-        * 
+        *
         * @param       integer         The page id for which to get the path
         * @return      string          The path.
         */
@@ -1051,9 +1086,9 @@ class localRecordList extends recordList {
 
        /**
         * Returns true if a link for creating new records should be displayed for $table
-        * 
+        *
         * @param       string          Table name
-        * @return      boolean         
+        * @return      boolean
         */
        function showNewRecLink($table) {
                return !count($this->allowedNewTables) || in_array($table,$this->allowedNewTables);
@@ -1062,8 +1097,8 @@ class localRecordList extends recordList {
        /**
         * Creates the "&returnUrl" parameter for links - this is used when the script links to other scripts and passes its own URL with the link so other scripts can return to the listing again.
         * Uses REQUEST_URI as value.
-        * 
-        * @return      string          
+        *
+        * @return      string
         */
        function makeReturnUrl()        {
                return '&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
@@ -1083,18 +1118,18 @@ class localRecordList extends recordList {
         * CSV related functions
         *
         ************************************/
-        
+
        /**
         * Initializes internal csvLines array with the header of field names
-        * 
-        * @return      void            
+        *
+        * @return      void
         */
        function initCSV()      {
 
                        // Reset:
                $this->csvLines=array();
 
-                       // Getting header line with field names:                                        
+                       // Getting header line with field names:
                $csvRow=array();
                foreach($this->fieldArray as $fN)       {
                        $csvRow[]=$fN;
@@ -1107,9 +1142,9 @@ class localRecordList extends recordList {
 
        /**
         * Adds the content of input array $row to the CSV list:
-        * 
+        *
         * @param       array           Record array, from which the values of fields found in $this->fieldArray will be listed in the CSV output.
-        * @return      void            
+        * @return      void
         */
        function addToCSV($row) {
 
@@ -1122,16 +1157,16 @@ class localRecordList extends recordList {
                                $csvRow[]=$row[$fN];
                        }
                }
-               
+
                        // Set the values in the CSV list
                $this->setCsvRow($csvRow);
        }
 
        /**
         * Adds input row of values to the internal csvLines array as a CSV formatted line
-        * 
+        *
         * @param       array           Array with values to be listed.
-        * @return      void            
+        * @return      void
         */
        function setCsvRow($csvRow)     {
                $this->csvLines[] = t3lib_div::csvValues($csvRow);
@@ -1140,7 +1175,7 @@ class localRecordList extends recordList {
        /**
         * Compiles the internal csvLines array to a csv-string and outputs it to the browser.
         * This function exits!
-        * 
+        *
         * @param       string          Filename prefix:
         * @return      void            EXITS php execusion!
         */
@@ -1148,7 +1183,7 @@ class localRecordList extends recordList {
 
                        // Setting filename:
                $filename=$prefix.'_'.date('dmy-Hi').'.csv';
-               
+
                        // Creating output header:
                $mimeType = 'application/octet-stream';
                Header('Content-Type: '.$mimeType);
@@ -1156,15 +1191,15 @@ class localRecordList extends recordList {
 
                        // Printing the content of the CSV lines:
                echo implode(chr(13).chr(10),$this->csvLines);
-               
+
                        // Exits:
                exit;
        }
 }
 
+
 
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc'])  {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc']);
 }
-?>
\ No newline at end of file
+?>