* Added Page TSconfig option "mod.web_list.listOnlyInSingleTableView = 1" which makes...
[Packages/TYPO3.CMS.git] / typo3 / class.db_list_extra.inc
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2004 Kasper Skaarhoj (kasper@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 <kasper@typo3.com>
36 */
37 /**
38 * [CLASS/FUNCTION INDEX of SCRIPT]
39 *
40 *
41 *
42 * 89: class localRecordList extends recordList
43 * 121: function writeTop($row,$path)
44 * 295: function getTable($table,$id,$rowlist)
45 * 476: function renderListRow($table,$row,$cc,$titleCol,$thumbsCol)
46 * 539: function renderListHeader($table,$currentIdList)
47 *
48 * SECTION: Rendering of various elements
49 * 678: function makeControl($table,$row)
50 * 852: function makeClip($table,$row)
51 * 921: function fieldSelectBox($table,$formFields=1)
52 *
53 * SECTION: Helper functions
54 * 1000: function linkClipboardHeaderIcon($string,$table,$cmd,$warning='')
55 * 1011: function clipNumPane()
56 * 1025: function addSortLink($code,$field,$table)
57 * 1050: function recPath($pid)
58 * 1063: function showNewRecLink($table)
59 * 1073: function makeReturnUrl()
60 *
61 * SECTION: CSV related functions
62 * 1097: function initCSV()
63 * 1119: function addToCSV($row)
64 * 1141: function setCsvRow($csvRow)
65 * 1152: function outputCSV($prefix)
66 *
67 * TOTAL FUNCTIONS: 17
68 * (This index is automatically created/updated by the extension "extdeveval")
69 *
70 */
71
72
73
74
75
76
77
78
79
80
81
82 /**
83 * Class for rendering of Web>List module
84 *
85 * @author Kasper Skaarhoj <kasper@typo3.com>
86 * @package TYPO3
87 * @subpackage core
88 */
89 class localRecordList extends recordList {
90
91 // External:
92 var $alternateBgColors=FALSE; // If true, table rows in the list will alternate in background colors (and have background colors at all!)
93 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.
94 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!).
95
96 var $dontShowClipControlPanels=FALSE; // If true, will disable the rendering of clipboard + control panels.
97 var $showClipboard=FALSE; // If true, will show the clipboard in the field list.
98 var $noControlPanels = FALSE; // If true, will DISABLE all control panels in lists. (Takes precedence)
99
100
101
102
103 // Internal:
104 var $pageRow=array(); // Set to the page record (see writeTop())
105
106 var $csvLines=array(); // Used to accumulate CSV lines in for CSV export.
107 var $csvOutput=FALSE; // If set, the listing is returned as CSV instead.
108
109 var $clipObj; // Clipboard object
110 var $CBnames=array(); // Tracking names of elements (for clipboard use)
111 var $duplicateStack=array(); // Used to track which elements has duplicates and how many
112
113
114 /**
115 * Writes the top of the full listing
116 *
117 * @param array Current page record
118 * @return void (Adds content to internal variable, $this->HTMLcode)
119 */
120 function writeTop($row) {
121 global $LANG;
122
123 // Makes the code for the pageicon in the top
124 $this->pageRow=$row;
125 $this->counter++;
126 $alttext = t3lib_BEfunc::getRecordIconAltText($row,'pages');
127 $iconImg = t3lib_iconWorks::getIconImage('pages',$row,$this->backPath,'title="'.htmlspecialchars($alttext).'"');
128 $titleCol='test'; // pseudo title column name
129 $this->fieldArray = Array($titleCol,'up'); // Setting the fields to display in the list (this is of course "pseudo fields" since this is the top!)
130
131
132 // Filling in the pseudo data array:
133 $theData = Array();
134 $theData[$titleCol] = $this->widthGif;
135
136 // Get users permissions for this row:
137 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms($row);
138
139 $theData['up']=array();
140
141 // Initialize control panel for currect page ($this->id):
142 // Some of the controls are added only if $this->id is set - since they make sense only on a real page, not root level.
143 $theCtrlPanel =array();
144
145 // "View page" icon is added:
146 $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($this->id,'',t3lib_BEfunc::BEgetRootLine($this->id))).'">'.
147 '<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="" />'.
148 '</a>';
149
150 // If edit permissions are set (see class.t3lib_userauthgroup.php)
151 if ($localCalcPerms&2) {
152
153 // Adding "Edit page" icon:
154 if ($this->id) {
155 $params='&edit[pages]['.$row['uid'].']=edit';
156 $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
157 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('editPage',1).'" alt="" />'.
158 '</a>';
159 }
160
161 // Adding "New record" icon:
162 if (!$GLOBALS['SOBE']->modTSconfig['properties']['noCreateRecordsLink']) {
163 $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\'db_new.php?id='.$this->id.'\');').'">'.
164 '<img'.t3lib_iconWorks::skinImg('','gfx/new_el.gif','width="11" height="12"').' title="'.$LANG->getLL('newRecordGeneral',1).'" alt="" />'.
165 '</a>';
166 }
167
168 // Adding "Hide/Unhide" icon:
169 if ($this->id) {
170 if ($row['hidden']) {
171 $params='&data[pages]['.$row['uid'].'][hidden]=0';
172 $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$GLOBALS['SOBE']->doc->issueCommand($params,-1).'\');').'">'.
173 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_unhide.gif','width="11" height="10"').' title="'.$LANG->getLL('unHidePage',1).'" alt="" />'.
174 '</a>';
175 } else {
176 $params='&data[pages]['.$row['uid'].'][hidden]=1';
177 $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$GLOBALS['SOBE']->doc->issueCommand($params,-1).'\');').'">'.
178 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_hide.gif','width="11" height="10"').' title="'.$LANG->getLL('hidePage',1).'" alt="" />'.
179 '</a>';
180 }
181 }
182
183 // Adding "move page" button:
184 if ($this->id) {
185 $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\'move_el.php?table=pages&uid='.$row['uid'].'\');').'">'.
186 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/move_'.($table=='tt_content'?'record':'page').'.gif','width="11" height="12"').' title="'.$LANG->getLL('move_page',1).'" alt="" />'.
187 '</a>';
188 }
189 }
190
191 // "Paste into page" link:
192 if (($localCalcPerms&8) || ($localCalcPerms&16)) {
193 $elFromTable = $this->clipObj->elFromTable('');
194 if (count($elFromTable)) {
195 $theCtrlPanel[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('',$this->id)).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg('pages',$this->pageRow,'into',$elFromTable)).'">'.
196 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteafter.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_paste',1).'" alt="" />'.
197 '</a>';
198 }
199 }
200
201 // Finally, compile all elements of the control panel into table cells:
202 if (count($theCtrlPanel)) {
203 $theData['up'][]='
204
205 <!--
206 Control panel for page
207 -->
208 <table border="0" cellpadding="0" cellspacing="0" class="bgColor4" id="typo3-dblist-ctrltop">
209 <tr>
210 <td>'.implode('</td>
211 <td>',$theCtrlPanel).'</td>
212 </tr>
213 </table>';
214 }
215
216
217 // Add "clear-cache" link:
218 $theData['up'][]='<a href="'.htmlspecialchars($this->listURL().'&clear_cache=1').'">'.
219 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clear_cache.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.clear_cache',1).'" alt="" />'.
220 '</a>';
221
222 // Add "CSV" link, if a specific table is shown:
223 if ($this->table) {
224 $theData['up'][]='<a href="'.htmlspecialchars($this->listURL().'&csv=1').'">'.
225 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/csv.gif','width="27" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.csv',1).'" alt="" />'.
226 '</a>';
227 }
228
229 // Add "refresh" link:
230 $theData['up'][]='<a href="'.htmlspecialchars($this->listURL()).'">'.
231 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/refresh_n.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.reload',1).'" alt="" />'.
232 '</a>';
233
234
235 // Add icon with clickmenu, etc:
236 if ($this->id) { // If there IS a real page...:
237
238 // Setting title of page + the "Go up" link:
239 $theData[$titleCol].='<br /><span title="'.htmlspecialchars($row['_thePathFull']).'">'.htmlspecialchars(t3lib_div::fixed_lgd_pre($row['_thePath'],$this->fixedL)).'</span>';
240 $theData['up'][]='<a href="'.htmlspecialchars($this->listURL($row['pid'])).'">'.
241 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/pages_up.gif','width="18" height="16"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel',1).'" alt="" />'.
242 '</a>';
243
244 // Make Icon:
245 $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg,'pages',$this->id);
246 } else { // On root-level of page tree:
247
248 // Setting title of root (sitename):
249 $theData[$titleCol].='<br />'.htmlspecialchars(t3lib_div::fixed_lgd_pre($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],$this->fixedL));
250
251 // Make Icon:
252 $theIcon='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_website.gif','width="18" height="16"').' alt="" />';
253 }
254
255 // If there is a returnUrl given, add a back-link:
256 if ($this->returnUrl) {
257 $theData['up'][]='<a href="'.htmlspecialchars(t3lib_div::linkThisUrl($this->returnUrl,array('id'=>$this->id))).'" class="typo3-goBack">'.
258 '<img'.t3lib_iconWorks::skinImg($GLOBALS["BACK_PATH"],'gfx/goback.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.goBack',1).'" alt="" />'.
259 '</a>';
260 }
261
262 // Finally, the "up" pseudo field is compiled into a table - has been accumulated in an array:
263 $theData['up']='
264 <table border="0" cellpadding="0" cellspacing="0">
265 <tr>
266 <td>'.implode('</td>
267 <td>',$theData['up']).'</td>
268 </tr>
269 </table>';
270
271 // ... and the element row is created:
272 $out.=$this->addelement(1,'',$theData,'',$this->leftMargin,$theIcon);
273
274 // ... and wrapped into a table and added to the internal ->HTMLcode variable:
275 $this->HTMLcode.='
276
277
278 <!--
279 Page header for db_list:
280 -->
281 <table border="0" cellpadding="0" cellspacing="0" id="typo3-dblist-top">
282 '.$out.'
283 </table>';
284 }
285
286 /**
287 * Creates the listing of records from a single table
288 *
289 * @param string Table name
290 * @param integer Page id
291 * @param string List of fields to show in the listing. Pseudo fields will be added including the record header.
292 * @return string HTML table with the listing for the record.
293 */
294 function getTable($table,$id,$rowlist) {
295 global $TCA;
296
297 // Loading all TCA details for this table:
298 t3lib_div::loadTCA($table);
299
300 // Init
301 $titleCol = $TCA[$table]['ctrl']['label'];
302 $thumbsCol = $TCA[$table]['ctrl']['thumbnail'];
303
304 // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
305 $this->fieldArray=array();
306 $this->fieldArray[] = $titleCol; // Add title column
307 if (!t3lib_div::inList($rowlist,'_CONTROL_')) {
308 $this->fieldArray[] = '_CONTROL_';
309 }
310 if ($this->showClipboard) {
311 $this->fieldArray[] = '_CLIPBOARD_';
312 }
313 if ($this->searchLevels) {
314 $this->fieldArray[]='_PATH_';
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 }
335 $selectFields[] = 'doktype';
336 }
337 if (is_array($TCA[$table]['ctrl']['enablecolumns'])) {
338 $selectFields = array_merge($selectFields,$TCA[$table]['ctrl']['enablecolumns']);
339 }
340 if ($TCA[$table]['ctrl']['type']) {
341 $selectFields[] = $TCA[$table]['ctrl']['type'];
342 }
343 if ($TCA[$table]['ctrl']['typeicon_column']) {
344 $selectFields[] = $TCA[$table]['ctrl']['typeicon_column'];
345 }
346 if ($TCA[$table]['ctrl']['label_alt']) {
347 $selectFields = array_merge($selectFields,t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['label_alt'],1));
348 }
349 $selectFields = array_unique($selectFields); // Unique list!
350 $selectFields = array_intersect($selectFields,$this->makeFieldList($table,1)); // Making sure that the fields in the field-list ARE in the field-list from TCA!
351 $selFieldList = implode(',',$selectFields); // implode it into a list of fields for the SQL-statement.
352
353 // Create the SQL query for selecting the elements in the listing:
354 $queryParts = $this->makeQueryArray($table, $id,'',$selFieldList); // (API function from class.db_list.inc)
355 $this->setTotalItems($queryParts); // Finding the total amount of records on the page (API function from class.db_list.inc)
356
357 // Init:
358 $dbCount = 0;
359 $out = '';
360
361 // If the count query returned any number of records, we perform the real query, selecting records.
362 if ($this->totalItems) {
363 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
364 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
365 }
366
367 $LOISmode = $this->listOnlyInSingleTableMode && !$this->table;
368
369 // If any records was selected, render the list:
370 if ($dbCount) {
371
372 // Half line is drawn between tables:
373 if (!$LOISmode) {
374 $theData = Array();
375 if (!$this->table && !$rowlist) {
376 $theData[$titleCol] = '<img src="clear.gif" width="'.($GLOBALS['SOBE']->MOD_SETTINGS['bigControlPanel']?'230':'350').'" height="1" alt="" />';
377 if (in_array('_CONTROL_',$this->fieldArray)) $theData['_CONTROL_']='';
378 if (in_array('_CLIPBOARD_',$this->fieldArray)) $theData['_CLIPBOARD_']='';
379 }
380 $out.=$this->addelement(0,'',$theData,'',$this->leftMargin);
381 }
382
383 // Header line is drawn
384 $theData = Array();
385 if ($this->disableSingleTableView) {
386 $theData[$titleCol] = '<span class="c-table">'.$GLOBALS['LANG']->sL($TCA[$table]['ctrl']['title'],1).'</span> ('.$this->totalItems.')';
387 } else {
388 $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="" />');
389 }
390
391 if ($LOISmode) {
392 $out.='
393 <tr>
394 <td class="c-headLineTable" style="width:95%;">'.$theData[$titleCol].'</td>
395 </tr>';
396
397 if ($GLOBALS['BE_USER']->uc["edit_showFieldHelp"]) {
398 $GLOBALS['LANG']->loadSingleTableDescription($table);
399 if (isset($GLOBALS['TCA_DESCR'][$table]['columns'][''])) {
400 $onClick = 'vHWin=window.open(\'view_help.php?tfID='.$table.'.\',\'viewFieldHelp\',\'height=300,width=250,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;';
401 $out.='
402 <tr>
403 <td class="c-tableDescription">'.t3lib_BEfunc::helpTextIcon($table,'',$this->backPath,TRUE).$GLOBALS['TCA_DESCR'][$table]['columns']['']['description'].'</td>
404 </tr>';
405 }
406 }
407 } else {
408 $theUpIcon = ($table=='pages'&&$this->id&&isset($this->pageRow['pid'])) ? '<a href="'.htmlspecialchars($this->listURL($this->pageRow['pid'])).'"><img'.t3lib_iconWorks::skinImg('','gfx/i/pages_up.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel',1).'" alt="" /></a>':'';
409 $out.=$this->addelement(1,$theUpIcon,$theData,' class="c-headLineTable"','');
410 }
411
412 If (!$LOISmode) {
413 // Fixing a order table for sortby tables
414 $this->currentTable = array();
415 $currentIdList = array();
416 $doSort = ($TCA[$table]['ctrl']['sortby'] && !$this->sortField);
417
418 $prevUid = 0;
419 $prevPrevUid = 0;
420 $accRows = array(); // Accumulate rows here
421 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
422 $accRows[] = $row;
423 $currentIdList[] = $row['uid'];
424 if ($doSort) {
425 if ($prevUid) {
426 $this->currentTable['prev'][$row['uid']] = $prevPrevUid;
427 $this->currentTable['next'][$prevUid] = '-'.$row['uid'];
428 $this->currentTable['prevUid'][$row['uid']] = $prevUid;
429 }
430 $prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
431 $prevUid=$row['uid'];
432 }
433 }
434 $GLOBALS['TYPO3_DB']->sql_free_result($result);
435
436 // CSV initiated
437 if ($this->csvOutput) $this->initCSV();
438
439 // Render items:
440 $this->CBnames=array();
441 $this->duplicateStack=array();
442 $this->eCounter=$this->firstElementNumber;
443
444 $iOut = '';
445 $cc = 0;
446 foreach($accRows as $row) {
447
448 // Forward/Backwards navigation links:
449 list($flag,$code) = $this->fwd_rwd_nav($table);
450 $iOut.=$code;
451
452 // If render item, increment counter and call function
453 if ($flag) {
454 $cc++;
455 $iOut.=$this->renderListRow($table,$row,$cc,$titleCol,$thumbsCol);
456 }
457
458 // Counter of total rows incremented:
459 $this->eCounter++;
460 }
461
462 // The header row for the table is now created:
463 $out.=$this->renderListHeader($table,$currentIdList);
464 }
465
466 // The list of records is added after the header:
467 $out.=$iOut;
468
469 // ... and it is all wrapped in a table:
470 $out='
471
472
473
474 <!--
475 DB listing of elements: "'.htmlspecialchars($table).'"
476 -->
477 <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist'.($LOISmode?' typo3-dblist-overview':'').'">
478 '.$out.'
479 </table>';
480
481 // Output csv if...
482 if ($this->csvOutput) $this->outputCSV($table); // This ends the page with exit.
483 }
484
485 // Return content:
486 return $out;
487 }
488
489 /**
490 * Rendering a single row for the list
491 *
492 * @param string Table name
493 * @param array Current record
494 * @param integer Counter, counting for each time an element is rendered (used for alternating colors)
495 * @param string Table field (column) where header value is found
496 * @param string Table field (column) where (possible) thumbnails can be found
497 * @return string Table row for the element
498 * @access private
499 * @see getTable()
500 */
501 function renderListRow($table,$row,$cc,$titleCol,$thumbsCol) {
502 $iOut = '';
503
504 // Background color, if any:
505 $row_bgColor=
506 $this->alternateBgColors ?
507 (($cc%2)?'' :' bgcolor="'.t3lib_div::modifyHTMLColor($GLOBALS['SOBE']->doc->bgColor4,+10,+10,+10).'"') :
508 '';
509
510 // Initialization
511 $alttext = t3lib_BEfunc::getRecordIconAltText($row,$table);
512 $recTitle = t3lib_BEfunc::getRecordTitle($table,$row);
513
514 // Incr. counter.
515 $this->counter++;
516
517 // The icon with link
518 $iconImg = t3lib_iconWorks::getIconImage($table,$row,$this->backPath,'title="'.htmlspecialchars($alttext).'"');
519 $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg,$table,$row['uid']);
520
521 // Preparing and getting the data-array
522 $theData = Array();
523 reset($this->fieldArray);
524 while(list(,$fCol)=each($this->fieldArray)) {
525 if ($fCol==$titleCol) {
526 $theData[$fCol] = $this->linkWrapItems($table,$row['uid'],$recTitle,$row);
527 } elseif ($fCol=='pid') {
528 $theData[$fCol]=$row[$fCol];
529 } elseif ($fCol=='_PATH_') {
530 $theData[$fCol]=$this->recPath($row['pid']);
531 } elseif ($fCol=='_CONTROL_') {
532 $theData[$fCol]=$this->makeControl($table,$row);
533 } elseif ($fCol=='_CLIPBOARD_') {
534 $theData[$fCol]=$this->makeClip($table,$row);
535 } else {
536 $theData[$fCol]=htmlspecialchars(t3lib_BEfunc::getProcessedValueExtra($table,$fCol,$row[$fCol],100));
537 }
538 }
539
540 // Add row to CSV list:
541 if ($this->csvOutput) $this->addToCSV($row);
542
543 // Create element in table cells:
544 $iOut.=$this->addelement(1,$theIcon,$theData,$row_bgColor);
545
546 // Render thumbsnails if a thumbnail column exists and there is content in it:
547 if ($this->thumbs && trim($row[$thumbsCol])) {
548 $iOut.=$this->addelement(4,'', Array($titleCol=>$this->thumbCode($row,$table,$thumbsCol)),$row_bgColor);
549 }
550
551 // Finally, return table row element:
552 return $iOut;
553 }
554
555 /**
556 * Rendering the header row for a table
557 *
558 * @param string Table name
559 * @param array Array of the currectly displayed uids of the table
560 * @return string Header table row
561 * @access private
562 * @see getTable()
563 */
564 function renderListHeader($table,$currentIdList) {
565 global $TCA, $LANG;
566
567 // Init:
568 $theData = Array();
569
570 // Traverse the fields:
571 foreach($this->fieldArray as $fCol) {
572
573 // Calculate users permissions to edit records in the table:
574 $permsEdit = $this->calcPerms & ($table=='pages'?2:16);
575
576 switch((string)$fCol) {
577 case '_PATH_': // Path
578 $theData[$fCol]='<i>['.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels._PATH_',1).']</i>';
579 break;
580 case '_CLIPBOARD_': // Clipboard:
581 $cells=array();
582
583 // If there are elements on the clipboard for this table, then display the "paste into" icon:
584 $elFromTable = $this->clipObj->elFromTable($table);
585 if (count($elFromTable)) {
586 $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl($table,$this->id)).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg('pages',$this->pageRow,'into',$elFromTable)).'">'.
587 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteafter.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_paste',1).'" alt="" />'.
588 '</a>';
589 }
590
591 // If the numeric clipboard pads are enabled, display the control icons for that:
592 if ($this->clipObj->current!='normal') {
593
594 // The "select" link:
595 $cells[]=$this->linkClipboardHeaderIcon('<img'.t3lib_iconWorks::skinImg('','gfx/clip_copy.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_selectMarked',1).'" alt="" />',$table,'setCB');
596
597 // The "edit marked" link:
598 $editIdList = implode(',',$currentIdList);
599 $editIdList = "'+editList('".$table."','".$editIdList."')+'";
600 $params='&edit['.$table.']['.$editIdList.']=edit&disHelp=1';
601 $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
602 '<img'.t3lib_iconWorks::skinImg('','gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('clip_editMarked',1).'" alt="" />'.
603 '</a>';
604
605 // The "Delete marked" link:
606 $cells[]=$this->linkClipboardHeaderIcon('<img'.t3lib_iconWorks::skinImg('','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'])));
607
608 // The "Select all" link:
609 $cells[]='<a href="#" onclick="'.htmlspecialchars('checkOffCB(\''.implode(',',$this->CBnames).'\'); return false;').'">'.
610 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_select.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_markRecords',1).'" alt="" />'.
611 '</a>';
612 } else {
613 $cells[]='';
614 }
615 $theData[$fCol]=implode('',$cells);
616 break;
617 case '_CONTROL_': // Control panel:
618 if (!$TCA[$table]['ctrl']['readOnly']) {
619
620 // If new records can be created on this page, add links:
621 if ($this->calcPerms&($table=='pages'?8:16) && $this->showNewRecLink($table)) {
622 if ($table=="tt_content" && $this->newWizards) {
623 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
624 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
625 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
626 $newContentWizScriptPath = t3lib_extMgm::isLoaded($tmpTSc) ? (t3lib_extMgm::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : (TYPO3_mainDir.'sysext/cms/layout/db_new_content_el.php');
627
628 $theData[$fCol]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$newContentWizScriptPath.'?id='.$this->id.'\');').'">'.
629 '<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="" />'.
630 '</a>';
631 } elseif ($table=='pages' && $this->newWizards) {
632 $theData[$fCol]='<a href="'.htmlspecialchars('db_new.php?id='.$this->id.'&pagesOnly=1returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
633 '<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="" />'.
634 '</a>';
635 } else {
636 $params='&edit['.$table.']['.$this->id.']=new';
637 $theData[$fCol]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
638 '<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="" />'.
639 '</a>';
640 }
641 }
642
643 // If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
644 if ($permsEdit && $this->table && is_array($currentIdList)) {
645 $editIdList = implode(',',$currentIdList);
646 if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
647 $params='&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.implode(',',$this->fieldArray).'&disHelp=1';
648 $theData[$fCol].='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
649 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('editShownColumns',1).'" alt="" />'.
650 '</a>';
651 }
652 }
653 break;
654 default: // Regular fields header:
655 $theData[$fCol]='';
656 if ($this->table && is_array($currentIdList)) {
657
658 // If the numeric clipboard pads are selected, show duplicate sorting link:
659 if ($this->clipNumPane()) {
660 $theData[$fCol].='<a href="'.htmlspecialchars($this->listURL('',-1).'&duplicateField='.$fCol).'">'.
661 '<img'.t3lib_iconWorks::skinImg('','gfx/select_duplicates.gif','width="11" height="11"').' title="'.$LANG->getLL('clip_duplicates',1).'" alt="" />'.
662 '</a>';
663 }
664
665 // If the table can be edited, add link for editing THIS field for all listed records:
666 if (!$TCA[$table]['ctrl']['readOnly'] && $permsEdit && $TCA[$table]['columns'][$fCol]) {
667 $editIdList = implode(',',$currentIdList);
668 if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
669 $params='&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.$fCol.'&disHelp=1';
670 $iTitle = sprintf($LANG->getLL('editThisColumn'),ereg_replace(':$','',trim($LANG->sL(t3lib_BEfunc::getItemLabel($table,$fCol)))));
671 $theData[$fCol].='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
672 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.htmlspecialchars($iTitle).'" alt="" />'.
673 '</a>';
674 }
675 }
676 $theData[$fCol].=$this->addSortLink($LANG->sL(t3lib_BEfunc::getItemLabel($table,$fCol,'<i>[|]</i>')),$fCol,$table);
677 break;
678 }
679 }
680
681 // Create and return header table row:
682 return $this->addelement(1,'',$theData,' class="c-headLine"','');
683 }
684
685
686
687
688
689
690 /*********************************
691 *
692 * Rendering of various elements
693 *
694 *********************************/
695
696 /**
697 * Creates the control panel for a single record in the listing.
698 *
699 * @param string The table
700 * @param array The record for which to make the control panel.
701 * @return string HTML table with the control panel (unless disabled)
702 */
703 function makeControl($table,$row) {
704 global $TCA, $LANG, $SOBE;
705
706 // Return blank, if disabled:
707 if ($this->dontShowClipControlPanels) return '';
708
709 // Initialize:
710 t3lib_div::loadTCA($table);
711 $cells=array();
712
713 // If the listed table is 'pages' we have to request the permission settings for each page:
714 if ($table=='pages') {
715 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid']));
716 }
717
718 // This expresses the edit permissions for this particular element:
719 $permsEdit = ($table=='pages' && ($localCalcPerms&2)) || ($table!='pages' && ($this->calcPerms&16));
720
721 // "Show" link (only pages and tt_content elements)
722 if ($table=='pages' || $table=='tt_content') {
723 $params='&edit['.$table.']['.$row['uid'].']=edit';
724 $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($table=='tt_content'?$this->id.'#'.$row['uid']:$row['uid'])).'">'.
725 '<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="" />'.
726 '</a>';
727 }
728
729 // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
730 if ($permsEdit) {
731 $params='&edit['.$table.']['.$row['uid'].']=edit';
732 $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
733 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2'.(!$TCA[$table]['ctrl']['readOnly']?'':'_d').'.gif','width="11" height="12"').' title="'.$LANG->getLL('edit',1).'" alt="" />'.
734 '</a>';
735 }
736
737 // "Move" wizard link for pages/tt_content elements:
738 if (($table=="tt_content" && $permsEdit) || ($table=='pages')) {
739 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\'move_el.php?table='.$table.'&uid='.$row['uid'].'\');').'">'.
740 '<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="" />'.
741 '</a>';
742 }
743
744 // If the extended control panel is enabled OR if we are seeing a single table:
745 if ($SOBE->MOD_SETTINGS['bigControlPanel'] || $this->table) {
746
747 // "Info": (All records)
748 $cells[]='<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$table.'\', \''.$row['uid'].'\'); return false;').'">'.
749 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom2.gif','width="12" height="12"').' title="'.$LANG->getLL('showInfo',1).'" alt="" />'.
750 '</a>';
751
752 // If the table is NOT a read-only table, then show these links:
753 if (!$TCA[$table]['ctrl']['readOnly']) {
754
755 // "Revert" link (history/undo)
756 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\'show_rechis.php?element='.rawurlencode($table.':'.$row['uid']).'\',\'#latest\');').'">'.
757 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/history2.gif','width="13" height="12"').' title="'.$LANG->getLL('history',1).'" alt="" />'.
758 '</a>';
759
760 // "Edit Perms" link:
761 if ($table=='pages' && $GLOBALS['BE_USER']->check('modules','web_perm')) {
762 $cells[]='<a href="'.htmlspecialchars('mod/web/perm/index.php?id='.$row['uid'].'&return_id='.$row['uid'].'&edit=1').'">'.
763 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/perm.gif','width="7" height="12"').' title="'.$LANG->getLL('permissions',1).'" alt="" />'.
764 '</a>';
765 }
766
767 // "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):
768 if ($TCA[$table]['ctrl']['sortby'] || $TCA[$table]['ctrl']['useColumnsForDefaultValues']) {
769 if (
770 ($table!='pages' && ($this->calcPerms&16)) || // For NON-pages, must have permission to edit content on this parent page
771 ($table=='pages' && ($this->calcPerms&8)) // For pages, must have permission to create new pages here.
772 ) {
773 if ($this->showNewRecLink($table)) {
774 $params='&edit['.$table.']['.(-$row['uid']).']=new';
775 $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
776 '<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="" />'.
777 '</a>';
778 }
779 }
780 }
781
782 // "Up/Down" links
783 if ($permsEdit && $TCA[$table]['ctrl']['sortby'] && !$this->sortField && !$this->searchLevels) {
784 if (isset($this->currentTable['prev'][$row['uid']])) { // Up
785 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prev'][$row['uid']];
786 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
787 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_up.gif','width="11" height="10"').' title="'.$LANG->getLL('moveUp',1).'" alt="" />'.
788 '</a>';
789 } else {
790 $cells[]='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_up.gif','width="11" height="10"',2).' alt="" />';
791 }
792 if ($this->currentTable['next'][$row['uid']]) { // Down
793 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['next'][$row['uid']];
794 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
795 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"').' title="'.$LANG->getLL('moveDown',1).'" alt="" />'.
796 '</a>';
797 } else {
798 $cells[]='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"',2).' alt="" />';
799 }
800 }
801
802 // "Hide/Unhide" links:
803 $hiddenField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
804 if ($permsEdit && $hiddenField && $TCA[$table]['columns'][$hiddenField] && (!$TCA[$table]['columns'][$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$table.':'.$hiddenField))) {
805 if ($row[$hiddenField]) {
806 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=0';
807 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
808 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_unhide.gif','width="11" height="10"').' title="'.$LANG->getLL('unHide'.($table=='pages'?'Page':''),1).'" alt="" />'.
809 '</a>';
810 } else {
811 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=1';
812 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
813 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_hide.gif','width="11" height="10"').' title="'.$LANG->getLL('hide'.($table=='pages'?'Page':''),1).'" alt="" />'.
814 '</a>';
815 }
816 }
817
818 // "Delete" link:
819 if (
820 ($table=='pages' && ($localCalcPerms&4)) || ($table!='pages' && ($this->calcPerms&16))
821 ) {
822 $params='&cmd['.$table.']['.$row['uid'].'][delete]=1';
823 $cells[]='<a href="#" onclick="'.htmlspecialchars('if (confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning')).')) {jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');} return false;').'">'.
824 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/garbage.gif','width="11" height="12"').' title="'.$LANG->getLL('delete',1).'" alt="" />'.
825 '</a>';
826 }
827
828 // "Levels" links: Moving pages into new levels...
829 if ($permsEdit && $table=='pages' && !$this->searchLevels) {
830
831 // Up (Paste as the page right after the current parent page)
832 if ($this->calcPerms&8) {
833 $params='&cmd['.$table.']['.$row['uid'].'][move]='.-$this->id;
834 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
835 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_left.gif','width="11" height="10"').' title="'.$LANG->getLL('prevLevel',1).'" alt="" />'.
836 '</a>';
837 }
838 // Down (Paste as subpage to the page right above)
839 if ($this->currentTable['prevUid'][$row['uid']]) {
840 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$this->currentTable['prevUid'][$row['uid']]));
841 if ($localCalcPerms&8) {
842 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prevUid'][$row['uid']];
843 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
844 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_right.gif','width="11" height="10"').' title="'.$LANG->getLL('nextLevel',1).'" alt="" />'.
845 '</a>';
846 } else {
847 $cells[]='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_right.gif','width="11" height="10"',2).' alt="" />';
848 }
849 } else {
850 $cells[]='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_right.gif','width="11" height="10"',2).' alt="" />';
851 }
852 }
853 }
854 }
855
856 // If the record is edit-locked by another user, we will show a little warning sign:
857 if ($lockInfo=t3lib_BEfunc::isRecordLocked($table,$row['uid'])) {
858 $cells[]='<a href="#" onclick="'.htmlspecialchars('alert('.$LANG->JScharCode($lockInfo['msg']).');return false;').'">'.
859 '<img'.t3lib_iconWorks::skinImg('','gfx/recordlock_warning3.gif','width="17" height="12"').' title="'.htmlspecialchars($lockInfo['msg']).'" alt="" />'.
860 '</a>';
861 }
862
863
864 // Compile items into a DIV-element:
865 return '
866 <!-- CONTROL PANEL: '.$table.':'.$row['uid'].' -->
867 <div class="typo3-DBctrl">'.implode('',$cells).'</div>';
868 }
869
870 /**
871 * Creates the clipboard panel for a single record in the listing.
872 *
873 * @param string The table
874 * @param array The record for which to make the clipboard panel.
875 * @return string HTML table with the clipboard panel (unless disabled)
876 */
877 function makeClip($table,$row) {
878 global $TCA, $LANG;
879
880 // Return blank, if disabled:
881 if ($this->dontShowClipControlPanels) return '';
882 $cells=array();
883
884 // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel:
885 if ($this->clipObj->current=='normal') { // For the "Normal" pad:
886
887 // Show copy/cut icons:
888 $isSel = (string)$this->clipObj->isSelected($table,$row['uid']);
889 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpSelf(\''.$this->clipObj->selUrlDB($table,$row['uid'],1,($isSel=='copy'),array('returnUrl'=>'')).'\');').'">'.
890 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_copy'.($isSel=='copy'?'_h':'').'.gif','width="12" height="12"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:cm.copy',1).'" alt="" />'.
891 '</a>';
892 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpSelf(\''.$this->clipObj->selUrlDB($table,$row['uid'],0,($isSel=='cut'),array('returnUrl'=>'')).'\');').'">'.
893 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_cut'.($isSel=='cut'?'_h':'').'.gif','width="12" height="12"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:cm.cut',1).'" alt="" />'.
894 '</a>';
895
896 } else { // For the numeric clipboard pads (showing checkboxes where one can select elements on/off)
897
898 // Setting name of the element in ->CBnames array:
899 $n=$table.'|'.$row['uid'];
900 $this->CBnames[]=$n;
901
902 // Check if the current element is selected and if so, prepare to set the checkbox as selected:
903 $checked = ($this->clipObj->isSelected($table,$row['uid'])?' checked="checked"':'');
904
905 // If the "duplicateField" value is set then select all elements which are duplicates...
906 if ($this->duplicateField && isset($row[$this->duplicateField])) {
907 $checked='';
908 if (in_array($row[$this->duplicateField], $this->duplicateStack)) {
909 $checked=' checked="checked"';
910 }
911 $this->duplicateStack[] = $row[$this->duplicateField];
912 }
913
914 // Adding the checkbox to the panel:
915 $cells[]='<input type="hidden" name="CBH['.$n.']" value="0" /><input type="checkbox" name="CBC['.$n.']" value="1" class="smallCheckboxes"'.$checked.' />';
916 }
917
918 // Now, looking for selected elements from the current table:
919 $elFromTable = $this->clipObj->elFromTable($table);
920 if (count($elFromTable) && $TCA[$table]['ctrl']['sortby']) { // IF elements are found and they can be individually ordered, then add a "paste after" icon:
921 $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl($table,-$row['uid'])).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg($table,$row,'after',$elFromTable)).'">'.
922 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteafter.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_pasteAfter',1).'" alt="" />'.
923 '</a>';
924 }
925
926 // Now, looking for elements in general:
927 $elFromTable = $this->clipObj->elFromTable('');
928 if ($table=='pages' && count($elFromTable)) {
929 $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('',$row['uid'])).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg($table,$row,'into',$elFromTable)).'">'.
930 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteinto.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_pasteInto',1).'" alt="" />'.
931 '</a>';
932 }
933
934 // Compile items into a DIV-element:
935 return ' <!-- CLIPBOARD PANEL: '.$table.':'.$row['uid'].' -->
936 <div class="typo3-clipCtrl">'.implode('',$cells).'</div>';
937 }
938
939 /**
940 * Create the selector box for selecting fields to display from a table:
941 *
942 * @param string Table name
943 * @param boolean If true, form-fields will be wrapped around the table.
944 * @return string HTML table with the selector box (name: displayFields['.$table.'][])
945 */
946 function fieldSelectBox($table,$formFields=1) {
947 global $TCA, $LANG;
948
949 // Init:
950 t3lib_div::loadTCA($table);
951 $formElements=array('','');
952 if ($formFields) {
953 $formElements=array('<form action="'.htmlspecialchars($this->listURL()).'" method="post">','</form>');
954 }
955
956 // Load already selected fields, if any:
957 $setFields=is_array($this->setFields[$table]) ? $this->setFields[$table] : array();
958
959 // Request fields from table:
960 $fields = $this->makeFieldList($table);
961
962 // Add pseudo "control" fields
963 $fields[]='_PATH_';
964 $fields[]='_CONTROL_';
965 $fields[]='_CLIPBOARD_';
966
967 // Create an option for each field:
968 $opt=array();
969 $opt[] = '<option value=""></option>';
970 foreach($fields as $fN) {
971 $fL = is_array($TCA[$table]['columns'][$fN]) ? ereg_replace(':$','',$LANG->sL($TCA[$table]['columns'][$fN]['label'])) : '['.$fN.']'; // Field label
972 $opt[] = '
973 <option value="'.$fN.'"'.(in_array($fN,$setFields)?' selected="selected"':'').'>'.htmlspecialchars($fL).'</option>';
974 }
975
976 // Compile the options into a multiple selector box:
977 $lMenu = '
978 <select size='.t3lib_div::intInRange(count($fields)+1,3,20).' multiple="multiple" name="displayFields['.$table.'][]">'.implode('',$opt).'
979 </select>
980 ';
981
982 // Table with the field selector::
983 $content.= '
984 '.$formElements[0].'
985
986 <!--
987 Field selector for extended table view:
988 -->
989 <table border="0" cellpadding="0" cellspacing="0" class="bgColor4" id="typo3-dblist-fieldSelect">
990 <tr>
991 <td>'.$lMenu.'</td>
992 <td><input type="submit" name="search" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.setFields',1).'" /></td>
993 </tr>
994 </table>
995 '.$formElements[1];
996 return $content;
997 }
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009 /*********************************
1010 *
1011 * Helper functions
1012 *
1013 *********************************/
1014
1015 /**
1016 * Creates a link around $string. The link contains an onclick action which submits the script with some clipboard action.
1017 * Currently, this is used for setting elements / delete elements.
1018 *
1019 * @param string The HTML content to link (image/text)
1020 * @param string Table name
1021 * @param string Clipboard command (eg. "setCB" or "delete")
1022 * @param string Warning text, if any ("delete" uses this for confirmation)
1023 * @return string <a> tag wrapped link.
1024 */
1025 function linkClipboardHeaderIcon($string,$table,$cmd,$warning='') {
1026 $onClickEvent = 'document.dblistForm.cmd.value=\''.$cmd.'\';document.dblistForm.cmd_table.value=\''.$table.'\';document.dblistForm.submit();';
1027 if ($warning) $onClickEvent = 'if (confirm('.$GLOBALS['LANG']->JScharCode($warning).')){'.$onClickEvent.'}';
1028 return '<a href="#" onclick="'.htmlspecialchars($onClickEvent.'return false;').'">'.$string.'</a>';
1029 }
1030
1031 /**
1032 * Returns true if a numeric clipboard pad is selected/active
1033 *
1034 * @return boolean
1035 */
1036 function clipNumPane() {
1037 return in_Array('_CLIPBOARD_',$this->fieldArray) && $this->clipObj->current!='normal';
1038 }
1039
1040 /**
1041 * Creates a sort-by link on the input string ($code).
1042 * It will automatically detect if sorting should be ascending or descending depending on $this->sortRev.
1043 * Also some fields will not be possible to sort (including if single-table-view is disabled).
1044 *
1045 * @param string The string to link (text)
1046 * @param string The fieldname represented by the title ($code)
1047 * @param string Table name
1048 * @return string Linked $code variable
1049 */
1050 function addSortLink($code,$field,$table) {
1051
1052 // Certain circumstances just return string right away (no links):
1053 if ($field=='_CONTROL_' || $field=='_CLIPBOARD_' || $this->disableSingleTableView) return $code;
1054
1055 // If "_PATH_" (showing record path) is selected, force sorting by pid field (will at least group the records!)
1056 if ($field=='_PATH_') $field=pid;
1057
1058 // Create the sort link:
1059 $sortUrl = $this->listURL('',-1,'sortField,sortRev,table').'&table='.$table.'&sortField='.$field.'&sortRev='.($this->sortRev || ($this->sortField!=$field)?0:1);
1060 $sortArrow = ($this->sortField==$field?'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/red'.($this->sortRev?'up':'down').'.gif','width="7" height="4"').' alt="" />':'');
1061
1062 // Return linked field:
1063 return '<a href="'.htmlspecialchars($sortUrl).'">'.$code.
1064 $sortArrow.
1065 '</a>';
1066 }
1067
1068 /**
1069 * Returns the path for a certain pid
1070 * The result is cached internally for the session, thus you can call this function as much as you like without performance problems.
1071 *
1072 * @param integer The page id for which to get the path
1073 * @return string The path.
1074 */
1075 function recPath($pid) {
1076 if (!isset($this->recPath_cache[$pid])) {
1077 $this->recPath_cache[$pid] = t3lib_BEfunc::getRecordPath($pid,$this->perms_clause,20);
1078 }
1079 return $this->recPath_cache[$pid];
1080 }
1081
1082 /**
1083 * Returns true if a link for creating new records should be displayed for $table
1084 *
1085 * @param string Table name
1086 * @return boolean
1087 */
1088 function showNewRecLink($table) {
1089 return !count($this->allowedNewTables) || in_array($table,$this->allowedNewTables);
1090 }
1091
1092 /**
1093 * 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.
1094 * Uses REQUEST_URI as value.
1095 *
1096 * @return string
1097 */
1098 function makeReturnUrl() {
1099 return '&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
1100 }
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111 /************************************
1112 *
1113 * CSV related functions
1114 *
1115 ************************************/
1116
1117 /**
1118 * Initializes internal csvLines array with the header of field names
1119 *
1120 * @return void
1121 */
1122 function initCSV() {
1123
1124 // Reset:
1125 $this->csvLines=array();
1126
1127 // Getting header line with field names:
1128 $csvRow=array();
1129 foreach($this->fieldArray as $fN) {
1130 $csvRow[]=$fN;
1131 }
1132
1133 // Set the header + an empty row:
1134 $this->setCsvRow($csvRow);
1135 $this->csvLines[]='';
1136 }
1137
1138 /**
1139 * Adds the content of input array $row to the CSV list:
1140 *
1141 * @param array Record array, from which the values of fields found in $this->fieldArray will be listed in the CSV output.
1142 * @return void
1143 */
1144 function addToCSV($row) {
1145
1146 // Traversing fields, adding values from $row:
1147 $csvRow=array();
1148 foreach($this->fieldArray as $fN) {
1149 if ($fN=='_PATH_') {
1150 $csvRow[]=$this->recPath($row['pid']);
1151 } else {
1152 $csvRow[]=$row[$fN];
1153 }
1154 }
1155
1156 // Set the values in the CSV list
1157 $this->setCsvRow($csvRow);
1158 }
1159
1160 /**
1161 * Adds input row of values to the internal csvLines array as a CSV formatted line
1162 *
1163 * @param array Array with values to be listed.
1164 * @return void
1165 */
1166 function setCsvRow($csvRow) {
1167 $this->csvLines[] = t3lib_div::csvValues($csvRow);
1168 }
1169
1170 /**
1171 * Compiles the internal csvLines array to a csv-string and outputs it to the browser.
1172 * This function exits!
1173 *
1174 * @param string Filename prefix:
1175 * @return void EXITS php execusion!
1176 */
1177 function outputCSV($prefix) {
1178
1179 // Setting filename:
1180 $filename=$prefix.'_'.date('dmy-Hi').'.csv';
1181
1182 // Creating output header:
1183 $mimeType = 'application/octet-stream';
1184 Header('Content-Type: '.$mimeType);
1185 Header('Content-Disposition: attachment; filename='.$filename);
1186
1187 // Printing the content of the CSV lines:
1188 echo implode(chr(13).chr(10),$this->csvLines);
1189
1190 // Exits:
1191 exit;
1192 }
1193 }
1194
1195
1196
1197 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc']) {
1198 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc']);
1199 }
1200 ?>