164744a10SAndreas Gohr<?php 29d01c1d9SSatoshi Sahara 364744a10SAndreas Gohrnamespace dokuwiki\Form; 464744a10SAndreas Gohr 564744a10SAndreas Gohr/** 664744a10SAndreas Gohr * Class TagCloseElement 764744a10SAndreas Gohr * 864744a10SAndreas Gohr * Creates an HTML close tag. You have to make sure it has been opened 964744a10SAndreas Gohr * before or this will produce invalid HTML 1064744a10SAndreas Gohr * 1164744a10SAndreas Gohr * @package dokuwiki\Form 1264744a10SAndreas Gohr */ 139d01c1d9SSatoshi Saharaclass TagCloseElement extends ValueElement 149d01c1d9SSatoshi Sahara{ 1564744a10SAndreas Gohr /** 1664744a10SAndreas Gohr * @param string $tag 1764744a10SAndreas Gohr * @param array $attributes 1864744a10SAndreas Gohr */ 19*6fd0861fSAndreas Gohr public function __construct($tag, $attributes = []) 209d01c1d9SSatoshi Sahara { 2164744a10SAndreas Gohr parent::__construct('tagclose', $tag, $attributes); 2264744a10SAndreas Gohr } 2364744a10SAndreas Gohr 2464744a10SAndreas Gohr /** 251f5d8b65SAndreas Gohr * do not call this 261f5d8b65SAndreas Gohr * 277ec97767SGerrit Uitslag * @param string $class 281f5d8b65SAndreas Gohr * @return void 291f5d8b65SAndreas Gohr * @throws \BadMethodCallException 301f5d8b65SAndreas Gohr */ 319d01c1d9SSatoshi Sahara public function addClass($class) 329d01c1d9SSatoshi Sahara { 331f5d8b65SAndreas Gohr throw new \BadMethodCallException('You can\t add classes to closing tag'); 341f5d8b65SAndreas Gohr } 351f5d8b65SAndreas Gohr 361f5d8b65SAndreas Gohr /** 371f5d8b65SAndreas Gohr * do not call this 381f5d8b65SAndreas Gohr * 397ec97767SGerrit Uitslag * @param null|string $id 40be4223afSMichael Große * @return string 411f5d8b65SAndreas Gohr * @throws \BadMethodCallException 421f5d8b65SAndreas Gohr */ 439d01c1d9SSatoshi Sahara public function id($id = null) 449d01c1d9SSatoshi Sahara { 45be4223afSMichael Große if ($id === null) { 46be4223afSMichael Große return ''; 47be4223afSMichael Große } else { 481f5d8b65SAndreas Gohr throw new \BadMethodCallException('You can\t add ID to closing tag'); 491f5d8b65SAndreas Gohr } 50be4223afSMichael Große } 511f5d8b65SAndreas Gohr 521f5d8b65SAndreas Gohr /** 531f5d8b65SAndreas Gohr * do not call this 541f5d8b65SAndreas Gohr * 557ec97767SGerrit Uitslag * @param string $name 567ec97767SGerrit Uitslag * @param null|string $value 57be4223afSMichael Große * @return string 581f5d8b65SAndreas Gohr * @throws \BadMethodCallException 591f5d8b65SAndreas Gohr */ 609d01c1d9SSatoshi Sahara public function attr($name, $value = null) 619d01c1d9SSatoshi Sahara { 62be4223afSMichael Große if ($value === null) { 63be4223afSMichael Große return ''; 64be4223afSMichael Große } else { 651f5d8b65SAndreas Gohr throw new \BadMethodCallException('You can\t add attributes to closing tag'); 661f5d8b65SAndreas Gohr } 67be4223afSMichael Große } 681f5d8b65SAndreas Gohr 691f5d8b65SAndreas Gohr /** 701f5d8b65SAndreas Gohr * do not call this 711f5d8b65SAndreas Gohr * 727ec97767SGerrit Uitslag * @param array|null $attributes 73be4223afSMichael Große * @return array 741f5d8b65SAndreas Gohr * @throws \BadMethodCallException 751f5d8b65SAndreas Gohr */ 769d01c1d9SSatoshi Sahara public function attrs($attributes = null) 779d01c1d9SSatoshi Sahara { 78be4223afSMichael Große if ($attributes === null) { 79*6fd0861fSAndreas Gohr return []; 80be4223afSMichael Große } else { 811f5d8b65SAndreas Gohr throw new \BadMethodCallException('You can\t add attributes to closing tag'); 821f5d8b65SAndreas Gohr } 83be4223afSMichael Große } 841f5d8b65SAndreas Gohr 851f5d8b65SAndreas Gohr /** 8664744a10SAndreas Gohr * The HTML representation of this element 8764744a10SAndreas Gohr * 8864744a10SAndreas Gohr * @return string 8964744a10SAndreas Gohr */ 909d01c1d9SSatoshi Sahara public function toHTML() 919d01c1d9SSatoshi Sahara { 9264744a10SAndreas Gohr return '</' . $this->val() . '>'; 9364744a10SAndreas Gohr } 9464744a10SAndreas Gohr} 95