public function run($args) { foreach ($GLOBALS["TESTS"] as $test) { HtmlBBcodeUtils::initZeilenCounter(); $res = HtmlBBcodeUtils::bbcode2html_absaetze($test["src"], $test["presentation_hacks"], $test["line_length"]); $allesrichtig = true; if (count($res["html"]) != count($test["expected_html"])) { $allesrichtig = false; } if (count($res["html_plain"]) != count($test["expected_plain"])) { $allesrichtig = false; } if ($allesrichtig) { foreach ($res["html"] as $i => $line) { if ($test["expected_html"][$i] !== $line) { $allesrichtig = false; } } foreach ($res["html_plain"] as $i => $line) { if ($test["expected_plain"][$i] !== $line) { $allesrichtig = false; } } } if ($allesrichtig) { echo "Korrekt\n"; } else { echo "FEHLER!\n"; echo "Erwartet (HTML):\n"; var_dump($test["expected_html"]); echo "Bekommen (HTML):\n"; var_dump($res["html"]); echo "Erwartet (Plain): \n"; var_dump($test["expected_plain"]); echo "Bekommen (Plain):\n"; var_dump($res["html_plain"]); echo "\n"; } } }
/** * @param string $string1 * @param string $string2 * @param int $zeilenlaenge * @return Horde_Text_Diff */ public static function getTextDiffMitZeilennummern($string1 = "", $string2 = "", $zeilenlaenge) { HtmlBBcodeUtils::initZeilenCounter(); $string1 = trim(static::bbNormalizeForDiff($string1)); $arr1 = HtmlBBcodeUtils::bbcode2zeilen_absaetze($string1, $zeilenlaenge); $text1 = implode("\n#ABSATZ#\n", $arr1); HtmlBBcodeUtils::initZeilenCounter(); $string2 = trim(static::bbNormalizeForDiff($string2)); $arr2 = HtmlBBcodeUtils::bbcode2zeilen_absaetze($string2, $zeilenlaenge); $text2 = implode("\n#ABSATZ#\n", $arr2); $diff = new Horde_Text_Diff('native', array(explode("\n", $text1), explode("\n", $text2))); return $diff; }
/** * @param bool $runValidation * @param null $attributes * @return bool */ public function save($runValidation = true, $attributes = null) { HtmlBBcodeUtils::initZeilenCounter(); list($anzahl_absaetze, $anzahl_zeilen) = HtmlBBcodeUtils::getBBCodeStats(trim($this->text), $this->veranstaltung->getEinstellungen()->zeilenlaenge); $this->cache_anzahl_absaetze = $anzahl_absaetze; $this->cache_anzahl_zeilen = $anzahl_zeilen + 1; // + Überschrift Yii::app()->cache->delete("pdf_" . $this->veranstaltung->id); Yii::app()->cache->delete("pdf_" . $this->veranstaltung->id . "_" . $this->id); return parent::save($runValidation, $attributes); }
/** * @return array|AntragAbsatz[] */ public function getAntragstextParagraphs_flat() { if (!is_null($this->absaetze)) { return $this->absaetze; } $this->absaetze = array(); $komms = $this->aenderungsantragKommentare; HtmlBBcodeUtils::initZeilenCounter(); $arr = HtmlBBcodeUtils::bbcode2html_absaetze(trim($this->aenderung_text), false, $this->antrag->veranstaltung->getEinstellungen()->zeilenlaenge); for ($i = 0; $i < count($arr["html"]); $i++) { $html_plain = HtmlBBcodeUtils::wrapWithTextClass($arr["html_plain"][$i]); $this->absaetze[] = new AntragAbsatz($arr["html"][$i], $html_plain, $arr["bbcode"][$i], $this->id, count($this->absaetze), $komms, array()); } return $this->absaetze; }