2 /***************************************************************
5 * (c) 1999-2009 Kasper Skårhøj (kasperYYYY@typo3.com)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Include file extending t3lib_recordList
29 * Shared between Web>List (db_list.php) and Web>Page (sysext/cms/layout/db_layout.php)
31 * Revised for TYPO3 3.6 December/2003 by Kasper Skårhøj
34 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
48 * Child class for rendering of Web > List (not the final class. see class.db_list_extra)
50 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
53 * @see localRecordList
55 class recordList extends t3lib_recordList {
58 var $tableList=''; // Specify a list of tables which are the only ones allowed to be displayed.
59 var $returnUrl=''; // Return URL
60 var $thumbs = 0; // Boolean. Thumbnails on records containing files (pictures)
61 var $itemsLimitPerTable = 20; // default Max items shown per table in "multi-table mode", may be overridden by tables.php
62 var $itemsLimitSingleTable = 100; // default Max items shown per table in "single-table mode", may be overridden by tables.php
63 var $widthGif = '<img src="clear.gif" width="1" height="4" hspace="160" alt="" />';
64 var $script = 'index.php'; // Current script name
65 var $allFields=0; // Indicates if all available fields for a user should be selected or not.
66 var $localizationView=FALSE; // Whether to show localization view or not.
68 // Internal, static: GPvar:
69 var $csvOutput=FALSE; // If set, csvList is outputted.
70 var $sortField; // Field, to sort list by
71 var $sortRev; // Field, indicating to sort in reverse order.
72 var $displayFields; // Array, containing which fields to display in extended mode
73 var $duplicateField; // String, can contain the field name from a table which must have duplicate values marked.
77 var $table=''; // Tablename if single-table mode
78 var $listOnlyInSingleTableMode=FALSE; // If TRUE, records are listed only if a specific table is selected.
79 var $firstElementNumber=0; // Pointer for browsing list
80 var $searchString=''; // Search string
81 var $searchLevels=''; // Levels to search down.
82 var $showLimit=0; // Number of records to show
83 var $pidSelect=''; // List of ids from which to select/search etc. (when search-levels are set high). See start()
84 var $perms_clause=''; // Page select permissions
85 var $calcPerms=0; // Some permissions...
86 var $clickTitleMode = ''; // Mode for what happens when a user clicks the title of a record.
87 var $modSharedTSconfig = array(); // Shared module configuration, used by localization features
88 var $pageRecord = array(); // Loaded with page record with version overlay if any.
89 var $hideTables = ''; // Tables which should not get listed
90 var $tableTSconfigOverTCA = array(); //TSconfig which overwrites TCA-Settings
91 var $tablesCollapsed = array(); // Array of collapsed / uncollapsed tables in multi table view
94 var $JScode = ''; // JavaScript code accumulation
95 var $HTMLcode = ''; // HTML output
96 var $iLimit=0; // "LIMIT " in SQL...
97 var $eCounter=0; // Counting the elements no matter what...
98 var $totalItems=''; // Set to the total number of items for a table when selecting.
99 var $recPath_cache=array(); // Cache for record path
100 var $setFields=array(); // Fields to display for the current table
101 var $currentTable = array(); // Used for tracking next/prev uids
102 var $duplicateStack=array(); // Used for tracking duplicate values of fields
104 var $modTSconfig; // module configuratio
109 * Initializes the list generation
111 * @param integer Page id for which the list is rendered. Must be >= 0
112 * @param string Tablename - if extended mode where only one table is listed at a time.
113 * @param integer Browsing pointer.
114 * @param string Search word, if any
115 * @param integer Number of levels to search down the page tree
116 * @param integer Limit of records to be listed.
119 function start($id,$table,$pointer,$search="",$levels="",$showLimit=0) {
121 // Setting internal variables:
122 $this->id=intval($id); // sets the parent id
123 if ($GLOBALS['TCA'][$table]) {
124 // Setting single table mode, if table exists:
125 $this->table = $table;
127 $this->firstElementNumber=$pointer;
128 $this->searchString=trim($search);
129 $this->searchLevels=trim($levels);
130 $this->showLimit=t3lib_utility_Math::forceIntegerInRange($showLimit,0,10000);
133 $this->csvOutput = t3lib_div::_GP('csv') ? TRUE : FALSE;
134 $this->sortField = t3lib_div::_GP('sortField');
135 $this->sortRev = t3lib_div::_GP('sortRev');
136 $this->displayFields = t3lib_div::_GP('displayFields');
137 $this->duplicateField = t3lib_div::_GP('duplicateField');
139 if (t3lib_div::_GP('justLocalized')) {
140 $this->localizationRedirect(t3lib_div::_GP('justLocalized'));
143 // If thumbnails are disabled, set the "notfound" icon as default:
144 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails']) {
145 $this->thumbScript='gfx/notfound_thumb.gif';
148 // Init dynamic vars:
154 if(isset($this->modTSconfig['properties']['itemsLimitPerTable'])) {
155 $this->itemsLimitPerTable = t3lib_utility_Math::forceIntegerInRange(intval($this->modTSconfig['properties']['itemsLimitPerTable']), 1, 10000);
157 if(isset($this->modTSconfig['properties']['itemsLimitSingleTable'])) {
158 $this->itemsLimitSingleTable = t3lib_utility_Math::forceIntegerInRange(intval($this->modTSconfig['properties']['itemsLimitSingleTable']), 1, 10000);
161 // Set search levels:
162 $searchLevels = intval($this->searchLevels);
163 $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
165 // this will hide records from display - it has nothing todo with user rights!!
166 if ($pidList = $GLOBALS['BE_USER']->getTSConfigVal('options.hideRecords.pages')) {
167 if ($pidList = $GLOBALS['TYPO3_DB']->cleanIntList($pidList)) {
168 $this->perms_clause .= ' AND pages.uid NOT IN ('.$pidList.')';
172 // Get configuration of collapsed tables from user uc and merge with sanitized GP vars
173 $this->tablesCollapsed = is_array($GLOBALS['BE_USER']->uc['moduleData']['list']) ? $GLOBALS['BE_USER']->uc['moduleData']['list'] : array();
174 $collapseOverride = t3lib_div::_GP('collapse');
175 if (is_array($collapseOverride)) {
176 foreach($collapseOverride as $collapseTable => $collapseValue) {
177 if (is_array($GLOBALS['TCA'][$collapseTable]) && ($collapseValue == 0 || $collapseValue == 1)) {
178 $this->tablesCollapsed[$collapseTable] = $collapseValue;
181 // Save modified user uc
182 $GLOBALS['BE_USER']->uc['moduleData']['list'] = $this->tablesCollapsed;
183 $GLOBALS['BE_USER']->writeUC($GLOBALS['BE_USER']->uc);
184 if (t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'))) {
185 $location = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
186 t3lib_utility_Http::redirect($location);
190 if ($searchLevels > 0) {
191 $tree = $this->getTreeObject($this->id, $searchLevels, $this->perms_clause);
192 $pidList = implode(',', $GLOBALS['TYPO3_DB']->cleanIntArray($tree->ids));
193 $this->pidSelect = 'pid IN (' . $pidList . ')';
194 } elseif ($searchLevels < 0) {
196 $this->pidSelect = '1=1';
198 $this->pidSelect = 'pid=' . intval($id);
201 // Initialize languages:
202 if ($this->localizationView) {
203 $this->initializeLanguages();
208 * Traverses the table(s) to be listed and renders the output code for each:
209 * The HTML is accumulated in $this->HTMLcode
210 * Finishes off with a stopper-gif
214 function generateList() {
216 // Set page record in header
217 $this->pageRecord = t3lib_BEfunc::getRecordWSOL('pages',$this->id);
219 // Traverse the TCA table array:
220 foreach ($GLOBALS['TCA'] as $tableName => $value) {
222 // Checking if the table should be rendered:
223 if ((!$this->table || $tableName==$this->table) && (!$this->tableList || t3lib_div::inList($this->tableList,$tableName)) && $GLOBALS['BE_USER']->check('tables_select',$tableName)) { // Checks that we see only permitted/requested tables:
225 // Load full table definitions:
226 t3lib_div::loadTCA($tableName);
228 // Don't show table if hidden by TCA ctrl section
229 $hideTable = $GLOBALS['TCA'][$tableName]['ctrl']['hideTable'] ? TRUE : FALSE;
230 // Don't show table if hidden by pageTSconfig mod.web_list.hideTables
231 if (in_array($tableName, t3lib_div::trimExplode(',', $this->hideTables))) {
234 // Override previous selection if table is enabled or hidden by TSconfig TCA override mod.web_list.table
235 if (isset($this->tableTSconfigOverTCA[$tableName.'.']['hideTable'])) {
236 $hideTable = $this->tableTSconfigOverTCA[$tableName.'.']['hideTable'] ? TRUE : FALSE;
242 // iLimit is set depending on whether we're in single- or multi-table mode
244 $this->iLimit= (isset($GLOBALS['TCA'][$tableName]['interface']['maxSingleDBListItems'])
245 ? intval($GLOBALS['TCA'][$tableName]['interface']['maxSingleDBListItems']) :
246 $this->itemsLimitSingleTable);
248 $this->iLimit = (isset($GLOBALS['TCA'][$tableName]['interface']['maxDBListItems'])
249 ? intval($GLOBALS['TCA'][$tableName]['interface']['maxDBListItems'])
250 : $this->itemsLimitPerTable);
252 if ($this->showLimit) $this->iLimit = $this->showLimit;
254 // Setting fields to select:
255 if ($this->allFields) {
256 $fields = $this->makeFieldList($tableName);
260 $fields[]='_CONTROL_';
261 if (is_array($this->setFields[$tableName])) {
262 $fields = array_intersect($fields,$this->setFields[$tableName]);
270 // Find ID to use (might be different for "versioning_followPages" tables)
271 if (intval($this->searchLevels)==0) {
272 if ($GLOBALS['TCA'][$tableName]['ctrl']['versioning_followPages'] && $this->pageRecord['_ORIG_pid'] == -1
273 && $this->pageRecord['t3ver_swapmode'] == 0) {
274 $this->pidSelect = 'pid='.intval($this->pageRecord['_ORIG_uid']);
276 $this->pidSelect = 'pid='.intval($this->id);
280 // Finally, render the list:
281 $this->HTMLcode.=$this->getTable($tableName, $this->id, implode(',',$fields));
287 * Creates the search box
289 * @param boolean If TRUE, the search box is wrapped in its own form-tags
290 * @return string HTML for the search box
292 function getSearchBox($formFields=1) {
294 // Setting form-elements, if applicable:
295 $formElements=array('','');
297 $formElements = array('<form action="' . htmlspecialchars($this->listURL('', -1, 'firstElementNumber')) . '" method="post">', '</form>');
300 // Make level selector:
302 $parts = explode('|',$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.enterSearchLevels'));
303 foreach ($parts as $kv => $label) {
304 $opt[] = '<option value="'.$kv.'"'.($kv==intval($this->searchLevels)?' selected="selected"':'').'>'.htmlspecialchars($label).'</option>';
306 $lMenu = '<select name="search_levels">'.implode('',$opt).'</select>';
308 // Table with the search box:
315 <table border="0" cellpadding="0" cellspacing="0" id="typo3-dblist-search">
317 <td><label for="search_field">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.enterSearchString', 1) . '</label><input type="text" name="search_field" id="search_field" value="' . htmlspecialchars($this->searchString) . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(10) . ' /></td>
318 <td>' . $lMenu . '</td>
319 <td><input type="submit" name="search" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.search', 1) . '" /></td>
322 <td colspan="3"><label for="showLimit">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showRecords', 1) . '</label>:<input type="text" name="showLimit" id="showLimit" value="' . htmlspecialchars($this->showLimit ? $this->showLimit : '') . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(4) . ' /></td>
330 * Creates the display of sys_notes for the page.
331 * Relies on the "sys_note" extension to be loaded.
333 * @return string HTML for the sys-notes (if any)
335 function showSysNotesForPage() {
338 // Checking if extension is loaded:
339 if (!t3lib_extMgm::isLoaded('sys_note')) return '';
341 // Create query for selecting the notes:
342 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*','sys_note','pid IN ('.$this->id.') AND (personal=0 OR cruser='.intval($GLOBALS['BE_USER']->user['uid']).')'.t3lib_BEfunc::deleteClause('sys_note').t3lib_BEfunc::versioningPlaceholderClause('sys_note'));
345 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
347 // If some notes were found, render them:
351 // Load full table description:
352 t3lib_div::loadTCA('sys_note');
354 // Traverse note-types and get labels:
355 if ($GLOBALS['TCA']['sys_note'] && $GLOBALS['TCA']['sys_note']['columns']['category']
356 && is_array($GLOBALS['TCA']['sys_note']['columns']['category']['config']['items'])) {
357 foreach($GLOBALS['TCA']['sys_note']['columns']['category']['config']['items'] as $el) {
358 $cat[$el[1]]=$GLOBALS['LANG']->sL($el[0]);
362 // For each note found, make rendering:
363 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
366 $iconImg = t3lib_iconWorks::getSpriteIconForRecord('sys_note', $row);
367 $subject = htmlspecialchars($row['subject']);
369 $fields['Author:'] = htmlspecialchars($row['author'].($row['email'] && $row['author'] ? ', ':'').$row['email']);
370 $fields['Category:'] = htmlspecialchars($cat[$row['category']]);
371 $fields['Note:'] = nl2br(htmlspecialchars($row['message']));
378 Sys-notes for list module:
380 <table border="0" cellpadding="1" cellspacing="1" id="typo3-dblist-sysnotes">
381 <tr><td colspan="2" class="bgColor2">'.$iconImg.'<strong>'.$subject.'</strong></td></tr>
382 <tr><td class="bgColor4">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.category',1).'</td><td class="bgColor4">'.$fields['Category:'].'</td></tr>
383 <tr><td class="bgColor4">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.author',1).'</td><td class="bgColor4">'.$fields['Author:'].'</td></tr>
384 <tr><td class="bgColor4">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.note',1).'</td><td class="bgColor4">'.$fields['Note:'].'</td></tr>
399 /******************************
401 * Various helper functions
403 ******************************/
406 * Setting the field names to display in extended list.
407 * Sets the internal variable $this->setFields
411 function setDispFields() {
413 // Getting from session:
414 $dispFields = $GLOBALS['BE_USER']->getModuleData('list/displayFields');
416 // If fields has been inputted, then set those as the value and push it to session variable:
417 if (is_array($this->displayFields)) {
418 reset($this->displayFields);
419 $tKey = key($this->displayFields);
420 $dispFields[$tKey]=$this->displayFields[$tKey];
421 $GLOBALS['BE_USER']->pushModuleData('list/displayFields',$dispFields);
425 $this->setFields=$dispFields;
429 * Create thumbnail code for record/field
431 * @param array Record array
432 * @param string Table (record is from)
433 * @param string Field name for which thumbsnail are to be rendered.
434 * @return string HTML for thumbnails, if any.
436 function thumbCode($row,$table,$field) {
437 return t3lib_BEfunc::thumbCode($row,$table,$field,$this->backPath,$this->thumbScript);
441 * Returns the SQL-query array to select the records from a table $table with pid = $id
443 * @param string Table name
444 * @param integer Page id (NOT USED! $this->pidSelect is used instead)
445 * @param string Additional part for where clause
446 * @param string Field list to select, * for all (for "SELECT [fieldlist] FROM ...")
447 * @return array Returns query array
449 function makeQueryArray($table, $id, $addWhere='', $fieldList='*') {
450 $hookObjectsArr = array();
451 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list.inc']['makeQueryArray'])) {
452 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list.inc']['makeQueryArray'] as $classRef) {
453 $hookObjectsArr[] = t3lib_div::getUserObj($classRef);
458 $orderBy = ($GLOBALS['TCA'][$table]['ctrl']['sortby']
459 ? 'ORDER BY ' . $GLOBALS['TCA'][$table]['ctrl']['sortby']
460 : $GLOBALS['TCA'][$table]['ctrl']['default_sortby']);
461 if ($this->sortField) {
462 if (in_array($this->sortField,$this->makeFieldList($table,1))) {
463 $orderBy = 'ORDER BY '.$this->sortField;
464 if ($this->sortRev) $orderBy.=' DESC';
469 $limit = $this->iLimit ? ($this->firstElementNumber ? $this->firstElementNumber.',' : '').($this->iLimit+1) : '';
471 // Filtering on displayable pages (permissions):
472 $pC = ($table=='pages' && $this->perms_clause)?' AND '.$this->perms_clause:'';
474 // Adding search constraints:
475 $search = $this->makeSearchString($table, $id);
477 // Compiling query array:
479 'SELECT' => $fieldList,
481 'WHERE' => $this->pidSelect.
483 t3lib_BEfunc::deleteClause($table).
484 t3lib_BEfunc::versioningPlaceholderClause($table).
488 'ORDERBY' => $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy),
492 // Apply hook as requested in http://bugs.typo3.org/view.php?id=4361
493 foreach ($hookObjectsArr as $hookObj) {
494 if (method_exists($hookObj, 'makeQueryArray_post')) {
496 'orderBy' => $orderBy,
501 $hookObj->makeQueryArray_post($queryParts, $this, $table, $id, $addWhere, $fieldList, $_params);
510 * Based on input query array (query for selecting count(*) from a table) it will select the number of records and set the value in $this->totalItems
512 * @param array Query array
514 * @see makeQueryArray()
516 function setTotalItems($queryParts) {
517 $this->totalItems = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
525 * Creates part of query for searching after a word ($this->searchString)
526 * fields in input table.
528 * @param string $table Table, in which the fields are being searched.
529 * @param integer $currentPid Page id for the possible search limit. -1 only if called from an old XCLASS.
530 * @return string Returns part of WHERE-clause for searching, if applicable.
532 function makeSearchString($table, $currentPid = -1) {
535 $currentPid = intval($currentPid);
536 $tablePidField = ($table == 'pages' ? 'uid' : 'pid');
538 // Make query, only if table is valid and a search string is actually defined:
539 if ($this->searchString) {
540 $result = ' AND 0=1';
541 if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['searchFields']) {
542 $searchableFields = t3lib_div::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['searchFields'], TRUE);
544 // Loading full table description - we need to traverse fields:
545 t3lib_div::loadTCA($table);
547 if (t3lib_utility_Math::canBeInterpretedAsInteger($this->searchString)) {
549 'uid=' . $this->searchString
552 foreach($searchableFields as $fieldName) {
553 if (isset($GLOBALS['TCA'][$table]['columns'][$fieldName])) {
554 $fieldConfig = &$GLOBALS['TCA'][$table]['columns'][$fieldName]['config'];
555 if ($fieldConfig['type'] == 'input' && $fieldConfig['eval'] && t3lib_div::inList($fieldConfig['eval'], 'int')) {
556 $condition = $fieldName . '=' . $this->searchString;
557 if (is_array($fieldConfig['search']) && in_array('pidonly', $fieldConfig['search']) && $currentPid > 0) {
558 $condition = '(' . $condition . ' AND ' . $tablePidField . '=' . $currentPid . ')';
560 $whereParts[] = $condition;
565 $whereParts = array();
567 $GLOBALS['TYPO3_DB']->quoteStr($GLOBALS['TYPO3_DB']->escapeStrForLike($this->searchString, $table), $table) .
569 foreach($searchableFields as $fieldName) {
570 if (isset($GLOBALS['TCA'][$table]['columns'][$fieldName])) {
571 $fieldConfig = &$GLOBALS['TCA'][$table]['columns'][$fieldName]['config'];
572 $format = 'LCASE(%s) LIKE LCASE(%s)';
573 if (is_array($fieldConfig['search'])) {
574 if (in_array('case', $fieldConfig['search'])) {
575 $format = '%s LIKE %s';
577 if (in_array('pidonly', $fieldConfig['search']) && $currentPid > 0) {
578 $format = '(' . $format . ' AND ' . $tablePidField . '=' . $currentPid . ')';
580 if ($fieldConfig['search']['andWhere']) {
581 $format = '((' . $fieldConfig['search']['andWhere'] . ') AND (' . $format . '))';
584 if ($fieldConfig['type'] == 'text' ||
585 $fieldConfig['type'] == 'flex' ||
586 ($fieldConfig['type'] == 'input' && (!$fieldConfig['eval'] || !preg_match('/date|time|int/',$fieldConfig['eval'])))) {
587 $whereParts[] = sprintf($format, $fieldName, $like);
593 // If search-fields were defined (and there always are) we create the query:
594 if (count($whereParts)) {
595 $result = ' AND (' . implode(' OR ', $whereParts) . ')';
603 * Returns the title (based on $code) of a table ($table) with the proper link around. For headers over tables.
604 * The link will cause the display of all extended mode or not for the table.
606 * @param string Table name
607 * @param string Table label
608 * @return string The linked table label
610 function linkWrapTable($table,$code) {
611 if ($this->table!=$table) {
612 return '<a href="' . htmlspecialchars($this->listURL('', $table, 'firstElementNumber')) . '">' . $code . '</a>';
614 return '<a href="' . htmlspecialchars($this->listURL('', '', 'sortField,sortRev,table,firstElementNumber')) . '">' . $code . '</a>';
619 * Returns the title (based on $code) of a record (from table $table) with the proper link around (that is for 'pages'-records a link to the level of that record...)
621 * @param string Table name
622 * @param integer Item uid
623 * @param string Item title (not htmlspecialchars()'ed yet)
624 * @param array Item row
625 * @return string The item title. Ready for HTML output (is htmlspecialchars()'ed)
627 function linkWrapItems($table,$uid,$code,$row) {
630 // If the title is blank, make a "no title" label:
631 if (!strcmp($code,'')) {
632 $code = '<i>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']</i> - '.htmlspecialchars(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table,$row),$GLOBALS['BE_USER']->uc['titleLen']));
634 $code = htmlspecialchars(t3lib_div::fixed_lgd_cs($code, $this->fixedL));
635 if ($code != htmlspecialchars($origCode)) {
636 $code = '<span title="'.htmlspecialchars($origCode).'">'.$code.'</span>';
640 switch((string)$this->clickTitleMode) {
642 // If the listed table is 'pages' we have to request the permission settings for each page:
643 if ($table=='pages') {
644 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid']));
645 $permsEdit = $localCalcPerms&2;
647 $permsEdit = $this->calcPerms&16;
650 // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
652 $params='&edit['.$table.']['.$row['uid'].']=edit';
653 $code = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath, -1)) .
654 '" title="' . $GLOBALS['LANG']->getLL('edit', 1) . '">' .
660 // "Show" link (only pages and tt_content elements)
661 if ($table=='pages' || $table=='tt_content') {
662 $code = '<a href="#" onclick="'. htmlspecialchars(t3lib_BEfunc::viewOnClick(
663 $table == 'tt_content' ? $this->id . '#' . $row['uid'] : $row['uid'])
664 ) . '" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', 1) . '">'.
669 // "Info": (All records)
670 $code = '<a href="#" onclick="'.htmlspecialchars('top.launchView(\'' . $table . '\', \'' . $row['uid'] .
671 '\'); return false;') . '" title="'.$GLOBALS['LANG']->getLL('showInfo', 1) . '">' .
676 // Output the label now:
677 if ($table=='pages') {
678 $code = '<a href="' . htmlspecialchars($this->listURL($uid, '', 'firstElementNumber')) . '" onclick="setHighlight(' . $uid . ')">' . $code . '</a>';
680 $code = $this->linkUrlMail($code,$origCode);
689 * Wrapping input code in link to URL or email if $testString is either.
691 * @param string code to wrap
692 * @param string String which is tested for being a URL or email and which will be used for the link if so.
693 * @return string Link-Wrapped $code value, if $testString was URL or email.
695 function linkUrlMail($code,$testString) {
698 $schema = parse_url($testString);
699 if ($schema['scheme'] && t3lib_div::inList('http,https,ftp',$schema['scheme'])) {
700 return '<a href="'.htmlspecialchars($testString).'" target="_blank">'.$code.'</a>';
704 if (t3lib_div::validEmail($testString)) {
705 return '<a href="mailto:'.htmlspecialchars($testString).'" target="_blank">'.$code.'</a>';
708 // Return if nothing else...
713 * Creates the URL to this script, including all relevant GPvars
714 * Fixed GPvars are id, table, imagemode, returlUrl, search_field, search_levels and showLimit
715 * The GPvars "sortField" and "sortRev" are also included UNLESS they are found in the $exclList variable.
717 * @param string Alternative id value. Enter blank string for the current id ($this->id)
718 * @param string Tablename to display. Enter "-1" for the current table.
719 * @param string Commalist of fields NOT to include ("sortField", "sortRev" or "firstElementNumber")
722 function listURL($altId='',$table=-1,$exclList='') {
723 $urlParameters = array();
724 if (strcmp($altId, '')) {
725 $urlParameters['id'] = $altId;
727 $urlParameters['id'] = $this->id;
730 $urlParameters['table'] = $this->table;
732 $urlParameters['table'] = $table;
735 $urlParameters['imagemode'] = $this->thumbs;
737 if ($this->returnUrl) {
738 $urlParameters['returnUrl'] = $this->returnUrl;
740 if ($this->searchString) {
741 $urlParameters['search_field'] = $this->searchString;
743 if ($this->searchLevels) {
744 $urlParameters['search_levels'] = $this->searchLevels;
746 if ($this->showLimit) {
747 $urlParameters['showLimit'] = $this->showLimit;
749 if ((!$exclList || !t3lib_div::inList($exclList, 'firstElementNumber')) && $this->firstElementNumber) {
750 $urlParameters['pointer'] = $this->firstElementNumber;
752 if ((!$exclList || !t3lib_div::inList($exclList, 'sortField')) && $this->sortField) {
753 $urlParameters['sortField'] = $this->sortField;
755 if ((!$exclList || !t3lib_div::inList($exclList, 'sortRev')) && $this->sortRev) {
756 $urlParameters['sortRev'] = $this->sortRev;
759 return t3lib_BEfunc::getModuleUrl('web_list', $urlParameters);
763 * Returns "requestUri" - which is basically listURL
765 * @return string Content of ->listURL()
767 function requestUri() {
768 return $this->listURL();
772 * Makes the list of fields to select for a table
774 * @param string Table name
775 * @param boolean If set, users access to the field (non-exclude-fields) is NOT checked.
776 * @param boolean If set, also adds crdate and tstamp fields (note: they will also be added if user is admin or dontCheckUser is set)
777 * @return array Array, where values are fieldnames to include in query
779 function makeFieldList($table,$dontCheckUser=0,$addDateFields=0) {
781 // Init fieldlist array:
782 $fieldListArr = array();
785 if (is_array($GLOBALS['TCA'][$table])) {
786 t3lib_div::loadTCA($table);
788 // Traverse configured columns and add them to field array, if available for user.
789 foreach($GLOBALS['TCA'][$table]['columns'] as $fN => $fieldValue) {
790 if ($dontCheckUser ||
791 ((!$fieldValue['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $fN))
792 && $fieldValue['config']['type']!='passthrough')) {
797 // Add special fields:
798 if ($dontCheckUser || $GLOBALS['BE_USER']->isAdmin()) {
799 $fieldListArr[]='uid';
800 $fieldListArr[]='pid';
804 if ($dontCheckUser || $GLOBALS['BE_USER']->isAdmin() || $addDateFields) {
805 if ($GLOBALS['TCA'][$table]['ctrl']['tstamp']) {
806 $fieldListArr[]=$GLOBALS['TCA'][$table]['ctrl']['tstamp'];
808 if ($GLOBALS['TCA'][$table]['ctrl']['crdate']) {
809 $fieldListArr[]=$GLOBALS['TCA'][$table]['ctrl']['crdate'];
813 // Add more special fields:
814 if ($dontCheckUser || $GLOBALS['BE_USER']->isAdmin()) {
815 if ($GLOBALS['TCA'][$table]['ctrl']['cruser_id']) {
816 $fieldListArr[]=$GLOBALS['TCA'][$table]['ctrl']['cruser_id'];
818 if ($GLOBALS['TCA'][$table]['ctrl']['sortby']) {
819 $fieldListArr[]=$GLOBALS['TCA'][$table]['ctrl']['sortby'];
821 if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
822 $fieldListArr[]='t3ver_id';
823 $fieldListArr[]='t3ver_state';
824 $fieldListArr[]='t3ver_wsid';
825 if ($table==='pages') {
826 $fieldListArr[]='t3ver_swapmode';
831 return $fieldListArr;
835 * Creates an instance of t3lib_pageTree which will select a page tree to $depth and return the object. In that object we will find the ids of the tree.
837 * @param integer Page id.
838 * @param integer Depth to go down.
839 * @param string Select clause
840 * @return object t3lib_pageTree instance with created list of ids.
842 function getTreeObject($id,$depth,$perms_clause) {
843 $tree = t3lib_div::makeInstance('t3lib_pageTree');
844 $tree->init('AND '.$perms_clause);
846 $tree->fieldArray = Array('uid','php_tree_stop');
848 $tree->getTree($id, $depth, '');
855 * Redirects to TCEforms (alt_doc) if a record is just localized.
857 * @param string string with table, orig uid and language separated by ":"
860 function localizationRedirect($justLocalized) {
861 list($table,$orig_uid,$language) = explode(':',$justLocalized);
863 if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['languageField']
864 && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']) {
865 $localizedRecord = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
868 $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '=' . intval($language) . ' AND ' .
869 $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . '=' . intval($orig_uid) .
870 t3lib_BEfunc::deleteClause($table).
871 t3lib_BEfunc::versioningPlaceholderClause($table)
874 if (is_array($localizedRecord)) {
875 // Create parameters and finally run the classic page module for creating a new page translation
876 $url = substr($this->listURL(), strlen($this->backPath));
877 $params = '&edit['.$table.']['.$localizedRecord['uid'].']=edit';
878 $returnUrl = '&returnUrl='.rawurlencode($url);
879 $location = $GLOBALS['BACK_PATH'].'alt_doc.php?'.$params.$returnUrl;
881 t3lib_utility_Http::redirect($location);
888 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/class.db_list.inc'])) {
889 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/class.db_list.inc']);