fixed bug #7816: New page icon does not honor a selected page, credits Steffen Kamper
[Packages/TYPO3.CMS.git] / typo3 / alt_db_navframe.php
index 420414c..a9fba73 100755 (executable)
  * [CLASS/FUNCTION INDEX of SCRIPT]
  *
  *
- *
- *   78: class localPageTree extends t3lib_browseTree
- *   88:     function localPageTree()
- *   99:     function wrapIcon($icon,&$row)
- *  142:     function wrapStop($str,$row)
- *  158:     function wrapTitle($title,$row,$bank=0)
- *
- *
  *  192: class SC_alt_db_navframe
  *  210:     function init()
  *  313:     function main()
  */
 
 
-$BACK_PATH='';
-require('init.php');
+$BACK_PATH = '';
+require_once('init.php');
 require('template.php');
-require_once(PATH_t3lib.'class.t3lib_browsetree.php');
-
-
-
-/**
- * Extension class for the t3lib_browsetree class, specially made for browsing pages in the Web module
- *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage core
- * @see class t3lib_browseTree
- */
-class localPageTree extends t3lib_browseTree {
-
-       var $ext_showPageId;
-       var $ext_IconMode;
-
-       /**
-        * Calls init functions
-        *
-        * @return      void
-        */
-       function localPageTree() {
-               $this->init();
-       }
-
-       /**
-        * Wrapping icon in browse tree
-        *
-        * @param       string          Icon IMG code
-        * @param       array           Data row for element.
-        * @return      string          Page icon
-        */
-       function wrapIcon($icon,&$row)  {
-                       // If the record is locked, present a warning sign.
-               if ($lockInfo=t3lib_BEfunc::isRecordLocked('pages',$row['uid']))        {
-                       $aOnClick = 'alert('.$GLOBALS['LANG']->JScharCode($lockInfo['msg']).');return false;';
-                       $lockIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
-                               '<img'.t3lib_iconWorks::skinImg('','gfx/recordlock_warning3.gif','width="17" height="12"').' title="'.htmlspecialchars($lockInfo['msg']).'" alt="" />'.
-                               '</a>';
-               } else $lockIcon = '';
-
-                       // Add title attribute to input icon tag
-               $thePageIcon = $this->addTagAttributes($icon, $this->titleAttrib.'="'.$this->getTitleAttrib($row).'"');
-
-                       // Wrap icon in click-menu link.
-               if (!$this->ext_IconMode)       {
-                       $thePageIcon = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon($thePageIcon,'pages',$row['uid'],0,'&bank='.$this->bank);
-               } elseif (!strcmp($this->ext_IconMode,'titlelink'))     {
-                       $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->treeName.'\');';
-                       $thePageIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$thePageIcon.'</a>';
-               }
-
-                       // Wrap icon in a drag/drop span.
-               $spanOnDrag = htmlspecialchars('return dragElement("'.$row['uid'].'")');
-               $spanOnDrop = htmlspecialchars('return dropElement("'.$row['uid'].'")');
-               $dragDropIcon = '<span id="dragIconID_'.$row['uid'].'" ondragstart="'.$spanOnDrag.'" onmousedown="'.$spanOnDrag.'" onmouseup="'.$spanOnDrop.'">'.$thePageIcon.'</span>';
-
-                       // Add Page ID:
-               if ($this->ext_showPageId)      {
-                       $pageIdStr = '['.$row['uid'].']&nbsp;';
-               } else {
-                       $pageIdStr = '';
-               }
-
-               return $dragDropIcon.$lockIcon.$pageIdStr;
-       }
-
-       /**
-        * Adds a red "+" to the input string, $str, if the field "php_tree_stop" in the $row (pages) is set
-        *
-        * @param       string          Input string, like a page title for the tree
-        * @param       array           record row with "php_tree_stop" field
-        * @return      string          Modified string
-        * @access private
-        */
-       function wrapStop($str,$row)    {
-               if ($row['php_tree_stop'])      {
-                       $str.='<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => $row['uid']))).'" class="typo3-red">+</a> ';
-               }
-               return $str;
-       }
-
-       /**
-        * Wrapping $title in a-tags.
-        *
-        * @param       string          Title string
-        * @param       string          Item record
-        * @param       integer         Bank pointer (which mount point number)
-        * @return      string
-        * @access private
-        */
-       function wrapTitle($title,$row,$bank=0) {
-               $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->domIdPrefix.$this->getId($row).'\','.$bank.');';
-               $CSM = '';
-               if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler'])       {
-                       $CSM = ' oncontextmenu="'.htmlspecialchars($GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon('','pages',$row['uid'],0,'&bank='.$this->bank,'',TRUE)).'"';
-               }
-               $thePageTitle='<a href="#" onclick="'.htmlspecialchars($aOnClick).'"'.$CSM.'>'.$title.'</a>';
-
-                       // Wrap title in a drag/drop span.
-               $spanOnDrag = htmlspecialchars('return dragElement("'.$row['uid'].'")');
-               $spanOnDrop = htmlspecialchars('return dropElement("'.$row['uid'].'")');
-               $dragDropTitle = '<span id="dragTitleID_'.$row['uid'].'" ondragstart="'.$spanOnDrag.'" onmousedown="'.$spanOnDrag.'" onmouseup="'.$spanOnDrop.'">'.$thePageTitle.'</span>';
-               return $dragDropTitle;
-       }
-}
-
-
-
-
-
-
-
-
-
-
+require_once('class.webpagetree.php');
 
 
 /**
@@ -194,14 +70,24 @@ class SC_alt_db_navframe {
                // Internal:
        var $content;
        var $pagetree;
+
+       /**
+        * document template object
+        *
+        * @var template
+        */
        var $doc;
        var $active_tempMountPoint = 0;         // Temporary mount point (record), if any
