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