Fixed bug #15580: Add calls to logDeprecatedFunction() for more deprecated functions...
[Packages/TYPO3.CMS.git] / typo3 / class.db_list_extra.inc
1 <?php
2 /*************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2009 Kasper Skårhøj (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$
32 * Revised for TYPO3 3.6 December/2003 by Kasper Skårhøj
33 * XHTML compliant
34 *
35 * @author Kasper Skårhøj <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 Skårhøj <kasperYYYY@typo3.com>
87 * @package TYPO3
88 * @subpackage core
89 */
90 class 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 $iOut = $this->renderListNavigation('top') . $iOut . $this->renderListNavigation('bottom');
597 } else {
598 // show that there are more records than shown
599 if ($this->totalItems > $this->itemsLimitPerTable) {
600 $countOnFirstPage = $this->totalItems > $this->itemsLimitSingleTable ? $this->itemsLimitSingleTable : $this->totalItems;
601 $hasMore = ($this->totalItems > $this->itemsLimitSingleTable);
602 $iOut .= '<tr><td colspan="' . count($this->fieldArray) . '" style="padding:5px;">
603 <a href="'.htmlspecialchars($this->listURL() . '&table=' . rawurlencode($table)) . '">' .
604 '<img' . t3lib_iconWorks::skinImg($this->backPath,'gfx/pildown.gif', 'width="14" height="14"') .' alt="" />'.
605 ' <i>[1 - ' . $countOnFirstPage . ($hasMore ? '+' : '') . ']</i></a>
606 </td></tr>';
607 }
608
609 }
610
611 // The header row for the table is now created:
612 $out .= $this->renderListHeader($table,$currentIdList);
613 }
614
615 // The list of records is added after the header:
616 $out .= $iOut;
617 unset($iOut);
618
619 // ... and it is all wrapped in a table:
620 $out='
621
622
623
624 <!--
625 DB listing of elements: "'.htmlspecialchars($table).'"
626 -->
627 <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist'.($listOnlyInSingleTableMode?' typo3-dblist-overview':'').'">
628 '.$out.'
629 </table>';
630
631 // Output csv if...
632 if ($this->csvOutput) $this->outputCSV($table); // This ends the page with exit.
633 }
634
635 // Return content:
636 return $out;
637 }
638
639 /**
640 * Rendering a single row for the list
641 *
642 * @param string Table name
643 * @param array Current record
644 * @param integer Counter, counting for each time an element is rendered (used for alternating colors)
645 * @param string Table field (column) where header value is found
646 * @param string Table field (column) where (possible) thumbnails can be found
647 * @param integer Indent from left.
648 * @return string Table row for the element
649 * @access private
650 * @see getTable()
651 */
652 function renderListRow($table,$row,$cc,$titleCol,$thumbsCol,$indent=0) {
653 $iOut = '';
654
655 if (strlen($this->searchString)) { // If in search mode, make sure the preview will show the correct page
656 $id_orig = $this->id;
657 $this->id = $row['pid'];
658 }
659
660 if (is_array($row)) {
661 // add special classes for first and last row
662 $rowSpecial = '';
663 if ($cc == 1 && $indent == 0) {
664 $rowSpecial .= ' firstcol';
665 }
666 if ($cc == $this->totalRowCount || $cc == $this->iLimit) {
667 $rowSpecial .= ' lastcol';
668 }
669
670 // Background color, if any:
671 if ($this->alternateBgColors) {
672 $row_bgColor = ($cc%2) ? ' class="db_list_normal'.$rowSpecial.'"' : ' class="db_list_alt'.$rowSpecial.'"';
673 } else {
674 $row_bgColor = ' class="db_list_normal'.$rowSpecial.'"';
675 }
676 // Overriding with versions background color if any:
677 $row_bgColor = $row['_CSSCLASS'] ? ' class="'.$row['_CSSCLASS'].'"' : $row_bgColor;
678
679 // Incr. counter.
680 $this->counter++;
681
682 // The icon with link
683 $alttext = t3lib_BEfunc::getRecordIconAltText($row,$table);
684 $iconImg = t3lib_iconWorks::getSpriteIconForRecord($table, $row, array('title' => htmlspecialchars($alttext), 'style' => ($indent ? ' margin-left: ' . $indent . 'px;' : '')));
685
686
687 $theIcon = $this->clickMenuEnabled ? $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg,$table,$row['uid']) : $iconImg;
688
689 // Preparing and getting the data-array
690 $theData = Array();
691 foreach($this->fieldArray as $fCol) {
692 if ($fCol==$titleCol) {
693 $recTitle = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
694 // If the record is edit-locked by another user, we will show a little warning sign:
695 if (($lockInfo = t3lib_BEfunc::isRecordLocked($table, $row['uid']))) {
696 $warning = '<a href="#" onclick="' . htmlspecialchars('alert(' . $GLOBALS['LANG']->JScharCode($lockInfo['msg']) . '); return false;') . '" title="' . htmlspecialchars($lockInfo['msg']) . '">' .
697 t3lib_iconWorks::getSpriteIcon('status-warning-in-use') .
698 '</a>';
699 }
700 $theData[$fCol] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
701
702 // Render thumbsnails if a thumbnail column exists and there is content in it:
703 if ($this->thumbs && trim($row[$thumbsCol])) {
704 $theData[$fCol] .= '<br />' . $this->thumbCode($row,$table,$thumbsCol);
705 }
706
707 $localizationMarkerClass = '';
708 if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
709 && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0) {
710 // it's a translated record
711 $localizationMarkerClass = ' localization';
712 }
713 } elseif ($fCol == 'pid') {
714 $theData[$fCol]=$row[$fCol];
715 } elseif ($fCol == '_PATH_') {
716 $theData[$fCol]=$this->recPath($row['pid']);
717 } elseif ($fCol == '_REF_') {
718 $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
719 } elseif ($fCol == '_CONTROL_') {
720 $theData[$fCol]=$this->makeControl($table,$row);
721 } elseif ($fCol == '_AFTERCONTROL_' || $fCol == '_AFTERREF_') {
722 $theData[$fCol] = '&nbsp;';
723 } elseif ($fCol == '_CLIPBOARD_') {
724 $theData[$fCol]=$this->makeClip($table,$row);
725 } elseif ($fCol == '_LOCALIZATION_') {
726 list($lC1, $lC2) = $this->makeLocalizationPanel($table,$row);
727 $theData[$fCol] = $lC1;
728 $theData[$fCol.'b'] = $lC2;
729 } elseif ($fCol == '_LOCALIZATION_b') {
730 // Do nothing, has been done above.
731 } else {
732 $tmpProc = t3lib_BEfunc::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid']);
733 $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
734 if ($this->csvOutput) {
735 $row[$fCol] = t3lib_BEfunc::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
736 }
737 }
738 }
739
740 if (strlen($this->searchString)) { // Reset the ID if it was overwritten
741 $this->id = $id_orig;
742 }
743
744 // Add row to CSV list:
745 if ($this->csvOutput) {
746 $this->addToCSV($row,$table);
747 }
748
749 // Add classes to table cells
750 $this->addElement_tdCssClass[$titleCol] = 'col-title' . $localizationMarkerClass;
751 if (!$this->dontShowClipControlPanels) {
752 $this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
753 $this->addElement_tdCssClass['_AFTERCONTROL_'] = 'col-control-space';
754 $this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard';
755 }
756 $this->addElement_tdCssClass['_PATH_'] = 'col-path';
757 $this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa';
758 $this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb';
759
760 // Create element in table cells:
761 $iOut.=$this->addelement(1,$theIcon,$theData,$row_bgColor);
762
763 // Finally, return table row element:
764 return $iOut;
765 }
766 }
767
768 /**
769 * Write sys_refindex entries for current record to $this->references
770 *
771 * @param string Table name
772 * @param integer Uid of current record
773 * @return void
774 *
775 * @deprecated since 4.4, will be removed in TYPO3 4.6 - Use getReferenceCount instead
776 */
777 function setReferences($table, $uid) {
778 t3lib_div::logDeprecatedFunction();
779
780 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
781 'tablename, recuid, field',
782 'sys_refindex',
783 'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_refindex').
784 ' AND ref_uid='.intval($uid).
785 ' AND deleted=0'
786 );
787 $this->references = $rows;
788 }
789
790 /**
791 * Gets the number of records referencing the record with the UID $uid in
792 * the table $tableName.
793 *
794 * @param string $tableName
795 * table name of the referenced record, must not be empty
796 * @param integer $uid
797 * UID of the referenced record, must be > 0
798 *
799 * @return integer the number of references to record $uid in table
800 * $tableName, will be >= 0
801 */
802 protected function getReferenceCount($tableName, $uid) {
803 if (!isset($this->referenceCount[$tableName][$uid])) {
804 $numberOfReferences = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
805 '*',
806 'sys_refindex',
807 'ref_table = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
808 $tableName, 'sys_refindex'
809 ) .
810 ' AND ref_uid = ' . $uid .
811 ' AND deleted = 0'
812 );
813
814 $this->referenceCount[$tableName][$uid] = $numberOfReferences;
815 }
816
817 return $this->referenceCount[$tableName][$uid];
818 }
819
820 /**
821 * Rendering the header row for a table
822 *
823 * @param string Table name
824 * @param array Array of the currently displayed uids of the table
825 * @return string Header table row
826 * @access private
827 * @see getTable()
828 */
829 function renderListHeader($table, $currentIdList) {
830 global $TCA, $LANG, $TYPO3_CONF_VARS;
831
832 // Init:
833 $theData = Array();
834
835 // Traverse the fields:
836 foreach($this->fieldArray as $fCol) {
837
838 // Calculate users permissions to edit records in the table:
839 $permsEdit = $this->calcPerms & ($table=='pages'?2:16);
840
841 switch((string)$fCol) {
842 case '_PATH_': // Path
843 $theData[$fCol] = '<i>['.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels._PATH_',1).']</i>';
844 break;
845 case '_REF_': // References
846 $theData[$fCol] = '<i>['.$LANG->sL('LLL:EXT:lang/locallang_mod_file_list.xml:c__REF_',1).']</i>';
847 break;
848 case '_LOCALIZATION_': // Path
849 $theData[$fCol] = '<i>['.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels._LOCALIZATION_',1).']</i>';
850 break;
851 case '_LOCALIZATION_b': // Path
852 $theData[$fCol] = $LANG->getLL('Localize',1);
853 break;
854 case '_CLIPBOARD_': // Clipboard:
855 $cells=array();
856
857 // If there are elements on the clipboard for this table, then display the "paste into" icon:
858 $elFromTable = $this->clipObj->elFromTable($table);
859 if (count($elFromTable)) {
860 $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) . '">' .
861 t3lib_iconWorks::getSpriteIcon('actions-document-paste-after') .
862 '</a>';
863 }
864
865 // If the numeric clipboard pads are enabled, display the control icons for that:
866 if ($this->clipObj->current!='normal') {
867
868 // The "select" link:
869 $cells['copyMarked']=$this->linkClipboardHeaderIcon(t3lib_iconWorks::getSpriteIcon('actions-edit-copy', array('title' => $LANG->getLL('clip_selectMarked', TRUE))), $table, 'setCB');
870
871 // The "edit marked" link:
872 $editIdList = implode(',',$currentIdList);
873 $editIdList = "'+editList('".$table."','".$editIdList."')+'";
874 $params='&edit['.$table.']['.$editIdList.']=edit&disHelp=1';
875 $cells['edit']='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="' . $LANG->getLL('clip_editMarked', TRUE) . '">' .
876 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
877 '</a>';
878
879 // The "Delete marked" link:
880 $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'])));
881
882 // The "Select all" link:
883 $cells['markAll'] = '<a class="cbcCheckAll" rel="" href="#" onclick="' . htmlspecialchars('checkOffCB(\'' . implode(',', $this->CBnames) . '\', this); return false;') . '" title="' . $LANG->getLL('clip_markRecords', TRUE) . '">' .
884 t3lib_iconWorks::getSpriteIcon('actions-document-select') .
885 '</a>';
886 } else {
887 $cells['empty']='';
888 }
889 /**
890 * @hook renderListHeaderActions: Allows to change the clipboard icons of the Web>List table headers
891 * @date 2007-11-20
892 * @request Bernhard Kraft <krafbt@kraftb.at>
893 * @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.
894 */
895 if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
896 foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
897 $hookObject = t3lib_div::getUserObj($classData);
898 if(!($hookObject instanceof localRecordList_actionsHook)) {
899 throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567850);
900 }
901 $cells = $hookObject->renderListHeaderActions($table, $currentIdList, $cells, $this);
902 }
903 }
904 $theData[$fCol]=implode('',$cells);
905 break;
906 case '_CONTROL_': // Control panel:
907 if (!$TCA[$table]['ctrl']['readOnly']) {
908
909 // If new records can be created on this page, add links:
910 if ($this->calcPerms&($table=='pages'?8:16) && $this->showNewRecLink($table)) {
911 if ($table=="tt_content" && $this->newWizards) {
912 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
913 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
914 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
915 $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';
916
917 $icon = '<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$newContentWizScriptPath.'?id='.$this->id.'\');').'" title="' . $LANG->getLL('new', TRUE) . '">'.
918 ($table == 'pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
919 '</a>';
920 } elseif ($table=='pages' && $this->newWizards) {
921 $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).'">'.
922 ($table=='pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
923 '</a>';
924
925 } else {
926 $params = '&edit['.$table.']['.$this->id.']=new';
927 if ($table == 'pages_language_overlay') {
928 $params .= '&overrideVals[pages_language_overlay][doktype]=' . (int) $this->pageRow['doktype'];
929 }
930 $icon = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.$LANG->getLL('new', TRUE).'">'.
931 ($table=='pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
932 '</a>';
933 }
934 }
935
936 // If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
937 if ($permsEdit && $this->table && is_array($currentIdList)) {
938 $editIdList = implode(',',$currentIdList);
939 if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
940 $params = '&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.implode(',',$this->fieldArray).'&disHelp=1';
941 $icon .= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.$LANG->getLL('editShownColumns', TRUE) . '">'.
942 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
943 '</a>';
944 }
945 // add an empty entry, so column count fits again after moving this into $icon
946 $theData[$fCol] = '&nbsp;';
947 }
948 break;
949 case '_AFTERCONTROL_': // space column
950 case '_AFTERREF_': // space column
951 $theData[$fCol] = '&nbsp;';
952 break;
953 default: // Regular fields header:
954 $theData[$fCol]='';
955 if ($this->table && is_array($currentIdList)) {
956
957 // If the numeric clipboard pads are selected, show duplicate sorting link:
958 if ($this->clipNumPane()) {
959 $theData[$fCol].='<a href="'.htmlspecialchars($this->listURL('',-1).'&duplicateField='.$fCol).'" title="'.$LANG->getLL('clip_duplicates', TRUE) . '">'.
960 t3lib_iconWorks::getSpriteIcon('actions-document-duplicates-select') .
961 '</a>';
962 }
963
964 // If the table can be edited, add link for editing THIS field for all listed records:
965 if (!$TCA[$table]['ctrl']['readOnly'] && $permsEdit && $TCA[$table]['columns'][$fCol]) {
966 $editIdList = implode(',',$currentIdList);
967 if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
968 $params='&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.$fCol.'&disHelp=1';
969 $iTitle = sprintf($LANG->getLL('editThisColumn'),rtrim(trim($LANG->sL(t3lib_BEfunc::getItemLabel($table,$fCol))),':'));
970 $theData[$fCol].='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.htmlspecialchars($iTitle).'">'.
971 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
972 '</a>';
973 }
974 }
975 $theData[$fCol].=$this->addSortLink($LANG->sL(t3lib_BEfunc::getItemLabel($table,$fCol,'<i>[|]</i>')),$fCol,$table);
976 break;
977 }
978
979 }
980
981 /**
982 * @hook renderListHeader: Allows to change the contents of columns/cells of the Web>List table headers
983 * @date 2007-11-20
984 * @request Bernhard Kraft <krafbt@kraftb.at>
985 * @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.
986 */
987 if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
988 foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
989 $hookObject = t3lib_div::getUserObj($classData);
990 if(!($hookObject instanceof localRecordList_actionsHook)) {
991 throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567855);
992 }
993 $theData = $hookObject->renderListHeader($table, $currentIdList, $theData, $this);
994 }
995 }
996
997 // Create and return header table row:
998 return $this->addelement(1, $icon, $theData, ' class="c-headLine"', '');
999 }
1000
1001 /**
1002 * Creates a page browser for tables with many records
1003 *
1004 * @param string Distinguish between 'top' and 'bottom' part of the navigation (above or below the records)
1005 * @return string Navigation HTML
1006 *
1007 */
1008 protected function renderListNavigation($renderPart = 'top') {
1009 $totalPages = ceil($this->totalItems / $this->iLimit);
1010
1011 $content = '';
1012 $returnContent = '';
1013
1014 // Show page selector if not all records fit into one page
1015 if ($totalPages > 1) {
1016 $first = $previous = $next = $last = $reload = '';
1017 $listURL = $this->listURL('', $this->table);
1018
1019 // 1 = first page
1020 $currentPage = floor(($this->firstElementNumber + 1) / $this->iLimit) + 1;
1021
1022 // Compile first, previous, next, last and refresh buttons
1023 if ($currentPage > 1) {
1024 $labelFirst = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:first');
1025
1026 $first = '<a href="' . $listURL . '&pointer=0">' .
1027 t3lib_iconWorks::getSpriteIcon('actions-view-paging-first', array('title'=> $labelFirst)) .
1028 '</a>';
1029 } else {
1030 $first = t3lib_iconWorks::getSpriteIcon('actions-view-paging-first-disabled');
1031 }
1032
1033 if (($currentPage - 1) > 0) {
1034 $labelPrevious = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:previous');
1035
1036 $previous = '<a href="' . $listURL . '&pointer=' . (($currentPage - 2) * $this->iLimit) . '">' .
1037 t3lib_iconWorks::getSpriteIcon('actions-view-paging-previous', array('title' => $labelPrevious)) .
1038 '</a>';
1039 } else {
1040 $previous = t3lib_iconWorks::getSpriteIcon('actions-view-paging-previous-disabled');
1041 }
1042
1043 if (($currentPage + 1) <= $totalPages) {
1044 $labelNext = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:next');
1045
1046 $next = '<a href="' . $listURL . '&pointer=' . (($currentPage) * $this->iLimit) . '">' .
1047 t3lib_iconWorks::getSpriteIcon('actions-view-paging-next', array('title' => $labelNext)) .
1048 '</a>';
1049 } else {
1050 $next = t3lib_iconWorks::getSpriteIcon('actions-view-paging-next-disabled');
1051 }
1052
1053 if ($currentPage != $totalPages) {
1054 $labelLast = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:last');
1055
1056 $last = '<a href="' . $listURL . '&pointer=' . (($totalPages - 1) * $this->iLimit) . '">' .
1057 t3lib_iconWorks::getSpriteIcon('actions-view-paging-last', array('title' => $labelLast)) .
1058 '</a>';
1059 } else {
1060 $last = t3lib_iconWorks::getSpriteIcon('actions-view-paging-last-disabled');
1061 }
1062
1063 $reload = '<a href="#" onclick="document.dblistForm.action=\''
1064 . $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) . '">' .
1065 t3lib_iconWorks::getSpriteIcon('actions-system-refresh') .
1066 '</a>';
1067
1068 if ($renderPart === 'top') {
1069 // Add js to traverse a page select input to a pointer value
1070 $content = '
1071 <script type="text/JavaScript">
1072 /*<![CDATA[*/
1073
1074 function calculatePointer(page) {
1075 if (page > ' . $totalPages . ') {
1076 page = ' . $totalPages . ';
1077 }
1078
1079 if (page < 1) {
1080 page = 1;
1081 }
1082
1083 pointer = (page - 1) * ' . $this->iLimit . ';
1084
1085 return pointer;
1086 }
1087
1088 /*]]>*/
1089 </script>
1090 ';
1091 }
1092 $pageNumberInput = '<span>
1093 <input type="text" value="' . $currentPage
1094 . '" 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;" />
1095 </span>';
1096 $pageIndicator = '<span class="pageIndicator">'
1097 . sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:pageIndicator'), $pageNumberInput, $totalPages)
1098 . '</span>';
1099
1100 if ($this->totalItems > ($this->firstElementNumber + $this->iLimit)) {
1101 $lastElementNumber = $this->firstElementNumber + $this->iLimit;
1102 } else {
1103 $lastElementNumber = $this->totalItems;
1104 }
1105 $rangeIndicator = '<span class="pageIndicator">'
1106 . sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:rangeIndicator'), $this->firstElementNumber + 1, $lastElementNumber)
1107 . '</span>';
1108
1109 $content .= '<div id="typo3-dblist-pagination">'
1110 . $first . $previous
1111 . '<span class="bar">&nbsp;</span>'
1112 . $rangeIndicator . '<span class="bar">&nbsp;</span>'
1113 . $pageIndicator . '<span class="bar">&nbsp;</span>'
1114 . $next . $last . '<span class="bar">&nbsp;</span>'
1115 . $reload
1116 . '</div>';
1117
1118 $data = Array();
1119 $titleColumn = $this->fieldArray[0];
1120 $data[$titleColumn] = $content;
1121
1122 $returnContent = $this->addElement(1, '', $data);
1123 } // end of if pages > 1
1124
1125 return $returnContent;
1126 }
1127
1128
1129
1130
1131
1132
1133 /*********************************
1134 *
1135 * Rendering of various elements
1136 *
1137 *********************************/
1138
1139 /**
1140 * Creates the control panel for a single record in the listing.
1141 *
1142 * @param string The table
1143 * @param array The record for which to make the control panel.
1144 * @return string HTML table with the control panel (unless disabled)
1145 */
1146 function makeControl($table,$row) {
1147 global $TCA, $LANG, $SOBE, $TYPO3_CONF_VARS;
1148
1149 if ($this->dontShowClipControlPanels) return '';
1150
1151 // Initialize:
1152 t3lib_div::loadTCA($table);
1153 $cells=array();
1154
1155 // If the listed table is 'pages' we have to request the permission settings for each page:
1156 if ($table=='pages') {
1157 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid']));
1158 }
1159
1160 // This expresses the edit permissions for this particular element:
1161 $permsEdit = ($table=='pages' && ($localCalcPerms&2)) || ($table!='pages' && ($this->calcPerms&16));
1162
1163 // "Show" link (only pages and tt_content elements)
1164 if ($table=='pages' || $table=='tt_content') {
1165 $params='&edit['.$table.']['.$row['uid'].']=edit';
1166 $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).'">'.
1167 t3lib_iconWorks::getSpriteIcon('actions-document-view') .
1168 '</a>';
1169 } elseif(!$this->table) {
1170 $cells['view'] = $this->spaceIcon;
1171 }
1172
1173 // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
1174 if ($permsEdit) {
1175 $params='&edit['.$table.']['.$row['uid'].']=edit';
1176 $cells['edit']='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.$LANG->getLL('edit', TRUE).'">'.
1177 ( $TCA[$table]['ctrl']['readOnly'] ? t3lib_iconWorks::getSpriteIcon('actions-document-open-read-only') : t3lib_iconWorks::getSpriteIcon('actions-document-open') ).
1178 '</a>';
1179 } elseif(!$this->table) {
1180 $cells['edit'] = $this->spaceIcon;
1181 }
1182
1183 // "Move" wizard link for pages/tt_content elements:
1184 if (($table=="tt_content" && $permsEdit) || ($table=='pages')) {
1185 $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) . '">' .
1186 ($table == 'tt_content' ? t3lib_iconWorks::getSpriteIcon('actions-document-move') : t3lib_iconWorks::getSpriteIcon('actions-page-move')) .
1187 '</a>';
1188 } elseif(!$this->table) {
1189 $cells['move'] = $this->spaceIcon;
1190 }
1191
1192 // If the extended control panel is enabled OR if we are seeing a single table:
1193 if ($SOBE->MOD_SETTINGS['bigControlPanel'] || $this->table) {
1194
1195 // "Info": (All records)
1196 $cells['viewBig']='<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$table.'\', \''.$row['uid'].'\'); return false;').'" title="'.$LANG->getLL('showInfo', TRUE).'">'.
1197 t3lib_iconWorks::getSpriteIcon('actions-document-info') .
1198 '</a>';
1199
1200 // If the table is NOT a read-only table, then show these links:
1201 if (!$TCA[$table]['ctrl']['readOnly']) {
1202
1203 // "Revert" link (history/undo)
1204 $cells['history']='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$this->backPath.'show_rechis.php?element='.rawurlencode($table.':'.$row['uid']).'\',\'#latest\');').'" title="'.$LANG->getLL('history', TRUE).'">'.
1205 t3lib_iconWorks::getSpriteIcon('actions-document-history-open') .
1206 '</a>';
1207
1208 // Versioning:
1209 if (t3lib_extMgm::isLoaded('version')) {
1210 $vers = t3lib_BEfunc::selectVersionsOfRecord($table, $row['uid'], 'uid', $GLOBALS['BE_USER']->workspace, FALSE, $row);
1211 if (is_array($vers)) { // If table can be versionized.
1212 $versionIcon = 'no-version';
1213 if (count($vers) > 1) {
1214 $versionIcon = count($vers) - 1;
1215 }
1216
1217 $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) . '">' .
1218 t3lib_iconWorks::getSpriteIcon('status-version-' . $versionIcon) .
1219 '</a>';
1220 } elseif(!$this->table) {
1221 $cells['version'] = $this->spaceIcon;
1222 }
1223 }
1224
1225 // "Edit Perms" link:
1226 if ($table=='pages' && $GLOBALS['BE_USER']->check('modules','web_perm')) {
1227 $cells['perms']='<a href="'.htmlspecialchars('mod/web/perm/index.php?id='.$row['uid'].'&return_id='.$row['uid'].'&edit=1').'" title="'.$LANG->getLL('permissions', TRUE).'">'.
1228 t3lib_iconWorks::getSpriteIcon('status-status-locked') .
1229 '</a>';
1230 } elseif(!$this->table && $GLOBALS['BE_USER']->check('modules','web_perm')) {
1231 $cells['perms'] = $this->spaceIcon;
1232 }
1233
1234 // "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):
1235 if ($TCA[$table]['ctrl']['sortby'] || $TCA[$table]['ctrl']['useColumnsForDefaultValues']) {
1236 if (
1237 ($table!='pages' && ($this->calcPerms&16)) || // For NON-pages, must have permission to edit content on this parent page
1238 ($table=='pages' && ($this->calcPerms&8)) // For pages, must have permission to create new pages here.
1239 ) {
1240 if ($this->showNewRecLink($table)) {
1241 $params='&edit['.$table.']['.(-($row['_MOVE_PLH']?$row['_MOVE_PLH_uid']:$row['uid'])).']=new';
1242 $cells['new']='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.$LANG->getLL('new'.($table=='pages'?'Page':'Record'), TRUE).'">'.
1243 ($table=='pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
1244 '</a>';
1245 }
1246 }
1247 } elseif(!$this->table) {
1248 $cells['new'] = $this->spaceIcon;
1249 }
1250
1251 // "Up/Down" links
1252 if ($permsEdit && $TCA[$table]['ctrl']['sortby'] && !$this->sortField && !$this->searchLevels) {
1253 if (isset($this->currentTable['prev'][$row['uid']])) { // Up
1254 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prev'][$row['uid']];
1255 $cells['moveUp']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('moveUp', TRUE) . '">' .
1256 t3lib_iconWorks::getSpriteIcon('actions-move-up') .
1257 '</a>';
1258 } else {
1259 $cells['moveUp'] = $this->spaceIcon;
1260 }
1261 if ($this->currentTable['next'][$row['uid']]) { // Down
1262 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['next'][$row['uid']];
1263 $cells['moveDown']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('moveDown', TRUE) . '">' .
1264 t3lib_iconWorks::getSpriteIcon('actions-move-down') .
1265 '</a>';
1266 } else {
1267 $cells['moveDown'] = $this->spaceIcon;
1268 }
1269 } elseif(!$this->table) {
1270 $cells['moveUp'] = $this->spaceIcon;
1271 $cells['moveDown'] = $this->spaceIcon;
1272 }
1273
1274 // "Hide/Unhide" links:
1275 $hiddenField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
1276 if ($permsEdit && $hiddenField && $TCA[$table]['columns'][$hiddenField] && (!$TCA[$table]['columns'][$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$table.':'.$hiddenField))) {
1277 if ($row[$hiddenField]) {
1278 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=0';
1279 $cells['hide']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('unHide' . ($table == 'pages' ? 'Page' : ''), TRUE) . '">' .
1280 t3lib_iconWorks::getSpriteIcon('actions-edit-unhide') .
1281 '</a>';
1282 } else {
1283 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=1';
1284 $cells['hide']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('hide' . ($table == 'pages' ? 'Page' : ''), TRUE) . '">' .
1285 t3lib_iconWorks::getSpriteIcon('actions-edit-hide') .
1286 '</a>';
1287 }
1288 } elseif(!$this->table) {
1289 $cells['hide'] = $this->spaceIcon;
1290 }
1291
1292 // "Delete" link:
1293 if (($table=='pages' && ($localCalcPerms&4)) || ($table!='pages' && ($this->calcPerms&16))) {
1294 $titleOrig = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
1295 $title = t3lib_div::slashJS(t3lib_div::fixed_lgd_cs($titleOrig, $this->fixedL), 1);
1296 $params = '&cmd['.$table.']['.$row['uid'].'][delete]=1';
1297
1298 $refCountMsg = t3lib_BEfunc::referenceCount(
1299 $table,
1300 $row['uid'],
1301 ' ' . $GLOBALS['LANG']->sL(
1302 'LLL:EXT:lang/locallang_core.xml:labels.referencesToRecord'
1303 ),
1304 $this->getReferenceCount($table, $row['uid'])
1305 ) .
1306 t3lib_BEfunc::translationCount($table, $row['uid'], ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.translationsOfRecord'));
1307 $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) . '">' .
1308 t3lib_iconWorks::getSpriteIcon('actions-edit-delete') .
1309 '</a>';
1310 } elseif(!$this->table) {
1311 $cells['delete'] = $this->spaceIcon;
1312 }
1313
1314 // "Levels" links: Moving pages into new levels...
1315 if ($permsEdit && $table=='pages' && !$this->searchLevels) {
1316
1317 // Up (Paste as the page right after the current parent page)
1318 if ($this->calcPerms&8) {
1319 $params='&cmd['.$table.']['.$row['uid'].'][move]='.-$this->id;
1320 $cells['moveLeft']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('prevLevel', TRUE).'">'.
1321 t3lib_iconWorks::getSpriteIcon('actions-move-left') .
1322 '</a>';
1323 }
1324 // Down (Paste as subpage to the page right above)
1325 if ($this->currentTable['prevUid'][$row['uid']]) {
1326 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$this->currentTable['prevUid'][$row['uid']]));
1327 if ($localCalcPerms&8) {
1328 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prevUid'][$row['uid']];
1329 $cells['moveRight']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'" title="'.$LANG->getLL('nextLevel', TRUE).'">'.
1330 t3lib_iconWorks::getSpriteIcon('actions-move-right') .
1331 '</a>';
1332 } else {
1333 $cells['moveRight'] = $this->spaceIcon;
1334 }
1335 } else {
1336 $cells['moveRight'] = $this->spaceIcon;
1337 }
1338 } elseif(!$this->table) {
1339 $cells['moveLeft'] = $this->spaceIcon;
1340 $cells['moveRight'] = $this->spaceIcon;
1341 }
1342 }
1343 }
1344
1345
1346 /**
1347 * @hook recStatInfoHooks: Allows to insert HTML before record icons on various places
1348 * @date 2007-09-22
1349 * @request Kasper Skårhøj <kasper2007@typo3.com>
1350 */
1351 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) {
1352 $stat='';
1353 $_params = array($table,$row['uid']);
1354 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) {
1355 $stat.=t3lib_div::callUserFunction($_funcRef,$_params,$this);
1356 }
1357 $cells['stat'] = $stat;
1358 }
1359 /**
1360 * @hook makeControl: Allows to change control icons of records in list-module
1361 * @date 2007-11-20
1362 * @request Bernhard Kraft <krafbt@kraftb.at>
1363 * @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.
1364 */
1365 if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1366 foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1367 $hookObject = t3lib_div::getUserObj($classData);
1368 if(!($hookObject instanceof localRecordList_actionsHook)) {
1369 throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567840);
1370 }
1371 $cells = $hookObject->makeControl($table, $row, $cells, $this);
1372 }
1373 }
1374
1375 // Compile items into a DIV-element:
1376 return '
1377 <!-- CONTROL PANEL: '.$table.':'.$row['uid'].' -->
1378 <div class="typo3-DBctrl">'.implode('',$cells).'</div>';
1379 }
1380
1381 /**
1382 * Creates the clipboard panel for a single record in the listing.
1383 *
1384 * @param string The table
1385 * @param array The record for which to make the clipboard panel.
1386 * @return string HTML table with the clipboard panel (unless disabled)
1387 */
1388 function makeClip($table,$row) {
1389 global $TCA, $LANG, $TYPO3_CONF_VARS;
1390
1391 // Return blank, if disabled:
1392 if ($this->dontShowClipControlPanels) return '';
1393 $cells=array();
1394
1395 $cells['pasteAfter'] = $cells['pasteInto'] = $this->spaceIcon;
1396 //enables to hide the copy, cut and paste icons for localized records - doesn't make much sense to perform these options for them
1397 $isL10nOverlay = $this->localizationView && $table != 'pages_language_overlay' && $row[$TCA[$table]['ctrl']['transOrigPointerField']] != 0;
1398 // Return blank, if disabled:
1399 // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel:
1400 if ($this->clipObj->current=='normal') { // For the "Normal" pad:
1401
1402 // Show copy/cut icons:
1403 $isSel = (string)$this->clipObj->isSelected($table,$row['uid']);
1404 $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).'">'.
1405 ((!$isSel=='copy') ? t3lib_iconWorks::getSpriteIcon('actions-edit-copy') : t3lib_iconWorks::getSpriteIcon('actions-edit-copy-release')) .
1406 '</a>';
1407 $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).'">'.
1408 ((!$isSel=='cut') ? t3lib_iconWorks::getSpriteIcon('actions-edit-cut') : t3lib_iconWorks::getSpriteIcon('actions-edit-cut-release')) .
1409 '</a>';
1410
1411 } else { // For the numeric clipboard pads (showing checkboxes where one can select elements on/off)
1412
1413 // Setting name of the element in ->CBnames array:
1414 $n=$table.'|'.$row['uid'];
1415 $this->CBnames[]=$n;
1416
1417 // Check if the current element is selected and if so, prepare to set the checkbox as selected:
1418 $checked = ($this->clipObj->isSelected($table,$row['uid'])?' checked="checked"':'');
1419
1420 // If the "duplicateField" value is set then select all elements which are duplicates...
1421 if ($this->duplicateField && isset($row[$this->duplicateField])) {
1422 $checked='';
1423 if (in_array($row[$this->duplicateField], $this->duplicateStack)) {
1424 $checked=' checked="checked"';
1425 }
1426 $this->duplicateStack[] = $row[$this->duplicateField];
1427 }
1428
1429 // Adding the checkbox to the panel:
1430 $cells['select'] = $isL10nOverlay ? $this->spaceIcon : '<input type="hidden" name="CBH['.$n.']" value="0" /><input type="checkbox" name="CBC['.$n.']" value="1" class="smallCheckboxes"'.$checked.' />';
1431 }
1432
1433 // Now, looking for selected elements from the current table:
1434 $elFromTable = $this->clipObj->elFromTable($table);
1435 if (count($elFromTable) && $TCA[$table]['ctrl']['sortby']) { // IF elements are found and they can be individually ordered, then add a "paste after" icon:
1436 $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).'">'.
1437 t3lib_iconWorks::getSpriteIcon('actions-document-paste-after') .
1438 '</a>';
1439 }
1440
1441 // Now, looking for elements in general:
1442 $elFromTable = $this->clipObj->elFromTable('');
1443 if ($table=='pages' && count($elFromTable)) {
1444 $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).'">'.
1445 t3lib_iconWorks::getSpriteIcon('actions-document-paste-into') .
1446 '</a>';
1447 }
1448
1449 /*
1450 * @hook makeClip: Allows to change clip-icons of records in list-module
1451 * @date 2007-11-20
1452 * @request Bernhard Kraft <krafbt@kraftb.at>
1453 * @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.
1454 */
1455 if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1456 foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1457 $hookObject = t3lib_div::getUserObj($classData);
1458 if(!($hookObject instanceof localRecordList_actionsHook)) {
1459 throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567845);
1460 }
1461 $cells = $hookObject->makeClip($table, $row, $cells, $this);
1462 }
1463 }
1464
1465 // Compile items into a DIV-element:
1466 return ' <!-- CLIPBOARD PANEL: '.$table.':'.$row['uid'].' -->
1467 <div class="typo3-clipCtrl">'.implode('',$cells).'</div>';
1468 }
1469
1470 /**
1471 * Make reference count
1472 *
1473 * @param string Table name
1474 * @param integer UID of record
1475 * @return string HTML-table
1476 *
1477 * @deprecated since 4.4, will be removed in TYPO3 4.6 - Use getReferenceHTML() instead
1478 */
1479 function makeRef($table,$uid) {
1480 t3lib_div::logDeprecatedFunction();
1481
1482 // Compile information for title tag:
1483 $infoData=array();
1484 if (is_array($this->references)) {
1485 foreach ($this->references as $row) {
1486 $infoData[]=$row['tablename'].':'.$row['recuid'].':'.$row['field'];
1487 }
1488 }
1489
1490 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>' : '';
1491 }
1492
1493 /**
1494 * Creates the HTML for a reference count for the record with the UID $uid
1495 * in the table $tableName.
1496 *
1497 * @param string $tableName
1498 * table name of the referenced record, must not be empty
1499 * @param integer $uid
1500 * UID of the referenced record, must be > 0
1501 *
1502 * @return string HTML of reference a link, will be empty if there are no
1503 * references to the corresponding record
1504 */
1505 protected function createReferenceHtml($tableName, $uid) {
1506 $referenceCount = $this->getReferenceCount($tableName, $uid);
1507 if ($referenceCount == 0) {
1508 return '';
1509 }
1510
1511 $queryResult = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1512 'tablename, recuid, field',
1513 'sys_refindex',
1514 'ref_table = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
1515 $tableName, 'sys_refindex'
1516 ) .
1517 ' AND ref_uid = ' . $uid .
1518 ' AND deleted = 0',
1519 '',
1520 '',
1521 '0,20'
1522 );
1523
1524 $referenceTitles = array();
1525
1526 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($queryResult)) {
1527 $referenceTitles[] = $row['tablename'] . ':' . $row['recuid'] .
1528 ':' . $row['field'];
1529 if (strlen(implode(' / ', $referenceTitles)) >= 100) {
1530 break;
1531 }
1532 }
1533 $GLOBALS['TYPO3_DB']->sql_free_result($queryResult);
1534
1535 return '<a href="#" ' .
1536 'onclick="' . htmlspecialchars(
1537 'top.launchView(\'' . $tableName . '\', \'' . $uid .
1538 '\'); return false;'
1539 ) . '" ' .
1540 'title="' . htmlspecialchars(
1541 t3lib_div::fixed_lgd_cs(implode(' / ', $referenceTitles), 100)
1542 ) . '">' . $referenceCount . '</a>';
1543 }
1544
1545 /**
1546 * Creates the localization panel
1547 *
1548 * @param string The table
1549 * @param array The record for which to make the localization panel.
1550 * @return array Array with key 0/1 with content for column 1 and 2
1551 */
1552 function makeLocalizationPanel($table,$row) {
1553 global $TCA,$LANG;
1554
1555 $out = array(
1556 0 => '',
1557 1 => '',
1558 );
1559
1560 $translations = $this->translateTools->translationInfo($table, $row['uid'], 0, $row, $this->selFieldList);
1561 $this->translations = $translations['translations'];
1562
1563 // Language title and icon:
1564 $out[0] = $this->languageFlag($row[$TCA[$table]['ctrl']['languageField']]);
1565
1566 if (is_array($translations)) {
1567
1568 // Traverse page translations and add icon for each language that does NOT yet exist:
1569 $lNew = '';
1570 foreach($this->pageOverlays as $lUid_OnPage => $lsysRec) {
1571 if (!isset($translations['translations'][$lUid_OnPage]) && $GLOBALS['BE_USER']->checkLanguageAccess($lUid_OnPage)) {
1572 $url = substr($this->listURL(), strlen($this->backPath));
1573 $href = $GLOBALS['SOBE']->doc->issueCommand(
1574 '&cmd[' . $table . '][' . $row['uid'] . '][localize]=' . $lUid_OnPage,
1575 $url . '&justLocalized=' . rawurlencode($table . ':' . $row['uid'] . ':' . $lUid_OnPage)
1576 );
1577 $language = t3lib_BEfunc::getRecord('sys_language', $lUid_OnPage, 'title');
1578 $lC = ($this->languageIconTitles[$lUid_OnPage]['flagIcon'] ? '<img src="'.$this->languageIconTitles[$lUid_OnPage]['flagIcon'].'" class="absmiddle" alt="" />' : $this->languageIconTitles[$lUid_OnPage]['title']);
1579 $lC = '<a href="' . htmlspecialchars($href) . '" title="' . htmlspecialchars($language['title']) . '">' . $lC . '</a> ';
1580
1581 $lNew.=$lC;
1582 }
1583 }
1584
1585 if ($lNew) $out[1].= $lNew;
1586 } else {
1587 $out[0] = '&nbsp;&nbsp;&nbsp;&nbsp;'.$out[0];
1588 }
1589
1590
1591 return $out;
1592 }
1593
1594 /**
1595 * Create the selector box for selecting fields to display from a table:
1596 *
1597 * @param string Table name
1598 * @param boolean If true, form-fields will be wrapped around the table.
1599 * @return string HTML table with the selector box (name: displayFields['.$table.'][])
1600 */
1601 function fieldSelectBox($table,$formFields=1) {
1602 global $TCA, $LANG;
1603
1604 // Init:
1605 t3lib_div::loadTCA($table);
1606 $formElements=array('','');
1607 if ($formFields) {
1608 $formElements=array('<form action="'.htmlspecialchars($this->listURL()).'" method="post">','</form>');
1609 }
1610
1611 // Load already selected fields, if any:
1612 $setFields=is_array($this->setFields[$table]) ? $this->setFields[$table] : array();
1613
1614 // Request fields from table:
1615 $fields = $this->makeFieldList($table, false, true);
1616
1617 // Add pseudo "control" fields
1618 $fields[]='_PATH_';
1619 $fields[]='_REF_';
1620 $fields[]='_LOCALIZATION_';
1621 $fields[]='_CONTROL_';
1622 $fields[]='_CLIPBOARD_';
1623
1624 // Create an option for each field:
1625 $opt=array();
1626 $opt[] = '<option value=""></option>';
1627 foreach($fields as $fN) {
1628 $fL = is_array($TCA[$table]['columns'][$fN]) ? rtrim($LANG->sL($TCA[$table]['columns'][$fN]['label']),':') : '['.$fN.']'; // Field label
1629 $opt[] = '
1630 <option value="'.$fN.'"'.(in_array($fN,$setFields)?' selected="selected"':'').'>'.htmlspecialchars($fL).'</option>';
1631 }
1632
1633 // Compile the options into a multiple selector box:
1634 $lMenu = '
1635 <select size="'.t3lib_div::intInRange(count($fields)+1,3,20).'" multiple="multiple" name="displayFields['.$table.'][]">'.implode('',$opt).'
1636 </select>
1637 ';
1638
1639 // Table with the field selector::
1640 $content.= '
1641 '.$formElements[0].'
1642
1643 <!--
1644 Field selector for extended table view:
1645 -->
1646 <table border="0" cellpadding="0" cellspacing="0" class="bgColor4" id="typo3-dblist-fieldSelect">
1647 <tr>
1648 <td>'.$lMenu.'</td>
1649 <td><input type="submit" name="search" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.setFields',1).'" /></td>
1650 </tr>
1651 </table>
1652 '.$formElements[1];
1653 return $content;
1654 }
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666 /*********************************
1667 *
1668 * Helper functions
1669 *
1670 *********************************/
1671
1672 /**
1673 * Creates a link around $string. The link contains an onclick action which submits the script with some clipboard action.
1674 * Currently, this is used for setting elements / delete elements.
1675 *
1676 * @param string The HTML content to link (image/text)
1677 * @param string Table name
1678 * @param string Clipboard command (eg. "setCB" or "delete")
1679 * @param string Warning text, if any ("delete" uses this for confirmation)
1680 * @return string <a> tag wrapped link.
1681 */
1682 function linkClipboardHeaderIcon($string,$table,$cmd,$warning='') {
1683 $onClickEvent = 'document.dblistForm.cmd.value=\''.$cmd.'\';document.dblistForm.cmd_table.value=\''.$table.'\';document.dblistForm.submit();';
1684 if ($warning) $onClickEvent = 'if (confirm('.$GLOBALS['LANG']->JScharCode($warning).')){'.$onClickEvent.'}';
1685 return '<a href="#" onclick="'.htmlspecialchars($onClickEvent.'return false;').'">'.$string.'</a>';
1686 }
1687
1688 /**
1689 * Returns true if a numeric clipboard pad is selected/active
1690 *
1691 * @return boolean
1692 */
1693 function clipNumPane() {
1694 return in_Array('_CLIPBOARD_',$this->fieldArray) && $this->clipObj->current!='normal';
1695 }
1696
1697 /**
1698 * Creates a sort-by link on the input string ($code).
1699 * It will automatically detect if sorting should be ascending or descending depending on $this->sortRev.
1700 * Also some fields will not be possible to sort (including if single-table-view is disabled).
1701 *
1702 * @param string The string to link (text)
1703 * @param string The fieldname represented by the title ($code)
1704 * @param string Table name
1705 * @return string Linked $code variable
1706 */
1707 function addSortLink($code,$field,$table) {
1708
1709 // Certain circumstances just return string right away (no links):
1710 if ($field=='_CONTROL_' || $field=='_LOCALIZATION_' || $field=='_CLIPBOARD_' || $field=='_REF_' || $this->disableSingleTableView) return $code;
1711
1712 // If "_PATH_" (showing record path) is selected, force sorting by pid field (will at least group the records!)
1713 if ($field=='_PATH_') $field=pid;
1714
1715 // Create the sort link:
1716 $sortUrl = $this->listURL('',-1,'sortField,sortRev,table').'&table='.$table.'&sortField='.$field.'&sortRev='.($this->sortRev || ($this->sortField!=$field)?0:1);
1717 $sortArrow = ($this->sortField==$field?'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/red'.($this->sortRev?'up':'down').'.gif','width="7" height="4"').' alt="" />':'');
1718
1719 // Return linked field:
1720 return '<a href="'.htmlspecialchars($sortUrl).'">'.$code.
1721 $sortArrow.
1722 '</a>';
1723 }
1724
1725 /**
1726 * Returns the path for a certain pid
1727 * The result is cached internally for the session, thus you can call this function as much as you like without performance problems.
1728 *
1729 * @param integer The page id for which to get the path
1730 * @return string The path.
1731 */
1732 function recPath($pid) {
1733 if (!isset($this->recPath_cache[$pid])) {
1734 $this->recPath_cache[$pid] = t3lib_BEfunc::getRecordPath($pid,$this->perms_clause,20);
1735 }
1736 return $this->recPath_cache[$pid];
1737 }
1738
1739 /**
1740 * Returns true if a link for creating new records should be displayed for $table
1741 *
1742 * @param string Table name
1743 * @return boolean Returns true if a link for creating new records should be displayed for $table
1744 * @see SC_db_new::showNewRecLink
1745 */
1746 function showNewRecLink($table) {
1747 // No deny/allow tables are set:
1748 if (!count($this->allowedNewTables) && !count($this->deniedNewTables)) {
1749 return true;
1750 // If table is not denied (which takes precedence over allowed tables):
1751 } elseif (!in_array($table, $this->deniedNewTables) && (!count($this->allowedNewTables) || in_array($table, $this->allowedNewTables))) {
1752 return true;
1753 // If table is denied or allowed tables are set, but table is not part of:
1754 } else {
1755 return false;
1756 }
1757 }
1758
1759 /**
1760 * 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.
1761 * Uses REQUEST_URI as value.
1762 *
1763 * @return string
1764 */
1765 function makeReturnUrl() {
1766 return '&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
1767 }
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779 /************************************
1780 *
1781 * CSV related functions
1782 *
1783 ************************************/
1784
1785 /**
1786 * Initializes internal csvLines array with the header of field names
1787 *
1788 * @return void
1789 */
1790 protected function initCSV() {
1791 $this->addHeaderRowToCSV();
1792 }
1793
1794 /**
1795 * Add header line with field names as CSV line
1796 *
1797 * @return void
1798 */
1799 protected function addHeaderRowToCSV() {
1800 // Add header row, control fields will be reduced inside addToCSV()
1801 $this->addToCSV(array_combine($this->fieldArray, $this->fieldArray));
1802 }
1803
1804 /**
1805 * Adds selected columns of one table row as CSV line.
1806 *
1807 * @param array Record array, from which the values of fields found in $this->fieldArray will be listed in the CSV output.
1808 * @param string Table name @deprecated since 4.4
1809 * @return void
1810 */
1811 protected function addToCSV(array $row = array(), $table = '') {
1812 $rowReducedByControlFields = self::removeControlFieldsFromFieldRow($row);
1813 $rowReducedToSelectedColumns = array_intersect_key($rowReducedByControlFields, array_flip($this->fieldArray));
1814 $this->setCsvRow($rowReducedToSelectedColumns);
1815 }
1816
1817 /**
1818 * Remove control fields from row for CSV export
1819 *
1820 * @param array fieldNames => fieldValues
1821 * @return array Input array reduces by control fields
1822 */
1823 protected static function removeControlFieldsFromFieldRow(array $row = array()) {
1824 // Possible control fields in a list row
1825 $controlFields = array(
1826 '_PATH_',
1827 '_REF_',
1828 '_CONTROL_',
1829 '_AFTERCONTROL_',
1830 '_AFTERREF_',
1831 '_CLIPBOARD_',
1832 '_LOCALIZATION_',
1833 '_LOCALIZATION_b',
1834 );
1835 return array_diff_key($row, array_flip($controlFields));
1836 }
1837
1838
1839 /**
1840 * Adds input row of values to the internal csvLines array as a CSV formatted line
1841 *
1842 * @param array Array with values to be listed.
1843 * @return void
1844 */
1845 function setCsvRow($csvRow) {
1846 $this->csvLines[] = t3lib_div::csvValues($csvRow);
1847 }
1848
1849 /**
1850 * Compiles the internal csvLines array to a csv-string and outputs it to the browser.
1851 * This function exits!
1852 *
1853 * @param string Filename prefix:
1854 * @return void EXITS php execusion!
1855 */
1856 function outputCSV($prefix) {
1857
1858 // Setting filename:
1859 $filename=$prefix.'_'.date('dmy-Hi').'.csv';
1860
1861 // Creating output header:
1862 $mimeType = 'application/octet-stream';
1863 Header('Content-Type: '.$mimeType);
1864 Header('Content-Disposition: attachment; filename='.$filename);
1865
1866 // Printing the content of the CSV lines:
1867 echo implode(chr(13).chr(10),$this->csvLines);
1868
1869 // Exits:
1870 exit;
1871 }
1872 }
1873
1874
1875
1876 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc']) {
1877 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc']);
1878 }
1879
1880 ?>