Fixed spoiler bbcode issue
authorMarcel Werk <burntime@woltlab.com>
Thu, 3 Oct 2013 13:06:43 +0000 (15:06 +0200)
committerMarcel Werk <burntime@woltlab.com>
Thu, 3 Oct 2013 13:06:43 +0000 (15:06 +0200)
com.woltlab.wcf/templates/spoilerBBCodeTag.tpl
wcfsetup/install/files/lib/util/MessageUtil.class.php

index af9e5cde56ea5401a07caae6cc46cc0cf2cc00f5..2b11f52cec065ddb612d0a65469d8ecbc255eb7f 100644 (file)
@@ -1,16 +1,14 @@
+<!-- begin:parser_nonessential -->
 <div class="container containerPadding spoilerBox jsSpoilerBox">
-       <!-- begin:parser_nonessential -->
        <header class="jsOnly">
                <a class="button jsSpoilerToggle">{if $buttonTitle}{$buttonTitle}{else}{lang}wcf.bbcode.spoiler.show{/lang}{/if}</a>
        </header>
-       <!-- end:parser_nonessential -->
        
        <div style="display: none">
                {@$content}
        </div>
 </div>
 
-<!-- begin:parser_nonessential -->
 <script data-relocate="true">
        //<![CDATA[
        $(function() {
index 213560e0c151032b9458cd37b4cdba7299662746..0cceed34e33179ae1d01691561e720abc1189a9a 100644 (file)
@@ -102,4 +102,16 @@ class MessageUtil {
                
                return $usernames;
        }
+       
+       /**
+        * Truncates a formatted message and keeps the HTML syntax intact.
+        *
+        * @param       string          $message                string which shall be truncated
+        * @param       integer         $maxLength              string length after truncating
+        * @return      string                                  truncated string
+        */
+       public static function truncateFormattedMessage($message, $maxLength = 1000) {
+               $message = Regex::compile('<!-- begin:parser_nonessential -->.*?<!-- end:parser_nonessential -->', Regex::DOT_ALL)->replace($message, '');
+               return StringUtil::truncateHTML($message, $maxLength);
+       }
 }