ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilLinksTableGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24include_once("Services/Table/classes/class.ilTable2GUI.php");
25
35{
36 public function __construct(
37 $a_parent_obj,
38 $a_parent_cmd,
39 $a_lm_id,
40 $a_lm_type
41 ) {
42 global $DIC;
43
44 $this->ctrl = $DIC->ctrl();
45 $this->lng = $DIC->language();
46 $ilCtrl = $DIC->ctrl();
47 $lng = $DIC->language();
48
49 parent::__construct($a_parent_obj, $a_parent_cmd);
50
51 $this->addColumn($lng->txt("pg"), "", "");
52 $this->addColumn($lng->txt("cont_internal_links"), "", "");
53 $this->setEnableHeader(true);
54 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
55 $this->setRowTemplate(
56 "tpl.links_table_row.html",
57 "Modules/LearningModule"
58 );
59 $this->lm_id = $a_lm_id;
60 $this->lm_type = $a_lm_type;
61 $this->getLinks();
62
63 $this->setTitle($lng->txt("cont_internal_links"));
64 }
65
69 public function getLinks()
70 {
71 $pages = ilLMPageObject::getPagesWithLinksList($this->lm_id, $this->lm_type);
72 $this->setData($pages);
73 }
74
79 protected function fillRow($a_set)
80 {
83
84 $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
85 $ilCtrl->setParameterByClass(
86 "illmpageobjectgui",
87 "obj_id",
88 $a_set["obj_id"]
89 );
90 $this->tpl->setVariable(
91 "HREF_PAGE",
92 $ilCtrl->getLinkTargetByClass("illmpageobjectgui", "edit")
93 );
94
95 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
96 $page_object = new ilLMPage($a_set["obj_id"]);
97 $page_object->buildDom();
98 $int_links = $page_object->getInternalLinks();
99
100 foreach ($int_links as $link) {
101 $target = $link["Target"];
102 if (substr($target, 0, 4) == "il__") {
103 $target_arr = explode("_", $target);
104 $target_id = $target_arr[count($target_arr) - 1];
105 $type = $link["Type"];
106
107 switch ($type) {
108 case "PageObject":
109 $this->tpl->setCurrentBlock("link");
110 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("pg"));
113 $add_str = ($lm_id != $this->lm_id)
114 ? " (" . ilObject::_lookupTitle($lm_id) . ")"
115 : "";
116 $this->tpl->setVariable(
117 "TXT_LINK_TITLE",
119 );
120 } else {
121 $this->tpl->setVariable(
122 "TXT_MISSING",
123 "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>"
124 );
125 }
126 $this->tpl->parseCurrentBlock();
127 break;
128
129 case "StructureObject":
130 $this->tpl->setCurrentBlock("link");
131 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("st"));
134 $add_str = ($lm_id != $this->lm_id)
135 ? " (" . ilObject::_lookupTitle($lm_id) . ")"
136 : "";
137 $this->tpl->setVariable(
138 "TXT_LINK_TITLE",
140 );
141 } else {
142 $this->tpl->setVariable(
143 "TXT_MISSING",
144 "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>"
145 );
146 }
147 $this->tpl->parseCurrentBlock();
148 break;
149
150 case "GlossaryItem":
151 $this->tpl->setCurrentBlock("link");
152 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_term"));
153 include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
155 $this->tpl->setVariable(
156 "TXT_LINK_TITLE",
158 );
159 } else {
160 $this->tpl->setVariable(
161 "TXT_MISSING",
162 "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>"
163 );
164 }
165 $this->tpl->parseCurrentBlock();
166 break;
167
168 case "MediaObject":
169 $this->tpl->setCurrentBlock("link");
170 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("mob"));
172 $this->tpl->setVariable(
173 "TXT_LINK_TITLE",
175 );
176 } else {
177 $this->tpl->setVariable(
178 "TXT_MISSING",
179 "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>"
180 );
181 }
182 $this->tpl->parseCurrentBlock();
183 break;
184
185 case "RepositoryItem":
186 $this->tpl->setCurrentBlock("link");
187 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_repository_item"));
188 $obj_type = ilObject::_lookupType($target_id, true);
190 if (ilObject::_exists($obj_id)) {
191 $this->tpl->setVariable(
192 "TXT_LINK_TITLE",
193 ilObject::_lookupTitle($obj_id) . " (" .
194 $lng->txt(("obj_" . $obj_type))
195 . ")"
196 );
197 } else {
198 $this->tpl->setVariable(
199 "TXT_MISSING",
200 "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>"
201 );
202 }
203 $this->tpl->parseCurrentBlock();
204 break;
205
206 }
207 } else {
208 $type = $link["Type"];
209
210 switch ($type) {
211 case "PageObject":
212 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("pg"));
213 break;
214 case "StructureObject":
215 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("st"));
216 break;
217 case "GlossaryItem":
218 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_term"));
219 break;
220 case "MediaObject":
221 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("mob"));
222 break;
223 case "RepositoryItem":
224 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_repository_item"));
225 break;
226 }
227
228 $this->tpl->setCurrentBlock("link");
229 $this->tpl->setVariable(
230 "TXT_MISSING",
231 "<b>" . $lng->txt("cont_target_missing") . " [" . $target . "]" . "</b>"
232 );
233 $this->tpl->parseCurrentBlock();
234 }
235 }
236 }
237}
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
$target
Definition: test.php:19
$type
global $DIC
Definition: saml.php:7