[BUGFIX] Pootle: Multi-line labels are not rendered properly
[Packages/TYPO3.CMS.git] / typo3 / wizard_rte.php
old mode 100755 (executable)
new mode 100644 (file)
index 22c430f..348765e
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
 /**
  * Wizard to display the RTE in "full screen" mode
  *
- * $Id$
- * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
+ * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
  * XHTML compliant
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
- */
-/**
- * [CLASS/FUNCTION INDEX of SCRIPT]
- *
- *
- *
- *   81: class SC_wizard_rte
- *   99:     function init()
- *  123:     function main()
- *  285:     function printContent()
- *  298:     function checkEditAccess($table,$uid)
- *
- * TOTAL FUNCTIONS: 4
- * (This index is automatically created/updated by the extension "extdeveval")
- *
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  */
 
 
 $BACK_PATH='';
 require ('init.php');
 require ('template.php');
-$LANG->includeLLFile('EXT:lang/locallang_wizards.xml');
-require_once (PATH_t3lib.'class.t3lib_tceforms.php');
-require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
-require_once (PATH_t3lib.'class.t3lib_transferdata.php');
+$GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_wizards.xml');
 
 t3lib_BEfunc::lockRecords();
 
@@ -74,7 +55,7 @@ t3lib_BEfunc::lockRecords();
 /**
  * Script Class for rendering the full screen RTE display
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
@@ -92,6 +73,7 @@ class SC_wizard_rte {
                // Internal, static: GPvars
        var $P;                                         // Wizard parameters, coming from TCEforms linking to the wizard.
        var $popView;                           // If set, launch a new window with the current records pid.
+       var $R_URI;                                     // Set to the URL of this script including variables which is needed to re-display the form. See main()
 
 
 
@@ -105,6 +87,7 @@ class SC_wizard_rte {
                        // Setting GPvars:
                $this->P = t3lib_div::_GP('P');
                $this->popView = t3lib_div::_GP('popView');
+               $this->R_URI = t3lib_div::linkThisScript(array('popView' => ''));
 
                        // "Module name":
                $this->MCONF['name']='xMOD_wizard_rte.php';
@@ -123,8 +106,6 @@ class SC_wizard_rte {
         * @return      void
         */
        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'];
