ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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,
52  private \ilBiblAdminFactoryFacadeInterface $facade
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  );
66 
67  $this->components[] = $this->table = $this->ui_factory->table()->ordering(
68  $data_retrieval,
69  $this->lng->txt('filter'),
70  $columns,
71  new URI(
72  ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget($this->calling_gui, \ilBiblAdminFieldGUI::CMD_SAVE_ORDERING)
73  )
74  )->withActions($actions)->withRequest(
75  $DIC->http()->request()
76  );
77  }
78 
79  private function initURIBuilder(): URLBuilder
80  {
81  $url_builder = new URLBuilder(
83  );
84 
85  // these are the query parameters this instance is controlling
86  $query_params_namespace = ['bibl'];
87  [$url_builder, $this->id_token] = $url_builder->acquireParameters(
88  $query_params_namespace,
90  );
91  return $url_builder;
92  }
93 
94  protected function initColumns(): array
95  {
96  return [
97  'identifier' => $this->ui_factory->table()->column()->text($this->lng->txt('identifier')),
98  'data_type' => $this->ui_factory->table()->column()->text($this->lng->txt('translation')),
99  'is_standard_field' => $this->ui_factory->table()->column()->text($this->lng->txt('standard'))
100  ];
101  }
102 
103  protected function initActions(): array
104  {
105  return [
106  'translate' => $this->ui_factory->table()->action()->single(
107  $this->lng->txt("translate"),
108  $this->url_builder->withURI($this->getURIWithTargetClass(\ilBiblTranslationGUI::class, \ilBiblTranslationGUI::CMD_DEFAULT)),
110  )
111  ];
112  }
113 
118  protected function getURI(string $command): URI
119  {
120  return new URI(
121  ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget(
122  $this->calling_gui,
123  $command
124  )
125  );
126  }
127 
128  protected function getURIWithTargetClass(string $target_gui, string $command): URI
129  {
130  return new URI(
131  ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTargetByClass(
132  $target_gui,
133  $command
134  )
135  );
136  }
137 
138  public function getHTML(): string
139  {
140  return $this->ui_renderer->render($this->components);
141  }
142 
143  public function getOrdering(): array
144  {
145  return $this->table->getData();
146  }
147 
148  public function getUrlBuilder(): URLBuilder
149  {
150  return $this->url_builder;
151  }
152 
153  public function getIdToken(): URLBuilderToken
154  {
155  return $this->id_token;
156  }
157 }
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:118
__construct(private \ilBiblAdminFieldGUI $calling_gui, private \ilBiblAdminFactoryFacadeInterface $facade)
ilTable constructor.
Definition: Table.php:50
global $DIC
Definition: shib_login.php:22
Builds data types.
Definition: Factory.php:35
getURIWithTargetClass(string $target_gui, string $command)
Definition: Table.php:128
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...