(.*?)

Aus HL7 Austria MediaWiki
Version vom 16. Mai 2018, 16:16 Uhr von Lahnsteiner (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „Diese Seite dient zur Erklärung von verschiedenen Fehlercodes die behoben worden sind. =Fehler in PHP= ==CustomTitle== Mit der Extension CustomTitle hatten w…“)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche

Diese Seite dient zur Erklärung von verschiedenen Fehlercodes die behoben worden sind.

1 Fehler in PHP

1.1 CustomTitle

Mit der Extension CustomTitle hatten wir leider das Problem, dass im Text folgender Code dargestellt wurde:

Um dies zu Unterbinden wurden in der CustomTitle.php die Funktion onOutputPageBeforeHTML erweitert.

vorheriger Code:

function onOutputPageBeforeHTML(&$out, &$text)
    {
        if (($found = strpos($text, 'xxx-CustomTitleStart-xxx')) !== false) {
            if (preg_match("//", $text, $matches)) {
                $this->customTitle = $matches[1];
                $text = str_replace($matches[0], "", $text);
            }
        }

        if (($found = strpos($text, 'xxx-CustomPageTitleStart-xxx')) !== false) {
            if (preg_match("//", $text, $matches)) {
                $this->customPageTitle = $matches[1];
                $text = str_replace($matches[0], "", $text);
            }
        }

        return true;
    }

Lösung:

   function onOutputPageBeforeHTML(&$out, &$text)
    {
        if (($found = strpos($text, 'xxx-CustomTitleStart-xxx')) !== false) {
            if (preg_match("//", $text, $matches)) {
                $this->customTitle = $matches[1];
                $text = str_replace($matches[0], "", $text);
                // replace any remaining occurrences
                while (preg_match("//", $text, $matches)) {
                    $text = str_replace($matches[0], "", $text);
                }
            }
        }
 
        if (($found = strpos($text, 'xxx-CustomPageTitleStart-xxx')) !== false) {
            if (preg_match("//", $text, $matches)) {
                $this->customPageTitle = $matches[1];
                $text = str_replace($matches[0], "", $text);
                // replace any remaining occurrences
                while (preg_match("//", $text, $matches)) {
                    $text = str_replace($matches[0], "", $text);
                }
            }
        }
 
        return true;
    }