ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
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 
24 include_once("Services/Table/classes/class.ilTable2GUI.php");
25 
35 {
36 
37  function ilLinksTableGUI($a_parent_obj, $a_parent_cmd,
38  $a_lm_id, $a_lm_type)
39  {
40  global $ilCtrl, $lng;
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("tpl.links_table_row.html",
49  "Modules/LearningModule");
50  $this->lm_id = $a_lm_id;
51  $this->lm_type = $a_lm_type;
52  $this->getLinks();
53 
54  $this->setTitle($lng->txt("cont_internal_links"));
55  }
56 
60  function getLinks()
61  {
62  $pages = ilLMPageObject::getPagesWithLinksList($this->lm_id, $this->lm_type);
63  $this->setData($pages);
64  }
65 
70  protected function fillRow($a_set)
71  {
72  global $lng, $ilCtrl;
73 
74  $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
75  $ilCtrl->setParameterByClass("illmpageobjectgui", "obj_id",
76  $a_set["obj_id"]);
77  $this->tpl->setVariable("HREF_PAGE",
78  $ilCtrl->getLinkTargetByClass("illmpageobjectgui", "edit"));
79 
80  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
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  {
87  $target = $link["Target"];
88  if (substr($target, 0, 4) == "il__")
89  {
90  $target_arr = explode("_", $target);
91  $target_id = $target_arr[count($target_arr) - 1];
92  $type = $link["Type"];
93 
94  switch($type)
95  {
96  case "PageObject":
97  $this->tpl->setCurrentBlock("link");
98  $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("pg"));
100  {
102  $add_str = ($lm_id != $this->lm_id)
103  ? " (".ilObject::_lookupTitle($lm_id).")"
104  : "";
105  $this->tpl->setVariable("TXT_LINK_TITLE",
107  }
108  else
109  {
110  $this->tpl->setVariable("TXT_MISSING",
111  "<b>".$lng->txt("cont_target_missing")." [".$target_id."]"."</b>");
112  }
113  $this->tpl->parseCurrentBlock();
114  break;
115 
116  case "StructureObject":
117  $this->tpl->setCurrentBlock("link");
118  $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("st"));
120  {
122  $add_str = ($lm_id != $this->lm_id)
123  ? " (".ilObject::_lookupTitle($lm_id).")"
124  : "";
125  $this->tpl->setVariable("TXT_LINK_TITLE",
127  }
128  else
129  {
130  $this->tpl->setVariable("TXT_MISSING",
131  "<b>".$lng->txt("cont_target_missing")." [".$target_id."]"."</b>");
132  }
133  $this->tpl->parseCurrentBlock();
134  break;
135 
136  case "GlossaryItem":
137  $this->tpl->setCurrentBlock("link");
138  $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_term"));
139  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
141  {
142  $this->tpl->setVariable("TXT_LINK_TITLE",
144  }
145  else
146  {
147  $this->tpl->setVariable("TXT_MISSING",
148  "<b>".$lng->txt("cont_target_missing")." [".$target_id."]"."</b>");
149  }
150  $this->tpl->parseCurrentBlock();
151  break;
152 
153  case "MediaObject":
154  $this->tpl->setCurrentBlock("link");
155  $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("mob"));
157  {
158  $this->tpl->setVariable("TXT_LINK_TITLE",
160  }
161  else
162  {
163  $this->tpl->setVariable("TXT_MISSING",
164  "<b>".$lng->txt("cont_target_missing")." [".$target_id."]"."</b>");
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);
174  if (ilObject::_exists($obj_id))
175  {
176  $this->tpl->setVariable("TXT_LINK_TITLE",
177  ilObject::_lookupTitle($obj_id)." (".
178  $lng->txt(("obj_".$obj_type))
179  .")");
180  }
181  else
182  {
183  $this->tpl->setVariable("TXT_MISSING",
184  "<b>".$lng->txt("cont_target_missing")." [".$target_id."]"."</b>");
185  }
186  $this->tpl->parseCurrentBlock();
187  break;
188 
189  }
190  }
191  else
192  {
193  $type = $link["Type"];
194 
195  switch($type)
196  {
197  case "PageObject":
198  $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("pg"));
199  break;
200  case "StructureObject":
201  $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("st"));
202  break;
203  case "GlossaryItem":
204  $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_term"));
205  break;
206  case "MediaObject":
207  $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("mob"));
208  break;
209  case "RepositoryItem":
210  $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_repository_item"));
211  break;
212  }
213 
214  $this->tpl->setCurrentBlock("link");
215  $this->tpl->setVariable("TXT_MISSING",
216  "<b>".$lng->txt("cont_target_missing")." [".$target."]"."</b>");
217  $this->tpl->parseCurrentBlock();
218  }
219  }
220  }
221 
222 }
223 ?>
$target_arr
Definition: goto.php:86
_exists($a_id)
checks wether a glossary term with specified id exists or not
_exists($a_id)
checks wether a lm content object with specified id exists or not
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
$target_id
Definition: goto.php:88
static _lookupTitle($a_id)
lookup object title
getPagesWithLinksList($a_lm_id, $a_par_type)
Get all pages of lm that contain any internal links.
static _lookupTitle($a_obj_id)
Lookup title.
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
fillRow($a_set)
Standard Version of Fill Row.
Class ilTable2GUI.
TableGUI class for (broken) links in learning module.
static _lookupObjId($a_id)
_lookupContObjID($a_id)
get learning module / digibook id for lm object
setRowTemplate($a_template, $a_template_dir="")
Set row template.
static _lookupType($a_id, $a_reference=false)
lookup object type
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
global $lng
Definition: privfeed.php:40
setEnableHeader($a_enableheader)
Set Enable Header.
getLinks()
Get pages incl.
ilLinksTableGUI($a_parent_obj, $a_parent_cmd, $a_lm_id, $a_lm_type)
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.
static _lookGlossaryTerm($term_id)
get glossary term
Extension of ilPageObject for learning modules.