/**
  * @param BBcodeDefinitionFactory $factory
  */
 public function __construct(BBcodeDefinitionFactory $factory, $documentElementClassName = 'OpenOrchestra\\BBcodeBundle\\ElementNode\\BBcodeDocumentElement', $textNodeClassName = 'OpenOrchestra\\BBcodeBundle\\ElementNode\\BBcodeTextNode', $elementNodeClassName = 'OpenOrchestra\\BBcodeBundle\\ElementNode\\BBcodeElementNode')
 {
     parent::__construct();
     $this->definitionFactory = $factory;
     if (class_exists($documentElementClassName)) {
         $this->documentElementClassName = $documentElementClassName;
     }
     if (class_exists($textNodeClassName)) {
         $this->textNodeClassName = $textNodeClassName;
     }
     if (class_exists($elementNodeClassName)) {
         $this->elementNodeClassName = $elementNodeClassName;
     }
 }
Esempio n. 2
0
 /**
  * parst einen Text mit BBCode-Regeln
  *
  * Zur Anwendung kann HtmlParser::parse() verwendet werden
  *
  * @param  string  $text  Der Text, der geparst werden soll
  * @param  array  $config  config array
  */
 public function parse($text, array $config = array())
 {
     $this->config = new Config();
     $this->config->mergeRecursive($config);
     $parser = new Parser();
     $definition_sets = $this->getDefinitionSets();
     // Wenn keine Definitions definiert wurde, brechen wir ab
     if (count($definition_sets) === 0) {
         return $text;
     }
     // Die DefinitionSets dem Parser zuweisen
     foreach ($definition_sets as $definition_set) {
         $parser->addCodeDefinitionSet($definition_set);
     }
     $parser->parse($text);
     // Sollen Urls erkannt werden?
     if ($this->config->get('parse_urls')) {
         $visitor = $this->config->get('visitor.url');
         if (is_object($visitor) and $visitor instanceof VisitorInterface) {
             $visitor->setConfig($this->config);
             $parser->accept($visitor);
         }
     }
     // Sollen Smilies geparset werden?
     if ($this->config->get('parse_smilies')) {
         $visitor = $this->config->get('visitor.smiley');
         if (is_object($visitor) and $visitor instanceof \JBBCode\NodeVisitor) {
             // BC: VisitorInterface wurde erst mit v1.1 eingeführt
             if ($visitor instanceof VisitorInterface) {
                 $visitor->setConfig($this->config);
             }
             $parser->accept($visitor);
         }
     }
     $text = $parser->getAsHtml();
     $text = $this->addParagraphs($text);
     //Erklärungen hinzufügen
     $text = $this->addExplanations($text);
     return $text;
 }
        </script>

    </head>

    <body>
        <section>
            <?php 
