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