Added the media field for page type "Shortcut" as well
[Packages/TYPO3.CMS.git] / typo3 / alt_file_navframe.php
index d351d2b..c8ebef1 100755 (executable)
  *
  *
  *
- *   68: class SC_alt_file_navframe
- *   85:     function init()
- *  168:     function main()
- *  199:     function printContent()
+ *   72: class localFolderTree extends t3lib_folderTree
+ *   81:     function localFolderTree()
+ *   92:     function wrapIcon($icon,&$row)
+ *  121:     function wrapTitle($title,$row,$bank=0)
  *
- * TOTAL FUNCTIONS: 3
+ *
+ *  146: class SC_alt_file_navframe
+ *  163:     function init()
+ *  253:     function main()
+ *  284:     function printContent()
+ *
+ * TOTAL FUNCTIONS: 6
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
 
-
-$BACK_PATH='';
-require ('init.php');
-require ('template.php');
-require_once (PATH_t3lib.'class.t3lib_foldertree.php');
-
-
-
+$BACK_PATH = '';
+require('init.php');
+require('template.php');
+require_once('class.filelistfoldertree.php');
 
 
 /**
@@ -70,9 +72,17 @@ class SC_alt_file_navframe {
                // Internal, dynamic:
        var $content;           // Content accumulates in this variable.
        var $foldertree;        // Folder tree object.
-       var $doc;                       // Template object.
+
+       /**
+        * document template object
+        *
+        * @var template
+        */
+       var $doc;
+       var $backPath;
 
                // Internal, static: GPvar:
+       var $ajax;                                                      // Is set, if an AJAX call should be handled.
        var $currentSubScript;
        var $cMR;
 
