ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilLinksTableGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
14{
15 public function __construct(
16 $a_parent_obj,
17 $a_parent_cmd,
18 $a_lm_id,
19 $a_lm_type
20 ) {
21 global $DIC;
22
23 $this->ctrl = $DIC->ctrl();
24 $this->lng = $DIC->language();
25 $ilCtrl = $DIC->ctrl();
26 $lng = $DIC->language();
27
28 parent::__construct($a_parent_obj, $a_parent_cmd);
29
30 $this->addColumn($lng->txt("pg"), "", "");
31 $this->addColumn($lng->txt("cont_internal_links"), "", "");
32 $this->setEnableHeader(true);
33 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
34 $this->setRowTemplate(
35 "tpl.links_table_row.html",
36 "Modules/LearningModule"
37 );
38 $this->lm_id = $a_lm_id;
39 $this->lm_type = $a_lm_type;
40 $this->getLinks();
41
42 $this->setTitle($lng->txt("cont_internal_links"));
43 }
44
48 public function getLinks()
49 {
50 $pages = ilLMPageObject::getPagesWithLinksList($this->lm_id, $this->lm_type);
51 $this->setData($pages);
52 }
53
58 protected function fillRow($a_set)
59 {
62
63 $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
64 $ilCtrl->setParameterByClass(
65 "illmpageobjectgui",
66 "obj_id",
67 $a_set["obj_id"]
68 );
69 $this->tpl->setVariable(
70 "HREF_PAGE",
71 $ilCtrl->getLinkTargetByClass("illmpageobjectgui", "edit")
72 );
73
74 $page_object = new ilLMPage($a_set["obj_id"]);
75 $page_object->buildDom();
76 $int_links = $page_object->getInternalLinks();
77
78 foreach ($int_links as $link) {
79 $target = $link["Target"];
80 if (substr($target, 0, 4) == "il__") {
81 $target_arr = explode("_", $target);
83 $type = $link["Type"];
84
85 switch ($type) {
86 case "PageObject":
87 $this->tpl->setCurrentBlock("link");
88 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("pg"));
91 $add_str = ($lm_id != $this->lm_id)
92 ? " (" . ilObject::_lookupTitle($lm_id) . ")"
93 : "";
94 $this->tpl->setVariable(
95 "TXT_LINK_TITLE",
97 );
98 } else {
99 $this->tpl->setVariable(
100 "TXT_MISSING",
101 "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>"
102 );
103 }
104 $this->tpl->parseCurrentBlock();
105 break;
106
107 case "StructureObject":
108 $this->tpl->setCurrentBlock("link");
109 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("st"));
112 $add_str = ($lm_id != $this->lm_id)
113 ? " (" . ilObject::_lookupTitle($lm_id) . ")"
114 : "";
115 $this->tpl->setVariable(
116 "TXT_LINK_TITLE",
118 );
119 } else {
120 $this->tpl->setVariable(
121 "TXT_MISSING",
122 "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>"
123 );
124 }
125 $this->tpl->parseCurrentBlock();
126 break;
127
128 case "GlossaryItem":
129 $this->tpl->setCurrentBlock("link");
130 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_term"));
132 $this->tpl->setVariable(
133 "TXT_LINK_TITLE",
135 );
136 } else {
137 $this->tpl->setVariable(
138 "TXT_MISSING",
139 "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>"
140 );
141 }
142 $this->tpl->parseCurrentBlock();
143 break;
144
145 case "MediaObject":
146 $this->tpl->setCurrentBlock("link");
147 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("mob"));
149 $this->tpl->setVariable(
150 "TXT_LINK_TITLE",
152 );
153 } else {
154 $this->tpl->setVariable(
155 "TXT_MISSING",
156 "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>"
157 );
158 }
159 $this->tpl->parseCurrentBlock();
160 break;
161
162 case "RepositoryItem":
163 $this->tpl->setCurrentBlock("link");
164 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_repository_item"));
165 $obj_type = ilObject::_lookupType($target_id, true);
167 if (ilObject::_exists($obj_id)) {
168 $this->tpl->setVariable(
169 "TXT_LINK_TITLE",
170 ilObject::_lookupTitle($obj_id) . " (" .
171 $lng->txt(("obj_" . $obj_type))
172 . ")"
173 );
174 } else {
175 $this->tpl->setVariable(
176 "TXT_MISSING",
177 "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>"
178 );
179 }
180 $this->tpl->parseCurrentBlock();
181 break;
182
183 }
184 } else {
185 $type = $link["Type"];
186
187 switch ($type) {
188 case "PageObject":
189 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("pg"));
190 break;
191 case "StructureObject":
192 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("st"));
193 break;
194 case "GlossaryItem":
195 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_term"));
196 break;
197 case "MediaObject":
198 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("mob"));
199 break;
200 case "RepositoryItem":
201 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_repository_item"));
202 break;
203 }
204
205 $this->tpl->setCurrentBlock("link");
206 $this->tpl->setVariable(
207 "TXT_MISSING",
208 "<b>" . $lng->txt("cont_target_missing") . " [" . $target . "]" . "</b>"
209 );
210 $this->tpl->parseCurrentBlock();
211 }
212 }
213 }
214}
An exception for terminatinating execution or to throw for unit testing.
static _lookGlossaryTerm($term_id)
get glossary term
static _exists($a_id)
checks wether a glossary term with specified id exists or not
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
static _lookupTitle($a_obj_id)
Lookup title.
static _exists($a_id)
checks wether a lm content object with specified id exists or not
static getPagesWithLinksList($a_lm_id, $a_par_type)
Get all pages of lm that contain any internal links.
Extension of ilPageObject for learning modules.
TableGUI class for (broken) links in learning module.
fillRow($a_set)
Standard Version of Fill Row.
getLinks()
Get pages incl.
__construct( $a_parent_obj, $a_parent_cmd, $a_lm_id, $a_lm_type)
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilTable2GUI.
setEnableHeader($a_enableheader)
Set Enable Header.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
$target_id
Definition: goto.php:49
$target_arr
Definition: goto.php:47
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type
$DIC
Definition: xapitoken.php:46