コード例 #1
0
 /**
  * @inheritdoc
  */
 public function __construct()
 {
     parent::__construct();
     /* [quote] blockquote tag */
     $builder = new CodeDefinitionBuilder('quote', '<blockquote><p>{param}</p></blockquote>');
     array_push($this->definitions, $builder->build());
     /* [p] paragraph tag */
     $builder = new CodeDefinitionBuilder('p', '<p>{param}</p>');
     array_push($this->definitions, $builder->build());
     /* [h=1|2|3|4|5|6] header tag */
     $builder = new CodeDefinitionBuilder('h', '<h{option}>{param}</h{option}>');
     $builder->setUseOption(true)->setOptionValidator(new NumberValidator(['integerOnly' => true, 'min' => 1, 'max' => 6]));
     array_push($this->definitions, $builder->build());
     /* [center] align text by center */
     $builder = new CodeDefinitionBuilder('center', '<div style="text-align: center">{param}</div>');
     array_push($this->definitions, $builder->build());
     /* [left] align text by left of edge */
     $builder = new CodeDefinitionBuilder('left', '<div style="text-align: left">{param}</div>');
     array_push($this->definitions, $builder->build());
     /* [right] align text by right of edge */
     $builder = new CodeDefinitionBuilder('right', '<div style="text-align: right">{param}</div>');
     array_push($this->definitions, $builder->build());
     /* [hr] separate, horizontal line */
     $builder = new CodeDefinitionBuilder('hr', '<hr />');
     $builder->setParseContent(false);
     array_push($this->definitions, $builder->build());
     /* [list] with marker */
     array_push($this->definitions, new ListMarkerCodeDefinition());
     /* [list=1] with number */
     array_push($this->definitions, new ListNumberCodeDefinition());
     /* [table] table */
     array_push($this->definitions, new TableCodeDefinition());
 }
コード例 #2
0
ファイル: Parser.php プロジェクト: jensdoecke/responsive-pot
 /**
  * Adds a simple (text-replacement only) bbcode definition
  *
  * @param string  $tagName      the tag name of the code (for example the b in [b])
  * @param string  $replace      the html to use, with {param} and optionally {option} for replacements
  * @param boolean $useOption    whether or not this bbcode uses the secondary {option} replacement
  * @param boolean $parseContent whether or not to parse the content within these elements
  * @param integer $nestLimit    an optional limit of the number of elements of this kind that can be nested within
  *                              each other before the parser stops parsing them.
  * @param InputValidator $optionValidator   the validator to run {option} through
  * @param BodyValidator  $bodyValidator     the validator to run {param} through (only used if $parseContent == false)
  */
 public function addBBCode($tagName, $replace, $useOption = false, $parseContent = true, $nestLimit = -1, InputValidator $optionValidator = null, InputValidator $bodyValidator = null)
 {
     $builder = new CodeDefinitionBuilder($tagName, $replace);
     $builder->setUseOption($useOption);
     $builder->setParseContent($parseContent);
     $builder->setNestLimit($nestLimit);
     if ($optionValidator) {
         $builder->setOptionValidator($optionValidator);
     }
     if ($bodyValidator) {
         $builder->setBodyValidator($bodyValidator);
     }
     $this->addCodeDefinition($builder->build());
 }