19 declare(strict_types=1);
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 (
335 protected \ilCtrl
$ctrl;
339 protected int $tax_node,
340 protected array $adv_cols_order,
349 $this->
ctrl = $DIC->ctrl();
352 public function getRows(
354 array $visible_column_ids,
358 ?array $additional_parameters
360 $records = $this->getRecords($range, $order, $filter_data);
361 foreach ($records as $idx => $record) {
362 $row_id = (
int) $record[
"term_id"];
364 $data_row = $row_builder->buildDataRow((
string) $row_id, $record);
365 if (!($this->term_perm->checkPermission(
"write", $row_id)
366 || $this->term_perm->checkPermission(
"edit_content", $row_id))) {
369 $data_row = $data_row->withDisabledAction(
"edit_definition");
370 $data_row = $data_row->withDisabledAction(
"edit_term");
377 public function getTotalRowCount(
379 ?array $additional_parameters
381 return count($this->getRecords());
393 $data = $this->glossary->getTermList(
405 foreach (
$data as $term) {
406 $term_ids[$term[
"id"]] = new \ILIAS\AdvancedMetaData\Services\SubObjectID(
407 $this->glossary->getId(),
412 $adv_md_data = $this->adv_term_mode->getData(...$term_ids);
416 foreach (
$data as $term) {
418 $term_id = (
int) $term[
"id"];
419 $this->
ctrl->setParameterByClass(
"ilobjglossarygui",
"term_id", $term_id);
420 $this->
ctrl->setParameterByClass(
"ilglossarytermgui",
"term_id", $term_id);
421 $this->
ctrl->setParameterByClass(
"ilglossarydefpagegui",
"term_id", $term_id);
422 $records[$i][
"term_id"] = $term_id;
429 $term_obj = new \ilGlossaryTerm($term_id);
430 $term_obj->updateShortText();
431 $short_str = $term_obj->getShortText();
435 $page = new \ilGlossaryDefPage($term_id);
439 $ltexs = strrpos($short_str,
"[tex]");
440 $ltexe = strrpos($short_str,
"[/tex]");
441 if ($ltexs > $ltexe) {
443 $short_str = $page->getFirstParagraphText();
444 $short_str = strip_tags($short_str,
"<br>");
445 $ltexe = strpos($short_str,
"[/tex]", $ltexs);
455 !$page->getPageConfig()->getPreventHTMLUnmasking()
458 $short_str =
"Error: Page is missing.";
461 $records[$i][
"definition"] = $short_str;
463 $this->
ctrl->setParameterByClass(
"ilobjglossarygui",
"term_id", $term_id);
468 if ($nr_usage > 0 && $this->glossary->getId() == $term[
"glo_id"]) {
469 $this->
ctrl->setParameterByClass(
"ilglossarytermgui",
"term_id", $term_id);
471 $records[$i][
"usage_link"] = $this->ui_fac->link()->standard(
472 $this->lng->txt(
"glo_link_to_usages"),
473 $this->
ctrl->getLinkTargetByClass(
"ilglossarytermgui",
"listUsages")
475 $this->
ctrl->setParameterByClass(
"ilglossarytermgui",
"term_id",
"");
481 if ($this->glossary->getVirtualMode() ===
"coll" 485 $records[$i][
"glossary"] = $glo_title;
489 $records[$i][
"language"] = $this->lng->txt(
"meta_l_" . $term[
"language"]);
492 $sub_obj_id = $term_ids[$term_id];
493 $adv_data = $adv_md_data->dataForSubObject($sub_obj_id);
494 foreach ($adv_data as $key => $val) {
495 $records[$i][$key] = $val;
498 foreach ($this->adv_cols_order as
$c) {
500 $records[$i][
"term"] = $term[
"term"];
508 $records = $this->orderRecords($records, $order);
512 $records = $this->limitRecords($records, $range);
519 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)
__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. ...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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.
$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.
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS AdvancedMetaData Services SubObjectModes DataTable SupplierInterface $adv_term_mode
static _lookGlossaryID(int $term_id)
get glossary id form term id