Skip to content

Commit bb29b5a

Browse files
authored
Merge pull request #360 from rottaran/ticket_349_longtext
Ticket #349 longtext
2 parents 29634fa + b0002ce commit bb29b5a

File tree

3 files changed

+68
-40
lines changed

3 files changed

+68
-40
lines changed

_test/Column.test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function test_allTypes() {
2121
'DateTime' => 'dokuwiki\\plugin\\struct\\types\\DateTime',
2222
'Decimal' => 'dokuwiki\\plugin\\struct\\types\\Decimal',
2323
'Dropdown' => 'dokuwiki\\plugin\\struct\\types\\Dropdown',
24+
'LongText' => 'dokuwiki\\plugin\\struct\\types\\LongText',
2425
'Lookup' => 'dokuwiki\\plugin\\struct\\types\\Lookup',
2526
'Mail' => 'dokuwiki\\plugin\\struct\\types\\Mail',
2627
'Media' => 'dokuwiki\\plugin\\struct\\types\\Media',
@@ -44,6 +45,7 @@ public function test_extendedTypes() {
4445
'DateTime' => 'dokuwiki\\plugin\\struct\\types\\DateTime',
4546
'Decimal' => 'dokuwiki\\plugin\\struct\\types\\Decimal',
4647
'Dropdown' => 'dokuwiki\\plugin\\struct\\types\\Dropdown',
48+
'LongText' => 'dokuwiki\\plugin\\struct\\types\\LongText',
4749
'Lookup' => 'dokuwiki\\plugin\\struct\\types\\Lookup',
4850
'Mail' => 'dokuwiki\\plugin\\struct\\types\\Mail',
4951
'Media' => 'dokuwiki\\plugin\\struct\\types\\Media',

types/LongText.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
namespace dokuwiki\plugin\struct\types;
3+
4+
use dokuwiki\plugin\struct\meta\QueryBuilder;
5+
use dokuwiki\plugin\struct\meta\QueryBuilderWhere;
6+
7+
class LongText extends AbstractMultiBaseType {
8+
use TraitFilterPrefix;
9+
10+
protected $config = array(
11+
'prefix' => '',
12+
'postfix' => '',
13+
'rows' => '5',
14+
'cols' => '50'
15+
);
16+
17+
18+
/**
19+
* Output the stored data
20+
*
21+
* @param string|int $value the value stored in the database
22+
* @param \Doku_Renderer $R the renderer currently used to render the data
23+
* @param string $mode The mode the output is rendered in (eg. XHTML)
24+
* @return bool true if $mode could be satisfied
25+
*/
26+
public function renderValue($value, \Doku_Renderer $R, $mode) {
27+
$R->cdata($this->config['prefix'] . $value . $this->config['postfix']);
28+
return true;
29+
}
30+
31+
/**
32+
* Clean line endings
33+
*
34+
* @param int|string $rawvalue
35+
* @return int|string
36+
*/
37+
public function validate($rawvalue) {
38+
$rawvalue = rtrim($rawvalue);
39+
$rawvalue = cleanText($rawvalue);
40+
return $rawvalue;
41+
}
42+
43+
/**
44+
* Use a text area for input
45+
*
46+
* @param string $name
47+
* @param string $rawvalue
48+
* @param string $htmlID
49+
*
50+
* @return string
51+
*/
52+
public function valueEditor($name, $rawvalue, $htmlID) {
53+
$rawvalue = formText($rawvalue);
54+
$params = array(
55+
'name' => $name,
56+
'class' => 'struct_'.strtolower($this->getClass()),
57+
'id' => $htmlID,
58+
'rows' => $this->config['rows'],
59+
'cols' => $this->config['cols']
60+
);
61+
$attributes = buildAttributes($params, true);
62+
63+
return "<textarea $attributes>$rawvalue</textarea>";
64+
}
65+
}

types/Wiki.php

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@
33

44
use dokuwiki\plugin\struct\meta\QueryBuilderWhere;
55

6-
class Wiki extends AbstractBaseType {
7-
use TraitFilterPrefix;
8-
9-
protected $config = array(
10-
'prefix' => '',
11-
'postfix' => '',
12-
);
6+
class Wiki extends LongText {
137

148
/**
159
* @param int|string $value
@@ -23,37 +17,4 @@ public function renderValue($value, \Doku_Renderer $R, $mode) {
2317
$R->doc .= $doc; // FIXME this probably does not work for all renderers
2418
return true;
2519
}
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-
$rawvalue = formText($rawvalue);
50-
$params = array(
51-
'name' => $name,
52-
'class' => 'struct_'.strtolower($this->getClass()),
53-
'id' => $htmlID
54-
);
55-
$attributes = buildAttributes($params, true);
56-
57-
return "<textarea $attributes>$rawvalue</textarea>";
58-
}
5920
}

0 commit comments

Comments
 (0)