[CLEANUP] Tree Classes
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / Classes / LocalPageTree.php
1 <?php
2 namespace TYPO3\CMS\Impexp;
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 use TYPO3\CMS\Backend\Utility\IconUtility;
17
18 /**
19 * Extension of the page tree class. Used to get the tree of pages to export.
20 *
21 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
22 */
23 class LocalPageTree extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
24
25 /**
26 * Initialization
27 */
28 public function __construct() {
29 $this->init();
30 }
31
32 /**
33 * Wrapping title from page tree.
34 *
35 * @param string $title Title to wrap
36 * @param mixed $v (See parent class)
37 * @return string Wrapped title
38 */
39 public function wrapTitle($title, $v) {
40 return trim($title) === '' ? '<em>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', TRUE) . ']</em>' : htmlspecialchars($title);
41 }
42
43 /**
44 * Wrapping Plus/Minus icon
45 *
46 * @param string $icon Icon HTML
47 * @param mixed $cmd (See parent class)
48 * @param mixed $bMark (See parent class)
49 * @return string Icon HTML
50 */
51 public function PM_ATagWrap($icon, $cmd, $bMark = '') {
52 return $icon;
53 }
54
55 /**
56 * Wrapping Icon
57 *
58 * @param string $icon Icon HTML
59 * @param array $row Record row (page)
60 * @return string Icon HTML
61 */
62 public function wrapIcon($icon, $row) {
63 return $icon;
64 }
65
66 /**
67 * Tree rendering
68 *
69 * @param int $pid PID value
70 * @param string $clause Additional where clause
71 * @return array Array of tree elements
72 */
73 public function ext_tree($pid, $clause = '') {
74 // Initialize:
75 $this->init(' AND ' . $this->BE_USER->getPagePermsClause(1) . $clause);
76 // Get stored tree structure:
77 $this->stored = unserialize($this->BE_USER->uc['browseTrees']['browsePages']);
78 $treeArr = array();
79 $idx = 0;
80 // Set first:
81 $this->bank = $idx;
82 $isOpen = $this->stored[$idx][$pid] || $this->expandFirst;
83 // save ids
84 $curIds = $this->ids;
85 $this->reset();
86 $this->ids = $curIds;
87 $firstHtml = '<img' . IconUtility::skinImg($this->backPath, ('gfx/ol/' . ($isOpen ? 'minus' : 'plus') . 'only.gif'), 'width="18" height="16"') . ' align="top" alt="" />';
88 if ($pid > 0) {
89 $rootRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL('pages', $pid);
90 $firstHtml .= IconUtility::getSpriteIconForRecord('pages', $rootRec);
91 } else {
92 $rootRec = array(
93 'title' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
94 'uid' => 0
95 );
96 $firstHtml .= $this->getRootIcon($rootRec);
97 }
98 $this->tree[] = array('HTML' => $firstHtml, 'row' => $rootRec);
99 if ($isOpen) {
100 // Set depth:
101 $depthD = '<img' . IconUtility::skinImg($this->backPath, 'gfx/ol/blank.gif', 'width="18" height="16"') . ' align="top" alt="" />';
102 if ($this->addSelfId) {
103 $this->ids[] = $pid;
104 }
105 $this->getTree($pid, 999, $depthD);
106 $idH = array();
107 $idH[$pid]['uid'] = $pid;
108 if (!empty($this->buffer_idH)) {
109 $idH[$pid]['subrow'] = $this->buffer_idH;
110 }
111 $this->buffer_idH = $idH;
112 }
113 // Add tree:
114 $treeArr = array_merge($treeArr, $this->tree);
115 return $treeArr;
116 }
117
118 }