89535969d619d77d4728cfc218e8e3bd2704d1cb
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / Classes / View / ExportPageTreeView.php
1 <?php
2 namespace TYPO3\CMS\Impexp\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 use TYPO3\CMS\Backend\Tree\View\BrowseTreeView;
18 use TYPO3\CMS\Backend\Utility\BackendUtility;
19 use TYPO3\CMS\Core\Imaging\Icon;
20 use TYPO3\CMS\Core\Imaging\IconFactory;
21 use TYPO3\CMS\Core\Utility\GeneralUtility;
22
23 /**
24 * Extension of the page tree class. Used to get the tree of pages to export.
25 */
26 class ExportPageTreeView extends BrowseTreeView
27 {
28 /**
29 * Initialization
30 */
31 public function __construct()
32 {
33 parent::__construct();
34 $this->init();
35 }
36
37 /**
38 * Wrapping title from page tree.
39 *
40 * @param string $title Title to wrap
41 * @param string $row Item record
42 * @param int $bank Bank pointer (which mount point number)
43 * @return string Wrapped title
44 * @access private
45 */
46 public function wrapTitle($title, $row, $bank = 0)
47 {
48 return trim($title) === '' ? '<em>[' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.no_title')) . ']</em>' : htmlspecialchars($title);
49 }
50
51 /**
52 * Wrapping Plus/Minus icon
53 *
54 * @param string $icon Icon HTML
55 * @param mixed $cmd (See parent class)
56 * @param mixed $bMark (See parent class)
57 * @param bool $isOpen
58 * @return string Icon HTML
59 */
60 public function PM_ATagWrap($icon, $cmd, $bMark = '', $isOpen = false)
61 {
62 return $icon;
63 }
64
65 /**
66 * Wrapping Icon
67 *
68 * @param string $icon Icon HTML
69 * @param array $row Record row (page)
70 * @return string Icon HTML
71 */
72 public function wrapIcon($icon, $row)
73 {
74 return $icon;
75 }
76
77 /**
78 * Tree rendering
79 *
80 * @param int $pid PID value
81 * @param string $clause Additional where clause
82 * @return array Array of tree elements
83 */
84 public function ext_tree($pid, $clause = '')
85 {
86 // Initialize:
87 $this->init(' AND ' . $this->BE_USER->getPagePermsClause(1) . $clause);
88 // Get stored tree structure:
89 $this->stored = unserialize($this->BE_USER->uc['browseTrees']['browsePages'], ['allowed_classes' => false]);
90 $treeArr = [];
91 $idx = 0;
92 // Set first:
93 $this->bank = $idx;
94 $isOpen = $this->stored[$idx][$pid] || $this->expandFirst;
95 // save ids
96 $curIds = $this->ids;
97 $this->reset();
98 $this->ids = $curIds;
99 if ($pid > 0) {
100 $rootRec = BackendUtility::getRecordWSOL('pages', $pid);
101 $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
102 $firstHtml = $iconFactory->getIconForRecord('pages', $rootRec, Icon::SIZE_SMALL)->render();
103 } else {
104 $rootRec = [
105 'title' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
106 'uid' => 0
107 ];
108 $firstHtml = $this->getRootIcon($rootRec);
109 }
110 $this->tree[] = ['HTML' => $firstHtml, 'row' => $rootRec, 'hasSub' => $isOpen];
111 if ($isOpen) {
112 // Set depth:
113 if ($this->addSelfId) {
114 $this->ids[] = $pid;
115 }
116 $this->getTree($pid, 999, '');
117 $idH = [];
118 $idH[$pid]['uid'] = $pid;
119 if (!empty($this->buffer_idH)) {
120 $idH[$pid]['subrow'] = $this->buffer_idH;
121 }
122 $this->buffer_idH = $idH;
123 }
124 // Add tree:
125 return array_merge($treeArr, $this->tree);
126 }
127 }