(feature/cleanup) Refactored clickmenu to speed up the BE
[Packages/TYPO3.CMS.git] / typo3 / alt_db_navframe.php
index 1b3c4d5..86a9480 100755 (executable)
@@ -70,10 +70,18 @@ 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 $ajax;                                                      // Is set, if an AJAX call should be handled.
        var $currentSubScript;
        var $cMR;
        var $setTempDBmount;                    // If not '' (blank) then it will clear (0) or set (>0) Temporary DB mount.
@@ -86,17 +94,22 @@ 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->ajax = t3lib_div::_GP('ajax');
                $this->cMR = t3lib_div::_GP('cMR');
+               $this->currentSubScript = t3lib_div::_GP('currentSubScript');
                $this->setTempDBmount = t3lib_div::_GP('setTempDBmount');
 
-
                        // Create page tree object:
                $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');
@@ -104,57 +117,61 @@ 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();
 
-                       // Setting highlight mode:
-               $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight') && $BE_USER->workspace===0;
+                       // Use template rendering only if this is a non-AJAX call:
+               if (!$this->ajax) {
+                               // Setting highlight mode:
+                       $this->doHighlight = !$BE_USER->getTSConfigVal('options.pageTree.disableTitleHighlight');
 
-                       // Create template object:
-               $this->doc = t3lib_div::makeInstance('template');
-               $this->doc->docType = 'xhtml_trans';
+                               // If highlighting is active, define the CSS class for the active item depending on the workspace
+                       if ($this->doHighlight) {
+                               if ($BE_USER->workspace === 0) $hlClass = 'active';
+                               else $hlClass = 'active active-ws wsver'.$BE_USER->workspace; 
+                       }
 
-                       // Setting backPath
-               $this->doc->backPath = $BACK_PATH;
+                               // Create template object:
+                       $this->doc = t3lib_div::makeInstance('template');
+                       $this->doc->backPath = $BACK_PATH;
+                       $this->doc->docType = 'xhtml_trans';
+
+                               // Adding javascript code for AJAX (prototype), drag&drop and the pagetree
+                       $this->doc->loadJavascriptLib('contrib/prototype/prototype.js');
+                       $this->doc->loadJavascriptLib('tree.js');
 
+                       $this->doc->JScode .= $this->doc->wrapScriptTags(
+                       ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
+                       // setting prefs for pagetree and drag & drop
+                       Tree.thisScript    = "'.$this->pagetree->thisScript.'";
+                       '.($this->doHighlight ? 'Tree.highlightClass = "'.$hlClass.'";' : '').'
 
-                       // Adding javascript code for AJAX (prototype), drag&drop and the pagetree
-               $this->doc->JScode  = '
-               <script type="text/javascript" src="prototype.js"></script>
-               <script type="text/javascript" src="tree.js"></script>'."\n";
+                       DragDrop.changeURL = "'.$this->backPath.'alt_clickmenu.php";
+                       DragDrop.backPath  = "'.t3lib_div::shortMD5(''.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']).'";
+                       DragDrop.table     = "pages";
 
-               $this->doc->JScode .= $this->doc->wrapScriptTags(
-               ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
-               // setting prefs for pagetree and drag & drop
-               Tree.thisScript    = "'.$this->pagetree->thisScript.'";
-               DragDrop.changeURL = "'.$this->backPath.'alt_clickmenu.php";
-               DragDrop.backPath  = "'.t3lib_div::shortMD5(''.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']).'";
-               DragDrop.table     = "pages";
+                       // 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;
 
-               // 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;
 
-                       if (top.condensedMode) top.content.location.href = theUrl;
-                       else                   parent.list_frame.location.href=theUrl;
+                               '.($this->doHighlight ? 'Tree.highlightActiveItem("web", highlightID + "_" + bank);' : '').'
+                               '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) linkObj.blur(); ').'
+                               return false;
+                       }
+                       '.($this->cMR?"jumpTo(top.fsMod.recentIds['web'],'');":'').'
+                       ');
 
-                       '.($this->doHighlight ? 'Tree.highlightActiveItem("web", highlightID + "_" + bank);' : '').'
-                       '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) linkObj.blur(); ').'
-                       return false;
+                               // Click menu code is added:
+                       $this->doc->getContextMenuCode();
+                       $this->doc->bodyTagId = 'bodyTag';
                }
-               '.($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];
        }
 
 
@@ -169,9 +186,9 @@ class SC_alt_db_navframe {
                        // Produce browse-tree:
                $tree = $this->pagetree->getBrowsableTree();
 
-                       // output only the tree if this is an ajax call
-               if (t3lib_div::_GP('ajax')) {
-                       $this->content = $tree;
+                       // Output only the tree if this is an AJAX call:
+               if ($this->ajax) {
+                       $this->content = $LANG->csConvObj->utf8_encode($tree, $LANG->charSet);
                        return;
                }
 
@@ -201,6 +218,14 @@ class SC_alt_db_navframe {
                        ';
                }
 
+               if (!$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.hideFilter'))        {
+                       $this->content.= '
+                                       <div class="bgColor4">
+                                               Filter: <input type="text" value="" name="_livesearch" id="_livesearch" onkeyup="filter(this.value);"/>
+                                       </div><br>
+                       ';
+               }
+
                        // Outputting Temporary DB mount notice:
                if ($this->active_tempMountPoint)       {
                        $this->content.= '
@@ -226,11 +251,9 @@ class SC_alt_db_navframe {
                        </p>
                        <br />';
 
-
                        // CSH icon:
                $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH']);
 
-
                        // Adding javascript for drag & drop activation and highlighting
                $this->content .=$this->doc->wrapScriptTags('
                        '.($this->doHighlight ? 'Tree.highlightActiveItem("",top.fsMod.navFrameHighlightedID["web"]);' : '').'
@@ -244,7 +267,12 @@ class SC_alt_db_navframe {
         * @return      void
         */
        function printContent() {
-               if (!t3lib_div::_GP('ajax')) {
+                       // If we handle an AJAX call, send headers:
+               if ($this->ajax) {
+                       header('X-JSON: ('.($this->pagetree->ajaxStatus?'true':'false').')');
+                       header('Content-type: text/html; charset=utf-8');
+                       // If it's the regular call to fully output the tree:
+               } else {
                        $this->content.= $this->doc->endPage();
                        $this->content = $this->doc->insertStylesAndJS($this->content);
                }
@@ -325,4 +353,4 @@ $SOBE->init();
 $SOBE->main();
 $SOBE->printContent();
 
-?>
\ No newline at end of file
+?>