[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/Form/ -> FieldsetOpenElement.php (source)

   1  <?php
   2  namespace dokuwiki\Form;
   3  
   4  /**
   5   * Class FieldsetOpenElement
   6   *
   7   * Opens a Fieldset with an optional legend
   8   *
   9   * @package dokuwiki\Form
  10   */
  11  class FieldsetOpenElement extends TagOpenElement {
  12  
  13      /**
  14       * @param string $legend
  15       * @param array $attributes
  16       */
  17      public function __construct($legend='', $attributes = array()) {
  18          // this is a bit messy and we just do it for the nicer class hierarchy
  19          // the parent would expect the tag in $value but we're storing the
  20          // legend there, so we have to set the type manually
  21          parent::__construct($legend, $attributes);
  22          $this->type = 'fieldsetopen';
  23      }
  24  
  25      /**
  26       * The HTML representation of this element
  27       *
  28       * @return string
  29       */
  30      public function toHTML() {
  31          $html = '<fieldset '.buildAttributes($this->attrs()).'>';
  32          $legend = $this->val();
  33          if($legend) $html .= DOKU_LF.'<legend>'.hsc($legend).'</legend>';
  34          return $html;
  35      }
  36  }