Revert "[BUGFIX] Use correct parameter type in insertPositionIcon"
[Packages/TYPO3.CMS.git] / typo3 / class.browse_links.php
1 <?php
2 /*
3 * @deprecated since 6.0, the classname TBE_browser_recordList and this file is obsolete
4 * and will be removed with 6.2. The class was renamed and is now located at:
5 * typo3/sysext/backend/Classes/RecordList/ElementBrowserRecordList.php
6 */
7 require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('backend') . 'Classes/RecordList/ElementBrowserRecordList.php';
8 /**
9 * Class which generates the page tree
10 *
11 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
12 */
13 class localPageTree extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
14
15 /**
16 * whether the page ID should be shown next to the title, activate through
17 * userTSconfig (options.pageTree.showPageIdWithTitle)
18 *
19 * @boolean
20 */
21 public $ext_showPageId = FALSE;
22
23 /**
24 * Constructor. Just calling init()
25 *
26 * @todo Define visibility
27 */
28 public function __construct() {
29 $this->thisScript = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('SCRIPT_NAME');
30 $this->init();
31 $this->clause = ' AND doktype!=' . \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_RECYCLER . $this->clause;
32 }
33
34 /**
35 * Wrapping the title in a link, if applicable.
36 *
37 * @param string $title Title, (must be ready for output, that means it must be htmlspecialchars()'ed).
38 * @param array $v The record
39 * @param boolean $ext_pArrPages (Ignore)
40 * @return string Wrapping title string.
41 * @todo Define visibility
42 */
43 public function wrapTitle($title, $v, $ext_pArrPages = '') {
44 if ($this->ext_isLinkable($v['doktype'], $v['uid'])) {
45 $aOnClick = 'return link_typo3Page(\'' . $v['uid'] . '\');';
46 return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
47 } else {
48 return '<span style="color: #666666;">' . $title . '</span>';
49 }
50 }
51
52 /**
53 * Create the page navigation tree in HTML
54 *
55 * @param array $treeArr Tree array
56 * @return string HTML output.
57 * @todo Define visibility
58 */
59 public function printTree($treeArr = '') {
60 $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
61 if (!is_array($treeArr)) {
62 $treeArr = $this->tree;
63 }
64 $out = '';
65 $c = 0;
66 foreach ($treeArr as $k => $v) {
67 $c++;
68 $bgColorClass = ($c + 1) % 2 ? 'bgColor' : 'bgColor-10';
69 if ($GLOBALS['SOBE']->browser->curUrlInfo['act'] == 'page' && $GLOBALS['SOBE']->browser->curUrlInfo['pageid'] == $v['row']['uid'] && $GLOBALS['SOBE']->browser->curUrlInfo['pageid']) {
70 $arrCol = '<td><img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_right.gif', 'width="5" height="9"') . ' class="c-blinkArrowR" alt="" /></td>';
71 $bgColorClass = 'bgColor4';
72 } else {
73 $arrCol = '<td></td>';
74 }
75 $aOnClick = 'return jumpToUrl(\'' . $this->thisScript . '?act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandPage=' . $v['row']['uid'] . '\');';
76 $cEbullet = $this->ext_isLinkable($v['row']['doktype'], $v['row']['uid']) ? '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '"><img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/arrowbullet.gif', 'width="18" height="16"') . ' alt="" /></a>' : '';
77 $out .= '
78 <tr class="' . $bgColorClass . '">
79 <td nowrap="nowrap"' . ($v['row']['_CSSCLASS'] ? ' class="' . $v['row']['_CSSCLASS'] . '"' : '') . '>' . $v['HTML'] . $this->wrapTitle($this->getTitleStr($v['row'], $titleLen), $v['row'], $this->ext_pArrPages) . '</td>' . $arrCol . '<td>' . $cEbullet . '</td>
80 </tr>';
81 }
82 $out = '
83
84
85 <!--
86 Navigation Page Tree:
87 -->
88 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
89 ' . $out . '
90 </table>';
91 return $out;
92 }
93
94 /**
95 * Returns TRUE if a doktype can be linked.
96 *
97 * @param integer $doktype Doktype value to test
98 * @param integer $uid uid to test.
99 * @return boolean
100 * @todo Define visibility
101 */
102 public function ext_isLinkable($doktype, $uid) {
103 if ($uid && $doktype < 199) {
104 return TRUE;
105 }
106 }
107
108 /**
109 * Wrap the plus/minus icon in a link
110 *
111 * @param string $icon HTML string to wrap, probably an image tag.
112 * @param string $cmd Command for 'PM' get var
113 * @param boolean $bMark If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
114 * @return string Link-wrapped input string
115 * @todo Define visibility
116 */
117 public function PM_ATagWrap($icon, $cmd, $bMark = '') {
118 if ($bMark) {
119 $anchor = '#' . $bMark;
120 $name = ' name="' . $bMark . '"';
121 }
122 $aOnClick = 'return jumpToUrl(\'' . $this->thisScript . '?PM=' . $cmd . '\',\'' . $anchor . '\');';
123 return '<a href="#"' . $name . ' onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>';
124 }
125
126 /**
127 * Wrapping the image tag, $icon, for the row, $row
128 *
129 * @param string $icon The image tag for the icon
130 * @param array $row The row for the current element
131 * @return string The processed icon input value.
132 * @todo Define visibility
133 */
134 public function wrapIcon($icon, $row) {
135 $content = $this->addTagAttributes($icon, ' title="id=' . $row['uid'] . '"');
136 if ($this->ext_showPageId) {
137 $content .= '[' . $row['uid'] . ']&nbsp;';
138 }
139 return $content;
140 }
141
142 }
143
144 /**
145 * Page tree for the RTE - totally the same, no changes needed. (Just for the sake of beauty - or confusion... :-)
146 *
147 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
148 */
149 class rtePageTree extends localPageTree {
150
151
152 }
153
154 /**
155 * For TBE record browser
156 *
157 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
158 */
159 class TBE_PageTree extends localPageTree {
160
161 /**
162 * Returns TRUE if a doktype can be linked (which is always the case here).
163 *
164 * @param integer $doktype Doktype value to test
165 * @param integer $uid uid to test.
166 * @return boolean
167 * @todo Define visibility
168 */
169 public function ext_isLinkable($doktype, $uid) {
170 return TRUE;
171 }
172
173 /**
174 * Wrapping the title in a link, if applicable.
175 *
176 * @param string $title Title, ready for output.
177 * @param array $v The record
178 * @param boolean $ext_pArrPages If set, pages clicked will return immediately, otherwise reload page.
179 * @return string Wrapping title string.
180 * @todo Define visibility
181 */
182 public function wrapTitle($title, $v, $ext_pArrPages) {
183 if ($ext_pArrPages) {
184 $ficon = \TYPO3\CMS\Backend\Utility\IconUtility::getIcon('pages', $v);
185 $onClick = 'return insertElement(\'pages\', \'' . $v['uid'] . '\', \'db\', ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($v['title']) . ', \'\', \'\', \'' . $ficon . '\',\'\',1);';
186 } else {
187 $onClick = htmlspecialchars('return jumpToUrl(\'' . $this->thisScript . '?act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandPage=' . $v['uid'] . '\');');
188 }
189 return '<a href="#" onclick="' . $onClick . '">' . $title . '</a>';
190 }
191
192 }
193
194 /**
195 * Base extension class which generates the folder tree.
196 * Used directly by the RTE.
197 * also used for the linkpicker on files
198 *
199 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
200 */
201 class localFolderTree extends \TYPO3\CMS\Backend\Tree\View\FolderTreeView {
202
203 /**
204 * @todo Define visibility
205 */
206 public $ext_IconMode = 1;
207
208 /**
209 * Initializes the script path
210 *
211 * @todo Define visibility
212 */
213 public function __construct() {
214 $this->thisScript = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('SCRIPT_NAME');
215 parent::__construct();
216 }
217
218 /**
219 * Wrapping the title in a link, if applicable.
220 *
221 * @param string $title Title, ready for output.
222 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject The "record
223 * @return string Wrapping title string.
224 * @todo Define visibility
225 */
226 public function wrapTitle($title, \TYPO3\CMS\Core\Resource\Folder $folderObject) {
227 if ($this->ext_isLinkable($folderObject)) {
228 $aOnClick = 'return jumpToUrl(\'' . $this->thisScript . '?act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier()) . '\');';
229 return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
230 } else {
231 return '<span class="typo3-dimmed">' . $title . '</span>';
232 }
233 }
234
235 /**
236 * Returns TRUE if the input "record" contains a folder which can be linked.
237 *
238 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject Object with information about the folder element. Contains keys like title, uid, path, _title
239 * @return boolean TRUE is returned if the path is found in the web-part of the server and is NOT a recycler or temp folder
240 * @todo Define visibility
241 */
242 public function ext_isLinkable(\TYPO3\CMS\Core\Resource\Folder $folderObject) {
243 if (!$folderObject->getStorage()->isPublic() || strstr($folderObject->getIdentifier(), '_recycler_') || strstr($folderObject->getIdentifier(), '_temp_')) {
244 return FALSE;
245 } else {
246 return TRUE;
247 }
248 }
249
250 /**
251 * Wrap the plus/minus icon in a link
252 *
253 * @param string $icon HTML string to wrap, probably an image tag.
254 * @param string $cmd Command for 'PM' get var
255 * @param boolean $bMark If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
256 * @return string Link-wrapped input string
257 * @access private
258 * @todo Define visibility
259 */
260 public function PM_ATagWrap($icon, $cmd, $bMark = '') {
261 if ($bMark) {
262 $anchor = '#' . $bMark;
263 $name = ' name="' . $bMark . '"';
264 }
265 $aOnClick = 'return jumpToUrl(\'' . $this->thisScript . '?PM=' . $cmd . '\',\'' . $anchor . '\');';
266 return '<a href="#"' . $name . ' onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>';
267 }
268
269 }
270
271 /**
272 * Folder tree for the RTE - totally the same, no changes needed. (Just for the sake of beauty - or confusion... :-)
273 *
274 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
275 */
276 class rteFolderTree extends localFolderTree {
277
278
279 }
280
281 /**
282 * For TBE File Browser
283 *
284 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
285 */
286 class TBE_FolderTree extends localFolderTree {
287
288 // If file-drag mode is set, temp and recycler folders are filtered out.
289 /**
290 * @todo Define visibility
291 */
292 public $ext_noTempRecyclerDirs = 0;
293
294 /**
295 * Returns TRUE if the input "record" contains a folder which can be linked.
296 *
297 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject object with information about the folder element. Contains keys like title, uid, path, _title
298 * @return boolean TRUE is returned if the path is NOT a recycler or temp folder AND if ->ext_noTempRecyclerDirs is not set.
299 * @todo Define visibility
300 */
301 public function ext_isLinkable($folderObject) {
302 if ($this->ext_noTempRecyclerDirs && (substr($folderObject->getIdentifier(), -7) == '_temp_/' || substr($folderObject->getIdentifier(), -11) == '_recycler_/')) {
303 return FALSE;
304 } else {
305 return TRUE;
306 }
307 }
308
309 /**
310 * Wrapping the title in a link, if applicable.
311 *
312 * @param string $title Title, ready for output.
313 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject The folderObject 'record'
314 * @return string Wrapping title string.
315 * @todo Define visibility
316 */
317 public function wrapTitle($title, $folderObject) {
318 if ($this->ext_isLinkable($folderObject)) {
319 $aOnClick = 'return jumpToUrl(\'' . $this->thisScript . '?act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier()) . '\');';
320 return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
321 } else {
322 return '<span class="typo3-dimmed">' . $title . '</span>';
323 }
324 }
325
326 }
327
328 /*
329 * @deprecated since 6.0, the classname browse_links and this file is obsolete
330 * and will be removed with 6.2. The class was renamed and is now located at:
331 * typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php
332 */
333 require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('recordlist') . 'Classes/Browser/ElementBrowser.php';
334 ?>