/** * @static * @param string $text_alt * @param string $text_neu * @param bool $compact * @param int $css_width_hack * @param string $pre_str_html * @param bool $wrapWithCssClass * @param bool $debug * @return string */ public static function renderBBCodeDiff2HTML($text_alt, $text_neu, $compact = false, $css_width_hack = 0, $pre_str_html = "", $wrapWithCssClass = true, $debug = false) { $text_alt = static::bbNormalizeForDiff($text_alt); $text_neu = static::bbNormalizeForDiff($text_neu); $diff = DiffUtils::getTextDiff($text_alt, $text_neu); if ($compact) { $renderer = new Horde_Text_Diff_Renderer_Inline_Antrag15(); $absatz = $renderer->render($diff); } else { $absatz = DiffUtils::renderAbsatzDiff($diff); } if ($debug) { echo "\n\n============== Nach DIFF ===============\n\n"; var_dump($absatz); } $split_lists = function ($matches) use($debug) { $lis = explode("[*]", $matches["inhalt"]); if (count($lis) == 1) { return $matches[0]; } $output = ""; for ($i = 0; $i < count($lis); $i++) { if ($i == 0) { if (trim($lis[$i]) == "") { $output .= $lis[$i]; } else { $output .= $matches["anfang"] . $lis[$i] . $matches["ende"]; } } elseif ($i == count($lis) - 1) { if (trim($lis[$i]) == "") { $output .= "[*]" . $lis[$i]; } else { $output .= "[*]" . $matches["anfang"] . $lis[$i] . $matches["ende"]; } } else { $output .= "[*]" . $matches["anfang"] . $lis[$i] . $matches["ende"]; } } if ($debug) { echo "-----------------\n"; var_dump($matches); var_dump($lis); var_dump($output); } return $output; }; $absatz = preg_replace_callback("/(?<anfang><del>)(?<inhalt>.*)(?<ende><\\/del>)/siU", $split_lists, $absatz); $absatz = preg_replace_callback("/(?<anfang><ins>)(?<inhalt>.*)(?<ende><\\/ins>)/siU", $split_lists, $absatz); $diffstr = HtmlBBcodeUtils::bbcode2html($absatz); $diffstr = str_ireplace(array("<ins>", "</ins>", "<del>", "</del>"), array("<ins>", "</ins>", "<del>", "</del>"), $diffstr); if ($debug) { echo "\n\n============== In HTML ===============\n\n"; var_dump($diffstr); } static::$ins_mode_active = false; static::$del_mode_active = false; $diffstr = preg_replace_callback("/(<li>)(.*)(<\\/li>)/siuU", function ($matches) { $pos_del_open = mb_stripos($matches[2], "<del>"); $pos_del_close = mb_stripos($matches[2], "</del>"); $pos_ins_open = mb_stripos($matches[2], "<ins>"); $pos_ins_close = mb_stripos($matches[2], "</ins>"); $middle = $matches[2]; if ($pos_del_close !== false && ($pos_del_open === false || $pos_del_open > $pos_del_close)) { $middle = "<del>" . $middle; static::$del_mode_active = false; } if ($pos_del_open !== false && ($pos_del_close === false || $pos_del_open > $pos_del_close)) { $middle .= "</del>"; static::$del_mode_active = true; } if ($pos_del_close === false && $pos_del_open === false && static::$del_mode_active) { $middle = "<del>{$middle}</del>"; } if ($pos_ins_close !== false && ($pos_ins_open === false || $pos_ins_open > $pos_ins_close)) { $middle = "<ins>" . $middle; static::$ins_mode_active = false; } if ($pos_ins_open !== false && ($pos_ins_close === false || $pos_ins_open > $pos_ins_close)) { $middle .= "</ins>"; static::$ins_mode_active = true; } if ($pos_ins_close === false && $pos_ins_open === false && static::$ins_mode_active) { $middle = "<ins>{$middle}</ins>"; } return $matches[1] . $middle . $matches[3]; }, $diffstr); if ($diffstr == "") { $diffstr = HtmlBBcodeUtils::bbcode2html($text_alt); } if ($wrapWithCssClass) { $diffstr = HtmlBBcodeUtils::wrapWithTextClass($pre_str_html . $diffstr, $css_width_hack); } return $diffstr; }
$von = implode(", ", $x); echo "<label><input type='radio' name='absatz_typ[{$i}]' value='" . $ant->id . "'> " . $ae_link . " (von " . CHtml::encode($von) . ")</label>"; $full_texts .= "<blockquote class='aenderung ae_" . $ant->id . "'>" . DiffUtils::renderBBCodeDiff2HTML($abs->str_bbcode, $par[$i]) . "</blockquote>"; } } echo "<label><input type='radio' name='absatz_typ[{$i}]' value='neu'> Neuer Text</label><br>"; echo "<blockquote class='original'>" . $abs->str_html_plain . "</blockquote>" . $full_texts; echo "<div><textarea class='neu_text' name='neu_text[{$i}]' id='neu_text_{$i}' style='width: 550px; height: 200px;'>" . CHtml::encode($abs->str_bbcode) . "</textarea></div>"; echo "</div>"; } echo "<h3>Begründung</h3><div class='absatz_selector_holder content absatz_begruendung'>"; /** @var AntragAbsatz $abs */ $full_texts = ""; echo "<label><input type='radio' name='begruendung_typ' value='original' checked> Original beibehalten</label>"; echo "<label><input type='radio' name='begruendung_typ' value='neu'> Neuer Text</label><br>"; echo "<blockquote class='original'>" . HtmlBBcodeUtils::bbcode2html($antrag->begruendung) . "</blockquote>" . $full_texts; echo "<div><textarea class='neu_text' name='neu_begruendung' id='neu_begruendung' style='width: 550px; height: 200px;'>" . CHtml::encode($antrag->begruendung) . "</textarea></div>"; echo "</div>"; ?> <h3> Stati der Änderunganträge setzen </h3> <div id="ae_status_setter" class="content"> <?php foreach ($antrag->aenderungsantraege as $ae) { if (!in_array($ae->status, IAntrag::$STATI_UNSICHTBAR)) { $absaetze = $ae->getAffectedParagraphs(); ?> <label><span class="ae"><?php echo CHtml::encode($ae->revision_name); ?> </span> <select
if (!$letztes_leer) { $letztes_leer = true; echo "<div class='absatz_ueberspringen'>.<br>.<br>.</div>"; } } } ?> </div> </div> <div class="begruendungs_text_holder"> <h3>Begründung</h3> <div class="textholder consolidated content"> <?php echo HtmlBBcodeUtils::bbcode2html($aenderungsantrag->aenderung_begruendung); ?> </div> <br><br> </div> <?php $zustimmung_von = $aenderungsantrag->getZustimmungen(); $ablehnung_von = $aenderungsantrag->getAblehnungen(); $unterstuetzerInnen = $aenderungsantrag->getUnterstuetzerInnen(); $eintraege = count($unterstuetzerInnen) > 0 || count($zustimmung_von) > 0 || count($ablehnung_von) > 0; $unterstuetzen_policy = $aenderungsantrag->antrag->veranstaltung->getPolicyUnterstuetzen(); $kann_unterstuetzen = $unterstuetzen_policy->checkCurUserHeuristically(); $kann_nicht_unterstuetzen_msg = $unterstuetzen_policy->getPermissionDeniedMsg(); if ($eintraege || $kann_unterstuetzen || $kann_nicht_unterstuetzen_msg != "") {
</td> </tr> <?php } ?> </table> <h2><?php echo $sprache->get("Antragstext"); ?> </h2> <?php $absae = $antrag->getParagraphs(true, false); foreach ($absae as $i => $abs) { echo $abs->str_html_plain; echo "<br><br>"; } if (trim($antrag->begruendung) != "") { ?> <h3>Begründung</h3> <?php if ($antrag->begruendung_html) { echo $antrag->begruendung; } else { echo HtmlBBcodeUtils::bbcode2html($antrag->begruendung); } } ?> </body> </html>
} $doc->setCell($row, $COL_AE_NR, OdsTemplateEngine::$TYPE_TEXT, $ae->revision_name); $doc->setCell($row, $COL_ANTRAGSTELLERIN, OdsTemplateEngine::$TYPE_TEXT, implode(", ", $initiatorInnen_namen)); $doc->setCell($row, $COL_KONTAKT, OdsTemplateEngine::$TYPE_TEXT, implode("\n", $initiatorInnen_kontakt)); $doc->setCell($row, $COL_ZEILE, OdsTemplateEngine::$TYPE_TEXT, $ae->getFirstDiffLine()); $absae = $ae->getAntragstextParagraphs_diff(); $diffhtml = ""; foreach ($absae as $i => $abs) { if ($abs !== null) { $diffhtml .= $abs->getDiffHTMLForODS(); } } if ($ae->aenderung_begruendung_html) { $text_begruendung = $ae->aenderung_begruendung; } else { $text_begruendung = '<div>' . HtmlBBcodeUtils::bbcode2html($ae->aenderung_begruendung) . '</div>'; } if (!isset($COL_BEGRUENDUNG)) { $text = '<p><strong>Änderungsantrag:</strong></p>' . $diffhtml; $text .= '<p><strong>Begründung:</strong></p>' . $text_begruendung; $doc->setCell($row, $COL_ANTRAGSTEXT, OdsTemplateEngine::$TYPE_HTML, $text); } else { if ($DEBUG) { echo CHtml::encode($text_begruendung); } $doc->setCell($row, $COL_ANTRAGSTEXT, OdsTemplateEngine::$TYPE_HTML, $diffhtml); $doc->setCell($row, $COL_BEGRUENDUNG, OdsTemplateEngine::$TYPE_HTML, $text_begruendung); } } if (!$antraege_separat) { /** @var int $antrag_row_from */
} else { $x[] = $unt->getNameMitBeschlussdatum(true); } } } echo implode(", ", $x); ?> </td> </tr> <tr> <th><?php echo GxHtml::encode($data->getAttributeLabel('aenderung_text')); ?> :</th> <td><?php echo HtmlBBcodeUtils::bbcode2html($data->aenderung_text); ?> </td> </tr> <tr> <th><?php echo GxHtml::encode($data->getAttributeLabel('datum_einreichung')); ?> :</th> <td><?php echo GxHtml::encode($data->datum_einreichung); ?> </td> </tr> <tr> <th><?php
/** * @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); }
/** * @param Veranstaltung $veranstaltung * @return array */ private function getFeedAntragKommentarData(&$veranstaltung) { $veranstaltung_id = IntVal($veranstaltung->id); $antraege = AntragKommentar::holeNeueste($veranstaltung, 20); $data = array(); foreach ($antraege as $ant) { $data[AntraegeUtils::date_sql2timestamp($ant->datum) . "_kommentar_" . $ant->id] = array("title" => "Kommentar von " . $ant->verfasserIn->name . " zu: " . $ant->antrag->nameMitRev(), "link" => Yii::app()->getBaseUrl(true) . $this->createUrl("antrag/anzeige", array("antrag_id" => $ant->antrag->id, "kommentar_id" => $ant->id, "#" => "komm" . $ant->id)), "dateCreated" => AntraegeUtils::date_sql2timestamp($ant->datum), "content" => HtmlBBcodeUtils::bbcode2html($ant->text)); } return $data; }
/** * @param string [] * @param string * @return string */ public function convert($antrag_absaetze, $begruendung) { $this->appendTextStyleNode("Antragsgruen_fett", array("fo:font-weight" => "bold", "style:font-weight-asian" => "bold", "style:font-weight-complex" => "bold")); $this->appendTextStyleNode("Antragsgruen_kursiv", array("fo:font-style" => "italic", "style:font-style-asian" => "italic", "style:font-style-complex" => "italic")); $this->appendTextStyleNode("Antragsgruen_unterstrichen", array("style:text-underline-width" => "auto", "style:text-underline-color" => "font-color", "style:text-underline-style" => "solid")); $this->appendTextStyleNode("Antragsgruen_gruen", array("fo:color" => "#00ff00")); $this->appendTextStyleNode("Antragsgruen_rot", array("fo:color" => "#ff0000")); /** @var DOMNode[] $nodes */ $nodes = array(); foreach ($this->doc->getElementsByTagNameNS(static::$NS_TEXT, 'span') as $element) { $nodes[] = $element; } foreach ($this->doc->getElementsByTagNameNS(static::$NS_TEXT, 'p') as $element) { $nodes[] = $element; } foreach ($nodes as $node) { $children = $node->childNodes; foreach ($children as $child) { if ($child->nodeType == XML_TEXT_NODE) { /** @var DOMText $child */ $child->data = preg_replace(array_keys($this->replaces), array_values($this->replaces), $child->data); if (preg_match("/\\{\\{ANTRAGSGRUEN:BEGRUENDUNG( [^\\}]*)?/siu", $child->data)) { $this->node_begruendung = $node; } if (preg_match("/\\{\\{ANTRAGSGRUEN:ANTRAGSTEXT_1( [^\\}]*)?/siu", $child->data)) { $this->node_template_1 = $node; } if (preg_match("/\\{\\{ANTRAGSGRUEN:ANTRAGSTEXT_N( [^\\}]*)?/siu", $child->data)) { $this->node_template_n = $node; } } } } if ($this->node_begruendung) { if ($begruendung) { $new_nodes = $this->html2ooNodes($begruendung, static::$TEMPLATE_TYPE_BEGRUENDUNG); foreach ($new_nodes as $new_node) { $this->node_begruendung->parentNode->insertBefore($new_node, $this->node_begruendung); } } $this->node_begruendung->parentNode->removeChild($this->node_begruendung); } if ($this->node_template_1) { $html = HtmlBBcodeUtils::bbcode2html($antrag_absaetze[0]->str_bbcode); if ($this->DEBUG) { echo "======<br>" . nl2br(CHtml::encode($html)) . "<br>========<br>"; } $new_nodes = $this->html2ooNodes($html, static::$TEMPLATE_TYPE_ANTRAG); foreach ($new_nodes as $new_node) { $this->node_template_1->parentNode->insertBefore($new_node, $this->node_template_1); } $this->node_template_1->parentNode->removeChild($this->node_template_1); } if ($this->node_template_n) { for ($i = 1; $i < count($antrag_absaetze); $i++) { $html = HtmlBBcodeUtils::bbcode2html($antrag_absaetze[$i]->str_bbcode); if ($this->DEBUG) { echo "======<br>" . nl2br(CHtml::encode($html)) . "<br>========<br>"; } $new_nodes = $this->html2ooNodes($html, static::$TEMPLATE_TYPE_ANTRAG); foreach ($new_nodes as $new_node) { $this->node_template_n->parentNode->insertBefore($new_node, $this->node_template_n); } } $this->node_template_n->parentNode->removeChild($this->node_template_n); } return $this->doc->saveXML(); }