1<?php 2namespace dokuwiki\plugin\struct\types; 3 4class Text extends AbstractMultiBaseType { 5 6 protected $config = array( 7 'prefix' => '', 8 'postfix' => '', 9 ); 10 11 /** 12 * Output the stored data 13 * 14 * @param string|int $value the value stored in the database 15 * @param \Doku_Renderer $R the renderer currently used to render the data 16 * @param string $mode The mode the output is rendered in (eg. XHTML) 17 * @return bool true if $mode could be satisfied 18 */ 19 public function renderValue($value, \Doku_Renderer $R, $mode) { 20 $R->cdata($this->config['prefix'] . $value . $this->config['postfix']); 21 return true; 22 } 23 24 /** 25 * Comparisons should always be done against the full string 26 * 27 * @param string $column 28 * @param string $comp 29 * @param string $value 30 * @return array 31 */ 32 public function compare($column, $comp, $value) { 33 $opt = array(); 34 if ($this->config['prefix']) { 35 $column = "? || $column"; 36 $opt[] = $this->config['prefix']; 37 } 38 if ($this->config['postfix']) { 39 $column = "$column || ?"; 40 $opt[] = $this->config['postfix']; 41 } 42 43 // this assumes knowledge about the parent implementation which is kinda bad 44 // but avoids some code duplication 45 list($sql) = parent::compare($column, $comp, $value); 46 $opt[] = $value; 47 48 return array($sql, $opt); 49 } 50 51} 52