[BUGFIX] Show correct record title
[Packages/TYPO3.CMS.git] / typo3 / class.db_list.inc
old mode 100755 (executable)
new mode 100644 (file)
index 0125527..40fc778
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2009 Kasper Skårhøj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
  * Include file extending t3lib_recordList
  * Shared between Web>List (db_list.php) and Web>Page (sysext/cms/layout/db_layout.php)
  *
- * $Id$
- * Revised for TYPO3 3.6 December/2003 by Kasper Skaarhoj
+ * Revised for TYPO3 3.6 December/2003 by Kasper Skårhøj
  * XHTML compliant
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  */
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
@@ -78,7 +77,7 @@
 /**
  * Child class for rendering of Web > List (not the final class. see class.db_list_extra)
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  * @see localRecordList
@@ -92,7 +91,7 @@ class recordList extends t3lib_recordList {
        var $itemsLimitPerTable = 20;                   // default Max items shown per table in "multi-table mode", may be overridden by tables.php
        var $itemsLimitSingleTable = 100;               // default Max items shown per table in "single-table mode", may be overridden by tables.php
        var $widthGif = '<img src="clear.gif" width="1" height="4" hspace="160" alt="" />';
-       var $script = 'db_list.php';                    // Current script name
+       var $script = 'index.php';                      // Current script name
        var $allFields=0;                               // Indicates if all available fields for a user should be selected or not.
        var $localizationView=FALSE;                    // Whether to show localization view or not.
 
@@ -106,7 +105,7 @@ class recordList extends t3lib_recordList {
                // Internal, static:
        var $id;                                        // Page id
        var $table='';                                  // Tablename if single-table mode
-       var $listOnlyInSingleTableMode=FALSE;           // If true, records are listed only if a specific table is selected.
+       var $listOnlyInSingleTableMode=FALSE;           // If TRUE, records are listed only if a specific table is selected.
        var $firstElementNumber=0;                      // Pointer for browsing list
        var $searchString='';                           // Search string
        var $searchLevels='';                           // Levels to search down.
@@ -118,6 +117,8 @@ class recordList extends t3lib_recordList {
        var $modSharedTSconfig = array();               // Shared module configuration, used by localization features
        var $pageRecord = array();              // Loaded with page record with version overlay if any.
        var $hideTables = '';                   // Tables which should not get listed
+       var $tableTSconfigOverTCA = array(); //TSconfig which overwrites TCA-Settings
+       var $tablesCollapsed = array(); // Array of collapsed / uncollapsed tables in multi table view
 
                // Internal, dynamic:
        var $JScode = '';                               // JavaScript code accumulation
@@ -130,7 +131,7 @@ class recordList extends t3lib_recordList {
        var $currentTable = array();                    // Used for tracking next/prev uids
        var $duplicateStack=array();                    // Used for tracking duplicate values of fields
 
-
+       var $modTSconfig;                               // module configuratio
 
 
 
@@ -146,11 +147,13 @@ class recordList extends t3lib_recordList {
         * @return      void
         */
        function start($id,$table,$pointer,$search="",$levels="",$showLimit=0)  {
-               global $TCA;
 
                        // Setting internal variables:
                $this->id=intval($id);                                  // sets the parent id
-               if ($TCA[$table])       $this->table=$table;            // Setting single table mode, if table exists:
+               if ($GLOBALS['TCA'][$table]) {
+                               // Setting single table mode, if table exists:
+                       $this->table = $table;
+               }
                $this->firstElementNumber=$pointer;
                $this->searchString=trim($search);
                $this->searchLevels=trim($levels);
@@ -177,6 +180,14 @@ class recordList extends t3lib_recordList {
                $this->JScode='';
                $this->HTMLcode='';
 
+                       // limits
+               if(isset($this->modTSconfig['properties']['itemsLimitPerTable'])) {
+                       $this->itemsLimitPerTable = t3lib_div::intInRange(intval($this->modTSconfig['properties']['itemsLimitPerTable']), 1, 10000);
+               }
+               if(isset($this->modTSconfig['properties']['itemsLimitSingleTable'])) {
+                       $this->itemsLimitSingleTable = t3lib_div::intInRange(intval($this->modTSconfig['properties']['itemsLimitSingleTable']), 1, 10000);
+               }
+
                        // Set select levels:
                $sL=intval($this->searchLevels);
                $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
@@ -188,9 +199,28 @@ class recordList extends t3lib_recordList {
                        }
                }
 
+               // Get configuration of collapsed tables from user uc and merge with sanitized GP vars
+               $this->tablesCollapsed = is_array($GLOBALS['BE_USER']->uc['moduleData']['list']) ? $GLOBALS['BE_USER']->uc['moduleData']['list'] : array();
+               $collapseOverride = t3lib_div::_GP('collapse');
+               if (is_array($collapseOverride)) {
+                       foreach($collapseOverride as $collapseTable => $collapseValue) {
+                               if (is_array($GLOBALS['TCA'][$collapseTable]) && ($collapseValue == 0 || $collapseValue == 1)) {
+                                       $this->tablesCollapsed[$collapseTable] = $collapseValue;
+                               }
+                       }
+                       // Save modified user uc
+                       $GLOBALS['BE_USER']->uc['moduleData']['list'] = $this->tablesCollapsed;
+                       $GLOBALS['BE_USER']->writeUC($GLOBALS['BE_USER']->uc);
+                       if (t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'))) {
+                               $location = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
+                               t3lib_utility_Http::redirect($location);
+                       }
+               }
+
                if ($sL>0)      {
-                       $tree = $this->getTreeObject($id,$sL,$this->perms_clause);
-                       $this->pidSelect = 'pid IN ('.implode(',',$tree->ids).')';
+                       $tree = $this->getTreeObject($this->id, $sL, $this->perms_clause);
+                       $pidList = implode(',', $GLOBALS['TYPO3_DB']->cleanIntArray($tree->ids));
+                       $this->pidSelect = 'pid IN (' . $pidList . ')';
                } else {
                        $this->pidSelect = 'pid='.intval($id);
                }
@@ -209,14 +239,12 @@ class recordList extends t3lib_recordList {
         * @return      void
         */
        function generateList() {
-               global $TCA;
 
                        // Set page record in header
                $this->pageRecord = t3lib_BEfunc::getRecordWSOL('pages',$this->id);
 
                        // Traverse the TCA table array:
-               reset($TCA);
-               while (list($tableName)=each($TCA))     {
+               foreach ($GLOBALS['TCA'] as $tableName => $value) {
 
                                // Checking if the table should be rendered:
                        if ((!$this->table || $tableName==$this->table) && (!$this->tableList || t3lib_div::inList($this->tableList,$tableName)) && $GLOBALS['BE_USER']->check('tables_select',$tableName))     {               // Checks that we see only permitted/requested tables:
@@ -224,14 +252,29 @@ class recordList extends t3lib_recordList {
                                        // Load full table definitions:
                                t3lib_div::loadTCA($tableName);
 
-                                       // Hide tables which are configured via TSConfig not to be shown (also works for admins):
-                               if (t3lib_div::inList($this->hideTables, $tableName))   continue;
+                                       // Don't show table if hidden by TCA ctrl section
+                               $hideTable = $GLOBALS['TCA'][$tableName]['ctrl']['hideTable'] ? TRUE : FALSE;
+                                       // Don't show table if hidden by pageTSconfig mod.web_list.hideTables
+                               if (in_array($tableName, t3lib_div::trimExplode(',', $this->hideTables))) {
+                                       $hideTable = TRUE;
+                               }
+                                       // Override previous selection if table is enabled or hidden by TSconfig TCA override mod.web_list.table
+                               if (isset($this->tableTSconfigOverTCA[$tableName.'.']['hideTable'])) {
+                                       $hideTable = $this->tableTSconfigOverTCA[$tableName.'.']['hideTable'] ? TRUE : FALSE;
+                               }
+                               if ($hideTable) {
+                                       continue;
+                               }
 
                                        // iLimit is set depending on whether we're in single- or multi-table mode
                                if ($this->table)       {
-                                       $this->iLimit=(isset($TCA[$tableName]['interface']['maxSingleDBListItems'])?intval($TCA[$tableName]['interface']['maxSingleDBListItems']):$this->itemsLimitSingleTable);
+                                       $this->iLimit= (isset($GLOBALS['TCA'][$tableName]['interface']['maxSingleDBListItems'])
+                                               ? intval($GLOBALS['TCA'][$tableName]['interface']['maxSingleDBListItems']) :
+                                               $this->itemsLimitSingleTable);
                                } else {
-                                       $this->iLimit=(isset($TCA[$tableName]['interface']['maxDBListItems'])?intval($TCA[$tableName]['interface']['maxDBListItems']):$this->itemsLimitPerTable);
+                                       $this->iLimit = (isset($GLOBALS['TCA'][$tableName]['interface']['maxDBListItems'])
+                                               ? intval($GLOBALS['TCA'][$tableName]['interface']['maxDBListItems'])
+                                               : $this->itemsLimitPerTable);
                                }
                                if ($this->showLimit)   $this->iLimit = $this->showLimit;
 
@@ -253,7 +296,8 @@ class recordList extends t3lib_recordList {
 
                                        // Find ID to use (might be different for "versioning_followPages" tables)
                                if (intval($this->searchLevels)==0)     {
-                                       if ($TCA[$tableName]['ctrl']['versioning_followPages'] && $this->pageRecord['_ORIG_pid']==-1 && $this->pageRecord['t3ver_swapmode']==0) {
+                                       if ($GLOBALS['TCA'][$tableName]['ctrl']['versioning_followPages'] && $this->pageRecord['_ORIG_pid'] == -1
+                                               && $this->pageRecord['t3ver_swapmode'] == 0) {
                                                $this->pidSelect = 'pid='.intval($this->pageRecord['_ORIG_uid']);
                                        } else {
                                                $this->pidSelect = 'pid='.intval($this->id);
@@ -269,7 +313,7 @@ class recordList extends t3lib_recordList {
        /**
         * Creates the search box
         *
-        * @param       boolean         If true, the search box is wrapped in its own form-tags
+        * @param       boolean         If TRUE, the search box is wrapped in its own form-tags
         * @return      string          HTML for the search box
         */
        function getSearchBox($formFields=1)    {
@@ -277,13 +321,13 @@ class recordList extends t3lib_recordList {
                        // Setting form-elements, if applicable:
                $formElements=array('','');
                if ($formFields)        {
-                       $formElements=array('<form action="'.htmlspecialchars($this->listURL()).'" method="post">','</form>');
+                       $formElements = array('<form action="' . htmlspecialchars($this->listURL('', -1, 'firstElementNumber')) . '" method="post">', '</form>');
                }
 
                        // Make level selector:
                $opt=array();
                $parts = explode('|',$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.enterSearchLevels'));
-               while(list($kv,$label)=each($parts))    {
+               foreach ($parts as $kv => $label) {
                        $opt[] = '<option value="'.$kv.'"'.($kv==intval($this->searchLevels)?' selected="selected"':'').'>'.htmlspecialchars($label).'</option>';
                }
                $lMenu = '<select name="search_levels">'.implode('',$opt).'</select>';
@@ -295,18 +339,17 @@ class recordList extends t3lib_recordList {
                                <!--
                                        Search box:
                                -->
-                               <table border="0" cellpadding="0" cellspacing="0" class="bgColor4" id="typo3-dblist-search">
+                               <table border="0" cellpadding="0" cellspacing="0" id="typo3-dblist-search">
                                        <tr>
-                                               <td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.enterSearchString',1).'<input type="text" name="search_field" value="'.htmlspecialchars($this->searchString).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(10).' /></td>
-                                               <td>'.$lMenu.'</td>
-                                               <td><input type="submit" name="search" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.search',1).'" /></td>
+                                               <td><label for="search_field">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.enterSearchString', 1) . '</label><input type="text" name="search_field" id="search_field" value="' . htmlspecialchars($this->searchString) . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(10) . ' /></td>
+                                               <td>' . $lMenu . '</td>
+                                               <td><input type="submit" name="search" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.search', 1) . '" /></td>
                                        </tr>
                                        <tr>
-                                               <td colspan="3">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showRecords',1).':<input type="text" name="showLimit" value="'.htmlspecialchars($this->showLimit?$this->showLimit:'').'"'.$GLOBALS['SOBE']->doc->formWidth(4).' /></td>
+                                               <td colspan="3"><label for="showLimit">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showRecords', 1) . '</label>:<input type="text" name="showLimit" id="showLimit" value="' . htmlspecialchars($this->showLimit ? $this->showLimit : '') . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(4) . ' /></td>
                                        </tr>
                                </table>
                        '.$formElements[1];
-               $content.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_searchbox', $GLOBALS['BACK_PATH'],'|<br/>');
                return $content;
        }
 
@@ -317,8 +360,6 @@ class recordList extends t3lib_recordList {
         * @return      string          HTML for the sys-notes (if any)
         */
        function showSysNotesForPage()  {
-               global $TCA;
-
                $out='';
 
                        // Checking if extension is loaded:
@@ -338,8 +379,9 @@ class recordList extends t3lib_recordList {
                        t3lib_div::loadTCA('sys_note');
 
                                // Traverse note-types and get labels:
-                       if ($TCA['sys_note'] && $TCA['sys_note']['columns']['category'] && is_array($TCA['sys_note']['columns']['category']['config']['items']))        {
-                               foreach($TCA['sys_note']['columns']['category']['config']['items'] as $el)      {
+                       if ($GLOBALS['TCA']['sys_note'] && $GLOBALS['TCA']['sys_note']['columns']['category']
+                               && is_array($GLOBALS['TCA']['sys_note']['columns']['category']['config']['items'])) {
+                               foreach($GLOBALS['TCA']['sys_note']['columns']['category']['config']['items'] as $el) {
                                        $cat[$el[1]]=$GLOBALS['LANG']->sL($el[0]);
                                }
                        }
@@ -348,7 +390,7 @@ class recordList extends t3lib_recordList {
                        while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result))    {
 
                                        // Create content:
-                               $iconImg = t3lib_iconWorks::getIconImage('sys_note',$row,$this->backPath,'');
+                               $iconImg = t3lib_iconWorks::getSpriteIconForRecord('sys_note', $row);
                                $subject = htmlspecialchars($row['subject']);
                                $fields = array();
                                $fields['Author:'] = htmlspecialchars($row['author'].($row['email'] && $row['author'] ? ', ':'').$row['email']);
@@ -360,7 +402,7 @@ class recordList extends t3lib_recordList {
 
 
                                <!--
-                                       Sys-notes for the db_list.php:
+                                       Sys-notes for list module:
                                -->
                                        <table border="0" cellpadding="1" cellspacing="1" id="typo3-dblist-sysnotes">
                                                <tr><td colspan="2" class="bgColor2">'.$iconImg.'<strong>'.$subject.'</strong></td></tr>
@@ -396,14 +438,14 @@ class recordList extends t3lib_recordList {
        function setDispFields()        {
 
                        // Getting from session:
-               $dispFields = $GLOBALS['BE_USER']->getModuleData('db_list.php/displayFields');
+               $dispFields = $GLOBALS['BE_USER']->getModuleData('list/displayFields');
 
                        // If fields has been inputted, then set those as the value and push it to session variable:
                if (is_array($this->displayFields))     {
                        reset($this->displayFields);
                        $tKey = key($this->displayFields);
                        $dispFields[$tKey]=$this->displayFields[$tKey];
-                       $GLOBALS['BE_USER']->pushModuleData('db_list.php/displayFields',$dispFields);
+                       $GLOBALS['BE_USER']->pushModuleData('list/displayFields',$dispFields);
                }
 
                        // Setting result:
@@ -431,11 +473,18 @@ class recordList extends t3lib_recordList {
         * @param       string          Field list to select, * for all (for "SELECT [fieldlist] FROM ...")
         * @return      array           Returns query array
         */
-       function makeQueryArray($table, $id, $addWhere="",$fieldList='*')       {
-               global $TCA;
+       function makeQueryArray($table, $id, $addWhere='', $fieldList='*')      {
+               $hookObjectsArr = array();
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list.inc']['makeQueryArray'])) {
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list.inc']['makeQueryArray'] as $classRef) {
+                               $hookObjectsArr[] = t3lib_div::getUserObj($classRef);
+                       }
+               }
 
                        // Set ORDER BY:
-               $orderBy = ($TCA[$table]['ctrl']['sortby']) ? 'ORDER BY '.$TCA[$table]['ctrl']['sortby'] : $TCA[$table]['ctrl']['default_sortby'];
+               $orderBy = ($GLOBALS['TCA'][$table]['ctrl']['sortby']
+                       ? 'ORDER BY ' . $GLOBALS['TCA'][$table]['ctrl']['sortby']
+                       : $GLOBALS['TCA'][$table]['ctrl']['default_sortby']);
                if ($this->sortField)   {
                        if (in_array($this->sortField,$this->makeFieldList($table,1)))  {
                                $orderBy = 'ORDER BY '.$this->sortField;
@@ -467,6 +516,19 @@ class recordList extends t3lib_recordList {
                        'LIMIT' => $limit
                );
 
+                       // Apply hook as requested in http://bugs.typo3.org/view.php?id=4361
+               foreach ($hookObjectsArr as $hookObj) {
+                       if (method_exists($hookObj, 'makeQueryArray_post')) {
+                               $_params = array(
+                                       'orderBy' => $orderBy,
+                                       'limit' => $limit,
+                                       'pC' => $pC,
+                                       'search' => $search,
+                               );
+                               $hookObj->makeQueryArray_post($queryParts, $this, $table, $id, $addWhere, $fieldList, $_params);
+                       }
+               }
+
                        // Return query:
                return $queryParts;
        }
@@ -479,13 +541,11 @@ class recordList extends t3lib_recordList {
         * @see makeQueryArray()
         */
        function setTotalItems($queryParts)     {
-               $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                                       'count(*)',
-                                       $queryParts['FROM'],
-                                       $queryParts['WHERE']
-                               );
-               list($rCount) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
-               $this->totalItems = $rCount;
+               $this->totalItems = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                       '*',
+                       $queryParts['FROM'],
+                       $queryParts['WHERE']
+               );
        }
 
        /**
@@ -495,10 +555,9 @@ class recordList extends t3lib_recordList {
         * @return      string          Returns part of WHERE-clause for searching, if applicable.
         */
        function makeSearchString($table)       {
-               global $TCA;
 
                        // Make query, only if table is valid and a search string is actually defined:
-               if ($TCA[$table] && $this->searchString)        {
+               if ($GLOBALS['TCA'][$table] && $this->searchString) {
 
                                // Loading full table description - we need to traverse fields:
                        t3lib_div::loadTCA($table);
@@ -508,8 +567,8 @@ class recordList extends t3lib_recordList {
                        $sfields[]='uid';       // Adding "uid" by default.
 
                                // Traverse the configured columns and add all columns that can be searched:
-                       foreach($TCA[$table]['columns'] as $fieldName => $info) {
-                               if ($info['config']['type']=='text' || ($info['config']['type']=='input' && !ereg('date|time|int',$info['config']['eval'])))    {
+                       foreach($GLOBALS['TCA'][$table]['columns'] as $fieldName => $info) {
+                               if ($info['config']['type']=='text' || ($info['config']['type']=='input' && !preg_match('/date|time|int/',$info['config']['eval'])))    {
                                        $sfields[]=$fieldName;
                                }
                        }
@@ -535,9 +594,9 @@ class recordList extends t3lib_recordList {
         */
        function linkWrapTable($table,$code)    {
                if ($this->table!=$table)       {
-                       return '<a href="'.htmlspecialchars($this->listURL('',$table)).'">'.$code.'</a>';
+                       return '<a href="' . htmlspecialchars($this->listURL('', $table, 'firstElementNumber')) . '">' . $code . '</a>';
                } else {
-                       return '<a href="'.htmlspecialchars($this->listURL('','','sortField,sortRev,table')).'">'.$code.'</a>';
+                       return '<a href="' . htmlspecialchars($this->listURL('', '', 'sortField,sortRev,table,firstElementNumber')) . '">' . $code . '</a>';
                }
        }
 
@@ -551,15 +610,16 @@ class recordList extends t3lib_recordList {
         * @return      string          The item title. Ready for HTML output (is htmlspecialchars()'ed)
         */
        function linkWrapItems($table,$uid,$code,$row)  {
-               global $TCA, $LANG;
-
                $origCode = $code;
 
                        // If the title is blank, make a "no title" label:
                if (!strcmp($code,'')) {
                        $code = '<i>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']</i> - '.htmlspecialchars(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table,$row),$GLOBALS['BE_USER']->uc['titleLen']));
                } else {
-                       $code = htmlspecialchars(t3lib_div::fixed_lgd_cs($code,$this->fixedL));
+                       $code = htmlspecialchars(t3lib_div::fixed_lgd_cs($code, $this->fixedL));
+                       if ($code != htmlspecialchars($origCode)) {
+                               $code = '<span title="'.htmlspecialchars($origCode).'">'.$code.'</span>';
+                       }
                }
 
                switch((string)$this->clickTitleMode)   {
@@ -575,29 +635,32 @@ class recordList extends t3lib_recordList {
                                        // "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';
-                                       $code = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'" title="'.$LANG->getLL('edit',1).'">'.
-                                                       $code.
+                                       $code = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath, -1)) .
+                                               '" title="' . $GLOBALS['LANG']->getLL('edit', 1) . '">' .
+                                                       $code .
                                                        '</a>';
                                }
                        break;
                        case 'show':
                                        // "Show" link (only pages and tt_content elements)
                                if ($table=='pages' || $table=='tt_content')    {
-                                       $code = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($table=='tt_content'?$this->id.'#'.$row['uid']:$row['uid'])).'" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPage',1).'">'.
-                                                       $code.
-                                                       '</a>';
+                                       $code = '<a href="#" onclick="'. htmlspecialchars(t3lib_BEfunc::viewOnClick(
+                                                       $table == 'tt_content' ? $this->id . '#' . $row['uid'] : $row['uid'])
+                                               ) . '" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', 1) . '">'.
+                                               $code. '</a>';
                                }
                        break;
                        case 'info':
                                // "Info": (All records)
-                               $code = '<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$table.'\', \''.$row['uid'].'\'); return false;').'" title="'.$LANG->getLL('showInfo',1).'">'.
+                               $code = '<a href="#" onclick="'.htmlspecialchars('top.launchView(\'' . $table . '\', \'' . $row['uid'] .
+                                       '\'); return false;') . '" title="'.$GLOBALS['LANG']->getLL('showInfo', 1) . '">' .
                                        $code.
                                        '</a>';
                        break;
                        default:
                                        // Output the label now:
                                if ($table=='pages')    {
-                                       $code = '<a href="'.htmlspecialchars($this->listURL($uid,'')).'" onclick="setHighlight('.$uid.')">'.$code.'</a>';
+                                       $code = '<a href="' . htmlspecialchars($this->listURL($uid, '', 'firstElementNumber')) . '" onclick="setHighlight(' . $uid . ')">' . $code . '</a>';
                                } else {
                                        $code = $this->linkUrlMail($code,$origCode);
                                }
@@ -638,21 +701,47 @@ class recordList extends t3lib_recordList {
         *
         * @param       string          Alternative id value. Enter blank string for the current id ($this->id)
         * @param       string          Tablename to display. Enter "-1" for the current table.
-        * @param       string          Commalist of fields NOT to include ("sortField" or "sortRev")
+        * @param       string          Commalist of fields NOT to include ("sortField", "sortRev" or "firstElementNumber")
         * @return      string          URL
         */
        function listURL($altId='',$table=-1,$exclList='')      {
-               return $this->script.
-                       '?id='.(strcmp($altId,'')?$altId:$this->id).
-                       '&table='.rawurlencode($table==-1?$this->table:$table).
-                       ($this->thumbs?'&imagemode='.$this->thumbs:'').
-                       ($this->returnUrl?'&returnUrl='.rawurlencode($this->returnUrl):'').
-                       ($this->searchString?'&search_field='.rawurlencode($this->searchString):'').
-                       ($this->searchLevels?'&search_levels='.rawurlencode($this->searchLevels):'').
-                       ($this->showLimit?'&showLimit='.rawurlencode($this->showLimit):'').
-                       ((!$exclList || !t3lib_div::inList($exclList,'sortField')) && $this->sortField?'&sortField='.rawurlencode($this->sortField):'').
-                       ((!$exclList || !t3lib_div::inList($exclList,'sortRev')) && $this->sortRev?'&sortRev='.rawurlencode($this->sortRev):'')
-                       ;
+               $urlParameters = array();
+               if (strcmp($altId, '')) {
+                       $urlParameters['id'] = $altId;
+               } else {
+                       $urlParameters['id'] = $this->id;
+               }
+               if ($table === -1) {
+                       $urlParameters['table'] = $this->table;
+               } else {
+                       $urlParameters['table'] = $table;
+               }
+               if ($this->thumbs) {
+                       $urlParameters['imagemode'] = $this->thumbs;
+               }
+               if ($this->returnUrl) {
+                       $urlParameters['returnUrl'] = $this->returnUrl;
+               }
+               if ($this->searchString) {
+                       $urlParameters['search_field'] = $this->searchString;
+               }
+               if ($this->searchLevels) {
+                       $urlParameters['search_levels'] = $this->searchLevels;
+               }
+               if ($this->showLimit) {
+                       $urlParameters['showLimit'] = $this->showLimit;
+               }
+               if ((!$exclList || !t3lib_div::inList($exclList, 'firstElementNumber')) && $this->firstElementNumber) {
+                       $urlParameters['pointer'] = $this->firstElementNumber;
+               }
+               if ((!$exclList || !t3lib_div::inList($exclList, 'sortField')) && $this->sortField) {
+                       $urlParameters['sortField'] = $this->sortField;
+               }
+               if ((!$exclList || !t3lib_div::inList($exclList, 'sortRev')) && $this->sortRev) {
+                       $urlParameters['sortRev'] = $this->sortRev;
+               }
+
+               return t3lib_BEfunc::getModuleUrl('web_list', $urlParameters);
        }
 
        /**
@@ -669,35 +758,52 @@ class recordList extends t3lib_recordList {
         *
         * @param       string          Table name
         * @param       boolean         If set, users access to the field (non-exclude-fields) is NOT checked.
+        * @param       boolean         If set, also adds crdate and tstamp fields (note: they will also be added if user is admin or dontCheckUser is set)
         * @return      array           Array, where values are fieldnames to include in query
         */
-       function makeFieldList($table,$dontCheckUser=0) {
-               global $TCA,$BE_USER;
+       function makeFieldList($table,$dontCheckUser=0,$addDateFields=0)        {
 
                        // Init fieldlist array:
                $fieldListArr = array();
 
                        // Check table:
-               if (is_array($TCA[$table]))     {
+               if (is_array($GLOBALS['TCA'][$table])) {
                        t3lib_div::loadTCA($table);
 
                                // Traverse configured columns and add them to field array, if available for user.
-                       foreach($TCA[$table]['columns'] as $fN => $fieldValue)  {
+                       foreach($GLOBALS['TCA'][$table]['columns'] as $fN => $fieldValue) {
                                if ($dontCheckUser ||
-                                       ((!$fieldValue['exclude'] || $BE_USER->check('non_exclude_fields',$table.':'.$fN)) && $fieldValue['config']['type']!='passthrough'))    {
+                                       ((!$fieldValue['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $fN))
+                                       && $fieldValue['config']['type']!='passthrough')) {
                                        $fieldListArr[]=$fN;
                                }
                        }
 
                                // Add special fields:
-                       if ($dontCheckUser || $BE_USER->isAdmin())      {
+                       if ($dontCheckUser || $GLOBALS['BE_USER']->isAdmin()) {
                                $fieldListArr[]='uid';
                                $fieldListArr[]='pid';
-                               if ($TCA[$table]['ctrl']['tstamp'])     $fieldListArr[]=$TCA[$table]['ctrl']['tstamp'];
-                               if ($TCA[$table]['ctrl']['crdate'])     $fieldListArr[]=$TCA[$table]['ctrl']['crdate'];
-                               if ($TCA[$table]['ctrl']['cruser_id'])  $fieldListArr[]=$TCA[$table]['ctrl']['cruser_id'];
-                               if ($TCA[$table]['ctrl']['sortby'])     $fieldListArr[]=$TCA[$table]['ctrl']['sortby'];
-                               if ($TCA[$table]['ctrl']['versioningWS'])       {
+                       }
+
+                               // Add date fields
+                       if ($dontCheckUser || $GLOBALS['BE_USER']->isAdmin() || $addDateFields) {
+                               if ($GLOBALS['TCA'][$table]['ctrl']['tstamp']) {
+                                       $fieldListArr[]=$GLOBALS['TCA'][$table]['ctrl']['tstamp'];
+                               }
+                               if ($GLOBALS['TCA'][$table]['ctrl']['crdate']) {
+                                       $fieldListArr[]=$GLOBALS['TCA'][$table]['ctrl']['crdate'];
+                               }
+                       }
+
+                               // Add more special fields:
+                       if ($dontCheckUser || $GLOBALS['BE_USER']->isAdmin()) {
+                               if ($GLOBALS['TCA'][$table]['ctrl']['cruser_id']) {
+                                       $fieldListArr[]=$GLOBALS['TCA'][$table]['ctrl']['cruser_id'];
+                               }
+                               if ($GLOBALS['TCA'][$table]['ctrl']['sortby']) {
+                                       $fieldListArr[]=$GLOBALS['TCA'][$table]['ctrl']['sortby'];
+                               }
+                               if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
                                        $fieldListArr[]='t3ver_id';
                                        $fieldListArr[]='t3ver_state';
                                        $fieldListArr[]='t3ver_wsid';
@@ -737,35 +843,35 @@ class recordList extends t3lib_recordList {
         * @return      void
         */
        function localizationRedirect($justLocalized)   {
-               global $TCA;
-
                list($table,$orig_uid,$language) = explode(':',$justLocalized);
 
-               if ($TCA[$table] && $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField'])     {
-                       list($localizedRecord) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+               if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['languageField']
+                       && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']) {
+                       $localizedRecord = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
                                        'uid',
                                        $table,
-                                       $TCA[$table]['ctrl']['languageField'].'='.intval($language).' AND '.
-                                               $TCA[$table]['ctrl']['transOrigPointerField'].'='.intval($orig_uid).
+                                       $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '=' . intval($language) . ' AND ' .
+                                               $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . '=' . intval($orig_uid) .
                                                t3lib_BEfunc::deleteClause($table).
                                                t3lib_BEfunc::versioningPlaceholderClause($table)
                                );
 
                        if (is_array($localizedRecord)) {
                                        // Create parameters and finally run the classic page module for creating a new page translation
+                               $url = substr($this->listURL(), strlen($this->backPath));
                                $params = '&edit['.$table.']['.$localizedRecord['uid'].']=edit';
-                               $returnUrl = '&returnUrl='.rawurlencode($this->listURL());
+                               $returnUrl = '&returnUrl='.rawurlencode($url);
                                $location = $GLOBALS['BACK_PATH'].'alt_doc.php?'.$params.$returnUrl;
 
-                               header('Location: '.t3lib_div::locationHeaderUrl($location));
-                               exit;
+                               t3lib_utility_Http::redirect($location);
                        }
                }
        }
 }
 
 
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list.inc'])        {
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list.inc']);
+if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/class.db_list.inc'])) {
+       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/class.db_list.inc']);
 }
+
 ?>
\ No newline at end of file