+       var $backPath;
 
                // Internal, static: GPvar:
        var $currentSubScript;
        var $cMR;
        var $setTempDBmount;                    // If not '' (blank) then it will clear (0) or set (>0) Temporary DB mount.
 
+       var $template;                                  // a static HTML template, usually in templates/alt_db_navframe.html
+       var $hasFilterBox;                              //depends on userTS-setting
+
        /**
         * Initialiation of the class
         *
@@ -210,15 +96,24 @@ class SC_alt_db_navframe {
        function init() {
                global $BE_USER,$BACK_PATH;
 
+                       // Setting backPath
+               $this->backPath = $BACK_PATH;
+
                        // Setting GPvars:
-               $this->currentSubScript = t3lib_div::_GP('currentSubScript');
                $this->cMR = t3lib_div::_GP('cMR');
+               $this->currentSubScript = t3lib_div::_GP('currentSubScript');
                $this->setTempDBmount = t3lib_div::_GP('setTempDBmount');
 
+                       // look for User setting
+               $this->hasFilterBox = !$BE_USER->getTSConfigVal('options.pageTree.hideFilter');
+
                        // Create page tree object:
-               $this->pagetree = t3lib_div::makeInstance('localPageTree');
+               $this->pagetree = t3lib_div::makeInstance('webPageTree');
                $this->pagetree->ext_IconMode = $BE_USER->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
                $this->pagetree->ext_showPageId = $BE_USER->getTSConfigVal('options.pageTree.showPageIdWithTitle');
+               $this->pagetree->ext_showNavTitle = $BE_USER->getTSConfigVal('options.pageTree.showNavTitle');
+               $this->pagetree->ext_separateNotinmenuPages = $BE_USER->getTSConfigVal('options.pageTree.separateNotinmenuPages');
+               $this->pagetree->ext_alphasortNotinmenuPages = $BE_USER->getTSConfigVal('options.pageTree.alphasortNotinmenuPages');
                $this->pagetree->thisScript = 'alt_db_navframe.php';
                $this->pagetree->addField('alias');
                $this->pagetree->addField('shortcut');
@@ -226,85 +121,72 @@ class SC_alt_db_navframe {
                $this->pagetree->addField('mount_pid');
                $this->pagetree->addField('mount_pid_ol');
                $this->pagetree->addField('nav_hide');
+               $this->pagetree->addField('nav_title');
                $this->pagetree->addField('url');
 
-#              $this->settingTemporaryMountPoint(11);
                        // Temporary DB mounts:
                $this->initializeTemporaryDBmount();
+       }
+
+
+       /**
+        * initialization for the visual parts of the class
+        * Use template rendering only if this is a non-AJAX call
+        *
+        * @return      void
+        */
+       public function initPage() {
+               global $BE_USER;
 
                        // Setting highlight mode:
-               $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight') && $BE_USER->workspace===0;
+               $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight');
+
+                       // If highlighting is active, define the CSS class for the active item depending on the workspace
+               if ($this->doHighlight) {
+                       $hlClass = ($BE_USER->workspace === 0 ? 'active' : 'active active-ws wsver'.$BE_USER->workspace);
+               }
 
                        // Create template object:
                $this->doc = t3lib_div::makeInstance('template');
-               $this->doc->docType='xhtml_trans';
-
-                       // Setting backPath
                $this->doc->backPath = $BACK_PATH;
+               $this->doc->setModuleTemplate('templates/alt_db_navframe.html');
+               $this->doc->docType  = 'xhtml_trans';
 
-                       // Setting JavaScript for menu.
-               $this->doc->JScode=$this->doc->wrapScriptTags(
-       ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
+                       // get HTML-Template
 
-               // Function, loading the list frame from navigation tree:
-       function jumpTo(id,linkObj,highLightID,bank)    {       //
-               var theUrl = top.TS.PATH_typo3+top.currentSubScript+"?id="+id;
-               top.fsMod.currentBank = bank;
-
-               if (top.condensedMode)  {
-                       top.content.location.href=theUrl;
-               } else {
-                       parent.list_frame.location.href=theUrl;
-               }
 
-               '.($this->doHighlight?'hilight_row("web",highLightID+"_"+bank);':'').'
+                       // Adding javascript code for AJAX (prototype), drag&drop and the pagetree as well as the click menu code
+               $this->doc->getDragDropCode('pages');
+               $this->doc->getContextMenuCode();
+               $this->doc->loadJavascriptLib('contrib/scriptaculous/scriptaculous.js?load=effects');
 
-               '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) {linkObj.blur();}').'
-               return false;
-       }
+               $this->doc->JScode .= $this->doc->wrapScriptTags(
+               ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
+               // setting prefs for pagetree and drag & drop
+               '.($this->doHighlight ? 'Tree.highlightClass = "'.$hlClass.'";' : '').'
 
-               // Call this function, refresh_nav(), from another script in the backend if you want to refresh the navigation frame (eg. after having changed a page title or moved pages etc.)
-               // See t3lib_BEfunc::getSetUpdateSignal()
-       function refresh_nav()  {       //
-               window.setTimeout("_refresh_nav();",0);
-       }
-       function _refresh_nav() {       //
-               window.location.href="'.$this->pagetree->thisScript.'?unique='.time().'";
-       }
+               // Function, loading the list frame from navigation tree:
+               function jumpTo(id, linkObj, highlightID, bank) { //
+                       var theUrl = top.TS.PATH_typo3 + top.currentSubScript + "?id=" + id;
+                       top.fsMod.currentBank = bank;
 
-               // Highlighting rows in the page tree:
-       function hilight_row(frameSetModule,highLightID) {      //
+                       if (top.condensedMode) top.content.location.href = theUrl;
+                       else                   parent.list_frame.location.href=theUrl;
 
-                       // Remove old:
-               theObj = document.getElementById(top.fsMod.navFrameHighlightedID[frameSetModule]);
-               if (theObj)     {
-                       theObj.setAttribute("class", "");
+                       '.($this->doHighlight ? 'Tree.highlightActiveItem("web", highlightID + "_" + bank);' : '').'
+                       '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) linkObj.blur(); ').'
+                       return false;
                }
+               '.($this->cMR?"jumpTo(top.fsMod.recentIds['web'],'');":'').
 
-                       // Set new:
-               top.fsMod.navFrameHighlightedID[frameSetModule] = highLightID;
-               theObj = document.getElementById(highLightID);
-               if (theObj)     {
-                       theObj.setAttribute("class", "navFrameHL");
-               }
-       }
+                       ($this->hasFilterBox ? 'var TYPO3PageTreeFilter = new PageTreeFilter();' : '') . '
 
-       '.($this->cMR?"jumpTo(top.fsMod.recentIds['web'],'');":'').';
                ');
 
-                       // Click menu code is added:
-               $CMparts=$this->doc->getContextMenuCode();
-               $this->doc->bodyTagAdditions = $CMparts[1];
-               $this->doc->JScode.= $CMparts[0];
-               $this->doc->postCode.= $CMparts[2];
-
-                       // Drag and Drop code is added:
-               $DDparts=$this->doc->getDragDropCode('pages');
-               // ignore the $DDparts[1] for now
-               $this->doc->JScode.= $DDparts[0];
-               $this->doc->postCode.= $DDparts[2];
+               $this->doc->bodyTagId = 'typo3-pagetree';
        }
 
+
        /**
         * Main function, rendering the browsable page tree
         *
@@ -316,67 +198,42 @@ class SC_alt_db_navframe {
                        // Produce browse-tree:
                $tree = $this->pagetree->getBrowsableTree();
 
-                       // Start page:
-               $this->content = '';
-               $this->content.= $this->doc->startPage('Page tree');
-
-                       // Outputting workspace info
-               if ($GLOBALS['BE_USER']->workspace!==0 || $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo'))  {
-                       switch($GLOBALS['BE_USER']->workspace)  {
-                               case 0:
-                                       $wsTitle = '&nbsp;'.$this->doc->icons(2).'['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_onlineWS',1).']';
-                               break;
-                               case -1:
-                                       $wsTitle = '['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_offlineWS',1).']';
-                               break;
-                               default:
-                                       $wsTitle = '['.$GLOBALS['BE_USER']->workspace.'] '.htmlspecialchars($GLOBALS['BE_USER']->workspaceRec['title']);
-                               break;
-                       }
-
-                       $this->content.= '
-                               <div class="bgColor4 workspace-info">'.
-                                       '<a href="'.htmlspecialchars('mod/user/ws/index.php').'" target="content">'.
-                                       '<img'.t3lib_iconWorks::skinImg('','gfx/i/sys_workspace.png','width="18" height="16"').' align="top" alt="" />'.
-                                       '</a>'.$wsTitle.'
-                               </div>
-                       ';
-               }
 
                        // Outputting Temporary DB mount notice:
                if ($this->active_tempMountPoint)       {
                        $this->content.= '
-                               <div class="bgColor4 c-notice">
-                                       <img'.t3lib_iconWorks::skinImg('','gfx/icon_note.gif','width="18" height="16"').' align="top" alt="" />'.
-                                       '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))).'">'.
-                                       $LANG->sl('LLL:EXT:lang/locallang_core.php:labels.temporaryDBmount',1).
-                                       '</a><br/>
-                                       '.$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>
-                               </div>
+       <div class="bgColor4 c-notice">
+               <img'.t3lib_iconWorks::skinImg('','gfx/icon_note.gif','width="18" height="16"').' align="top" alt="" />'.
+               '<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))).'">'.
+               $LANG->sl('LLL:EXT:lang/locallang_core.xml:labels.temporaryDBmount',1).
+               '</a><br/>
+               '.$LANG->sl('LLL:EXT:lang/locallang_core.xml:labels.path',1).': <span title="'.htmlspecialchars($this->active_tempMountPoint['_thePathFull']).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($this->active_tempMountPoint['_thePath'],-50)).'</span>
+       </div>
                        ';
                }
 
                        // Outputting page tree:
-               $this->content.= $tree;
-
-                       // Outputting refresh-link
-               $refreshUrl = t3lib_div::getIndpEnv('REQUEST_URI');
-               $this->content.= '
-                       <p class="c-refresh">
-                               <a href="'.htmlspecialchars($refreshUrl).'">'.
-                               '<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="" />'.
-                               '</a><a href="'.htmlspecialchars($refreshUrl).'">'.
-                               $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh',1).'</a>
-                       </p>
-                       <br />';
-
-                       // CSH icon:
-               $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH']);
-
-                       // Adding highlight - JavaScript
-               if ($this->doHighlight) $this->content .=$this->doc->wrapScriptTags('
-                       hilight_row("",top.fsMod.navFrameHighlightedID["web"]);
-               ');
+               $this->content .= '<div id="PageTreeDiv">'.$tree.'</div>';
+
+                       // Adding javascript for drag & drop activation and highlighting
+               $this->content .= $this->doc->wrapScriptTags('
+                       '.($this->doHighlight ? 'Tree.highlightActiveItem("",top.fsMod.navFrameHighlightedID["web"]);' : '').'
+                       '.(!$this->doc->isCMlayers() ? 'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();')
+               );
+
+                       // Setting up the buttons and markers for docheader
+               $docHeaderButtons = $this->getButtons();
+               $markers = array(
+                       'IMG_RESET' => '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/close_gray.gif', ' width="16" height="16"').' id="treeFilterReset" alt="Reset Filter" />',
+                       'WORKSPACEINFO' => $this->getWorkspaceInfo(),
+                       'CONTENT' => $this->content
+               );
+
+                       // Build the <body> for the module
+               $this->content = $this->doc->startPage('TYPO3 Page Tree');
+               $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
+               $this->content.= $this->doc->endPage();
+               $this->content = $this->doc->insertStylesAndJS($this->content);
        }
 
        /**
@@ -385,20 +242,68 @@ class SC_alt_db_navframe {
         * @return      void
         */
        function printContent() {
-               $this->content.= $this->doc->endPage();
-               $this->content = $this->doc->insertStylesAndJS($this->content);
                echo $this->content;
        }
 
+       /**
+        * Create the panel of buttons for submitting the form or otherwise perform operations.
+        *
+        * @return      array   all available buttons as an assoc. array
+        */
+       private function getButtons()   {
+               global $LANG;
 
+               $buttons = array(
+                       'csh' => '',
+                       'new_page' => '',
+                       'refresh' => '',
+               );
 
+                       // New Page
+               $onclickNewPageWizard = 'top.content.list_frame.location.href=top.TS.PATH_typo3+\'db_new.php?pagesOnly=1&id=\'+Tree.pageID;"';
+               $buttons['new_page'] = '<a href="#" onclick="' . $onclickNewPageWizard . '"><img' . t3lib_iconWorks::skinImg('', 'gfx/new_page.gif') . ' title="' . $LANG->sL('LLL:EXT:cms/layout/locallang.xml:newPage', 1) . '" alt="" /></a>';
 
+                       // Refresh
+               $buttons['refresh'] = '<a href="' . htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')) . '"><img' . t3lib_iconWorks::skinImg('', 'gfx/refresh_n.gif') . ' title="' . $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.refresh', 1) . '" alt="" /></a>';
 
+                       // CSH
+               $buttons['csh'] = str_replace('typo3-csh-inline','typo3-csh-inline show-right',t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH']));
 
+               return $buttons;
+       }
 
+       /**
+        * Create the workspace information
+        *
+        * @return      string  HTML containing workspace info
+        */
+       private function getWorkspaceInfo() {
+               global $LANG;
 
+               if ($GLOBALS['BE_USER']->workspace!==0 || $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.onlineWorkspaceInfo'))  {
+                       switch($GLOBALS['BE_USER']->workspace)  {
+                               case 0:
+                                       $wsTitle = '&nbsp;'.$this->doc->icons(2).'['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_onlineWS',1).']';
+                               break;
+                               case -1:
+                                       $wsTitle = '['.$LANG->sL('LLL:EXT:lang/locallang_misc.xml:shortcut_offlineWS',1).']';
+                               break;
+                               default:
+                                       $wsTitle = '['.$GLOBALS['BE_USER']->workspace.'] '.htmlspecialchars($GLOBALS['BE_USER']->workspaceRec['title']);
+                               break;
+                       }
 
+                       $workspaceInfo = '
+                               <div class="bgColor4 workspace-info">
+                                       <a href="'.htmlspecialchars('mod/user/ws/index.php').'" target="content">'.
+                                       '<img'.t3lib_iconWorks::skinImg('','gfx/i/sys_workspace.png','width="18" height="16"').' align="top" alt="" />'.
+                                       '</a>'.$wsTitle.'
+                               </div>
+                       ';
+               }
 
+               return $workspaceInfo;
+       }
 
 
        /**********************************
@@ -440,6 +345,7 @@ class SC_alt_db_navframe {
                }
        }
 
+
        /**
         * Setting temporary page id as DB mount
         *
@@ -447,33 +353,51 @@ class SC_alt_db_navframe {
         * @return      void
         */
        function settingTemporaryMountPoint($pageId)    {
-               global $BE_USER;
+               $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint',intval($pageId));
+       }
+
+
+       /**********************************
+        *
+        * AJAX Calls
+        *
+        **********************************/
 
