Fixed bug 5701: linkHandler Hook Not Initialized Properly, patch supplied by Jeff...
[Packages/TYPO3.CMS.git] / typo3 / wizard_rte.php
index 7172d3d..b18ce39 100755 (executable)
@@ -41,8 +41,8 @@
  *   81: class SC_wizard_rte
  *   99:     function init()
  *  123:     function main()
- *  279:     function printContent()
- *  290:     function checkEditAccess($table,$uid)
+ *  285:     function printContent()
+ *  298:     function checkEditAccess($table,$uid)
  *
  * TOTAL FUNCTIONS: 4
  * (This index is automatically created/updated by the extension "extdeveval")
@@ -81,7 +81,12 @@ t3lib_BEfunc::lockRecords();
 class SC_wizard_rte {
 
                // Internal, dynamic:
-       var $doc;                                       // Document template object
+       /**
+        * document template object
+        *
+        * @var mediumDoc
+        */
+       var $doc;
        var $content;                           // Content accumulation for the module.
 
                // Internal, static: GPvars
@@ -110,7 +115,7 @@ class SC_wizard_rte {
                $this->doc = t3lib_div::makeInstance('mediumDoc');
                $this->doc->docType = 'xhtml_trans';
                $this->doc->divClass = '';      // Need to NOT have the page wrapped in DIV since if we do that we destroy the feature that the RTE spans the whole height of the page!!!
-               $this->doc->form='<form action="tce_db.php" method="post" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'" name="editform" onsubmit="return TBE_EDITOR_checkSubmit(1);">';
+               $this->doc->form='<form action="tce_db.php" method="post" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'" name="editform" onsubmit="return TBE_EDITOR.checkSubmit(1);">';
                $this->doc->backPath = $BACK_PATH;
 
        }
@@ -123,22 +128,28 @@ class SC_wizard_rte {
        function main() {
                global $BE_USER,$LANG;
 
+                       // translate id to the workspace version:
+               if ($versionRec = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $this->P['table'], $this->P['uid'], 'uid')) {
+                       $this->P['uid'] = $versionRec['uid'];
+               }
+
                        // If all parameters are available:
                if ($this->P['table'] && $this->P['field'] && $this->P['uid'] && $this->checkEditAccess($this->P['table'],$this->P['uid']))     {
 
                                // Getting the raw record (we need only the pid-value from here...)
                        $rawRec = t3lib_BEfunc::getRecord($this->P['table'],$this->P['uid']);
+                       t3lib_BEfunc::fixVersioningPid($this->P['table'], $rawRec);
 
                                // Setting JavaScript, including the pid value for viewing:
                        $this->doc->JScode = $this->doc->wrapScriptTags('
                                        function jumpToUrl(URL,formEl)  {       //
                                                if (document.editform)  {
-                                                       if (!TBE_EDITOR_isFormChanged())        {
-                                                               document.location = URL;
+                                                       if (!TBE_EDITOR.isFormChanged())        {
+                                                               window.location.href = URL;
                                                        } else if (formEl) {
                                                                if (formEl.type=="checkbox") formEl.checked = formEl.checked ? 0 : 1;
                                                        }
-                                               } else document.location = URL;
+                                               } else window.location.href = URL;
                                        }
                                '.($this->popView ? t3lib_BEfunc::viewOnClick($rawRec['pid'],'',t3lib_BEfunc::BEgetRootLine($rawRec['pid'])) : '').'
                        ');
@@ -195,19 +206,19 @@ class SC_wizard_rte {
 
                                // Save:
                        $toolBarButtons[]=
-                               '<a href="#" onclick="TBE_EDITOR_checkAndDoSubmit(1); return false;">'.
+                               '<a href="#" onclick="TBE_EDITOR.checkAndDoSubmit(1); return false;">'.
                                '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/savedok.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc',1).'" alt="" />'.
                                '</a>';
 
                                // Save/View:
                        if (t3lib_extMgm::isLoaded('cms'))      {
                                $toolBarButtons[]=
-                                       '<a href="#" onclick="'.htmlspecialchars('document.editform.redirect.value+=\'&popView=1\'; TBE_EDITOR_checkAndDoSubmit(1); return false;').'">'.
+                                       '<a href="#" onclick="'.htmlspecialchars('document.editform.redirect.value+=\'&popView=1\'; TBE_EDITOR.checkAndDoSubmit(1); return false;').'">'.
                                        '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/savedokshow.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveDocShow',1).'" alt="" />'.
                                        '</a>';
                        }
                                // Save/Close:
-                       $toolBarButtons[] = '<input type="image" class="c-inputButton" onclick="'.htmlspecialchars('document.editform.redirect.value=\''.$closeUrl.'\'; TBE_EDITOR_checkAndDoSubmit(1); return false;').'" name="_saveandclosedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/saveandclosedok.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc',1).'" />';
+                       $toolBarButtons[] = '<input type="image" class="c-inputButton" onclick="'.htmlspecialchars('document.editform.redirect.value=\''.$closeUrl.'\'; TBE_EDITOR.checkAndDoSubmit(1); return false;').'" name="_saveandclosedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/saveandclosedok.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc',1).'" />';
                                // Close:
                        $toolBarButtons[]=
                                        '<a href="#" onclick="'.htmlspecialchars('jumpToUrl(unescape(\''.rawurlencode($closeUrl).'\')); return false;').'">'.
@@ -217,7 +228,7 @@ class SC_wizard_rte {
                                // Undo/Revert:
                        if ($undoButton)        {
                                $toolBarButtons[]=
-                                       '<a href="#" onclick="'.htmlspecialchars('document.location=\'show_rechis.php?element='.rawurlencode($this->P['table'].':'.$this->P['uid']).'&revert='.rawurlencode('field:'.$this->P['field']).'&sumUp=-1&returnUrl='.rawurlencode($R_URI).'\'; return false;').'">'.
+                                       '<a href="#" onclick="'.htmlspecialchars('window.location.href=\'show_rechis.php?element='.rawurlencode($this->P['table'].':'.$this->P['uid']).'&revert='.rawurlencode('field:'.$this->P['field']).'&sumUp=-1&returnUrl='.rawurlencode($R_URI).'\'; return false;').'">'.
                                        '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/undo.gif','width="21" height="16"').' class="c-inputButton" title="'.htmlspecialchars(sprintf($LANG->getLL('rte_undoLastChange'),t3lib_BEfunc::calcAge(time()-$undoButtonR['tstamp'],$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')))).'" alt="" />'.
                                        '</a>';
                        }
@@ -269,8 +280,6 @@ class SC_wizard_rte {
                        $this->content.=$this->doc->section($LANG->getLL('forms_title'),'<span class="typo3-red">'.$LANG->getLL('table_noData',1).'</span>',0,1);
                }
 
-                       // Ending page:
-               $this->content.=$this->doc->endPage();
        }
 
        /**
@@ -279,6 +288,8 @@ class SC_wizard_rte {
         * @return      void
         */
        function printContent() {
+               $this->content.= $this->doc->endPage();
+               $this->content = $this->doc->insertStylesAndJS($this->content);
                echo $this->content;
        }
 
@@ -293,7 +304,7 @@ class SC_wizard_rte {
                global $BE_USER;
 
                $calcPRec = t3lib_BEfunc::getRecord($table,$uid);
-               t3lib_BEfunc::fixVersioningPid($table,$uid);
+               t3lib_BEfunc::fixVersioningPid($table,$calcPRec);
                if (is_array($calcPRec))        {
                        if ($table=='pages')    {       // If pages:
                                $CALC_PERMS = $BE_USER->calcPerms($calcPRec);