/** * @static * @param string $text * @param bool $praesentations_hacks * @param int $zeilenlaenge * @return array|string[] */ static function bbcode2html_absaetze($text, $praesentations_hacks = false, $zeilenlaenge) { $text = static::bbNormalizeForAbsaetze($text); $x = explode("\n\n", $text); $absaetze_html = array(); $absaetze_bbcode = array(); $absaetze_html_plain = array(); HtmlBBcodeUtils::$br_implicit = $praesentations_hacks ? " <br class='implicit'>" : "<br>"; // wird bei responsiver Ansicht manchmal ausgeblendet HtmlBBcodeUtils::$br_explicit = "<br>"; HtmlBBcodeUtils::$zeilenlaenge = $zeilenlaenge; foreach ($x as $i => $y) { $absaetze_bbcode[] = $y; $abs = HtmlBBcodeUtils::bbcode2html($y); $absaetze_html_plain[] = $abs; if (mb_stripos($abs, "<ul") === 0 || mb_stripos($abs, "<ol") === 0 || mb_stripos($abs, "<blockquote") === 0) { $str_neu = str_ireplace("<ul", "<ul class='text'", $abs); $str_neu = str_ireplace("<ol", "<ol class='text'", $str_neu); $str_neu = str_ireplace("<blockquote", "<blockquote class='text'", $str_neu); $str_neu = preg_replace("/( |<br>)*<\\/li>/", "</li>", $str_neu); $str_neu = preg_replace_callback("/(<(blockquote|li)[^>]*>)(.*)(<\\/\\2>)/siU", function ($matches) { $out = $matches[1]; $zeils = explode("<br>", $matches[3]); $zeils_neu = array(); foreach ($zeils as $zeile) { $x = HtmlBBcodeUtils::text2zeilen($zeile, HtmlBBcodeUtils::$zeilenlaenge - 10, false); $zeils_neu[] = "###ZEILENNUMMER###" . implode(HtmlBBcodeUtils::$br_implicit . "###ZEILENNUMMER###", $x); } $out .= implode("<br>", $zeils_neu); $out .= $matches[4]; return $out; }, $str_neu); } else { $zeils = explode("<br>", $abs); $zeils_neu = array(); foreach ($zeils as $zeile) { $x = HtmlBBcodeUtils::text2zeilen($zeile, HtmlBBcodeUtils::$zeilenlaenge, false); $zeils_neu[] = "###ZEILENNUMMER###" . implode(HtmlBBcodeUtils::$br_implicit . "###ZEILENNUMMER###", $x); } $str_neu = "<div class='text'>"; $str_neu .= implode("<br>", $zeils_neu); $str_neu .= "</div>"; } $str_neu = preg_replace_callback("/###ZEILENNUMMER###/", function () { return "<span class='zeilennummer'>" . HtmlBBcodeUtils::$zeilen_counter++ . "</span>"; }, $str_neu); $absaetze_html[] = $str_neu; } return array("html" => $absaetze_html, "html_plain" => $absaetze_html_plain, "bbcode" => $absaetze_bbcode); }