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