diff options
author | Michael Vogel <icarus@dabo.de> | 2012-03-17 11:07:49 +0100 |
---|---|---|
committer | Michael Vogel <icarus@dabo.de> | 2012-03-17 11:07:49 +0100 |
commit | 8a1f175df022e2fc2c2162aa314ea34454482d48 (patch) | |
tree | 08daca362b42d402322787f4e69810c2999ff791 /include/text.php | |
parent | b5120888cf6e3aac29aa2a8d80bddcab73822e1e (diff) | |
download | volse-hubzilla-8a1f175df022e2fc2c2162aa314ea34454482d48.tar.gz volse-hubzilla-8a1f175df022e2fc2c2162aa314ea34454482d48.tar.bz2 volse-hubzilla-8a1f175df022e2fc2c2162aa314ea34454482d48.zip |
New bbcode element: "spoiler". Mail: Top post quotes are now embraced in "spoiler" elements
Diffstat (limited to 'include/text.php')
-rw-r--r-- | include/text.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/text.php b/include/text.php index d34fd7fbe..bcd567a15 100644 --- a/include/text.php +++ b/include/text.php @@ -955,6 +955,25 @@ function prepare_body($item,$attach = false) { $s .= '<div class="filesavetags"><span>' . t('Filed under:') . ' </span>' . $x . '</div>'; } + // Look for spoiler + $spoilersearch = '<blockquote class="spoiler">'; + + // Remove line breaks before the spoiler + while ((strpos($s, "\n".$spoilersearch) !== false)) + $s = str_replace("\n".$spoilersearch, $spoilersearch, $s); + while ((strpos($s, "<br />".$spoilersearch) !== false)) + $s = str_replace("<br />".$spoilersearch, $spoilersearch, $s); + + while ((strpos($s, $spoilersearch) !== false)) { + + $pos = strpos($s, $spoilersearch); + $rnd = random_string(8); + $spoilerreplace = '<span id="spoiler-wrap-'.$rnd.'" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'spoiler-'.$rnd.'\');">'.sprintf(t('Click to open/close')).'</span>'. + '<blockquote class="spoiler" id="spoiler-'.$rnd.'" style="display: none;">'; + //$s = str_replace($spoilersearch, $spoilerreplace, $s); + $s = substr($s, 0, $pos).$spoilerreplace.substr($s, $pos+strlen($spoilersearch)); + } + $prep_arr = array('item' => $item, 'html' => $s); call_hooks('prepare_body_final', $prep_arr); |