[BUGFIX] Remove unused references to former ElementBrowser
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Tree / View / ElementBrowserFolderTreeView.php
1 <?php
2 namespace TYPO3\CMS\Backend\Tree\View;
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\Core\Resource\Folder;
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19 use TYPO3\CMS\Recordlist\Tree\View\LinkParameterProviderInterface;
20
21 /**
22 * Base extension class which generates the folder tree.
23 * Used directly by the RTE.
24 * also used for the linkpicker on files
25 *
26 * Browsable folder tree, used in Element Browser and RTE (for which it will be extended)
27 * previously located inside typo3/class.browse_links.php
28 */
29 class ElementBrowserFolderTreeView extends FolderTreeView
30 {
31 /**
32 * @var int
33 */
34 public $ext_IconMode = 1;
35
36 /**
37 * @var LinkParameterProviderInterface
38 */
39 protected $linkParameterProvider;
40
41 /**
42 * @param LinkParameterProviderInterface $linkParameterProvider
43 *
44 * @return void
45 */
46 public function setLinkParameterProvider(LinkParameterProviderInterface $linkParameterProvider)
47 {
48 $this->linkParameterProvider = $linkParameterProvider;
49 $this->thisScript = $linkParameterProvider->getScriptUrl();
50 }
51
52 /**
53 * Wrapping the title in a link, if applicable.
54 *
55 * @param string $title Title, ready for output.
56 * @param Folder $folderObject The "record
57 * @return string Wrapping title string.
58 */
59 public function wrapTitle($title, Folder $folderObject)
60 {
61 if ($this->ext_isLinkable($folderObject)) {
62 $parameters = GeneralUtility::implodeArrayForUrl('', $this->linkParameterProvider->getUrlParameters(['identifier' => $folderObject->getCombinedIdentifier()]));
63 return '<a href="#" onclick="return jumpToUrl(' . htmlspecialchars(GeneralUtility::quoteJSvalue($this->getThisScript() . ltrim($parameters, '&'))) . ');">' . $title . '</a>';
64 } else {
65 return '<span class="text-muted">' . $title . '</span>';
66 }
67 }
68
69 /**
70 * Returns TRUE if the input "record" contains a folder which can be linked.
71 *
72 * @param Folder $folderObject Object with information about the folder element. Contains keys like title, uid, path, _title
73 * @return bool TRUE is returned if the path is found in the web-part of the server and is NOT a recycler or temp folder AND if ->ext_noTempRecyclerDirs is not set.
74 */
75 public function ext_isLinkable(Folder $folderObject)
76 {
77 $identifier = $folderObject->getIdentifier();
78 return !$this->ext_noTempRecyclerDirs || substr($identifier, -7) !== '_temp_/' && substr($identifier, -11) !== '_recycler_/';
79 }
80
81 /**
82 * @param string $cmd
83 * @param bool $isOpen
84 * @return string
85 */
86 protected function renderPMIconAndLink($cmd, $isOpen)
87 {
88 if (get_class($this) === __CLASS__) {
89 return $this->PMiconATagWrap('', $cmd, !$isOpen);
90 }
91 return parent::renderPMIconAndLink($cmd, $isOpen);
92 }
93
94 /**
95 * Wrap the plus/minus icon in a link
96 *
97 * @param string $icon HTML string to wrap, probably an image tag.
98 * @param string $cmd Command for 'PM' get var
99 * @param bool|string $bMark If set, the link will have an anchor point (=$bMark) and a name attribute (=$bMark)
100 * @param bool $isOpen check if the item has children
101 * @return string Link-wrapped input string
102 * @access private
103 */
104 public function PM_ATagWrap($icon, $cmd, $bMark = '', $isOpen = false)
105 {
106 $anchor = $bMark ? '#' . $bMark : '';
107 $name = $bMark ? ' name=' . $bMark : '';
108 $urlParameters = $this->linkParameterProvider->getUrlParameters([]);
109 $urlParameters['PM'] = $cmd;
110 $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . ltrim(GeneralUtility::implodeArrayForUrl('', $urlParameters), '&')) . ',' . GeneralUtility::quoteJSvalue($anchor) . ');';
111 return '<a href="#"' . htmlspecialchars($name) . ' onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>';
112 }
113
114 /**
115 * Wrap the plus/minus icon in a link
116 *
117 * @param string $icon HTML string to wrap, probably an image tag.
118 * @param string $cmd Command for 'PM' get var
119 * @param bool $isExpand Whether to be expanded
120 * @return string Link-wrapped input string
121 * @internal
122 */
123 public function PMiconATagWrap($icon, $cmd, $isExpand = true)
124 {
125 if (empty($this->scope)) {
126 $this->scope = array(
127 'class' => get_class($this),
128 'script' => $this->thisScript,
129 'ext_noTempRecyclerDirs' => $this->ext_noTempRecyclerDirs,
130 'browser' => $this->linkParameterProvider->getUrlParameters([]),
131 );
132 }
133
134 return parent::PMiconATagWrap($icon, $cmd, $isExpand);
135 }
136 }