2 /***************************************************************
5 * (c) 1999-2009 Kasper Skaarhoj (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.
31 * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
33 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
34 * @coauthor René Fritz <r.fritz@colorcube.de>
37 * [CLASS/FUNCTION INDEX of SCRIPT]
41 * 74: class t3lib_browseTree extends t3lib_treeView
42 * 83: function init($clause='')
43 * 116: function getTitleAttrib($row)
44 * 128: function wrapIcon($icon,$row)
45 * 150: function getTitleStr($row,$titleLen=30)
48 * (This index is automatically created/updated by the extension "extdeveval")
65 * Extension class for the t3lib_treeView class, specially made for browsing pages
67 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
68 * @coauthor René Fritz <r.fritz@colorcube.de>
69 * @see t3lib_treeView, t3lib_pageTree
73 class t3lib_browseTree
extends t3lib_treeView
{
76 * Initialize, setting what is necessary for browsing pages.
77 * Using the current user.
79 * @param string Additional clause for selecting pages.
82 function init($clause='') {
84 // this will hide records from display - it has nothing todo with user rights!!
85 $clauseExludePidList = '';
86 if ($pidList = $GLOBALS['BE_USER']->getTSConfigVal('options.hideRecords.pages')) {
87 if ($pidList = $GLOBALS['TYPO3_DB']->cleanIntList($pidList)) {
88 $clauseExludePidList = ' AND pages.uid NOT IN ('.$pidList.')';
92 // This is very important for making trees of pages: Filtering out deleted pages, pages with no access to and sorting them correctly:
93 parent
::init(' AND '.$GLOBALS['BE_USER']->getPagePermsClause(1).' '.$clause.$clauseExludePidList, 'sorting');
95 $this->table
= 'pages';
96 $this->setTreeName('browsePages');
97 $this->domIdPrefix
= 'pages';
99 $this->title
= $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
100 $this->MOUNTS
= $GLOBALS['WEBMOUNTS'];
103 // Remove mountpoint if explicitely set in options.hideRecords.pages (see above)
104 $hideList = explode(',',$pidList);
105 $this->MOUNTS
= array_diff($this->MOUNTS
,$hideList);
108 $this->fieldArray
= array_merge($this->fieldArray
,array('doktype','php_tree_stop','t3ver_id','t3ver_state','t3ver_wsid','t3ver_swapmode','t3ver_state','t3ver_move_id'));
109 if (t3lib_extMgm
::isLoaded('cms')) {
110 $this->fieldArray
= array_merge(
112 array('hidden', 'starttime', 'endtime', 'fe_group', 'module', 'extendToSubpages', 'is_siteroot', 'nav_hide')
118 * Creates title attribute content for pages.
119 * Uses API function in t3lib_BEfunc which will retrieve lots of useful information for pages.
121 * @param array The table row.
124 function getTitleAttrib($row) {
125 return t3lib_BEfunc
::titleAttribForPages($row,'1=1 '.$this->clause
,0);
129 * Wrapping the image tag, $icon, for the row, $row (except for mount points)
131 * @param string The image tag for the icon
132 * @param array The row for the current element
133 * @return string The processed icon input value.
136 function wrapIcon($icon,$row) {
137 // Add title attribute to input icon tag
138 $theIcon = $this->addTagAttributes($icon,($this->titleAttrib ?
$this->titleAttrib
.'="'.$this->getTitleAttrib($row).'"' : ''));
140 // Wrap icon in click-menu link.
141 if (!$this->ext_IconMode
) {
142 $theIcon = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon($theIcon,$this->treeName
,$this->getId($row),0);
143 } elseif (!strcmp($this->ext_IconMode
,'titlelink')) {
144 $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->domIdPrefix
.$this->getId($row).'\','.$this->bank
.');';
145 $theIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$theIcon.'</a>';
151 * Returns the title for the input record. If blank, a "no title" label (localized) will be returned.
152 * Do NOT htmlspecialchar the string from this function - has already been done.
154 * @param array The input row array (where the key "title" is used for the title)
155 * @param integer Title length (30)
156 * @return string The title.
158 function getTitleStr($row,$titleLen=30) {
159 // get the basic title from the parent implementation in t3lib_treeview
160 $title = parent
::getTitleStr($row,$titleLen);
161 if (isset($row['is_siteroot']) && $row['is_siteroot'] != 0 && $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showDomainNameWithTitle')) {
162 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('domainName,sorting', 'sys_domain',
163 'pid=' . $GLOBALS['TYPO3_DB']->quoteStr($row['uid'], 'sys_domain'), '', 'sorting', 1);
164 if (is_array($rows) && count($rows) > 0) {
165 $title = sprintf('%s [%s]', $title, $rows[0]['domainName']);
172 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_browsetree.php']) {
173 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_browsetree.php']);