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 'rows' => '5', 13 'cols' => '50' 14 ); 15 16 /** 17 * @param int|string $value 18 * @param \Doku_Renderer $R 19 * @param string $mode 20 * @return bool 21 */ 22 public function renderValue($value, \Doku_Renderer $R, $mode) { 23 $value = $this->config['prefix'] . $value . $this->config['postfix']; 24 $doc = p_render($mode, p_get_instructions($value), $info); 25 $R->doc .= $doc; // FIXME this probably does not work for all renderers 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 'rows' => $this->config['rows'], 57 'cols' => $this->config['cols'] 58 ); 59 $attributes = buildAttributes($params, true); 60 61 return "<textarea $attributes>$rawvalue</textarea>"; 62 } 63} 64