alt_db_navframe.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  * Page navigation tree for the Web module
00029  *
00030  * $Id: alt_db_navframe.php 8156 2010-07-11 12:42:05Z psychomieze $
00031  * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
00032  * XHTML compliant
00033  *
00034  * @author  Kasper Skaarhoj <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 Skaarhoj <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         $this->doc->getPageRenderer()->addJsFile('js/pagetreefiltermenu.js');
00165 
00166         $this->doc->JScode .= $this->doc->wrapScriptTags(
00167         ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
00168         // setting prefs for pagetree and drag & drop
00169         '.($this->doHighlight ? 'Tree.highlightClass = "'.$hlClass.'";' : '').'
00170 
00171         // Function, loading the list frame from navigation tree:
00172         function jumpTo(id, linkObj, highlightID, bank) { //
00173             var theUrl = top.TS.PATH_typo3 + top.currentSubScript ;
00174             if (theUrl.indexOf("?") != -1) {
00175                 theUrl += "&id=" + id
00176             } else {
00177                 theUrl += "?id=" + id
00178             }
00179             top.fsMod.currentBank = bank;
00180 
00181             if (top.TYPO3.configuration.condensedMode) {
00182                 top.content.location.href = theUrl;
00183             } else {
00184                 parent.list_frame.location.href=theUrl;
00185             }
00186 
00187             '.($this->doHighlight ? 'Tree.highlightActiveItem("web", highlightID + "_" + bank);' : '').'
00188             '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) linkObj.blur(); ').'
00189             return false;
00190         }
00191         '.($this->cMR?"jumpTo(top.fsMod.recentIds['web'],'');":'').
00192 
00193             ($this->hasFilterBox ? 'var TYPO3PageTreeFilter = new PageTreeFilter();' : '') . '
00194 
00195         ');
00196 
00197         $this->doc->bodyTagId = 'typo3-pagetree';
00198     }
00199 
00200 
00201     /**
00202      * Main function, rendering the browsable page tree
00203      *
00204      * @return  void
00205      */
00206     function main() {
00207         global $LANG,$CLIENT;
00208 
00209             // Produce browse-tree:
00210         $tree = $this->pagetree->getBrowsableTree();
00211 
00212 
00213             // Outputting Temporary DB mount notice:
00214         if ($this->active_tempMountPoint)   {
00215             $flashText = '
00216                 <a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))) . '">' .
00217                 $LANG->sl('LLL:EXT:lang/locallang_core.xml:labels.temporaryDBmount',1) .
00218                 '</a>       <br />' .
00219                 $LANG->sl('LLL:EXT:lang/locallang_core.xml:labels.path',1) . ': <span title="' .
00220                 htmlspecialchars($this->active_tempMountPoint['_thePathFull']) . '">' .
00221                 htmlspecialchars(t3lib_div::fixed_lgd_cs($this->active_tempMountPoint['_thePath'],-50)).
00222                 '</span>
00223             ';
00224 
00225             $flashMessage = t3lib_div::makeInstance(
00226                 't3lib_FlashMessage',
00227                 $flashText,
00228                 '',
00229                 t3lib_FlashMessage::INFO
00230             );
00231 
00232 
00233             $this->content.= $flashMessage->render();
00234         }
00235 
00236             // Outputting page tree:
00237         $this->content .= '<div id="PageTreeDiv">'.$tree.'</div>';
00238 
00239             // Adding javascript for drag & drop activation and highlighting
00240         $this->content .= $this->doc->wrapScriptTags('
00241             '.($this->doHighlight ? 'Tree.highlightActiveItem("",top.fsMod.navFrameHighlightedID["web"]);' : '').'
00242             '.(!$this->doc->isCMlayers() ? 'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();')
00243         );
00244 
00245             // Setting up the buttons and markers for docheader
00246         $docHeaderButtons = $this->getButtons();
00247         $markers = array(
00248             'IMG_RESET'     => t3lib_iconWorks::getSpriteIcon('actions-document-close', array(
00249                         'id' =>'treeFilterReset',
00250                         'alt'=> $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter'),
00251                         'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter')
00252                     )),
00253             'WORKSPACEINFO' => $this->getWorkspaceInfo(),
00254             'CONTENT'       => $this->content
00255         );
00256         $subparts = array();
00257 
00258         if (!$this->hasFilterBox) {
00259             $subparts['###SECOND_ROW###'] = '';
00260         }
00261             // Build the <body> for the module
00262         $this->content = $this->doc->startPage('TYPO3 Page Tree');
00263         $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers, $subparts);
00264         $this->content.= $this->doc->endPage();
00265 
00266         $this->content = $this->doc->insertStylesAndJS($this->content);
00267     }
00268 
00269     /**
00270      * Outputting the accumulated content to screen
00271      *
00272      * @return  void
00273      */
00274     function printContent() {
00275         echo $this->content;
00276     }
00277 
00278     /**
00279      * Create the panel of buttons for submitting the form or otherwise perform operations.
00280      *
00281      * @return  array   all available buttons as an assoc. array
00282      */
00283     protected function getButtons() {
00284         global $LANG;
00285 
00286         $buttons = array(
00287             'csh' => '',
00288             'new_page' => '',
00289             'refresh' => '',
00290             'filter' => '',
00291         );
00292 
00293             // New Page
00294         $onclickNewPageWizard = 'top.content.list_frame.location.href=top.TS.PATH_typo3+\'db_new.php?pagesOnly=1&amp;id=\'+Tree.pageID;';
00295         $buttons['new_page'] = '<a href="#" onclick="' . $onclickNewPageWizard . '" title="' . $LANG->sL('LLL:EXT:cms/layout/locallang.xml:newPage', TRUE) . '">' .
00296                 t3lib_iconWorks::getSpriteIcon('actions-page-new') .
00297             '</a>';
00298 
00299             // Refresh
00300         $buttons['refresh'] = '<a href="' . htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')) . '" title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh', TRUE) . '">' .
00301                 t3lib_iconWorks::getSpriteIcon('actions-system-refresh') .
00302             '</a>';
00303 
00304             // CSH
00305         $buttons['csh'] = str_replace('typo3-csh-inline','typo3-csh-inline show-right',t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH'], '', TRUE));
00306 
00307             // Filter
00308         if ($this->hasFilterBox) {
00309             $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>';
00310         }
00311 
00312         return $buttons;
00313     }
00314 
00315     /**
00316      * Create the workspace information
00317      *
00318      * @return  string  HTML containing workspace info
00319      */
00320     protected function getWorkspaceInfo() {
00321         global $LANG;
00322 
00323         if ($GLOBALS['BE_USER']->workspace!==0 || $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo'))  {
00324             switch($GLOBALS['BE_USER']->workspace)  {
00325                 case 0:
00326                     $wsTitle = '&nbsp;'.$this->doc->icons(2).'['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_onlineWS',1).']';
00327                 break;
00328                 case -1:
00329                     $wsTitle = '['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_offlineWS',1).']';
00330                 break;
00331                 default:
00332                     $wsTitle = '['.$GLOBALS['BE_USER']->workspace.'] '.htmlspecialchars($GLOBALS['BE_USER']->workspaceRec['title']);
00333                 break;
00334             }
00335 
00336             $workspaceInfo = '
00337                 <div class="bgColor4 workspace-info">
00338                     <a href="'.htmlspecialchars('mod/user/ws/index.php').'" target="content">'.
00339                       t3lib_iconWorks::getSpriteIcon('apps-toolbar-menu-workspace') .
00340                     '</a>'.$wsTitle.'
00341                 </div>
00342             ';
00343         }
00344 
00345         return $workspaceInfo;
00346     }
00347 
00348 
00349     /**********************************
00350      *
00351      * Temporary DB mounts
00352      *
00353      **********************************/
00354 
00355     /**
00356      * Getting temporary DB mount
00357      *
00358      * @return  void
00359      */
00360     function initializeTemporaryDBmount(){
00361         global $BE_USER;
00362 
00363             // Set/Cancel Temporary DB Mount:
00364         if (strlen($this->setTempDBmount))  {
00365             $set = t3lib_div::intInRange($this->setTempDBmount,0);
00366             if ($set>0 && $BE_USER->isInWebMount($set)) {   // Setting...:
00367                 $this->settingTemporaryMountPoint($set);
00368             } else {    // Clear:
00369                 $this->settingTemporaryMountPoint(0);
00370             }
00371         }
00372 
00373             // Getting temporary mount point ID:
00374         $temporaryMountPoint = intval($BE_USER->getSessionData('pageTree_temporaryMountPoint'));
00375 
00376             // If mount point ID existed and is within users real mount points, then set it temporarily:
00377         if ($temporaryMountPoint > 0 && $BE_USER->isInWebMount($temporaryMountPoint))   {
00378             if ($this->active_tempMountPoint = t3lib_BEfunc::readPageAccess($temporaryMountPoint, $BE_USER->getPagePermsClause(1))) {
00379                 $this->pagetree->MOUNTS = array($temporaryMountPoint);
00380             }
00381             else {
00382                 // Clear temporary mount point as we have no access to it any longer
00383                 $this->settingTemporaryMountPoint(0);
00384             }
00385         }
00386     }
00387 
00388 
00389     /**
00390      * Setting temporary page id as DB mount
00391      *
00392      * @param   integer     The page id to set as DB mount
00393      * @return  void
00394      */
00395     function settingTemporaryMountPoint($pageId)    {
00396         $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint',intval($pageId));
00397     }
00398 
00399 
00400     /**********************************
00401      *
00402      * AJAX Calls
00403      *
00404      **********************************/
00405 
00406     /**
00407      * Makes the AJAX call to expand or collapse the pagetree.
00408      * Called by typo3/ajax.php
00409      *
00410      * @param   array       $params: additional parameters (not used here)
00411      * @param   TYPO3AJAX   $ajaxObj: The TYPO3AJAX object of this request
00412      * @return  void
00413      */
00414     public function ajaxExpandCollapse($params, $ajaxObj) {
00415         global $LANG;
00416 
00417         $this->init();
00418         $tree = $this->pagetree->getBrowsableTree();
00419         if (!$this->pagetree->ajaxStatus) {
00420             $ajaxObj->setError($tree);
00421         } else  {
00422             $ajaxObj->addContent('tree', $tree);
00423         }
00424     }
00425 }
00426 
00427 
00428 
00429 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php'])   {
00430     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']);
00431 }
00432 
00433 
00434 // Make instance if it is not an AJAX call
00435 if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX)) {
00436     $SOBE = t3lib_div::makeInstance('SC_alt_db_navframe');
00437     $SOBE->init();
00438     $SOBE->initPage();
00439     $SOBE->main();
00440     $SOBE->printContent();
00441 }
00442 
00443 ?>

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