FieldsetOpenElement.php 989 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace dokuwiki\Form;
  3. /**
  4. * Class FieldsetOpenElement
  5. *
  6. * Opens a Fieldset with an optional legend
  7. *
  8. * @package dokuwiki\Form
  9. */
  10. class FieldsetOpenElement extends TagOpenElement
  11. {
  12. /**
  13. * @param string $legend
  14. * @param array $attributes
  15. */
  16. public function __construct($legend='', $attributes = array())
  17. {
  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. * The HTML representation of this element
  26. *
  27. * @return string
  28. */
  29. public function toHTML()
  30. {
  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. }