Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _test/Column.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down
65 changes: 65 additions & 0 deletions types/LongText.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
namespace dokuwiki\plugin\struct\types;

use dokuwiki\plugin\struct\meta\QueryBuilder;
use dokuwiki\plugin\struct\meta\QueryBuilderWhere;

class LongText extends AbstractMultiBaseType {
use TraitFilterPrefix;

protected $config = array(
'prefix' => '',
'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 "<textarea $attributes>$rawvalue</textarea>";
}
}
41 changes: 1 addition & 40 deletions types/Wiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 "<textarea $attributes>$rawvalue</textarea>";
}
}