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