* Added option "mod.web_list.clickTitleMode = edit/info/show" to determine alternativ...
[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 foreach($this->fieldArray as $fCol) {
524 if ($fCol==$titleCol) {
525 $theData[$fCol] = $this->linkWrapItems($table,$row['uid'],$recTitle,$row);
526 } elseif ($fCol=='pid') {
527 $theData[$fCol]=$row[$fCol];
528 } elseif ($fCol=='_PATH_') {
529 $theData[$fCol]=$this->recPath($row['pid']);
530 } elseif ($fCol=='_CONTROL_') {
531 $theData[$fCol]=$this->makeControl($table,$row);
532 } elseif ($fCol=='_CLIPBOARD_') {
533 $theData[$fCol]=$this->makeClip($table,$row);
534 } else {
535 $theData[$fCol]=htmlspecialchars(t3lib_BEfunc::getProcessedValueExtra($table,$fCol,$row[$fCol],100));
536 }
537 }
538
539 // Add row to CSV list:
540 if ($this->csvOutput) $this->addToCSV($row);
541
542 // Create element in table cells:
543 $iOut.=$this->addelement(1,$theIcon,$theData,$row_bgColor);
544
545 // Render thumbsnails if a thumbnail column exists and there is content in it:
546 if ($this->thumbs && trim($row[$thumbsCol])) {
547 $iOut.=$this->addelement(4,'', Array($titleCol=>$this->thumbCode($row,$table,$thumbsCol)),$row_bgColor);
548 }
549
550 // Finally, return table row element:
551 return $iOut;
552 }
553
554 /**
555 * Rendering the header row for a table
556 *
557 * @param string Table name
558 * @param array Array of the currectly displayed uids of the table
559 * @return string Header table row
560 * @access private
561 * @see getTable()
562 */
563 function renderListHeader($table,$currentIdList) {
564 global $TCA, $LANG;
565
566 // Init:
567 $theData = Array();
568
569 // Traverse the fields:
570 foreach($this->fieldArray as $fCol) {
571
572 // Calculate users permissions to edit records in the table:
573 $permsEdit = $this->calcPerms & ($table=='pages'?2:16);
574
575 switch((string)$fCol) {
576 case '_PATH_': // Path
577 $theData[$fCol]='<i>['.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels._PATH_',1).']</i>';
578 break;
579 case '_CLIPBOARD_': // Clipboard:
580 $cells=array();
581
582 // If there are elements on the clipboard for this table, then display the "paste into" icon:
583 $elFromTable = $this->clipObj->elFromTable($table);
584 if (count($elFromTable)) {
585 $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl($table,$this->id)).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg('pages',$this->pageRow,'into',$elFromTable)).'">'.
586 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteafter.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_paste',1).'" alt="" />'.
587 '</a>';
588 }
589
590 // If the numeric clipboard pads are enabled, display the control icons for that:
591 if ($this->clipObj->current!='normal') {
592
593 // The "select" link:
594 $cells[]=$this->linkClipboardHeaderIcon('<img'.t3lib_iconWorks::skinImg('','gfx/clip_copy.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_selectMarked',1).'" alt="" />',$table,'setCB');
595
596 // The "edit marked" link:
597 $editIdList = implode(',',$currentIdList);
598 $editIdList = "'+editList('".$table."','".$editIdList."')+'";
599 $params='&edit['.$table.']['.$editIdList.']=edit&disHelp=1';
600 $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
601 '<img'.t3lib_iconWorks::skinImg('','gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('clip_editMarked',1).'" alt="" />'.
602 '</a>';
603
604 // The "Delete marked" link:
605 $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'])));
606
607 // The "Select all" link:
608 $cells[]='<a href="#" onclick="'.htmlspecialchars('checkOffCB(\''.implode(',',$this->CBnames).'\'); return false;').'">'.
609 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_select.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_markRecords',1).'" alt="" />'.
610 '</a>';
611 } else {
612 $cells[]='';
613 }
614 $theData[$fCol]=implode('',$cells);
615 break;
616 case '_CONTROL_': // Control panel:
617 if (!$TCA[$table]['ctrl']['readOnly']) {
618
619 // If new records can be created on this page, add links:
620 if ($this->calcPerms&($table=='pages'?8:16) && $this->showNewRecLink($table)) {
621 if ($table=="tt_content" && $this->newWizards) {
622 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
623 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
624 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
625 $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');
626
627 $theData[$fCol]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$newContentWizScriptPath.'?id='.$this->id.'\');').'">'.
628 '<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="" />'.
629 '</a>';
630 } elseif ($table=='pages' && $this->newWizards) {
631 $theData[$fCol]='<a href="'.htmlspecialchars('db_new.php?id='.$this->id.'&pagesOnly=1returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
632 '<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="" />'.
633 '</a>';
634 } else {
635 $params='&edit['.$table.']['.$this->id.']=new';
636 $theData[$fCol]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
637 '<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="" />'.
638 '</a>';
639 }
640 }
641
642 // If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
643 if ($permsEdit && $this->table && is_array($currentIdList)) {
644 $editIdList = implode(',',$currentIdList);
645 if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
646 $params='&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.implode(',',$this->fieldArray).'&disHelp=1';
647 $theData[$fCol].='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
648 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('editShownColumns',1).'" alt="" />'.
649 '</a>';
650 }
651 }
652 break;
653 default: // Regular fields header:
654 $theData[$fCol]='';
655 if ($this->table && is_array($currentIdList)) {
656
657 // If the numeric clipboard pads are selected, show duplicate sorting link:
658 if ($this->clipNumPane()) {
659 $theData[$fCol].='<a href="'.htmlspecialchars($this->listURL('',-1).'&duplicateField='.$fCol).'">'.
660 '<img'.t3lib_iconWorks::skinImg('','gfx/select_duplicates.gif','width="11" height="11"').' title="'.$LANG->getLL('clip_duplicates',1).'" alt="" />'.
661 '</a>';
662 }
663
664 // If the table can be edited, add link for editing THIS field for all listed records:
665 if (!$TCA[$table]['ctrl']['readOnly'] && $permsEdit && $TCA[$table]['columns'][$fCol]) {
666 $editIdList = implode(',',$currentIdList);
667 if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
668 $params='&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.$fCol.'&disHelp=1';
669 $iTitle = sprintf($LANG->getLL('editThisColumn'),ereg_replace(':$','',trim($LANG->sL(t3lib_BEfunc::getItemLabel($table,$fCol)))));
670 $theData[$fCol].='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
671 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.htmlspecialchars($iTitle).'" alt="" />'.
672 '</a>';
673 }
674 }
675 $theData[$fCol].=$this->addSortLink($LANG->sL(t3lib_BEfunc::getItemLabel($table,$fCol,'<i>[|]</i>')),$fCol,$table);
676 break;
677 }
678 }
679
680 // Create and return header table row:
681 return $this->addelement(1,'',$theData,' class="c-headLine"','');
682 }
683
684
685
686
687
688
689 /*********************************
690 *
691 * Rendering of various elements
692 *
693 *********************************/
694
695 /**
696 * Creates the control panel for a single record in the listing.
697 *
698 * @param string The table
699 * @param array The record for which to make the control panel.
700 * @return string HTML table with the control panel (unless disabled)
701 */
702 function makeControl($table,$row) {
703 global $TCA, $LANG, $SOBE;
704
705 // Return blank, if disabled:
706 if ($this->dontShowClipControlPanels) return '';
707
708 // Initialize:
709 t3lib_div::loadTCA($table);
710 $cells=array();
711
712 // If the listed table is 'pages' we have to request the permission settings for each page:
713 if ($table=='pages') {
714 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid']));
715 }
716
717 // This expresses the edit permissions for this particular element:
718 $permsEdit = ($table=='pages' && ($localCalcPerms&2)) || ($table!='pages' && ($this->calcPerms&16));
719
720 // "Show" link (only pages and tt_content elements)
721 if ($table=='pages' || $table=='tt_content') {
722 $params='&edit['.$table.']['.$row['uid'].']=edit';
723 $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($table=='tt_content'?$this->id.'#'.$row['uid']:$row['uid'])).'">'.
724 '<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="" />'.
725 '</a>';
726 }
727
728 // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
729 if ($permsEdit) {
730 $params='&edit['.$table.']['.$row['uid'].']=edit';
731 $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
732 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2'.(!$TCA[$table]['ctrl']['readOnly']?'':'_d').'.gif','width="11" height="12"').' title="'.$LANG->getLL('edit',1).'" alt="" />'.
733 '</a>';
734 }
735
736 // "Move" wizard link for pages/tt_content elements:
737 if (($table=="tt_content" && $permsEdit) || ($table=='pages')) {
738 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\'move_el.php?table='.$table.'&uid='.$row['uid'].'\');').'">'.
739 '<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="" />'.
740 '</a>';
741 }
742
743 // If the extended control panel is enabled OR if we are seeing a single table:
744 if ($SOBE->MOD_SETTINGS['bigControlPanel'] || $this->table) {
745
746 // "Info": (All records)
747 $cells[]='<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$table.'\', \''.$row['uid'].'\'); return false;').'">'.
748 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom2.gif','width="12" height="12"').' title="'.$LANG->getLL('showInfo',1).'" alt="" />'.
749 '</a>';
750
751 // If the table is NOT a read-only table, then show these links:
752 if (!$TCA[$table]['ctrl']['readOnly']) {
753
754 // "Revert" link (history/undo)
755 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\'show_rechis.php?element='.rawurlencode($table.':'.$row['uid']).'\',\'#latest\');').'">'.
756 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/history2.gif','width="13" height="12"').' title="'.$LANG->getLL('history',1).'" alt="" />'.
757 '</a>';
758
759 // "Edit Perms" link:
760 if ($table=='pages' && $GLOBALS['BE_USER']->check('modules','web_perm')) {
761 $cells[]='<a href="'.htmlspecialchars('mod/web/perm/index.php?id='.$row['uid'].'&return_id='.$row['uid'].'&edit=1').'">'.
762 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/perm.gif','width="7" height="12"').' title="'.$LANG->getLL('permissions',1).'" alt="" />'.
763 '</a>';
764 }
765
766 // "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):
767 if ($TCA[$table]['ctrl']['sortby'] || $TCA[$table]['ctrl']['useColumnsForDefaultValues']) {
768 if (
769 ($table!='pages' && ($this->calcPerms&16)) || // For NON-pages, must have permission to edit content on this parent page
770 ($table=='pages' && ($this->calcPerms&8)) // For pages, must have permission to create new pages here.
771 ) {
772 if ($this->showNewRecLink($table)) {
773 $params='&edit['.$table.']['.(-$row['uid']).']=new';
774 $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
775 '<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="" />'.
776 '</a>';
777 }
778 }
779 }
780
781 // "Up/Down" links
782 if ($permsEdit && $TCA[$table]['ctrl']['sortby'] && !$this->sortField && !$this->searchLevels) {
783 if (isset($this->currentTable['prev'][$row['uid']])) { // Up
784 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prev'][$row['uid']];
785 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
786 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_up.gif','width="11" height="10"').' title="'.$LANG->getLL('moveUp',1).'" alt="" />'.
787 '</a>';
788 } else {
789 $cells[]='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_up.gif','width="11" height="10"',2).' alt="" />';
790 }
791 if ($this->currentTable['next'][$row['uid']]) { // Down
792 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['next'][$row['uid']];
793 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
794 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"').' title="'.$LANG->getLL('moveDown',1).'" alt="" />'.
795 '</a>';
796 } else {
797 $cells[]='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"',2).' alt="" />';
798 }
799 }
800
801 // "Hide/Unhide" links:
802 $hiddenField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
803 if ($permsEdit && $hiddenField && $TCA[$table]['columns'][$hiddenField] && (!$TCA[$table]['columns'][$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$table.':'.$hiddenField))) {
804 if ($row[$hiddenField]) {
805 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=0';
806 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
807 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_unhide.gif','width="11" height="10"').' title="'.$LANG->getLL('unHide'.($table=='pages'?'Page':''),1).'" alt="" />'.
808 '</a>';
809 } else {
810 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=1';
811 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
812 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_hide.gif','width="11" height="10"').' title="'.$LANG->getLL('hide'.($table=='pages'?'Page':''),1).'" alt="" />'.
813 '</a>';
814 }
815 }
816
817 // "Delete" link:
818 if (
819 ($table=='pages' && ($localCalcPerms&4)) || ($table!='pages' && ($this->calcPerms&16))
820 ) {
821 $params='&cmd['.$table.']['.$row['uid'].'][delete]=1';
822 $cells[]='<a href="#" onclick="'.htmlspecialchars('if (confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning')).')) {jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');} return false;').'">'.
823 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/garbage.gif','width="11" height="12"').' title="'.$LANG->getLL('delete',1).'" alt="" />'.
824 '</a>';
825 }
826
827 // "Levels" links: Moving pages into new levels...
828 if ($permsEdit && $table=='pages' && !$this->searchLevels) {
829
830 // Up (Paste as the page right after the current parent page)
831 if ($this->calcPerms&8) {
832 $params='&cmd['.$table.']['.$row['uid'].'][move]='.-$this->id;
833 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
834 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_left.gif','width="11" height="10"').' title="'.$LANG->getLL('prevLevel',1).'" alt="" />'.
835 '</a>';
836 }
837 // Down (Paste as subpage to the page right above)
838 if ($this->currentTable['prevUid'][$row['uid']]) {
839 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$this->currentTable['prevUid'][$row['uid']]));
840 if ($localCalcPerms&8) {
841 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prevUid'][$row['uid']];
842 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
843 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_right.gif','width="11" height="10"').' title="'.$LANG->getLL('nextLevel',1).'" alt="" />'.
844 '</a>';
845 } else {
846 $cells[]='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_right.gif','width="11" height="10"',2).' alt="" />';
847 }
848 } else {
849 $cells[]='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_right.gif','width="11" height="10"',2).' alt="" />';
850 }
851 }
852 }
853 }
854
855 // If the record is edit-locked by another user, we will show a little warning sign:
856 if ($lockInfo=t3lib_BEfunc::isRecordLocked($table,$row['uid'])) {
857 $cells[]='<a href="#" onclick="'.htmlspecialchars('alert('.$LANG->JScharCode($lockInfo['msg']).');return false;').'">'.
858 '<img'.t3lib_iconWorks::skinImg('','gfx/recordlock_warning3.gif','width="17" height="12"').' title="'.htmlspecialchars($lockInfo['msg']).'" alt="" />'.
859 '</a>';
860 }
861
862
863 // Compile items into a DIV-element:
864 return '
865 <!-- CONTROL PANEL: '.$table.':'.$row['uid'].' -->
866 <div class="typo3-DBctrl">'.implode('',$cells).'</div>';
867 }
868
869 /**
870 * Creates the clipboard panel for a single record in the listing.
871 *
872 * @param string The table
873 * @param array The record for which to make the clipboard panel.
874 * @return string HTML table with the clipboard panel (unless disabled)
875 */
876 function makeClip($table,$row) {
877 global $TCA, $LANG;
878
879 // Return blank, if disabled:
880 if ($this->dontShowClipControlPanels) return '';
881 $cells=array();
882
883 // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel:
884 if ($this->clipObj->current=='normal') { // For the "Normal" pad:
885
886 // Show copy/cut icons:
887 $isSel = (string)$this->clipObj->isSelected($table,$row['uid']);
888 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpSelf(\''.$this->clipObj->selUrlDB($table,$row['uid'],1,($isSel=='copy'),array('returnUrl'=>'')).'\');').'">'.
889 '<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="" />'.
890 '</a>';
891 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpSelf(\''.$this->clipObj->selUrlDB($table,$row['uid'],0,($isSel=='cut'),array('returnUrl'=>'')).'\');').'">'.
892 '<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="" />'.
893 '</a>';
894
895 } else { // For the numeric clipboard pads (showing checkboxes where one can select elements on/off)
896
897 // Setting name of the element in ->CBnames array:
898 $n=$table.'|'.$row['uid'];
899 $this->CBnames[]=$n;
900
901 // Check if the current element is selected and if so, prepare to set the checkbox as selected:
902 $checked = ($this->clipObj->isSelected($table,$row['uid'])?' checked="checked"':'');
903
904 // If the "duplicateField" value is set then select all elements which are duplicates...
905 if ($this->duplicateField && isset($row[$this->duplicateField])) {
906 $checked='';
907 if (in_array($row[$this->duplicateField], $this->duplicateStack)) {
908 $checked=' checked="checked"';
909 }
910 $this->duplicateStack[] = $row[$this->duplicateField];
911 }
912
913 // Adding the checkbox to the panel:
914 $cells[]='<input type="hidden" name="CBH['.$n.']" value="0" /><input type="checkbox" name="CBC['.$n.']" value="1" class="smallCheckboxes"'.$checked.' />';
915 }
916
917 // Now, looking for selected elements from the current table:
918 $elFromTable = $this->clipObj->elFromTable($table);
919 if (count($elFromTable) && $TCA[$table]['ctrl']['sortby']) { // IF elements are found and they can be individually ordered, then add a "paste after" icon:
920 $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl($table,-$row['uid'])).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg($table,$row,'after',$elFromTable)).'">'.
921 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteafter.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_pasteAfter',1).'" alt="" />'.
922 '</a>';
923 }
924
925 // Now, looking for elements in general:
926 $elFromTable = $this->clipObj->elFromTable('');
927 if ($table=='pages' && count($elFromTable)) {
928 $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('',$row['uid'])).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg($table,$row,'into',$elFromTable)).'">'.
929 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteinto.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_pasteInto',1).'" alt="" />'.
930 '</a>';
931 }
932
933 // Compile items into a DIV-element:
934 return ' <!-- CLIPBOARD PANEL: '.$table.':'.$row['uid'].' -->
935 <div class="typo3-clipCtrl">'.implode('',$cells).'</div>';
936 }
937
938 /**
939 * Create the selector box for selecting fields to display from a table:
940 *
941 * @param string Table name
942 * @param boolean If true, form-fields will be wrapped around the table.
943 * @return string HTML table with the selector box (name: displayFields['.$table.'][])
944 */
945 function fieldSelectBox($table,$formFields=1) {
946 global $TCA, $LANG;
947
948 // Init:
949 t3lib_div::loadTCA($table);
950 $formElements=array('','');
951 if ($formFields) {
952 $formElements=array('<form action="'.htmlspecialchars($this->listURL()).'" method="post">','</form>');
953 }
954
955 // Load already selected fields, if any:
956 $setFields=is_array($this->setFields[$table]) ? $this->setFields[$table] : array();
957
958 // Request fields from table:
959 $fields = $this->makeFieldList($table);
960
961 // Add pseudo "control" fields
962 $fields[]='_PATH_';
963 $fields[]='_CONTROL_';
964 $fields[]='_CLIPBOARD_';
965
966 // Create an option for each field:
967 $opt=array();
968 $opt[] = '<option value=""></option>';
969 foreach($fields as $fN) {
970 $fL = is_array($TCA[$table]['columns'][$fN]) ? ereg_replace(':$','',$LANG->sL($TCA[$table]['columns'][$fN]['label'])) : '['.$fN.']'; // Field label
971 $opt[] = '
972 <option value="'.$fN.'"'.(in_array($fN,$setFields)?' selected="selected"':'').'>'.htmlspecialchars($fL).'</option>';
973 }
974
975 // Compile the options into a multiple selector box:
976 $lMenu = '
977 <select size='.t3lib_div::intInRange(count($fields)+1,3,20).' multiple="multiple" name="displayFields['.$table.'][]">'.implode('',$opt).'
978 </select>
979 ';
980
981 // Table with the field selector::
982 $content.= '
983 '.$formElements[0].'
984
985 <!--
986 Field selector for extended table view:
987 -->
988 <table border="0" cellpadding="0" cellspacing="0" class="bgColor4" id="typo3-dblist-fieldSelect">
989 <tr>
990 <td>'.$lMenu.'</td>
991 <td><input type="submit" name="search" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.setFields',1).'" /></td>
992 </tr>
993 </table>
994 '.$formElements[1];
995 return $content;
996 }
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008 /*********************************
1009 *
1010 * Helper functions
1011 *
1012 *********************************/
1013
1014 /**
1015 * Creates a link around $string. The link contains an onclick action which submits the script with some clipboard action.
1016 * Currently, this is used for setting elements / delete elements.
1017 *
1018 * @param string The HTML content to link (image/text)
1019 * @param string Table name
1020 * @param string Clipboard command (eg. "setCB" or "delete")
1021 * @param string Warning text, if any ("delete" uses this for confirmation)
1022 * @return string <a> tag wrapped link.
1023 */
1024 function linkClipboardHeaderIcon($string,$table,$cmd,$warning='') {
1025 $onClickEvent = 'document.dblistForm.cmd.value=\''.$cmd.'\';document.dblistForm.cmd_table.value=\''.$table.'\';document.dblistForm.submit();';
1026 if ($warning) $onClickEvent = 'if (confirm('.$GLOBALS['LANG']->JScharCode($warning).')){'.$onClickEvent.'}';
1027 return '<a href="#" onclick="'.htmlspecialchars($onClickEvent.'return false;').'">'.$string.'</a>';
1028 }
1029
1030 /**
1031 * Returns true if a numeric clipboard pad is selected/active
1032 *
1033 * @return boolean
1034 */
1035 function clipNumPane() {
1036 return in_Array('_CLIPBOARD_',$this->fieldArray) && $this->clipObj->current!='normal';
1037 }
1038
1039 /**
1040 * Creates a sort-by link on the input string ($code).
1041 * It will automatically detect if sorting should be ascending or descending depending on $this->sortRev.
1042 * Also some fields will not be possible to sort (including if single-table-view is disabled).
1043 *
1044 * @param string The string to link (text)
1045 * @param string The fieldname represented by the title ($code)
1046 * @param string Table name
1047 * @return string Linked $code variable
1048 */
1049 function addSortLink($code,$field,$table) {
1050
1051 // Certain circumstances just return string right away (no links):
1052 if ($field=='_CONTROL_' || $field=='_CLIPBOARD_' || $this->disableSingleTableView) return $code;
1053
1054 // If "_PATH_" (showing record path) is selected, force sorting by pid field (will at least group the records!)
1055 if ($field=='_PATH_') $field=pid;
1056
1057 // Create the sort link:
1058 $sortUrl = $this->listURL('',-1,'sortField,sortRev,table').'&table='.$table.'&sortField='.$field.'&sortRev='.($this->sortRev || ($this->sortField!=$field)?0:1);
1059 $sortArrow = ($this->sortField==$field?'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/red'.($this->sortRev?'up':'down').'.gif','width="7" height="4"').' alt="" />':'');
1060
1061 // Return linked field:
1062 return '<a href="'.htmlspecialchars($sortUrl).'">'.$code.
1063 $sortArrow.
1064 '</a>';
1065 }
1066
1067 /**
1068 * Returns the path for a certain pid
1069 * The result is cached internally for the session, thus you can call this function as much as you like without performance problems.
1070 *
1071 * @param integer The page id for which to get the path
1072 * @return string The path.
1073 */
1074 function recPath($pid) {
1075 if (!isset($this->recPath_cache[$pid])) {
1076 $this->recPath_cache[$pid] = t3lib_BEfunc::getRecordPath($pid,$this->perms_clause,20);
1077 }
1078 return $this->recPath_cache[$pid];
1079 }
1080
1081 /**
1082 * Returns true if a link for creating new records should be displayed for $table
1083 *
1084 * @param string Table name
1085 * @return boolean
1086 */
1087 function showNewRecLink($table) {
1088 return !count($this->allowedNewTables) || in_array($table,$this->allowedNewTables);
1089 }
1090
1091 /**
1092 * 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.
1093 * Uses REQUEST_URI as value.
1094 *
1095 * @return string
1096 */
1097 function makeReturnUrl() {
1098 return '&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
1099 }
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110 /************************************
1111 *
1112 * CSV related functions
1113 *
1114 ************************************/
1115
1116 /**
1117 * Initializes internal csvLines array with the header of field names
1118 *
1119 * @return void
1120 */
1121 function initCSV() {
1122
1123 // Reset:
1124 $this->csvLines=array();
1125
1126 // Getting header line with field names:
1127 $csvRow=array();
1128 foreach($this->fieldArray as $fN) {
1129 $csvRow[]=$fN;
1130 }
1131
1132 // Set the header + an empty row:
1133 $this->setCsvRow($csvRow);
1134 $this->csvLines[]='';
1135 }
1136
1137 /**
1138 * Adds the content of input array $row to the CSV list:
1139 *
1140 * @param array Record array, from which the values of fields found in $this->fieldArray will be listed in the CSV output.
1141 * @return void
1142 */
1143 function addToCSV($row) {
1144
1145 // Traversing fields, adding values from $row:
1146 $csvRow=array();
1147 foreach($this->fieldArray as $fN) {
1148 if ($fN=='_PATH_') {
1149 $csvRow[]=$this->recPath($row['pid']);
1150 } else {
1151 $csvRow[]=$row[$fN];
1152 }
1153 }
1154
1155 // Set the values in the CSV list
1156 $this->setCsvRow($csvRow);
1157 }
1158
1159 /**
1160 * Adds input row of values to the internal csvLines array as a CSV formatted line
1161 *
1162 * @param array Array with values to be listed.
1163 * @return void
1164 */
1165 function setCsvRow($csvRow) {
1166 $this->csvLines[] = t3lib_div::csvValues($csvRow);
1167 }
1168
1169 /**
1170 * Compiles the internal csvLines array to a csv-string and outputs it to the browser.
1171 * This function exits!
1172 *
1173 * @param string Filename prefix:
1174 * @return void EXITS php execusion!
1175 */
1176 function outputCSV($prefix) {
1177
1178 // Setting filename:
1179 $filename=$prefix.'_'.date('dmy-Hi').'.csv';
1180
1181 // Creating output header:
1182 $mimeType = 'application/octet-stream';
1183 Header('Content-Type: '.$mimeType);
1184 Header('Content-Disposition: attachment; filename='.$filename);
1185
1186 // Printing the content of the CSV lines:
1187 echo implode(chr(13).chr(10),$this->csvLines);
1188
1189 // Exits:
1190 exit;
1191 }
1192 }
1193
1194
1195
1196 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc']) {
1197 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc']);
1198 }
1199 ?>