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