[CLEANUP] Make use of bool/int in DocComments
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Tree / View / ElementBrowserPageTreeView.php
1 <?php
2 namespace TYPO3\CMS\Backend\Tree\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 /**
18 * Class which generates the page tree
19 *
20 * Browsable tree, used in PagePositionMaps (move elements), Element Browser and RTE (for which it will be extended)
21 * previously located inside typo3/class.browse_links.php
22 */
23 class ElementBrowserPageTreeView extends BrowseTreeView {
24
25 /**
26 * whether the page ID should be shown next to the title, activate through
27 * userTSconfig (options.pageTree.showPageIdWithTitle)
28 *
29 * @var bool
30 */
31 public $ext_showPageId = FALSE;
32
33 /**
34 * Constructor. Just calling init()
35 */
36 public function __construct() {
37 $this->determineScriptUrl();
38 $this->init();
39 $this->clause = ' AND doktype!=' . \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_RECYCLER . $this->clause;
40 }
41
42 /**
43 * Wrapping the title in a link, if applicable.
44 *
45 * @param string $title Title, (must be ready for output, that means it must be htmlspecialchars()'ed).
46 * @param array $v The record
47 * @param bool $ext_pArrPages (Ignore)
48 * @return string Wrapping title string.
49 */
50 public function wrapTitle($title, $v, $ext_pArrPages = '') {
51 if ($this->ext_isLinkable($v['doktype'], $v['uid'])) {
52 $aOnClick = 'return link_typo3Page(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($v['uid']) . ');';
53 return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
54 } else {
55 return '<span style="color: #666666;">' . $title . '</span>';
56 }
57 }
58
59 /**
60 * Create the page navigation tree in HTML
61 *
62 * @param array $treeArr Tree array
63 * @return string HTML output.
64 */
65 public function printTree($treeArr = '') {
66 $titleLen = (int)$GLOBALS['BE_USER']->uc['titleLen'];
67 if (!is_array($treeArr)) {
68 $treeArr = $this->tree;
69 }
70 $out = '';
71 $c = 0;
72 foreach ($treeArr as $k => $v) {
73 $c++;
74 $bgColorClass = ($c + 1) % 2 ? 'bgColor' : 'bgColor-10';
75 if ($GLOBALS['SOBE']->browser->curUrlInfo['act'] == 'page' && $GLOBALS['SOBE']->browser->curUrlInfo['pageid'] == $v['row']['uid'] && $GLOBALS['SOBE']->browser->curUrlInfo['pageid']) {
76 $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>';
77 $bgColorClass = 'bgColor4';
78 } else {
79 $arrCol = '<td></td>';
80 }
81 $aOnClick = 'return jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&expandPage=' . $v['row']['uid']) . ');';
82 $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>' : '';
83 $out .= '
84 <tr class="' . $bgColorClass . '">
85 <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>
86 </tr>';
87 }
88 $out = '
89
90
91 <!--
92 Navigation Page Tree:
93 -->
94 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
95 ' . $out . '
96 </table>';
97 return $out;
98 }
99
100 /**
101 * Returns TRUE if a doktype can be linked.
102 *
103 * @param int $doktype Doktype value to test
104 * @param int $uid uid to test.
105 * @return bool
106 */
107 public function ext_isLinkable($doktype, $uid) {
108 if ($uid && $doktype < 199) {
109 return TRUE;
110 }
111 }
112
113 /**
114 * Wrap the plus/minus icon in a link
115 *
116 * @param string $icon HTML string to wrap, probably an image tag.
117 * @param string $cmd Command for 'PM' get var
118 * @param bool $bMark If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
119 * @return string Link-wrapped input string
120 */
121 public function PM_ATagWrap($icon, $cmd, $bMark = '') {
122 $name = '';
123 if ($bMark) {
124 $anchor = '#' . $bMark;
125 $name = ' name=' . $bMark;
126 }
127 $aOnClick = 'return jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->getThisScript() . 'PM=' . $cmd) . ',' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($anchor) . ');';
128 return '<a href="#"' . htmlspecialchars($name) . ' onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>';
129 }
130
131 /**
132 * Wrapping the image tag, $icon, for the row, $row
133 *
134 * @param string $icon The image tag for the icon
135 * @param array $row The row for the current element
136 * @return string The processed icon input value.
137 */
138 public function wrapIcon($icon, $row) {
139 $content = $this->addTagAttributes($icon, ' title="id=' . $row['uid'] . '"');
140 if ($this->ext_showPageId) {
141 $content .= '[' . $row['uid'] . ']&nbsp;';
142 }
143 return $content;
144 }
145
146 }