[CLEANUP] Tree Classes
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Tree / View / BrowseTreeView.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 use TYPO3\CMS\Backend\Utility\BackendUtility;
18
19 /**
20 * Generate a page-tree, browsable.
21 *
22 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
23 * @coauthor René Fritz <r.fritz@colorcube.de>
24 */
25 class BrowseTreeView extends AbstractTreeView {
26
27 /**
28 * @var array
29 */
30 public $fieldArray = array(
31 'uid',
32 'pid',
33 'title',
34 'doktype',
35 'nav_title',
36 'mount_pid',
37 'php_tree_stop',
38 't3ver_id',
39 't3ver_state',
40 'hidden',
41 'starttime',
42 'endtime',
43 'fe_group',
44 'module',
45 'extendToSubpages',
46 'nav_hide',
47 't3ver_wsid',
48 't3ver_move_id',
49 'is_siteroot'
50 );
51
52 /**
53 * override to use this treeName
54 * @var string
55 */
56 public $treeName = 'browsePages';
57
58 /**
59 * override to use this table
60 * @var string
61 */
62 public $table = 'pages';
63
64 /**
65 * override to use this domIdPrefix
66 * @var string
67 */
68 public $domIdPrefix = 'pages';
69
70 /**
71 * Initialize, setting what is necessary for browsing pages.
72 * Using the current user.
73 *
74 * @param string $clause Additional clause for selecting pages.
75 * @param string $orderByFields record ORDER BY field
76 * @return void
77 */
78 public function init($clause = '', $orderByFields = '') {
79 // This will hide records from display - it has nothing todo with user rights!!
80 $clauseExcludePidList = '';
81 if ($pidList = $GLOBALS['BE_USER']->getTSConfigVal('options.hideRecords.pages')) {
82 if ($pidList = $GLOBALS['TYPO3_DB']->cleanIntList($pidList)) {
83 $clauseExcludePidList = ' AND pages.uid NOT IN (' . $pidList . ')';
84 }
85 }
86 // This is very important for making trees of pages: Filtering out deleted pages, pages with no access to and sorting them correctly:
87 parent::init(' AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1) . ' ' . $clause . $clauseExcludePidList, 'sorting');
88 $this->title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
89 $this->MOUNTS = $GLOBALS['BE_USER']->returnWebmounts();
90 if ($pidList) {
91 // Remove mountpoint if explicitly set in options.hideRecords.pages (see above)
92 $hideList = explode(',', $pidList);
93 $this->MOUNTS = array_diff($this->MOUNTS, $hideList);
94 }
95 }
96
97 /**
98 * Creates title attribute content for pages.
99 * Uses API function in \TYPO3\CMS\Backend\Utility\BackendUtility which will retrieve lots of useful information for pages.
100 *
101 * @param array $row The table row.
102 * @return string
103 */
104 public function getTitleAttrib($row) {
105 return BackendUtility::titleAttribForPages($row, '1=1 ' . $this->clause, 0);
106 }
107
108 /**
109 * Wrapping the image tag, $icon, for the row, $row (except for mount points)
110 *
111 * @param string $icon The image tag for the icon
112 * @param array $row The row for the current element
113 * @return string The processed icon input value.
114 * @access private
115 */
116 public function wrapIcon($icon, $row) {
117 // Add title attribute to input icon tag
118 $theIcon = $this->addTagAttributes($icon, $this->titleAttrib ? $this->titleAttrib . '="' . $this->getTitleAttrib($row) . '"' : '');
119 // Wrap icon in click-menu link.
120 if (!$this->ext_IconMode) {
121 $theIcon = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon($theIcon, $this->treeName, $this->getId($row), 0);
122 } elseif ($this->ext_IconMode === 'titlelink') {
123 $aOnClick = 'return jumpTo(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->getJumpToParam($row)) . ',this,' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->domIdPrefix . $this->getId($row)) . ',' . $this->bank . ');';
124 $theIcon = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $theIcon . '</a>';
125 }
126 return $theIcon;
127 }
128
129 /**
130 * Returns the title for the input record. If blank, a "no title" label (localized) will be returned.
131 * Do NOT htmlspecialchar the string from this function - has already been done.
132 *
133 * @param array $row The input row array (where the key "title" is used for the title)
134 * @param int $titleLen Title length (30)
135 * @return string The title.
136 */
137 public function getTitleStr($row, $titleLen = 30) {
138 $title = parent::getTitleStr($row, $titleLen);
139 if (isset($row['is_siteroot']) && $row['is_siteroot'] != 0 && $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showDomainNameWithTitle')) {
140 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('domainName,sorting', 'sys_domain', 'pid=' . $GLOBALS['TYPO3_DB']->quoteStr(($row['uid'] . BackendUtility::deleteClause('sys_domain') . BackendUtility::BEenableFields('sys_domain')), 'sys_domain'), '', 'sorting', 1);
141 if (is_array($rows) && !empty($rows)) {
142 $title = sprintf('%s [%s]', $title, htmlspecialchars($rows[0]['domainName']));
143 }
144 }
145 return $title;
146 }
147
148 }