TYPO3 API  SVNRelease
alt_db_navframe.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  * Page navigation tree for the Web module
00029  *
00030  * $Id: alt_db_navframe.php 10121 2011-01-18 20:15:30Z ohader $
00031  * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
00032  * XHTML compliant
00033  *
00034  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00035  */
00036 /**
00037  * [CLASS/FUNCTION INDEX of SCRIPT]
00038  *
00039  *
00040  *  192: class SC_alt_db_navframe
00041  *  210:     function init()
00042  *  313:     function main()
00043  *  387:     function printContent()
00044  *
00045  *              SECTION: Temporary DB mounts
00046  *  415:     function initializeTemporaryDBmount()
00047  *  449:     function settingTemporaryMountPoint($pageId)
00048  *
00049  * TOTAL FUNCTIONS: 9
00050  * (This index is automatically created/updated by the extension "extdeveval")
00051  *
00052  */
00053 
00054 
00055 $BACK_PATH = '';
00056 require_once('init.php');
00057 require('template.php');
00058 require_once('class.webpagetree.php');
00059 
00060 
00061 /**
00062  * Main script class for the page tree navigation frame
00063  *
00064  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00065  * @package TYPO3
00066  * @subpackage core
00067  */
00068 class SC_alt_db_navframe {
00069 
00070         // Internal:
00071     var $content;
00072     var $pagetree;
00073 
00074     /**
00075      * document template object
00076      *
00077      * @var template
00078      */
00079     var $doc;
00080     var $active_tempMountPoint = 0;     // Temporary mount point (record), if any
00081     var $backPath;
00082 
00083         // Internal, static: GPvar:
00084     var $currentSubScript;
00085     var $cMR;
00086     var $setTempDBmount;            // If not '' (blank) then it will clear (0) or set (>0) Temporary DB mount.
00087 
00088     var $template;                  // a static HTML template, usually in templates/alt_db_navframe.html
00089     var $hasFilterBox;              //depends on userTS-setting
00090 
00091     /**
00092      * Initialiation of the class
00093      *
00094      * @return  void
00095      */
00096     function init() {
00097         global $BE_USER,$BACK_PATH;
00098 
00099             // Setting backPath
00100         $this->backPath = $BACK_PATH;
00101 
00102             // Setting GPvars:
00103         $this->cMR = t3lib_div::_GP('cMR');
00104         $this->currentSubScript = t3lib_div::_GP('currentSubScript');
00105         $this->setTempDBmount = t3lib_div::_GP('setTempDBmount');
00106 
00107             // look for User setting
00108         $this->hasFilterBox = !$BE_USER->getTSConfigVal('options.pageTree.hideFilter');
00109 
00110             // Create page tree object:
00111         $this->pagetree = t3lib_div::makeInstance('webPageTree');
00112         $this->pagetree->ext_IconMode = $BE_USER->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
00113         $this->pagetree->ext_showPageId = $BE_USER->getTSConfigVal('options.pageTree.showPageIdWithTitle');
00114         $this->pagetree->ext_showNavTitle = $BE_USER->getTSConfigVal('options.pageTree.showNavTitle');
00115         $this->pagetree->ext_separateNotinmenuPages = $BE_USER->getTSConfigVal('options.pageTree.separateNotinmenuPages');
00116         $this->pagetree->ext_alphasortNotinmenuPages = $BE_USER->getTSConfigVal('options.pageTree.alphasortNotinmenuPages');
00117         $this->pagetree->thisScript = 'alt_db_navframe.php';
00118         $this->pagetree->addField('alias');
00119         $this->pagetree->addField('shortcut');
00120         $this->pagetree->addField('shortcut_mode');
00121         $this->pagetree->addField('mount_pid');
00122         $this->pagetree->addField('mount_pid_ol');
00123         $this->pagetree->addField('nav_hide');
00124         $this->pagetree->addField('nav_title');
00125         $this->pagetree->addField('url');
00126 
00127             // Temporary DB mounts:
00128         $this->initializeTemporaryDBmount();
00129     }
00130 
00131 
00132     /**
00133      * initialization for the visual parts of the class
00134      * Use template rendering only if this is a non-AJAX call
00135      *
00136      * @return  void
00137      */
00138     public function initPage() {
00139         global $BE_USER;
00140 
00141             // Setting highlight mode:
00142         $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight');
00143 
00144             // If highlighting is active, define the CSS class for the active item depending on the workspace
00145         if ($this->doHighlight) {
00146             $hlClass = ($BE_USER->workspace === 0 ? 'active' : 'active active-ws wsver'.$BE_USER->workspace);
00147         }
00148 
00149             // Create template object:
00150         $this->doc = t3lib_div::makeInstance('template');
00151         $this->doc->backPath = $BACK_PATH;
00152         $this->doc->setModuleTemplate('templates/alt_db_navframe.html');
00153         $this->doc->showFlashMessages = FALSE;
00154 
00155             // get HTML-Template
00156 
00157 
00158             // Adding javascript code for AJAX (prototype), drag&drop and the pagetree as well as the click menu code
00159         $this->doc->getDragDropCode('pages');
00160         $this->doc->getContextMenuCode();
00161         $this->doc->getPageRenderer()->loadScriptaculous('effects');
00162         $this->doc->getPageRenderer()->loadExtJS();
00163 
00164         if ($this->hasFilterBox) {
00165             $this->doc->getPageRenderer()->addJsFile('js/pagetreefiltermenu.js');
00166         }
00167 
00168         $this->doc->JScode .= $this->doc->wrapScriptTags(
00169         ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
00170         // setting prefs for pagetree and drag & drop
00171         '.($this->doHighlight ? 'Tree.highlightClass = "'.$hlClass.'";' : '').'
00172 
00173         // Function, loading the list frame from navigation tree:
00174         function jumpTo(id, linkObj, highlightID, bank) { //
00175             var theUrl = top.TS.PATH_typo3 + top.currentSubScript ;
00176             if (theUrl.indexOf("?") != -1) {
00177                 theUrl += "&id=" + id
00178             } else {
00179                 theUrl += "?id=" + id
00180             }
00181             top.fsMod.currentBank = bank;
00182             top.TYPO3.Backend.ContentContainer.setUrl(theUrl);
00183 
00184             '.($this->doHighlight ? 'Tree.highlightActiveItem("web", highlightID + "_" + bank);' : '').'
00185             '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) linkObj.blur(); ').'
00186             return false;
00187         }
00188         '.($this->cMR?"jumpTo(top.fsMod.recentIds['web'],'');":'').
00189 
00190             ($this->hasFilterBox ? 'var TYPO3PageTreeFilter = new PageTreeFilter();' : '') . '
00191 
00192         ');
00193 
00194         $this->doc->bodyTagId = 'typo3-pagetree';
00195     }
00196 
00197 
00198     /**
00199      * Main function, rendering the browsable page tree
00200      *
00201      * @return  void
00202      */
00203     function main() {
00204         global $LANG,$CLIENT;
00205 
00206             // Produce browse-tree:
00207         $tree = $this->pagetree->getBrowsableTree();
00208 
00209 
00210             // Outputting Temporary DB mount notice:
00211         if ($this->active_tempMountPoint)   {
00212             $flashText = '
00213                 <a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))) . '">' .
00214                 $LANG->sl('LLL:EXT:lang/locallang_core.xml:labels.temporaryDBmount',1) .
00215                 '</a>       <br />' .
00216                 $LANG->sl('LLL:EXT:lang/locallang_core.xml:labels.path',1) . ': <span title="' .
00217                 htmlspecialchars($this->active_tempMountPoint['_thePathFull']) . '">' .
00218                 htmlspecialchars(t3lib_div::fixed_lgd_cs($this->active_tempMountPoint['_thePath'],-50)).
00219                 '</span>
00220             ';
00221 
00222             $flashMessage = t3lib_div::makeInstance(
00223                 't3lib_FlashMessage',
00224                 $flashText,
00225                 '',
00226                 t3lib_FlashMessage::INFO
00227             );
00228 
00229 
00230             $this->content.= $flashMessage->render();
00231         }
00232 
00233             // Outputting page tree:
00234         $this->content .= '<div id="PageTreeDiv">'.$tree.'</div>';
00235 
00236             // Adding javascript for drag & drop activation and highlighting
00237         $this->content .= $this->doc->wrapScriptTags('
00238             '.($this->doHighlight ? 'Tree.highlightActiveItem("",top.fsMod.navFrameHighlightedID["web"]);' : '').'
00239             '.(!$this->doc->isCMlayers() ? 'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();')
00240         );
00241 
00242             // Setting up the buttons and markers for docheader
00243         $docHeaderButtons = $this->getButtons();
00244         $markers = array(
00245             'IMG_RESET'     => t3lib_iconWorks::getSpriteIcon('actions-document-close', array(
00246                         'id' =>'treeFilterReset',
00247                         'alt'=> $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter'),
00248                         'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter')
00249                     )),
00250             'WORKSPACEINFO' => $this->getWorkspaceInfo(),
00251             'CONTENT'       => $this->content
00252         );
00253         $subparts = array();
00254 
00255         if (!$this->hasFilterBox) {
00256             $subparts['###SECOND_ROW###'] = '';
00257         }
00258             // Build the <body> for the module
00259         $this->content = $this->doc->startPage('TYPO3 Page Tree');
00260         $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers, $subparts);
00261         $this->content.= $this->doc->endPage();
00262 
00263         $this->content = $this->doc->insertStylesAndJS($this->content);
00264     }
00265 
00266     /**
00267      * Outputting the accumulated content to screen
00268      *
00269      * @return  void
00270      */
00271     function printContent() {
00272         echo $this->content;
00273     }
00274 
00275     /**
00276      * Create the panel of buttons for submitting the form or otherwise perform operations.
00277      *
00278      * @return  array   all available buttons as an assoc. array
00279      */
00280     protected function getButtons() {
00281         global $LANG;
00282 
00283         $buttons = array(
00284             'csh' => '',
00285             'new_page' => '',
00286             'refresh' => '',
00287             'filter' => '',
00288         );
00289 
00290             // New Page
00291         $onclickNewPageWizard = 'top.content.list_frame.location.href=top.TS.PATH_typo3+\'db_new.php?pagesOnly=1&amp;id=\'+Tree.pageID;';
00292         $buttons['new_page'] = '<a href="#" onclick="' . $onclickNewPageWizard . '" title="' . $LANG->sL('LLL:EXT:cms/layout/locallang.xml:newPage', TRUE) . '">' .
00293                 t3lib_iconWorks::getSpriteIcon('actions-page-new') .
00294             '</a>';
00295 
00296             // Refresh
00297         $buttons['refresh'] = '<a href="' . htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')) . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh', TRUE) . '">' .
00298                 t3lib_iconWorks::getSpriteIcon('actions-system-refresh') .
00299             '</a>';
00300 
00301             // CSH
00302         $buttons['csh'] = str_replace('typo3-csh-inline','typo3-csh-inline show-right',t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH'], '', TRUE));
00303 
00304             // Filter
00305         if ($this->hasFilterBox) {
00306             $buttons['filter'] = '<a href="#" id="tree-toolbar-filter-item">' . t3lib_iconWorks::getSpriteIcon('actions-system-tree-search-open', array('title'=> $LANG->sL('LLL:EXT:cms/layout/locallang.xml:labels.filter', 1))) . '</a>';
00307         }
00308 
00309         return $buttons;
00310     }
00311 
00312     /**
00313      * Create the workspace information
00314      *
00315      * @return  string  HTML containing workspace info
00316      */
00317     protected function getWorkspaceInfo() {
00318 
00319         if (t3lib_extMgm::isLoaded('workspaces') && ($GLOBALS['BE_USER']->workspace !== 0 || $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo'))) {
00320             $wsTitle = htmlspecialchars(tx_Workspaces_Service_Workspaces::getWorkspaceTitle($GLOBALS['BE_USER']->workspace));
00321 
00322             $workspaceInfo = '
00323                 <div class="bgColor4 workspace-info">' .
00324                      t3lib_iconWorks::getSpriteIcon(
00325                         'apps-toolbar-menu-workspace',
00326                         array(
00327                             'title' => $wsTitle,
00328                             'onclick' => 'top.goToModule(\'web_WorkspacesWorkspaces\');',
00329                             'style' => 'cursor:pointer;'
00330                         )
00331                     ) .
00332                     $wsTitle .
00333                 '</div>
00334             ';
00335         }
00336 
00337         return $workspaceInfo;
00338     }
00339 
00340 
00341     /**********************************
00342      *
00343      * Temporary DB mounts
00344      *
00345      **********************************/
00346 
00347     /**
00348      * Getting temporary DB mount
00349      *
00350      * @return  void
00351      */
00352     function initializeTemporaryDBmount(){
00353         global $BE_USER;
00354 
00355             // Set/Cancel Temporary DB Mount:
00356         if (strlen($this->setTempDBmount))  {
00357             $set = t3lib_div::intInRange($this->setTempDBmount,0);
00358             if ($set>0 && $BE_USER->isInWebMount($set)) {   // Setting...:
00359                 $this->settingTemporaryMountPoint($set);
00360             } else {    // Clear:
00361                 $this->settingTemporaryMountPoint(0);
00362             }
00363         }
00364 
00365             // Getting temporary mount point ID:
00366         $temporaryMountPoint = intval($BE_USER->getSessionData('pageTree_temporaryMountPoint'));
00367 
00368             // If mount point ID existed and is within users real mount points, then set it temporarily:
00369         if ($temporaryMountPoint > 0 && $BE_USER->isInWebMount($temporaryMountPoint))   {
00370             if ($this->active_tempMountPoint = t3lib_BEfunc::readPageAccess($temporaryMountPoint, $BE_USER->getPagePermsClause(1))) {
00371                 $this->pagetree->MOUNTS = array($temporaryMountPoint);
00372             }
00373             else {
00374                 // Clear temporary mount point as we have no access to it any longer
00375                 $this->settingTemporaryMountPoint(0);
00376             }
00377         }
00378     }
00379 
00380 
00381     /**
00382      * Setting temporary page id as DB mount
00383      *
00384      * @param   integer     The page id to set as DB mount
00385      * @return  void
00386      */
00387     function settingTemporaryMountPoint($pageId)    {
00388         $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint',intval($pageId));
00389     }
00390 
00391 
00392     /**********************************
00393      *
00394      * AJAX Calls
00395      *
00396      **********************************/
00397 
00398     /**
00399      * Makes the AJAX call to expand or collapse the pagetree.
00400      * Called by typo3/ajax.php
00401      *
00402      * @param   array       $params: additional parameters (not used here)
00403      * @param   TYPO3AJAX   $ajaxObj: The TYPO3AJAX object of this request
00404      * @return  void
00405      */
00406     public function ajaxExpandCollapse($params, $ajaxObj) {
00407         global $LANG;
00408 
00409         $this->init();
00410         $tree = $this->pagetree->getBrowsableTree();
00411         if (!$this->pagetree->ajaxStatus) {
00412             $ajaxObj->setError($tree);
00413         } else  {
00414             $ajaxObj->addContent('tree', $tree);
00415         }
00416     }
00417 }
00418 
00419 
00420 
00421 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php'])) {
00422     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']);
00423 }
00424 
00425 
00426 // Make instance if it is not an AJAX call
00427 if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX)) {
00428     $SOBE = t3lib_div::makeInstance('SC_alt_db_navframe');
00429     $SOBE->init();
00430     $SOBE->initPage();
00431     $SOBE->main();
00432     $SOBE->printContent();
00433 }
00434 
00435 ?>