[BUGFIX] Wrong margin calculation for Text/Image
authorderhansen <t.hansen@skyfillers.com>
Fri, 4 May 2012 09:55:16 +0000 (11:55 +0200)
committerSteffen Ritter <info@rs-websystems.de>
Sun, 24 Jun 2012 13:31:19 +0000 (15:31 +0200)
This patch fixes a wrong calculation of margins for Text/Image
items with the properties "Beside text, left" and "Beside
text, right".

Change-Id: Ie484685aa2839123c42338862c241403614e7f7a
Fixes: #36541
Releases: 6.0, 4.7
Reviewed-on: http://review.typo3.org/10995
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
typo3/sysext/css_styled_content/pi1/class.tx_cssstyledcontent_pi1.php

index c26ff01..e1888a2 100755 (executable)
@@ -628,22 +628,6 @@ class tx_cssstyledcontent_pi1 extends tslib_pibase {
                        }
                }
 
-                       // Set the margin for image + text, no wrap always to avoid multiple stylesheets
-               if ($accessibilityMode) {
-                       $noWrapMargin = (integer) (($maxWInText ? $maxWInText : $fiftyPercentWidthInText) +
-                               intval($this->cObj->stdWrap($conf['textMargin'], $conf['textMargin.'])));
-
-                       $this->addPageStyle(
-                               '.csc-textpic-intext-right-nowrap .csc-textpic-text',
-                               'margin-right: ' . $noWrapMargin . 'px;'
-                       );
-
-                       $this->addPageStyle(
-                               '.csc-textpic-intext-left-nowrap .csc-textpic-text',
-                               'margin-left: ' . $noWrapMargin . 'px;'
-                       );
-               }
-
                        // max usuable width for images (without spacers and borders)
                $netW = $maxW - $colspacing * ($colCount - 1) - $colCount * $border * ($borderThickness + $borderSpace) * 2;
 
@@ -1008,6 +992,45 @@ class tx_cssstyledcontent_pi1 extends tslib_pibase {
                                }
                        }
 
+                               // Set the margin for image + text, no wrap always to avoid multiple stylesheets
+                       $noWrapMargin = (integer) (($maxWInText ? $maxWInText : $fiftyPercentWidthInText) +
+                               intval($this->cObj->stdWrap($conf['textMargin'], $conf['textMargin.']
+                       )));
+
+                       $this->addPageStyle(
+                               '.csc-textpic-intext-right-nowrap .csc-textpic-text',
+                               'margin-right: ' . $noWrapMargin . 'px;'
+                       );
+
+                       $this->addPageStyle(
+                               '.csc-textpic-intext-left-nowrap .csc-textpic-text',
+                               'margin-left: ' . $noWrapMargin . 'px;'
+                       );
+
+                               // Beside Text where the image block width is not equal to maxW
+                       if ($contentPosition == 24 && $maxW != $imageBlockWidth) {
+                               $noWrapMargin = $imageBlockWidth + $textMargin;
+
+                                       // Beside Text, Right
+                               if ($imagePosition == 1) {
+                                       $this->addPageStyle(
+                                               '.csc-textpic-intext-right-nowrap-' . $noWrapMargin. ' .csc-textpic-text',
+                                               'margin-right: ' . $noWrapMargin . 'px;'
+                                       );
+
+                                       $classes[] = 'csc-textpic-intext-right-nowrap-' . $noWrapMargin;
+
+                                       // Beside Text, Left
+                               } elseif ($imagePosition == 2) {
+                                       $this->addPageStyle(
+                                               '.csc-textpic-intext-left-nowrap-' . $noWrapMargin . ' .csc-textpic-text',
+                                               'margin-left: ' . $noWrapMargin . 'px;'
+                                       );
+
+                                       $classes[] = 'csc-textpic-intext-left-nowrap-' . $noWrapMargin;
+                               }
+                       }
+
                                // Add the border class if needed
                        if ($border){
                                $classes[] = $conf['borderClass'] ? $conf['borderClass'] : 'csc-textpic-border';