ecca79cbb694958a2d5e418225ab0dd7f50d8508
[Packages/TYPO3.CMS.git] / typo3 / class.browse_links.php
1 <?php
2 /**
3 * Class which generates the page tree
4 *
5 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
6 */
7 class localPageTree extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
8
9 /**
10 * whether the page ID should be shown next to the title, activate through
11 * userTSconfig (options.pageTree.showPageIdWithTitle)
12 *
13 * @boolean
14 */
15 public $ext_showPageId = FALSE;
16
17 /**
18 * Constructor. Just calling init()
19 *
20 * @todo Define visibility
21 */
22 public function __construct() {
23 $this->thisScript = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('SCRIPT_NAME');
24 $this->init();
25 $this->clause = ' AND doktype!=' . \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_RECYCLER . $this->clause;
26 }
27
28 /**
29 * Wrapping the title in a link, if applicable.
30 *
31 * @param string $title Title, (must be ready for output, that means it must be htmlspecialchars()'ed).
32 * @param array $v The record
33 * @param boolean $ext_pArrPages (Ignore)
34 * @return string Wrapping title string.
35 * @todo Define visibility
36 */
37 public function wrapTitle($title, $v, $ext_pArrPages = '') {
38 if ($this->ext_isLinkable($v['doktype'], $v['uid'])) {
39 $aOnClick = 'return link_typo3Page(\'' . $v['uid'] . '\');';
40 return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
41 } else {
42 return '<span style="color: #666666;">' . $title . '</span>';
43 }
44 }
45
46 /**
47 * Create the page navigation tree in HTML
48 *
49 * @param array $treeArr Tree array
50 * @return string HTML output.
51 * @todo Define visibility
52 */
53 public function printTree($treeArr = '') {
54 $titleLen = intval($GLOBALS['BE_USER']->uc['titleLen']);
55 if (!is_array($treeArr)) {
56 $treeArr = $this->tree;
57 }
58 $out = '';
59 $c = 0;
60 foreach ($treeArr as $k => $v) {
61 $c++;
62 $bgColorClass = ($c + 1) % 2 ? 'bgColor' : 'bgColor-10';
63 if ($GLOBALS['SOBE']->browser->curUrlInfo['act'] == 'page' && $GLOBALS['SOBE']->browser->curUrlInfo['pageid'] == $v['row']['uid'] && $GLOBALS['SOBE']->browser->curUrlInfo['pageid']) {
64 $arrCol = '<td><img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_right.gif', 'width="5" height="9"') . ' class="c-blinkArrowR" alt="" /></td>';
65 $bgColorClass = 'bgColor4';
66 } else {
67 $arrCol = '<td></td>';
68 }
69 $aOnClick = 'return jumpToUrl(\'' . $this->thisScript . '?act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandPage=' . $v['row']['uid'] . '\');';
70 $cEbullet = $this->ext_isLinkable($v['row']['doktype'], $v['row']['uid']) ? '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '"><img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/ol/arrowbullet.gif', 'width="18" height="16"') . ' alt="" /></a>' : '';
71 $out .= '
72 <tr class="' . $bgColorClass . '">
73 <td nowrap="nowrap"' . ($v['row']['_CSSCLASS'] ? ' class="' . $v['row']['_CSSCLASS'] . '"' : '') . '>' . $v['HTML'] . $this->wrapTitle($this->getTitleStr($v['row'], $titleLen), $v['row'], $this->ext_pArrPages) . '</td>' . $arrCol . '<td>' . $cEbullet . '</td>
74 </tr>';
75 }
76 $out = '
77
78
79 <!--
80 Navigation Page Tree:
81 -->
82 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
83 ' . $out . '
84 </table>';
85 return $out;
86 }
87
88 /**
89 * Returns TRUE if a doktype can be linked.
90 *
91 * @param integer $doktype Doktype value to test
92 * @param integer $uid uid to test.
93 * @return boolean
94 * @todo Define visibility
95 */
96 public function ext_isLinkable($doktype, $uid) {
97 if ($uid && $doktype < 199) {
98 return TRUE;
99 }
100 }
101
102 /**
103 * Wrap the plus/minus icon in a link
104 *
105 * @param string $icon HTML string to wrap, probably an image tag.
106 * @param string $cmd Command for 'PM' get var
107 * @param boolean $bMark If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
108 * @return string Link-wrapped input string
109 * @todo Define visibility
110 */
111 public function PM_ATagWrap($icon, $cmd, $bMark = '') {
112 if ($bMark) {
113 $anchor = '#' . $bMark;
114 $name = ' name="' . $bMark . '"';
115 }
116 $aOnClick = 'return jumpToUrl(\'' . $this->thisScript . '?PM=' . $cmd . '\',\'' . $anchor . '\');';
117 return '<a href="#"' . $name . ' onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>';
118 }
119
120 /**
121 * Wrapping the image tag, $icon, for the row, $row
122 *
123 * @param string $icon The image tag for the icon
124 * @param array $row The row for the current element
125 * @return string The processed icon input value.
126 * @todo Define visibility
127 */
128 public function wrapIcon($icon, $row) {
129 $content = $this->addTagAttributes($icon, ' title="id=' . $row['uid'] . '"');
130 if ($this->ext_showPageId) {
131 $content .= '[' . $row['uid'] . ']&nbsp;';
132 }
133 return $content;
134 }
135
136 }
137
138 /**
139 * Page tree for the RTE - totally the same, no changes needed. (Just for the sake of beauty - or confusion... :-)
140 *
141 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
142 */
143 class rtePageTree extends localPageTree {
144
145
146 }
147
148 /**
149 * For TBE record browser
150 *
151 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
152 */
153 class TBE_PageTree extends localPageTree {
154
155 /**
156 * Returns TRUE if a doktype can be linked (which is always the case here).
157 *
158 * @param integer $doktype Doktype value to test
159 * @param integer $uid uid to test.
160 * @return boolean
161 * @todo Define visibility
162 */
163 public function ext_isLinkable($doktype, $uid) {
164 return TRUE;
165 }
166
167 /**
168 * Wrapping the title in a link, if applicable.
169 *
170 * @param string $title Title, ready for output.
171 * @param array $v The record
172 * @param boolean $ext_pArrPages If set, pages clicked will return immediately, otherwise reload page.
173 * @return string Wrapping title string.
174 * @todo Define visibility
175 */
176 public function wrapTitle($title, $v, $ext_pArrPages) {
177 if ($ext_pArrPages) {
178 $ficon = \TYPO3\CMS\Backend\Utility\IconUtility::getIcon('pages', $v);
179 $onClick = 'return insertElement(\'pages\', \'' . $v['uid'] . '\', \'db\', ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($v['title']) . ', \'\', \'\', \'' . $ficon . '\',\'\',1);';
180 } else {
181 $onClick = htmlspecialchars('return jumpToUrl(\'' . $this->thisScript . '?act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandPage=' . $v['uid'] . '\');');
182 }
183 return '<a href="#" onclick="' . $onClick . '">' . $title . '</a>';
184 }
185
186 }
187
188 /**
189 * Base extension class which generates the folder tree.
190 * Used directly by the RTE.
191 * also used for the linkpicker on files
192 *
193 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
194 */
195 class localFolderTree extends \TYPO3\CMS\Backend\Tree\View\FolderTreeView {
196
197 /**
198 * @todo Define visibility
199 */
200 public $ext_IconMode = 1;
201
202 /**
203 * Initializes the script path
204 *
205 * @todo Define visibility
206 */
207 public function __construct() {
208 $this->thisScript = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('SCRIPT_NAME');
209 parent::__construct();
210 }
211
212 /**
213 * Wrapping the title in a link, if applicable.
214 *
215 * @param string $title Title, ready for output.
216 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject The "record
217 * @return string Wrapping title string.
218 * @todo Define visibility
219 */
220 public function wrapTitle($title, \TYPO3\CMS\Core\Resource\Folder $folderObject) {
221 if ($this->ext_isLinkable($folderObject)) {
222 $aOnClick = 'return jumpToUrl(\'' . $this->thisScript . '?act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier()) . '\');';
223 return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
224 } else {
225 return '<span class="typo3-dimmed">' . $title . '</span>';
226 }
227 }
228
229 /**
230 * Returns TRUE if the input "record" contains a folder which can be linked.
231 *
232 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject Object with information about the folder element. Contains keys like title, uid, path, _title
233 * @return boolean TRUE is returned if the path is found in the web-part of the server and is NOT a recycler or temp folder
234 * @todo Define visibility
235 */
236 public function ext_isLinkable(\TYPO3\CMS\Core\Resource\Folder $folderObject) {
237 if (!$folderObject->getStorage()->isPublic() || strstr($folderObject->getIdentifier(), '_recycler_') || strstr($folderObject->getIdentifier(), '_temp_')) {
238 return FALSE;
239 } else {
240 return TRUE;
241 }
242 }
243
244 /**
245 * Wrap the plus/minus icon in a link
246 *
247 * @param string $icon HTML string to wrap, probably an image tag.
248 * @param string $cmd Command for 'PM' get var
249 * @param boolean $bMark If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
250 * @return string Link-wrapped input string
251 * @access private
252 * @todo Define visibility
253 */
254 public function PM_ATagWrap($icon, $cmd, $bMark = '') {
255 if ($bMark) {
256 $anchor = '#' . $bMark;
257 $name = ' name="' . $bMark . '"';
258 }
259 $aOnClick = 'return jumpToUrl(\'' . $this->thisScript . '?PM=' . $cmd . '\',\'' . $anchor . '\');';
260 return '<a href="#"' . $name . ' onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>';
261 }
262
263 }
264
265 /**
266 * Folder tree for the RTE - totally the same, no changes needed. (Just for the sake of beauty - or confusion... :-)
267 *
268 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
269 */
270 class rteFolderTree extends localFolderTree {
271
272
273 }
274
275 /**
276 * For TBE File Browser
277 *
278 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
279 */
280 class TBE_FolderTree extends localFolderTree {
281
282 // If file-drag mode is set, temp and recycler folders are filtered out.
283 /**
284 * @todo Define visibility
285 */
286 public $ext_noTempRecyclerDirs = 0;
287
288 /**
289 * Returns TRUE if the input "record" contains a folder which can be linked.
290 *
291 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject object with information about the folder element. Contains keys like title, uid, path, _title
292 * @return boolean TRUE is returned if the path is NOT a recycler or temp folder AND if ->ext_noTempRecyclerDirs is not set.
293 * @todo Define visibility
294 */
295 public function ext_isLinkable($folderObject) {
296 if ($this->ext_noTempRecyclerDirs && (substr($folderObject->getIdentifier(), -7) == '_temp_/' || substr($folderObject->getIdentifier(), -11) == '_recycler_/')) {
297 return FALSE;
298 } else {
299 return TRUE;
300 }
301 }
302
303 /**
304 * Wrapping the title in a link, if applicable.
305 *
306 * @param string $title Title, ready for output.
307 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject The folderObject 'record'
308 * @return string Wrapping title string.
309 * @todo Define visibility
310 */
311 public function wrapTitle($title, $folderObject) {
312 if ($this->ext_isLinkable($folderObject)) {
313 $aOnClick = 'return jumpToUrl(\'' . $this->thisScript . '?act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier()) . '\');';
314 return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
315 } else {
316 return '<span class="typo3-dimmed">' . $title . '</span>';
317 }
318 }
319 }
320
321 ?>