112a4e4d1SAndreas Gohr<?php 212a4e4d1SAndreas Gohrnamespace dokuwiki\Form; 312a4e4d1SAndreas Gohr 412a4e4d1SAndreas Gohr/** 512a4e4d1SAndreas Gohr * Class TextareaElement 612a4e4d1SAndreas Gohr * @package dokuwiki\Form 712a4e4d1SAndreas Gohr */ 812a4e4d1SAndreas Gohrclass TextareaElement extends InputElement { 912a4e4d1SAndreas Gohr 1012a4e4d1SAndreas Gohr /** 1112a4e4d1SAndreas Gohr * @var string the actual text within the area 1212a4e4d1SAndreas Gohr */ 1312a4e4d1SAndreas Gohr protected $text; 1412a4e4d1SAndreas Gohr 1512a4e4d1SAndreas Gohr /** 1612a4e4d1SAndreas Gohr * @param string $name The name of this form element 1712a4e4d1SAndreas Gohr * @param string $label The label text for this element 1812a4e4d1SAndreas Gohr */ 1912a4e4d1SAndreas Gohr public function __construct($name, $label) { 2012a4e4d1SAndreas Gohr parent::__construct('textarea', $name, $label); 21de19515fSAndreas Gohr $this->attr('dir', 'auto'); 2212a4e4d1SAndreas Gohr } 2312a4e4d1SAndreas Gohr 2412a4e4d1SAndreas Gohr /** 2512a4e4d1SAndreas Gohr * Get or set the element's value 2612a4e4d1SAndreas Gohr * 2712a4e4d1SAndreas Gohr * This is the preferred way of setting the element's value 2812a4e4d1SAndreas Gohr * 2912a4e4d1SAndreas Gohr * @param null|string $value 3012a4e4d1SAndreas Gohr * @return string|$this 3112a4e4d1SAndreas Gohr */ 3212a4e4d1SAndreas Gohr public function val($value = null) { 3312a4e4d1SAndreas Gohr if($value !== null) { 34*6834946fSAndreas Gohr $this->text = cleanText($value); 3512a4e4d1SAndreas Gohr return $this; 3612a4e4d1SAndreas Gohr } 3712a4e4d1SAndreas Gohr return $this->text; 3812a4e4d1SAndreas Gohr } 3912a4e4d1SAndreas Gohr 4012a4e4d1SAndreas Gohr /** 4112a4e4d1SAndreas Gohr * The HTML representation of this element 4212a4e4d1SAndreas Gohr * 4312a4e4d1SAndreas Gohr * @return string 4412a4e4d1SAndreas Gohr */ 4512a4e4d1SAndreas Gohr protected function mainElementHTML() { 4612a4e4d1SAndreas Gohr if($this->useInput) $this->prefillInput(); 4712a4e4d1SAndreas Gohr return '<textarea ' . buildAttributes($this->attrs()) . '>' . 4812a4e4d1SAndreas Gohr formText($this->val()) . '</textarea>'; 4912a4e4d1SAndreas Gohr } 5012a4e4d1SAndreas Gohr 5112a4e4d1SAndreas Gohr} 52