ILIAS  Release_4_4_x_branch Revision 61816
 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  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 ?>