@@ -158,7 +139,7 @@ class SC_wizard_rte {
                        $tceforms->colorScheme[0]=$this->doc->bgColor;  // SPECIAL: Setting background color of the RTE to ordinary background
 
                                // Initialize style for RTE object:
-                       $RTEobj = &t3lib_BEfunc::RTEgetObj();   // Getting reference to the RTE object used to render the field!
+                       $RTEobj = t3lib_BEfunc::RTEgetObj();    // Getting reference to the RTE object used to render the field!
                        if ($RTEobj->ID == 'rte')       {
                                $RTEobj->RTEdivStyle = 'position:relative; left:0px; top:0px; height:100%; width:100%; border:solid 0px;';      // SPECIAL: Setting style for the RTE <DIV> layer containing the IFRAME
                        }
@@ -169,8 +150,7 @@ class SC_wizard_rte {
                        $trData->fetchRecord($this->P['table'],$this->P['uid'],'');
 
                                // Getting the processed record content out:
-                       reset($trData->regTableItems_data);
-                       $rec = current($trData->regTableItems_data);
+                       $rec = reset($trData->regTableItems_data);
                        $rec['uid'] = $this->P['uid'];
                        $rec['pid'] = $rawRec['pid'];
 
@@ -179,7 +159,7 @@ class SC_wizard_rte {
                        if (strcmp($fieldTSConfig['RTEfullScreenWidth'],''))    {
                                $width=$fieldTSConfig['RTEfullScreenWidth'];
                        } else {
-                               $width='500';
+                               $width='100%';
                        }
 
                                // Get the form field and wrap it in the table with the buttons:
@@ -198,8 +178,9 @@ class SC_wizard_rte {
                                </table>';
 
                                // Adding hidden fields:
-                       $formContent.= '<input type="hidden" name="redirect" value="'.htmlspecialchars($R_URI).'" />
-                                               <input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />';
+                       $formContent.= '<input type="hidden" name="redirect" value="'.htmlspecialchars($this->R_URI).'" />
+                                               <input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />' .
+                                               t3lib_TCEforms::getHiddenTokenField('tceAction');
 
 
                                // Finally, add the whole setup:
@@ -209,7 +190,7 @@ class SC_wizard_rte {
                                $tceforms->printNeededJSFunctions();
                } else {
                                // ERROR:
-                       $this->content.=$this->doc->section($LANG->getLL('forms_title'),'<span class="typo3-red">'.$LANG->getLL('table_noData',1).'</span>',0,1);
+                       $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('forms_title'),'<span class="typo3-red">'.$GLOBALS['LANG']->getLL('table_noData',1).'</span>',0,1);
                }
 
                // Setting up the buttons and markers for docheader
@@ -251,8 +232,7 @@ class SC_wizard_rte {
                );
 
                if ($this->P['table'] && $this->P['field'] && $this->P['uid'] && $this->checkEditAccess($this->P['table'],$this->P['uid'])) {
-                       $closeUrl = $this->P['returnUrl'];
-                       $R_URI=t3lib_div::linkThisScript(array('popView' => ''));
+                       $closeUrl = t3lib_div::sanitizeLocalUrl($this->P['returnUrl']);
 
                        // Getting settings for the undo button:
                        $undoButton = 0;
@@ -283,8 +263,8 @@ class SC_wizard_rte {
 
                        // Undo/Revert:
                        if ($undoButton)        {
-                               $buttons['undo'] = '<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') . ' class="c-inputButton" title="' . htmlspecialchars(sprintf($GLOBALS['LANG']->getLL('rte_undoLastChange'), t3lib_BEfunc::calcAge(time() - $undoButtonR['tstamp'], $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')))) . '" alt="" />' .
+                               $buttons['undo'] = '<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($this->R_URI) . '\'; return false;') . '">' .
+                                       '<img' . t3lib_iconWorks::skinImg($this->doc->backPath, 'gfx/undo.gif') . ' class="c-inputButton" title="' . htmlspecialchars(sprintf($GLOBALS['LANG']->getLL('rte_undoLastChange'), t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $undoButtonR['tstamp'], $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')))) . '" alt="" />' .
                                        '</a>';
                        }
 
@@ -305,22 +285,21 @@ class SC_wizard_rte {
         * @return      void
         */
        function checkEditAccess($table,$uid)   {
-               global $BE_USER;
-
                $calcPRec = t3lib_BEfunc::getRecord($table,$uid);
                t3lib_BEfunc::fixVersioningPid($table,$calcPRec);
                if (is_array($calcPRec))        {
                        if ($table=='pages')    {       // If pages:
-                               $CALC_PERMS = $BE_USER->calcPerms($calcPRec);
+                               $CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($calcPRec);
                                $hasAccess = $CALC_PERMS&2 ? TRUE : FALSE;
                        } else {
-                               $CALC_PERMS = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',$calcPRec['pid']));   // Fetching pid-record first.
+                                       // Fetching pid-record first.
+                               $CALC_PERMS = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$calcPRec['pid']));
                                $hasAccess = $CALC_PERMS&16 ? TRUE : FALSE;
                        }
 
                                // Check internals regarding access:
                        if ($hasAccess) {
-                               $hasAccess = $BE_USER->recordEditAccessInternals($table, $calcPRec);
+                               $hasAccess = $GLOBALS['BE_USER']->recordEditAccessInternals($table, $calcPRec);
                        }
                } else $hasAccess = FALSE;
 
@@ -328,19 +307,10 @@ class SC_wizard_rte {
        }
 }
 
-// Include extension?
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_rte.php'])   {
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_rte.php']);
-}
-
-
-
-
-
-
-
-
 
+if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/wizard_rte.php'])) {
+       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/wizard_rte.php']);
+}