Fixed bug 4814: Umlauts error in AJAX Pagetree
authorOliver Hader <oliver.hader@typo3.org>
Fri, 26 Jan 2007 07:12:35 +0000 (07:12 +0000)
committerOliver Hader <oliver.hader@typo3.org>
Fri, 26 Jan 2007 07:12:35 +0000 (07:12 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@1944 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/alt_db_navframe.php
typo3/alt_file_navframe.php

index 5ff4f0f..af4b549 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-01-26  Oliver Hader  <oh@inpublica.de>
+
+       * Fixed bug 4814: Umlauts error in AJAX Pagetree
+
 2007-01-25  Ingmar Schlecht  <ingmar@typo3.org>
 
        * Added backwards compatibility to Pagetree for non AJAX-capable browsers (by Benjamin Mack)
index 1b3c4d5..a2d5439 100755 (executable)
@@ -72,8 +72,10 @@ class SC_alt_db_navframe {
        var $pagetree;
        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,13 +88,16 @@ class SC_alt_db_navframe {
        function init() {
                global $BE_USER,$BACK_PATH;
 
+                       // Setting backPath
+               $this->backPath = $BACK_PATH;
+               $this->doc->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');
@@ -106,55 +111,52 @@ class SC_alt_db_navframe {
                $this->pagetree->addField('nav_hide');
                $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;
-
-                       // Create template object:
-               $this->doc = t3lib_div::makeInstance('template');
-               $this->doc->docType = 'xhtml_trans';
-
-                       // Setting backPath
-               $this->doc->backPath = $BACK_PATH;
-
-
-                       // 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";
-
-               $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;
-
-                       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;
+                       // 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') && $BE_USER->workspace===0;
+
+                               // Create template object:
+                       $this->doc = t3lib_div::makeInstance('template');
+                       $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.'prototype.js"></script>
+                       <script type="text/javascript" src="'.$this->backPath.'tree.js"></script>'."\n";
+
+                       $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;
+
+                               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'],'');":'').'
+                       ');
+
+                               // Click menu code is added:
+                       $CMparts=$this->doc->getContextMenuCode();
+                       $this->doc->bodyTagAdditions = $CMparts[1];
+                       $this->doc->JScode.= $CMparts[0];
+                       $this->doc->postCode.= $CMparts[2];
                }
-               '.($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 +171,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;
                }
 
@@ -226,11 +228,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 +244,11 @@ 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('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);
                }
index 40bce6f..4fd3b22 100755 (executable)
@@ -73,8 +73,10 @@ class SC_alt_file_navframe {
        var $content;           // Content accumulates in this variable.
        var $foldertree;        // Folder tree object.
        var $doc;                       // Template object.
+       var $backPath;
 
                // Internal, static: GPvar:
+       var $ajax;                                                      // Is set, if an AJAX call should be handled.
        var $currentSubScript;
        var $cMR;
 
@@ -87,7 +89,12 @@ class SC_alt_file_navframe {
        function init() {
                global $BE_USER,$BACK_PATH,$CLIENT;
 
+                       // Setting backPath
+               $this->backPath = $BACK_PATH;
+               $this->doc->backPath = $BACK_PATH;
+
                        // Setting GPvars:
+               $this->ajax = t3lib_div::_GP('ajax');
                $this->currentSubScript = t3lib_div::_GP('currentSubScript');
                $this->cMR = t3lib_div::_GP('cMR');
 
@@ -96,51 +103,51 @@ class SC_alt_file_navframe {
                $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;
-
-                       // 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";
-
-                       // 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;
+                       // 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';
+
+                               // Adding javascript code for AJAX (prototype), drag&drop and the pagetree
+                       $this->doc->JScode  = '
+                       <script type="text/javascript" src="'.$this->backPath.'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:
+                       $CMparts=$this->doc->getContextMenuCode();
+                       $this->doc->bodyTagAdditions = $CMparts[1];
+                       $this->doc->JScode.= $CMparts[0];
+                       $this->doc->postCode.= $CMparts[2];
                }
-               '.($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];
        }
 
        /**
@@ -154,9 +161,9 @@ class SC_alt_file_navframe {
                        // Produce browse-tree:
                $tree = $this->foldertree->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;
                }
 
@@ -191,7 +198,11 @@ class SC_alt_file_navframe {
         * @return      void
         */
        function printContent() {
-               if (!t3lib_div::_GP('ajax')) {
+                       // If we handle an AJAX call, send headers:
+               if ($this->ajax) {
+                       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);
                }