TYPO3 API  SVNRelease
class.t3lib_browsetree.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003  *  Copyright notice
00004  *
00005  *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
00006  *  All rights reserved
00007  *
00008  *  This script is part of the TYPO3 project. The TYPO3 project is
00009  *  free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  The GNU General Public License can be found at
00015  *  http://www.gnu.org/copyleft/gpl.html.
00016  *  A copy is found in the textfile GPL.txt and important notices to the license
00017  *  from the author is found in LICENSE.txt distributed with these scripts.
00018  *
00019  *
00020  *  This script is distributed in the hope that it will be useful,
00021  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *  GNU General Public License for more details.
00024  *
00025  *  This copyright notice MUST APPEAR in all copies of the script!
00026  ***************************************************************/
00027 /**
00028  * Generate a page-tree, browsable.
00029  *
00030  * $Id: class.t3lib_browsetree.php 10121 2011-01-18 20:15:30Z ohader $
00031  * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
00032  *
00033  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00034  * @coauthor    René Fritz <r.fritz@colorcube.de>
00035  */
00036 /**
00037  * [CLASS/FUNCTION INDEX of SCRIPT]
00038  *
00039  *
00040  *
00041  *   74: class t3lib_browseTree extends t3lib_treeView
00042  *   83:     function init($clause='')
00043  *  116:     function getTitleAttrib($row)
00044  *  128:     function wrapIcon($icon,$row)
00045  *  150:     function getTitleStr($row,$titleLen=30)
00046  *
00047  * TOTAL FUNCTIONS: 4
00048  * (This index is automatically created/updated by the extension "extdeveval")
00049  *
00050  */
00051 
00052 
00053 /**
00054  * Extension class for the t3lib_treeView class, specially made for browsing pages
00055  *
00056  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00057  * @coauthor    René Fritz <r.fritz@colorcube.de>
00058  * @see t3lib_treeView, t3lib_pageTree
00059  * @package TYPO3
00060  * @subpackage t3lib
00061  */
00062 class t3lib_browseTree extends t3lib_treeView {
00063 
00064     /**
00065      * Initialize, setting what is necessary for browsing pages.
00066      * Using the current user.
00067      *
00068      * @param   string      Additional clause for selecting pages.
00069      * @return  void
00070      */
00071     function init($clause = '') {
00072 
00073             // this will hide records from display - it has nothing todo with user rights!!
00074         $clauseExludePidList = '';
00075         if ($pidList = $GLOBALS['BE_USER']->getTSConfigVal('options.hideRecords.pages')) {
00076             if ($pidList = $GLOBALS['TYPO3_DB']->cleanIntList($pidList)) {
00077                 $clauseExludePidList = ' AND pages.uid NOT IN (' . $pidList . ')';
00078             }
00079         }
00080 
00081             // This is very important for making trees of pages: Filtering out deleted pages, pages with no access to and sorting them correctly:
00082         parent::init(' AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1) . ' ' . $clause . $clauseExludePidList, 'sorting');
00083 
00084         $this->table = 'pages';
00085         $this->setTreeName('browsePages');
00086         $this->domIdPrefix = 'pages';
00087         $this->iconName = '';
00088         $this->title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
00089         $this->MOUNTS = $GLOBALS['WEBMOUNTS'];
00090 
00091         if ($pidList) {
00092                 // Remove mountpoint if explicitely set in options.hideRecords.pages (see above)
00093             $hideList = explode(',', $pidList);
00094             $this->MOUNTS = array_diff($this->MOUNTS, $hideList);
00095         }
00096 
00097         $this->fieldArray = array_merge(
00098             $this->fieldArray,
00099             array('doktype', 'php_tree_stop', 't3ver_id', 't3ver_state', 't3ver_wsid', 't3ver_swapmode', 't3ver_state', 't3ver_move_id')
00100         );
00101         if (t3lib_extMgm::isLoaded('cms')) {
00102             $this->fieldArray = array_merge(
00103                 $this->fieldArray,
00104                 array('hidden', 'starttime', 'endtime', 'fe_group', 'module', 'extendToSubpages', 'is_siteroot', 'nav_hide')
00105             );
00106         }
00107     }
00108 
00109     /**
00110      * Creates title attribute content for pages.
00111      * Uses API function in t3lib_BEfunc which will retrieve lots of useful information for pages.
00112      *
00113      * @param   array       The table row.
00114      * @return  string
00115      */
00116     function getTitleAttrib($row) {
00117         return t3lib_BEfunc::titleAttribForPages($row, '1=1 ' . $this->clause, 0);
00118     }
00119 
00120     /**
00121      * Wrapping the image tag, $icon, for the row, $row (except for mount points)
00122      *
00123      * @param   string      The image tag for the icon
00124      * @param   array       The row for the current element
00125      * @return  string      The processed icon input value.
00126      * @access private
00127      */
00128     function wrapIcon($icon, $row) {
00129             // Add title attribute to input icon tag
00130         $theIcon = $this->addTagAttributes($icon, ($this->titleAttrib ? $this->titleAttrib . '="' . $this->getTitleAttrib($row) . '"' : ''));
00131 
00132             // Wrap icon in click-menu link.
00133         if (!$this->ext_IconMode) {
00134             $theIcon = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon($theIcon, $this->treeName, $this->getId($row), 0);
00135         } elseif (!strcmp($this->ext_IconMode, 'titlelink')) {
00136             $aOnClick = 'return jumpTo(\'' . $this->getJumpToParam($row) . '\',this,\'' . $this->domIdPrefix . $this->getId($row) . '\',' . $this->bank . ');';
00137             $theIcon = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $theIcon . '</a>';
00138         }
00139         return $theIcon;
00140     }
00141 
00142     /**
00143      * Returns the title for the input record. If blank, a "no title" label (localized) will be returned.
00144      * Do NOT htmlspecialchar the string from this function - has already been done.
00145      *
00146      * @param   array       The input row array (where the key "title" is used for the title)
00147      * @param   integer     Title length (30)
00148      * @return  string      The title.
00149      */
00150     function getTitleStr($row, $titleLen = 30) {
00151             // get the basic title from the parent implementation in t3lib_treeview
00152         $title = parent::getTitleStr($row, $titleLen);
00153         if (isset($row['is_siteroot']) && $row['is_siteroot'] != 0 && $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showDomainNameWithTitle')) {
00154             $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('domainName,sorting', 'sys_domain',
00155                     'pid=' . $GLOBALS['TYPO3_DB']->quoteStr($row['uid'] . t3lib_BEfunc::deleteClause('sys_domain') . t3lib_BEfunc::BEenableFields('sys_domain'), 'sys_domain'), '', 'sorting', 1);
00156             if (is_array($rows) && count($rows) > 0) {
00157                 $title = sprintf('%s [%s]', $title, htmlspecialchars($rows[0]['domainName']));
00158             }
00159         }
00160         return $title;
00161     }
00162 
00163     /**
00164      * Adds a red "+" to the input string, $str, if the field "php_tree_stop" in the $row (pages) is set
00165      *
00166      * @param   string      Input string, like a page title for the tree
00167      * @param   array       record row with "php_tree_stop" field
00168      * @return  string      Modified string
00169      * @access private
00170      */
00171     function wrapStop($str, $row) {
00172         if ($row['php_tree_stop']) {
00173             $str .= '<span class="typo3-red">
00174                                 <a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => $row['uid']))) . '" class="typo3-red">+</a>
00175                             </span>';
00176         }
00177         return $str;
00178     }
00179 }
00180 
00181 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_browsetree.php'])) {
00182     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_browsetree.php']);
00183 }
00184 
00185 ?>