App\Libraries\BBCodeFromDB::toHTML PHP Метод

toHTML() публичный Метод

public toHTML ( $ignoreLineHeight = false )
    public function toHTML($ignoreLineHeight = false)
    {
        $text = $this->text;
        // block
        $text = $this->parseBox($text);
        $text = $this->parseCode($text);
        $text = $this->parseList($text);
        $text = $this->parseNotice($text);
        $text = $this->parseQuote($text);
        $text = $this->parseHeading($text);
        $text = $this->clearSpacesBetweenTags($text);
        // inline
        $text = $this->parseAudio($text);
        $text = $this->parseBold($text);
        $text = $this->parseCentre($text);
        $text = $this->parseColour($text);
        $text = $this->parseEmail($text);
        $text = $this->parseImage($text);
        $text = $this->parseItalic($text);
        $text = $this->parseSize($text);
        $text = $this->parseSmilies($text);
        $text = $this->parseSpoiler($text);
        $text = $this->parseStrike($text);
        $text = $this->parseUnderline($text);
        $text = $this->parseUrl($text);
        $text = $this->parseYoutube($text);
        $text = $this->parseProfile($text);
        $text = str_replace("\n", '<br />', $text);
        $text = CleanHTML::purify($text);
        $className = 'bbcode';
        if ($ignoreLineHeight) {
            $className .= ' bbcode--normal-line-height';
        }
        return "<div class='{$className}'>{$text}</div>";
    }

Usage Example

Пример #1
0
 public function testAll()
 {
     $text = new BBCodeFromDB("", $this->uid);
     $path = __DIR__ . "/bbcode_examples";
     foreach (glob("{$path}/*.db.txt") as $dbFilePath) {
         $htmlFilePath = preg_replace("/\\.db\\.txt\$/", ".html", $dbFilePath);
         $text->text = trim(file_get_contents($dbFilePath));
         $referenceHtmlOutput = $this->wrapDiv(trim(file_get_contents($htmlFilePath)));
         $this->assertEquals($referenceHtmlOutput, $text->toHTML());
     }
 }