blob: 4e66b4f4550449bf7d67dd645b5e66e5fd52b344 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
<?php
namespace Studip\Forms;
/**
* The Text class represents a part of a form that displays a user filter selection.
*/
class UserFilterInput extends Input
{
public function getValue()
{
$value = [];
foreach ($this->getContextObject()->filters as $connection) {
$filter = $connection->userfilter;
$one = [
'id' => $filter->getId(),
'attributes' => [
'text' => $filter->toString(),
'fields' => []
]
];
foreach ($filter->getFields() as $field) {
$class = get_class($field);
$one['attributes']['fields'][] = [
'id' => $field->getId(),
'attributes' => [
'type' => $class,
'typeparam' => $class::$isParameterized ? $field->datafield_id : null,
'compare-operator' => $field->getCompareOperator(),
'value' => $field->getValue()
]
];
}
$value[] = $one;
}
return json_encode($value);
}
public function getRequestValue()
{
return json_decode(\Request::get($this->name), true);
}
public function hasValidation(): bool
{
return false;
}
public function render(): string
{
$template = $GLOBALS['template_factory']->open('forms/user_filter_input');
$template->title = $this->title;
$template->name = $this->name;
$template->value = $this->getValue();
$template->id = md5(uniqid());
$template->required = $this->required;
$template->attributes = arrayToHtmlAttributes($this->attributes);
return $template->render();
}
}
|