diff --git a/_test/Column.test.php b/_test/Column.test.php index b1c14341..9ac1c22d 100644 --- a/_test/Column.test.php +++ b/_test/Column.test.php @@ -21,6 +21,7 @@ public function test_allTypes() { 'DateTime' => 'dokuwiki\\plugin\\struct\\types\\DateTime', 'Decimal' => 'dokuwiki\\plugin\\struct\\types\\Decimal', 'Dropdown' => 'dokuwiki\\plugin\\struct\\types\\Dropdown', + 'LongText' => 'dokuwiki\\plugin\\struct\\types\\LongText', 'Lookup' => 'dokuwiki\\plugin\\struct\\types\\Lookup', 'Mail' => 'dokuwiki\\plugin\\struct\\types\\Mail', 'Media' => 'dokuwiki\\plugin\\struct\\types\\Media', @@ -44,6 +45,7 @@ public function test_extendedTypes() { 'DateTime' => 'dokuwiki\\plugin\\struct\\types\\DateTime', 'Decimal' => 'dokuwiki\\plugin\\struct\\types\\Decimal', 'Dropdown' => 'dokuwiki\\plugin\\struct\\types\\Dropdown', + 'LongText' => 'dokuwiki\\plugin\\struct\\types\\LongText', 'Lookup' => 'dokuwiki\\plugin\\struct\\types\\Lookup', 'Mail' => 'dokuwiki\\plugin\\struct\\types\\Mail', 'Media' => 'dokuwiki\\plugin\\struct\\types\\Media', diff --git a/types/LongText.php b/types/LongText.php new file mode 100644 index 00000000..5188c232 --- /dev/null +++ b/types/LongText.php @@ -0,0 +1,65 @@ + '', + 'postfix' => '', + 'rows' => '5', + 'cols' => '50' + ); + + + /** + * Output the stored data + * + * @param string|int $value the value stored in the database + * @param \Doku_Renderer $R the renderer currently used to render the data + * @param string $mode The mode the output is rendered in (eg. XHTML) + * @return bool true if $mode could be satisfied + */ + public function renderValue($value, \Doku_Renderer $R, $mode) { + $R->cdata($this->config['prefix'] . $value . $this->config['postfix']); + return true; + } + + /** + * Clean line endings + * + * @param int|string $rawvalue + * @return int|string + */ + public function validate($rawvalue) { + $rawvalue = rtrim($rawvalue); + $rawvalue = cleanText($rawvalue); + return $rawvalue; + } + + /** + * Use a text area for input + * + * @param string $name + * @param string $rawvalue + * @param string $htmlID + * + * @return string + */ + public function valueEditor($name, $rawvalue, $htmlID) { + $rawvalue = formText($rawvalue); + $params = array( + 'name' => $name, + 'class' => 'struct_'.strtolower($this->getClass()), + 'id' => $htmlID, + 'rows' => $this->config['rows'], + 'cols' => $this->config['cols'] + ); + $attributes = buildAttributes($params, true); + + return ""; + } +} diff --git a/types/Wiki.php b/types/Wiki.php index c54077e0..9270acd6 100644 --- a/types/Wiki.php +++ b/types/Wiki.php @@ -3,13 +3,7 @@ use dokuwiki\plugin\struct\meta\QueryBuilderWhere; -class Wiki extends AbstractBaseType { - use TraitFilterPrefix; - - protected $config = array( - 'prefix' => '', - 'postfix' => '', - ); +class Wiki extends LongText { /** * @param int|string $value @@ -23,37 +17,4 @@ public function renderValue($value, \Doku_Renderer $R, $mode) { $R->doc .= $doc; // FIXME this probably does not work for all renderers return true; } - - /** - * Clean line endings - * - * @param int|string $rawvalue - * @return int|string - */ - public function validate($rawvalue) { - $rawvalue = rtrim($rawvalue); - $rawvalue = cleanText($rawvalue); - return $rawvalue; - } - - /** - * Use a text area for input - * - * @param string $name - * @param string $rawvalue - * @param string $htmlID - * - * @return string - */ - public function valueEditor($name, $rawvalue, $htmlID) { - $rawvalue = formText($rawvalue); - $params = array( - 'name' => $name, - 'class' => 'struct_'.strtolower($this->getClass()), - 'id' => $htmlID - ); - $attributes = buildAttributes($params, true); - - return ""; - } }