class.t3lib_browsetree.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2010 Kasper Skaarhoj (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 8145 2010-07-09 07:34:38Z steffenk $
00031  * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
00032  *
00033  * @author  Kasper Skaarhoj <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 
00055 
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 /**
00065  * Extension class for the t3lib_treeView class, specially made for browsing pages
00066  *
00067  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00068  * @coauthor    Ren� Fritz <r.fritz@colorcube.de>
00069  * @see t3lib_treeView, t3lib_pageTree
00070  * @package TYPO3
00071  * @subpackage t3lib
00072  */
00073 class t3lib_browseTree extends t3lib_treeView {
00074 
00075     /**
00076      * Initialize, setting what is necessary for browsing pages.
00077      * Using the current user.
00078      *
00079      * @param   string      Additional clause for selecting pages.
00080      * @return  void
00081      */
00082     function init($clause='')   {
00083 
00084             // this will hide records from display - it has nothing todo with user rights!!
00085         $clauseExludePidList = '';
00086         if ($pidList = $GLOBALS['BE_USER']->getTSConfigVal('options.hideRecords.pages')) {
00087             if ($pidList = $GLOBALS['TYPO3_DB']->cleanIntList($pidList)) {
00088                 $clauseExludePidList = ' AND pages.uid NOT IN ('.$pidList.')';
00089             }
00090         }
00091 
00092             // This is very important for making trees of pages: Filtering out deleted pages, pages with no access to and sorting them correctly:
00093         parent::init(' AND '.$GLOBALS['BE_USER']->getPagePermsClause(1).' '.$clause.$clauseExludePidList, 'sorting');
00094 
00095         $this->table = 'pages';
00096         $this->setTreeName('browsePages');
00097         $this->domIdPrefix = 'pages';
00098         $this->iconName = '';
00099         $this->title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
00100         $this->MOUNTS = $GLOBALS['WEBMOUNTS'];
00101 
00102         if ($pidList)   {
00103                 // Remove mountpoint if explicitely set in options.hideRecords.pages (see above)
00104             $hideList = explode(',',$pidList);
00105             $this->MOUNTS = array_diff($this->MOUNTS,$hideList);
00106         }
00107 
00108         $this->fieldArray = array_merge($this->fieldArray,array('doktype','php_tree_stop','t3ver_id','t3ver_state','t3ver_wsid','t3ver_swapmode','t3ver_state','t3ver_move_id'));
00109         if (t3lib_extMgm::isLoaded('cms'))  {
00110             $this->fieldArray = array_merge(
00111                 $this->fieldArray,
00112                 array('hidden', 'starttime', 'endtime', 'fe_group', 'module', 'extendToSubpages', 'is_siteroot', 'nav_hide')
00113             );
00114         }
00115     }
00116 
00117     /**
00118      * Creates title attribute content for pages.
00119      * Uses API function in t3lib_BEfunc which will retrieve lots of useful information for pages.
00120      *
00121      * @param   array       The table row.
00122      * @return  string
00123      */
00124     function getTitleAttrib($row) {
00125         return t3lib_BEfunc::titleAttribForPages($row,'1=1 '.$this->clause,0);
00126     }
00127 
00128     /**
00129      * Wrapping the image tag, $icon, for the row, $row (except for mount points)
00130      *
00131      * @param   string      The image tag for the icon
00132      * @param   array       The row for the current element
00133      * @return  string      The processed icon input value.
00134      * @access private
00135      */
00136     function wrapIcon($icon,$row)   {
00137             // Add title attribute to input icon tag
00138         $theIcon = $this->addTagAttributes($icon,($this->titleAttrib ? $this->titleAttrib.'="'.$this->getTitleAttrib($row).'"' : ''));
00139 
00140             // Wrap icon in click-menu link.
00141         if (!$this->ext_IconMode)   {
00142             $theIcon = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon($theIcon,$this->treeName,$this->getId($row),0);
00143         } elseif (!strcmp($this->ext_IconMode,'titlelink')) {
00144             $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->domIdPrefix.$this->getId($row).'\','.$this->bank.');';
00145             $theIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$theIcon.'</a>';
00146         }
00147         return $theIcon;
00148     }
00149 
00150     /**
00151      * Returns the title for the input record. If blank, a "no title" label (localized) will be returned.
00152      * Do NOT htmlspecialchar the string from this function - has already been done.
00153      *
00154      * @param   array       The input row array (where the key "title" is used for the title)
00155      * @param   integer     Title length (30)
00156      * @return  string      The title.
00157      */
00158     function getTitleStr($row,$titleLen=30) {
00159             // get the basic title from the parent implementation in t3lib_treeview
00160         $title = parent::getTitleStr($row,$titleLen);
00161         if (isset($row['is_siteroot']) && $row['is_siteroot'] != 0 && $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showDomainNameWithTitle')) {
00162             $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('domainName,sorting', 'sys_domain',
00163                         'pid=' . $GLOBALS['TYPO3_DB']->quoteStr($row['uid'], 'sys_domain'), '', 'sorting', 1);
00164             if (is_array($rows) && count($rows) > 0) {
00165                 $title = sprintf('%s [%s]', $title, $rows[0]['domainName']);
00166             }
00167         }
00168         return $title;
00169     }
00170 
00171     /**
00172      * Adds a red "+" to the input string, $str, if the field "php_tree_stop" in the $row (pages) is set
00173      *
00174      * @param   string      Input string, like a page title for the tree
00175      * @param   array       record row with "php_tree_stop" field
00176      * @return  string      Modified string
00177      * @access private
00178      */
00179     function wrapStop($str, $row)   {
00180         if ($row['php_tree_stop']) {
00181             $str .= '<span class="typo3-red">
00182                                 <a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => $row['uid']))).'" class="typo3-red">+</a>
00183                             </span>';
00184         }
00185         return $str;
00186     }
00187 }
00188 
00189 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_browsetree.php'])    {
00190     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_browsetree.php']);
00191 }
00192 
00193 ?>

Generated on Sat Jul 24 04:17:16 2010 for TYPO3 API by  doxygen 1.4.7