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