Documentation TYPO3 par Ameos

alt_db_navframe.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 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 ***************************************************************/
00055 $BACK_PATH = '';
00056 require('init.php');
00057 require('template.php');
00058 require_once('class.webpagetree.php');
00059 
00060 
00068 class SC_alt_db_navframe {
00069 
00070                 // Internal:
00071         var $content;
00072         var $pagetree;
00073         var $doc;
00074         var $active_tempMountPoint = 0;         // Temporary mount point (record), if any
00075         var $backPath;
00076 
00077                 // Internal, static: GPvar:
00078         var $ajax;                                                      // Is set, if an AJAX call should be handled.
00079         var $currentSubScript;
00080         var $cMR;
00081         var $setTempDBmount;                    // If not '' (blank) then it will clear (0) or set (>0) Temporary DB mount.
00082 
00088         function init() {
00089                 global $BE_USER,$BACK_PATH;
00090 
00091                         // Setting backPath
00092                 $this->backPath = $BACK_PATH;
00093                 $this->doc->backPath = $BACK_PATH;
00094 
00095                         // Setting GPvars:
00096                 $this->ajax = t3lib_div::_GP('ajax');
00097                 $this->cMR = t3lib_div::_GP('cMR');
00098                 $this->currentSubScript = t3lib_div::_GP('currentSubScript');
00099                 $this->setTempDBmount = t3lib_div::_GP('setTempDBmount');
00100 
00101                         // Create page tree object:
00102                 $this->pagetree = t3lib_div::makeInstance('webPageTree');
00103                 $this->pagetree->ext_IconMode = $BE_USER->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
00104                 $this->pagetree->ext_showPageId = $BE_USER->getTSConfigVal('options.pageTree.showPageIdWithTitle');
00105                 $this->pagetree->thisScript = 'alt_db_navframe.php';
00106                 $this->pagetree->addField('alias');
00107                 $this->pagetree->addField('shortcut');
00108                 $this->pagetree->addField('shortcut_mode');
00109                 $this->pagetree->addField('mount_pid');
00110                 $this->pagetree->addField('mount_pid_ol');
00111                 $this->pagetree->addField('nav_hide');
00112                 $this->pagetree->addField('url');
00113 
00114                         // Temporary DB mounts:
00115                 $this->initializeTemporaryDBmount();
00116 
00117                         // Use template rendering only if this is a non-AJAX call:
00118                 if (!$this->ajax) {
00119                                 // Setting highlight mode:
00120                         $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight');
00121 
00122                                 // If highlighting is active, define the CSS class for the active item depending on the workspace
00123                         if ($this->doHighlight) {
00124                                 if ($BE_USER->workspace === 0) $hlClass = 'active';
00125                                 else $hlClass = 'active active-ws wsver'.$BE_USER->workspace; 
00126                         }
00127 
00128                                 // Create template object:
00129                         $this->doc = t3lib_div::makeInstance('template');
00130                         $this->doc->docType = 'xhtml_trans';
00131 
00132                                 // Adding javascript code for AJAX (prototype), drag&drop and the pagetree
00133                         $this->doc->JScode  = '
00134                         <script type="text/javascript" src="'.$this->backPath.'contrib/prototype/prototype.js"></script>
00135                         <script type="text/javascript" src="'.$this->backPath.'tree.js"></script>'."\n";
00136 
00137                         $this->doc->JScode .= $this->doc->wrapScriptTags(
00138                         ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
00139                         // setting prefs for pagetree and drag & drop
00140                         Tree.thisScript    = "'.$this->pagetree->thisScript.'";
00141                         '.($this->doHighlight ? 'Tree.highlightClass = "'.$hlClass.'";' : '').'
00142 
00143                         DragDrop.changeURL = "'.$this->backPath.'alt_clickmenu.php";
00144                         DragDrop.backPath  = "'.t3lib_div::shortMD5(''.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']).'";
00145                         DragDrop.table     = "pages";
00146 
00147                         // Function, loading the list frame from navigation tree:
00148                         function jumpTo(id, linkObj, highlightID, bank) { //
00149                                 var theUrl = top.TS.PATH_typo3 + top.currentSubScript + "?id=" + id;
00150                                 top.fsMod.currentBank = bank;
00151 
00152                                 if (top.condensedMode) top.content.location.href = theUrl;
00153                                 else                   parent.list_frame.location.href=theUrl;
00154 
00155                                 '.($this->doHighlight ? 'Tree.highlightActiveItem("web", highlightID + "_" + bank);' : '').'
00156                                 '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) linkObj.blur(); ').'
00157                                 return false;
00158                         }
00159                         '.($this->cMR?"jumpTo(top.fsMod.recentIds['web'],'');":'').'
00160                         ');
00161 
00162                                 // Click menu code is added:
00163                         $CMparts=$this->doc->getContextMenuCode();
00164                         $this->doc->bodyTagAdditions = $CMparts[1];
00165                         $this->doc->JScode.= $CMparts[0];
00166                         $this->doc->postCode.= $CMparts[2];
00167                 }
00168         }
00169 
00170 
00176         function main() {
00177                 global $LANG,$CLIENT;
00178 
00179                         // Produce browse-tree:
00180                 $tree = $this->pagetree->getBrowsableTree();
00181 
00182                         // Output only the tree if this is an AJAX call:
00183                 if ($this->ajax) {
00184                         $this->content = $LANG->csConvObj->utf8_encode($tree, $LANG->charSet);
00185                         return;
00186                 }
00187 
00188                         // Start page:
00189                 $this->content = $this->doc->startPage('TYPO3 Page Tree');
00190                 
00191                         // Outputting workspace info
00192                 if ($GLOBALS['BE_USER']->workspace!==0 || $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo'))  {
00193                         switch($GLOBALS['BE_USER']->workspace)  {
00194                                 case 0:
00195                                         $wsTitle = '&nbsp;'.$this->doc->icons(2).'['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_onlineWS',1).']';
00196                                 break;
00197                                 case -1:
00198                                         $wsTitle = '['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_offlineWS',1).']';
00199                                 break;
00200                                 default:
00201                                         $wsTitle = '['.$GLOBALS['BE_USER']->workspace.'] '.htmlspecialchars($GLOBALS['BE_USER']->workspaceRec['title']);
00202                                 break;
00203                         }
00204 
00205                         $this->content.= '
00206                                 <div class="bgColor4 workspace-info">'.
00207                                         '<a href="'.htmlspecialchars('mod/user/ws/index.php').'" target="content">'.
00208                                         '<img'.t3lib_iconWorks::skinImg('','gfx/i/sys_workspace.png','width="18" height="16"').' align="top" alt="" />'.
00209                                         '</a>'.$wsTitle.'
00210                                 </div>
00211                         ';
00212                 }
00213 
00214                         // Outputting Temporary DB mount notice:
00215                 if ($this->active_tempMountPoint)       {
00216                         $this->content.= '
00217                                 <div class="bgColor4 c-notice">
00218                                         <img'.t3lib_iconWorks::skinImg('','gfx/icon_note.gif','width="18" height="16"').' align="top" alt="" />'.
00219                                         '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))).'">'.
00220                                         $LANG->sl('LLL:EXT:lang/locallang_core.php:labels.temporaryDBmount',1).
00221                                         '</a><br/>
00222                                         '.$LANG->sl('LLL:EXT:lang/locallang_core.php:labels.path',1).': <span title="'.htmlspecialchars($this->active_tempMountPoint['_thePathFull']).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($this->active_tempMountPoint['_thePath'],-50)).'</span>
00223                                 </div>
00224                         ';
00225                 }
00226 
00227                         // Outputting page tree:
00228                 $this->content.= $tree;
00229 
00230                         // Outputting refresh-link
00231                 $this->content.= '
00232                         <p class="c-refresh">
00233                                 <a href="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'">'.
00234                                 '<img'.t3lib_iconWorks::skinImg('','gfx/refresh_n.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'" alt="" />'.
00235                                 $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'</a>
00236                         </p>
00237                         <br />';
00238 
00239                         // CSH icon:
00240                 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH']);
00241 
00242                         // Adding javascript for drag & drop activation and highlighting
00243                 $this->content .=$this->doc->wrapScriptTags('
00244                         '.($this->doHighlight ? 'Tree.highlightActiveItem("",top.fsMod.navFrameHighlightedID["web"]);' : '').'
00245                         '.(!$this->doc->isCMlayers() ? 'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();')
00246                 );
00247         }
00248 
00254         function printContent() {
00255                         // If we handle an AJAX call, send headers:
00256                 if ($this->ajax) {
00257                         header('X-JSON: ('.($this->pagetree->ajaxStatus?'true':'false').')');
00258                         header('Content-type: text/html; charset=utf-8');
00259                         // If it's the regular call to fully output the tree:
00260                 } else {
00261                         $this->content.= $this->doc->endPage();
00262                         $this->content = $this->doc->insertStylesAndJS($this->content);
00263                 }
00264                 echo $this->content;
00265         }
00266 
00267 
00268 
00269 
00270 
00271         /**********************************
00272          *
00273          * Temporary DB mounts
00274          *
00275          **********************************/
00276 
00282         function initializeTemporaryDBmount(){
00283                 global $BE_USER;
00284 
00285                         // Set/Cancel Temporary DB Mount:
00286                 if (strlen($this->setTempDBmount))      {
00287                         $set = t3lib_div::intInRange($this->setTempDBmount,0);
00288                         if ($set>0 && $BE_USER->isInWebMount($set))     {       // Setting...:
00289                                 $this->settingTemporaryMountPoint($set);
00290                         } else {        // Clear:
00291                                 $this->settingTemporaryMountPoint(0);
00292                         }
00293                 }
00294 
00295                         // Getting temporary mount point ID:
00296                 $temporaryMountPoint = intval($BE_USER->getSessionData('pageTree_temporaryMountPoint'));
00297 
00298                         // If mount point ID existed and is within users real mount points, then set it temporarily:
00299                 if ($temporaryMountPoint > 0 && $BE_USER->isInWebMount($temporaryMountPoint))   {
00300                         if ($this->active_tempMountPoint = t3lib_BEfunc::readPageAccess($temporaryMountPoint, $BE_USER->getPagePermsClause(1))) {
00301                                 $this->pagetree->MOUNTS = array($temporaryMountPoint);
00302                         }
00303                         else {
00304                                 // Clear temporary mount point as we have no access to it any longer
00305                                 $this->settingTemporaryMountPoint(0);
00306                         }
00307                 }
00308         }
00309 
00310 
00317         function settingTemporaryMountPoint($pageId)    {
00318                 global $BE_USER;
00319 
00320                         // Setting temporary mount point ID:
00321                 $BE_USER->setAndSaveSessionData('pageTree_temporaryMountPoint',intval($pageId));
00322         }
00323 }
00324 
00325 
00326 // Include extension?
00327 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php'])       {
00328         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']);
00329 }
00330 
00331 
00332 
00333 
00334 
00335 // Make instance:
00336 $SOBE = t3lib_div::makeInstance('SC_alt_db_navframe');
00337 $SOBE->init();
00338 $SOBE->main();
00339 $SOBE->printContent();
00340 
00341 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6