19declare(strict_types=1);
25use Psr\Http\Message\ServerRequestInterface;
34 protected \ilLanguage
$lng;
35 protected \ilGlobalTemplateInterface
$tpl;
39 protected Data\Factory
$df;
44 protected \ILIAS\AdvancedMetaData\Services\SubObjectModes\DataTable\SupplierInterface
$adv_term_mode;
57 $this->
ctrl = $DIC->ctrl();
58 $this->
lng = $DIC->language();
59 $this->tpl =
$DIC[
"tpl"];
60 $this->ui_fac =
$DIC->ui()->factory();
61 $this->ui_ren =
$DIC->ui()->renderer();
62 $this->request =
$DIC->http()->request();
63 $this->df =
new Data\Factory();
67 $this->edit_gui_request =
$DIC->glossary()->internal()->gui()->editing()->request();
68 $this->requested_table_term_list_action = $this->edit_gui_request->getTableGlossaryTermListAction();
69 $this->requested_table_term_list_ids = $this->edit_gui_request->getTableGlossaryTermListIds();
71 $adv_service = new \ILIAS\AdvancedMetaData\Services\Services();
72 $this->adv_term_mode = $adv_service->forSubObjects(
74 $this->glossary->getRefId(),
85 if ($this->requested_table_term_list_action ===
"deleteTerms") {
87 foreach ($this->requested_table_term_list_ids as
$id) {
88 if (
$id ===
"ALL_OBJECTS") {
91 $data = $this->glossary->getTermList(
104 foreach (
$data as $term) {
105 $term_id = $term[
"id"];
107 $items[] = $this->ui_fac->modal()->interruptiveItem()->standard(
116 $items[] = $this->ui_fac->modal()->interruptiveItem()->standard(
124 echo($this->ui_ren->renderAsync([
125 $this->ui_fac->modal()->interruptive(
127 empty($items) ? $this->
lng->txt(
"no_checkbox") : $this->lng->txt(
"info_delete_sure"),
128 $this->ctrl->getFormActionByClass(
"ilobjglossarygui",
"deleteTerms")
130 ->withAffectedItems($items)
131 ->withActionButtonLabel(empty($items) ? $this->
lng->txt(
"ok") : $this->lng->txt(
"delete"))
136 $table = $this->ui_fac->table()
137 ->data($data_retrieval, $this->
lng->txt(
"cont_terms"), $columns)
140 $this->glossary->getRefId()
142 ->withActions($actions)
143 ->withRequest($this->request);
151 if ($term_glo_id != $this->glossary->getId()
155 $this->tpl->setOnScreenMessage(
"failure", $this->
lng->txt(
"glo_term_must_belong_to_glo"),
true);
156 $this->
ctrl->redirectByClass(
"ilobjglossarygui",
"listTerms");
162 $this->
ctrl->setParameterByClass(
169 $add =
" (" . $this->
lng->txt(
"glo_term_reference") .
")";
171 $link = $this->ui_fac->link()->standard(
172 $this->
lng->txt(
"glo_list_usages"),
173 $this->ctrl->getLinkTargetByClass(
"ilglossarytermgui",
"listUsages")
175 $add = sprintf($this->
lng->txt(
"glo_term_is_used_n_times"), $nr)
176 .
" [" . $this->ui_ren->render($link) .
"]";
188 $adv_ap = new \ilGlossaryAdvMetaDataAdapter($this->glossary->getRefId());
189 $this->adv_cols_order = $adv_ap->getColumnOrder();
190 foreach ($this->adv_cols_order as
$c) {
193 $columns[
"term"] = $this->ui_fac->table()->column()->text($this->
lng->txt(
"cont_term"));
195 if (empty($adv_columns)) {
196 $adv_columns = $this->adv_term_mode->getColumns();
201 foreach ($adv_columns as $k => $adv_column) {
202 $adv_column = $adv_column->withIsOptional(
true,
false);
203 $adv_columns[$k] = $adv_column;
205 $columns = array_merge($columns, $adv_columns);
207 $columns[
"language"] = $this->ui_fac->table()->column()->text($this->
lng->txt(
"language"))
208 ->withIsSortable(
false)
209 ->withIsOptional(
true,
true);
210 $columns[
"usage"] = $this->ui_fac->table()->column()->number($this->
lng->txt(
"cont_usage"))
211 ->withIsSortable(
false)
212 ->withIsOptional(
true,
true);
213 $columns[
"usage_link"] = $this->ui_fac->table()->column()->link($this->
lng->txt(
"glo_usage_link"))
214 ->withIsSortable(
false)
215 ->withIsOptional(
true,
true);
216 $columns[
"definition"] = $this->ui_fac->table()->column()->text($this->
lng->txt(
"cont_definition"))
217 ->withIsSortable(
false);
219 if ($this->glossary->getVirtualMode() ===
"coll"
222 $columns[
"glossary"] = $this->ui_fac->table()->column()->text($this->
lng->txt(
"obj_glo"))
223 ->withIsSortable(
false);
231 $query_params_namespace = [
"glo_term_list_table"];
233 $uri_copy = $this->df->uri(
234 ILIAS_HTTP_PATH .
"/" . $this->
ctrl->getLinkTargetByClass(
"ilobjglossarygui",
"copyTerms")
236 $url_builder_copy =
new UI\URLBuilder($uri_copy);
237 list($url_builder_copy, $action_parameter_token_copy, $row_id_token_copy) =
238 $url_builder_copy->acquireParameters(
239 $query_params_namespace,
244 $uri_reference = $this->df->uri(
245 ILIAS_HTTP_PATH .
"/" . $this->
ctrl->getLinkTargetByClass(
"ilobjglossarygui",
"referenceTerms")
247 $url_builder_reference =
new UI\URLBuilder($uri_reference);
248 list($url_builder_reference, $action_parameter_token_reference, $row_id_token_reference) =
249 $url_builder_reference->acquireParameters(
250 $query_params_namespace,
255 $url_builder_delete =
new UI\URLBuilder($this->df->uri($this->request->getUri()->__toString()));
256 list($url_builder_delete, $action_parameter_token_delete, $row_id_token_delete) =
257 $url_builder_delete->acquireParameters(
258 $query_params_namespace,
263 $uri_edit_definition = $this->df->uri(
264 ILIAS_HTTP_PATH .
"/" . $this->
ctrl->getLinkTargetByClass([
"ilglossarytermgui",
265 "iltermdefinitioneditorgui",
266 "ilglossarydefpagegui"],
"edit")
268 $url_builder_edit_definition =
new UI\URLBuilder($uri_edit_definition);
269 list($url_builder_edit_definition, $action_parameter_token_edit_definition, $row_id_token_edit_definition) =
270 $url_builder_edit_definition->acquireParameters(
271 $query_params_namespace,
276 $uri_edit_term = $this->df->uri(
277 ILIAS_HTTP_PATH .
"/" . $this->
ctrl->getLinkTargetByClass(
"ilglossarytermgui",
"editTerm")
279 $url_builder_edit_term =
new UI\URLBuilder($uri_edit_term);
280 list($url_builder_edit_term, $action_parameter_token_edit_term, $row_id_token_edit_term) =
281 $url_builder_edit_term->acquireParameters(
282 $query_params_namespace,
288 "copy" => $this->ui_fac->table()->action()->multi(
289 $this->
lng->txt(
"copy"),
290 $url_builder_copy->withParameter($action_parameter_token_copy,
"copyTerms"),
293 "reference" => $this->ui_fac->table()->action()->multi(
294 $this->
lng->txt(
"glo_reference"),
295 $url_builder_reference->withParameter($action_parameter_token_reference,
"referenceTerms"),
296 $row_id_token_reference
298 "delete" => $this->ui_fac->table()->action()->multi(
299 $this->
lng->txt(
"delete"),
300 $url_builder_delete->withParameter($action_parameter_token_delete,
"deleteTerms"),
306 $actions[
"edit_definition"] = $this->ui_fac->table()->action()->single(
307 $this->
lng->txt(
"cont_edit_definition"),
308 $url_builder_edit_definition->withParameter($action_parameter_token_edit_definition,
"editDefinition"),
309 $row_id_token_edit_definition
312 $actions[
"edit_term"] = $this->ui_fac->table()->action()->single(
313 $this->
lng->txt(
"cont_edit_term"),
314 $url_builder_edit_term->withParameter($action_parameter_token_edit_term,
"editTerm"),
315 $row_id_token_edit_term
323 $data_retrieval =
new class (
336 protected \ilCtrl
$ctrl;
351 $this->
ctrl = $DIC->ctrl();
354 public function getRows(
356 array $visible_column_ids,
360 ?array $additional_parameters
362 $records = $this->getRecords(
$range, $order, $filter_data);
363 foreach ($records as $idx => $record) {
364 $row_id = (
int) $record[
"term_id"];
366 $data_row = $row_builder->buildDataRow((
string) $row_id, $record);
367 if (!($this->term_perm->checkPermission(
"write", $row_id)
368 || $this->term_perm->checkPermission(
"edit_content", $row_id))) {
371 $data_row = $data_row->withDisabledAction(
"edit_definition");
372 $data_row = $data_row->withDisabledAction(
"edit_term");
379 public function getTotalRowCount(
381 ?array $additional_parameters
383 return count($this->getRecords());
386 protected function getRecords(?
Data\
Range $range =
null, ?
Data\
Order $order =
null, ?array $filter_data =
null): array
395 $data = $this->glossary->getTermList(
407 foreach (
$data as $term) {
408 $term_ids[$term[
"id"]] = new \ILIAS\AdvancedMetaData\Services\SubObjectID(
409 $this->glossary->getId(),
414 $adv_md_data = $this->adv_term_mode->getData(...$term_ids);
418 foreach (
$data as $term) {
420 $term_id = (
int) $term[
"id"];
421 $this->
ctrl->setParameterByClass(
"ilobjglossarygui",
"term_id", $term_id);
422 $this->
ctrl->setParameterByClass(
"ilglossarytermgui",
"term_id", $term_id);
423 $this->
ctrl->setParameterByClass(
"ilglossarydefpagegui",
"term_id", $term_id);
424 $records[$i][
"term_id"] = $term_id;
432 $term_obj = new \ilGlossaryTerm($term_id);
433 $term_obj->updateShortText();
434 $short_str = $term_obj->getShortText();
437 $page = new \ilGlossaryDefPage($term_id);
441 $ltexs = strrpos($short_str,
"[tex]");
442 $ltexe = strrpos($short_str,
"[/tex]");
443 if ($ltexs > $ltexe) {
445 $short_str = $page->getFirstParagraphText();
446 $short_str = strip_tags($short_str,
"<br>");
447 $ltexe = strpos($short_str,
"[/tex]", $ltexs);
455 !$page->getPageConfig()->getPreventHTMLUnmasking()
457 }
catch (\Exception
$e) {
458 $short_str =
"Error: Page is missing.";
461 $short_str = $this->ui_ren->render($this->ui_fac->legacy()->latexContent($short_str));
463 $records[$i][
"definition"] = $short_str;
465 $this->
ctrl->setParameterByClass(
"ilobjglossarygui",
"term_id", $term_id);
470 if ($nr_usage > 0 && $this->glossary->getId() == $term[
"glo_id"]) {
471 $this->
ctrl->setParameterByClass(
"ilglossarytermgui",
"term_id", $term_id);
473 $records[$i][
"usage_link"] = $this->ui_fac->link()->standard(
474 $this->lng->txt(
"glo_link_to_usages"),
475 $this->ctrl->getLinkTargetByClass(
"ilglossarytermgui",
"listUsages")
477 $this->
ctrl->setParameterByClass(
"ilglossarytermgui",
"term_id",
"");
483 if ($this->glossary->getVirtualMode() ===
"coll"
487 $records[$i][
"glossary"] = $glo_title;
491 $records[$i][
"language"] = $this->lng->txt(
"meta_l_" . $term[
"language"]);
494 $sub_obj_id = $term_ids[$term_id];
495 $adv_data = $adv_md_data->dataForSubObject($sub_obj_id);
496 foreach ($adv_data as $key => $val) {
497 $records[$i][$key] = $val;
500 foreach ($this->adv_cols_order as
$c) {
502 $records[$i][
"term"] = $term[
"term"];
510 $records = $this->orderRecords($records, $order);
514 $records = $this->limitRecords($records,
$range);
521 return $data_retrieval;
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Builds a Color from either hex- or rgb values.
Both the subject and the direction need to be specified when expressing an order.
A simple class to express a naive range of whole positive numbers.
array $requested_table_term_list_ids
string $requested_table_term_list_action
ilGlobalTemplateInterface $tpl
ilGlossaryTermPermission $term_perm
__construct(\ilObjGlossary $glossary, int $tax_node)
EditingGUIRequest $edit_gui_request
handleTermForModal(int $id)
ILIAS AdvancedMetaData Services SubObjectModes DataTable SupplierInterface $adv_term_mode
ServerRequestInterface $request
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static hasReferences(int $a_glossary_id)
Check if a glossary uses references.
static isReferenced(array $a_glo_id, int $a_term_id)
Is a term referenced by a set of glossaries.
static _lookGlossaryTerm(int $term_id)
get glossary term
static getNumberOfUsages(int $a_term_id)
static _lookGlossaryID(int $term_id)
get glossary id form term id
static _lookShortTextDirty(int $term_id)
get definition short text dirty
static _lookShortText(int $term_id)
get definition short text
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupTitle(int $obj_id)
static xml2output(string $a_text, bool $a_wysiwyg=false, bool $a_replace_lists=true, bool $unmask=true)
Converts xml from DB to output in edit textarea.
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
An entity that renders components to a string output.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.