2 /*************************************************************
5 * (c) 1999-2009 Kasper Skårhøj (kasperYYYY@typo3.com)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Include file extending recordList which extended t3lib_recordList
29 * Used specifically for the Web>List module (db_list.php)
32 * Revised for TYPO3 3.6 December/2003 by Kasper Skårhøj
35 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
38 * [CLASS/FUNCTION INDEX of SCRIPT]
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)
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)
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()
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)
70 * (This index is automatically created/updated by the extension "extdeveval")
84 * Class for rendering of Web>List module
86 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
90 class localRecordList extends recordList {
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!).
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
103 var $totalRowCount; // count of record rows in view
105 var $spaceIcon; // space icon used for alignment
108 var $pageRow=array(); // Set to the page record (see writeTop())
110 // Used to accumulate CSV lines for CSV export.
111 protected $csvLines = array();
113 var $csvOutput=FALSE; // If set, the listing is returned as CSV instead.
118 * @var t3lib_clipboard
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
125 * references of the current record
129 * @deprecated since 4.4: Use getReferenceCount instead
134 * [$tablename][$uid] = number of references to this record
138 protected $referenceCount = array();
140 var $translations; // Translations of the current record
141 var $selFieldList; // select fields for the query which fetches the translations of the current record
143 public function __construct() {
144 parent::__construct();
148 * Create the panel of buttons for submitting the form or otherwise perform operations.
150 * @return array all available buttons as an assoc. array
152 public function getButtons() {
172 // Get users permissions for this page record:
173 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms($this->pageRow);
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);
181 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module', $GLOBALS['BACK_PATH'], '', TRUE);
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);
189 //default exclusion: doktype 254 (sysfolder), 255 (recycler)
190 $noViewDokTypes = array(t3lib_pageSelect::DOKTYPE_SYSFOLDER, t3lib_pageSelect::DOKTYPE_RECYCLER);
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') .
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') .
206 // If edit permissions are set (see class.t3lib_userauthgroup.php)
207 if ($localCalcPerms&2 && !empty($this->id)) {
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') .
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') .
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') .
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')) .
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') .
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') .
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') .
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') .
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') .
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') .
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');
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') .
295 * Creates the listing of records from a single table
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.
302 function getTable($table,$id,$rowlist) {
303 global $TCA, $TYPO3_CONF_VARS;
305 // Loading all TCA details for this table:
306 t3lib_div::loadTCA($table);
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;
315 // prepare space icon
316 $this->spaceIcon = t3lib_iconWorks::getSpriteIcon('empty-empty', array('style' => 'background-position: 0 10px;'));
318 // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
319 $this->fieldArray=array();
321 $this->fieldArray[] = $titleCol; // Add title column
323 if (!t3lib_div::inList($rowlist,'_CONTROL_')) {
324 $this->fieldArray[] = '_CONTROL_';
325 $this->fieldArray[] = '_AFTERCONTROL_';
328 if ($this->showClipboard) {
329 $this->fieldArray[] = '_CLIPBOARD_';
332 if (!$this->dontShowClipControlPanels) {
333 $this->fieldArray[]='_REF_';
334 $this->fieldArray[]='_AFTERREF_';
337 if ($this->searchLevels) {
338 $this->fieldArray[]='_PATH_';
341 if ($this->localizationView && $l10nEnabled) {
342 $this->fieldArray[] = '_LOCALIZATION_';
343 $this->fieldArray[] = '_LOCALIZATION_b';
345 '.$TCA[$table]['ctrl']['languageField'].'<=0
347 '.$TCA[$table]['ctrl']['transOrigPointerField'].' = 0
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);
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';
370 $selectFields[] = 'doktype';
372 if (is_array($TCA[$table]['ctrl']['enablecolumns'])) {
373 $selectFields = array_merge($selectFields,$TCA[$table]['ctrl']['enablecolumns']);
375 if ($TCA[$table]['ctrl']['type']) {
376 $selectFields[] = $TCA[$table]['ctrl']['type'];
378 if ($TCA[$table]['ctrl']['typeicon_column']) {
379 $selectFields[] = $TCA[$table]['ctrl']['typeicon_column'];
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()
388 $selectFields[] = $TCA[$table]['ctrl']['languageField'];
389 $selectFields[] = $TCA[$table]['ctrl']['transOrigPointerField'];
391 if ($TCA[$table]['ctrl']['label_alt']) {
392 $selectFields = array_merge($selectFields,t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['label_alt'],1));
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;
400 * @hook DB-List getTable
402 * @request Malte Jansen <mail@maltejansen.de>
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);
408 if(!($hookObject instanceof t3lib_localRecordListGetTableHook)) {
409 throw new UnexpectedValueException('$hookObject must implement interface t3lib_localRecordListGetTableHook', 1195114460);
412 $hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this);
416 // Create the SQL query for selecting the elements in the listing:
417 if ($this->csvOutput) { // do not do paging when outputting as CSV
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;
429 $queryParts = $this->makeQueryArray($table, $id,$addWhere,$selFieldList); // (API function from class.db_list.inc)
432 $this->setTotalItems($queryParts); // Finding the total amount of records on the page (API function from class.db_list.inc)
437 $listOnlyInSingleTableMode = $this->listOnlyInSingleTableMode && !$this->table;
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;
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;
450 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
451 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
455 // If any records was selected, render the list:
458 // Half line is drawn between tables:
459 if (!$listOnlyInSingleTableMode) {
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_']='';
466 $out.=$this->addelement(0,'',$theData,'class="c-table-row-spacer"',$this->leftMargin);
469 // Header line is drawn
471 if ($this->disableSingleTableView) {
472 $theData[$titleCol] = '<span class="c-table">' . t3lib_BEfunc::wrapInHelp($table, '', $GLOBALS['LANG']->sL($TCA[$table]['ctrl']['title'], TRUE)) . '</span> ('.$this->totalItems.')';
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))))
479 if ($listOnlyInSingleTableMode) {
482 <td class="t3-row-header" style="width:95%;">' . t3lib_BEfunc::wrapInHelp($table, '', $theData[$titleCol]) . '</td>
485 // Render collapse button if in multi table mode
488 $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)) . '">' .
489 ($tableCollapsed ? t3lib_iconWorks::getSpriteIcon('actions-view-list-expand', array('class' => 'collapseIcon')) : t3lib_iconWorks::getSpriteIcon('actions-view-list-collapse', array('class' => 'collapseIcon'))) .
492 $out .= $this->addElement(1, $collapseIcon, $theData, ' class="t3-row-header"', '');
495 // Render table rows only if in multi table view and not collapsed or if in single table view
496 if (!$listOnlyInSingleTableMode && (!$tableCollapsed || $this->table)) {
497 // Fixing a order table for sortby tables
498 $this->currentTable = array();
499 $currentIdList = array();
500 $doSort = ($TCA[$table]['ctrl']['sortby'] && !$this->sortField);
505 // Get first two rows and initialize prevPrevUid and prevUid if on page > 1
506 if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
507 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
508 $prevPrevUid = -(int) $row['uid'];
509 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
510 $prevUid = $row['uid'];
513 $accRows = array(); // Accumulate rows here
514 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
516 // In offline workspace, look for alternative record:
517 t3lib_BEfunc::workspaceOL($table, $row, $GLOBALS['BE_USER']->workspace, TRUE);
519 if (is_array($row)) {
521 $currentIdList[] = $row['uid'];
524 $this->currentTable['prev'][$row['uid']] = $prevPrevUid;
525 $this->currentTable['next'][$prevUid] = '-'.$row['uid'];
526 $this->currentTable['prevUid'][$row['uid']] = $prevUid;
528 $prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
529 $prevUid=$row['uid'];
533 $GLOBALS['TYPO3_DB']->sql_free_result($result);
535 $this->totalRowCount = count($accRows);
538 if ($this->csvOutput) $this->initCSV();
541 $this->CBnames=array();
542 $this->duplicateStack=array();
543 $this->eCounter=$this->firstElementNumber;
548 foreach($accRows as $row) {
549 // Render item row if counter < limit
550 if ($cc < $this->iLimit) {
552 $this->translations = FALSE;
553 $iOut.= $this->renderListRow($table,$row,$cc,$titleCol,$thumbsCol);
555 // 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:
556 if ($this->localizationView && $l10nEnabled) {
557 // For each available translation, render the record:
558 if (is_array($this->translations)) {
559 foreach ($this->translations as $lRow) {
560 // $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
561 if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
562 $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);
563 $lRow = is_array($tmpRow)?$tmpRow:$lRow;
565 // In offline workspace, look for alternative record:
566 t3lib_BEfunc::workspaceOL($table, $lRow, $GLOBALS['BE_USER']->workspace, true);
567 if (is_array($lRow) && $GLOBALS['BE_USER']->checkLanguageAccess($lRow[$TCA[$table]['ctrl']['languageField']])) {
568 $currentIdList[] = $lRow['uid'];
569 $iOut.=$this->renderListRow($table,$lRow,$cc,$titleCol,$thumbsCol,18);
576 // Counter of total rows incremented:
580 // Record navigation is added to the beginning and end of the table if in single table mode
582 $iOut = $this->renderListNavigation('top') . $iOut . $this->renderListNavigation('bottom');
584 // show that there are more records than shown
585 if ($this->totalItems > $this->itemsLimitPerTable) {
586 $countOnFirstPage = $this->totalItems > $this->itemsLimitSingleTable ? $this->itemsLimitSingleTable : $this->totalItems;
587 $hasMore = ($this->totalItems > $this->itemsLimitSingleTable);
588 $iOut .= '<tr><td colspan="' . count($this->fieldArray) . '" style="padding:5px;">
589 <a href="'.htmlspecialchars($this->listURL() . '&table=' . rawurlencode($table)) . '">' .
590 '<img' . t3lib_iconWorks::skinImg($this->backPath,'gfx/pildown.gif', 'width="14" height="14"') .' alt="" />'.
591 ' <i>[1 - ' . $countOnFirstPage . ($hasMore ? '+' : '') . ']</i></a>
597 // The header row for the table is now created:
598 $out .= $this->renderListHeader($table,$currentIdList);
601 // The list of records is added after the header:
605 // ... and it is all wrapped in a table:
611 DB listing of elements: "'.htmlspecialchars($table).'"
613 <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist'.($listOnlyInSingleTableMode?' typo3-dblist-overview':'').'">
618 if ($this->csvOutput) $this->outputCSV($table); // This ends the page with exit.
626 * Rendering a single row for the list
628 * @param string Table name
629 * @param array Current record
630 * @param integer Counter, counting for each time an element is rendered (used for alternating colors)
631 * @param string Table field (column) where header value is found
632 * @param string Table field (column) where (possible) thumbnails can be found
633 * @param integer Indent from left.
634 * @return string Table row for the element
638 function renderListRow($table,$row,$cc,$titleCol,$thumbsCol,$indent=0) {
641 if (strlen($this->searchString)) { // If in search mode, make sure the preview will show the correct page
642 $id_orig = $this->id;
643 $this->id = $row['pid'];
646 if (is_array($row)) {
647 // add special classes for first and last row
649 if ($cc == 1 && $indent == 0) {
650 $rowSpecial .= ' firstcol';
652 if ($cc == $this->totalRowCount || $cc == $this->iLimit) {
653 $rowSpecial .= ' lastcol';
656 // Background color, if any:
657 if ($this->alternateBgColors) {
658 $row_bgColor = ($cc%2) ? ' class="db_list_normal'.$rowSpecial.'"' : ' class="db_list_alt'.$rowSpecial.'"';
660 $row_bgColor = ' class="db_list_normal'.$rowSpecial.'"';
662 // Overriding with versions background color if any:
663 $row_bgColor = $row['_CSSCLASS'] ? ' class="'.$row['_CSSCLASS'].'"' : $row_bgColor;
668 // The icon with link
669 $alttext = t3lib_BEfunc::getRecordIconAltText($row,$table);
670 $iconImg = t3lib_iconWorks::getSpriteIconForRecord($table, $row, array('title' => htmlspecialchars($alttext), 'style' => ($indent ? ' margin-left: ' . $indent . 'px;' : '')));
673 $theIcon = $this->clickMenuEnabled ? $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg,$table,$row['uid']) : $iconImg;
675 // Preparing and getting the data-array
677 foreach($this->fieldArray as $fCol) {
678 if ($fCol==$titleCol) {
679 $recTitle = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
680 // If the record is edit-locked by another user, we will show a little warning sign:
681 if (($lockInfo = t3lib_BEfunc::isRecordLocked($table, $row['uid']))) {
682 $warning = '<a href="#" onclick="' . htmlspecialchars('alert(' . $GLOBALS['LANG']->JScharCode($lockInfo['msg']) . '); return false;') . '" title="' . htmlspecialchars($lockInfo['msg']) . '">' .
683 t3lib_iconWorks::getSpriteIcon('status-warning-in-use') .
686 $theData[$fCol] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
688 // Render thumbsnails if a thumbnail column exists and there is content in it:
689 if ($this->thumbs && trim($row[$thumbsCol])) {
690 $theData[$fCol] .= '<br />' . $this->thumbCode($row,$table,$thumbsCol);
693 $localizationMarkerClass = '';
694 if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
695 && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0) {
696 // it's a translated record
697 $localizationMarkerClass = ' localization';
699 } elseif ($fCol == 'pid') {
700 $theData[$fCol]=$row[$fCol];
701 } elseif ($fCol == '_PATH_') {
702 $theData[$fCol]=$this->recPath($row['pid']);
703 } elseif ($fCol == '_REF_') {
704 $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
705 } elseif ($fCol == '_CONTROL_') {
706 $theData[$fCol]=$this->makeControl($table,$row);
707 } elseif ($fCol == '_AFTERCONTROL_' || $fCol == '_AFTERREF_') {
708 $theData[$fCol] = ' ';
709 } elseif ($fCol == '_CLIPBOARD_') {
710 $theData[$fCol]=$this->makeClip($table,$row);
711 } elseif ($fCol == '_LOCALIZATION_') {
712 list($lC1, $lC2) = $this->makeLocalizationPanel($table,$row);
713 $theData[$fCol] = $lC1;
714 $theData[$fCol.'b'] = $lC2;
715 } elseif ($fCol == '_LOCALIZATION_b') {
716 // Do nothing, has been done above.
718 $tmpProc = t3lib_BEfunc::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid']);
719 $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
720 if ($this->csvOutput) {
721 $row[$fCol] = t3lib_BEfunc::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
726 if (strlen($this->searchString)) { // Reset the ID if it was overwritten
727 $this->id = $id_orig;
730 // Add row to CSV list:
731 if ($this->csvOutput) {
732 $this->addToCSV($row,$table);
735 // Add classes to table cells
736 $this->addElement_tdCssClass[$titleCol] = 'col-title' . $localizationMarkerClass;
737 if (!$this->dontShowClipControlPanels) {
738 $this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
739 $this->addElement_tdCssClass['_AFTERCONTROL_'] = 'col-control-space';
740 $this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard';
742 $this->addElement_tdCssClass['_PATH_'] = 'col-path';
743 $this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa';
744 $this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb';
746 // Create element in table cells:
747 $iOut.=$this->addelement(1,$theIcon,$theData,$row_bgColor);
749 // Finally, return table row element:
755 * Write sys_refindex entries for current record to $this->references
757 * @param string Table name
758 * @param integer Uid of current record
761 * @deprecated since 4.4, will be removed in TYPO3 4.6 - Use getReferenceCount instead
763 function setReferences($table, $uid) {
764 t3lib_div::logDeprecatedFunction();
766 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
767 'tablename, recuid, field',
769 'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_refindex').
770 ' AND ref_uid='.intval($uid).
773 $this->references = $rows;
777 * Gets the number of records referencing the record with the UID $uid in
778 * the table $tableName.
780 * @param string $tableName
781 * table name of the referenced record, must not be empty
782 * @param integer $uid
783 * UID of the referenced record, must be > 0
785 * @return integer the number of references to record $uid in table
786 * $tableName, will be >= 0
788 protected function getReferenceCount($tableName, $uid) {
789 if (!isset($this->referenceCount[$tableName][$uid])) {
790 $numberOfReferences = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
793 'ref_table = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
794 $tableName, 'sys_refindex'
796 ' AND ref_uid = ' . $uid .
800 $this->referenceCount[$tableName][$uid] = $numberOfReferences;
803 return $this->referenceCount[$tableName][$uid];
807 * Rendering the header row for a table
809 * @param string Table name
810 * @param array Array of the currently displayed uids of the table
811 * @return string Header table row
815 function renderListHeader($table, $currentIdList) {
816 global $TCA, $LANG, $TYPO3_CONF_VARS;
821 // Traverse the fields:
822 foreach($this->fieldArray as $fCol) {
824 // Calculate users permissions to edit records in the table:
825 $permsEdit = $this->calcPerms & ($table=='pages'?2:16);
827 switch((string)$fCol) {
828 case '_PATH_': // Path
829 $theData[$fCol] = '<i>['.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels._PATH_',1).']</i>';
831 case '_REF_': // References
832 $theData[$fCol] = '<i>['.$LANG->sL('LLL:EXT:lang/locallang_mod_file_list.xml:c__REF_',1).']</i>';
834 case '_LOCALIZATION_': // Path
835 $theData[$fCol] = '<i>['.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels._LOCALIZATION_',1).']</i>';
837 case '_LOCALIZATION_b': // Path
838 $theData[$fCol] = $LANG->getLL('Localize',1);
840 case '_CLIPBOARD_': // Clipboard:
843 // If there are elements on the clipboard for this table, then display the "paste into" icon:
844 $elFromTable = $this->clipObj->elFromTable($table);
845 if (count($elFromTable)) {
846 $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) . '">' .
847 t3lib_iconWorks::getSpriteIcon('actions-document-paste-after') .
851 // If the numeric clipboard pads are enabled, display the control icons for that:
852 if ($this->clipObj->current!='normal') {
854 // The "select" link:
855 $cells['copyMarked']=$this->linkClipboardHeaderIcon(t3lib_iconWorks::getSpriteIcon('actions-edit-copy', array('title' => $LANG->getLL('clip_selectMarked', TRUE))), $table, 'setCB');
857 // The "edit marked" link:
858 $editIdList = implode(',',$currentIdList);
859 $editIdList = "'+editList('".$table."','".$editIdList."')+'";
860 $params='&edit['.$table.']['.$editIdList.']=edit&disHelp=1';
861 $cells['edit']='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="' . $LANG->getLL('clip_editMarked', TRUE) . '">' .
862 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
865 // The "Delete marked" link:
866 $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'])));
868 // The "Select all" link:
869 $cells['markAll'] = '<a class="cbcCheckAll" rel="" href="#" onclick="' . htmlspecialchars('checkOffCB(\'' . implode(',', $this->CBnames) . '\', this); return false;') . '" title="' . $LANG->getLL('clip_markRecords', TRUE) . '">' .
870 t3lib_iconWorks::getSpriteIcon('actions-document-select') .
876 * @hook renderListHeaderActions: Allows to change the clipboard icons of the Web>List table headers
878 * @request Bernhard Kraft <krafbt@kraftb.at>
879 * @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.
881 if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
882 foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
883 $hookObject = t3lib_div::getUserObj($classData);
884 if(!($hookObject instanceof localRecordList_actionsHook)) {
885 throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567850);
887 $cells = $hookObject->renderListHeaderActions($table, $currentIdList, $cells, $this);
890 $theData[$fCol]=implode('',$cells);
892 case '_CONTROL_': // Control panel:
893 if (!$TCA[$table]['ctrl']['readOnly']) {
895 // If new records can be created on this page, add links:
896 if ($this->calcPerms&($table=='pages'?8:16) && $this->showNewRecLink($table)) {
897 if ($table=="tt_content" && $this->newWizards) {
898 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
899 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
900 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
901 $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';
903 $icon = '<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$newContentWizScriptPath.'?id='.$this->id.'\');').'" title="' . $LANG->getLL('new', TRUE) . '">'.
904 ($table == 'pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
906 } elseif ($table=='pages' && $this->newWizards) {
907 $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).'">'.
908 ($table=='pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
912 $params = '&edit['.$table.']['.$this->id.']=new';
913 if ($table == 'pages_language_overlay') {
914 $params .= '&overrideVals[pages_language_overlay][doktype]=' . (int) $this->pageRow['doktype'];
916 $icon = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.$LANG->getLL('new', TRUE).'">'.
917 ($table=='pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
922 // If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
923 if ($permsEdit && $this->table && is_array($currentIdList)) {
924 $editIdList = implode(',',$currentIdList);
925 if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
926 $params = '&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.implode(',',$this->fieldArray).'&disHelp=1';
927 $icon .= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.$LANG->getLL('editShownColumns', TRUE) . '">'.
928 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
931 // add an empty entry, so column count fits again after moving this into $icon
932 $theData[$fCol] = ' ';
935 case '_AFTERCONTROL_': // space column
936 case '_AFTERREF_': // space column
937 $theData[$fCol] = ' ';
939 default: // Regular fields header:
941 if ($this->table && is_array($currentIdList)) {
943 // If the numeric clipboard pads are selected, show duplicate sorting link:
944 if ($this->clipNumPane()) {
945 $theData[$fCol].='<a href="'.htmlspecialchars($this->listURL('',-1).'&duplicateField='.$fCol).'" title="'.$LANG->getLL('clip_duplicates', TRUE) . '">'.
946 t3lib_iconWorks::getSpriteIcon('actions-document-duplicates-select') .
950 // If the table can be edited, add link for editing THIS field for all listed records:
951 if (!$TCA[$table]['ctrl']['readOnly'] && $permsEdit && $TCA[$table]['columns'][$fCol]) {
952 $editIdList = implode(',',$currentIdList);
953 if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
954 $params='&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.$fCol.'&disHelp=1';
955 $iTitle = sprintf($LANG->getLL('editThisColumn'),rtrim(trim($LANG->sL(t3lib_BEfunc::getItemLabel($table,$fCol))),':'));
956 $theData[$fCol].='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.htmlspecialchars($iTitle).'">'.
957 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
961 $theData[$fCol].=$this->addSortLink($LANG->sL(t3lib_BEfunc::getItemLabel($table,$fCol,'<i>[|]</i>')),$fCol,$table);
968 * @hook renderListHeader: Allows to change the contents of columns/cells of the Web>List table headers
970 * @request Bernhard Kraft <krafbt@kraftb.at>
971 * @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.
973 if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
974 foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
975 $hookObject = t3lib_div::getUserObj($classData);
976 if(!($hookObject instanceof localRecordList_actionsHook)) {
977 throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567855);
979 $theData = $hookObject->renderListHeader($table, $currentIdList, $theData, $this);
983 // Create and return header table row:
984 return $this->addelement(1, $icon, $theData, ' class="c-headLine"', '');
988 * Creates a page browser for tables with many records
990 * @param string Distinguish between 'top' and 'bottom' part of the navigation (above or below the records)
991 * @return string Navigation HTML
994 protected function renderListNavigation($renderPart = 'top') {
995 $totalPages = ceil($this->totalItems / $this->iLimit);
1000 // Show page selector if not all records fit into one page
1001 if ($totalPages > 1) {
1002 $first = $previous = $next = $last = $reload = '';
1003 $listURL = $this->listURL('', $this->table);
1006 $currentPage = floor(($this->firstElementNumber + 1) / $this->iLimit) + 1;
1008 // Compile first, previous, next, last and refresh buttons
1009 if ($currentPage > 1) {
1010 $labelFirst = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:first');
1012 $first = '<a href="' . $listURL . '&pointer=0">' .
1013 t3lib_iconWorks::getSpriteIcon('actions-view-paging-first', array('title'=> $labelFirst)) .
1016 $first = t3lib_iconWorks::getSpriteIcon('actions-view-paging-first-disabled');
1019 if (($currentPage - 1) > 0) {
1020 $labelPrevious = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:previous');
1022 $previous = '<a href="' . $listURL . '&pointer=' . (($currentPage - 2) * $this->iLimit) . '">' .
1023 t3lib_iconWorks::getSpriteIcon('actions-view-paging-previous', array('title' => $labelPrevious)) .
1026 $previous = t3lib_iconWorks::getSpriteIcon('actions-view-paging-previous-disabled');
1029 if (($currentPage + 1) <= $totalPages) {
1030 $labelNext = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:next');
1032 $next = '<a href="' . $listURL . '&pointer=' . (($currentPage) * $this->iLimit) . '">' .
1033 t3lib_iconWorks::getSpriteIcon('actions-view-paging-next', array('title' => $labelNext)) .
1036 $next = t3lib_iconWorks::getSpriteIcon('actions-view-paging-next-disabled');
1039 if ($currentPage != $totalPages) {
1040 $labelLast = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:last');
1042 $last = '<a href="' . $listURL . '&pointer=' . (($totalPages - 1) * $this->iLimit) . '">' .
1043 t3lib_iconWorks::getSpriteIcon('actions-view-paging-last', array('title' => $labelLast)) .
1046 $last = t3lib_iconWorks::getSpriteIcon('actions-view-paging-last-disabled');
1049 $reload = '<a href="#" onclick="document.dblistForm.action=\''
1050 . $listURL . '&pointer=\'+calculatePointer(document.getElementById(\'jumpPage-' . $renderPart .'\').value); document.dblistForm.submit(); return true;" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:reload', TRUE) . '">' .
1051 t3lib_iconWorks::getSpriteIcon('actions-system-refresh') .
1054 if ($renderPart === 'top') {
1055 // Add js to traverse a page select input to a pointer value
1057 <script type="text/JavaScript">
1060 function calculatePointer(page) {
1061 if (page > ' . $totalPages . ') {
1062 page = ' . $totalPages . ';
1069 pointer = (page - 1) * ' . $this->iLimit . ';
1078 $pageNumberInput = '<span>
1079 <input type="text" value="' . $currentPage
1080 . '" size="3" id="jumpPage-' . $renderPart . '" name="jumpPage-' . $renderPart . '" onkeyup="if (event.keyCode == Event.KEY_RETURN) { document.dblistForm.action=\'' . $listURL . '&pointer=\'+calculatePointer(this.value); document.dblistForm.submit(); } return true;" />
1082 $pageIndicator = '<span class="pageIndicator">'
1083 . sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:pageIndicator'), $pageNumberInput, $totalPages)
1086 if ($this->totalItems > ($this->firstElementNumber + $this->iLimit)) {
1087 $lastElementNumber = $this->firstElementNumber + $this->iLimit;
1089 $lastElementNumber = $this->totalItems;
1091 $rangeIndicator = '<span class="pageIndicator">'
1092 . sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:rangeIndicator'), $this->firstElementNumber + 1, $lastElementNumber)
1095 $content .= '<div id="typo3-dblist-pagination">'
1096 . $first . $previous
1097 . '<span class="bar"> </span>'
1098 . $rangeIndicator . '<span class="bar"> </span>'
1099 . $pageIndicator . '<span class="bar"> </span>'
1100 . $next . $last . '<span class="bar"> </span>'
1105 $titleColumn = $this->fieldArray[0];
1106 $data[$titleColumn] = $content;
1108 $returnContent = $this->addElement(1, '', $data);
1109 } // end of if pages > 1
1111 return $returnContent;
1119 /*********************************
1121 * Rendering of various elements
1123 *********************************/
1126 * Creates the control panel for a single record in the listing.
1128 * @param string The table
1129 * @param array The record for which to make the control panel.
1130 * @return string HTML table with the control panel (unless disabled)
1132 function makeControl($table,$row) {
1133 global $TCA, $LANG, $SOBE, $TYPO3_CONF_VARS;
1135 if ($this->dontShowClipControlPanels) return '';
1138 t3lib_div::loadTCA($table);
1141 // If the listed table is 'pages' we have to request the permission settings for each page:
1142 if ($table=='pages') {
1143 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid']));
1146 // This expresses the edit permissions for this particular element:
1147 $permsEdit = ($table=='pages' && ($localCalcPerms&2)) || ($table!='pages' && ($this->calcPerms&16));
1149 // "Show" link (only pages and tt_content elements)
1150 if ($table=='pages' || $table=='tt_content') {
1151 $params='&edit['.$table.']['.$row['uid'].']=edit';
1152 $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).'">'.
1153 t3lib_iconWorks::getSpriteIcon('actions-document-view') .
1155 } elseif(!$this->table) {
1156 $cells['view'] = $this->spaceIcon;
1159 // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
1161 $params='&edit['.$table.']['.$row['uid'].']=edit';
1162 $cells['edit']='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.$LANG->getLL('edit', TRUE).'">'.
1163 ( $TCA[$table]['ctrl']['readOnly'] ? t3lib_iconWorks::getSpriteIcon('actions-document-open-read-only') : t3lib_iconWorks::getSpriteIcon('actions-document-open') ).
1165 } elseif(!$this->table) {
1166 $cells['edit'] = $this->spaceIcon;
1169 // "Move" wizard link for pages/tt_content elements:
1170 if (($table=="tt_content" && $permsEdit) || ($table=='pages')) {
1171 $cells['move']='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$this->backPath.'move_el.php?table='.$table.'&uid='.$row['uid'].'\');').'" title="'.$LANG->getLL('move_' . ($table == 'tt_content' ? 'record' : 'page'), TRUE) . '">' .
1172 ($table == 'tt_content' ? t3lib_iconWorks::getSpriteIcon('actions-document-move') : t3lib_iconWorks::getSpriteIcon('actions-page-move')) .
1174 } elseif(!$this->table) {
1175 $cells['move'] = $this->spaceIcon;
1178 // If the extended control panel is enabled OR if we are seeing a single table:
1179 if ($SOBE->MOD_SETTINGS['bigControlPanel'] || $this->table) {
1181 // "Info": (All records)
1182 $cells['viewBig']='<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$table.'\', \''.$row['uid'].'\'); return false;').'" title="'.$LANG->getLL('showInfo', TRUE).'">'.
1183 t3lib_iconWorks::getSpriteIcon('actions-document-info') .
1186 // If the table is NOT a read-only table, then show these links:
1187 if (!$TCA[$table]['ctrl']['readOnly']) {
1189 // "Revert" link (history/undo)
1190 $cells['history']='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$this->backPath.'show_rechis.php?element='.rawurlencode($table.':'.$row['uid']).'\',\'#latest\');').'" title="'.$LANG->getLL('history', TRUE).'">'.
1191 t3lib_iconWorks::getSpriteIcon('actions-document-history-open') .
1195 if (t3lib_extMgm::isLoaded('version')) {
1196 $vers = t3lib_BEfunc::selectVersionsOfRecord($table, $row['uid'], 'uid', $GLOBALS['BE_USER']->workspace, FALSE, $row);
1197 if (is_array($vers)) { // If table can be versionized.
1198 $versionIcon = 'no-version';
1199 if (count($vers) > 1) {
1200 $versionIcon = count($vers) - 1;
1203 $cells['version'] = '<a href="' . htmlspecialchars($this->backPath . t3lib_extMgm::extRelPath('version') . 'cm1/index.php?table=' . rawurlencode($table) . '&uid=' . rawurlencode($row['uid'])) . '" title="' . $LANG->getLL('displayVersions', TRUE) . '">' .
1204 t3lib_iconWorks::getSpriteIcon('status-version-' . $versionIcon) .
1206 } elseif(!$this->table) {
1207 $cells['version'] = $this->spaceIcon;
1211 // "Edit Perms" link:
1212 if ($table=='pages' && $GLOBALS['BE_USER']->check('modules','web_perm')) {
1213 $cells['perms']='<a href="'.htmlspecialchars('mod/web/perm/index.php?id='.$row['uid'].'&return_id='.$row['uid'].'&edit=1').'" title="'.$LANG->getLL('permissions', TRUE).'">'.
1214 t3lib_iconWorks::getSpriteIcon('status-status-locked') .
1216 } elseif(!$this->table && $GLOBALS['BE_USER']->check('modules','web_perm')) {
1217 $cells['perms'] = $this->spaceIcon;
1220 // "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row or if default values can depend on previous record):
1221 if ($TCA[$table]['ctrl']['sortby'] || $TCA[$table]['ctrl']['useColumnsForDefaultValues']) {
1223 ($table!='pages' && ($this->calcPerms&16)) || // For NON-pages, must have permission to edit content on this parent page
1224 ($table=='pages' && ($this->calcPerms&8)) // For pages, must have permission to create new pages here.
1226 if ($this->showNewRecLink($table)) {
1227 $params='&edit['.$table.']['.(-($row['_MOVE_PLH']?$row['_MOVE_PLH_uid']:$row['uid'])).']=new';
1228 $cells['new']='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.$LANG->getLL('new'.($table=='pages'?'Page':'Record'), TRUE).'">'.
1229 ($table=='pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
1233 } elseif(!$this->table) {
1234 $cells['new'] = $this->spaceIcon;
1238 if ($permsEdit && $TCA[$table]['ctrl']['sortby'] && !$this->sortField && !$this->searchLevels) {
1239 if (isset($this->currentTable['prev'][$row['uid']])) { // Up
1240 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prev'][$row['uid']];
1241 $cells['moveUp']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('moveUp', TRUE) . '">' .
1242 t3lib_iconWorks::getSpriteIcon('actions-move-up') .
1245 $cells['moveUp'] = $this->spaceIcon;
1247 if ($this->currentTable['next'][$row['uid']]) { // Down
1248 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['next'][$row['uid']];
1249 $cells['moveDown']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('moveDown', TRUE) . '">' .
1250 t3lib_iconWorks::getSpriteIcon('actions-move-down') .
1253 $cells['moveDown'] = $this->spaceIcon;
1255 } elseif(!$this->table) {
1256 $cells['moveUp'] = $this->spaceIcon;
1257 $cells['moveDown'] = $this->spaceIcon;
1260 // "Hide/Unhide" links:
1261 $hiddenField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
1262 if ($permsEdit && $hiddenField && $TCA[$table]['columns'][$hiddenField] && (!$TCA[$table]['columns'][$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$table.':'.$hiddenField))) {
1263 if ($row[$hiddenField]) {
1264 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=0';
1265 $cells['hide']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('unHide' . ($table == 'pages' ? 'Page' : ''), TRUE) . '">' .
1266 t3lib_iconWorks::getSpriteIcon('actions-edit-unhide') .
1269 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=1';
1270 $cells['hide']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('hide' . ($table == 'pages' ? 'Page' : ''), TRUE) . '">' .
1271 t3lib_iconWorks::getSpriteIcon('actions-edit-hide') .
1274 } elseif(!$this->table) {
1275 $cells['hide'] = $this->spaceIcon;
1279 if (($table=='pages' && ($localCalcPerms&4)) || ($table!='pages' && ($this->calcPerms&16))) {
1280 $titleOrig = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
1281 $title = t3lib_div::slashJS(t3lib_div::fixed_lgd_cs($titleOrig, $this->fixedL), 1);
1282 $params = '&cmd['.$table.']['.$row['uid'].'][delete]=1';
1284 $refCountMsg = t3lib_BEfunc::referenceCount(
1287 ' ' . $GLOBALS['LANG']->sL(
1288 'LLL:EXT:lang/locallang_core.xml:labels.referencesToRecord'
1290 $this->getReferenceCount($table, $row['uid'])
1292 t3lib_BEfunc::translationCount($table, $row['uid'], ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.translationsOfRecord'));
1293 $cells['delete']='<a href="#" onclick="'.htmlspecialchars('if (confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning').' "'. $title.'" '.$refCountMsg).')) {jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');} return false;').'" title="' . $LANG->getLL('delete', TRUE) . '">' .
1294 t3lib_iconWorks::getSpriteIcon('actions-edit-delete') .
1296 } elseif(!$this->table) {
1297 $cells['delete'] = $this->spaceIcon;
1300 // "Levels" links: Moving pages into new levels...
1301 if ($permsEdit && $table=='pages' && !$this->searchLevels) {
1303 // Up (Paste as the page right after the current parent page)
1304 if ($this->calcPerms&8) {
1305 $params='&cmd['.$table.']['.$row['uid'].'][move]='.-$this->id;
1306 $cells['moveLeft']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('prevLevel', TRUE).'">'.
1307 t3lib_iconWorks::getSpriteIcon('actions-move-left') .
1310 // Down (Paste as subpage to the page right above)
1311 if ($this->currentTable['prevUid'][$row['uid']]) {
1312 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$this->currentTable['prevUid'][$row['uid']]));
1313 if ($localCalcPerms&8) {
1314 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prevUid'][$row['uid']];
1315 $cells['moveRight']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('nextLevel', TRUE).'">'.
1316 t3lib_iconWorks::getSpriteIcon('actions-move-right') .
1319 $cells['moveRight'] = $this->spaceIcon;
1322 $cells['moveRight'] = $this->spaceIcon;
1324 } elseif(!$this->table) {
1325 $cells['moveLeft'] = $this->spaceIcon;
1326 $cells['moveRight'] = $this->spaceIcon;
1333 * @hook recStatInfoHooks: Allows to insert HTML before record icons on various places
1335 * @request Kasper Skårhøj <kasper2007@typo3.com>
1337 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) {
1339 $_params = array($table,$row['uid']);
1340 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) {
1341 $stat.=t3lib_div::callUserFunction($_funcRef,$_params,$this);
1343 $cells['stat'] = $stat;
1346 * @hook makeControl: Allows to change control icons of records in list-module
1348 * @request Bernhard Kraft <krafbt@kraftb.at>
1349 * @usage This hook method gets passed the current $cells array as third parameter. This array contains values for the icons/actions generated for each record in Web>List. Each array entry is accessible by an index-key. The order of the icons is dependend on the order of those array entries.
1351 if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1352 foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1353 $hookObject = t3lib_div::getUserObj($classData);
1354 if(!($hookObject instanceof localRecordList_actionsHook)) {
1355 throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567840);
1357 $cells = $hookObject->makeControl($table, $row, $cells, $this);
1361 // Compile items into a DIV-element:
1363 <!-- CONTROL PANEL: '.$table.':'.$row['uid'].' -->
1364 <div class="typo3-DBctrl">'.implode('',$cells).'</div>';
1368 * Creates the clipboard panel for a single record in the listing.
1370 * @param string The table
1371 * @param array The record for which to make the clipboard panel.
1372 * @return string HTML table with the clipboard panel (unless disabled)
1374 function makeClip($table,$row) {
1375 global $TCA, $LANG, $TYPO3_CONF_VARS;
1377 // Return blank, if disabled:
1378 if ($this->dontShowClipControlPanels) return '';
1381 $cells['pasteAfter'] = $cells['pasteInto'] = $this->spaceIcon;
1382 //enables to hide the copy, cut and paste icons for localized records - doesn't make much sense to perform these options for them
1383 $isL10nOverlay = $this->localizationView && $table != 'pages_language_overlay' && $row[$TCA[$table]['ctrl']['transOrigPointerField']] != 0;
1384 // Return blank, if disabled:
1385 // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel:
1386 if ($this->clipObj->current=='normal') { // For the "Normal" pad:
1388 // Show copy/cut icons:
1389 $isSel = (string)$this->clipObj->isSelected($table,$row['uid']);
1390 $cells['copy'] = $isL10nOverlay ? $this->spaceIcon : '<a href="#" onclick="'.htmlspecialchars('return jumpSelf(\''.$this->clipObj->selUrlDB($table,$row['uid'],1,($isSel=='copy'),array('returnUrl'=>'')).'\');').'" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:cm.copy', TRUE).'">'.
1391 ((!$isSel=='copy') ? t3lib_iconWorks::getSpriteIcon('actions-edit-copy') : t3lib_iconWorks::getSpriteIcon('actions-edit-copy-release')) .
1393 $cells['cut'] = $isL10nOverlay ? $this->spaceIcon : '<a href="#" onclick="'.htmlspecialchars('return jumpSelf(\''.$this->clipObj->selUrlDB($table,$row['uid'],0,($isSel=='cut'),array('returnUrl'=>'')).'\');').'" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:cm.cut', TRUE).'">'.
1394 ((!$isSel=='cut') ? t3lib_iconWorks::getSpriteIcon('actions-edit-cut') : t3lib_iconWorks::getSpriteIcon('actions-edit-cut-release')) .
1397 } else { // For the numeric clipboard pads (showing checkboxes where one can select elements on/off)
1399 // Setting name of the element in ->CBnames array:
1400 $n=$table.'|'.$row['uid'];
1401 $this->CBnames[]=$n;
1403 // Check if the current element is selected and if so, prepare to set the checkbox as selected:
1404 $checked = ($this->clipObj->isSelected($table,$row['uid'])?' checked="checked"':'');
1406 // If the "duplicateField" value is set then select all elements which are duplicates...
1407 if ($this->duplicateField && isset($row[$this->duplicateField])) {
1409 if (in_array($row[$this->duplicateField], $this->duplicateStack)) {
1410 $checked=' checked="checked"';
1412 $this->duplicateStack[] = $row[$this->duplicateField];
1415 // Adding the checkbox to the panel:
1416 $cells['select'] = $isL10nOverlay ? $this->spaceIcon : '<input type="hidden" name="CBH['.$n.']" value="0" /><input type="checkbox" name="CBC['.$n.']" value="1" class="smallCheckboxes"'.$checked.' />';
1419 // Now, looking for selected elements from the current table:
1420 $elFromTable = $this->clipObj->elFromTable($table);
1421 if (count($elFromTable) && $TCA[$table]['ctrl']['sortby']) { // IF elements are found and they can be individually ordered, then add a "paste after" icon:
1422 $cells['pasteAfter'] = $isL10nOverlay ? $this->spaceIcon : '<a href="'.htmlspecialchars($this->clipObj->pasteUrl($table,-$row['uid'])).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg($table,$row,'after',$elFromTable)).'" title="'.$LANG->getLL('clip_pasteAfter', TRUE).'">'.
1423 t3lib_iconWorks::getSpriteIcon('actions-document-paste-after') .
1427 // Now, looking for elements in general:
1428 $elFromTable = $this->clipObj->elFromTable('');
1429 if ($table=='pages' && count($elFromTable)) {
1430 $cells['pasteInto']='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('',$row['uid'])).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg($table,$row,'into',$elFromTable)).'" title="'.$LANG->getLL('clip_pasteInto', TRUE).'">'.
1431 t3lib_iconWorks::getSpriteIcon('actions-document-paste-into') .
1436 * @hook makeClip: Allows to change clip-icons of records in list-module
1438 * @request Bernhard Kraft <krafbt@kraftb.at>
1439 * @usage This hook method gets passed the current $cells array as third parameter. This array contains values for the clipboard icons generated for each record in Web>List. Each array entry is accessible by an index-key. The order of the icons is dependend on the order of those array entries.
1441 if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1442 foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1443 $hookObject = t3lib_div::getUserObj($classData);
1444 if(!($hookObject instanceof localRecordList_actionsHook)) {
1445 throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567845);
1447 $cells = $hookObject->makeClip($table, $row, $cells, $this);
1451 // Compile items into a DIV-element:
1452 return ' <!-- CLIPBOARD PANEL: '.$table.':'.$row['uid'].' -->
1453 <div class="typo3-clipCtrl">'.implode('',$cells).'</div>';
1457 * Make reference count
1459 * @param string Table name
1460 * @param integer UID of record
1461 * @return string HTML-table
1463 * @deprecated since 4.4, will be removed in TYPO3 4.6 - Use getReferenceHTML() instead
1465 function makeRef($table,$uid) {
1466 t3lib_div::logDeprecatedFunction();
1468 // Compile information for title tag:
1470 if (is_array($this->references)) {
1471 foreach ($this->references as $row) {
1472 $infoData[]=$row['tablename'].':'.$row['recuid'].':'.$row['field'];
1476 return count($infoData) ? '<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$table.'\', \''.$uid.'\'); return false;').'" title="'.htmlspecialchars(t3lib_div::fixed_lgd_cs(implode(' / ',$infoData),100)).'">'.count($infoData).'</a>' : '';
1480 * Creates the HTML for a reference count for the record with the UID $uid
1481 * in the table $tableName.
1483 * @param string $tableName
1484 * table name of the referenced record, must not be empty
1485 * @param integer $uid
1486 * UID of the referenced record, must be > 0
1488 * @return string HTML of reference a link, will be empty if there are no
1489 * references to the corresponding record
1491 protected function createReferenceHtml($tableName, $uid) {
1492 $referenceCount = $this->getReferenceCount($tableName, $uid);
1493 if ($referenceCount == 0) {
1497 $queryResult = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1498 'tablename, recuid, field',
1500 'ref_table = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
1501 $tableName, 'sys_refindex'
1503 ' AND ref_uid = ' . $uid .
1510 $referenceTitles = array();
1512 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($queryResult)) {
1513 $referenceTitles[] = $row['tablename'] . ':' . $row['recuid'] .
1514 ':' . $row['field'];
1515 if (strlen(implode(' / ', $referenceTitles)) >= 100) {
1519 $GLOBALS['TYPO3_DB']->sql_free_result($queryResult);
1521 return '<a href="#" ' .
1522 'onclick="' . htmlspecialchars(
1523 'top.launchView(\'' . $tableName . '\', \'' . $uid .
1524 '\'); return false;'
1526 'title="' . htmlspecialchars(
1527 t3lib_div::fixed_lgd_cs(implode(' / ', $referenceTitles), 100)
1528 ) . '">' . $referenceCount . '</a>';
1532 * Creates the localization panel
1534 * @param string The table
1535 * @param array The record for which to make the localization panel.
1536 * @return array Array with key 0/1 with content for column 1 and 2
1538 function makeLocalizationPanel($table,$row) {
1546 $translations = $this->translateTools->translationInfo($table, $row['uid'], 0, $row, $this->selFieldList);
1547 $this->translations = $translations['translations'];
1549 // Language title and icon:
1550 $out[0] = $this->languageFlag($row[$TCA[$table]['ctrl']['languageField']]);
1552 if (is_array($translations)) {
1554 // Traverse page translations and add icon for each language that does NOT yet exist:
1556 foreach($this->pageOverlays as $lUid_OnPage => $lsysRec) {
1557 if (!isset($translations['translations'][$lUid_OnPage]) && $GLOBALS['BE_USER']->checkLanguageAccess($lUid_OnPage)) {
1558 $url = substr($this->listURL(), strlen($this->backPath));
1559 $href = $GLOBALS['SOBE']->doc->issueCommand(
1560 '&cmd[' . $table . '][' . $row['uid'] . '][localize]=' . $lUid_OnPage,
1561 $url . '&justLocalized=' . rawurlencode($table . ':' . $row['uid'] . ':' . $lUid_OnPage)
1563 $language = t3lib_BEfunc::getRecord('sys_language', $lUid_OnPage, 'title');
1564 if ($this->languageIconTitles[$lUid_OnPage]['flagIcon']) {
1565 $lC = t3lib_iconWorks::getSpriteIcon($this->languageIconTitles[$lUid_OnPage]['flagIcon']);;
1567 $lC = $this->languageIconTitles[$lUid_OnPage]['title'];
1569 $lC = '<a href="' . htmlspecialchars($href) . '" title="' . htmlspecialchars($language['title']) . '">' . $lC . '</a> ';
1575 if ($lNew) $out[1].= $lNew;
1577 $out[0] = ' '.$out[0];
1585 * Create the selector box for selecting fields to display from a table:
1587 * @param string Table name
1588 * @param boolean If true, form-fields will be wrapped around the table.
1589 * @return string HTML table with the selector box (name: displayFields['.$table.'][])
1591 function fieldSelectBox($table,$formFields=1) {
1595 t3lib_div::loadTCA($table);
1596 $formElements=array('','');
1598 $formElements=array('<form action="'.htmlspecialchars($this->listURL()).'" method="post">','</form>');
1601 // Load already selected fields, if any:
1602 $setFields=is_array($this->setFields[$table]) ? $this->setFields[$table] : array();
1604 // Request fields from table:
1605 $fields = $this->makeFieldList($table, false, true);
1607 // Add pseudo "control" fields
1610 $fields[]='_LOCALIZATION_';
1611 $fields[]='_CONTROL_';
1612 $fields[]='_CLIPBOARD_';
1614 // Create an option for each field:
1616 $opt[] = '<option value=""></option>';
1617 foreach($fields as $fN) {
1618 $fL = is_array($TCA[$table]['columns'][$fN]) ? rtrim($LANG->sL($TCA[$table]['columns'][$fN]['label']),':') : '['.$fN.']'; // Field label
1620 <option value="'.$fN.'"'.(in_array($fN,$setFields)?' selected="selected"':'').'>'.htmlspecialchars($fL).'</option>';
1623 // Compile the options into a multiple selector box:
1625 <select size="'.t3lib_div::intInRange(count($fields)+1,3,20).'" multiple="multiple" name="displayFields['.$table.'][]">'.implode('',$opt).'
1629 // Table with the field selector::
1631 '.$formElements[0].'
1634 Field selector for extended table view:
1636 <table border="0" cellpadding="0" cellspacing="0" id="typo3-dblist-fieldSelect">
1639 <td><input type="submit" name="search" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.setFields',1).'" /></td>
1656 /*********************************
1660 *********************************/
1663 * Creates a link around $string. The link contains an onclick action which submits the script with some clipboard action.
1664 * Currently, this is used for setting elements / delete elements.
1666 * @param string The HTML content to link (image/text)
1667 * @param string Table name
1668 * @param string Clipboard command (eg. "setCB" or "delete")
1669 * @param string Warning text, if any ("delete" uses this for confirmation)
1670 * @return string <a> tag wrapped link.
1672 function linkClipboardHeaderIcon($string,$table,$cmd,$warning='') {
1673 $onClickEvent = 'document.dblistForm.cmd.value=\''.$cmd.'\';document.dblistForm.cmd_table.value=\''.$table.'\';document.dblistForm.submit();';
1674 if ($warning) $onClickEvent = 'if (confirm('.$GLOBALS['LANG']->JScharCode($warning).')){'.$onClickEvent.'}';
1675 return '<a href="#" onclick="'.htmlspecialchars($onClickEvent.'return false;').'">'.$string.'</a>';
1679 * Returns true if a numeric clipboard pad is selected/active
1683 function clipNumPane() {
1684 return in_Array('_CLIPBOARD_',$this->fieldArray) && $this->clipObj->current!='normal';
1688 * Creates a sort-by link on the input string ($code).
1689 * It will automatically detect if sorting should be ascending or descending depending on $this->sortRev.
1690 * Also some fields will not be possible to sort (including if single-table-view is disabled).
1692 * @param string The string to link (text)
1693 * @param string The fieldname represented by the title ($code)
1694 * @param string Table name
1695 * @return string Linked $code variable
1697 function addSortLink($code,$field,$table) {
1699 // Certain circumstances just return string right away (no links):
1700 if ($field=='_CONTROL_' || $field=='_LOCALIZATION_' || $field=='_CLIPBOARD_' || $field=='_REF_' || $this->disableSingleTableView) return $code;
1702 // If "_PATH_" (showing record path) is selected, force sorting by pid field (will at least group the records!)
1703 if ($field=='_PATH_') $field=pid;
1705 // Create the sort link:
1706 $sortUrl = $this->listURL('',-1,'sortField,sortRev,table').'&table='.$table.'&sortField='.$field.'&sortRev='.($this->sortRev || ($this->sortField!=$field)?0:1);
1707 $sortArrow = ($this->sortField==$field?'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/red'.($this->sortRev?'up':'down').'.gif','width="7" height="4"').' alt="" />':'');
1709 // Return linked field:
1710 return '<a href="'.htmlspecialchars($sortUrl).'">'.$code.
1716 * Returns the path for a certain pid
1717 * The result is cached internally for the session, thus you can call this function as much as you like without performance problems.
1719 * @param integer The page id for which to get the path
1720 * @return string The path.
1722 function recPath($pid) {
1723 if (!isset($this->recPath_cache[$pid])) {
1724 $this->recPath_cache[$pid] = t3lib_BEfunc::getRecordPath($pid,$this->perms_clause,20);
1726 return $this->recPath_cache[$pid];
1730 * Returns true if a link for creating new records should be displayed for $table
1732 * @param string Table name
1733 * @return boolean Returns true if a link for creating new records should be displayed for $table
1734 * @see SC_db_new::showNewRecLink
1736 function showNewRecLink($table) {
1737 // No deny/allow tables are set:
1738 if (!count($this->allowedNewTables) && !count($this->deniedNewTables)) {
1740 // If table is not denied (which takes precedence over allowed tables):
1741 } elseif (!in_array($table, $this->deniedNewTables) && (!count($this->allowedNewTables) || in_array($table, $this->allowedNewTables))) {
1743 // If table is denied or allowed tables are set, but table is not part of:
1750 * Creates the "&returnUrl" parameter for links - this is used when the script links to other scripts and passes its own URL with the link so other scripts can return to the listing again.
1751 * Uses REQUEST_URI as value.
1755 function makeReturnUrl() {
1756 return '&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
1769 /************************************
1771 * CSV related functions
1773 ************************************/
1776 * Initializes internal csvLines array with the header of field names
1780 protected function initCSV() {
1781 $this->addHeaderRowToCSV();
1785 * Add header line with field names as CSV line
1789 protected function addHeaderRowToCSV() {
1790 // Add header row, control fields will be reduced inside addToCSV()
1791 $this->addToCSV(array_combine($this->fieldArray, $this->fieldArray));
1795 * Adds selected columns of one table row as CSV line.
1797 * @param array Record array, from which the values of fields found in $this->fieldArray will be listed in the CSV output.
1798 * @param string Table name @deprecated since 4.4
1801 protected function addToCSV(array $row = array(), $table = '') {
1802 $rowReducedByControlFields = self::removeControlFieldsFromFieldRow($row);
1803 $rowReducedToSelectedColumns = array_intersect_key($rowReducedByControlFields, array_flip($this->fieldArray));
1804 $this->setCsvRow($rowReducedToSelectedColumns);
1808 * Remove control fields from row for CSV export
1810 * @param array fieldNames => fieldValues
1811 * @return array Input array reduces by control fields
1813 protected static function removeControlFieldsFromFieldRow(array $row = array()) {
1814 // Possible control fields in a list row
1815 $controlFields = array(
1825 return array_diff_key($row, array_flip($controlFields));
1830 * Adds input row of values to the internal csvLines array as a CSV formatted line
1832 * @param array Array with values to be listed.
1835 function setCsvRow($csvRow) {
1836 $this->csvLines[] = t3lib_div::csvValues($csvRow);
1840 * Compiles the internal csvLines array to a csv-string and outputs it to the browser.
1841 * This function exits!
1843 * @param string Filename prefix:
1844 * @return void EXITS php execusion!
1846 function outputCSV($prefix) {
1848 // Setting filename:
1849 $filename=$prefix.'_'.date('dmy-Hi').'.csv';
1851 // Creating output header:
1852 $mimeType = 'application/octet-stream';
1853 Header('Content-Type: '.$mimeType);
1854 Header('Content-Disposition: attachment; filename='.$filename);
1856 // Printing the content of the CSV lines:
1857 echo implode(chr(13).chr(10),$this->csvLines);
1866 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc'])) {
1867 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc']);