[BUGFIX] Impexp is broken
[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 * Extension of the page tree class. Used to get the tree of pages to export.
31 *
32 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
33 */
34 class LocalPageTree extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
35
36 /**
37 * Initialization
38 *
39 * @todo Define visibility
40 */
41 public function __construct() {
42 $this->init();
43 }
44
45 /**
46 * Wrapping title from page tree.
47 *
48 * @param string $title Title to wrap
49 * @param mixed $v (See parent class)
50 * @return string Wrapped title
51 * @todo Define visibility
52 */
53 public function wrapTitle($title, $v) {
54 $title = !strcmp(trim($title), '') ? '<em>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title', 1) . ']</em>' : htmlspecialchars($title);
55 return $title;
56 }
57
58 /**
59 * Wrapping Plus/Minus icon
60 *
61 * @param string $icon Icon HTML
62 * @param mixed $cmd (See parent class)
63 * @param mixed $bMark (See parent class)
64 * @return string Icon HTML
65 * @todo Define visibility
66 */
67 public function PM_ATagWrap($icon, $cmd, $bMark = '') {
68 return $icon;
69 }
70
71 /**
72 * Wrapping Icon
73 *
74 * @param string $icon Icon HTML
75 * @param array $row Record row (page)
76 * @return string Icon HTML
77 * @todo Define visibility
78 */
79 public function wrapIcon($icon, $row) {
80 return $icon;
81 }
82
83 /**
84 * Select permissions
85 *
86 * @return string SQL where clause
87 * @todo Define visibility
88 */
89 public function permsC() {
90 return $this->BE_USER->getPagePermsClause(1);
91 }
92
93 /**
94 * Tree rendering
95 *
96 * @param integer $pid PID value
97 * @param string $clause Additional where clause
98 * @return array Array of tree elements
99 * @todo Define visibility
100 */
101 public function ext_tree($pid, $clause = '') {
102 // Initialize:
103 $this->init(' AND ' . $this->permsC() . $clause);
104 // Get stored tree structure:
105 $this->stored = unserialize($this->BE_USER->uc['browseTrees']['browsePages']);
106 // PM action:
107 $PM = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode('_', \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('PM'));
108 // traverse mounts:
109 $titleLen = intval($this->BE_USER->uc['titleLen']);
110 $treeArr = array();
111 $idx = 0;
112 // Set first:
113 $this->bank = $idx;
114 $isOpen = $this->stored[$idx][$pid] || $this->expandFirst;
115 // save ids
116 $curIds = $this->ids;
117 $this->reset();
118 $this->ids = $curIds;
119 // Set PM icon:
120 $cmd = $this->bank . '_' . ($isOpen ? '0_' : '1_') . $pid;
121 $icon = '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->backPath, ('gfx/ol/' . ($isOpen ? 'minus' : 'plus') . 'only.gif'), 'width="18" height="16"') . ' align="top" alt="" />';
122 $firstHtml = $this->PM_ATagWrap($icon, $cmd);
123 if ($pid > 0) {
124 $rootRec = \t3lib_befunc::getRecordWSOL('pages', $pid);
125 $firstHtml .= $this->wrapIcon(\TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $rootRec), $rootRec);
126 } else {
127 $rootRec = array(
128 'title' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
129 'uid' => 0
130 );
131 $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);
132 }
133 $this->tree[] = array('HTML' => $firstHtml, 'row' => $rootRec);
134 if ($isOpen) {
135 // Set depth:
136 $depthD = '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->backPath, 'gfx/ol/blank.gif', 'width="18" height="16"') . ' align="top" alt="" />';
137 if ($this->addSelfId) {
138 $this->ids[] = $pid;
139 }
140 $this->getTree($pid, 999, $depthD);
141 $idH = array();
142 $idH[$pid]['uid'] = $pid;
143 if (count($this->buffer_idH)) {
144 $idH[$pid]['subrow'] = $this->buffer_idH;
145 }
146 $this->buffer_idH = $idH;
147 }
148 // Add tree:
149 $treeArr = array_merge($treeArr, $this->tree);
150 return $treeArr;
151 }
152
153 }
154
155
156 ?>