164744a10SAndreas Gohr<?php 29d01c1d9SSatoshi Sahara 364744a10SAndreas Gohrnamespace dokuwiki\Form; 464744a10SAndreas Gohr 564744a10SAndreas Gohr/** 664744a10SAndreas Gohr * Class FieldsetOpenElement 764744a10SAndreas Gohr * 864744a10SAndreas Gohr * Opens a Fieldset with an optional legend 964744a10SAndreas Gohr * 1064744a10SAndreas Gohr * @package dokuwiki\Form 1164744a10SAndreas Gohr */ 129d01c1d9SSatoshi Saharaclass FieldsetOpenElement extends TagOpenElement 139d01c1d9SSatoshi Sahara{ 1464744a10SAndreas Gohr /** 1564744a10SAndreas Gohr * @param string $legend 1664744a10SAndreas Gohr * @param array $attributes 1764744a10SAndreas Gohr */ 18*6fd0861fSAndreas Gohr public function __construct($legend = '', $attributes = []) 199d01c1d9SSatoshi Sahara { 2064744a10SAndreas Gohr // this is a bit messy and we just do it for the nicer class hierarchy 2164744a10SAndreas Gohr // the parent would expect the tag in $value but we're storing the 2264744a10SAndreas Gohr // legend there, so we have to set the type manually 2364744a10SAndreas Gohr parent::__construct($legend, $attributes); 2464744a10SAndreas Gohr $this->type = 'fieldsetopen'; 2564744a10SAndreas Gohr } 2664744a10SAndreas Gohr 2764744a10SAndreas Gohr /** 2864744a10SAndreas Gohr * The HTML representation of this element 2964744a10SAndreas Gohr * 3064744a10SAndreas Gohr * @return string 3164744a10SAndreas Gohr */ 329d01c1d9SSatoshi Sahara public function toHTML() 339d01c1d9SSatoshi Sahara { 3464744a10SAndreas Gohr $html = '<fieldset ' . buildAttributes($this->attrs()) . '>'; 3564744a10SAndreas Gohr $legend = $this->val(); 3664744a10SAndreas Gohr if ($legend) $html .= DOKU_LF . '<legend>' . hsc($legend) . '</legend>'; 3764744a10SAndreas Gohr return $html; 3864744a10SAndreas Gohr } 3964744a10SAndreas Gohr} 40