[BUGFIX] Preview message causes javascript errors
authorJigal van Hemert <jigal@xs4all.nl>
Mon, 17 Oct 2011 20:21:06 +0000 (22:21 +0200)
committerSteffen Ritter <info@rs-websystems.de>
Thu, 3 Nov 2011 17:36:45 +0000 (18:36 +0100)
Placing the preview message just before the closing body tag prevents it from
interfering with the (x)HTML structure.

Change-Id: I029099989678c011ecaf1397ef6932323fbd0d85
Fixes: #30897
Releases: 4.5
Reviewed-on: http://review.typo3.org/5919
Reviewed-by: Georg Ringer
Reviewed-by: Oliver Klee
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
typo3/sysext/cms/tslib/class.tslib_fe.php
typo3/sysext/cms/tslib/index_ts.php

index 48da79d..702533d 100644 (file)
@@ -3870,32 +3870,33 @@ if (version == "n3") {
        }
 
        /**
-        * Outputs preview info.
+        * Generates preview info.
         *
-        * @return      void
+        * @return string Formatted preview message
         */
        function previewInfo()  {
+               $content = '';
                if ($this->fePreview && (!isset($this->config['config']['disablePreviewNotification']) || intval($this->config['config']['disablePreviewNotification']) !== 1)) {
-                               if ($this->fePreview === 2) {
-                                       $onclickForStoppingPreview = 'document.location="'.t3lib_div::getIndpEnv('TYPO3_SITE_URL').'index.php?ADMCMD_prev=LOGOUT&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')).'";return false;';
-                                       $text = 'Preview of workspace "'.$this->whichWorkspace(TRUE).'" ('.$this->whichWorkspace().')';
-                                       $html = $this->doWorkspacePreview() ? '<br/><input name="_" type="submit" value="Stop preview" onclick="'.htmlspecialchars($onclickForStoppingPreview).'" />' : '';
-                               } else {
-                                       $text = 'PREVIEW!';
-                                       $html = '';
-                               }
+                       if ($this->fePreview === 2) {
+                               $onclickForStoppingPreview = 'document.location="' . t3lib_div::getIndpEnv('TYPO3_SITE_URL') . 'index.php?ADMCMD_prev=LOGOUT&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . '";return false;';
+                               $text = 'Preview of workspace "' . $this->whichWorkspace(TRUE) . '" (' . $this->whichWorkspace() . ')';
+                               $html = $this->doWorkspacePreview() ? '<br/><input name="_" type="submit" value="Stop preview" onclick="' . htmlspecialchars($onclickForStoppingPreview) . '" />' : '';
+                       } else {
+                               $text = 'PREVIEW!';
+                               $html = '';
+                       }
 
-                               $stdMsg = '<div id="typo3-previewInfo" style="position: absolute; top: 20px; right: 20px; border: 2px solid #000; padding: 5px 5px; background: #f00; font: 1em Verdana; color: #000; font-weight: bold; z-index: 10001">'.htmlspecialchars($text).$html.'</div>';
+                       $stdMsg = '<div id="typo3-previewInfo" style="position: absolute; top: 20px; right: 20px; border: 2px solid #000; padding: 5px; background: #f00; font: 1em Verdana; color: #000; font-weight: bold; z-index: 10001">' . htmlspecialchars($text) . $html . '</div>';
 
-                               if ($this->fePreview === 2) {
-                                       $temp_content = $this->config['config']['message_preview_workspace'] ?
-                                               @sprintf($this->config['config']['message_preview_workspace'], $this->whichWorkspace(TRUE),$this->whichWorkspace()) :
-                                               $stdMsg;
-                               } else {
-                                       $temp_content = $this->config['config']['message_preview'] ? $this->config['config']['message_preview'] : $stdMsg;
-                               }
-                               echo $temp_content;
+                       if ($this->fePreview === 2) {
+                               $content = $this->config['config']['message_preview_workspace'] ?
+                                       @sprintf($this->config['config']['message_preview_workspace'], $this->whichWorkspace(TRUE),$this->whichWorkspace()) :
+                                       $stdMsg;
+                       } else {
+                               $content = $this->config['config']['message_preview'] ? $this->config['config']['message_preview'] : $stdMsg;
+                       }
                }
+               return $content;
        }
 
        /**
index 6b8d04a..d75cf4f 100644 (file)
@@ -541,7 +541,7 @@ $TSFE->jumpurl();
 // *************
 // Preview info
 // *************
-$TSFE->previewInfo();
+$TSFE->content = str_ireplace('</body>', $TSFE->previewInfo() . '</body>', $TSFE->content);
 
 
 // ******************