[TASK] Add typehints for ElementBrowser usage via SOBE
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / Classes / FolderTree.php
1 <?php
2 namespace TYPO3\CMS\Rtehtmlarea;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Tree\View\ElementBrowserFolderTreeView;
18 use TYPO3\CMS\Core\Resource\Folder;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20
21 /**
22 * RTE class which generates the folder tree.
23 */
24 class FolderTree extends ElementBrowserFolderTreeView {
25
26 /**
27 * Will create and return the HTML code for a browsable tree of folders.
28 * Is based on the mounts found in the internal array ->MOUNTS (set in the constructor)
29 *
30 * @return string HTML code for the browsable tree
31 */
32 public function getBrowsableTree() {
33 // TYPO3\CMS\Backend\Controller\FileSystemNavigationFrameController does not set custom parameters on an Ajax expand/collapse request
34 /** @var BrowseLinks|SelectImage $elementBrowser */
35 $elementBrowser = $GLOBALS['SOBE']->browser;
36 if (!$elementBrowser->editorNo) {
37 $scopeData = (string)GeneralUtility::_GP('scopeData');
38 $scopeHash = (string)GeneralUtility::_GP('scopeHash');
39 if (!empty($scopeData) && GeneralUtility::hmac($scopeData) === $scopeHash) {
40 $scopeData = unserialize($scopeData);
41 if ($scopeData['browser']['editorNo']) {
42 $elementBrowser->editorNo = $scopeData['browser']['editorNo'];
43 }
44 if ($scopeData['browser']['sys_language_content']) {
45 $elementBrowser->sys_language_content = $scopeData['browser']['sys_language_content'];
46 }
47 if ($scopeData['browser']['contentTypo3Language']) {
48 $elementBrowser->contentTypo3Language = $scopeData['browser']['contentTypo3Language'];
49 }
50 }
51 }
52 return parent::getBrowsableTree();
53 }
54
55 /**
56 * Wrapping the title in a link, if applicable.
57 *
58 * @param string $title Title, ready for output.
59 * @param Folder $folderObject The "record"
60 * @return string Wrapping title string.
61 */
62 public function wrapTitle($title, Folder $folderObject) {
63 if ($this->ext_isLinkable($folderObject)) {
64 /** @var BrowseLinks|SelectImage $elementBrowser */
65 $elementBrowser = $GLOBALS['SOBE']->browser;
66 $aOnClick = 'return jumpToUrl(\''
67 . $this->getThisScript()
68 . 'act=' . $elementBrowser->act
69 . '&mode=' . $elementBrowser->mode
70 . '&editorNo=' . $elementBrowser->editorNo
71 . ($elementBrowser->sys_language_content ? '&sys_language_content=' . $elementBrowser->sys_language_content : '')
72 . ($elementBrowser->contentTypo3Language ? '&contentTypo3Language=' . $elementBrowser->contentTypo3Language : '')
73 . '&expandFolder=' . $this->getJumpToParam($folderObject)
74 . '\');';
75 return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
76 } else {
77 return '<span class="text-muted">' . $title . '</span>';
78 }
79 }
80
81 /**
82 * Wrap the plus/minus icon in a link
83 *
84 * @param string $icon HTML string to wrap, probably an image tag.
85 * @param string $cmd Command for 'PM' get var
86 * @param bool $isExpand If expanded
87 * @return string Link-wrapped input string
88 * @access private
89 */
90 public function PMiconATagWrap($icon, $cmd, $isExpand = TRUE) {
91 if (empty($this->scope)) {
92 /** @var BrowseLinks|SelectImage $elementBrowser */
93 $elementBrowser = $GLOBALS['SOBE']->browser;
94 $this->scope = array(
95 'class' => get_class($this),
96 'script' => $this->thisScript,
97 'ext_noTempRecyclerDirs' => $this->ext_noTempRecyclerDirs,
98 'browser' => array(
99 'mode' => $elementBrowser->mode,
100 'act' => $elementBrowser->act
101 )
102 );
103 if ($elementBrowser->editorNo) {
104 $this->scope['browser']['editorNo'] = $elementBrowser->editorNo;
105 }
106 if ($elementBrowser->sys_language_content) {
107 $this->scope['browser']['sys_language_content'] = $elementBrowser->sys_language_content;
108 }
109 if ($elementBrowser->contentTypo3Language) {
110 $this->scope['browser']['contentTypo3Language'] = $elementBrowser->contentTypo3Language;
111 }
112 }
113 return parent::PMiconATagWrap($icon, $cmd, $isExpand);
114 }
115
116 }