98f1bd1b392cd36d56b360d0fe20fe7420e2bb71
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / Classes / PageTree.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 /**
18 * Displays the page/file tree for browsing database records or files.
19 * Used from TCEFORMS an other elements
20 * In other words: This is the ELEMENT BROWSER!
21 *
22 * Adapted for htmlArea RTE by Stanislas Rolland
23 */
24 use TYPO3\CMS\Core\Utility\GeneralUtility;
25
26 /**
27 * Class which generates the page tree
28 */
29 class PageTree extends \TYPO3\CMS\Backend\Tree\View\ElementBrowserPageTreeView {
30
31 /**
32 * Create the page navigation tree in HTML
33 *
34 * @param array Tree array
35 * @return string HTML output.
36 */
37 public function printTree($treeArr = '') {
38 $titleLen = (int)$GLOBALS['BE_USER']->uc['titleLen'];
39 if (!is_array($treeArr)) {
40 $treeArr = $this->tree;
41 }
42 $out = '';
43 $closeDepth = array();
44 foreach ($treeArr as $treeItem) {
45
46 $classAttr = $treeItem['row']['_CSSCLASS'];
47 if ($treeItem['isFirst']) {
48 $out .= '<ul class="list-tree">';
49 }
50
51 // Add CSS classes to the list item
52 if ($treeItem['hasSub']) {
53 $classAttr .= ' list-tree-control-open';
54 }
55
56 $selected = '';
57 if ($GLOBALS['SOBE']->browser->curUrlInfo['act'] == 'page' && $GLOBALS['SOBE']->browser->curUrlInfo['pageid'] == $treeItem['row']['uid'] && $GLOBALS['SOBE']->browser->curUrlInfo['pageid']) {
58 $selected = ' bg-success';
59 }
60 $aOnClick = 'return jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $GLOBALS['SOBE']->browser->act . '&editorNo=' . $GLOBALS['SOBE']->browser->editorNo . '&contentTypo3Language=' . $GLOBALS['SOBE']->browser->contentTypo3Language . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandPage=' . $treeItem['row']['uid']) . ');';
61 $cEbullet = $this->ext_isLinkable($treeItem['row']['doktype'], $treeItem['row']['uid']) ? '<a href="#" class="pull-right" onclick="' . htmlspecialchars($aOnClick) . '"><i class="fa fa-caret-square-o-right"></i></a>' : '';
62 $out .= '<li' . ($classAttr ? ' class="' . trim($classAttr) . '"' : '') . '><span class="list-tree-group' . $selected . '">' . $cEbullet . $treeItem['HTML'] . $this->wrapTitle($this->getTitleStr($treeItem['row'], $titleLen), $treeItem['row'], $this->ext_pArrPages) . '</span>';
63
64 if (!$treeItem['hasSub']) {
65 $out .= '</li>';
66 }
67
68 // We have to remember if this is the last one
69 // on level X so the last child on level X+1 closes the <ul>-tag
70 if ($treeItem['isLast']) {
71 $closeDepth[$treeItem['invertedDepth']] = 1;
72 }
73 // If this is the last one and does not have subitems, we need to close
74 // the tree as long as the upper levels have last items too
75 if ($treeItem['isLast'] && !$treeItem['hasSub']) {
76 for ($i = $treeItem['invertedDepth']; $closeDepth[$i] == 1; $i++) {
77 $closeDepth[$i] = 0;
78 $out .= '</ul></li>';
79 }
80 }
81 }
82 $out = '<ul class="list-tree" id="treeRoot">' . $out . '</ul>';
83 return $out;
84 }
85
86 }