|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the TYPO3 CMS project. |
|
5
|
|
|
* |
|
6
|
|
|
* It is free software; you can redistribute it and/or modify it under |
|
7
|
|
|
* the terms of the GNU General Public License, either version 2 |
|
8
|
|
|
* of the License, or any later version. |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please read the |
|
11
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
12
|
|
|
* |
|
13
|
|
|
* The TYPO3 project - inspiring people to share! |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace TYPO3\CMS\Backend\Tree\View; |
|
17
|
|
|
|
|
18
|
|
|
use TYPO3\CMS\Backend\Utility\BackendUtility; |
|
19
|
|
|
use TYPO3\CMS\Core\Exception\SiteNotFoundException; |
|
20
|
|
|
use TYPO3\CMS\Core\Site\SiteFinder; |
|
21
|
|
|
use TYPO3\CMS\Core\Type\Bitmask\Permission; |
|
22
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Generate a page-tree, browsable. |
|
26
|
|
|
*/ |
|
27
|
|
|
class BrowseTreeView extends AbstractTreeView |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* override to use this table |
|
31
|
|
|
* @var string |
|
32
|
|
|
*/ |
|
33
|
|
|
public $table = 'pages'; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Initialize, setting what is necessary for browsing pages. |
|
37
|
|
|
* Using the current user. |
|
38
|
|
|
* |
|
39
|
|
|
* @param string $clause Additional clause for selecting pages. |
|
40
|
|
|
* @param string $orderByFields record ORDER BY field |
|
41
|
|
|
*/ |
|
42
|
|
|
public function init($clause = '', $orderByFields = '') |
|
43
|
|
|
{ |
|
44
|
|
|
$backendUser = $this->getBackendUser(); |
|
45
|
|
|
// This will hide records from display - it has nothing to do with user rights!! |
|
46
|
|
|
$clauseExcludePidList = ''; |
|
47
|
|
|
$pidList = $backendUser->getTSConfig()['options.']['hideRecords.']['pages'] ?? ''; |
|
48
|
|
|
if (!empty($pidList)) { |
|
49
|
|
|
if ($pidList = implode(',', GeneralUtility::intExplode(',', $pidList))) { |
|
50
|
|
|
$clauseExcludePidList = ' AND pages.uid NOT IN (' . $pidList . ')'; |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
// This is very important for making trees of pages: Filtering out deleted pages, pages with no access to and sorting them correctly: |
|
54
|
|
|
parent::init(' AND deleted=0 AND sys_language_uid=0 AND ' . $backendUser->getPagePermsClause(Permission::PAGE_SHOW) . ' ' . $clause . $clauseExcludePidList, 'sorting'); |
|
55
|
|
|
$this->title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']; |
|
56
|
|
|
$this->MOUNTS = $backendUser->returnWebmounts(); |
|
57
|
|
|
if ($pidList) { |
|
58
|
|
|
// Remove mountpoint if explicitly set in options.hideRecords.pages (see above) |
|
59
|
|
|
$hideList = explode(',', $pidList); |
|
60
|
|
|
$this->MOUNTS = array_diff($this->MOUNTS, $hideList); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Creates title attribute content for pages. |
|
66
|
|
|
* Uses API function in \TYPO3\CMS\Backend\Utility\BackendUtility which will retrieve lots of useful information for pages. |
|
67
|
|
|
* |
|
68
|
|
|
* @param array $row The table row. |
|
69
|
|
|
* @return string |
|
70
|
|
|
*/ |
|
71
|
|
|
public function getTitleAttrib($row) |
|
72
|
|
|
{ |
|
73
|
|
|
return BackendUtility::titleAttribForPages($row, '1=1 ' . $this->clause, false); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Returns the title for the input record. If blank, a "no title" label (localized) will be returned. |
|
78
|
|
|
* Do NOT htmlspecialchar the string from this function - has already been done. |
|
79
|
|
|
* |
|
80
|
|
|
* @param array $row The input row array (where the key "title" is used for the title) |
|
81
|
|
|
* @param int $titleLen Title length (30) |
|
82
|
|
|
* @return string The title. |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getTitleStr($row, $titleLen = 30) |
|
85
|
|
|
{ |
|
86
|
|
|
$title = parent::getTitleStr($row, $titleLen); |
|
87
|
|
|
if (!empty($row['is_siteroot']) |
|
88
|
|
|
&& $this->getBackendUser()->getTSConfig()['options.']['pageTree.']['showDomainNameWithTitle'] ?? false |
|
89
|
|
|
) { |
|
90
|
|
|
$pageId = (int)$row['uid']; |
|
91
|
|
|
$siteFinder = GeneralUtility::makeInstance(SiteFinder::class); |
|
92
|
|
|
try { |
|
93
|
|
|
$site = $siteFinder->getSiteByRootPageId($pageId); |
|
94
|
|
|
$title .= ' [' . (string)$site->getBase() . ']'; |
|
95
|
|
|
} catch (SiteNotFoundException $e) { |
|
96
|
|
|
// No site found |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
return $title; |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|