PageRenderTime 7ms CodeModel.GetById 80ms app.highlight 249ms RepoModel.GetById 33ms app.codeStats 1ms

/typo3/class.db_list_extra.inc

https://bitbucket.org/linxpinx/mercurial
PHP | 1878 lines | 1127 code | 263 blank | 488 comment | 264 complexity | eab6c910d7f7936dde0dd9ea1c52e184 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1<?php
   2/*************************************************************
   3*  Copyright notice
   4*
   5*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
   6*  All rights reserved
   7*
   8*  This script is part of the TYPO3 project. The TYPO3 project is
   9*  free software; you can redistribute it and/or modify
  10*  it under the terms of the GNU General Public License as published by
  11*  the Free Software Foundation; either version 2 of the License, or
  12*  (at your option) any later version.
  13*
  14*  The GNU General Public License can be found at
  15*  http://www.gnu.org/copyleft/gpl.html.
  16*  A copy is found in the textfile GPL.txt and important notices to the license
  17*  from the author is found in LICENSE.txt distributed with these scripts.
  18*
  19*
  20*  This script is distributed in the hope that it will be useful,
  21*  but WITHOUT ANY WARRANTY; without even the implied warranty of
  22*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23*  GNU General Public License for more details.
  24*
  25*  This copyright notice MUST APPEAR in all copies of the script!
  26***************************************************************/
  27/**
  28 * Include file extending recordList which extended t3lib_recordList
  29 * Used specifically for the Web>List module (db_list.php)
  30 *
  31 * $Id: class.db_list_extra.inc 8289 2010-07-27 19:08:35Z psychomieze $
  32 * Revised for TYPO3 3.6 December/2003 by Kasper Skaarhoj
  33 * XHTML compliant
  34 *
  35 * @author	Kasper Skaarhoj <kasperYYYY@typo3.com>
  36 */
  37/**
  38 * [CLASS/FUNCTION INDEX of SCRIPT]
  39 *
  40 *
  41 *
  42 *   91: class localRecordList extends recordList
  43 *  123:     function writeTop($row)
  44 *  304:     function getTable($table,$id,$rowlist)
  45 *  559:     function renderListRow($table,$row,$cc,$titleCol,$thumbsCol,$indent=0)
  46 *  648:     function renderListHeader($table,$currentIdList)
  47 *
  48 *              SECTION: Rendering of various elements
  49 *  796:     function makeControl($table,$row)
  50 *  986:     function makeClip($table,$row)
  51 * 1057:     function makeRef($table,$uid)
  52 * 1086:     function makeLocalizationPanel($table,$row)
  53 * 1148:     function fieldSelectBox($table,$formFields=1)
  54 *
  55 *              SECTION: Helper functions
  56 * 1231:     function linkClipboardHeaderIcon($string,$table,$cmd,$warning='')
  57 * 1242:     function clipNumPane()
  58 * 1256:     function addSortLink($code,$field,$table)
  59 * 1281:     function recPath($pid)
  60 * 1294:     function showNewRecLink($table)
  61 * 1304:     function makeReturnUrl()
  62 *
  63 *              SECTION: CSV related functions
  64 * 1329:     function initCSV()
  65 * 1352:     function addToCSV($row,$table)
  66 * 1376:     function setCsvRow($csvRow)
  67 * 1387:     function outputCSV($prefix)
  68 *
  69 * TOTAL FUNCTIONS: 19
  70 * (This index is automatically created/updated by the extension "extdeveval")
  71 *
  72 */
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83/**
  84 * Class for rendering of Web>List module
  85 *
  86 * @author	Kasper Skaarhoj <kasperYYYY@typo3.com>
  87 * @package TYPO3
  88 * @subpackage core
  89 */
  90class localRecordList extends recordList {
  91
  92		// External:
  93	var $alternateBgColors=FALSE;			// If true, table rows in the list will alternate in background colors (and have background colors at all!)
  94	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.
  95	var $deniedNewTables=array();			// Used to indicate which tables (values in the array) that cannot have a create-new-record link. If the array is empty, all tables are allowed.
  96	var $newWizards=FALSE;					// If true, the control panel will contain links to the create-new wizards for pages and tt_content elements (normally, the link goes to just creating a new element without the wizards!).
  97
  98	var $dontShowClipControlPanels=FALSE;	// If true, will disable the rendering of clipboard + control panels.
  99	var $showClipboard=FALSE;				// If true, will show the clipboard in the field list.
 100 	var $noControlPanels = FALSE;			// If true, will DISABLE all control panels in lists. (Takes precedence)
 101	var $clickMenuEnabled = TRUE;			// If true, clickmenus will be rendered
 102
 103	var $totalRowCount;						// count of record rows in view
 104
 105	var $spaceIcon;							// space icon used for alignment
 106
 107		// Internal:
 108	var $pageRow=array();					// Set to the page record (see writeTop())
 109
 110		// Used to accumulate CSV lines for CSV export.
 111	protected $csvLines = array();
 112
 113	var $csvOutput=FALSE;					// If set, the listing is returned as CSV instead.
 114
 115	/**
 116	 * Clipboard object
 117	 *
 118	 * @var t3lib_clipboard
 119	 */
 120	var $clipObj;
 121	var $CBnames=array();					// Tracking names of elements (for clipboard use)
 122	var $duplicateStack=array();			// Used to track which elements has duplicates and how many
 123
 124	/**
 125	 * references of the current record
 126	 *
 127	 * @var array
 128	 *
 129	 * @deprecated since 4.4: Use getReferenceCount instead
 130	 */
 131	public $references;
 132
 133	/**
 134	 * [$tablename][$uid] = number of references to this record
 135	 *
 136	 * @var array
 137	 */
 138	protected $referenceCount = array();
 139
 140	var $translations;						// Translations of the current record
 141	var $selFieldList;						// select fields for the query which fetches the translations of the current record
 142
 143	public function __construct() {
 144		parent::__construct();
 145	}
 146
 147	/**
 148	 * Create the panel of buttons for submitting the form or otherwise perform operations.
 149	 *
 150	 * @return	array	all available buttons as an assoc. array
 151	 */
 152	public function getButtons()	{
 153		global $LANG;
 154
 155		$buttons = array(
 156			'csh' => '',
 157			'view' => '',
 158			'edit' => '',
 159			'hide_unhide' => '',
 160			'move' => '',
 161			'new_record' => '',
 162			'paste' => '',
 163			'level_up' => '',
 164			'cache' => '',
 165			'reload' => '',
 166			'shortcut' => '',
 167			'back' => '',
 168			'csv' => '',
 169			'export' => ''
 170		);
 171
 172			// Get users permissions for this page record:
 173		$localCalcPerms = $GLOBALS['BE_USER']->calcPerms($this->pageRow);
 174
 175			// CSH
 176		if (!strlen($this->id))	{
 177			$buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module_noId', $GLOBALS['BACK_PATH'], '', TRUE);
 178		} elseif(!$this->id) {
 179			$buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module_root', $GLOBALS['BACK_PATH'], '', TRUE);
 180		} else {
 181			$buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module', $GLOBALS['BACK_PATH'], '', TRUE);
 182		}
 183
 184		if (isset($this->id)) {
 185				// View  Exclude doktypes 254,255 Configuration: mod.web_list.noViewWithDokTypes = 254,255
 186			if (isset($GLOBALS['SOBE']->modTSconfig['properties']['noViewWithDokTypes'])) {
 187				$noViewDokTypes = t3lib_div::trimExplode(',', $GLOBALS['SOBE']->modTSconfig['properties']['noViewWithDokTypes'], true);
 188			} else {
 189					//default exclusion: doktype 254, 255
 190				$noViewDokTypes = array('254', '255');
 191			}
 192
 193			if (!in_array($this->pageRow['doktype'], $noViewDokTypes)) {
 194				$buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->id, $this->backPath, t3lib_BEfunc::BEgetRootLine($this->id))) . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', TRUE) . '">' .
 195								t3lib_iconWorks::getSpriteIcon('actions-document-view') .
 196							'</a>';
 197			}
 198
 199				// New record
 200			if (!$GLOBALS['SOBE']->modTSconfig['properties']['noCreateRecordsLink']) {
 201				$buttons['new_record'] = '<a href="#" onclick="' . htmlspecialchars('return jumpExt(\'' . $this->backPath . 'db_new.php?id=' . $this->id . '\');') . '" title="' . $LANG->getLL('newRecordGeneral', TRUE) . '">' .
 202									t3lib_iconWorks::getSpriteIcon('actions-document-new') .
 203								'</a>';
 204			}
 205
 206				// If edit permissions are set (see class.t3lib_userauthgroup.php)
 207			if ($localCalcPerms&2 && !empty($this->id))	{
 208
 209					// Edit
 210				$params = '&edit[pages][' . $this->pageRow['uid'] . ']=edit';
 211				$buttons['edit'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath, -1)) . '" title="' . $LANG->getLL('editPage', TRUE) . '">' .
 212									t3lib_iconWorks::getSpriteIcon('actions-page-open') .
 213								'</a>';
 214					// Unhide
 215				if ($this->pageRow['hidden'])	{
 216					$params = '&data[pages][' . $this->pageRow['uid'] . '][hidden]=0';
 217					$buttons['hide_unhide'] = '<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');') . '" title="' . $LANG->getLL('unHidePage', TRUE) . '">' .
 218										t3lib_iconWorks::getSpriteIcon('actions-edit-unhide') .
 219									'</a>';
 220					// Hide
 221				} else {
 222					$params = '&data[pages][' . $this->pageRow['uid'] . '][hidden]=1';
 223					$buttons['hide_unhide'] = '<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');') . '" title="' . $LANG->getLL('hidePage', TRUE) . '">'.
 224										t3lib_iconWorks::getSpriteIcon('actions-edit-hide') .
 225									'</a>';
 226				}
 227
 228					// Move
 229				$buttons['move'] = '<a href="#" onclick="' . htmlspecialchars('return jumpExt(\'' . $this->backPath . 'move_el.php?table=pages&uid=' . $this->pageRow['uid'] . '\');') . '" title="' . $LANG->getLL('move_page', TRUE) . '">' .
 230									(($this->table == 'tt_content') ? t3lib_iconWorks::getSpriteIcon('actions-document-move') : t3lib_iconWorks::getSpriteIcon('actions-page-move')) .
 231								'</a>';
 232
 233					// Up one level
 234				$buttons['level_up'] = '<a href="' . htmlspecialchars($this->listURL($this->pageRow['pid'])) . '" onclick="setHighlight(' . $this->pageRow['pid'] . ')" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel', TRUE) . '">' .
 235								t3lib_iconWorks::getSpriteIcon('actions-view-go-up') .
 236							'</a>';
 237
 238			}
 239
 240
 241				// Paste
 242			if (($localCalcPerms&8) || ($localCalcPerms&16)) {
 243				$elFromTable = $this->clipObj->elFromTable('');
 244				if (count($elFromTable)) {
 245					$buttons['paste'] = '<a href="' . htmlspecialchars($this->clipObj->pasteUrl('', $this->id)) . '" onclick="' . htmlspecialchars('return ' . $this->clipObj->confirmMsg('pages', $this->pageRow, 'into', $elFromTable)) . '" title="' . $LANG->getLL('clip_paste', TRUE) . '">' .
 246										t3lib_iconWorks::getSpriteIcon('actions-document-paste-after') .
 247									'</a>';
 248				}
 249			}
 250
 251				// Cache
 252			$buttons['cache'] = '<a href="' . htmlspecialchars($this->listURL() . '&clear_cache=1') . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.clear_cache', TRUE) . '">' .
 253								t3lib_iconWorks::getSpriteIcon('actions-system-cache-clear') .
 254							'</a>';
 255
 256			if ($this->table) {
 257
 258					// CSV
 259				$buttons['csv'] = '<a href="' . htmlspecialchars($this->listURL() . '&csv=1') . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.csv', TRUE) . '">' .
 260									t3lib_iconWorks::getSpriteIcon('mimetypes-text-csv') .
 261								'</a>';
 262
 263					// Export
 264				if (t3lib_extMgm::isLoaded('impexp')) {
 265					$url = $this->backPath . t3lib_extMgm::extRelPath('impexp') . 'app/index.php?tx_impexp[action]=export';
 266					$buttons['export'] = '<a href="' . htmlspecialchars($url . '&tx_impexp[list][]=' . rawurlencode($this->table . ':' . $this->id)) . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:rm.export', TRUE) . '">' .
 267								t3lib_iconWorks::getSpriteIcon('actions-document-export-t3d') .
 268							'</a>';
 269				}
 270
 271			}
 272
 273				// Reload
 274			$buttons['reload'] = '<a href="' . htmlspecialchars($this->listURL()) . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.reload', TRUE) . '">' .
 275								t3lib_iconWorks::getSpriteIcon('actions-system-refresh') .
 276							'</a>';
 277
 278				// Shortcut
 279			if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
 280				$buttons['shortcut'] = $GLOBALS['TBE_TEMPLATE']->makeShortcutIcon('id, imagemode, pointer, table, search_field, search_levels, showLimit, sortField, sortRev', implode(',', array_keys($this->MOD_MENU)), 'web_list');
 281			}
 282
 283				// Back
 284			if ($this->returnUrl) {
 285				$buttons['back'] = '<a href="' . htmlspecialchars(t3lib_div::linkThisUrl($this->returnUrl, array('id' => $this->id))) . '" class="typo3-goBack" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.goBack', TRUE) . '">' .
 286									t3lib_iconWorks::getSpriteIcon('actions-view-go-back') .
 287								'</a>';
 288			}
 289		}
 290
 291		return $buttons;
 292	}
 293
 294	/**
 295	 * Creates the listing of records from a single table
 296	 *
 297	 * @param	string		Table name
 298	 * @param	integer		Page id
 299	 * @param	string		List of fields to show in the listing. Pseudo fields will be added including the record header.
 300	 * @return	string		HTML table with the listing for the record.
 301	 */
 302	function getTable($table,$id,$rowlist)	{
 303		global $TCA, $TYPO3_CONF_VARS;
 304
 305			// Loading all TCA details for this table:
 306		t3lib_div::loadTCA($table);
 307
 308			// Init
 309		$addWhere = '';
 310		$titleCol = $TCA[$table]['ctrl']['label'];
 311		$thumbsCol = $TCA[$table]['ctrl']['thumbnail'];
 312		$l10nEnabled = $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField'] && !$TCA[$table]['ctrl']['transOrigPointerTable'];
 313		$tableCollapsed = (!$this->tablesCollapsed[$table]) ? false : true;
 314
 315		// prepare space icon
 316		$this->spaceIcon = t3lib_iconWorks::getSpriteIcon('empty-empty', array('style' => 'background-position: 0 10px;'));
 317
 318			// Cleaning rowlist for duplicates and place the $titleCol as the first column always!
 319		$this->fieldArray=array();
 320			// title Column
 321		$this->fieldArray[] = $titleCol;	// Add title column
 322			// Control-Panel
 323		if (!t3lib_div::inList($rowlist,'_CONTROL_'))	{
 324			$this->fieldArray[] = '_CONTROL_';
 325			$this->fieldArray[] = '_AFTERCONTROL_';
 326		}
 327			// Clipboard
 328		if ($this->showClipboard)	{
 329			$this->fieldArray[] = '_CLIPBOARD_';
 330		}
 331			// Ref
 332		if (!$this->dontShowClipControlPanels)	{
 333			$this->fieldArray[]='_REF_';
 334			$this->fieldArray[]='_AFTERREF_';
 335		}
 336			// Path
 337		if ($this->searchLevels)	{
 338			$this->fieldArray[]='_PATH_';
 339		}
 340			// Localization
 341		if ($this->localizationView && $l10nEnabled)	{
 342			$this->fieldArray[] = '_LOCALIZATION_';
 343			$this->fieldArray[] = '_LOCALIZATION_b';
 344			$addWhere.=' AND (
 345				'.$TCA[$table]['ctrl']['languageField'].'<=0
 346				OR
 347				'.$TCA[$table]['ctrl']['transOrigPointerField'].' = 0
 348			)';
 349		}
 350			// Cleaning up:
 351		$this->fieldArray=array_unique(array_merge($this->fieldArray,t3lib_div::trimExplode(',',$rowlist,1)));
 352		if ($this->noControlPanels)	{
 353			$tempArray = array_flip($this->fieldArray);
 354			unset($tempArray['_CONTROL_']);
 355			unset($tempArray['_CLIPBOARD_']);
 356			$this->fieldArray = array_keys($tempArray);
 357		}
 358
 359			// Creating the list of fields to include in the SQL query:
 360		$selectFields = $this->fieldArray;
 361		$selectFields[] = 'uid';
 362		$selectFields[] = 'pid';
 363		if ($thumbsCol)	$selectFields[] = $thumbsCol;	// adding column for thumbnails
 364		if ($table=='pages')	{
 365			if (t3lib_extMgm::isLoaded('cms'))	{
 366				$selectFields[] = 'module';
 367				$selectFields[] = 'extendToSubpages';
 368				$selectFields[] = 'nav_hide';
 369			}
 370			$selectFields[] = 'doktype';
 371		}
 372		if (is_array($TCA[$table]['ctrl']['enablecolumns']))	{
 373			$selectFields = array_merge($selectFields,$TCA[$table]['ctrl']['enablecolumns']);
 374		}
 375		if ($TCA[$table]['ctrl']['type'])	{
 376			$selectFields[] = $TCA[$table]['ctrl']['type'];
 377		}
 378		if ($TCA[$table]['ctrl']['typeicon_column'])	{
 379			$selectFields[] = $TCA[$table]['ctrl']['typeicon_column'];
 380		}
 381		if ($TCA[$table]['ctrl']['versioningWS'])	{
 382			$selectFields[] = 't3ver_id';
 383			$selectFields[] = 't3ver_state';
 384			$selectFields[] = 't3ver_wsid';
 385			$selectFields[] = 't3ver_swapmode';		// Filtered out when pages in makeFieldList()
 386		}
 387		if ($l10nEnabled)	{
 388			$selectFields[] = $TCA[$table]['ctrl']['languageField'];
 389			$selectFields[] = $TCA[$table]['ctrl']['transOrigPointerField'];
 390		}
 391		if ($TCA[$table]['ctrl']['label_alt'])	{
 392			$selectFields = array_merge($selectFields,t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['label_alt'],1));
 393		}
 394		$selectFields = array_unique($selectFields);		// Unique list!
 395		$selectFields = array_intersect($selectFields,$this->makeFieldList($table,1));		// Making sure that the fields in the field-list ARE in the field-list from TCA!
 396		$selFieldList = implode(',',$selectFields);		// implode it into a list of fields for the SQL-statement.
 397		$this->selFieldList = $selFieldList;
 398
 399		/**
 400		 * @hook			DB-List getTable
 401		 * @date			2007-11-16
 402		 * @request		Malte Jansen  <mail@maltejansen.de>
 403		 */
 404		if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'])) {
 405			foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] as $classData) {
 406				$hookObject = t3lib_div::getUserObj($classData);
 407
 408				if(!($hookObject instanceof t3lib_localRecordListGetTableHook)) {
 409					throw new UnexpectedValueException('$hookObject must implement interface t3lib_localRecordListGetTableHook', 1195114460);
 410				}
 411
 412				$hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this);
 413			}
 414		}
 415
 416			// Create the SQL query for selecting the elements in the listing:
 417		if ($this->csvOutput) {	// do not do paging when outputting as CSV
 418			$this->iLimit = 0;
 419		}
 420
 421		if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
 422				// Get the two previous rows for sorting if displaying page > 1
 423			$this->firstElementNumber = $this->firstElementNumber - 2;
 424			$this->iLimit = $this->iLimit + 2;
 425			$queryParts = $this->makeQueryArray($table, $id,$addWhere,$selFieldList);	// (API function from class.db_list.inc)
 426			$this->firstElementNumber = $this->firstElementNumber + 2;
 427			$this->iLimit = $this->iLimit - 2;
 428		} else {
 429			$queryParts = $this->makeQueryArray($table, $id,$addWhere,$selFieldList);	// (API function from class.db_list.inc)
 430		}
 431
 432		$this->setTotalItems($queryParts);		// Finding the total amount of records on the page (API function from class.db_list.inc)
 433
 434			// Init:
 435		$dbCount = 0;
 436		$out = '';
 437		$listOnlyInSingleTableMode = $this->listOnlyInSingleTableMode && !$this->table;
 438
 439			// If the count query returned any number of records, we perform the real query, selecting records.
 440		if ($this->totalItems)	{
 441			// Fetch records only if not in single table mode or if in multi table mode and not collapsed
 442			if ($listOnlyInSingleTableMode || (!$this->table && $tableCollapsed)) {
 443				$dbCount = $this->totalItems;
 444			} else {
 445					// set the showLimit to the number of records when outputting as CSV
 446				if ($this->csvOutput) {
 447					$this->showLimit = $this->totalItems;
 448					$this->iLimit = $this->totalItems;
 449				}
 450				$result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
 451				$dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
 452			}
 453		}
 454
 455			// If any records was selected, render the list:
 456		if ($dbCount)	{
 457
 458				// Half line is drawn between tables:
 459			if (!$listOnlyInSingleTableMode)	{
 460				$theData = Array();
 461				if (!$this->table && !$rowlist)	{
 462					$theData[$titleCol] = '<img src="clear.gif" width="'.($GLOBALS['SOBE']->MOD_SETTINGS['bigControlPanel']?'230':'350').'" height="1" alt="" />';
 463					if (in_array('_CONTROL_',$this->fieldArray))	$theData['_CONTROL_']='';
 464					if (in_array('_CLIPBOARD_',$this->fieldArray))	$theData['_CLIPBOARD_']='';
 465				}
 466				$out.=$this->addelement(0,'',$theData,'class="c-table-row-spacer"',$this->leftMargin);
 467			}
 468
 469				// Header line is drawn
 470			$theData = Array();
 471			if ($this->disableSingleTableView)	{
 472				$theData[$titleCol] = '<span class="c-table">'.$GLOBALS['LANG']->sL($TCA[$table]['ctrl']['title'],1).'</span> ('.$this->totalItems.')';
 473			} else {
 474				$theData[$titleCol] = $this->linkWrapTable($table, '<span class="c-table">' . $GLOBALS['LANG']->sL($TCA[$table]['ctrl']['title'], TRUE) . '</span> (' . $this->totalItems . ') ' .
 475						($this->table ? t3lib_iconWorks::getSpriteIcon('actions-view-table-collapse', array('title' => $GLOBALS['LANG']->getLL('contractView', TRUE))) : t3lib_iconWorks::getSpriteIcon('actions-view-table-expand', array('title' => $GLOBALS['LANG']->getLL('expandView', TRUE))))
 476					);
 477			}
 478
 479				// CSH:
 480			$theData[$titleCol].= t3lib_BEfunc::cshItem($table,'',$this->backPath,'',FALSE,'margin-bottom:0px; white-space: normal;');
 481
 482			if ($listOnlyInSingleTableMode)	{
 483				$out.='
 484					<tr>
 485						<td class="t3-row-header" style="width:95%;">' . $theData[$titleCol] . '</td>
 486					</tr>';
 487
 488				if ($GLOBALS['BE_USER']->uc["edit_showFieldHelp"])	{
 489					$GLOBALS['LANG']->loadSingleTableDescription($table);
 490					if (isset($GLOBALS['TCA_DESCR'][$table]['columns']['']))	{
 491						$onClick = 'vHWin=window.open(\'view_help.php?tfID='.$table.'.\',\'viewFieldHelp\',\'height=400,width=600,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;';
 492						$out.='
 493					<tr>
 494						<td class="c-tableDescription">'.t3lib_BEfunc::helpTextIcon($table,'',$this->backPath,TRUE).$GLOBALS['TCA_DESCR'][$table]['columns']['']['description'].'</td>
 495					</tr>';
 496					}
 497				}
 498			} else {
 499				// Render collapse button if in multi table mode
 500				$collapseIcon = '';
 501				if (!$this->table) {
 502					$collapseIcon = '<a href="' . htmlspecialchars($this->listURL() . '&collapse[' . $table . ']=' . ($tableCollapsed ? '0' : '1')) . '" title="' . ($tableCollapsed ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.expandTable', TRUE) : $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.collapseTable', TRUE)) . '">' .
 503							($tableCollapsed ? t3lib_iconWorks::getSpriteIcon('actions-view-list-expand', array('class' => 'collapseIcon')) : t3lib_iconWorks::getSpriteIcon('actions-view-list-collapse', array('class' => 'collapseIcon'))) .
 504						'</a>';
 505				}
 506				$out .= $this->addElement(1, $collapseIcon, $theData, ' class="t3-row-header"', '');
 507			}
 508
 509			// Render table rows only if in multi table view and not collapsed or if in single table view
 510			if (!$listOnlyInSingleTableMode && (!$tableCollapsed || $this->table)) {
 511					// Fixing a order table for sortby tables
 512				$this->currentTable = array();
 513				$currentIdList = array();
 514				$doSort = ($TCA[$table]['ctrl']['sortby'] && !$this->sortField);
 515
 516				$prevUid = 0;
 517				$prevPrevUid = 0;
 518
 519					// Get first two rows and initialize prevPrevUid and prevUid if on page > 1
 520				if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
 521					$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
 522					$prevPrevUid = -(int) $row['uid'];
 523					$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
 524					$prevUid = $row['uid'];
 525				}
 526
 527				$accRows = array();	// Accumulate rows here
 528				while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result))	{
 529
 530						// In offline workspace, look for alternative record:
 531					t3lib_BEfunc::workspaceOL($table, $row, $GLOBALS['BE_USER']->workspace, TRUE);
 532
 533					if (is_array($row))	{
 534						$accRows[] = $row;
 535						$currentIdList[] = $row['uid'];
 536						if ($doSort)	{
 537							if ($prevUid)	{
 538								$this->currentTable['prev'][$row['uid']] = $prevPrevUid;
 539								$this->currentTable['next'][$prevUid] = '-'.$row['uid'];
 540								$this->currentTable['prevUid'][$row['uid']] = $prevUid;
 541							}
 542							$prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
 543							$prevUid=$row['uid'];
 544						}
 545					}
 546				}
 547				$GLOBALS['TYPO3_DB']->sql_free_result($result);
 548
 549				$this->totalRowCount = count($accRows);
 550
 551					// CSV initiated
 552				if ($this->csvOutput) $this->initCSV();
 553
 554					// Render items:
 555				$this->CBnames=array();
 556				$this->duplicateStack=array();
 557				$this->eCounter=$this->firstElementNumber;
 558
 559				$iOut = '';
 560				$cc = 0;
 561
 562				foreach($accRows as $row)	{
 563					// Render item row if counter < limit
 564					if ($cc < $this->iLimit) {
 565						$cc++;
 566						$this->translations = FALSE;
 567						$iOut.= $this->renderListRow($table,$row,$cc,$titleCol,$thumbsCol);
 568
 569							// If localization view is enabled it means that the selected records are either default or All language and here we will not select translations which point to the main record:
 570						if ($this->localizationView && $l10nEnabled)	{
 571								// For each available translation, render the record:
 572							if (is_array($this->translations)) {
 573								foreach ($this->translations as $lRow) {
 574										// $lRow isn't always what we want - if record was moved we've to work with the placeholder records otherwise the list is messed up a bit
 575									if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
 576										$tmpRow = t3lib_BEfunc::getRecordRaw($table, 't3ver_move_id="'.intval($lRow['uid']) . '" AND pid="' . $row['_MOVE_PLH_pid'] . '" AND t3ver_wsid=' . $row['t3ver_wsid'] . t3lib_beFunc::deleteClause($table), $selFieldList);
 577										$lRow = is_array($tmpRow)?$tmpRow:$lRow;
 578									}
 579										// In offline workspace, look for alternative record:
 580									t3lib_BEfunc::workspaceOL($table, $lRow, $GLOBALS['BE_USER']->workspace, true);
 581									if (is_array($lRow) && $GLOBALS['BE_USER']->checkLanguageAccess($lRow[$TCA[$table]['ctrl']['languageField']]))	{
 582										$currentIdList[] = $lRow['uid'];
 583										$iOut.=$this->renderListRow($table,$lRow,$cc,$titleCol,$thumbsCol,18);
 584									}
 585								}
 586							}
 587						}
 588					}
 589
 590						// Counter of total rows incremented:
 591					$this->eCounter++;
 592				}
 593
 594					// Record navigation is added to the beginning and end of the table if in single table mode
 595				if ($this->table) {
 596					$pageNavigation = $this->renderListNavigation();
 597					$iOut = $pageNavigation . $iOut . $pageNavigation;
 598				} else {
 599						// show that there are more records than shown
 600					if ($this->totalItems > $this->itemsLimitPerTable) {
 601						$countOnFirstPage = $this->totalItems > $this->itemsLimitSingleTable ? $this->itemsLimitSingleTable : $this->totalItems;
 602						$hasMore = ($this->totalItems > $this->itemsLimitSingleTable);
 603						$iOut .= '<tr><td colspan="' . count($this->fieldArray) . '" style="padding:5px;">
 604								<a href="'.htmlspecialchars($this->listURL() . '&table=' . rawurlencode($table)) . '">' .
 605								'<img' . t3lib_iconWorks::skinImg($this->backPath,'gfx/pildown.gif', 'width="14" height="14"') .' alt="" />'.
 606								' <i>[1 - ' . $countOnFirstPage . ($hasMore ? '+' : '') . ']</i></a>
 607								</td></tr>';
 608						}
 609
 610				}
 611
 612					// The header row for the table is now created:
 613				$out .= $this->renderListHeader($table,$currentIdList);
 614			}
 615
 616				// The list of records is added after the header:
 617			$out .= $iOut;
 618			unset($iOut);
 619
 620				// ... and it is all wrapped in a table:
 621			$out='
 622
 623
 624
 625			<!--
 626				DB listing of elements:	"'.htmlspecialchars($table).'"
 627			-->
 628				<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist'.($listOnlyInSingleTableMode?' typo3-dblist-overview':'').'">
 629					'.$out.'
 630				</table>';
 631
 632				// Output csv if...
 633			if ($this->csvOutput)	$this->outputCSV($table);	// This ends the page with exit.
 634		}
 635
 636			// Return content:
 637		return $out;
 638	}
 639
 640	/**
 641	 * Rendering a single row for the list
 642	 *
 643	 * @param	string		Table name
 644	 * @param	array		Current record
 645	 * @param	integer		Counter, counting for each time an element is rendered (used for alternating colors)
 646	 * @param	string		Table field (column) where header value is found
 647	 * @param	string		Table field (column) where (possible) thumbnails can be found
 648	 * @param	integer		Indent from left.
 649	 * @return	string		Table row for the element
 650	 * @access private
 651	 * @see getTable()
 652	 */
 653	function renderListRow($table,$row,$cc,$titleCol,$thumbsCol,$indent=0)	{
 654		$iOut = '';
 655
 656		if (strlen($this->searchString))	{	// If in search mode, make sure the preview will show the correct page
 657			$id_orig = $this->id;
 658			$this->id = $row['pid'];
 659		}
 660
 661		if (is_array($row))	{
 662				// add special classes for first and last row
 663			$rowSpecial = '';
 664			if ($cc == 1 && $indent == 0) {
 665				$rowSpecial .= ' firstcol';
 666			}
 667			if ($cc == $this->totalRowCount || $cc == $this->iLimit) {
 668				$rowSpecial .= ' lastcol';
 669			}
 670
 671				// Background color, if any:
 672			if ($this->alternateBgColors) {
 673				$row_bgColor = ($cc%2) ? ' class="db_list_normal'.$rowSpecial.'"' : ' class="db_list_alt'.$rowSpecial.'"';
 674			} else {
 675				$row_bgColor = ' class="db_list_normal'.$rowSpecial.'"';
 676			}
 677				// Overriding with versions background color if any:
 678			$row_bgColor = $row['_CSSCLASS'] ? ' class="'.$row['_CSSCLASS'].'"' : $row_bgColor;
 679
 680				// Incr. counter.
 681			$this->counter++;
 682
 683				// The icon with link
 684			$alttext = t3lib_BEfunc::getRecordIconAltText($row,$table);
 685			$iconImg = t3lib_iconWorks::getSpriteIconForRecord($table, $row, array('title' => htmlspecialchars($alttext), 'style' => ($indent ? ' margin-left: ' . $indent . 'px;' : '')));
 686
 687
 688			$theIcon = $this->clickMenuEnabled ? $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg,$table,$row['uid']) : $iconImg;
 689
 690				// Preparing and getting the data-array
 691			$theData = Array();
 692			foreach($this->fieldArray as $fCol)	{
 693				if ($fCol==$titleCol)	{
 694					$recTitle = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
 695						// If the record is edit-locked	by another user, we will show a little warning sign:
 696					if (($lockInfo = t3lib_BEfunc::isRecordLocked($table, $row['uid']))) {
 697						$warning = '<a href="#" onclick="' . htmlspecialchars('alert(' . $GLOBALS['LANG']->JScharCode($lockInfo['msg']) . '); return false;') . '" title="' . htmlspecialchars($lockInfo['msg']) . '">' .
 698								t3lib_iconWorks::getSpriteIcon('status-warning-in-use') .
 699							'</a>';
 700					}
 701					$theData[$fCol] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
 702
 703						// Render thumbsnails if a thumbnail column exists and there is content in it:
 704					if ($this->thumbs && trim($row[$thumbsCol])) {
 705						$theData[$fCol] .= '<br />' . $this->thumbCode($row,$table,$thumbsCol);
 706					}
 707
 708					$localizationMarkerClass = '';
 709					if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
 710					&& $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0) {
 711							// it's a translated record
 712						$localizationMarkerClass = ' localization';
 713					}
 714				} elseif ($fCol == 'pid') {
 715					$theData[$fCol]=$row[$fCol];
 716				} elseif ($fCol == '_PATH_') {
 717					$theData[$fCol]=$this->recPath($row['pid']);
 718				} elseif ($fCol == '_REF_') {
 719					$theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
 720				} elseif ($fCol == '_CONTROL_') {
 721					$theData[$fCol]=$this->makeControl($table,$row);
 722				} elseif ($fCol == '_AFTERCONTROL_' || $fCol == '_AFTERREF_') {
 723					$theData[$fCol] = '&nbsp;';
 724				} elseif ($fCol == '_CLIPBOARD_') {
 725					$theData[$fCol]=$this->makeClip($table,$row);
 726				} elseif ($fCol == '_LOCALIZATION_') {
 727					list($lC1, $lC2) = $this->makeLocalizationPanel($table,$row);
 728					$theData[$fCol] = $lC1;
 729					$theData[$fCol.'b'] = $lC2;
 730				} elseif ($fCol == '_LOCALIZATION_b') {
 731					// Do nothing, has been done above.
 732				} else {
 733					$tmpProc = t3lib_BEfunc::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid']);
 734					$theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
 735					$row[$fCol] = $tmpProc;
 736				}
 737			}
 738
 739			if (strlen($this->searchString))	{	// Reset the ID if it was overwritten
 740				$this->id = $id_orig;
 741			}
 742
 743				// Add row to CSV list:
 744			if ($this->csvOutput) {
 745				$this->addToCSV($row,$table);
 746			}
 747
 748			// Add classes to table cells
 749			$this->addElement_tdCssClass[$titleCol]         = 'col-title' . $localizationMarkerClass;
 750			if (!$this->dontShowClipControlPanels) {
 751				$this->addElement_tdCssClass['_CONTROL_']       = 'col-control';
 752				$this->addElement_tdCssClass['_AFTERCONTROL_']  = 'col-control-space';
 753				$this->addElement_tdCssClass['_CLIPBOARD_']     = 'col-clipboard';
 754			}
 755			$this->addElement_tdCssClass['_PATH_']          = 'col-path';
 756			$this->addElement_tdCssClass['_LOCALIZATION_']  = 'col-localizationa';
 757			$this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb';
 758
 759				// Create element in table cells:
 760			$iOut.=$this->addelement(1,$theIcon,$theData,$row_bgColor);
 761
 762				// Finally, return table row element:
 763			return $iOut;
 764		}
 765	}
 766
 767	/**
 768	 * Write sys_refindex entries for current record to $this->references
 769	 *
 770	 * @param	string		Table name
 771	 * @param	integer		Uid of current record
 772	 * @return	void
 773	 *
 774	 * @deprecated since 4.4: Use getReferenceCount instead
 775	 */
 776	function setReferences($table, $uid) {
 777		t3lib_div::logDeprecatedFunction();
 778
 779		$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
 780			'tablename, recuid, field',
 781			'sys_refindex',
 782			'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_refindex').
 783				' AND ref_uid='.intval($uid).
 784				' AND deleted=0'
 785		);
 786		$this->references = $rows;
 787	}
 788
 789	/**
 790	 * Gets the number of records referencing the record with the UID $uid in
 791	 * the table $tableName.
 792	 *
 793	 * @param string $tableName
 794	 *        table name of the referenced record, must not be empty
 795	 * @param integer $uid
 796	 *        UID of the referenced record, must be > 0
 797	 *
 798	 * @return integer the number of references to record $uid in table
 799	 *                 $tableName, will be >= 0
 800	 */
 801	protected function getReferenceCount($tableName, $uid) {
 802		if (!isset($this->referenceCount[$tableName][$uid])) {
 803			$numberOfReferences = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
 804				'*',
 805				'sys_refindex',
 806				'ref_table = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
 807					$tableName, 'sys_refindex'
 808				) .
 809					' AND ref_uid = ' . $uid .
 810					' AND deleted = 0'
 811			);
 812
 813			$this->referenceCount[$tableName][$uid] = $numberOfReferences;
 814		}
 815
 816		return $this->referenceCount[$tableName][$uid];
 817	}
 818
 819	/**
 820	 * Rendering the header row for a table
 821	 *
 822	 * @param	string		Table name
 823	 * @param	array		Array of the currently displayed uids of the table
 824	 * @return	string		Header table row
 825	 * @access private
 826	 * @see getTable()
 827	 */
 828	function renderListHeader($table, $currentIdList)	{
 829		global $TCA, $LANG, $TYPO3_CONF_VARS;
 830
 831			// Init:
 832		$theData = Array();
 833
 834			// Traverse the fields:
 835		foreach($this->fieldArray as $fCol)	{
 836
 837				// Calculate users permissions to edit records in the table:
 838			$permsEdit = $this->calcPerms & ($table=='pages'?2:16);
 839
 840			switch((string)$fCol)	{
 841				case '_PATH_':			// Path
 842					$theData[$fCol] = '<i>['.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels._PATH_',1).']</i>';
 843				break;
 844				case '_REF_':			// References
 845					$theData[$fCol] = '<i>['.$LANG->sL('LLL:EXT:lang/locallang_mod_file_list.xml:c__REF_',1).']</i>';
 846				break;
 847				case '_LOCALIZATION_':			// Path
 848					$theData[$fCol] = '<i>['.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels._LOCALIZATION_',1).']</i>';
 849				break;
 850				case '_LOCALIZATION_b':			// Path
 851					$theData[$fCol] = $LANG->getLL('Localize',1);
 852				break;
 853				case '_CLIPBOARD_':		// Clipboard:
 854					$cells=array();
 855
 856						// If there are elements on the clipboard for this table, then display the "paste into" icon:
 857					$elFromTable = $this->clipObj->elFromTable($table);
 858					if (count($elFromTable))	{
 859						$cells['pasteAfter']='<a href="'.htmlspecialchars($this->clipObj->pasteUrl($table,$this->id)).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg('pages',$this->pageRow,'into',$elFromTable)).'" title="' . $LANG->getLL('clip_paste', TRUE) . '">' .
 860									t3lib_iconWorks::getSpriteIcon('actions-document-paste-after') .
 861								'</a>';
 862					}
 863
 864						// If the numeric clipboard pads are enabled, display the control icons for that:
 865					if ($this->clipObj->current!='normal')	{
 866
 867							// The "select" link:
 868						$cells['copyMarked']=$this->linkClipboardHeaderIcon(t3lib_iconWorks::getSpriteIcon('actions-edit-copy', array('title' => $LANG->getLL('clip_selectMarked', TRUE))), $table, 'setCB');
 869
 870							// The "edit marked" link:
 871						$editIdList = implode(',',$currentIdList);
 872						$editIdList = "'+editList('".$table."','".$editIdList."')+'";
 873						$params='&edit['.$table.']['.$editIdList.']=edit&disHelp=1';
 874						$cells['edit']='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="' . $LANG->getLL('clip_editMarked', TRUE) . '">' .
 875								t3lib_iconWorks::getSpriteIcon('actions-document-open') .
 876								'</a>';
 877
 878							// The "Delete marked" link:
 879						$cells['delete']=$this->linkClipboardHeaderIcon(t3lib_iconWorks::getSpriteIcon('actions-edit-delete', array('title' => $LANG->getLL('clip_deleteMarked', TRUE))), $table,'delete',sprintf($LANG->getLL('clip_deleteMarkedWarning'), $LANG->sL($TCA[$table]['ctrl']['title'])));
 880
 881							// The "Select all" link:
 882						$cells['markAll'] = '<a class="cbcCheckAll" rel="" href="#" onclick="' . htmlspecialchars('checkOffCB(\'' . implode(',', $this->CBnames) . '\', this); return false;') . '" title="' . $LANG->getLL('clip_markRecords', TRUE) . '">' .
 883								t3lib_iconWorks::getSpriteIcon('actions-document-select') .
 884								'</a>';
 885					} else {
 886						$cells['empty']='';
 887					}
 888					/**
 889					 * @hook			renderListHeaderActions: Allows to change the clipboard icons of the Web>List table headers
 890					 * @date			2007-11-20
 891					 * @request		Bernhard Kraft  <krafbt@kraftb.at>
 892					 * @usage		Above each listed table in Web>List a header row is shown. This hook allows to modify the icons responsible for the clipboard functions (shown above the clipboard checkboxes when a clipboard other than "Normal" is selected), or other "Action" functions which perform operations on the listed records.
 893					 */
 894					if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions']))	{
 895						foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData)	{
 896							$hookObject = t3lib_div::getUserObj($classData);
 897							if(!($hookObject instanceof localRecordList_actionsHook))	{
 898								throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567850);
 899							}
 900							$cells = $hookObject->renderListHeaderActions($table, $currentIdList, $cells, $this);
 901						}
 902					}
 903					$theData[$fCol]=implode('',$cells);
 904				break;
 905				case '_CONTROL_':		// Control panel:
 906					if (!$TCA[$table]['ctrl']['readOnly'])	{
 907
 908							// If new records can be created on this page, add links:
 909						if ($this->calcPerms&($table=='pages'?8:16) && $this->showNewRecLink($table))	{
 910							if ($table=="tt_content" && $this->newWizards)	{
 911									//  If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
 912								$tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
 913								$tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
 914								$newContentWizScriptPath = $this->backPath.t3lib_extMgm::isLoaded($tmpTSc) ? (t3lib_extMgm::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
 915
 916								$icon = '<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$newContentWizScriptPath.'?id='.$this->id.'\');').'" title="' . $LANG->getLL('new', TRUE) . '">'.
 917													($table == 'pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
 918												'</a>';
 919							} elseif ($table=='pages' && $this->newWizards)	{
 920								$icon = '<a href="'.htmlspecialchars($this->backPath.'db_new.php?id='.$this->id.'&pagesOnly=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'" title="'.$LANG->getLL('new', TRUE).'">'.
 921													($table=='pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
 922												'</a>';
 923
 924							} else {
 925								$params = '&edit['.$table.']['.$this->id.']=new';
 926								if ($table == 'pages_language_overlay') {
 927									$params .= '&overrideVals[pages_language_overlay][doktype]=' . (int) $this->pageRow['doktype'];
 928								}
 929								$icon   = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.$LANG->getLL('new', TRUE).'">'.
 930													($table=='pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
 931												'</a>';
 932							}
 933						}
 934
 935							// If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
 936						if ($permsEdit && $this->table && is_array($currentIdList))	{
 937							$editIdList = implode(',',$currentIdList);
 938							if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
 939							$params = '&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.implode(',',$this->fieldArray).'&disHelp=1';
 940							$icon  .= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.$LANG->getLL('editShownColumns', TRUE) . '">'.
 941												t3lib_iconWorks::getSpriteIcon('actions-document-open') .
 942											'</a>';
 943						}
 944							// add an empty entry, so column count fits again after moving this into $icon
 945						$theData[$fCol] = '&nbsp;';
 946					}
 947				break;
 948				case '_AFTERCONTROL_':  // space column
 949				case '_AFTERREF_':	// space column
 950					$theData[$fCol] = '&nbsp;';
 951				break;
 952				default:			// Regular fields header:
 953					$theData[$fCol]='';
 954					if ($this->table && is_array($currentIdList))	{
 955
 956							// If the numeric clipboard pads are selected, show duplicate sorting link:
 957						if ($this->clipNumPane()) {
 958							$theData[$fCol].='<a href="'.htmlspecialchars($this->listURL('',-1).'&duplicateField='.$fCol).'" title="'.$LANG->getLL('clip_duplicates', TRUE) . '">'.
 959												t3lib_iconWorks::getSpriteIcon('actions-document-duplicates-select') .
 960											'</a>';
 961						}
 962
 963							// If the table can be edited, add link for editing THIS field for all listed records:
 964						if (!$TCA[$table]['ctrl']['readOnly'] && $permsEdit && $TCA[$table]['columns'][$fCol])	{
 965							$editIdList = implode(',',$currentIdList);
 966							if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
 967							$params='&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.$fCol.'&disHelp=1';
 968							$iTitle = sprintf($LANG->getLL('editThisColumn'),rtrim(trim($LANG->sL(t3lib_BEfunc::getItemLabel($table,$fCol))),':'));
 969							$theData[$fCol].='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.htmlspecialchars($iTitle).'">'.
 970												t3lib_iconWorks::getSpriteIcon('actions-document-open') .
 971											'</a>';
 972						}
 973					}
 974					$theData[$fCol].=$this->addSortLink($LANG->sL(t3lib_BEfunc::getItemLabel($table,$fCol,'<i>[|]</i>')),$fCol,$table);
 975				break;
 976			}
 977
 978		}
 979
 980		/**
 981		 * @hook			renderListHeader: Allows to change the contents of columns/cells of the Web>List table headers
 982		 * @date			2007-11-20
 983		 * @request		Bernhard Kraft  <krafbt@kraftb.at>
 984		 * @usage		Above each listed table in Web>List a header row is shown. Containing the labels of all shown fields and additional icons to create new records for this table or perform special clipboard tasks like mark and copy all listed records to clipboard, etc.
 985		 */
 986		if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions']))	{
 987			foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData)	{
 988				$hookObject = t3lib_div::getUserObj($classData);
 989				if(!($hookObject instanceof localRecordList_actionsHook))	{
 990					throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567855);
 991				}
 992				$theData = $hookObject->renderListHeader($table, $currentIdList, $theData, $this);
 993			}
 994		}
 995
 996			// Create and return header table row:
 997		return $this->addelement(1, $icon, $theData, ' class="c-headLine"', '');
 998	}
 999