const PREVIEW_LENGTH = 50;
echo "<h3 class='document-title'>" . "<a target='_parent' href='show_document.php?id=" . $docId . "'>" . $meta["title"] . "</a>" . "<span class='right-time'>" . $meta["time"] . "</span></h3><br><br>";
require_once "../JBBCode/Parser.php";
require_once "../JBBCode/KhinenwCodeDefinitionSet.php";
require_once "../JBBCode/BBToolkit.php";
use JBBCode\Parser;
use JBBCode\KhinenwCodeDefinitionSet;
use JBBCode\BBToolkit;
$parser = new Parser();
$parser->addCodeDefinitionSet(new KhinenwCodeDefinitionSet());
$parser->parse(BBToolkit::bracketToTag(file_get_contents(Config::$docsFolder . $docId . ".txt")));
$text = str_replace("<br>", "[br]", BBToolkit::tagToBracket(BBToolkit::useNewLine($parser->getAsHTML())));
$text = str_replace("[br]", "<br>", preg_replace("/<.*>/", "", preg_replace("/<\\/.*>/", "", $text)));
if (mb_strlen($text) < PREVIEW_LENGTH) {
    echo $text;
} else {
    echo mb_substr($text, 0, PREVIEW_LENGTH) . "...";
}
echo "<br><br><a class='right-more' target='_parent' href='show_document.php?id=" . $docId . "'>Read More &gt;</a>";
echo "<span class='view'>View : " . $count . "</span>";
echo "<br><a class='tag' target='_parent' href='show_tags.php'>#</a>";
foreach ($meta["tag"] as $tag) {
    echo "<a class='tag-contents' target='_parent' href='show_category.php?tag=" . $tag . "'>" . $tag . "</a>&nbsp;&#124;&nbsp;";
}
Esempio n. 4
0
 public static function parseBBCode($str)
 {
     $validator = new htmlValidator();
     $parser = new BBCodeParser();
     $parser->addCodeDefinitionSet(new \JBBCode\DefaultCodeDefinitionSet());
     /* [s] <strike> */
     $builder = new BBCodeBuilder('s', '<strike>{param}</strike>');
     $parser->addCodeDefinition($builder->build());
     /* [pre] <pre> */
     $builder = new BBCodeBuilder('pre', '<pre>{param}</pre>');
     $parser->addCodeDefinition($builder->build());
     /* [pre] <pre> */
     $builder = new BBCodeBuilder('sup', '<sup>{param}</sup>');
     $parser->addCodeDefinition($builder->build());
     /* [pre] <pre> */
     $builder = new BBCodeBuilder('sub', '<sub>{param}</sub>');
     $parser->addCodeDefinition($builder->build());
     /* [li] <li> */
     $builder = new BBCodeBuilder('li', '<li>{param}</li>');
     $parser->addCodeDefinition($builder->build());
     $builder = new BBCodeBuilder('list', '<ul>{param}</ul>');
     $builder->setUseOption(false)->setParseContent(true);
     $parser->addCodeDefinition($builder->build());
     $builder = new BBCodeBuilder('list', '<ol>{param}</ol>');
     $builder->setUseOption(true)->setParseContent(true);
     $parser->addCodeDefinition($builder->build());
     /* [move] <marquee> */
     $builder = new BBCodeBuilder('move', '<marquee>{param}</marquee>');
     $parser->addCodeDefinition($builder->build());
     /* [center] <div text-align: center> */
     $builder = new BBCodeBuilder('center', '<div style="text-align: center">{param}</div>');
     $parser->addCodeDefinition($builder->build());
     /* [left] <div text-align: left> */
     $builder = new BBCodeBuilder('left', '<div style="text-align: left">{param}</div>');
     $parser->addCodeDefinition($builder->build());
     /* [right] <div text-align: right> */
     $builder = new BBCodeBuilder('right', '<div style="text-align: right">{param}</div>');
     $parser->addCodeDefinition($builder->build());
     $parser->parse($str);
     return $parser->getAsHTML();
 }
                </div>
            </div>
        </header>

        <section>
            <div class="section-wrapper">
                <div class="section-inside-wrapper">
                    <?php 
echo "<h2 class='document-title'>" . $meta["title"] . "<span class='right-time'>" . $meta["time"] . "</span></h2><br><br>";
require_once "../JBBCode/Parser.php";
require_once "../JBBCode/KhinenwCodeDefinitionSet.php";
require_once "../JBBCode/BBToolkit.php";
use JBBCode\Parser;
use JBBCode\KhinenwCodeDefinitionSet;
use JBBCode\BBToolkit;
$parser = new Parser();
$parser->addCodeDefinitionSet(new KhinenwCodeDefinitionSet());
$parser->parse(BBToolkit::bracketToTag(file_get_contents(Config::$docsFolder . $docId . ".txt")));
echo BBToolkit::tagToBracket(BBToolkit::useNewLine($parser->getAsHTML()));
echo "<br><br><span class='view'>View : " . $count . "</span>";
echo "<br><span class='tag'>#</span>";
foreach ($meta["tag"] as $tag) {
    echo "<a class='tag-contents' href='show_category.php?tag=" . $tag . "'>" . $tag . "</a>&nbsp;&#124;&nbsp;";
}
echo "<hr>";
?>

                    <br><br>

                    <!-- Disqus import -->
                    <div id="disqus_thread"></div>
Esempio n. 6
0
 /**
  * Insert <br /> tag to new line.
  * @inheritdoc
  */
 public function parse($str)
 {
     $str = preg_replace('/(\\r\\n|\\n\\r|\\n|\\r)/', '<br />', $str);
     $str = preg_replace('/(<br[^>]*>[\\s]*){2}/', '<br />', $str);
     return parent::parse($str);
 }