8f4bfc10e81150b1ea67bf0fe96862c152266118
[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 /**
18 * Base extension class which generates the folder tree.
19 * Used directly by the RTE.
20 * also used for the linkpicker on files
21 *
22 * Browsable folder tree, used in Element Browser and RTE (for which it will be extended)
23 * previously located inside typo3/class.browse_links.php
24 */
25 class ElementBrowserFolderTreeView extends FolderTreeView {
26
27 /**
28 * If file-drag mode is set, temp and recycler folders are filtered out.
29 *
30 * @var int
31 */
32 public $ext_noTempRecyclerDirs = 0;
33
34 /**
35 * @var int
36 */
37 public $ext_IconMode = 1;
38
39 /**
40 * Initializes the script path
41 */
42 public function __construct() {
43 $this->determineScriptUrl();
44 parent::__construct();
45 }
46
47 /**
48 * Wrapping the title in a link, if applicable.
49 *
50 * @param string $title Title, ready for output.
51 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject The "record
52 * @return string Wrapping title string.
53 */
54 public function wrapTitle($title, \TYPO3\CMS\Core\Resource\Folder $folderObject) {
55 if ($this->ext_isLinkable($folderObject)) {
56 $aOnClick = 'return jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier())) . ');';
57 return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
58 } else {
59 return '<span class="text-muted">' . $title . '</span>';
60 }
61 }
62
63 /**
64 * Returns TRUE if the input "record" contains a folder which can be linked.
65 *
66 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject Object with information about the folder element. Contains keys like title, uid, path, _title
67 * @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.
68 */
69 public function ext_isLinkable(\TYPO3\CMS\Core\Resource\Folder $folderObject) {
70 if ($this->ext_noTempRecyclerDirs && (substr($folderObject->getIdentifier(), -7) === '_temp_/' || substr($folderObject->getIdentifier(), -11) === '_recycler_/')) {
71 return FALSE;
72 } else {
73 return TRUE;
74 }
75 }
76
77 /**
78 * Wrap the plus/minus icon in a link
79 *
80 * @param string $icon HTML string to wrap, probably an image tag.
81 * @param string $cmd Command for 'PM' get var
82 * @param bool $bMark If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
83 * @return string Link-wrapped input string
84 * @access private
85 */
86 public function PM_ATagWrap($icon, $cmd, $bMark = '', $isOpen = FALSE) {
87 $name = $anchor = '';
88 if ($bMark) {
89 $anchor = '#' . $bMark;
90 $name = ' name="' . $bMark . '"';
91 }
92 $aOnClick = 'return jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->getThisScript() . 'PM=' . $cmd) . ',' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($anchor) . ');';
93 return '<a href="#"' . htmlspecialchars($name) . ' onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>';
94 }
95
96 }