ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
QuestionsBrowserFilter.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\UI\Factory as UIFactory;
27use ilLanguage;
29use ilUIService;
30use Psr\Http\Message\ServerRequestInterface;
31
33{
34 public function __construct(
35 private readonly ilUIService $ui_service,
36 private readonly ilLanguage $lng,
37 private readonly UIFactory $ui_factory,
38 private readonly string $filter_id,
39 private readonly string $parent_title
40 ) {
41 }
42
43 public function getComponent(string $action, ServerRequestInterface $request): Filter
44 {
45 $filter_inputs = [];
46 $is_input_initially_rendered = [];
47 $field_factory = $this->ui_factory->input()->field();
48
49 foreach ($this->getFields($field_factory) as $filter_id => $filter) {
50 [$filter_inputs[$filter_id], $is_input_initially_rendered[$filter_id]] = $filter;
51 }
52
53 $component = $this->ui_service->filter()->standard(
54 $this->filter_id,
55 $action,
56 $filter_inputs,
57 $is_input_initially_rendered,
58 true,
59 true
60 );
61
62 return $request->getMethod() === 'POST' ? $component->withRequest($request) : $component;
63 }
64
70 private function getFields(FieldFactory $input): array
71 {
72 $lifecycle_options = array_merge(
73 ['' => $this->lng->txt('qst_lifecycle_filter_all')],
74 ilAssQuestionLifecycle::getDraftInstance()->getSelectOptions($this->lng)
75 );
76 $yes_no_all_options = [
77 '' => $this->lng->txt('resulttable_all'),
78 'true' => $this->lng->txt('yes'),
79 'false' => $this->lng->txt('no')
80 ];
81
82 return [
83 'title' => [$input->text($this->lng->txt('tst_question_title')), true],
84 'description' => [$input->text($this->lng->txt('description')), false],
85 'type' => [$input->select($this->lng->txt('tst_question_type'), $this->resolveQuestionTypeFilterOptions()), true],
86 'author' => [$input->text($this->lng->txt('author')), false],
87 'lifecycle' => [$input->select($this->lng->txt('qst_lifecycle'), $lifecycle_options), false],
88 'parent_title' => [$input->text($this->lng->txt($this->parent_title)), true],
89 'taxonomy_title' => [$input->text($this->lng->txt('taxonomy_title')), true],
90 'taxonomy_node_title' => [$input->text($this->lng->txt('taxonomy_node_title')), true],
91 'feedback' => [$input->select($this->lng->txt('feedback'), $yes_no_all_options), false],
92 ];
93 }
94
95 private function resolveQuestionTypeFilterOptions(): array
96 {
97 $question_type_options = ['' => $this->lng->txt('filter_all_question_types')];
98
99 foreach (ilObjQuestionPool::_getQuestionTypes() as $translation => $row) {
100 $question_type_options[$row['type_tag']] = $translation;
101 }
102 return $question_type_options;
103 }
104}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
__construct(private readonly ilUIService $ui_service, private readonly ilLanguage $lng, private readonly UIFactory $ui_factory, private readonly string $filter_id, private readonly string $parent_title)
getComponent(string $action, ServerRequestInterface $request)
language handling
static _getQuestionTypes($all_tags=false, $fixOrder=false, $withDeprecatedTypes=true)
Filter service.
This describes commonalities between all filters.
Definition: Filter.php:34
withRequest(ServerRequestInterface $request)
Get a Filter like this where data from the request is attached.
This is what a factory for input fields looks like.
Definition: Factory.php:31
global $lng
Definition: privfeed.php:31