[~BUGFIX] Fluid (ViewHelpers): fixed and tweaked format.crop view helper (BE mode)
authorBastian Waidelich <bastian@typo3.org>
Wed, 23 Sep 2009 20:47:14 +0000 (20:47 +0000)
committerBastian Waidelich <bastian@typo3.org>
Wed, 23 Sep 2009 20:47:14 +0000 (20:47 +0000)
[-TASK] Fluid (ViewHelpers): removed instanceof check from be.menus.actionMenu view helper to enable wrapping of menuItems in <f:if> blocks

typo3/sysext/fluid/Classes/ViewHelpers/Be/Menus/ActionMenuViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Format/CropViewHelper.php

index a852342..5e19682 100644 (file)
@@ -101,8 +101,7 @@ class Tx_Fluid_ViewHelpers_Be_Menus_ActionMenuViewHelper extends Tx_Fluid_Core_V
                $this->tag->addAttribute('onchange', 'jumpToUrl(this.options[this.selectedIndex].value, this);');
                $options = '';
                foreach ($this->childNodes as $childNode) {
-                       if ($childNode instanceof Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode
-                               && $childNode->getViewHelperClassName() === 'Tx_Fluid_ViewHelpers_Be_Menus_ActionMenuItemViewHelper') {
+                       if ($childNode instanceof Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode) {
                                $childNode->setRenderingContext($this->renderingContext);
                                $options .= $childNode->evaluate();
                        }
index 3aa9a4f..6012cfb 100644 (file)
@@ -77,7 +77,7 @@ class Tx_Fluid_ViewHelpers_Format_CropViewHelper extends Tx_Fluid_Core_ViewHelpe
         *
         * @param integer $maxCharacters Place where to truncate the string
         * @param string $append What to append, if truncation happened
-        * @param boolean $respectBoundaries If TRUE and division is in the middle of a word, the remains of that word is removed
+        * @param boolean $respectBoundaries If TRUE and division is in the middle of a word, the remains of that word is removed. This is currently ignored in backend mode!
         * @return string cropped text
         * @author Andreas Pattynama <andreas.pattynama@innocube.ch>
         * @author Sebastian Kurf├╝rst <sebastian@typo3.org>
@@ -86,10 +86,13 @@ class Tx_Fluid_ViewHelpers_Format_CropViewHelper extends Tx_Fluid_Core_ViewHelpe
        public function render($maxCharacters, $append = '...', $respectWordBoundaries = TRUE) {
                $stringToTruncate = $this->renderChildren();
                if (TYPO3_MODE === 'BE') {
-                       return substr($stringToTruncate, $maxCharacters);
+                       if (strlen($stringToTruncate) > $maxCharacters) {
+                               $stringToTruncate = substr($stringToTruncate, 0, ($maxCharacters - strlen($append))) . $append;
+                       }
+                       return $stringToTruncate;
+               } else {
+                       return $this->contentObject->crop($stringToTruncate, $maxCharacters . '|' . $append . '|' . $respectWordBoundaries);
                }
-
-               return $this->contentObject->crop($stringToTruncate, $maxCharacters . '|' . $append . '|' . $respectWordBoundaries);
        }
 }