Follow-up to #12381: Scheduler: BLOB database fields may not be NOT NULL
[Packages/TYPO3.CMS.git] / typo3 / alt_db_navframe.php
old mode 100755 (executable)
new mode 100644 (file)
index ae6638f..1edf306
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -85,6 +85,8 @@ class SC_alt_db_navframe {
        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
@@ -102,6 +104,9 @@ class SC_alt_db_navframe {
                $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('webPageTree');
                $this->pagetree->ext_IconMode = $BE_USER->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu');
@@ -144,13 +149,16 @@ class SC_alt_db_navframe {
                        // Create template object:
                $this->doc = t3lib_div::makeInstance('template');
                $this->doc->backPath = $BACK_PATH;
-               $this->doc->docType  = 'xhtml_trans';
+               $this->doc->setModuleTemplate('templates/alt_db_navframe.html');
+               $this->doc->showFlashMessages = FALSE;
+
+                       // get HTML-Template
 
 
                        // 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->getPageRenderer()->loadScriptaculous('effects');
 
                $this->doc->JScode .= $this->doc->wrapScriptTags(
                ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
@@ -159,22 +167,27 @@ class SC_alt_db_navframe {
 
                // Function, loading the list frame from navigation tree:
                function jumpTo(id, linkObj, highlightID, bank) { //
-                       var theUrl = top.TS.PATH_typo3 + top.currentSubScript + "?id=" + id;
+                       var theUrl = top.TS.PATH_typo3 + top.currentSubScript ;
+                       if (theUrl.indexOf("?") != -1) {
+                               theUrl += "&id=" + id
+                       } else {
+                               theUrl += "?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->cMR?"jumpTo(top.fsMod.recentIds['web'],'');":'').
 
-                       Event.observe(window, "load", function() {
-                               Event.observe(PageTreeFilter.field, "keyup", PageTreeFilter.filter.bindAsEventListener(PageTreeFilter));
-                               Event.observe(PageTreeFilter.resetfield, "click", PageTreeFilter.resetSearchField.bindAsEventListener(PageTreeFilter) );
-                       });
+                       ($this->hasFilterBox ? 'var TYPO3PageTreeFilter = new PageTreeFilter();' : '') . '
 
                ');
 
@@ -193,52 +206,6 @@ class SC_alt_db_navframe {
                        // Produce browse-tree:
                $tree = $this->pagetree->getBrowsableTree();
 
-                       // Start page:
-               $this->content = $this->doc->startPage('TYPO3 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 = ' '.$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>
-                       ';
-               }
-
-                       // adding tree options
-                       $this->content .= '
-       <div id="treeOptions">';
-               if (!$GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.hideFilter'))        {
-                       $this->content .= '
-               <div id="treeFilterBox">
-                       <input type="text" value="" name="treeFilter" id="treeFilter" />
-                       <img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/search_reset.png', ' width="11" height="11"').' id="treeFilterReset" alt="Reset Filter" />
-               </div>';
-
-               }
-
-               $this->content .= '
-               <div id="treeOptionButtons">
-                       <a href="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'"><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>'.
-                               // CSH icon:
-                       t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'pagetree', $GLOBALS['BACK_PATH']).'
-               </div>
-       </div>';
-
 
                        // Outputting Temporary DB mount notice:
                if ($this->active_tempMountPoint)       {
@@ -246,22 +213,42 @@ class SC_alt_db_navframe {
        <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>
+               $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;
+               $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="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter') . '" ' .
+                       'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.resetFilter') . '" />',
+                       'WORKSPACEINFO' => $this->getWorkspaceInfo(),
+                       'CONTENT'       => $this->content
+               );
+               $subparts = array();
+
+               if (!$this->hasFilterBox) {
+                       $subparts['###SECOND_ROW###'] = '';
+               }
+                       // Build the <body> for the module
+               $this->content = $this->doc->startPage('TYPO3 Page Tree');
+               $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers, $subparts);
+               $this->content.= $this->doc->endPage();
+
+               $this->content = $this->doc->insertStylesAndJS($this->content);
        }
 
        /**
@@ -270,13 +257,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
+        */
+       protected 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&amp;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'], '', TRUE));
+
+               return $buttons;
+       }
+
+       /**
+        * Create the workspace information
+        *
+        * @return      string  HTML containing workspace info
+        */
+       protected 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;
+       }
 
 
        /**********************************
@@ -341,10 +383,10 @@ class SC_alt_db_navframe {
         * Called by typo3/ajax.php
         *
         * @param       array           $params: additional parameters (not used here)
-        * @param       TYPO3AJAX       &$ajaxObj: reference of the TYPO3AJAX object of this request
+        * @param       TYPO3AJAX       $ajaxObj: The TYPO3AJAX object of this request
         * @return      void
         */
-       public function ajaxExpandCollapse($params, &$ajaxObj) {
+       public function ajaxExpandCollapse($params, $ajaxObj) {
                global $LANG;
 
                $this->init();
@@ -358,7 +400,7 @@ class SC_alt_db_navframe {
 }
 
 
-// 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']);
 }