ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  $page_object = new ilPageObject($this->lm_type, $a_set["obj_id"]);
81  $page_object->buildDom();
82  $int_links = $page_object->getInternalLinks();
83 
84  foreach($int_links as $link)
85  {
86  $target = $link["Target"];
87  if (substr($target, 0, 4) == "il__")
88  {
89  $target_arr = explode("_", $target);
90  $target_id = $target_arr[count($target_arr) - 1];
91  $type = $link["Type"];
92 
93  switch($type)
94  {
95  case "PageObject":
96  $this->tpl->setCurrentBlock("link");
97  $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("pg"));
99  {
101  $add_str = ($lm_id != $this->lm_id)
102  ? " (".ilObject::_lookupTitle($lm_id).")"
103  : "";
104  $this->tpl->setVariable("TXT_LINK_TITLE",
106  }
107  else
108  {
109  $this->tpl->setVariable("TXT_MISSING",
110  "<b>".$lng->txt("cont_target_missing")." [".$target_id."]"."</b>");
111  }
112  $this->tpl->parseCurrentBlock();
113  break;
114 
115  case "StructureObject":
116  $this->tpl->setCurrentBlock("link");
117  $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("st"));
119  {
121  $add_str = ($lm_id != $this->lm_id)
122  ? " (".ilObject::_lookupTitle($lm_id).")"
123  : "";
124  $this->tpl->setVariable("TXT_LINK_TITLE",
126  }
127  else
128  {
129  $this->tpl->setVariable("TXT_MISSING",
130  "<b>".$lng->txt("cont_target_missing")." [".$target_id."]"."</b>");
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  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
140  {
141  $this->tpl->setVariable("TXT_LINK_TITLE",
143  }
144  else
145  {
146  $this->tpl->setVariable("TXT_MISSING",
147  "<b>".$lng->txt("cont_target_missing")." [".$target_id."]"."</b>");
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"));
156  {
157  $this->tpl->setVariable("TXT_LINK_TITLE",
159  }
160  else
161  {
162  $this->tpl->setVariable("TXT_MISSING",
163  "<b>".$lng->txt("cont_target_missing")." [".$target_id."]"."</b>");
164  }
165  $this->tpl->parseCurrentBlock();
166  break;
167 
168  case "RepositoryItem":
169  $this->tpl->setCurrentBlock("link");
170  $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_repository_item"));
171  $obj_type = ilObject::_lookupType($target_id, true);
173  if (ilObject::_exists($obj_id))
174  {
175  $this->tpl->setVariable("TXT_LINK_TITLE",
176  ilObject::_lookupTitle($obj_id)." (".
177  $lng->txt(("obj_".$obj_type))
178  .")");
179  }
180  else
181  {
182  $this->tpl->setVariable("TXT_MISSING",
183  "<b>".$lng->txt("cont_target_missing")." [".$target_id."]"."</b>");
184  }
185  $this->tpl->parseCurrentBlock();
186  break;
187 
188  }
189  }
190  else
191  {
192  $type = $link["Type"];
193 
194  switch($type)
195  {
196  case "PageObject":
197  $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("pg"));
198  break;
199  case "StructureObject":
200  $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("st"));
201  break;
202  case "GlossaryItem":
203  $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_term"));
204  break;
205  case "MediaObject":
206  $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("mob"));
207  break;
208  case "RepositoryItem":
209  $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_repository_item"));
210  break;
211  }
212 
213  $this->tpl->setCurrentBlock("link");
214  $this->tpl->setVariable("TXT_MISSING",
215  "<b>".$lng->txt("cont_target_missing")." [".$target."]"."</b>");
216  $this->tpl->parseCurrentBlock();
217  }
218  }
219  }
220 
221 }
222 ?>