ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLinksTableGUI.php
Go to the documentation of this file.
1<?php
2
25{
26 protected string $lm_type;
27 protected int $lm_id;
28
29 public function __construct(
30 object $a_parent_obj,
31 string $a_parent_cmd,
32 int $a_lm_id,
33 string $a_lm_type
34 ) {
35 global $DIC;
36
37 $this->ctrl = $DIC->ctrl();
38 $this->lng = $DIC->language();
39 $ilCtrl = $DIC->ctrl();
40 $lng = $DIC->language();
41
42 parent::__construct($a_parent_obj, $a_parent_cmd);
43
44 $this->addColumn($lng->txt("pg"), "", "");
45 $this->addColumn($lng->txt("cont_internal_links"), "", "");
46 $this->setEnableHeader(true);
47 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
48 $this->setRowTemplate(
49 "tpl.links_table_row.html",
50 "components/ILIAS/LearningModule"
51 );
52 $this->lm_id = $a_lm_id;
53 $this->lm_type = $a_lm_type;
54 $this->getLinks();
55
56 $this->setTitle($lng->txt("cont_internal_links"));
57 }
58
59 public function getLinks(): void
60 {
61 $pages = ilLMPageObject::getPagesWithLinksList($this->lm_id, $this->lm_type);
62 $this->setData($pages);
63 }
64
65 protected function fillRow(array $a_set): void
66 {
68 $ilCtrl = $this->ctrl;
69
70 $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
71 $ilCtrl->setParameterByClass(
72 "illmpageobjectgui",
73 "obj_id",
74 $a_set["obj_id"]
75 );
76 $this->tpl->setVariable(
77 "HREF_PAGE",
78 $ilCtrl->getLinkTargetByClass("illmpageobjectgui", "edit")
79 );
80
81 $page_object = new ilLMPage($a_set["obj_id"]);
82 $page_object->buildDom();
83 $int_links = $page_object->getInternalLinks();
84
85 foreach ($int_links as $link) {
86 $target = $link["Target"];
87 if (substr($target, 0, 4) == "il__") {
88 $target_arr = explode("_", $target);
89 $target_id = $target_arr[count($target_arr) - 1];
90 $type = $link["Type"];
91
92 switch ($type) {
93 case "PageObject":
94 $this->tpl->setCurrentBlock("link");
95 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("pg"));
96 if (ilLMObject::_exists($target_id)) {
98 $add_str = ($lm_id != $this->lm_id)
99 ? " (" . ilObject::_lookupTitle($lm_id) . ")"
100 : "";
101 $this->tpl->setVariable(
102 "TXT_LINK_TITLE",
103 ilLMObject::_lookupTitle($target_id) . $add_str
104 );
105 } else {
106 $this->tpl->setVariable(
107 "TXT_MISSING",
108 "<strong>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</strong>"
109 );
110 }
111 $this->tpl->parseCurrentBlock();
112 break;
113
114 case "StructureObject":
115 $this->tpl->setCurrentBlock("link");
116 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("st"));
117 if (ilLMObject::_exists($target_id)) {
119 $add_str = ($lm_id != $this->lm_id)
120 ? " (" . ilObject::_lookupTitle($lm_id) . ")"
121 : "";
122 $this->tpl->setVariable(
123 "TXT_LINK_TITLE",
124 ilLMObject::_lookupTitle($target_id) . $add_str
125 );
126 } else {
127 $this->tpl->setVariable(
128 "TXT_MISSING",
129 "<strong>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</strong>"
130 );
131 }
132 $this->tpl->parseCurrentBlock();
133 break;
134
135 case "GlossaryItem":
136 $this->tpl->setCurrentBlock("link");
137 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_term"));
138 if (ilGlossaryTerm::_exists($target_id)) {
139 $this->tpl->setVariable(
140 "TXT_LINK_TITLE",
142 );
143 } else {
144 $this->tpl->setVariable(
145 "TXT_MISSING",
146 "<strong>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</strong>"
147 );
148 }
149 $this->tpl->parseCurrentBlock();
150 break;
151
152 case "MediaObject":
153 $this->tpl->setCurrentBlock("link");
154 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("mob"));
155 if (ilObject::_exists($target_id)) {
156 $this->tpl->setVariable(
157 "TXT_LINK_TITLE",
158 ilObject::_lookupTitle($target_id)
159 );
160 } else {
161 $this->tpl->setVariable(
162 "TXT_MISSING",
163 "<strong>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</strong>"
164 );
165 }
166 $this->tpl->parseCurrentBlock();
167 break;
168
169 case "RepositoryItem":
170 $this->tpl->setCurrentBlock("link");
171 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_repository_item"));
172 $obj_type = ilObject::_lookupType($target_id, true);
173 $obj_id = ilObject::_lookupObjId($target_id);
174 if (ilObject::_exists($obj_id)) {
175 $this->tpl->setVariable(
176 "TXT_LINK_TITLE",
177 ilObject::_lookupTitle($obj_id) . " (" .
178 $lng->txt(("obj_" . $obj_type))
179 . ")"
180 );
181 } else {
182 $this->tpl->setVariable(
183 "TXT_MISSING",
184 "<strong>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</strong>"
185 );
186 }
187 $this->tpl->parseCurrentBlock();
188 break;
189 }
190 } else {
191 $type = $link["Type"];
192
193 switch ($type) {
194 case "PageObject":
195 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("pg"));
196 break;
197 case "StructureObject":
198 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("st"));
199 break;
200 case "GlossaryItem":
201 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_term"));
202 break;
203 case "MediaObject":
204 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("mob"));
205 break;
206 case "RepositoryItem":
207 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_repository_item"));
208 break;
209 }
210
211 $this->tpl->setCurrentBlock("link");
212 $this->tpl->setVariable(
213 "TXT_MISSING",
214 "<strong>" . $lng->txt("cont_target_missing") . " [" . $target . "]" . "</strong>"
215 );
216 $this->tpl->parseCurrentBlock();
217 }
218 }
219 }
220}
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
static _lookGlossaryTerm(int $term_id)
get glossary term
static _exists(int $a_id)
checks whether a glossary term with specified id exists or not
static _exists(int $a_id)
checks wether a lm content object with specified id exists or not
static _lookupContObjID(int $a_id)
get learning module id for lm object
static _lookupTitle(int $a_obj_id)
static getPagesWithLinksList(int $a_lm_id, string $a_par_type)
Get all pages of lm that contain any internal links.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(object $a_parent_obj, string $a_parent_cmd, int $a_lm_id, string $a_lm_type)
fillRow(array $a_set)
Standard Version of Fill Row.
static _lookupType(int $id, bool $reference=false)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setEnableHeader(bool $a_enableheader)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setData(array $a_data)
Set table data.
ilLanguage $lng
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26