ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
Table.php
Go to the documentation of this file.
1 <?php
2 
20 
27 use ILIAS\Data\URI;
30 
35 class Table
36 {
39  private \ilCtrlInterface $ctrl;
40  private \ilLanguage $lng;
41  private URLBuilder $url_builder;
43  private Ordering $table;
44 
45  protected array $components = [];
46 
50  public function __construct(
51  private \ilBiblAdminFieldGUI $calling_gui,
53  ) {
54  global $DIC;
55  $this->ui_factory = $DIC['ui.factory'];
56  $this->ui_renderer = $DIC['ui.renderer'];
57  $this->ctrl = $DIC['ilCtrl'];
58  $this->lng = $DIC['lng'];
59 
60  $this->url_builder = $this->initURIBuilder();
61  $columns = $this->initColumns();
62  $actions = $this->initActions();
63  $data_retrieval = new DataRetrieval(
64  $facade,
65  $calling_gui->checkPermissionBoolAndReturn('write')
66  );
67 
68  $this->components[] = $this->table = $this->ui_factory->table()->ordering(
69  $data_retrieval,
70  $this->lng->txt('filter'),
71  $columns,
72  new URI(
73  ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget($this->calling_gui, \ilBiblAdminFieldGUI::CMD_SAVE_ORDERING)
74  )
75  )->withActions($actions)->withRequest(
76  $DIC->http()->request()
77  );
78  }
79 
80  private function initURIBuilder(): URLBuilder
81  {
82  $url_builder = new URLBuilder(
84  );
85 
86  // these are the query parameters this instance is controlling
87  $query_params_namespace = ['bibl'];
88  [$url_builder, $this->id_token] = $url_builder->acquireParameters(
89  $query_params_namespace,
91  );
92  return $url_builder;
93  }
94 
95  protected function initColumns(): array
96  {
97  return [
98  'identifier' => $this->ui_factory->table()->column()->text($this->lng->txt('identifier')),
99  'data_type' => $this->ui_factory->table()->column()->text($this->lng->txt('translation')),
100  'is_standard_field' => $this->ui_factory->table()->column()->text($this->lng->txt('standard'))
101  ];
102  }
103 
104  protected function initActions(): array
105  {
106  return [
107  'translate' => $this->ui_factory->table()->action()->single(
108  $this->lng->txt("translate"),
109  $this->url_builder->withURI($this->getURIWithTargetClass(\ilBiblTranslationGUI::class, \ilBiblTranslationGUI::CMD_DEFAULT)),
111  )
112  ];
113  }
114 
119  protected function getURI(string $command): URI
120  {
121  return new URI(
122  ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget(
123  $this->calling_gui,
124  $command
125  )
126  );
127  }
128 
129  protected function getURIWithTargetClass(string $target_gui, string $command): URI
130  {
131  return new URI(
132  ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTargetByClass(
133  $target_gui,
134  $command
135  )
136  );
137  }
138 
139  public function getHTML(): string
140  {
141  return $this->ui_renderer->render($this->components);
142  }
143 
144  public function getOrdering(): array
145  {
146  return $this->table->getData();
147  }
148 
149  public function getUrlBuilder(): URLBuilder
150  {
151  return $this->url_builder;
152  }
153 
154  public function getIdToken(): URLBuilderToken
155  {
156  return $this->id_token;
157  }
158 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getURI(string $command)
Unfortunately, I have not yet found an easier way to generate this URI.
Definition: Table.php:119
global $DIC
Definition: shib_login.php:26
Builds data types.
Definition: Factory.php:35
checkPermissionBoolAndReturn(string $permission)
getURIWithTargetClass(string $target_gui, string $command)
Definition: Table.php:129
__construct(private \ilBiblAdminFieldGUI $calling_gui, \ilBiblAdminFactoryFacadeInterface $facade)
ilTable constructor.
Definition: Table.php:50
Class ilChatroomConfigFileHandler .