1<?php 2namespace dokuwiki\plugin\struct\types; 3 4use dokuwiki\plugin\struct\meta\QueryBuilder; 5use dokuwiki\plugin\struct\meta\QueryBuilderWhere; 6 7class LongText extends AbstractMultiBaseType { 8 use TraitFilterPrefix; 9 10 protected $config = array( 11 'prefix' => '', 12 'postfix' => '', 13 ); 14 15 16 /** 17 * Output the stored data 18 * 19 * @param string|int $value the value stored in the database 20 * @param \Doku_Renderer $R the renderer currently used to render the data 21 * @param string $mode The mode the output is rendered in (eg. XHTML) 22 * @return bool true if $mode could be satisfied 23 */ 24 public function renderValue($value, \Doku_Renderer $R, $mode) { 25 $R->cdata($this->config['prefix'] . $value . $this->config['postfix']); 26 return true; 27 } 28 29 /** 30 * Clean line endings 31 * 32 * @param int|string $rawvalue 33 * @return int|string 34 */ 35 public function validate($rawvalue) { 36 $rawvalue = rtrim($rawvalue); 37 $rawvalue = cleanText($rawvalue); 38 return $rawvalue; 39 } 40 41 /** 42 * Use a text area for input 43 * 44 * @param string $name 45 * @param string $rawvalue 46 * @param string $htmlID 47 * 48 * @return string 49 */ 50 public function valueEditor($name, $rawvalue, $htmlID) { 51 $rawvalue = formText($rawvalue); 52 $params = array( 53 'name' => $name, 54 'class' => 'struct_'.strtolower($this->getClass()), 55 'id' => $htmlID 56 ); 57 $attributes = buildAttributes($params, true); 58 59 return "<textarea $attributes>$rawvalue</textarea>"; 60 } 61} 62