2 /***************************************************************
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Generate a page-tree, browsable.
30 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
32 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
33 * @coauthor René Fritz <r.fritz@colorcube.de>
38 * Extension class for the t3lib_treeView class, specially made for browsing pages
40 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
41 * @coauthor René Fritz <r.fritz@colorcube.de>
42 * @see t3lib_treeView, t3lib_pageTree
46 class t3lib_browseTree
extends t3lib_treeView
{
49 * Initialize, setting what is necessary for browsing pages.
50 * Using the current user.
52 * @param string $clause Additional clause for selecting pages.
53 * @param string $orderByFields record ORDER BY field
56 function init($clause = '', $orderByFields = '') {
58 // this will hide records from display - it has nothing todo with user rights!!
59 $clauseExludePidList = '';
60 if ($pidList = $GLOBALS['BE_USER']->getTSConfigVal('options.hideRecords.pages')) {
61 if ($pidList = $GLOBALS['TYPO3_DB']->cleanIntList($pidList)) {
62 $clauseExludePidList = ' AND pages.uid NOT IN (' . $pidList . ')';
66 // This is very important for making trees of pages: Filtering out deleted pages, pages with no access to and sorting them correctly:
67 parent
::init(' AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1) . ' ' . $clause . $clauseExludePidList, 'sorting');
69 $this->table
= 'pages';
70 $this->setTreeName('browsePages');
71 $this->domIdPrefix
= 'pages';
73 $this->title
= $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
74 $this->MOUNTS
= $GLOBALS['WEBMOUNTS'];
77 // Remove mountpoint if explicitely set in options.hideRecords.pages (see above)
78 $hideList = explode(',', $pidList);
79 $this->MOUNTS
= array_diff($this->MOUNTS
, $hideList);
82 $this->fieldArray
= array_merge(
84 array('doktype', 'php_tree_stop', 't3ver_id', 't3ver_state', 't3ver_wsid', 't3ver_swapmode', 't3ver_state', 't3ver_move_id')
86 if (t3lib_extMgm
::isLoaded('cms')) {
87 $this->fieldArray
= array_merge(
89 array('hidden', 'starttime', 'endtime', 'fe_group', 'module', 'extendToSubpages', 'is_siteroot', 'nav_hide')
95 * Creates title attribute content for pages.
96 * Uses API function in t3lib_BEfunc which will retrieve lots of useful information for pages.
98 * @param array The table row.
101 function getTitleAttrib($row) {
102 return t3lib_BEfunc
::titleAttribForPages($row, '1=1 ' . $this->clause
, 0);
106 * Wrapping the image tag, $icon, for the row, $row (except for mount points)
108 * @param string The image tag for the icon
109 * @param array The row for the current element
110 * @return string The processed icon input value.
113 function wrapIcon($icon, $row) {
114 // Add title attribute to input icon tag
115 $theIcon = $this->addTagAttributes($icon, ($this->titleAttrib ?
$this->titleAttrib
. '="' . $this->getTitleAttrib($row) . '"' : ''));
117 // Wrap icon in click-menu link.
118 if (!$this->ext_IconMode
) {
119 $theIcon = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon($theIcon, $this->treeName
, $this->getId($row), 0);
120 } elseif (!strcmp($this->ext_IconMode
, 'titlelink')) {
121 $aOnClick = 'return jumpTo(\'' . $this->getJumpToParam($row) . '\',this,\'' . $this->domIdPrefix
. $this->getId($row) . '\',' . $this->bank
. ');';
122 $theIcon = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $theIcon . '</a>';
128 * Returns the title for the input record. If blank, a "no title" label (localized) will be returned.
129 * Do NOT htmlspecialchar the string from this function - has already been done.
131 * @param array The input row array (where the key "title" is used for the title)
132 * @param integer Title length (30)
133 * @return string The title.
135 function getTitleStr($row, $titleLen = 30) {
136 // get the basic title from the parent implementation in t3lib_treeview
137 $title = parent
::getTitleStr($row, $titleLen);
138 if (isset($row['is_siteroot']) && $row['is_siteroot'] != 0 && $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showDomainNameWithTitle')) {
139 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('domainName,sorting', 'sys_domain',
140 'pid=' . $GLOBALS['TYPO3_DB']->quoteStr($row['uid'] . t3lib_BEfunc
::deleteClause('sys_domain') . t3lib_BEfunc
::BEenableFields('sys_domain'), 'sys_domain'), '', 'sorting', 1);
141 if (is_array($rows) && count($rows) > 0) {
142 $title = sprintf('%s [%s]', $title, htmlspecialchars($rows[0]['domainName']));
149 * Adds a red "+" to the input string, $str, if the field "php_tree_stop" in the $row (pages) is set
151 * @param string Input string, like a page title for the tree
152 * @param array record row with "php_tree_stop" field
153 * @return string Modified string
156 function wrapStop($str, $row) {
157 if ($row['php_tree_stop']) {
158 $str .= '<span class="typo3-red">
159 <a href="' . htmlspecialchars(t3lib_div
::linkThisScript(array('setTempDBmount' => $row['uid']))) . '" class="typo3-red">+</a>
166 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_browsetree.php'])) {
167 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_browsetree.php']);