ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
TableBuilder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\HTTP\Services as HTTPServices;
24use ILIAS\UI\Component\Table\Data as DataTable;
25use ILIAS\UI\Factory as UIFactory;
26use ilLanguage;
27
29{
30 public const string TABLE_COL_LOGIN = 'login';
31 public const string TABLE_COL_LASTNAME = 'lastname';
32 public const string TABLE_COL_FIRSTNAME = 'firstname';
33 public const string TABLE_COL_ANSWER_PREFIX = 'answer';
34 public const string LNG_TABLE_COL_LOGIN = 'login';
35 public const string LNG_TABLE_COL_LASTNAME = 'lastname';
36 public const string LNG_TABLE_COL_FIRSTNAME = 'firstname';
37 protected const string TABLE_ID = 'pllusrtbl';
38
39 public function __construct(
40 protected DataRetrieval $data_retrieval,
41 protected UIFactory $ui_factory,
42 protected ilLanguage $lng,
43 protected HTTPServices $http_services
44 ) {
45 }
46
47 public function getColumns(): array
48 {
49 $columns = [
50 self::TABLE_COL_LOGIN => $this->ui_factory->table()->column()->text(
51 $this->lng->txt(self::LNG_TABLE_COL_LOGIN)
52 )->withHighlight(true),
53 self::TABLE_COL_FIRSTNAME => $this->ui_factory->table()->column()->text(
54 $this->lng->txt(self::LNG_TABLE_COL_FIRSTNAME)
55 ),
56 self::TABLE_COL_LASTNAME => $this->ui_factory->table()->column()->text(
57 $this->lng->txt(self::LNG_TABLE_COL_LASTNAME)
58 )
59 ];
60
61 foreach ($this->data_retrieval->getAnswers() as $answer) {
62 $columns[self::TABLE_COL_ANSWER_PREFIX . (int) ($answer["id"] ?? 0)] = $this->ui_factory->table()->column()->statusIcon(
63 (string) ($answer["answer"] ?? '')
64 );
65 }
66 return $columns;
67 }
68
69 public function get(): DataTable
70 {
71 $title = $this->lng->txt("poll_question") . ": \"" . $this->data_retrieval->getPollQuestion() . "\"";
72 return $this->ui_factory->table()->data(
73 $this->data_retrieval,
74 $title,
75 $this->getColumns()
76 )->withId(self::TABLE_ID)->withRequest($this->http_services->request());
77 }
78}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Class Services.
Definition: Services.php:43
__construct(protected DataRetrieval $data_retrieval, protected UIFactory $ui_factory, protected ilLanguage $lng, protected HTTPServices $http_services)
language handling
This describes a Data Table.
Definition: Data.php:33
global $lng
Definition: privfeed.php:26