1<?php 2namespace dokuwiki\plugin\struct\types; 3 4use dokuwiki\plugin\struct\meta\QueryBuilderWhere; 5 6class Wiki extends AbstractBaseType { 7 use TraitFilterPrefix; 8 9 protected $config = array( 10 'prefix' => '', 11 'postfix' => '', 12 ); 13 14 /** 15 * @param int|string $value 16 * @param \Doku_Renderer $R 17 * @param string $mode 18 * @return bool 19 */ 20 public function renderValue($value, \Doku_Renderer $R, $mode) { 21 $value = $this->config['prefix'] . $value . $this->config['postfix']; 22 $doc = p_render($mode, p_get_instructions($value), $info); 23 $R->doc .= $doc; // FIXME this probably does not work for all renderers 24 return true; 25 } 26 27 /** 28 * Clean line endings 29 * 30 * @param int|string $rawvalue 31 * @return int|string 32 */ 33 public function validate($rawvalue) { 34 $rawvalue = rtrim($rawvalue); 35 $rawvalue = cleanText($rawvalue); 36 return $rawvalue; 37 } 38 39 /** 40 * Use a text area for input 41 * 42 * @param string $name 43 * @param string $rawvalue 44 * @param string $htmlID 45 * 46 * @return string 47 */ 48 public function valueEditor($name, $rawvalue, $htmlID) { 49 $class = 'struct_'.strtolower($this->getClass()); 50 $name = hsc($name); 51 $rawvalue = formText($rawvalue); 52 $id = !empty($htmlID) ? "id=\"$htmlID\"" : ''; 53 54 $html = "<textarea name=\"$name\" class=\"$class\" $id>$rawvalue</textarea>"; 55 return "$html"; 56 } 57} 58