[!!!][TASK] Move non-namespaced classes into correct places
[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 * @var int
29 */
30 public $ext_IconMode = 1;
31
32 /**
33 * Initializes the script path
34 */
35 public function __construct() {
36 $this->determineScriptUrl();
37 parent::__construct();
38 }
39
40 /**
41 * Wrapping the title in a link, if applicable.
42 *
43 * @param string $title Title, ready for output.
44 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject The "record
45 * @return string Wrapping title string.
46 */
47 public function wrapTitle($title, \TYPO3\CMS\Core\Resource\Folder $folderObject) {
48 if ($this->ext_isLinkable($folderObject)) {
49 $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())) . ');';
50 return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
51 } else {
52 return '<span class="typo3-dimmed">' . $title . '</span>';
53 }
54 }
55
56 /**
57 * Returns TRUE if the input "record" contains a folder which can be linked.
58 *
59 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject Object with information about the folder element. Contains keys like title, uid, path, _title
60 * @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
61 */
62 public function ext_isLinkable(\TYPO3\CMS\Core\Resource\Folder $folderObject) {
63 if (strstr($folderObject->getIdentifier(), '_recycler_') || strstr($folderObject->getIdentifier(), '_temp_')) {
64 return FALSE;
65 } else {
66 return TRUE;
67 }
68 }
69
70 /**
71 * Wrap the plus/minus icon in a link
72 *
73 * @param string $icon HTML string to wrap, probably an image tag.
74 * @param string $cmd Command for 'PM' get var
75 * @param bool $bMark If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
76 * @return string Link-wrapped input string
77 * @access private
78 */
79 public function PM_ATagWrap($icon, $cmd, $bMark = '') {
80 $name = $anchor = '';
81 if ($bMark) {
82 $anchor = '#' . $bMark;
83 $name = ' name="' . $bMark . '"';
84 }
85 $aOnClick = 'return jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->getThisScript() . 'PM=' . $cmd) . ',' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($anchor) . ');';
86 return '<a href="#"' . htmlspecialchars($name) . ' onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>';
87 }
88
89 }