3 * Class which generates the page tree
5 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
7 class localPageTree
extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView
{
10 * whether the page ID should be shown next to the title, activate through
11 * userTSconfig (options.pageTree.showPageIdWithTitle)
15 public $ext_showPageId = FALSE
;
18 * Constructor. Just calling init()
20 public function __construct() {
21 $this->determineScriptUrl();
23 $this->clause
= ' AND doktype!=' . \TYPO3\CMS\Frontend\Page\PageRepository
::DOKTYPE_RECYCLER
. $this->clause
;
27 * Wrapping the title in a link, if applicable.
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 bool $ext_pArrPages (Ignore)
32 * @return string Wrapping title string.
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>';
39 return '<span style="color: #666666;">' . $title . '</span>';
44 * Create the page navigation tree in HTML
46 * @param array $treeArr Tree array
47 * @return string HTML output.
49 public function printTree($treeArr = '') {
50 $titleLen = (int)$GLOBALS['BE_USER']->uc
['titleLen'];
51 if (!is_array($treeArr)) {
52 $treeArr = $this->tree
;
56 foreach ($treeArr as $k => $v) {
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';
63 $arrCol = '<td></td>';
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>' : '';
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>
78 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tree">
85 * Returns TRUE if a doktype can be linked.
87 * @param int $doktype Doktype value to test
88 * @param int $uid uid to test.
91 public function ext_isLinkable($doktype, $uid) {
92 if ($uid && $doktype < 199) {
98 * Wrap the plus/minus icon in a link
100 * @param string $icon HTML string to wrap, probably an image tag.
101 * @param string $cmd Command for 'PM' get var
102 * @param bool $bMark If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
103 * @return string Link-wrapped input string
105 public function PM_ATagWrap($icon, $cmd, $bMark = '') {
108 $anchor = '#' . $bMark;
109 $name = ' name="' . $bMark . '"';
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>';
116 * Wrapping the image tag, $icon, for the row, $row
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.
122 public function wrapIcon($icon, $row) {
123 $content = $this->addTagAttributes($icon, ' title="id=' . $row['uid'] . '"');
124 if ($this->ext_showPageId
) {
125 $content .= '[' . $row['uid'] . '] ';
133 * For TBE record browser
135 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
137 class TBE_PageTree
extends localPageTree
{
140 * Returns TRUE if a doktype can be linked (which is always the case here).
142 * @param int $doktype Doktype value to test
143 * @param int $uid uid to test.
146 public function ext_isLinkable($doktype, $uid) {
151 * Wrapping the title in a link, if applicable.
153 * @param string $title Title, ready for output.
154 * @param array $v The record
155 * @param bool $ext_pArrPages If set, pages clicked will return immediately, otherwise reload page.
156 * @return string Wrapping title string.
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);';
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']) . ');';
165 return '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' . $title . '</a>';
171 * Base extension class which generates the folder tree.
172 * Used directly by the RTE.
173 * also used for the linkpicker on files
175 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
177 class localFolderTree
extends \TYPO3\CMS\Backend\Tree\View\FolderTreeView
{
182 public $ext_IconMode = 1;
185 * Initializes the script path
187 public function __construct() {
188 $this->determineScriptUrl();
189 parent
::__construct();
193 * Wrapping the title in a link, if applicable.
195 * @param string $title Title, ready for output.
196 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject The "record
197 * @return string Wrapping title string.
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>';
204 return '<span class="typo3-dimmed">' . $title . '</span>';
209 * Returns TRUE if the input "record" contains a folder which can be linked.
211 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject Object with information about the folder element. Contains keys like title, uid, path, _title
212 * @return bool TRUE is returned if the path is found in the web-part of the server and is NOT a recycler or temp folder
214 public function ext_isLinkable(\TYPO3\CMS\Core\Resource\Folder
$folderObject) {
215 if (strstr($folderObject->getIdentifier(), '_recycler_') ||
strstr($folderObject->getIdentifier(), '_temp_')) {
223 * Wrap the plus/minus icon in a link
225 * @param string $icon HTML string to wrap, probably an image tag.
226 * @param string $cmd Command for 'PM' get var
227 * @param bool $bMark If set, the link will have a anchor point (=$bMark) and a name attribute (=$bMark)
228 * @return string Link-wrapped input string
231 public function PM_ATagWrap($icon, $cmd, $bMark = '') {
232 $name = $anchor = '';
234 $anchor = '#' . $bMark;
235 $name = ' name="' . $bMark . '"';
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>';
244 * For TBE File Browser
246 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
248 class TBE_FolderTree
extends localFolderTree
{
251 * If file-drag mode is set, temp and recycler folders are filtered out.
255 public $ext_noTempRecyclerDirs = 0;
258 * Returns TRUE if the input "record" contains a folder which can be linked.
260 * @param \TYPO3\CMS\Core\Resource\Folder $folderObject object with information about the folder element. Contains keys like title, uid, path, _title
261 * @return bool TRUE is returned if the path is NOT a recycler or temp folder AND if ->ext_noTempRecyclerDirs is not set.
263 public function ext_isLinkable($folderObject) {
264 if ($this->ext_noTempRecyclerDirs
&& (substr($folderObject->getIdentifier(), -7) == '_temp_/' ||
substr($folderObject->getIdentifier(), -11) == '_recycler_/')) {
272 * Wrapping the title in a link, if applicable.
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.
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>';
283 return '<span class="typo3-dimmed">' . $title . '</span>';