|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the TYPO3 CMS project. |
|
5
|
|
|
* |
|
6
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
7
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
8
|
|
|
* of the License, or any later version. |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please read the |
|
11
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
12
|
|
|
* |
|
13
|
|
|
* The TYPO3 project - inspiring people to share! |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace TYPO3\CMS\Impexp\View; |
|
17
|
|
|
|
|
18
|
|
|
use TYPO3\CMS\Backend\Tree\View\BrowseTreeView; |
|
19
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility; |
|
20
|
|
|
use TYPO3\CMS\Core\Imaging\Icon; |
|
21
|
|
|
use TYPO3\CMS\Core\Imaging\IconFactory; |
|
22
|
|
|
use TYPO3\CMS\Core\Type\Bitmask\Permission; |
|
23
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Extension of the page tree class. Used to get the tree of pages to export. |
|
27
|
|
|
* @internal |
|
28
|
|
|
*/ |
|
29
|
|
|
class ExportPageTreeView extends BrowseTreeView |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* Initialization |
|
33
|
|
|
*/ |
|
34
|
|
|
public function __construct() |
|
35
|
|
|
{ |
|
36
|
|
|
parent::__construct(); |
|
37
|
|
|
$this->init(); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Wrapping title from page tree. |
|
42
|
|
|
* |
|
43
|
|
|
* @param string $title Title to wrap |
|
44
|
|
|
* @param string $row Item record |
|
45
|
|
|
* @param int $bank Bank pointer (which mount point number) |
|
46
|
|
|
* @return string Wrapped title |
|
47
|
|
|
* @internal |
|
48
|
|
|
*/ |
|
49
|
|
|
public function wrapTitle($title, $row, $bank = 0) |
|
50
|
|
|
{ |
|
51
|
|
|
return trim($title) === '' ? '<em>[' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title')) . ']</em>' : htmlspecialchars($title); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Wrapping Plus/Minus icon |
|
56
|
|
|
* |
|
57
|
|
|
* @param string $icon Icon HTML |
|
58
|
|
|
* @param mixed $cmd (See parent class) |
|
59
|
|
|
* @param mixed $bMark (See parent class) |
|
60
|
|
|
* @param bool $isOpen |
|
61
|
|
|
* @return string Icon HTML |
|
62
|
|
|
*/ |
|
63
|
|
|
public function PM_ATagWrap($icon, $cmd, $bMark = '', $isOpen = false) |
|
64
|
|
|
{ |
|
65
|
|
|
return $icon; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Wrapping Icon |
|
70
|
|
|
* |
|
71
|
|
|
* @param string $icon Icon HTML |
|
72
|
|
|
* @param array $row Record row (page) |
|
73
|
|
|
* @return string Icon HTML |
|
74
|
|
|
*/ |
|
75
|
|
|
public function wrapIcon($icon, $row) |
|
76
|
|
|
{ |
|
77
|
|
|
return $icon; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Tree rendering |
|
82
|
|
|
* |
|
83
|
|
|
* @param int $pid PID value |
|
84
|
|
|
* @param string $clause Additional where clause |
|
85
|
|
|
* @return array Array of tree elements |
|
86
|
|
|
*/ |
|
87
|
|
|
public function ext_tree($pid, $clause = '') |
|
88
|
|
|
{ |
|
89
|
|
|
// Initialize: |
|
90
|
|
|
$this->init(' AND ' . $this->BE_USER->getPagePermsClause(Permission::PAGE_SHOW) . $clause); |
|
91
|
|
|
// Get stored tree structure: |
|
92
|
|
|
$this->stored = json_decode($this->BE_USER->uc['browseTrees']['browsePages'], true); |
|
93
|
|
|
$treeArr = []; |
|
94
|
|
|
$idx = 0; |
|
95
|
|
|
// Set first: |
|
96
|
|
|
$this->bank = $idx; |
|
97
|
|
|
$isOpen = $this->stored[$idx][$pid] || $this->expandFirst; |
|
98
|
|
|
// save ids |
|
99
|
|
|
$curIds = $this->ids; |
|
100
|
|
|
$this->reset(); |
|
101
|
|
|
$this->ids = $curIds; |
|
102
|
|
|
if ($pid > 0) { |
|
103
|
|
|
$rootRec = BackendUtility::getRecordWSOL('pages', $pid); |
|
104
|
|
|
$iconFactory = GeneralUtility::makeInstance(IconFactory::class); |
|
105
|
|
|
$firstHtml = $iconFactory->getIconForRecord('pages', $rootRec, Icon::SIZE_SMALL)->render(); |
|
106
|
|
|
} else { |
|
107
|
|
|
$rootRec = [ |
|
108
|
|
|
'title' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'], |
|
109
|
|
|
'uid' => 0 |
|
110
|
|
|
]; |
|
111
|
|
|
$firstHtml = $this->getRootIcon($rootRec); |
|
112
|
|
|
} |
|
113
|
|
|
$this->tree[] = ['HTML' => $firstHtml, 'row' => $rootRec, 'hasSub' => $isOpen]; |
|
114
|
|
|
if ($isOpen) { |
|
115
|
|
|
// Set depth: |
|
116
|
|
|
if ($this->addSelfId) { |
|
117
|
|
|
$this->ids[] = $pid; |
|
118
|
|
|
} |
|
119
|
|
|
$this->getTree($pid, 999, ''); |
|
120
|
|
|
$idH = []; |
|
121
|
|
|
$idH[$pid]['uid'] = $pid; |
|
122
|
|
|
if (!empty($this->buffer_idH)) { |
|
123
|
|
|
$idH[$pid]['subrow'] = $this->buffer_idH; |
|
124
|
|
|
} |
|
125
|
|
|
$this->buffer_idH = $idH; |
|
126
|
|
|
} |
|
127
|
|
|
// Add tree: |
|
128
|
|
|
return array_merge($treeArr, $this->tree); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* Compiles the HTML code for displaying the structure found inside the ->tree array |
|
133
|
|
|
* |
|
134
|
|
|
* @param array|string $treeArr "tree-array" - if blank string, the internal ->tree array is used. |
|
135
|
|
|
* @return string The HTML code for the tree |
|
136
|
|
|
*/ |
|
137
|
|
|
public function printTree($treeArr = '') |
|
138
|
|
|
{ |
|
139
|
|
|
$titleLen = (int)$this->BE_USER->uc['titleLen']; |
|
140
|
|
|
if (!is_array($treeArr)) { |
|
141
|
|
|
$treeArr = $this->tree; |
|
142
|
|
|
} |
|
143
|
|
|
$out = ''; |
|
144
|
|
|
$closeDepth = []; |
|
145
|
|
|
foreach ($treeArr as $treeItem) { |
|
146
|
|
|
$classAttr = ''; |
|
147
|
|
|
if ($treeItem['isFirst']) { |
|
148
|
|
|
$out .= '<ul class="list-tree">'; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
// Add CSS classes to the list item |
|
152
|
|
|
if ($treeItem['hasSub']) { |
|
153
|
|
|
$classAttr .= ' list-tree-control-open'; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
$idAttr = htmlspecialchars($this->domIdPrefix . $this->getId($treeItem['row']) . '_' . $treeItem['bank']); |
|
157
|
|
|
$out .= ' |
|
158
|
|
|
<li id="' . $idAttr . '"' . ($classAttr ? ' class="' . trim($classAttr) . '"' : '') . '> |
|
159
|
|
|
<span class="list-tree-group"> |
|
160
|
|
|
<span class="list-tree-icon">' . $treeItem['HTML'] . '</span> |
|
161
|
|
|
<span class="list-tree-title">' . $this->wrapTitle($this->getTitleStr($treeItem['row'], $titleLen), $treeItem['row'], $treeItem['bank']) . '</span> |
|
162
|
|
|
</span>'; |
|
163
|
|
|
|
|
164
|
|
|
if (!$treeItem['hasSub']) { |
|
165
|
|
|
$out .= '</li>'; |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
// We have to remember if this is the last one |
|
169
|
|
|
// on level X so the last child on level X+1 closes the <ul>-tag |
|
170
|
|
|
if ($treeItem['isLast']) { |
|
171
|
|
|
$closeDepth[$treeItem['invertedDepth']] = 1; |
|
172
|
|
|
} |
|
173
|
|
|
// If this is the last one and does not have subitems, we need to close |
|
174
|
|
|
// the tree as long as the upper levels have last items too |
|
175
|
|
|
if ($treeItem['isLast'] && !$treeItem['hasSub']) { |
|
176
|
|
|
for ($i = $treeItem['invertedDepth']; $closeDepth[$i] == 1; $i++) { |
|
177
|
|
|
$closeDepth[$i] = 0; |
|
178
|
|
|
$out .= '</ul></li>'; |
|
179
|
|
|
} |
|
180
|
|
|
} |
|
181
|
|
|
} |
|
182
|
|
|
$out = '<ul class="list-tree list-tree-root list-tree-root-clean">' . $out . '</ul>'; |
|
183
|
|
|
return $out; |
|
184
|
|
|
} |
|
185
|
|
|
} |
|
186
|
|
|
|