[TASK] Remove deprecated usages of intInRange, intval_positive and int_from_ver
[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 * Revised for TYPO3 3.6 December/2003 by Kasper Skårhøj
32 * XHTML compliant
33 *
34 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
35 */
36
37
38
39
40
41
42
43
44
45
46 /**
47 * Class for rendering of Web>List module
48 *
49 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
50 * @package TYPO3
51 * @subpackage core
52 */
53 class localRecordList extends recordList {
54
55 // External:
56 var $alternateBgColors=FALSE; // If TRUE, table rows in the list will alternate in background colors (and have background colors at all!)
57 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.
58 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.
59 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!).
60
61 var $dontShowClipControlPanels=FALSE; // If TRUE, will disable the rendering of clipboard + control panels.
62 var $showClipboard=FALSE; // If TRUE, will show the clipboard in the field list.
63 var $noControlPanels = FALSE; // If TRUE, will DISABLE all control panels in lists. (Takes precedence)
64 var $clickMenuEnabled = TRUE; // If TRUE, clickmenus will be rendered
65
66 var $totalRowCount; // count of record rows in view
67
68 var $spaceIcon; // space icon used for alignment
69
70 // Internal:
71 var $pageRow=array(); // Set to the page record (see writeTop())
72
73 // Used to accumulate CSV lines for CSV export.
74 protected $csvLines = array();
75
76 var $csvOutput=FALSE; // If set, the listing is returned as CSV instead.
77
78 /**
79 * Clipboard object
80 *
81 * @var t3lib_clipboard
82 */
83 var $clipObj;
84 var $CBnames=array(); // Tracking names of elements (for clipboard use)
85 var $duplicateStack=array(); // Used to track which elements has duplicates and how many
86
87 /**
88 * references of the current record
89 *
90 * @var array
91 *
92 * @deprecated since 4.4: Use getReferenceCount instead
93 */
94 public $references;
95
96 /**
97 * [$tablename][$uid] = number of references to this record
98 *
99 * @var array
100 */
101 protected $referenceCount = array();
102
103 var $translations; // Translations of the current record
104 var $selFieldList; // select fields for the query which fetches the translations of the current record
105
106 public function __construct() {
107 parent::__construct();
108 }
109
110 /**
111 * Create the panel of buttons for submitting the form or otherwise perform operations.
112 *
113 * @return array all available buttons as an assoc. array
114 */
115 public function getButtons() {
116 $buttons = array(
117 'csh' => '',
118 'view' => '',
119 'edit' => '',
120 'hide_unhide' => '',
121 'move' => '',
122 'new_record' => '',
123 'paste' => '',
124 'level_up' => '',
125 'cache' => '',
126 'reload' => '',
127 'shortcut' => '',
128 'back' => '',
129 'csv' => '',
130 'export' => ''
131 );
132
133 // Get users permissions for this page record:
134 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms($this->pageRow);
135
136 // CSH
137 if (!strlen($this->id)) {
138 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module_noId', $GLOBALS['BACK_PATH'], '', TRUE);
139 } elseif(!$this->id) {
140 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module_root', $GLOBALS['BACK_PATH'], '', TRUE);
141 } else {
142 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'list_module', $GLOBALS['BACK_PATH'], '', TRUE);
143 }
144
145 if (isset($this->id)) {
146 // View Exclude doktypes 254,255 Configuration: mod.web_list.noViewWithDokTypes = 254,255
147 if (isset($GLOBALS['SOBE']->modTSconfig['properties']['noViewWithDokTypes'])) {
148 $noViewDokTypes = t3lib_div::trimExplode(',', $GLOBALS['SOBE']->modTSconfig['properties']['noViewWithDokTypes'], TRUE);
149 } else {
150 //default exclusion: doktype 254 (folder), 255 (recycler)
151 $noViewDokTypes = array(t3lib_pageSelect::DOKTYPE_SYSFOLDER, t3lib_pageSelect::DOKTYPE_RECYCLER);
152 }
153
154 if (!in_array($this->pageRow['doktype'], $noViewDokTypes)) {
155 $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->id, $this->backPath, t3lib_BEfunc::BEgetRootLine($this->id))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', TRUE) . '">' .
156 t3lib_iconWorks::getSpriteIcon('actions-document-view') .
157 '</a>';
158 }
159
160 // New record
161 if (!$GLOBALS['SOBE']->modTSconfig['properties']['noCreateRecordsLink']) {
162 $buttons['new_record'] = '<a href="#" onclick="' . htmlspecialchars('return jumpExt(\'' . $this->backPath . 'db_new.php?id=' . $this->id . '\');') . '" title="' . $GLOBALS['LANG']->getLL('newRecordGeneral', TRUE) . '">' .
163 t3lib_iconWorks::getSpriteIcon('actions-document-new') .
164 '</a>';
165 }
166
167 // If edit permissions are set (see class.t3lib_userauthgroup.php)
168 if ($localCalcPerms&2 && !empty($this->id)) {
169
170 // Edit
171 $params = '&edit[pages][' . $this->pageRow['uid'] . ']=edit';
172 $buttons['edit'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath, -1)) . '" title="' . $GLOBALS['LANG']->getLL('editPage', TRUE) . '">' .
173 t3lib_iconWorks::getSpriteIcon('actions-page-open') .
174 '</a>';
175 // Unhide
176 if ($this->pageRow['hidden']) {
177 $params = '&data[pages][' . $this->pageRow['uid'] . '][hidden]=0';
178 $buttons['hide_unhide'] = '<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');') . '" title="' . $GLOBALS['LANG']->getLL('unHidePage', TRUE) . '">' .
179 t3lib_iconWorks::getSpriteIcon('actions-edit-unhide') .
180 '</a>';
181 // Hide
182 } else {
183 $params = '&data[pages][' . $this->pageRow['uid'] . '][hidden]=1';
184 $buttons['hide_unhide'] = '<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');') . '" title="' . $GLOBALS['LANG']->getLL('hidePage', TRUE) . '">'.
185 t3lib_iconWorks::getSpriteIcon('actions-edit-hide') .
186 '</a>';
187 }
188
189 // Move
190 $buttons['move'] = '<a href="#" onclick="' . htmlspecialchars('return jumpExt(\'' . $this->backPath . 'move_el.php?table=pages&uid=' . $this->pageRow['uid'] . '\');') . '" title="' . $GLOBALS['LANG']->getLL('move_page', TRUE) . '">' .
191 (($this->table == 'tt_content') ? t3lib_iconWorks::getSpriteIcon('actions-document-move') : t3lib_iconWorks::getSpriteIcon('actions-page-move')) .
192 '</a>';
193
194 // Up one level
195 $buttons['level_up'] = '<a href="' . htmlspecialchars($this->listURL($this->pageRow['pid'], '-1', 'firstElementNumber')) . '" onclick="setHighlight(' . $this->pageRow['pid'] . ')" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel', TRUE) . '">' .
196 t3lib_iconWorks::getSpriteIcon('actions-view-go-up') .
197 '</a>';
198
199 }
200
201
202 // Paste
203 if (($localCalcPerms&8) || ($localCalcPerms&16)) {
204 $elFromTable = $this->clipObj->elFromTable('');
205 if (count($elFromTable)) {
206 $buttons['paste'] = '<a href="' . htmlspecialchars($this->clipObj->pasteUrl('', $this->id)) . '" onclick="' . htmlspecialchars('return ' . $this->clipObj->confirmMsg('pages', $this->pageRow, 'into', $elFromTable)) . '" title="' . $GLOBALS['LANG']->getLL('clip_paste', TRUE) . '">' .
207 t3lib_iconWorks::getSpriteIcon('actions-document-paste-after') .
208 '</a>';
209 }
210 }
211
212 // Cache
213 $buttons['cache'] = '<a href="' . htmlspecialchars($this->listURL() . '&clear_cache=1') . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.clear_cache', TRUE) . '">' .
214 t3lib_iconWorks::getSpriteIcon('actions-system-cache-clear') .
215 '</a>';
216
217 if ($this->table) {
218
219 // CSV
220 $buttons['csv'] = '<a href="' . htmlspecialchars($this->listURL() . '&csv=1') . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.csv', TRUE) . '">' .
221 t3lib_iconWorks::getSpriteIcon('mimetypes-text-csv') .
222 '</a>';
223
224 // Export
225 if (t3lib_extMgm::isLoaded('impexp')) {
226 $url = $this->backPath . t3lib_extMgm::extRelPath('impexp') . 'app/index.php?tx_impexp[action]=export';
227 $buttons['export'] = '<a href="' . htmlspecialchars($url . '&tx_impexp[list][]=' . rawurlencode($this->table . ':' . $this->id)) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.export', TRUE) . '">' .
228 t3lib_iconWorks::getSpriteIcon('actions-document-export-t3d') .
229 '</a>';
230 }
231
232 }
233
234 // Reload
235 $buttons['reload'] = '<a href="' . htmlspecialchars($this->listURL()) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.reload', TRUE) . '">' .
236 t3lib_iconWorks::getSpriteIcon('actions-system-refresh') .
237 '</a>';
238
239 // Shortcut
240 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
241 $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');
242 }
243
244 // Back
245 if ($this->returnUrl) {
246 $buttons['back'] = '<a href="' . htmlspecialchars(t3lib_div::linkThisUrl($this->returnUrl, array('id' => $this->id))) . '" class="typo3-goBack" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.goBack', TRUE) . '">' .
247 t3lib_iconWorks::getSpriteIcon('actions-view-go-back') .
248 '</a>';
249 }
250 }
251
252 return $buttons;
253 }
254
255 /**
256 * Creates the listing of records from a single table
257 *
258 * @param string Table name
259 * @param integer Page id
260 * @param string List of fields to show in the listing. Pseudo fields will be added including the record header.
261 * @return string HTML table with the listing for the record.
262 */
263 function getTable($table,$id,$rowlist) {
264 // Loading all TCA details for this table:
265 t3lib_div::loadTCA($table);
266
267 // Init
268 $addWhere = '';
269 $titleCol = $GLOBALS['TCA'][$table]['ctrl']['label'];
270 $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
271 $l10nEnabled = $GLOBALS['TCA'][$table]['ctrl']['languageField'] && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']
272 && !$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'];
273 $tableCollapsed = (!$this->tablesCollapsed[$table]) ? FALSE : TRUE;
274
275 // prepare space icon
276 $this->spaceIcon = t3lib_iconWorks::getSpriteIcon('empty-empty', array('style' => 'background-position: 0 10px;'));
277
278 // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
279 $this->fieldArray=array();
280 // title Column
281 $this->fieldArray[] = $titleCol; // Add title column
282 // Control-Panel
283 if (!t3lib_div::inList($rowlist,'_CONTROL_')) {
284 $this->fieldArray[] = '_CONTROL_';
285 $this->fieldArray[] = '_AFTERCONTROL_';
286 }
287 // Clipboard
288 if ($this->showClipboard) {
289 $this->fieldArray[] = '_CLIPBOARD_';
290 }
291 // Ref
292 if (!$this->dontShowClipControlPanels) {
293 $this->fieldArray[]='_REF_';
294 $this->fieldArray[]='_AFTERREF_';
295 }
296 // Path
297 if ($this->searchLevels) {
298 $this->fieldArray[]='_PATH_';
299 }
300 // Localization
301 if ($this->localizationView && $l10nEnabled) {
302 $this->fieldArray[] = '_LOCALIZATION_';
303 $this->fieldArray[] = '_LOCALIZATION_b';
304 $addWhere.=' AND (
305 ' . $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '<=0
306 OR
307 ' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . ' = 0
308 )';
309 }
310 // Cleaning up:
311 $this->fieldArray=array_unique(array_merge($this->fieldArray,t3lib_div::trimExplode(',',$rowlist,1)));
312 if ($this->noControlPanels) {
313 $tempArray = array_flip($this->fieldArray);
314 unset($tempArray['_CONTROL_']);
315 unset($tempArray['_CLIPBOARD_']);
316 $this->fieldArray = array_keys($tempArray);
317 }
318
319 // Creating the list of fields to include in the SQL query:
320 $selectFields = $this->fieldArray;
321 $selectFields[] = 'uid';
322 $selectFields[] = 'pid';
323 if ($thumbsCol) $selectFields[] = $thumbsCol; // adding column for thumbnails
324 if ($table=='pages') {
325 if (t3lib_extMgm::isLoaded('cms')) {
326 $selectFields[] = 'module';
327 $selectFields[] = 'extendToSubpages';
328 $selectFields[] = 'nav_hide';
329 }
330 $selectFields[] = 'doktype';
331 }
332 if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
333 $selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
334 }
335 if ($GLOBALS['TCA'][$table]['ctrl']['type']) {
336 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['type'];
337 }
338 if ($GLOBALS['TCA'][$table]['ctrl']['typeicon_column']) {
339 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_column'];
340 }
341 if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
342 $selectFields[] = 't3ver_id';
343 $selectFields[] = 't3ver_state';
344 $selectFields[] = 't3ver_wsid';
345 $selectFields[] = 't3ver_swapmode'; // Filtered out when pages in makeFieldList()
346 }
347 if ($l10nEnabled) {
348 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
349 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
350 }
351 if ($GLOBALS['TCA'][$table]['ctrl']['label_alt']) {
352 $selectFields = array_merge(
353 $selectFields,
354 t3lib_div::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['label_alt'], 1)
355 );
356 }
357 $selectFields = array_unique($selectFields); // Unique list!
358 $selectFields = array_intersect($selectFields,$this->makeFieldList($table,1)); // Making sure that the fields in the field-list ARE in the field-list from TCA!
359 $selFieldList = implode(',',$selectFields); // implode it into a list of fields for the SQL-statement.
360 $this->selFieldList = $selFieldList;
361
362 /**
363 * @hook DB-List getTable
364 * @date 2007-11-16
365 * @request Malte Jansen <mail@maltejansen.de>
366 */
367 if(is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'])) {
368 foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] as $classData) {
369 $hookObject = t3lib_div::getUserObj($classData);
370
371 if(!($hookObject instanceof t3lib_localRecordListGetTableHook)) {
372 throw new UnexpectedValueException('$hookObject must implement interface t3lib_localRecordListGetTableHook', 1195114460);
373 }
374
375 $hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this);
376 }
377 }
378
379 // Create the SQL query for selecting the elements in the listing:
380 if ($this->csvOutput) { // do not do paging when outputting as CSV
381 $this->iLimit = 0;
382 }
383
384 if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
385 // Get the two previous rows for sorting if displaying page > 1
386 $this->firstElementNumber = $this->firstElementNumber - 2;
387 $this->iLimit = $this->iLimit + 2;
388 $queryParts = $this->makeQueryArray($table, $id,$addWhere,$selFieldList); // (API function from class.db_list.inc)
389 $this->firstElementNumber = $this->firstElementNumber + 2;
390 $this->iLimit = $this->iLimit - 2;
391 } else {
392 $queryParts = $this->makeQueryArray($table, $id,$addWhere,$selFieldList); // (API function from class.db_list.inc)
393 }
394
395 $this->setTotalItems($queryParts); // Finding the total amount of records on the page (API function from class.db_list.inc)
396
397 // Init:
398 $dbCount = 0;
399 $out = '';
400 $listOnlyInSingleTableMode = $this->listOnlyInSingleTableMode && !$this->table;
401
402 // If the count query returned any number of records, we perform the real query, selecting records.
403 if ($this->totalItems) {
404 // Fetch records only if not in single table mode or if in multi table mode and not collapsed
405 if ($listOnlyInSingleTableMode || (!$this->table && $tableCollapsed)) {
406 $dbCount = $this->totalItems;
407 } else {
408 // set the showLimit to the number of records when outputting as CSV
409 if ($this->csvOutput) {
410 $this->showLimit = $this->totalItems;
411 $this->iLimit = $this->totalItems;
412 }
413 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
414 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
415 }
416 }
417
418 // If any records was selected, render the list:
419 if ($dbCount) {
420
421 // Half line is drawn between tables:
422 if (!$listOnlyInSingleTableMode) {
423 $theData = Array();
424 if (!$this->table && !$rowlist) {
425 $theData[$titleCol] = '<img src="clear.gif" width="'.($GLOBALS['SOBE']->MOD_SETTINGS['bigControlPanel']?'230':'350').'" height="1" alt="" />';
426 if (in_array('_CONTROL_',$this->fieldArray)) $theData['_CONTROL_']='';
427 if (in_array('_CLIPBOARD_',$this->fieldArray)) $theData['_CLIPBOARD_']='';
428 }
429 $out.=$this->addelement(0,'',$theData,'class="c-table-row-spacer"',$this->leftMargin);
430 }
431
432 // Header line is drawn
433 $theData = Array();
434 if ($this->disableSingleTableView) {
435 $theData[$titleCol] = '<span class="c-table">' . t3lib_BEfunc::wrapInHelp($table, '', $GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title'], TRUE)) . '</span> ('.$this->totalItems.')';
436 } else {
437 $theData[$titleCol] = $this->linkWrapTable($table, '<span class="c-table">' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title'], TRUE) . '</span> (' . $this->totalItems . ') ' .
438 ($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))))
439 );
440 }
441
442 if ($listOnlyInSingleTableMode) {
443 $out.='
444 <tr>
445 <td class="t3-row-header" style="width:95%;">' . t3lib_BEfunc::wrapInHelp($table, '', $theData[$titleCol]) . '</td>
446 </tr>';
447 } else {
448 // Render collapse button if in multi table mode
449 $collapseIcon = '';
450 if (!$this->table) {
451 $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)) . '">' .
452 ($tableCollapsed ? t3lib_iconWorks::getSpriteIcon('actions-view-list-expand', array('class' => 'collapseIcon')) : t3lib_iconWorks::getSpriteIcon('actions-view-list-collapse', array('class' => 'collapseIcon'))) .
453 '</a>';
454 }
455 $out .= $this->addElement(1, $collapseIcon, $theData, ' class="t3-row-header"', '');
456 }
457
458 // Render table rows only if in multi table view and not collapsed or if in single table view
459 if (!$listOnlyInSingleTableMode && (!$tableCollapsed || $this->table)) {
460 // Fixing a order table for sortby tables
461 $this->currentTable = array();
462 $currentIdList = array();
463 $doSort = ($GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField);
464
465 $prevUid = 0;
466 $prevPrevUid = 0;
467
468 // Get first two rows and initialize prevPrevUid and prevUid if on page > 1
469 if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
470 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
471 $prevPrevUid = -(int) $row['uid'];
472 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
473 $prevUid = $row['uid'];
474 }
475
476 $accRows = array(); // Accumulate rows here
477 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
478
479 // In offline workspace, look for alternative record:
480 t3lib_BEfunc::workspaceOL($table, $row, $GLOBALS['BE_USER']->workspace, TRUE);
481
482 if (is_array($row)) {
483 $accRows[] = $row;
484 $currentIdList[] = $row['uid'];
485 if ($doSort) {
486 if ($prevUid) {
487 $this->currentTable['prev'][$row['uid']] = $prevPrevUid;
488 $this->currentTable['next'][$prevUid] = '-'.$row['uid'];
489 $this->currentTable['prevUid'][$row['uid']] = $prevUid;
490 }
491 $prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
492 $prevUid=$row['uid'];
493 }
494 }
495 }
496 $GLOBALS['TYPO3_DB']->sql_free_result($result);
497
498 $this->totalRowCount = count($accRows);
499
500 // CSV initiated
501 if ($this->csvOutput) $this->initCSV();
502
503 // Render items:
504 $this->CBnames=array();
505 $this->duplicateStack=array();
506 $this->eCounter=$this->firstElementNumber;
507
508 $iOut = '';
509 $cc = 0;
510
511 foreach($accRows as $row) {
512 // Render item row if counter < limit
513 if ($cc < $this->iLimit) {
514 $cc++;
515 $this->translations = FALSE;
516 $iOut.= $this->renderListRow($table,$row,$cc,$titleCol,$thumbsCol);
517
518 // 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:
519 if ($this->localizationView && $l10nEnabled) {
520 // For each available translation, render the record:
521 if (is_array($this->translations)) {
522 foreach ($this->translations as $lRow) {
523 // $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
524 if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
525 $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);
526 $lRow = is_array($tmpRow)?$tmpRow:$lRow;
527 }
528 // In offline workspace, look for alternative record:
529 t3lib_BEfunc::workspaceOL($table, $lRow, $GLOBALS['BE_USER']->workspace, TRUE);
530 if (is_array($lRow) && $GLOBALS['BE_USER']->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
531 $currentIdList[] = $lRow['uid'];
532 $iOut.=$this->renderListRow($table,$lRow,$cc,$titleCol,$thumbsCol,18);
533 }
534 }
535 }
536 }
537 }
538
539 // Counter of total rows incremented:
540 $this->eCounter++;
541 }
542
543 // Record navigation is added to the beginning and end of the table if in single table mode
544 if ($this->table) {
545 $iOut = $this->renderListNavigation('top') . $iOut . $this->renderListNavigation('bottom');
546 } else {
547 // show that there are more records than shown
548 if ($this->totalItems > $this->itemsLimitPerTable) {
549 $countOnFirstPage = $this->totalItems > $this->itemsLimitSingleTable ? $this->itemsLimitSingleTable : $this->totalItems;
550 $hasMore = ($this->totalItems > $this->itemsLimitSingleTable);
551 $iOut .= '<tr><td colspan="' . count($this->fieldArray) . '" style="padding:5px;">
552 <a href="'.htmlspecialchars($this->listURL() . '&table=' . rawurlencode($table)) . '">' .
553 '<img' . t3lib_iconWorks::skinImg($this->backPath,'gfx/pildown.gif', 'width="14" height="14"') .' alt="" />'.
554 ' <i>[1 - ' . $countOnFirstPage . ($hasMore ? '+' : '') . ']</i></a>
555 </td></tr>';
556 }
557
558 }
559
560 // The header row for the table is now created:
561 $out .= $this->renderListHeader($table,$currentIdList);
562 }
563
564 // The list of records is added after the header:
565 $out .= $iOut;
566 unset($iOut);
567
568 // ... and it is all wrapped in a table:
569 $out='
570
571
572
573 <!--
574 DB listing of elements: "'.htmlspecialchars($table).'"
575 -->
576 <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist'.($listOnlyInSingleTableMode?' typo3-dblist-overview':'').'">
577 '.$out.'
578 </table>';
579
580 // Output csv if...
581 if ($this->csvOutput) $this->outputCSV($table); // This ends the page with exit.
582 }
583
584 // Return content:
585 return $out;
586 }
587
588 /**
589 * Rendering a single row for the list
590 *
591 * @param string Table name
592 * @param array Current record
593 * @param integer Counter, counting for each time an element is rendered (used for alternating colors)
594 * @param string Table field (column) where header value is found
595 * @param string Table field (column) where (possible) thumbnails can be found
596 * @param integer Indent from left.
597 * @return string Table row for the element
598 * @access private
599 * @see getTable()
600 */
601 function renderListRow($table,$row,$cc,$titleCol,$thumbsCol,$indent=0) {
602 $iOut = '';
603
604 if (strlen($this->searchString)) { // If in search mode, make sure the preview will show the correct page
605 $id_orig = $this->id;
606 $this->id = $row['pid'];
607 }
608
609 if (is_array($row)) {
610 // add special classes for first and last row
611 $rowSpecial = '';
612 if ($cc == 1 && $indent == 0) {
613 $rowSpecial .= ' firstcol';
614 }
615 if ($cc == $this->totalRowCount || $cc == $this->iLimit) {
616 $rowSpecial .= ' lastcol';
617 }
618
619 // Background color, if any:
620 if ($this->alternateBgColors) {
621 $row_bgColor = ($cc%2) ? ' class="db_list_normal'.$rowSpecial.'"' : ' class="db_list_alt'.$rowSpecial.'"';
622 } else {
623 $row_bgColor = ' class="db_list_normal'.$rowSpecial.'"';
624 }
625 // Overriding with versions background color if any:
626 $row_bgColor = $row['_CSSCLASS'] ? ' class="'.$row['_CSSCLASS'].'"' : $row_bgColor;
627
628 // Incr. counter.
629 $this->counter++;
630
631 // The icon with link
632 $alttext = t3lib_BEfunc::getRecordIconAltText($row,$table);
633 $iconImg = t3lib_iconWorks::getSpriteIconForRecord($table, $row, array('title' => htmlspecialchars($alttext), 'style' => ($indent ? ' margin-left: ' . $indent . 'px;' : '')));
634
635
636 $theIcon = $this->clickMenuEnabled ? $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg,$table,$row['uid']) : $iconImg;
637
638 // Preparing and getting the data-array
639 $theData = Array();
640 foreach($this->fieldArray as $fCol) {
641 if ($fCol==$titleCol) {
642 $recTitle = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
643 // If the record is edit-locked by another user, we will show a little warning sign:
644 if (($lockInfo = t3lib_BEfunc::isRecordLocked($table, $row['uid']))) {
645 $warning = '<a href="#" onclick="' . htmlspecialchars('alert(' . $GLOBALS['LANG']->JScharCode($lockInfo['msg']) . '); return false;') . '" title="' . htmlspecialchars($lockInfo['msg']) . '">' .
646 t3lib_iconWorks::getSpriteIcon('status-warning-in-use') .
647 '</a>';
648 }
649 $theData[$fCol] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
650
651 // Render thumbsnails if a thumbnail column exists and there is content in it:
652 if ($this->thumbs && trim($row[$thumbsCol])) {
653 $theData[$fCol] .= '<br />' . $this->thumbCode($row,$table,$thumbsCol);
654 }
655
656 $localizationMarkerClass = '';
657 if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
658 && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0
659 && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0) {
660 // it's a translated record with a language parent
661 $localizationMarkerClass = ' localization';
662 }
663 } elseif ($fCol == 'pid') {
664 $theData[$fCol]=$row[$fCol];
665 } elseif ($fCol == '_PATH_') {
666 $theData[$fCol]=$this->recPath($row['pid']);
667 } elseif ($fCol == '_REF_') {
668 $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
669 } elseif ($fCol == '_CONTROL_') {
670 $theData[$fCol]=$this->makeControl($table,$row);
671 } elseif ($fCol == '_AFTERCONTROL_' || $fCol == '_AFTERREF_') {
672 $theData[$fCol] = '&nbsp;';
673 } elseif ($fCol == '_CLIPBOARD_') {
674 $theData[$fCol]=$this->makeClip($table,$row);
675 } elseif ($fCol == '_LOCALIZATION_') {
676 list($lC1, $lC2) = $this->makeLocalizationPanel($table,$row);
677 $theData[$fCol] = $lC1;
678 $theData[$fCol.'b'] = $lC2;
679 } elseif ($fCol == '_LOCALIZATION_b') {
680 // Do nothing, has been done above.
681 } else {
682 $tmpProc = t3lib_BEfunc::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid']);
683 $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
684 if ($this->csvOutput) {
685 $row[$fCol] = t3lib_BEfunc::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
686 }
687 }
688 }
689
690 if (strlen($this->searchString)) { // Reset the ID if it was overwritten
691 $this->id = $id_orig;
692 }
693
694 // Add row to CSV list:
695 if ($this->csvOutput) {
696 $this->addToCSV($row,$table);
697 }
698
699 // Add classes to table cells
700 $this->addElement_tdCssClass[$titleCol] = 'col-title' . $localizationMarkerClass;
701 if (!$this->dontShowClipControlPanels) {
702 $this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
703 $this->addElement_tdCssClass['_AFTERCONTROL_'] = 'col-control-space';
704 $this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard';
705 }
706 $this->addElement_tdCssClass['_PATH_'] = 'col-path';
707 $this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa';
708 $this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb';
709
710 // Create element in table cells:
711 $iOut.=$this->addelement(1,$theIcon,$theData,$row_bgColor);
712
713 // Finally, return table row element:
714 return $iOut;
715 }
716 }
717
718 /**
719 * Write sys_refindex entries for current record to $this->references
720 *
721 * @param string Table name
722 * @param integer Uid of current record
723 * @return void
724 *
725 * @deprecated since 4.4, will be removed in TYPO3 4.6 - Use getReferenceCount instead
726 */
727 function setReferences($table, $uid) {
728 t3lib_div::logDeprecatedFunction();
729
730 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
731 'tablename, recuid, field',
732 'sys_refindex',
733 'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_refindex').
734 ' AND ref_uid='.intval($uid).
735 ' AND deleted=0'
736 );
737 $this->references = $rows;
738 }
739
740 /**
741 * Gets the number of records referencing the record with the UID $uid in
742 * the table $tableName.
743 *
744 * @param string $tableName
745 * table name of the referenced record, must not be empty
746 * @param integer $uid
747 * UID of the referenced record, must be > 0
748 *
749 * @return integer the number of references to record $uid in table
750 * $tableName, will be >= 0
751 */
752 protected function getReferenceCount($tableName, $uid) {
753 if (!isset($this->referenceCount[$tableName][$uid])) {
754 $numberOfReferences = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
755 '*',
756 'sys_refindex',
757 'ref_table = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
758 $tableName, 'sys_refindex'
759 ) .
760 ' AND ref_uid = ' . $uid .
761 ' AND deleted = 0'
762 );
763
764 $this->referenceCount[$tableName][$uid] = $numberOfReferences;
765 }
766
767 return $this->referenceCount[$tableName][$uid];
768 }
769
770 /**
771 * Rendering the header row for a table
772 *
773 * @param string Table name
774 * @param array Array of the currently displayed uids of the table
775 * @return string Header table row
776 * @access private
777 * @see getTable()
778 */
779 function renderListHeader($table, $currentIdList) {
780 // Init:
781 $theData = Array();
782
783 // Traverse the fields:
784 foreach($this->fieldArray as $fCol) {
785
786 // Calculate users permissions to edit records in the table:
787 $permsEdit = $this->calcPerms & ($table=='pages'?2:16);
788
789 switch((string)$fCol) {
790 case '_PATH_': // Path
791 $theData[$fCol] = '<i>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels._PATH_', 1) . ']</i>';
792 break;
793 case '_REF_': // References
794 $theData[$fCol] = '<i>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:c__REF_', 1) . ']</i>';
795 break;
796 case '_LOCALIZATION_': // Path
797 $theData[$fCol] = '<i>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels._LOCALIZATION_', 1) . ']</i>';
798 break;
799 case '_LOCALIZATION_b': // Path
800 $theData[$fCol] = $GLOBALS['LANG']->getLL('Localize', 1);
801 break;
802 case '_CLIPBOARD_': // Clipboard:
803 $cells=array();
804
805 // If there are elements on the clipboard for this table, then display the "paste into" icon:
806 $elFromTable = $this->clipObj->elFromTable($table);
807 if (count($elFromTable)) {
808 $cells['pasteAfter'] = '<a href="' . htmlspecialchars($this->clipObj->pasteUrl($table, $this->id)) .
809 '" onclick="' . htmlspecialchars('return ' . $this->clipObj->confirmMsg('pages', $this->pageRow, 'into' ,$elFromTable)) .
810 '" title="' . $GLOBALS['LANG']->getLL('clip_paste', TRUE) . '">' .
811 t3lib_iconWorks::getSpriteIcon('actions-document-paste-after') . '</a>';
812 }
813
814 // If the numeric clipboard pads are enabled, display the control icons for that:
815 if ($this->clipObj->current!='normal') {
816
817 // The "select" link:
818 $cells['copyMarked'] = $this->linkClipboardHeaderIcon(
819 t3lib_iconWorks::getSpriteIcon(
820 'actions-edit-copy',
821 array('title' => $GLOBALS['LANG']->getLL('clip_selectMarked', TRUE))
822 ),
823 $table,
824 'setCB');
825
826 // The "edit marked" link:
827 $editIdList = implode(',',$currentIdList);
828 $editIdList = "'+editList('".$table."','".$editIdList."')+'";
829 $params='&edit['.$table.']['.$editIdList.']=edit&disHelp=1';
830 $cells['edit'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath, -1)) .
831 '" title="' . $GLOBALS['LANG']->getLL('clip_editMarked', TRUE) . '">' .
832 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
833 '</a>';
834
835 // The "Delete marked" link:
836 $cells['delete'] = $this->linkClipboardHeaderIcon(
837 t3lib_iconWorks::getSpriteIcon(
838 'actions-edit-delete',
839 array('title' => $GLOBALS['LANG']->getLL('clip_deleteMarked', TRUE))
840 ),
841 $table,
842 'delete',
843 sprintf($GLOBALS['LANG']->getLL('clip_deleteMarkedWarning'), $GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title']))
844 );
845
846 // The "Select all" link:
847 $cells['markAll'] = '<a class="cbcCheckAll" rel="" href="#" onclick="' .
848 htmlspecialchars('checkOffCB(\'' . implode(',', $this->CBnames) . '\', this); return false;') .
849 '" title="' . $GLOBALS['LANG']->getLL('clip_markRecords', TRUE) . '">' .
850 t3lib_iconWorks::getSpriteIcon('actions-document-select') .
851 '</a>';
852 } else {
853 $cells['empty']='';
854 }
855 /**
856 * @hook renderListHeaderActions: Allows to change the clipboard icons of the Web>List table headers
857 * @date 2007-11-20
858 * @request Bernhard Kraft <krafbt@kraftb.at>
859 * @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.
860 */
861 if(is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
862 foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
863 $hookObject = t3lib_div::getUserObj($classData);
864 if(!($hookObject instanceof localRecordList_actionsHook)) {
865 throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567850);
866 }
867 $cells = $hookObject->renderListHeaderActions($table, $currentIdList, $cells, $this);
868 }
869 }
870 $theData[$fCol]=implode('',$cells);
871 break;
872 case '_CONTROL_': // Control panel:
873 if (!$GLOBALS['TCA'][$table]['ctrl']['readOnly']) {
874
875 // If new records can be created on this page, add links:
876 if ($this->calcPerms&($table=='pages'?8:16) && $this->showNewRecLink($table)) {
877 if ($table=="tt_content" && $this->newWizards) {
878 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
879 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
880 $tmpTSc = $tmpTSc['properties']['newContentWiz.']['overrideWithExtension'];
881 $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';
882
883 $icon = '<a href="#" onclick="' . htmlspecialchars('return jumpExt(\'' . $newContentWizScriptPath . '?id=' . $this->id . '\');') . '" title="' . $GLOBALS['LANG']->getLL('new', TRUE) . '">'.
884 ($table == 'pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
885 '</a>';
886 } elseif ($table=='pages' && $this->newWizards) {
887 $icon = '<a href="' . htmlspecialchars($this->backPath . 'db_new.php?id=' . $this->id . '&pagesOnly=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))) . '" title="' . $GLOBALS['LANG']->getLL('new', TRUE) . '">'.
888 ($table=='pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
889 '</a>';
890
891 } else {
892 $params = '&edit['.$table.']['.$this->id.']=new';
893 if ($table == 'pages_language_overlay') {
894 $params .= '&overrideVals[pages_language_overlay][doktype]=' . (int) $this->pageRow['doktype'];
895 }
896 $icon = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath, -1)) . '" title="' . $GLOBALS['LANG']->getLL('new', TRUE) . '">'.
897 ($table=='pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
898 '</a>';
899 }
900 }
901
902 // If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
903 if ($permsEdit && $this->table && is_array($currentIdList)) {
904 $editIdList = implode(',',$currentIdList);
905 if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
906 $params = '&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.implode(',',$this->fieldArray).'&disHelp=1';
907 $icon .= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath, -1 )) . '" title="' . $GLOBALS['LANG']->getLL('editShownColumns', TRUE) . '">' .
908 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
909 '</a>';
910 }
911 // add an empty entry, so column count fits again after moving this into $icon
912 $theData[$fCol] = '&nbsp;';
913 }
914 break;
915 case '_AFTERCONTROL_': // space column
916 case '_AFTERREF_': // space column
917 $theData[$fCol] = '&nbsp;';
918 break;
919 default: // Regular fields header:
920 $theData[$fCol]='';
921 if ($this->table && is_array($currentIdList)) {
922
923 // If the numeric clipboard pads are selected, show duplicate sorting link:
924 if ($this->clipNumPane()) {
925 $theData[$fCol] .= '<a href="' . htmlspecialchars($this->listURL('', -1) . '&duplicateField=' . $fCol) . '" title="' . $GLOBALS['LANG']->getLL('clip_duplicates', TRUE) . '">' .
926 t3lib_iconWorks::getSpriteIcon('actions-document-duplicates-select') .
927 '</a>';
928 }
929
930 // If the table can be edited, add link for editing THIS field for all listed records:
931 if (!$GLOBALS['TCA'][$table]['ctrl']['readOnly'] && $permsEdit && $GLOBALS['TCA'][$table]['columns'][$fCol]) {
932 $editIdList = implode(',',$currentIdList);
933 if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
934 $params='&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.$fCol.'&disHelp=1';
935 $iTitle = sprintf($GLOBALS['LANG']->getLL('editThisColumn'), rtrim(trim($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel($table, $fCol))), ':'));
936 $theData[$fCol].='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'" title="'.htmlspecialchars($iTitle).'">'.
937 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
938 '</a>';
939 }
940 }
941 $theData[$fCol] .= $this->addSortLink($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel($table, $fCol, '<i>[|]</i>')), $fCol, $table);
942 break;
943 }
944
945 }
946
947 /**
948 * @hook renderListHeader: Allows to change the contents of columns/cells of the Web>List table headers
949 * @date 2007-11-20
950 * @request Bernhard Kraft <krafbt@kraftb.at>
951 * @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.
952 */
953 if(is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
954 foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
955 $hookObject = t3lib_div::getUserObj($classData);
956 if(!($hookObject instanceof localRecordList_actionsHook)) {
957 throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567855);
958 }
959 $theData = $hookObject->renderListHeader($table, $currentIdList, $theData, $this);
960 }
961 }
962
963 // Create and return header table row:
964 return $this->addelement(1, $icon, $theData, ' class="c-headLine"', '');
965 }
966
967 /**
968 * Creates a page browser for tables with many records
969 *
970 * @param string Distinguish between 'top' and 'bottom' part of the navigation (above or below the records)
971 * @return string Navigation HTML
972 *
973 */
974 protected function renderListNavigation($renderPart = 'top') {
975 $totalPages = ceil($this->totalItems / $this->iLimit);
976
977 $content = '';
978 $returnContent = '';
979
980 // Show page selector if not all records fit into one page
981 if ($totalPages > 1) {
982 $first = $previous = $next = $last = $reload = '';
983 $listURL = $this->listURL('', $this->table);
984
985 // 1 = first page
986 $currentPage = floor(($this->firstElementNumber + 1) / $this->iLimit) + 1;
987
988 // Compile first, previous, next, last and refresh buttons
989 if ($currentPage > 1) {
990 $labelFirst = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:first');
991
992 $first = '<a href="' . $listURL . '&pointer=0">' .
993 t3lib_iconWorks::getSpriteIcon('actions-view-paging-first', array('title'=> $labelFirst)) .
994 '</a>';
995 } else {
996 $first = t3lib_iconWorks::getSpriteIcon('actions-view-paging-first-disabled');
997 }
998
999 if (($currentPage - 1) > 0) {
1000 $labelPrevious = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:previous');
1001
1002 $previous = '<a href="' . $listURL . '&pointer=' . (($currentPage - 2) * $this->iLimit) . '">' .
1003 t3lib_iconWorks::getSpriteIcon('actions-view-paging-previous', array('title' => $labelPrevious)) .
1004 '</a>';
1005 } else {
1006 $previous = t3lib_iconWorks::getSpriteIcon('actions-view-paging-previous-disabled');
1007 }
1008
1009 if (($currentPage + 1) <= $totalPages) {
1010 $labelNext = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:next');
1011
1012 $next = '<a href="' . $listURL . '&pointer=' . (($currentPage) * $this->iLimit) . '">' .
1013 t3lib_iconWorks::getSpriteIcon('actions-view-paging-next', array('title' => $labelNext)) .
1014 '</a>';
1015 } else {
1016 $next = t3lib_iconWorks::getSpriteIcon('actions-view-paging-next-disabled');
1017 }
1018
1019 if ($currentPage != $totalPages) {
1020 $labelLast = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:last');
1021
1022 $last = '<a href="' . $listURL . '&pointer=' . (($totalPages - 1) * $this->iLimit) . '">' .
1023 t3lib_iconWorks::getSpriteIcon('actions-view-paging-last', array('title' => $labelLast)) .
1024 '</a>';
1025 } else {
1026 $last = t3lib_iconWorks::getSpriteIcon('actions-view-paging-last-disabled');
1027 }
1028
1029 $reload = '<a href="#" onclick="document.dblistForm.action=\''
1030 . $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) . '">' .
1031 t3lib_iconWorks::getSpriteIcon('actions-system-refresh') .
1032 '</a>';
1033
1034 if ($renderPart === 'top') {
1035 // Add js to traverse a page select input to a pointer value
1036 $content = '
1037 <script type="text/JavaScript">
1038 /*<![CDATA[*/
1039
1040 function calculatePointer(page) {
1041 if (page > ' . $totalPages . ') {
1042 page = ' . $totalPages . ';
1043 }
1044
1045 if (page < 1) {
1046 page = 1;
1047 }
1048
1049 pointer = (page - 1) * ' . $this->iLimit . ';
1050
1051 return pointer;
1052 }
1053
1054 /*]]>*/
1055 </script>
1056 ';
1057 }
1058 $pageNumberInput = '<span>
1059 <input type="text" value="' . $currentPage
1060 . '" 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;" />
1061 </span>';
1062 $pageIndicator = '<span class="pageIndicator">'
1063 . sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:pageIndicator'), $pageNumberInput, $totalPages)
1064 . '</span>';
1065
1066 if ($this->totalItems > ($this->firstElementNumber + $this->iLimit)) {
1067 $lastElementNumber = $this->firstElementNumber + $this->iLimit;
1068 } else {
1069 $lastElementNumber = $this->totalItems;
1070 }
1071 $rangeIndicator = '<span class="pageIndicator">'
1072 . sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:rangeIndicator'), $this->firstElementNumber + 1, $lastElementNumber)
1073 . '</span>';
1074
1075 $content .= '<div id="typo3-dblist-pagination">'
1076 . $first . $previous
1077 . '<span class="bar">&nbsp;</span>'
1078 . $rangeIndicator . '<span class="bar">&nbsp;</span>'
1079 . $pageIndicator . '<span class="bar">&nbsp;</span>'
1080 . $next . $last . '<span class="bar">&nbsp;</span>'
1081 . $reload
1082 . '</div>';
1083
1084 $data = Array();
1085 $titleColumn = $this->fieldArray[0];
1086 $data[$titleColumn] = $content;
1087
1088 $returnContent = $this->addElement(1, '', $data);
1089 } // end of if pages > 1
1090
1091 return $returnContent;
1092 }
1093
1094
1095
1096
1097
1098
1099 /*********************************
1100 *
1101 * Rendering of various elements
1102 *
1103 *********************************/
1104
1105 /**
1106 * Creates the control panel for a single record in the listing.
1107 *
1108 * @param string The table
1109 * @param array The record for which to make the control panel.
1110 * @return string HTML table with the control panel (unless disabled)
1111 */
1112 function makeControl($table,$row) {
1113 if ($this->dontShowClipControlPanels) return '';
1114
1115 // Initialize:
1116 t3lib_div::loadTCA($table);
1117 $cells=array();
1118
1119 // If the listed table is 'pages' we have to request the permission settings for each page:
1120 if ($table=='pages') {
1121 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid']));
1122 }
1123
1124 // This expresses the edit permissions for this particular element:
1125 $permsEdit = ($table=='pages' && ($localCalcPerms&2)) || ($table!='pages' && ($this->calcPerms&16));
1126
1127 // "Show" link (only pages and tt_content elements)
1128 if ($table=='pages' || $table=='tt_content') {
1129 $params='&edit['.$table.']['.$row['uid'].']=edit';
1130 $cells['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick(
1131 $table=='tt_content' ? $this->id . '#' . $row['uid'] : $row['uid'],
1132 $this->backPath)
1133 ) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', TRUE) . '">' .
1134 t3lib_iconWorks::getSpriteIcon('actions-document-view') . '</a>';
1135 } elseif(!$this->table) {
1136 $cells['view'] = $this->spaceIcon;
1137 }
1138
1139 // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
1140 if ($permsEdit) {
1141 $params='&edit['.$table.']['.$row['uid'].']=edit';
1142 $cells['edit'] = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath, -1)) .
1143 '" title="' . $GLOBALS['LANG']->getLL('edit', TRUE) . '">' .
1144 ( $GLOBALS['TCA'][$table]['ctrl']['readOnly'] ? t3lib_iconWorks::getSpriteIcon('actions-document-open-read-only') : t3lib_iconWorks::getSpriteIcon('actions-document-open')) .
1145 '</a>';
1146 } elseif(!$this->table) {
1147 $cells['edit'] = $this->spaceIcon;
1148 }
1149
1150 // "Move" wizard link for pages/tt_content elements:
1151 if (($table=="tt_content" && $permsEdit) || ($table=='pages')) {
1152 $cells['move'] = '<a href="#" onclick="' .
1153 htmlspecialchars(
1154 'return jumpExt(\'' . $this->backPath . 'move_el.php?table=' . $table . '&uid='.$row['uid'] . '\');'
1155 ) .'" title="' . $GLOBALS['LANG']->getLL('move_' . ($table == 'tt_content' ? 'record' : 'page'), TRUE) . '">' .
1156 ($table == 'tt_content' ? t3lib_iconWorks::getSpriteIcon('actions-document-move') : t3lib_iconWorks::getSpriteIcon('actions-page-move')) .
1157 '</a>';
1158 } elseif(!$this->table) {
1159 $cells['move'] = $this->spaceIcon;
1160 }
1161
1162 // If the extended control panel is enabled OR if we are seeing a single table:
1163 if ($GLOBALS['SOBE']->MOD_SETTINGS['bigControlPanel'] || $this->table) {
1164
1165 // "Info": (All records)
1166 $cells['viewBig'] = '<a href="#" onclick="' . htmlspecialchars(
1167 'top.launchView(\'' . $table . '\', \''.$row['uid'] . '\'); return false;'
1168 ) . '" title="' . $GLOBALS['LANG']->getLL('showInfo', TRUE) . '">'.
1169 t3lib_iconWorks::getSpriteIcon('actions-document-info') .
1170 '</a>';
1171
1172 // If the table is NOT a read-only table, then show these links:
1173 if (!$GLOBALS['TCA'][$table]['ctrl']['readOnly']) {
1174
1175 // "Revert" link (history/undo)
1176 $cells['history'] = '<a href="#" onclick="' . htmlspecialchars(
1177 'return jumpExt(\'' . $this->backPath . 'show_rechis.php?element=' . rawurlencode($table . ':' . $row['uid']) . '\',\'#latest\');') .
1178 '" title="' . $GLOBALS['LANG']->getLL('history', TRUE) . '">'.
1179 t3lib_iconWorks::getSpriteIcon('actions-document-history-open') .
1180 '</a>';
1181
1182 // Versioning:
1183 if (t3lib_extMgm::isLoaded('version') && !t3lib_extMgm::isLoaded('workspaces')) {
1184 $vers = t3lib_BEfunc::selectVersionsOfRecord($table, $row['uid'], 'uid', $GLOBALS['BE_USER']->workspace, FALSE, $row);
1185 if (is_array($vers)) { // If table can be versionized.
1186 $versionIcon = 'no-version';
1187 if (count($vers) > 1) {
1188 $versionIcon = count($vers) - 1;
1189 }
1190
1191 $cells['version'] = '<a href="' . htmlspecialchars($this->backPath . t3lib_extMgm::extRelPath('version') . 'cm1/index.php?table=' . rawurlencode($table) . '&uid=' . rawurlencode($row['uid'])) . '" title="' . $GLOBALS['LANG']->getLL('displayVersions', TRUE) . '">' .
1192 t3lib_iconWorks::getSpriteIcon('status-version-' . $versionIcon) .
1193 '</a>';
1194 } elseif(!$this->table) {
1195 $cells['version'] = $this->spaceIcon;
1196 }
1197 }
1198
1199 // "Edit Perms" link:
1200 if ($table == 'pages' && $GLOBALS['BE_USER']->check('modules','web_perm') && t3lib_extMgm::isLoaded('perm')) {
1201 $cells['perms'] =
1202 '<a href="' .
1203 htmlspecialchars(
1204 t3lib_extMgm::extRelPath('perm') . 'mod1/index.php' .
1205 '?id=' . $row['uid'] . '&return_id=' . $row['uid'] . '&edit=1'
1206 ) .
1207 '" title="' . $GLOBALS['LANG']->getLL('permissions', TRUE) .
1208 '">'.
1209 t3lib_iconWorks::getSpriteIcon('status-status-locked') .
1210 '</a>';
1211 } elseif(!$this->table && $GLOBALS['BE_USER']->check('modules','web_perm')) {
1212 $cells['perms'] = $this->spaceIcon;
1213 }
1214
1215 // "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):
1216 if ($GLOBALS['TCA'][$table]['ctrl']['sortby'] || $GLOBALS['TCA'][$table]['ctrl']['useColumnsForDefaultValues']) {
1217 if (
1218 ($table!='pages' && ($this->calcPerms&16)) || // For NON-pages, must have permission to edit content on this parent page
1219 ($table=='pages' && ($this->calcPerms&8)) // For pages, must have permission to create new pages here.
1220 ) {
1221 if ($this->showNewRecLink($table)) {
1222 $params='&edit['.$table.']['.(-($row['_MOVE_PLH']?$row['_MOVE_PLH_uid']:$row['uid'])).']=new';
1223 $cells['new'] = '<a href="#" onclick="' . htmlspecialchars(
1224 t3lib_BEfunc::editOnClick($params, $this->backPath, -1)) .
1225 '" title="' . $GLOBALS['LANG']->getLL('new' . ($table == 'pages '? 'Page' : 'Record'), TRUE) . '">' .
1226 ($table == 'pages' ? t3lib_iconWorks::getSpriteIcon('actions-page-new') : t3lib_iconWorks::getSpriteIcon('actions-document-new')) .
1227 '</a>';
1228 }
1229 }
1230 } elseif(!$this->table) {
1231 $cells['new'] = $this->spaceIcon;
1232 }
1233
1234 // "Up/Down" links
1235 if ($permsEdit && $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField && !$this->searchLevels) {
1236 if (isset($this->currentTable['prev'][$row['uid']])) { // Up
1237 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prev'][$row['uid']];
1238 $cells['moveUp'] = '<a href="#" onclick="' . htmlspecialchars(
1239 'return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');'
1240 ) .'" title="'.$GLOBALS['LANG']->getLL('moveUp', TRUE) . '">' .
1241 t3lib_iconWorks::getSpriteIcon('actions-move-up') .
1242 '</a>';
1243 } else {
1244 $cells['moveUp'] = $this->spaceIcon;
1245 }
1246 if ($this->currentTable['next'][$row['uid']]) { // Down
1247 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['next'][$row['uid']];
1248 $cells['moveDown']='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$GLOBALS['SOBE']->doc->issueCommand($params,-1).'\');').'" title="'.$GLOBALS['LANG']->getLL('moveDown', TRUE) . '">' .
1249 t3lib_iconWorks::getSpriteIcon('actions-move-down') .
1250 '</a>';
1251 } else {
1252 $cells['moveDown'] = $this->spaceIcon;
1253 }
1254 } elseif(!$this->table) {
1255 $cells['moveUp'] = $this->spaceIcon;
1256 $cells['moveDown'] = $this->spaceIcon;
1257 }
1258
1259 // "Hide/Unhide" links:
1260 $hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
1261 if ($permsEdit && $hiddenField && $GLOBALS['TCA'][$table]['columns'][$hiddenField] && (!$GLOBALS['TCA'][$table]['columns'][$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $hiddenField))) {
1262 if ($row[$hiddenField]) {
1263 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=0';
1264 $cells['hide']='<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');') . '" title="'.$GLOBALS['LANG']->getLL('unHide' . ($table == 'pages' ? 'Page' : ''), TRUE) . '">' .
1265 t3lib_iconWorks::getSpriteIcon('actions-edit-unhide') .
1266 '</a>';
1267 } else {
1268 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=1';
1269 $cells['hide']='<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');') . '" title="' . $GLOBALS['LANG']->getLL('hide' . ($table == 'pages' ? 'Page' : ''), TRUE) . '">' .
1270 t3lib_iconWorks::getSpriteIcon('actions-edit-hide') .
1271 '</a>';
1272 }
1273 } elseif(!$this->table) {
1274 $cells['hide'] = $this->spaceIcon;
1275 }
1276
1277 // "Delete" link:
1278 if (($table=='pages' && ($localCalcPerms&4)) || ($table!='pages' && ($this->calcPerms&16))) {
1279 $titleOrig = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
1280 $title = t3lib_div::slashJS(t3lib_div::fixed_lgd_cs($titleOrig, $this->fixedL), 1);
1281 $params = '&cmd['.$table.']['.$row['uid'].'][delete]=1';
1282
1283 $refCountMsg = t3lib_BEfunc::referenceCount(
1284 $table,
1285 $row['uid'],
1286 ' ' . $GLOBALS['LANG']->sL(
1287 'LLL:EXT:lang/locallang_core.xml:labels.referencesToRecord'
1288 ),
1289 $this->getReferenceCount($table, $row['uid'])
1290 ) .
1291 t3lib_BEfunc::translationCount($table, $row['uid'], ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.translationsOfRecord'));
1292 $cells['delete'] = '<a href="#" onclick="' . htmlspecialchars('if (confirm(' . $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('deleteWarning') . ' "' . $title . '" ' . $refCountMsg) . ')) {jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');} return false;') . '" title="' . $GLOBALS['LANG']->getLL('delete', TRUE) . '">' .
1293 t3lib_iconWorks::getSpriteIcon('actions-edit-delete') .
1294 '</a>';
1295 } elseif(!$this->table) {
1296 $cells['delete'] = $this->spaceIcon;
1297 }
1298
1299 // "Levels" links: Moving pages into new levels...
1300 if ($permsEdit && $table=='pages' && !$this->searchLevels) {
1301
1302 // Up (Paste as the page right after the current parent page)
1303 if ($this->calcPerms&8) {
1304 $params='&cmd['.$table.']['.$row['uid'].'][move]='.-$this->id;
1305 $cells['moveLeft'] = '<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');') . '" title="' . $GLOBALS['LANG']->getLL('prevLevel', TRUE) . '">' .
1306 t3lib_iconWorks::getSpriteIcon('actions-move-left') .
1307 '</a>';
1308 }
1309 // Down (Paste as subpage to the page right above)
1310 if ($this->currentTable['prevUid'][$row['uid']]) {
1311 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$this->currentTable['prevUid'][$row['uid']]));
1312 if ($localCalcPerms&8) {
1313 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prevUid'][$row['uid']];
1314 $cells['moveRight'] = '<a href="#" onclick="' . htmlspecialchars('return jumpToUrl(\'' . $GLOBALS['SOBE']->doc->issueCommand($params, -1) . '\');') . '" title="' . $GLOBALS['LANG']->getLL('nextLevel', TRUE) . '">' .
1315 t3lib_iconWorks::getSpriteIcon('actions-move-right') .
1316 '</a>';
1317 } else {
1318 $cells['moveRight'] = $this->spaceIcon;
1319 }
1320 } else {
1321 $cells['moveRight'] = $this->spaceIcon;
1322 }
1323 } elseif(!$this->table) {
1324 $cells['moveLeft'] = $this->spaceIcon;
1325 $cells['moveRight'] = $this->spaceIcon;
1326 }
1327 }
1328 }
1329
1330
1331 /**
1332 * @hook recStatInfoHooks: Allows to insert HTML before record icons on various places
1333 * @date 2007-09-22
1334 * @request Kasper Skårhøj <kasper2007@typo3.com>
1335 */
1336 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) {
1337 $stat='';
1338 $_params = array($table,$row['uid']);
1339 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) {
1340 $stat.=t3lib_div::callUserFunction($_funcRef,$_params,$this);
1341 }
1342 $cells['stat'] = $stat;
1343 }
1344 /**
1345 * @hook makeControl: Allows to change control icons of records in list-module
1346 * @date 2007-11-20
1347 * @request Bernhard Kraft <krafbt@kraftb.at>
1348 * @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.
1349 */
1350 if(is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1351 foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1352 $hookObject = t3lib_div::getUserObj($classData);
1353 if(!($hookObject instanceof localRecordList_actionsHook)) {
1354 throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567840);
1355 }
1356 $cells = $hookObject->makeControl($table, $row, $cells, $this);
1357 }
1358 }
1359
1360 // Compile items into a DIV-element:
1361 return '
1362 <!-- CONTROL PANEL: '.$table.':'.$row['uid'].' -->
1363 <div class="typo3-DBctrl">'.implode('',$cells).'</div>';
1364 }
1365
1366 /**
1367 * Creates the clipboard panel for a single record in the listing.
1368 *
1369 * @param string The table
1370 * @param array The record for which to make the clipboard panel.
1371 * @return string HTML table with the clipboard panel (unless disabled)
1372 */
1373 function makeClip($table,$row) {
1374 // Return blank, if disabled:
1375 if ($this->dontShowClipControlPanels) return '';
1376 $cells=array();
1377
1378 $cells['pasteAfter'] = $cells['pasteInto'] = $this->spaceIcon;
1379 //enables to hide the copy, cut and paste icons for localized records - doesn't make much sense to perform these options for them
1380 $isL10nOverlay = $this->localizationView && $table != 'pages_language_overlay' && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0;
1381 // Return blank, if disabled:
1382 // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel:
1383 if ($this->clipObj->current=='normal') { // For the "Normal" pad:
1384
1385 // Show copy/cut icons:
1386 $isSel = (string)$this->clipObj->isSelected($table,$row['uid']);
1387 $cells['copy'] = $isL10nOverlay ? $this->spaceIcon : '<a href="#" onclick="' . htmlspecialchars('return jumpSelf(\'' . $this->clipObj->selUrlDB($table, $row['uid'], 1, ($isSel=='copy'), array('returnUrl'=>'')) . '\');') . '" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.copy', TRUE) . '">' .
1388 ((!$isSel=='copy') ? t3lib_iconWorks::getSpriteIcon('actions-edit-copy') : t3lib_iconWorks::getSpriteIcon('actions-edit-copy-release')) .
1389 '</a>';
1390 $cells['cut'] = $isL10nOverlay ? $this->spaceIcon : '<a href="#" onclick="' . htmlspecialchars('return jumpSelf(\'' . $this->clipObj->selUrlDB($table, $row['uid'], 0, ($isSel == 'cut'), array('returnUrl'=>'')) . '\');') . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.cut', TRUE) . '">' .
1391 ((!$isSel=='cut') ? t3lib_iconWorks::getSpriteIcon('actions-edit-cut') : t3lib_iconWorks::getSpriteIcon('actions-edit-cut-release')) .
1392 '</a>';
1393
1394 } else { // For the numeric clipboard pads (showing checkboxes where one can select elements on/off)
1395
1396 // Setting name of the element in ->CBnames array:
1397 $n=$table.'|'.$row['uid'];
1398 $this->CBnames[]=$n;
1399
1400 // Check if the current element is selected and if so, prepare to set the checkbox as selected:
1401 $checked = ($this->clipObj->isSelected($table,$row['uid'])?' checked="checked"':'');
1402
1403 // If the "duplicateField" value is set then select all elements which are duplicates...
1404 if ($this->duplicateField && isset($row[$this->duplicateField])) {
1405 $checked='';
1406 if (in_array($row[$this->duplicateField], $this->duplicateStack)) {
1407 $checked=' checked="checked"';
1408 }
1409 $this->duplicateStack[] = $row[$this->duplicateField];
1410 }
1411
1412 // Adding the checkbox to the panel:
1413 $cells['select'] = $isL10nOverlay ? $this->spaceIcon : '<input type="hidden" name="CBH['.$n.']" value="0" /><input type="checkbox" name="CBC['.$n.']" value="1" class="smallCheckboxes"'.$checked.' />';
1414 }
1415
1416 // Now, looking for selected elements from the current table:
1417 $elFromTable = $this->clipObj->elFromTable($table);
1418 if (count($elFromTable) && $GLOBALS['TCA'][$table]['ctrl']['sortby']){
1419 // IF elements are found and they can be individually ordered, then add a "paste after" icon:
1420 $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="' . $GLOBALS['LANG']->getLL('clip_pasteAfter', TRUE) . '">' .
1421 t3lib_iconWorks::getSpriteIcon('actions-document-paste-after') .
1422 '</a>';
1423 }
1424
1425 // Now, looking for elements in general:
1426 $elFromTable = $this->clipObj->elFromTable('');
1427 if ($table=='pages' && count($elFromTable)) {
1428 $cells['pasteInto'] = '<a href="' . htmlspecialchars($this->clipObj->pasteUrl('', $row['uid'])) . '" onclick="' . htmlspecialchars('return ' . $this->clipObj->confirmMsg($table, $row, 'into', $elFromTable)) . '" title="' . $GLOBALS['LANG']->getLL('clip_pasteInto', TRUE) . '">' .
1429 t3lib_iconWorks::getSpriteIcon('actions-document-paste-into') .
1430 '</a>';
1431 }
1432
1433 /*
1434 * @hook makeClip: Allows to change clip-icons of records in list-module
1435 * @date 2007-11-20
1436 * @request Bernhard Kraft <krafbt@kraftb.at>
1437 * @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.
1438 */
1439 if(is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1440 foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1441 $hookObject = t3lib_div::getUserObj($classData);
1442 if(!($hookObject instanceof localRecordList_actionsHook)) {
1443 throw new UnexpectedValueException('$hookObject must implement interface localRecordList_actionsHook', 1195567845);
1444 }
1445 $cells = $hookObject->makeClip($table, $row, $cells, $this);
1446 }
1447 }
1448
1449 // Compile items into a DIV-element:
1450 return ' <!-- CLIPBOARD PANEL: '.$table.':'.$row['uid'].' -->
1451 <div class="typo3-clipCtrl">'.implode('',$cells).'</div>';
1452 }
1453
1454 /**
1455 * Make reference count
1456 *
1457 * @param string Table name
1458 * @param integer UID of record
1459 * @return string HTML-table
1460 *
1461 * @deprecated since 4.4, will be removed in TYPO3 4.6 - Use createReferenceHtml() instead
1462 */
1463 function makeRef($table,$uid) {
1464 t3lib_div::logDeprecatedFunction();
1465
1466 // Compile information for title tag:
1467 $infoData=array();
1468 if (is_array($this->references)) {
1469 foreach ($this->references as $row) {
1470 $infoData[]=$row['tablename'].':'.$row['recuid'].':'.$row['field'];
1471 }
1472 }
1473
1474 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>' : '';
1475 }
1476
1477 /**
1478 * Creates the HTML for a reference count for the record with the UID $uid
1479 * in the table $tableName.
1480 *
1481 * @param string $tableName
1482 * table name of the referenced record, must not be empty
1483 * @param integer $uid
1484 * UID of the referenced record, must be > 0
1485 *
1486 * @return string HTML of reference a link, will be empty if there are no
1487 * references to the corresponding record
1488 */
1489 protected function createReferenceHtml($tableName, $uid) {
1490 $referenceCount = $this->getReferenceCount($tableName, $uid);
1491 if ($referenceCount == 0) {
1492 return '';
1493 }
1494
1495 $queryResult = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1496 'tablename, recuid, field',
1497 'sys_refindex',
1498 'ref_table = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(
1499 $tableName, 'sys_refindex'
1500 ) .
1501 ' AND ref_uid = ' . $uid .
1502 ' AND deleted = 0',
1503 '',
1504 '',
1505 '0,20'
1506 );
1507
1508 $referenceTitles = array();
1509
1510 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($queryResult)) {
1511 $referenceTitles[] = $row['tablename'] . ':' . $row['recuid'] .
1512 ':' . $row['field'];
1513 if (strlen(implode(' / ', $referenceTitles)) >= 100) {
1514 break;
1515 }
1516 }
1517 $GLOBALS['TYPO3_DB']->sql_free_result($queryResult);
1518
1519 return '<a href="#" ' .
1520 'onclick="' . htmlspecialchars(
1521 'top.launchView(\'' . $tableName . '\', \'' . $uid .
1522 '\'); return false;'
1523 ) . '" ' .
1524 'title="' . htmlspecialchars(
1525 t3lib_div::fixed_lgd_cs(implode(' / ', $referenceTitles), 100)
1526 ) . '">' . $referenceCount . '</a>';
1527 }
1528
1529 /**
1530 * Creates the localization panel
1531 *
1532 * @param string The table
1533 * @param array The record for which to make the localization panel.
1534 * @return array Array with key 0/1 with content for column 1 and 2
1535 */
1536 function makeLocalizationPanel($table,$row) {
1537 $out = array(
1538 0 => '',
1539 1 => '',
1540 );
1541
1542 $translations = $this->translateTools->translationInfo($table, $row['uid'], 0, $row, $this->selFieldList);
1543 $this->translations = $translations['translations'];
1544
1545 // Language title and icon:
1546 $out[0] = $this->languageFlag($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
1547
1548 if (is_array($translations)) {
1549
1550 // Traverse page translations and add icon for each language that does NOT yet exist:
1551 $lNew = '';
1552 foreach($this->pageOverlays as $lUid_OnPage => $lsysRec) {
1553 if (!isset($translations['translations'][$lUid_OnPage]) && $GLOBALS['BE_USER']->checkLanguageAccess($lUid_OnPage)) {
1554 $url = substr($this->listURL(), strlen($this->backPath));
1555 $href = $GLOBALS['SOBE']->doc->issueCommand(
1556 '&cmd[' . $table . '][' . $row['uid'] . '][localize]=' . $lUid_OnPage,
1557 $url . '&justLocalized=' . rawurlencode($table . ':' . $row['uid'] . ':' . $lUid_OnPage)
1558 );
1559 $language = t3lib_BEfunc::getRecord('sys_language', $lUid_OnPage, 'title');
1560 if ($this->languageIconTitles[$lUid_OnPage]['flagIcon']) {
1561 $lC = t3lib_iconWorks::getSpriteIcon($this->languageIconTitles[$lUid_OnPage]['flagIcon']);
1562 } else {
1563 $lC = $this->languageIconTitles[$lUid_OnPage]['title'];
1564 }
1565 $lC = '<a href="' . htmlspecialchars($href) . '" title="' . htmlspecialchars($language['title']) . '">' . $lC . '</a> ';
1566
1567 $lNew.=$lC;
1568 }
1569 }
1570
1571 if ($lNew) $out[1].= $lNew;
1572 } elseif ($row['l18n_parent']) {
1573 $out[0] = '&nbsp;&nbsp;&nbsp;&nbsp;'.$out[0];
1574 }
1575
1576
1577 return $out;
1578 }
1579
1580 /**
1581 * Create the selector box for selecting fields to display from a table:
1582 *
1583 * @param string Table name
1584 * @param boolean If TRUE, form-fields will be wrapped around the table.
1585 * @return string HTML table with the selector box (name: displayFields['.$table.'][])
1586 */
1587 function fieldSelectBox($table,$formFields=1) {
1588
1589 // Init:
1590 t3lib_div::loadTCA($table);
1591 $formElements=array('','');
1592 if ($formFields) {
1593 $formElements=array('<form action="'.htmlspecialchars($this->listURL()).'" method="post">','</form>');
1594 }
1595
1596 // Load already selected fields, if any:
1597 $setFields=is_array($this->setFields[$table]) ? $this->setFields[$table] : array();
1598
1599 // Request fields from table:
1600 $fields = $this->makeFieldList($table, FALSE, TRUE);
1601
1602 // Add pseudo "control" fields
1603 $fields[]='_PATH_';
1604 $fields[]='_REF_';
1605 $fields[]='_LOCALIZATION_';
1606 $fields[]='_CONTROL_';
1607 $fields[]='_CLIPBOARD_';
1608
1609 // Create an option for each field:
1610 $opt=array();
1611 $opt[] = '<option value=""></option>';
1612 foreach($fields as $fN) {
1613 // Field label
1614 $fL = (is_array($GLOBALS['TCA'][$table]['columns'][$fN])
1615 ? rtrim($GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['columns'][$fN]['label']), ':')
1616 : '[' . $fN . ']');
1617 $opt[] = '
1618 <option value="'.$fN.'"'.(in_array($fN,$setFields)?' selected="selected"':'').'>'.htmlspecialchars($fL).'</option>';
1619 }
1620
1621 // Compile the options into a multiple selector box:
1622 $lMenu = '
1623 <select size="'.t3lib_utility_Math::forceIntegerInRange(count($fields)+1,3,20).'" multiple="multiple" name="displayFields['.$table.'][]">'.implode('',$opt).'
1624 </select>
1625 ';
1626
1627 // Table with the field selector::
1628 $content.= '
1629 '.$formElements[0].'
1630
1631 <!--
1632 Field selector for extended table view:
1633 -->
1634 <table border="0" cellpadding="0" cellspacing="0" id="typo3-dblist-fieldSelect">
1635 <tr>
1636 <td>'.$lMenu.'</td>
1637 <td><input type="submit" name="search" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.setFields', 1) . '" /></td>
1638 </tr>
1639 </table>
1640 '.$formElements[1];
1641 return $content;
1642 }
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654 /*********************************
1655 *
1656 * Helper functions
1657 *
1658 *********************************/
1659
1660 /**
1661 * Creates a link around $string. The link contains an onclick action which submits the script with some clipboard action.
1662 * Currently, this is used for setting elements / delete elements.
1663 *
1664 * @param string The HTML content to link (image/text)
1665 * @param string Table name
1666 * @param string Clipboard command (eg. "setCB" or "delete")
1667 * @param string Warning text, if any ("delete" uses this for confirmation)
1668 * @return string <a> tag wrapped link.
1669 */
1670 function linkClipboardHeaderIcon($string,$table,$cmd,$warning='') {
1671 $onClickEvent = 'document.dblistForm.cmd.value=\''.$cmd.'\';document.dblistForm.cmd_table.value=\''.$table.'\';document.dblistForm.submit();';
1672 if ($warning) $onClickEvent = 'if (confirm('.$GLOBALS['LANG']->JScharCode($warning).')){'.$onClickEvent.'}';
1673 return '<a href="#" onclick="'.htmlspecialchars($onClickEvent.'return false;').'">'.$string.'</a>';
1674 }
1675
1676 /**
1677 * Returns TRUE if a numeric clipboard pad is selected/active
1678 *
1679 * @return boolean
1680 */
1681 function clipNumPane() {
1682 return in_Array('_CLIPBOARD_',$this->fieldArray) && $this->clipObj->current!='normal';
1683 }
1684
1685 /**
1686 * Creates a sort-by link on the input string ($code).
1687 * It will automatically detect if sorting should be ascending or descending depending on $this->sortRev.
1688 * Also some fields will not be possible to sort (including if single-table-view is disabled).
1689 *
1690 * @param string The string to link (text)
1691 * @param string The fieldname represented by the title ($code)
1692 * @param string Table name
1693 * @return string Linked $code variable
1694 */
1695 function addSortLink($code,$field,$table) {
1696
1697 // Certain circumstances just return string right away (no links):
1698 if ($field=='_CONTROL_' || $field=='_LOCALIZATION_' || $field=='_CLIPBOARD_' || $field=='_REF_' || $this->disableSingleTableView) return $code;
1699
1700 // If "_PATH_" (showing record path) is selected, force sorting by pid field (will at least group the records!)
1701 if ($field=='_PATH_') $field=pid;
1702
1703 // Create the sort link:
1704 $sortUrl = $this->listURL('', -1, 'sortField,sortRev,table,firstElementNumber') . '&table=' . $table . '&sortField=' . $field . '&sortRev=' . ($this->sortRev || ($this->sortField != $field) ? 0 : 1);
1705 $sortArrow = ($this->sortField==$field?'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/red'.($this->sortRev?'up':'down').'.gif','width="7" height="4"').' alt="" />':'');
1706
1707 // Return linked field:
1708 return '<a href="'.htmlspecialchars($sortUrl).'">'.$code.
1709 $sortArrow.
1710 '</a>';
1711 }
1712
1713 /**
1714 * Returns the path for a certain pid
1715 * The result is cached internally for the session, thus you can call this function as much as you like without performance problems.
1716 *
1717 * @param integer The page id for which to get the path
1718 * @return string The path.
1719 */
1720 function recPath($pid) {
1721 if (!isset($this->recPath_cache[$pid])) {
1722 $this->recPath_cache[$pid] = t3lib_BEfunc::getRecordPath($pid,$this->perms_clause,20);
1723 }
1724 return $this->recPath_cache[$pid];
1725 }
1726
1727 /**
1728 * Returns TRUE if a link for creating new records should be displayed for $table
1729 *
1730 * @param string Table name
1731 * @return boolean Returns TRUE if a link for creating new records should be displayed for $table
1732 * @see SC_db_new::showNewRecLink
1733 */
1734 function showNewRecLink($table) {
1735 // No deny/allow tables are set:
1736 if (!count($this->allowedNewTables) && !count($this->deniedNewTables)) {
1737 return TRUE;
1738 // If table is not denied (which takes precedence over allowed tables):
1739 } elseif (!in_array($table, $this->deniedNewTables) && (!count($this->allowedNewTables) || in_array($table, $this->allowedNewTables))) {
1740 return TRUE;
1741 // If table is denied or allowed tables are set, but table is not part of:
1742 } else {
1743 return FALSE;
1744 }
1745 }
1746
1747 /**
1748 * 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.
1749 * Uses REQUEST_URI as value.
1750 *
1751 * @return string
1752 */
1753 function makeReturnUrl() {
1754 return '&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
1755 }
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767 /************************************
1768 *
1769 * CSV related functions
1770 *
1771 ************************************/
1772
1773 /**
1774 * Initializes internal csvLines array with the header of field names
1775 *
1776 * @return void
1777 */
1778 protected function initCSV() {
1779 $this->addHeaderRowToCSV();
1780 }
1781
1782 /**
1783 * Add header line with field names as CSV line
1784 *
1785 * @return void
1786 */
1787 protected function addHeaderRowToCSV() {
1788 // Add header row, control fields will be reduced inside addToCSV()
1789 $this->addToCSV(array_combine($this->fieldArray, $this->fieldArray));
1790 }
1791
1792 /**
1793 * Adds selected columns of one table row as CSV line.
1794 *
1795 * @param array Record array, from which the values of fields found in $this->fieldArray will be listed in the CSV output.
1796 * @param string Table name @deprecated since 4.4
1797 * @return void
1798 */
1799 protected function addToCSV(array $row = array(), $table = '') {
1800 $rowReducedByControlFields = self::removeControlFieldsFromFieldRow($row);
1801 $rowReducedToSelectedColumns = array_intersect_key($rowReducedByControlFields, array_flip($this->fieldArray));
1802 $this->setCsvRow($rowReducedToSelectedColumns);
1803 }
1804
1805 /**
1806 * Remove control fields from row for CSV export
1807 *
1808 * @param array fieldNames => fieldValues
1809 * @return array Input array reduces by control fields
1810 */
1811 protected static function removeControlFieldsFromFieldRow(array $row = array()) {
1812 // Possible control fields in a list row
1813 $controlFields = array(
1814 '_PATH_',
1815 '_REF_',
1816 '_CONTROL_',
1817 '_AFTERCONTROL_',
1818 '_AFTERREF_',
1819 '_CLIPBOARD_',
1820 '_LOCALIZATION_',
1821 '_LOCALIZATION_b',
1822 );
1823 return array_diff_key($row, array_flip($controlFields));
1824 }
1825
1826
1827 /**
1828 * Adds input row of values to the internal csvLines array as a CSV formatted line
1829 *
1830 * @param array Array with values to be listed.
1831 * @return void
1832 */
1833 function setCsvRow($csvRow) {
1834 $this->csvLines[] = t3lib_div::csvValues($csvRow);
1835 }
1836
1837 /**
1838 * Compiles the internal csvLines array to a csv-string and outputs it to the browser.
1839 * This function exits!
1840 *
1841 * @param string Filename prefix:
1842 * @return void EXITS php execusion!
1843 */
1844 function outputCSV($prefix) {
1845
1846 // Setting filename:
1847 $filename=$prefix.'_'.date('dmy-Hi').'.csv';
1848
1849 // Creating output header:
1850 $mimeType = 'application/octet-stream';
1851 Header('Content-Type: '.$mimeType);
1852 Header('Content-Disposition: attachment; filename='.$filename);
1853
1854 // Printing the content of the CSV lines:
1855 echo implode(chr(13).chr(10),$this->csvLines);
1856
1857 // Exits:
1858 exit;
1859 }
1860 }
1861
1862
1863
1864 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc'])) {
1865 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc']);
1866 }
1867
1868 ?>