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