[TASK] Cleanup impexp
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / Classes / LocalPageTree.php
1 <?php
2 namespace TYPO3\CMS\Impexp;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 /**
31 * Extension of the page tree class. Used to get the tree of pages to export.
32 *
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 */
35 class LocalPageTree extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
36
37 /**
38 * Initialization
39 */
40 public function __construct() {
41 $this->init();
42 }
43
44 /**
45 * Wrapping title from page tree.
46 *
47 * @param string $title Title to wrap
48 * @param mixed $v (See parent class)
49 * @return string Wrapped title
50 * @todo Define visibility
51 */
52 public function wrapTitle($title, $v) {
53 $title = !strcmp(trim($title), '') ? '<em>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title', 1) . ']</em>' : htmlspecialchars($title);
54 return $title;
55 }
56
57 /**
58 * Wrapping Plus/Minus icon
59 *
60 * @param string $icon Icon HTML
61 * @param mixed $cmd (See parent class)
62 * @param mixed $bMark (See parent class)
63 * @return string Icon HTML
64 * @todo Define visibility
65 */
66 public function PM_ATagWrap($icon, $cmd, $bMark = '') {
67 return $icon;
68 }
69
70 /**
71 * Wrapping Icon
72 *
73 * @param string $icon Icon HTML
74 * @param array $row Record row (page)
75 * @return string Icon HTML
76 * @todo Define visibility
77 */
78 public function wrapIcon($icon, $row) {
79 return $icon;
80 }
81
82 /**
83 * Select permissions
84 *
85 * @return string SQL where clause
86 * @todo Define visibility
87 */
88 public function permsC() {
89 return $this->BE_USER->getPagePermsClause(1);
90 }
91
92 /**
93 * Tree rendering
94 *
95 * @param integer $pid PID value
96 * @param string $clause Additional where clause
97 * @return array Array of tree elements
98 * @todo Define visibility
99 */
100 public function ext_tree($pid, $clause = '') {
101 // Initialize:
102 $this->init(' AND ' . $this->permsC() . $clause);
103 // Get stored tree structure:
104 $this->stored = unserialize($this->BE_USER->uc['browseTrees']['browsePages']);
105 // PM action:
106 $PM = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode('_', \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('PM'));
107 // traverse mounts:
108 $titleLen = intval($this->BE_USER->uc['titleLen']);
109 $treeArr = array();
110 $idx = 0;
111 // Set first:
112 $this->bank = $idx;
113 $isOpen = $this->stored[$idx][$pid] || $this->expandFirst;
114 // save ids
115 $curIds = $this->ids;
116 $this->reset();
117 $this->ids = $curIds;
118 // Set PM icon:
119 $cmd = $this->bank . '_' . ($isOpen ? '0_' : '1_') . $pid;
120 $icon = '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->backPath, ('gfx/ol/' . ($isOpen ? 'minus' : 'plus') . 'only.gif'), 'width="18" height="16"') . ' align="top" alt="" />';
121 $firstHtml = $this->PM_ATagWrap($icon, $cmd);
122 if ($pid > 0) {
123 $rootRec = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL('pages', $pid);
124 $firstHtml .= $this->wrapIcon(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $rootRec), $rootRec);
125 } else {
126 $rootRec = array(
127 'title' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
128 'uid' => 0
129 );
130 $firstHtml .= $this->wrapIcon('<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->backPath, 'gfx/i/_icon_website.gif', 'width="18" height="16"') . ' align="top" alt="" />', $rootRec);
131 }
132 $this->tree[] = array('HTML' => $firstHtml, 'row' => $rootRec);
133 if ($isOpen) {
134 // Set depth:
135 $depthD = '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->backPath, 'gfx/ol/blank.gif', 'width="18" height="16"') . ' align="top" alt="" />';
136 if ($this->addSelfId) {
137 $this->ids[] = $pid;
138 }
139 $this->getTree($pid, 999, $depthD);
140 $idH = array();
141 $idH[$pid]['uid'] = $pid;
142 if (count($this->buffer_idH)) {
143 $idH[$pid]['subrow'] = $this->buffer_idH;
144 }
145 $this->buffer_idH = $idH;
146 }
147 // Add tree:
148 $treeArr = array_merge($treeArr, $this->tree);
149 return $treeArr;
150 }
151
152 }
153
154 ?>