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_ORDER = 'pos';
31 public const string TABLE_COL_ANSWER = 'answer';
32 public const string TABLE_COL_CURRENT_VOTES = 'votes';
33 public const string TABLE_COL_CURRENT_PERCENTAGE = 'percentage';
34 protected const string LNG_TABLE_COL_ORDER = 'poll_sortorder';
35 protected const string LNG_TABLE_COL_ANSWER = 'poll_answer';
36 protected const string LNG_TABLE_COL_CURRENT_VOTES = 'poll_absolute';
37 protected const string LNG_TABLE_COL_CURRENT_PERCENTAGE = 'poll_percentage';
38 protected const string TABLE_ID = 'pllnswrtbl';
39
40 public function __construct(
41 protected DataRetrieval $data_retrieval,
42 protected UIFactory $ui_factory,
43 protected ilLanguage $lng,
44 protected HTTPServices $http_services
45 ) {
46 }
47
48 protected function getColumns(): array
49 {
50 $columns = [
51 self::TABLE_COL_ORDER => $this->ui_factory->table()->column()->number(
52 $this->lng->txt(self::LNG_TABLE_COL_ORDER)
53 ),
54 self::TABLE_COL_ANSWER => $this->ui_factory->table()->column()->text(
55 $this->lng->txt(self::LNG_TABLE_COL_ANSWER)
56 )->withHighlight(true),
57 self::TABLE_COL_CURRENT_VOTES => $this->ui_factory->table()->column()->number(
58 $this->lng->txt(self::LNG_TABLE_COL_CURRENT_VOTES)
59 ),
60 self::TABLE_COL_CURRENT_PERCENTAGE => $this->ui_factory->table()->column()->number(
61 $this->lng->txt(self::LNG_TABLE_COL_CURRENT_PERCENTAGE)
62 )->withUnit('%')
63 ];
64 return $columns;
65 }
66
67 public function get(): DataTable
68 {
69 $title = $this->lng->txt("poll_question") . ": \"" . $this->data_retrieval->getQuestion() . "\"";
70 return $this->ui_factory->table()->data(
71 $this->data_retrieval,
72 $title,
73 $this->getColumns()
74 )->withId(self::TABLE_ID)->withRequest($this->http_services->request());
75 }
76}
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