[TASK] Remove comments for revised in TYPO3 3.6
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / RecordList / ElementBrowserRecordList.php
1 <?php
2 namespace TYPO3\CMS\Backend\RecordList;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 use TYPO3\CMS\Backend\Utility\BackendUtility;
31 use TYPO3\CMS\Backend\Utility\IconUtility;
32 use TYPO3\CMS\Core\Utility\GeneralUtility;
33
34 /**
35 * Displays the page/file tree for browsing database records or files.
36 * Used from TCEFORMS an other elements
37 * In other words: This is the ELEMENT BROWSER!
38 *
39 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
40 */
41 class ElementBrowserRecordList extends \TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList {
42
43 /**
44 * @todo Define visibility
45 */
46 public $thisScript = 'browse_links.php';
47
48 /**
49 * Table name of the field pointing to this element browser
50 *
51 * @var string
52 */
53 protected $relatingTable;
54
55 /**
56 * Field name of the field pointing to this element browser
57 *
58 * @var string
59 */
60 protected $relatingField;
61
62 /**
63 * Initializes the script path
64 *
65 * @return void
66 * @todo Define visibility
67 */
68 public function __construct() {
69 parent::__construct();
70 $this->thisScript = GeneralUtility::getIndpEnv('SCRIPT_NAME');
71 }
72
73 /**
74 * Creates the URL for links
75 *
76 * @param mixed $altId If not blank string, this is used instead of $this->id as the id value.
77 * @param string $table If this is "-1" then $this->table is used, otherwise the value of the input variable.
78 * @param string $exclList Commalist of fields NOT to pass as parameters (currently "sortField" and "sortRev")
79 * @return string Query-string for URL
80 * @todo Define visibility
81 */
82 public function listURL($altId = '', $table = -1, $exclList = '') {
83 return $this->thisScript . '?id=' . (strcmp($altId, '') ? $altId : $this->id) . '&table=' . rawurlencode(($table == -1 ? $this->table : $table)) . ($this->thumbs ? '&imagemode=' . $this->thumbs : '') . ($this->searchString ? '&search_field=' . rawurlencode($this->searchString) : '') . ($this->searchLevels ? '&search_levels=' . rawurlencode($this->searchLevels) : '') . ((!$exclList || !GeneralUtility::inList($exclList, 'sortField')) && $this->sortField ? '&sortField=' . rawurlencode($this->sortField) : '') . ((!$exclList || !GeneralUtility::inList($exclList, 'sortRev')) && $this->sortRev ? '&sortRev=' . rawurlencode($this->sortRev) : '') . $this->ext_addP();
84 }
85
86 /**
87 * Returns additional, local GET parameters to include in the links of the record list.
88 *
89 * @return string
90 * @todo Define visibility
91 */
92 public function ext_addP() {
93 $str = '&act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandPage=' . $GLOBALS['SOBE']->browser->expandPage . '&bparams=' . rawurlencode($GLOBALS['SOBE']->browser->bparams);
94 return $str;
95 }
96
97 /**
98 * 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...)
99 *
100 * @param string $table Table name
101 * @param integer $uid UID (not used here)
102 * @param string $code Title string
103 * @param array $row Records array (from table name)
104 * @return string
105 * @todo Define visibility
106 */
107 public function linkWrapItems($table, $uid, $code, $row) {
108 if (!$code) {
109 $code = '<i>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', 1) . ']</i>';
110 } else {
111 $code = BackendUtility::getRecordTitlePrep($code, $this->fixedL);
112 }
113 $title = BackendUtility::getRecordTitle($table, $row, FALSE, TRUE);
114 $ficon = IconUtility::getIcon($table, $row);
115 $aOnClick = 'return insertElement(\'' . $table . '\', \'' . $row['uid'] . '\', \'db\', ' . GeneralUtility::quoteJSvalue($title) . ', \'\', \'\', \'' . $ficon . '\');';
116 $ATag = '<a href="#" onclick="' . $aOnClick . '">';
117 $ATag_alt = substr($ATag, 0, -4) . ',\'\',1);">';
118 $ATag_e = '</a>';
119 return $ATag . '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/plusbullet2.gif', 'width="18" height="16"') . ' title="' . $GLOBALS['LANG']->getLL('addToList', 1) . '" alt="" />' . $ATag_e . $ATag_alt . $code . $ATag_e;
120 }
121
122 /**
123 * Check if all row listing conditions are fulfilled.
124 *
125 * @param string $table String Table name
126 * @param array $row Array Record
127 * @return boolean True, if all conditions are fulfilled.
128 */
129 protected function isRowListingConditionFulfilled($table, $row) {
130 $returnValue = TRUE;
131 if ($this->relatingField && $this->relatingTable) {
132 $tcaFieldConfig = $GLOBALS['TCA'][$this->relatingTable]['columns'][$this->relatingField]['config'];
133 if (is_array($tcaFieldConfig['filter'])) {
134 foreach ($tcaFieldConfig['filter'] as $filter) {
135 if (!$filter['userFunc']) {
136 continue;
137 }
138 $parameters = $filter['parameters'] ? $filter['parameters'] : array();
139 $parameters['values'] = array($table . '_' . $row['uid']);
140 $parameters['tcaFieldConfig'] = $tcaFieldConfig;
141 $valueArray = GeneralUtility::callUserFunction($filter['userFunc'], $parameters, $this);
142 if (count($valueArray) === 0) {
143 $returnValue = FALSE;
144 }
145 }
146 }
147 }
148 return $returnValue;
149 }
150
151 /**
152 * Set which pointing field (in the TCEForm) we are currently rendering the element browser for
153 *
154 * @param string $tableName Table name
155 * @param string $fieldName Field name
156 */
157 public function setRelatingTableAndField($tableName, $fieldName) {
158 global $TCA;
159 // Check validity of the input data and load TCA
160 if (isset($TCA[$tableName])) {
161 $this->relatingTable = $tableName;
162 if ($fieldName && isset($TCA[$tableName]['columns'][$fieldName])) {
163 $this->relatingField = $fieldName;
164 }
165 }
166 }
167
168 /**
169 * Local version that sets allFields to TRUE to support userFieldSelect
170 *
171 * @return void
172 * @see fieldSelectBox
173 * @todo Define visibility
174 */
175 public function generateList() {
176 $this->allFields = TRUE;
177 parent::generateList();
178 }
179
180 }
181
182
183 ?>