Skip to content

Commit 6eb2bb8

Browse files
committed
refactor(textareafield): use GLPI api for HTML generation
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent bfb273f commit 6eb2bb8

9 files changed

+100
-44
lines changed

inc/fields/actorfield.class.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ public function getDesignSpecializationField() {
5454
$additions .= '</label>';
5555
$additions .= '</td>';
5656
$additions .= '<td>';
57-
$additions .= '<textarea name="default_values" id="default_values" rows="4" cols="40"'
58-
.'style="width: 90%">'
59-
.$this->question->fields['default_values']
60-
.'</textarea>';
57+
$additions .= Html::textarea([
58+
'name' => 'default_values',
59+
'id' => 'default_values',
60+
'value' => $this->question->fields['default_values'],
61+
'display' => false,
62+
]);
6163
$additions .= '</td>';
6264
$additions .= '<td>';
6365
$additions .= '</td>';

inc/fields/checkboxesfield.class.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ public function getDesignSpecializationField() {
4949
$additions .= '</label>';
5050
$additions .= '</td>';
5151
$additions .= '<td>';
52-
$additions .= '<textarea name="default_values" id="default_values" rows="4" cols="40"'
53-
.'style="width: 90%">'
54-
.$this->question->fields['default_values']
55-
.'</textarea>';
52+
$additions .= Html::textarea([
53+
'name' => 'default_values',
54+
'id' => 'default_values',
55+
'value' => $this->question->fields['default_values'],
56+
'display' => false,
57+
]);
5658
$additions .= '</td>';
5759
$additions .= '<td>';
5860
$additions .= '<label for="values'.$rand.'">';
@@ -61,10 +63,12 @@ public function getDesignSpecializationField() {
6163
$additions .= '</label>';
6264
$additions .= '</td>';
6365
$additions .= '<td>';
64-
$additions .= '<textarea name="values" id="values" rows="4" cols="40"'
65-
.'style="width: 90%">'
66-
.$this->question->fields['values']
67-
.'</textarea>';
66+
$additions .= Html::textarea([
67+
'name' => 'values',
68+
'id' => 'values',
69+
'value' => $this->question->fields['values'],
70+
'display' => false,
71+
]);
6872
$additions .= '</td>';
6973
$additions .= '</tr>';
7074

inc/fields/multiselectfield.class.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ public function getDesignSpecializationField() {
4949
$additions .= '</label>';
5050
$additions .= '</td>';
5151
$additions .= '<td>';
52-
$additions .= '<textarea name="default_values" id="default_values" rows="4" cols="40"'
53-
.'style="width: 90%">'
54-
.$this->question->fields['default_values']
55-
.'</textarea>';
52+
$additions .= Html::textarea([
53+
'name' => 'default_values',
54+
'id' => 'default_values',
55+
'value' => $this->question->fields['default_values'],
56+
'display' => false,
57+
]);
5658
$additions .= '</td>';
5759
$additions .= '<td>';
5860
$additions .= '<label for="dropdown_default_values'.$rand.'">';
@@ -61,10 +63,12 @@ public function getDesignSpecializationField() {
6163
$additions .= '</label>';
6264
$additions .= '</td>';
6365
$additions .= '<td>';
64-
$additions .= '<textarea name="values" id="values" rows="4" cols="40"'
65-
.'style="width: 90%">'
66-
.$this->question->fields['values']
67-
.'</textarea>';
66+
$additions .= Html::textarea([
67+
'name' => 'values',
68+
'id' => 'values',
69+
'value' => $this->question->fields['values'],
70+
'display' => false,
71+
]);
6872
$additions .= '</td>';
6973
$additions .= '</tr>';
7074

inc/fields/radiosfield.class.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ public function getDesignSpecializationField() {
4949
$additions .= '</label>';
5050
$additions .= '</td>';
5151
$additions .= '<td>';
52-
$additions .= '<textarea name="default_values" id="default_values" rows="4" cols="40"'
53-
.'style="width: 90%">'
54-
.$this->question->fields['default_values']
55-
.'</textarea>';
52+
$additions .= Html::textarea([
53+
'name' => 'default_values',
54+
'id' => 'default_values',
55+
'value' => $this->question->fields['default_values'],
56+
'display' => false,
57+
]);
5658
$additions .= '</td>';
5759
$additions .= '<td>';
5860
$additions .= '<label for="dropdown_default_values'.$rand.'">';
@@ -61,10 +63,12 @@ public function getDesignSpecializationField() {
6163
$additions .= '</label>';
6264
$additions .= '</td>';
6365
$additions .= '<td>';
64-
$additions .= '<textarea name="values" id="values" rows="4" cols="40"'
65-
.'style="width: 90%">'
66-
.$this->question->fields['values']
67-
.'</textarea>';
66+
$additions .= Html::textarea([
67+
'name' => 'values',
68+
'id' => 'values',
69+
'value' => $this->question->fields['values'],
70+
'display' => false,
71+
]);
6872
$additions .= '</td>';
6973
$additions .= '</tr>';
7074

inc/fields/textareafield.class.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,13 @@ public function getDesignSpecializationField() {
4444
$additions .= '</label>';
4545
$additions .= '</td>';
4646
$additions .= '<td width="80%" colspan="3">';
47-
$additions .= '<textarea name="default_values" id="default_values" rows="4" cols="40">'
48-
.Html::entities_deep($this->getValueForDesign())
49-
.'</textarea>';
47+
$additions .= Html::textarea([
48+
'name' => 'default_values',
49+
'id' => 'default_values',
50+
'value' => Html::entities_deep($this->getValueForDesign()),
51+
'enable_rich_text' => true,
52+
'display' => false,
53+
]);
5054
$additions .= Html::initEditorSystem('default_values', '', false);
5155
$additions .= '</td>';
5256
$additions .= '</tr>';

inc/form.class.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,14 @@ public function showForm($ID, $options = []) {
421421

422422
echo '<tr class="tab_bg_1">';
423423
echo '<td>' . _n('Header', 'Headers', 1, 'formcreator') . '</td>';
424-
echo '<td colspan="3"><textarea name="content" cols="124" rows="10">' . $this->fields["content"] . '</textarea></td>';
425-
Html::initEditorSystem('content');
424+
echo '<td colspan="3">';
425+
echo Html::textarea([
426+
'name' => 'content',
427+
'value' => $this->fields["content"],
428+
'enable_richtext' => true,
429+
'display' => false,
430+
]);
431+
echo '</td>';
426432
echo '</tr>';
427433

428434
echo '<tr class="tab_bg_2">';

inc/question.class.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -885,9 +885,13 @@ public function showForm($ID, $options = []) {
885885
echo '</td>';
886886

887887
echo '<td width="80%" colspan="3">';
888-
echo '<textarea name="description" id="description" rows="6" cols="108"'
889-
.'style="width: 97%">'.$this->fields['description'].'</textarea>';
890-
Html::initEditorSystem('description');
888+
echo Html::textarea([
889+
'name' => 'description',
890+
'id' => 'description',
891+
'value' => $this->fields['description'],
892+
'enable_richtext' => true,
893+
'display' => false,
894+
]);
891895
echo '</td>';
892896
echo '</tr>';
893897

inc/targetchange.class.php

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,42 +260,66 @@ public function showForm($options = []) {
260260
echo '<tr class="line0">';
261261
echo '<td><strong>' . __('Description') . ' <span style="color:red;">*</span></strong></td>';
262262
echo '<td colspan="3">';
263-
echo '<textarea name="content" style="width:700px;" rows="15">' . $this->fields['content'] . '</textarea>';
263+
echo Html::textarea([
264+
'name' => 'content',
265+
'value' => $this->fields['content'],
266+
'display' => false,
267+
]);
264268
echo '</td>';
265269
echo '</tr>';
266270

267271
echo '<tr class="line1">';
268272
echo '<td><strong>' . __('Impacts') . ' </strong></td>';
269273
echo '<td colspan="3">';
270-
echo '<textarea name="impactcontent" style="width:700px;" rows="15">' . $this->fields['impactcontent'] . '</textarea>';
274+
echo Html::textarea([
275+
'name' => 'impactcontent',
276+
'value' => $this->fields['impactcontent'],
277+
'display' => false,
278+
]);
271279
echo '</td>';
272280
echo '</tr>';
273281

274282
echo '<tr class="line0">';
275283
echo '<td><strong>' . __('Control list') . ' </strong></td>';
276284
echo '<td colspan="3">';
277-
echo '<textarea name="controlistcontent" style="width:700px;" rows="15">' . $this->fields['controlistcontent'] . '</textarea>';
285+
echo Html::textarea([
286+
'name' => 'controlistcontent',
287+
'value' => $this->fields['controlistcontent'],
288+
'display' => false,
289+
]);
278290
echo '</td>';
279291
echo '</tr>';
280292

281293
echo '<tr class="line1">';
282294
echo '<td><strong>' . __('Deployment plan') . ' </strong></td>';
283295
echo '<td colspan="3">';
284-
echo '<textarea name="rolloutplancontent" style="width:700px;" rows="15">' . $this->fields['rolloutplancontent'] . '</textarea>';
296+
echo Html::textarea([
297+
'name' => 'rolloutplancontent',
298+
'value' => $this->fields['rolloutplancontent'],
299+
'display' => false,
300+
]);
285301
echo '</td>';
286302
echo '</tr>';
287303

288304
echo '<tr class="line0">';
289305
echo '<td><strong>' . __('Backup plan') . ' </strong></td>';
290306
echo '<td colspan="3">';
291-
echo '<textarea name="backoutplancontent" style="width:700px;" rows="15">' . $this->fields['backoutplancontent'] . '</textarea>';
307+
echo Html::textarea([
308+
'name' => 'backoutplancontent',
309+
'value' => $this->fields['backoutplancontent'],
310+
'display' => false,
311+
]);
292312
echo '</td>';
293313
echo '</tr>';
294314

295315
echo '<tr class="line1">';
296316
echo '<td><strong>' . __('Checklist') . ' </strong></td>';
297317
echo '<td colspan="3">';
298-
echo '<textarea name="checklistcontent" style="width:700px;" rows="15">' . $this->fields['checklistcontent'] . '</textarea>';
318+
echo Html::textarea([
319+
'name' => 'checklistcontent',
320+
'vamue' => $this->fields['checklistcontent'],
321+
'display' => false,
322+
]);
299323
echo '</td>';
300324
echo '</tr>';
301325

inc/targetticket.class.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,12 @@ public function showForm($ID, $options = []) {
122122
echo '<tr class="line0">';
123123
echo '<td><strong>' . __('Description') . ' <span style="color:red;">*</span></strong></td>';
124124
echo '<td colspan="3">';
125-
echo '<textarea name="content" style="width:700px;" rows="15">' . $this->fields['content'] . '</textarea>';
126-
Html::initEditorSystem('content');
125+
echo Html::textarea([
126+
'name' => 'content',
127+
'value' => $this->fields['content'],
128+
'enable_richtext' => true,
129+
'display' => false,
130+
]);
127131
echo '</td>';
128132
echo '</tr>';
129133

0 commit comments

Comments
 (0)