[BUGFIX] Folder tree in popup throws JS error
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / Classes / FolderTree.php
1 <?php
2 namespace TYPO3\CMS\Rtehtmlarea;
3
4 /**
5 * Base extension class which generates the folder tree.
6 * Used directly by the RTE.
7 *
8 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
9 */
10 class FolderTree extends \rteFolderTree {
11
12 /**
13 * Constructor function of the class
14 */
15 public function __construct() {
16 // The backpath is set her to fix problems with relatives path when used in ajax scope
17 $GLOBALS['BACK_PATH'] = isset($GLOBALS['ajaxID']) ? '../../../' : $GLOBALS['BACK_PATH'];
18 parent::__construct();
19 }
20
21 /**
22 * Wrapping the title in a link, if applicable.
23 *
24 * @param string Title, ready for output.
25 * @param \TYPO3\CMS\Core\Resource\Folder The "record
26 * @return string Wrapping title string.
27 * @todo Define visibility
28 */
29 public function wrapTitle($title, \TYPO3\CMS\Core\Resource\Folder $folderObject) {
30 if ($this->ext_isLinkable($folderObject)) {
31 $aOnClick = 'return jumpToUrl(\'' . $this->thisScript . '?act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&editorNo=' . $GLOBALS['SOBE']->browser->editorNo . '&contentTypo3Language=' . $GLOBALS['SOBE']->browser->contentTypo3Language . '&contentTypo3Charset=' . $GLOBALS['SOBE']->browser->contentTypo3Charset . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier()) . '\');';
32 return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
33 } else {
34 return '<span class="typo3-dimmed">' . $title . '</span>';
35 }
36 }
37
38 /**
39 * Wrap the plus/minus icon in a link
40 *
41 * @param string $icon HTML string to wrap, probably an image tag.
42 * @param string $cmd Command for 'PM' get var
43 * @param boolean $isExpand If expanded
44 * @return string Link-wrapped input string
45 * @access private
46 */
47 public function PMiconATagWrap($icon, $cmd, $isExpand = TRUE) {
48
49 if (empty($this->scope)) {
50 $this->scope = array(
51 'class' => get_class($this),
52 'script' => $this->thisScript,
53 'ext_noTempRecyclerDirs' => $this->ext_noTempRecyclerDirs,
54 'browser' => array(
55 'mode' => $GLOBALS['SOBE']->browser->mode,
56 'act' => $GLOBALS['SOBE']->browser->act,
57 ),
58 );
59 }
60
61 if ($this->thisScript) {
62 // Activates dynamic AJAX based tree
63 $scopeData = serialize($this->scope);
64 $scopeHash = \TYPO3\CMS\Core\Utility\GeneralUtility::hmac($scopeData);
65 $js = htmlspecialchars('Tree.thisScript=\'' . $this->backPath . 'ajax.php\',Tree.load(\'' . $cmd . '\', ' . intval($isExpand) . ', this, ' . json_encode($scopeData) . ', \'' . $scopeHash . '\');');
66 return '<a class="pm" onclick="' . $js . '">' . $icon . '</a>';
67 } else {
68 return $icon;
69 }
70 }
71
72 }
73
74 ?>