3 declare(strict_types=1);
35 protected \ilLanguage
$lng;
36 protected \ilGlobalTemplateInterface
$tpl;
40 protected Data\Factory
$df;
45 protected \ILIAS\AdvancedMetaData\Services\SubObjectModes\DataTable\SupplierInterface
$adv_term_mode;
58 $this->
ctrl = $DIC->ctrl();
59 $this->
lng = $DIC->language();
60 $this->tpl = $DIC[
"tpl"];
61 $this->ui_fac = $DIC->ui()->factory();
62 $this->ui_ren = $DIC->ui()->renderer();
63 $this->request = $DIC->http()->request();
64 $this->df =
new Data\Factory();
68 $this->edit_gui_request = $DIC->glossary()->internal()->gui()->editing()->request();
69 $this->requested_table_term_list_action = $this->edit_gui_request->getTableGlossaryTermListAction();
70 $this->requested_table_term_list_ids = $this->edit_gui_request->getTableGlossaryTermListIds();
72 $adv_service = new \ILIAS\AdvancedMetaData\Services\Services();
73 $this->adv_term_mode = $adv_service->forSubObjects(
75 $this->glossary->getRefId(),
86 if ($this->requested_table_term_list_action ===
"deleteTerms") {
88 foreach ($this->requested_table_term_list_ids as
$id) {
89 if ($id ===
"ALL_OBJECTS") {
92 $data = $this->glossary->getTermList(
105 foreach (
$data as $term) {
106 $term_id = $term[
"id"];
108 $items[] = $this->ui_fac->modal()->interruptiveItem()->standard(
117 $items[] = $this->ui_fac->modal()->interruptiveItem()->standard(
125 echo($this->ui_ren->renderAsync([
126 $this->ui_fac->modal()->interruptive(
128 empty($items) ? $this->
lng->txt(
"no_checkbox") : $this->
lng->txt(
"info_delete_sure"),
129 $this->
ctrl->getFormActionByClass(
"ilobjglossarygui",
"deleteTerms")
131 ->withAffectedItems($items)
132 ->withActionButtonLabel(empty($items) ? $this->
lng->txt(
"ok") : $this->
lng->txt(
"delete"))
137 $table = $this->ui_fac->table()
138 ->data($this->
lng->txt(
"cont_terms"), $columns, $data_retrieval)
141 $this->glossary->getRefId()
143 ->withActions($actions)
144 ->withRequest($this->request);
152 if ($term_glo_id != $this->glossary->getId()
156 $this->tpl->setOnScreenMessage(
"failure", $this->
lng->txt(
"glo_term_must_belong_to_glo"),
true);
157 $this->
ctrl->redirectByClass(
"ilobjglossarygui",
"listTerms");
163 $this->
ctrl->setParameterByClass(
170 $add =
" (" . $this->
lng->txt(
"glo_term_reference") .
")";
172 $link = $this->ui_fac->link()->standard(
173 $this->
lng->txt(
"glo_list_usages"),
174 $this->
ctrl->getLinkTargetByClass(
"ilglossarytermgui",
"listUsages")
176 $add = sprintf($this->
lng->txt(
"glo_term_is_used_n_times"), $nr)
177 .
" [" . $this->ui_ren->render($link) .
"]";
189 $adv_ap = new \ilGlossaryAdvMetaDataAdapter($this->glossary->getRefId());
190 $this->adv_cols_order = $adv_ap->getColumnOrder();
191 foreach ($this->adv_cols_order as
$c) {
194 $columns[
"term"] = $this->ui_fac->table()->column()->text($this->
lng->txt(
"cont_term"));
196 if (empty($adv_columns)) {
197 $adv_columns = $this->adv_term_mode->getColumns();
202 foreach ($adv_columns as $k => $adv_column) {
203 $adv_column = $adv_column->withIsOptional(
true,
false);
204 $adv_columns[$k] = $adv_column;
206 $columns = array_merge($columns, $adv_columns);
208 $columns[
"language"] = $this->ui_fac->table()->column()->text($this->
lng->txt(
"language"))
209 ->withIsSortable(
false)
210 ->withIsOptional(
true,
true);
211 $columns[
"usage"] = $this->ui_fac->table()->column()->number($this->
lng->txt(
"cont_usage"))
212 ->withIsSortable(
false)
213 ->withIsOptional(
true,
true);
214 $columns[
"usage_link"] = $this->ui_fac->table()->column()->link($this->
lng->txt(
"glo_usage_link"))
215 ->withIsSortable(
false)
216 ->withIsOptional(
true,
true);
217 $columns[
"definition"] = $this->ui_fac->table()->column()->text($this->
lng->txt(
"cont_definition"))
218 ->withIsSortable(
false);
220 if ($this->glossary->getVirtualMode() ===
"coll" 223 $columns[
"glossary"] = $this->ui_fac->table()->column()->text($this->
lng->txt(
"obj_glo"))
224 ->withIsSortable(
false);
232 $query_params_namespace = [
"glo_term_list_table"];
234 $uri_copy = $this->df->uri(
235 ILIAS_HTTP_PATH .
"/" . $this->
ctrl->getLinkTargetByClass(
"ilobjglossarygui",
"copyTerms")
237 $url_builder_copy =
new UI\URLBuilder($uri_copy);
238 list($url_builder_copy, $action_parameter_token_copy, $row_id_token_copy) =
239 $url_builder_copy->acquireParameters(
240 $query_params_namespace,
245 $uri_reference = $this->df->uri(
246 ILIAS_HTTP_PATH .
"/" . $this->
ctrl->getLinkTargetByClass(
"ilobjglossarygui",
"referenceTerms")
248 $url_builder_reference =
new UI\URLBuilder($uri_reference);
249 list($url_builder_reference, $action_parameter_token_reference, $row_id_token_reference) =
250 $url_builder_reference->acquireParameters(
251 $query_params_namespace,
256 $url_builder_delete =
new UI\URLBuilder($this->df->uri($this->request->getUri()->__toString()));
257 list($url_builder_delete, $action_parameter_token_delete, $row_id_token_delete) =
258 $url_builder_delete->acquireParameters(
259 $query_params_namespace,
264 $uri_edit_definition = $this->df->uri(
265 ILIAS_HTTP_PATH .
"/" . $this->
ctrl->getLinkTargetByClass([
"ilglossarytermgui",
266 "iltermdefinitioneditorgui",
267 "ilglossarydefpagegui"],
"edit")
269 $url_builder_edit_definition =
new UI\URLBuilder($uri_edit_definition);
270 list($url_builder_edit_definition, $action_parameter_token_edit_definition, $row_id_token_edit_definition) =
271 $url_builder_edit_definition->acquireParameters(
272 $query_params_namespace,
277 $uri_edit_term = $this->df->uri(
278 ILIAS_HTTP_PATH .
"/" . $this->
ctrl->getLinkTargetByClass(
"ilglossarytermgui",
"editTerm")
280 $url_builder_edit_term =
new UI\URLBuilder($uri_edit_term);
281 list($url_builder_edit_term, $action_parameter_token_edit_term, $row_id_token_edit_term) =
282 $url_builder_edit_term->acquireParameters(
283 $query_params_namespace,
289 "copy" => $this->ui_fac->table()->action()->multi(
290 $this->
lng->txt(
"copy"),
291 $url_builder_copy->withParameter($action_parameter_token_copy,
"copyTerms"),
294 "reference" => $this->ui_fac->table()->action()->multi(
295 $this->
lng->txt(
"glo_reference"),
296 $url_builder_reference->withParameter($action_parameter_token_reference,
"referenceTerms"),
297 $row_id_token_reference
299 "delete" => $this->ui_fac->table()->action()->multi(
300 $this->
lng->txt(
"delete"),
301 $url_builder_delete->withParameter($action_parameter_token_delete,
"deleteTerms"),
307 $actions[
"edit_definition"] = $this->ui_fac->table()->action()->single(
308 $this->
lng->txt(
"cont_edit_definition"),
309 $url_builder_edit_definition->withParameter($action_parameter_token_edit_definition,
"editDefinition"),
310 $row_id_token_edit_definition
313 $actions[
"edit_term"] = $this->ui_fac->table()->action()->single(
314 $this->
lng->txt(
"cont_edit_term"),
315 $url_builder_edit_term->withParameter($action_parameter_token_edit_term,
"editTerm"),
316 $row_id_token_edit_term
324 $data_retrieval =
new class (
336 protected \ilCtrl
$ctrl;
340 protected int $tax_node,
341 protected array $adv_cols_order,
350 $this->
ctrl = $DIC->ctrl();
353 public function getRows(
355 array $visible_column_ids,
359 ?array $additional_parameters
361 $records = $this->getRecords($range, $order, $filter_data);
362 foreach ($records as $idx => $record) {
363 $row_id = (
int) $record[
"term_id"];
365 $data_row = $row_builder->buildDataRow((
string) $row_id, $record);
366 if (!($this->term_perm->checkPermission(
"write", $row_id)
367 || $this->term_perm->checkPermission(
"edit_content", $row_id))) {
370 $data_row = $data_row->withDisabledAction(
"edit_definition");
371 $data_row = $data_row->withDisabledAction(
"edit_term");
378 public function getTotalRowCount(
380 ?array $additional_parameters
382 return count($this->getRecords());
385 protected function getRecords(
Data\
Range $range = null,
Data\
Order $order = null, ?array $filter_data = null): array
394 $data = $this->glossary->getTermList(
406 foreach (
$data as $term) {
407 $term_ids[$term[
"id"]] = new \ILIAS\AdvancedMetaData\Services\SubObjectID(
408 $this->glossary->getId(),
413 $adv_md_data = $this->adv_term_mode->getData(...$term_ids);
417 foreach (
$data as $term) {
419 $term_id = (
int) $term[
"id"];
420 $this->
ctrl->setParameterByClass(
"ilobjglossarygui",
"term_id", $term_id);
421 $this->
ctrl->setParameterByClass(
"ilglossarytermgui",
"term_id", $term_id);
422 $this->
ctrl->setParameterByClass(
"ilglossarydefpagegui",
"term_id", $term_id);
423 $records[$i][
"term_id"] = $term_id;
431 $term_obj = new \ilGlossaryTerm($term_id);
432 $term_obj->updateShortText();
433 $short_str = $term_obj->getShortText();
436 $page = new \ilGlossaryDefPage($term_id);
440 $ltexs = strrpos($short_str,
"[tex]");
441 $ltexe = strrpos($short_str,
"[/tex]");
442 if ($ltexs > $ltexe) {
444 $short_str = $page->getFirstParagraphText();
445 $short_str = strip_tags($short_str,
"<br>");
446 $ltexe = strpos($short_str,
"[/tex]", $ltexs);
456 !$page->getPageConfig()->getPreventHTMLUnmasking()
459 $short_str =
"Error: Page is missing.";
462 $records[$i][
"definition"] = $short_str;
464 $this->
ctrl->setParameterByClass(
"ilobjglossarygui",
"term_id", $term_id);
469 if ($nr_usage > 0 && $this->glossary->getId() == $term[
"glo_id"]) {
470 $this->
ctrl->setParameterByClass(
"ilglossarytermgui",
"term_id", $term_id);
472 $records[$i][
"usage_link"] = $this->ui_fac->link()->standard(
473 $this->lng->txt(
"glo_link_to_usages"),
474 $this->
ctrl->getLinkTargetByClass(
"ilglossarytermgui",
"listUsages")
476 $this->
ctrl->setParameterByClass(
"ilglossarytermgui",
"term_id",
"");
482 if ($this->glossary->getVirtualMode() ===
"coll" 486 $records[$i][
"glossary"] = $glo_title;
490 $records[$i][
"language"] = $this->lng->txt(
"meta_l_" . $term[
"language"]);
493 $sub_obj_id = $term_ids[$term_id];
494 $adv_data = $adv_md_data->dataForSubObject($sub_obj_id);
495 foreach ($adv_data as $key => $val) {
496 $records[$i][$key] = $val;
499 foreach ($this->adv_cols_order as
$c) {
501 $records[$i][
"term"] = $term[
"term"];
509 $records = $this->orderRecords($records, $order);
513 $records = $this->limitRecords($records, $range);
520 return $data_retrieval;
string $requested_table_term_list_action
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface Observer Contains several chained tasks and infos about them.
handleTermForModal(int $id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(\ilObjGlossary $glossary, int $tax_node)
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.
ServerRequestInterface $request
static _lookShortTextDirty(int $term_id)
get definition short text dirty
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.
Both the subject and the direction need to be specified when expressing an order. ...
ilGlobalTemplateInterface $tpl
static _lookupTitle(int $obj_id)
static _lookGlossaryTerm(int $term_id)
get glossary term
ilGlossaryTermPermission $term_perm
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 getInstance()
Singleton: get instance for use in ILIAS requests with a config loaded from the settings.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
array $requested_table_term_list_ids
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
EditingGUIRequest $edit_gui_request
static getNumberOfUsages(int $a_term_id)
A simple class to express a naive range of whole positive numbers.
ILIAS AdvancedMetaData Services SubObjectModes DataTable SupplierInterface $adv_term_mode
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookGlossaryID(int $term_id)
get glossary id form term id