browse_links.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2008 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  * Displays the page/file tree for browsing database records or files.
00029  * Used from TCEFORMS an other elements
00030  * In other words: This is the ELEMENT BROWSER!
00031  *
00032  * $Id: browse_links.php 4433 2008-11-07 04:13:12Z flyguide $
00033  * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
00034  * XHTML compliant
00035  *
00036  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00037  */
00038 /**
00039  * [CLASS/FUNCTION INDEX of SCRIPT]
00040  *
00041  *
00042  *
00043  *   78: class SC_browse_links
00044  *   99:     function init ()
00045  *  120:     function main()
00046  *  174:     function printContent()
00047  *
00048  * TOTAL FUNCTIONS: 3
00049  * (This index is automatically created/updated by the extension "extdeveval")
00050  *
00051  */
00052 $BACK_PATH='';
00053 require ('init.php');
00054 require ('template.php');
00055 $LANG->includeLLFile('EXT:lang/locallang_browse_links.xml');
00056 
00057 require_once (PATH_typo3.'/class.browse_links.php');
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069 
00070 
00071 /**
00072  * Script class for the Element Browser window.
00073  *
00074  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00075  * @package TYPO3
00076  * @subpackage core
00077  */
00078 class SC_browse_links {
00079 
00080 
00081     /**
00082      * The mode determines the main kind of output from the element browser.
00083      * There are these options for values: rte, db, file, filedrag, wizard.
00084      * "rte" will show the link selector for the Rich Text Editor (see main_rte())
00085      * "db" will allow you to browse for pages or records in the page tree (for TCEforms, see main_db())
00086      * "file"/"filedrag" will allow you to browse for files or folders in the folder mounts (for TCEforms, main_file())
00087      * "wizard" will allow you to browse for links (like "rte") which are passed back to TCEforms (see main_rte(1))
00088      *
00089      * @see main()
00090      */
00091     var $mode;
00092 
00093     /**
00094      * holds Instance of main browse_links class
00095      * needed fo intercommunication between various classes that need access to variables via $GLOBALS['SOBE']
00096      * Not the most nice solution but introduced since we don't have another general way to return class-instances or registry for now
00097      *
00098      * @var browse_links
00099      */
00100     var $browser;
00101 
00102     /**
00103      * document template object
00104      *
00105      * @var template
00106      */
00107     var $doc;
00108 
00109     /**
00110      * not really needed but for backwards compatibility ...
00111      *
00112      * @return  void
00113      */
00114     function init ()    {
00115 
00116             // Find "mode"
00117         $this->mode = t3lib_div::_GP('mode');
00118         if (!$this->mode)   {
00119             $this->mode = 'rte';
00120         }
00121 
00122             // Creating backend template object:
00123             // this might not be needed but some classes refer to $GLOBALS['SOBE']->doc, so ...
00124         $this->doc = t3lib_div::makeInstance('template');
00125         $this->doc->backPath = $GLOBALS['BACK_PATH'];
00126     }
00127 
00128 
00129     /**
00130      * Main function, detecting the current mode of the element browser and branching out to internal methods.
00131      *
00132      * @return  void
00133      */
00134     function main() {
00135 
00136         $this->content = '';
00137 
00138             // look for alternativ mountpoints
00139         switch((string)$this->mode) {
00140             case 'rte':
00141             case 'db':
00142             case 'wizard':
00143                     // Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
00144                 $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
00145                 if ($altMountPoints) {
00146                     $GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(t3lib_div::intExplode(',', $altMountPoints)));
00147                     $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
00148                 }
00149             case 'file':
00150             case 'filedrag':
00151             case 'folder':
00152                     // Setting additional read-only browsing file mounts
00153                 $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints'));
00154                 if ($altMountPoints) {
00155                     $altMountPoints = t3lib_div::trimExplode(',', $altMountPoints);
00156                     foreach($altMountPoints as $filePathRelativeToFileadmindir) {
00157                         $GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 'readonly');
00158                     }
00159                     $GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->returnFilemounts();
00160                 }
00161                 break;
00162         }
00163 
00164 
00165             // render type by user func
00166         $browserRendered = false;
00167         if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) {
00168             foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'] as $classRef) {
00169                 $browserRenderObj = t3lib_div::getUserObj($classRef);
00170                 if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render')) {
00171                     if ($browserRenderObj->isValid($this->mode, $this)) {
00172                         $this->content.= $browserRenderObj->render($this->mode, $this);
00173                         $browserRendered = true;
00174                         break;
00175                     }
00176                 }
00177             }
00178         }
00179 
00180             // if type was not rendered use default rendering functions
00181         if(!$browserRendered) {
00182             $this->browser = t3lib_div::makeInstance('browse_links');
00183             $this->browser->init();
00184             $modData = $GLOBALS['BE_USER']->getModuleData('browse_links.php', 'ses');
00185             list($modData, $store) = $this->browser->processSessionData($modData);
00186             $GLOBALS['BE_USER']->pushModuleData('browse_links.php', $modData);
00187 
00188                 // Output the correct content according to $this->mode
00189             switch((string)$this->mode) {
00190                 case 'rte':
00191                     $this->content = $this->browser->main_rte();
00192                 break;
00193                 case 'db':
00194                     $this->content = $this->browser->main_db();
00195                 break;
00196                 case 'file':
00197                 case 'filedrag':
00198                     $this->content = $this->browser->main_file();
00199                 break;
00200                 case 'folder':
00201                     $this->content = $this->browser->main_folder();
00202                 break;
00203                 case 'wizard':
00204                     $this->content = $this->browser->main_rte(1);
00205                 break;
00206             }
00207         }
00208     }
00209 
00210     /**
00211      * Print module content
00212      *
00213      * @return  void
00214      */
00215     function printContent() {
00216         echo $this->content;
00217     }
00218 
00219 
00220 }
00221 
00222 
00223 
00224 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/browse_links.php'])  {
00225     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/browse_links.php']);
00226 }
00227 
00228 
00229 
00230 // Make instance:
00231 $SOBE = t3lib_div::makeInstance('SC_browse_links');
00232 $SOBE->init();
00233 $SOBE->main();
00234 $SOBE->printContent();
00235 
00236 ?>

Generated on Sat Jan 3 04:23:28 2009 for TYPO3 API by  doxygen 1.4.7