Added feature #11107: CSC: Provides more flexible rendering for the images block...
authorErnesto Baschny <ernst@cron-it.de>
Wed, 3 Jun 2009 17:44:18 +0000 (17:44 +0000)
committerErnesto Baschny <ernst@cron-it.de>
Wed, 3 Jun 2009 17:44:18 +0000 (17:44 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@5540 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/css_styled_content/pi1/class.tx_cssstyledcontent_pi1.php
typo3/sysext/css_styled_content/static/setup.txt

index f3bd839..b19617b 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-06-03  Ernesto Baschny  <ernst@cron-it.de>
+
+       * Added feature #11107: CSC: Provides more flexible rendering for the images block in "text with image", e.g. less tags (and no DL) around "single images without caption"
+
 2009-06-03  Steffen Kamper  <info@sk-typo3.de>
 
        * Update  #11117: Update ExtJs to 3.0 RC2, added typo3be-theme
index 8660f62..761a389 100755 (executable)
@@ -441,10 +441,25 @@ class tx_cssstyledcontent_pi1 extends tslib_pibase {
 
                $imgPath = $this->cObj->stdWrap($conf['imgPath'], $conf['imgPath.']);
 
+                       // Does we need to render a "global caption" (below the whole image block)?
+               $renderGlobalCaption = !$conf['captionSplit'] && !$conf['imageTextSplit'] && is_array($conf['caption.']);
+               if ($imgCount == 1) {
+                               // If we just have one image, the caption relates to the image, so it is not "global"
+                       $renderGlobalCaption = false;
+               }
+
+                       // Use the calculated information (amount of images, if global caption is wanted) to choose a different rendering method for the images-block
+               $GLOBALS['TSFE']->register['imageCount'] = $imgCount;
+               $GLOBALS['TSFE']->register['renderGlobalCaption'] = $renderGlobalCaption;
+               $fallbackRenderMethod = $this->cObj->cObjGetSingle($conf['fallbackRendering'], $conf['fallbackRendering.']);
+               if ($fallbackRenderMethod && is_array($conf['rendering.'][$fallbackRenderMethod . '.']))        {
+                       $conf = $this->cObj->joinTSarrays($conf, $conf['rendering.'][$fallbackRenderMethod . '.']);
+               }
+
                        // Global caption
-               $caption = '';
-               if (!$conf['captionSplit'] && !$conf['imageTextSplit'] && is_array($conf['caption.']))  {
-                       $caption = $this->cObj->stdWrap($this->cObj->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']);
+               $globalCaption = '';
+               if ($renderGlobalCaption)       {
+                       $globalCaption = $this->cObj->stdWrap($this->cObj->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']);
                }
 
                        // Positioning
@@ -733,7 +748,7 @@ class tx_cssstyledcontent_pi1 extends tslib_pibase {
                                $thisImage = '';
                                $thisImage .= $this->cObj->stdWrap($imgsTag[$imgKey], $conf['imgTagStdWrap.']);
 
-                               if ($conf['captionSplit'] || $conf['imageTextSplit'])   {
+                               if (!$renderGlobalCaption)      {
                                        $thisImage .= $this->cObj->stdWrap($this->cObj->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']);
                                }
                                if ($editIconsHTML)     {
@@ -776,8 +791,8 @@ class tx_cssstyledcontent_pi1 extends tslib_pibase {
                }
 
                        // Add the global caption, if not split
-               if ($caption)   {
-                       $images .= $caption;
+               if ($globalCaption)     {
+                       $images .= $globalCaption;
                }
 
                        // CSS-classes
index e234801..97cd218 100644 (file)
@@ -573,6 +573,43 @@ tt_content.image.20 {
 
        rendering {
                dl {
+                       # Choose another rendering for special edge cases
+                       fallbackRendering = COA
+                       fallbackRendering {
+                               # Just one image without a caption => don't need the dl-overhead, use the "simple" rendering
+                               10 = TEXT
+                               10 {
+                                       if {
+                                               isFalse.field = imagecaption
+                                               value = 1
+                                               equals.data = register:imageCount
+                                       }
+                                       value = simple
+                               }
+
+                               # Multiple images and one global caption => "ul"
+                               20 = TEXT
+                               20 {
+                                       if {
+                                               value = 1
+                                               isGreaterThan.data = register:imageCount
+                                               isTrue.if.isTrue.data = register:renderGlobalCaption
+                                               isTrue.field = imagecaption
+                                       }
+                                       value = ul
+                               }
+                               
+                               # Multiple images and no caption at all => "ul"
+                               30 = TEXT
+                               30 {
+                                       if {
+                                               value = 1
+                                               isGreaterThan.data = register:imageCount
+                                               isFalse.field = imagecaption
+                                       }
+                                       value = ul
+                               }
+                       }
                        imageRowStdWrap.dataWrap = <div class="csc-textpic-imagerow" style="width:{register:rowwidth}px;"> | </div>
                        imageLastRowStdWrap.dataWrap = <div class="csc-textpic-imagerow csc-textpic-imagerow-last" style="width:{register:rowwidth}px;"> | </div>
                        noRowsStdWrap.wrap =
@@ -585,6 +622,8 @@ tt_content.image.20 {
                        }
                }
                ul {
+                       # Just one image without a caption => don't need the ul-overhead, use the "simple" rendering
+                       fallbackRendering < tt_content.image.20.rendering.dl.fallbackRendering.10
                        imageRowStdWrap.dataWrap = <div class="csc-textpic-imagerow" style="width:{register:rowwidth}px;"><ul> | </ul></div>
                        imageLastRowStdWrap.dataWrap = <div class="csc-textpic-imagerow csc-textpic-imagerow-last" style="width:{register:rowwidth}px;"><ul> | </ul></div>
                        noRowsStdWrap.wrap = <ul> | </ul>
@@ -594,6 +633,8 @@ tt_content.image.20 {
                        caption.wrap = <div class="csc-textpic-caption"> | </div>
                }
                div {
+                       # Just one image without a caption => don't need the div-overhead, use the "simple" rendering
+                       fallbackRendering < tt_content.image.20.rendering.dl.fallbackRendering.10
                        imageRowStdWrap.dataWrap = <div class="csc-textpic-imagerow" style="width:{register:rowwidth}px;"> | </div>
                        imageLastRowStdWrap.dataWrap = <div class="csc-textpic-imagerow csc-textpic-imagerow-last" style="width:{register:rowwidth}px;"> | </div>
                        noRowsStdWrap.wrap =
@@ -602,6 +643,16 @@ tt_content.image.20 {
                        editIconsStdWrap.wrap = <div> | </div>
                        caption.wrap = <div class="csc-textpic-caption"> | </div>
                }
+               simple {
+                       imageRowStdWrap.dataWrap = |
+                       imageLastRowStdWrap.dataWrap = |
+                       noRowsStdWrap.wrap =
+                       oneImageStdWrap.dataWrap = |
+                       imgTagStdWrap.wrap = |
+                       editIconsStdWrap.wrap = |
+                       caption.wrap = <div class="csc-textpic-caption"> | </div>
+                       #imageStdWrap.dataWrap = |
+               }
        }
        renderMethod = dl