1000	/**
1001	 * Creates a page browser for tables with many records
1002	 *
1003	 * @return	string	Navigation HTML
1004	 *
1005	 */
1006	protected function renderListNavigation() {
1007		$totalPages = ceil($this->totalItems / $this->iLimit);
1008
1009		$content = '';
1010		$returnContent = '';
1011
1012			// Show page selector if not all records fit into one page
1013		if ($totalPages > 1) {
1014			$first = $previous = $next = $last = $reload = '';
1015			$listURL = $this->listURL('', $this->table);
1016
1017				// 1 = first page
1018			$currentPage = floor(($this->firstElementNumber + 1) / $this->iLimit) + 1;
1019
1020				// Compile first, previous, next, last and refresh buttons
1021			if ($currentPage > 1) {
1022				$labelFirst = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:first');
1023
1024				$first = '<a href="' . $listURL . '&pointer=0">' .
1025					t3lib_iconWorks::getSpriteIcon('actions-view-paging-first', array('title'=> $labelFirst)) .
1026				'</a>';
1027			} else {
1028				$first = t3lib_iconWorks::getSpriteIcon('actions-view-paging-first-disabled');
1029			}
1030
1031			if (($currentPage - 1) > 0) {
1032				$labelPrevious = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:previous');
1033
1034				$previous = '<a href="' . $listURL . '&pointer=' . (($currentPage - 2) * $this->iLimit) . '">' .
1035					t3lib_iconWorks::getSpriteIcon('actions-view-paging-previous', array('title' => $labelPrevious)) .
1036					'</a>';
1037			} else {
1038				$previous = t3lib_iconWorks::getSpriteIcon('actions-view-paging-previous-disabled');
1039			}
1040
1041			if (($currentPage + 1) <= $totalPages) {
1042				$labelNext = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:next');
1043
1044				$next = '<a href="' . $listURL . '&pointer=' . (($currentPage) * $this->iLimit) . '">' .
1045					t3lib_iconWorks::getSpriteIcon('actions-view-paging-next', array('title' => $labelNext)) .
1046					'</a>';
1047			} else {
1048				$next = t3lib_iconWorks::getSpriteIcon('actions-view-paging-next-disabled');
1049			}
1050
1051			if ($currentPage != $totalPages) {
1052				$labelLast = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:last');
1053
1054				$last = '<a href="' . $listURL . '&pointer=' . (($totalPages - 1) * $this->iLimit) . '">' .
1055					t3lib_iconWorks::getSpriteIcon('actions-view-paging-last', array('title' => $labelLast)) .
1056					'</a>';
1057			} else {
1058				$last = t3lib_iconWorks::getSpriteIcon('actions-view-paging-last-disabled');
1059			}
1060
1061			$reload = '<a href="#" onclick="document.dblistForm.action=\''
1062				. $listURL . '&pointer=\'+calculatePointer(); document.dblistForm.submit(); return true;" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:reload', TRUE) . '">' .
1063					t3lib_iconWorks::getSpriteIcon('actions-system-refresh') .
1064				'</a>';
1065
1066			// Add js to traverse a page select input to a pointer value
1067			$content = '
1068<script type="text/JavaScript">
1069/*<![CDATA[*/
1070
1071	function calculatePointer(){
1072		page = document.getElementById(\'jumpPage\').value;
1073
1074		if (page > ' . $totalPages . ') {
1075			page = ' . $totalPages . ';
1076		}
1077
1078		if (page < 1) {
1079			page = 1;
1080		}
1081
1082		pointer = (page - 1) * ' . $this->iLimit . ';
1083
1084		return pointer;
1085	}
1086
1087/*]]>*/
1088</script>
1089';
1090
1091			$pageNumberInput = '<span>
1092				<input type="text" value="' . $currentPage
1093				. '" size="3" id="jumpPage" name="jumpPage" onkeyup="if (event.keyCode == Event.KEY_RETURN) { document.dblistForm.action=\'' . $listURL . '&pointer=\'+calculatePointer(); document.dblistForm.submit(); } return true;" />
1094				</span>';
1095			$pageIndicator = '<span class="pageIndicator">'
1096				. sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:pageIndicator'), $pageNumberInput, $totalPages)
1097				. '</span>';
1098
1099			if ($this->totalItems > ($this->firstElementNumber + $this->iLimit)) {
1100				$lastElementNumber = $this->firstElementNumber + $this->iLimit;
1101			} else {
1102				$lastElementNumber = $this->totalItems;
1103			}
1104			$rangeIndicator = '<span class="pageIndicator">'
1105				. sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:rangeIndicator'), $this->firstElementNumber + 1, $lastElementNumber)
1106				. '</span>';
1107
1108			$content .= '<div id="typo3-dblist-pagination">'
1109				. $first . $previous
1110				. '<span class="bar">&nbsp;</span>'
1111				. $rangeIndicator . '<span class="bar">&nbsp;</span>'
1112				. $pageIndicator . '<span class="bar">&nbsp;</span>'
1113				. $next . $last . '<span class="bar">&nbsp;</span>'
1114				. $reload
1115				. '</div>';
1116
1117			$data = Array();
1118			$titleColumn = $this->fieldArray[0];
1119			$data[$titleColumn] = $content;
1120
1121			$returnContent = $this->addElement(1, '', $data);
1122		} // end of if pages > 1
1123
1124		return $returnContent;
1125	}
1126
1127
1128
1129
1130
1131
1132	/*********************************
1133	 *
1134	 * Rendering of various elements
1135	 *
1136	 *********************************/
1137
1138	/**
1139	 * Creates the control panel for a single record in the listing.
1140	 *
1141	 * @param	string		The table
1142	 * @param	array		The record for which to make the control panel.
1143	 * @return	string		HTML table with the control panel (unless disabled)
1144	 */
1145	function makeControl($table,$row)	{
1146		global $TCA, $LANG, $SOBE, $TYPO3_CONF_VARS;
1147
1148		if ($this->dontShowClipControlPanels)	return '';
1149
1150			// Initialize:
1151		t3lib_div::loadTCA($table);
1152		$cells=array();
1153
1154			// If the listed table is 'pages' we have to request the permission settings for each page:
1155		if ($table=='pages')	{
1156			$localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid']));
1157		}
1158
1159			// This expresses the edit permissions for this particular element:
1160		$permsEdit = ($table=='pages' && ($localCalcPerms&2)) || ($table!='pages' && ($this->calcPerms&16));
1161
1162			// "Show" link (only pages and tt_content elements)
1163		if ($table=='pages' || $table=='tt_content')	{
1164			$params='&edit['.$table.']['.$row['uid'].']=edit';
1165			$cells['view']='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($table=='tt_content'?$this->id.'#'.$row['uid']:$row['uid'], $this->backPath)).'" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', TRUE).'">'.
1166						t3lib_iconWorks::getSpriteIcon('actions-document-view') .
1167					'</a>';
1168		} elseif(!$this->table) {
1169			$cells['view'] = $this->spaceIcon;
1170		}
1171
1172			// "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
1173		if ($permsEdit)	{
1174			$params='&edit['.$table.']['.$row['uid'].']=edit';
1175			$cells['edit']='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.$LANG->getLL('edit', TRUE).'">'.
1176						( $TCA[$table]['ctrl']['readOnly'] ? t3lib_iconWorks::getSpriteIcon('actions-document-open-read-only') : t3lib_iconWorks::getSpriteIcon('actions-document-open') ).
1177					'</a>';
1178		} elseif(!$this->table) {
1179			$cells['edit'] = $this->spaceIcon;
1180		}
1181
1182			// "Move" wizard link for pages/tt_content elements:
1183		if (($table=="tt_content" && $permsEdit) || ($table=='pages'))	{
1184			$cells['move']='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$this->backPath.'move_el.php?table='.$table.'&uid='.$row['uid'].'\');').'" title="'.$LANG->getLL('move_

Large files files are truncated, but you can click here to view the full file