@@ -85,79 +95,62 @@ class SC_alt_file_navframe {
        function init() {
                global $BE_USER,$BACK_PATH,$CLIENT;
 
+                       // Setting backPath
+               $this->backPath = $BACK_PATH;
+
                        // Setting GPvars:
+               $this->ajax = t3lib_div::_GP('ajax');
                $this->currentSubScript = t3lib_div::_GP('currentSubScript');
                $this->cMR = t3lib_div::_GP('cMR');
 
                        // Create folder tree object:
-               $this->foldertree = t3lib_div::makeInstance('t3lib_folderTree');
+               $this->foldertree = t3lib_div::makeInstance('filelistFolderTree');
                $this->foldertree->ext_IconMode = $BE_USER->getTSConfigVal('options.folderTree.disableIconLinkToContextmenu');
                $this->foldertree->thisScript = 'alt_file_navframe.php';
 
-                       // 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';
-
-                       // Setting backPath
-               $this->doc->backPath = $BACK_PATH;
-
-                       // Setting JavaScript for menu.
-               $this->doc->JScode=$this->doc->wrapScriptTags(
-       ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
-
-               // Function, loading the list frame from navigation tree:
-       function jumpTo(id,linkObj,highLightID) {       //
-               var theUrl = top.TS.PATH_typo3+top.currentSubScript+"?id="+id;
-
-               if (top.condensedMode)  {
-                       top.content.document.location=theUrl;
-               } else {
-                       parent.list_frame.document.location=theUrl;
+                       // 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->backPath = $BACK_PATH;
+                       $this->doc->docType = 'xhtml_trans';
+
+                               // Adding javascript code for AJAX (prototype), drag&drop and the pagetree
+                       $this->doc->JScode  = '
+                       <script type="text/javascript" src="'.$this->backPath.'contrib/prototype/prototype.js"></script>
+                       <script type="text/javascript" src="'.$this->backPath.'tree.js"></script>'."\n";
+
+                               // Setting JavaScript for menu.
+                       $this->doc->JScode .= $this->doc->wrapScriptTags(
+                       ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').'
+
+                       // setting prefs for pagetree and drag & drop
+                       Tree.thisScript    = "'.$this->foldertree->thisScript.'";
+                       DragDrop.changeURL = "'.$this->backPath.'alt_clickmenu.php";
+                       DragDrop.backPath  = "'.t3lib_div::shortMD5(''.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']).'";
+                       DragDrop.table     = "folders";
+
+                       // 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 ? 'Tree.highlightActiveItem("file", highlightID + "_" + bank);' : '').'
+                               '.(!$GLOBALS['CLIENT']['FORMSTYLE'] ? '' : 'if (linkObj) linkObj.blur(); ').'
+                               return false;
+                       }
+                       '.($this->cMR ? " jumpTo(top.fsMod.recentIds['file'],'');" : '')
+                       );
+
+                               // Click menu code is added:
+                       $this->doc->getContextMenuCode();
                }
-
-        '.($this->doHighlight?'hilight_row("file",highLightID);':'').'
-               '.(!$CLIENT['FORMSTYLE'] ? '' : 'if (linkObj) {linkObj.blur();}').'
-               return false;
-       }
-
-
-               // 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() {       //
-               document.location="'.$this->pagetree->thisScript.'?unique='.time().'";
-       }
-
-               // Highlighting rows in the folder tree:
-       function hilight_row(frameSetModule,highLightID) {      //
-
-                       // Remove old:
-               theObj = document.getElementById(top.fsMod.navFrameHighlightedID[frameSetModule]);
-               if (theObj)     {
-                       theObj.style.backgroundColor="";
-               }
-
-                       // Set new:
-               top.fsMod.navFrameHighlightedID[frameSetModule] = highLightID;
-               theObj = document.getElementById(highLightID);
-               if (theObj)     {
-                       theObj.style.backgroundColor="'.t3lib_div::modifyHTMLColorAll($this->doc->bgColor,-20).'";
-               }
-       }
-
-       '.($this->cMR?"jumpTo(top.fsMod.recentIds['file'],'');":'').';
-               ');
-
-                       // Click menu code is added:
-               $CMparts=$this->doc->getContextMenuCode();
-               $this->doc->bodyTagAdditions = $CMparts[1];
-               $this->doc->JScode.=$CMparts[0];
-               $this->doc->postCode.= $CMparts[2];
        }
 
        /**
@@ -171,24 +164,35 @@ class SC_alt_file_navframe {
                        // Produce browse-tree:
                $tree = $this->foldertree->getBrowsableTree();
 
-               $this->content = '';
-               $this->content.= $this->doc->startPage('Folder tree');
+                       // Output only the tree if this is an AJAX call:
+               if ($this->ajax) {
+                       $this->content = $LANG->csConvObj->utf8_encode($tree, $LANG->charSet);
+                       return;
+               }
+
+               $this->content = $this->doc->startPage('TYPO3 Folder Tree');
+
+                       // Outputting page tree:
                $this->content.= $tree;
-               $refreshUrl = t3lib_div::getIndpEnv('REQUEST_URI');
+
+                       // Outputting refresh-link
                $this->content.= '
                        <p class="c-refresh">
-                               <a href="'.htmlspecialchars($refreshUrl).'">'.
+                               <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><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', 'filetree', $GLOBALS['BACK_PATH']);
 
-                       // Adding highlight - JavaScript
-               if ($this->doHighlight) $this->content .=$this->doc->wrapScriptTags('
-                       hilight_row("",top.fsMod.navFrameHighlightedID["file"]);
-               ');
+                       // Adding javascript for drag & drop activation and highlighting
+               $this->content .=$this->doc->wrapScriptTags('
+                       '.($this->doHighlight ? 'Tree.highlightActiveItem("", top.fsMod.navFrameHighlightedID["file"]);' : '').'
+                       '.(!$this->doc->isCMlayers() ? 'Tree.activateDragDrop = false;' : 'Tree.registerDragDropHandlers();')
+               );
+
        }
 
        /**
@@ -197,7 +201,15 @@ class SC_alt_file_navframe {
         * @return      void
         */
        function printContent() {
-               $this->content.= $this->doc->endPage();
+                       // If we handle an AJAX call, send headers:
+               if ($this->ajax) {
+                       header('X-JSON: ('.($this->foldertree->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);
+               }
                echo $this->content;
        }
 }