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