-                       // Setting temporary mount point ID:
-               $BE_USER->setAndSaveSessionData('pageTree_temporaryMountPoint',intval($pageId));
+       /**
+        * Makes the AJAX call to expand or collapse the pagetree.
+        * Called by typo3/ajax.php
+        *
+        * @param       array           $params: additional parameters (not used here)
+        * @param       TYPO3AJAX       &$ajaxObj: reference of the TYPO3AJAX object of this request
+        * @return      void
+        */
+       public function ajaxExpandCollapse($params, &$ajaxObj) {
+               global $LANG;
+
+               $this->init();
+               $tree = $this->pagetree->getBrowsableTree();
+               if (!$this->pagetree->ajaxStatus) {
+                       $ajaxObj->setError($tree);
+               } else  {
+                       $ajaxObj->addContent('tree', $tree);
+               }
        }
 }
 
+
 // Include extension?
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php'])      {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_db_navframe.php']);
 }
 
 
-
-
-
-
-
-
-
-
-
-
-// Make instance:
-$SOBE = t3lib_div::makeInstance('SC_alt_db_navframe');
-$SOBE->init();
-$SOBE->main();
-$SOBE->printContent();
+// Make instance if it is not an AJAX call
+if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX)) {
+       $SOBE = t3lib_div::makeInstance('SC_alt_db_navframe');
+       $SOBE->init();
+       $SOBE->initPage();
+       $SOBE->main();
+       $SOBE->printContent();
+}
 
 ?>