ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilTermUsagesTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("Services/Table/classes/class.ilTable2GUI.php");
5 
15 {
16 
20  function __construct($a_parent_obj, $a_parent_cmd, $a_term_id)
21  {
22  global $ilCtrl, $lng, $ilAccess, $lng;
23 
24  parent::__construct($a_parent_obj, $a_parent_cmd);
25  $this->term_id = $a_term_id;
26 
27  $this->addColumn("", "", "1"); // checkbox
28  $this->setEnableHeader(false);
29  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
30  $this->setRowTemplate("tpl.term_usage_row.html", "Modules/Glossary");
31  $this->getItems();
32  $this->setTitle($lng->txt("cont_usage"));
33  }
34 
38  function getItems()
39  {
40  $usages = ilGlossaryTerm::getUsages($this->term_id);
41 
42  $clip_cnt = 0;
43  $to_del = array();
44  $agg_usages = array();
45  foreach($usages as $k => $usage)
46  {
47  if (empty($agg_usages[$usage["type"].":".$usage["id"]]))
48  {
49  $usage["hist_nr"] = array($usage["hist_nr"]);
50  $agg_usages[$usage["type"].":".$usage["id"]] = $usage;
51  }
52  else
53  {
54  $agg_usages[$usage["type"].":".$usage["id"]]["hist_nr"][] =
55  $usage["hist_nr"];
56  }
57  }
58 
59  $this->setData($agg_usages);
60  }
61 
66  protected function fillRow($a_set)
67  {
68  global $lng, $ilCtrl, $ilAccess;
69 
70  $usage = $a_set;
71 
72  if(is_int(strpos($usage["type"], ":")))
73  {
74  $us_arr = explode(":", $usage["type"]);
75  $usage["type"] = $us_arr[1];
76  $cont_type = $us_arr[0];
77  }
78 
79  include_once('./Services/Link/classes/class.ilLink.php');
80 
81  switch($usage["type"])
82  {
83  case "pg":
84  $item = array();
85 
86  //$this->tpl->setVariable("TXT_OBJECT", $usage["type"].":".$usage["id"]);
87  switch ($cont_type)
88  {
89  case "sahs":
90  require_once("./Modules/Scorm2004/classes/class.ilSCORM2004Page.php");
91  $page_obj = new ilSCORM2004Page($usage["id"]);
92 
93  require_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
94  require_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php");
95  $lm_obj = new ilObjSAHSLearningModule($page_obj->getParentId(), false);
96  $item["obj_type_txt"] = $this->lng->txt("obj_".$cont_type);
97  $item["obj_title"] = $lm_obj->getTitle();
98  $item["sub_txt"] = $this->lng->txt("pg");
99  $item["sub_title"] = ilSCORM2004PageNode::_lookupTitle($page_obj->getId());
100  $ref_id = $this->getFirstWritableRefId($lm_obj->getId());
101  if ($ref_id > 0)
102  {
103  $item["obj_link"] = ilLink::_getStaticLink($ref_id, "sahs");
104  }
105  break;
106 
107  case "lm":
108  require_once("./Modules/LearningModule/classes/class.ilLMPage.php");
109  $page_obj = new ilLMPage($usage["id"]);
110 
111  require_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
112  require_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
113  require_once("./Modules/LearningModule/classes/class.ilLMObject.php");
114  $lm_obj = new ilObjLearningModule($page_obj->getParentId(), false);
115  $item["obj_type_txt"] = $this->lng->txt("obj_".$cont_type);
116  $item["obj_title"] = $lm_obj->getTitle();
117  $item["sub_txt"] = $this->lng->txt("pg");
118  $item["sub_title"] = ilLMObject::_lookupTitle($page_obj->getId());
119  $ref_id = $this->getFirstWritableRefId($lm_obj->getId());
120  if ($ref_id > 0)
121  {
122  $item["obj_link"] = ilLink::_getStaticLink($ref_id, "lm");
123  }
124  break;
125 
126  case "wpg":
127  require_once("./Modules/Wiki/classes/class.ilWikiPage.php");
128  $page_obj = new ilWikiPage($usage["id"]);
129  $item["obj_type_txt"] = $this->lng->txt("obj_wiki");
130  $item["obj_title"] = ilObject::_lookupTitle($page_obj->getParentId());
131  $item["sub_txt"] = $this->lng->txt("pg");
132  $item["sub_title"] = ilWikiPage::lookupTitle($page_obj->getId());
133  $ref_id = $this->getFirstWritableRefId($page_obj->getParentId());
134  if ($ref_id > 0)
135  {
136  $item["obj_link"] = ilLink::_getStaticLink($ref_id, "wiki");
137  }
138  break;
139 
140  case "gdf":
141  require_once("./Modules/Glossary/classes/class.ilGlossaryDefPage.php");
142  $page_obj = new ilGlossaryDefPage($usage["id"]);
143  require_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
144  require_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
145  $term_id = ilGlossaryDefinition::_lookupTermId($page_obj->getId());
146  $glo_id = ilGlossaryTerm::_lookGlossaryId($term_id);
147  $item["obj_type_txt"] = $this->lng->txt("obj_glo");
148  $item["obj_title"] = ilObject::_lookupTitle($glo_id);
149  $item["sub_txt"] = $this->lng->txt("cont_term");
150  $item["sub_title"] = ilGlossaryTerm::_lookGlossaryTerm($term_id);
151  $ref_id = $this->getFirstWritableRefId($page_obj->getParentId());
152  if ($ref_id > 0)
153  {
154  $item["obj_link"] = ilLink::_getStaticLink($ref_id, "glo");
155  }
156  break;
157 
158  case "fold":
159  case "root":
160  case "crs":
161  case "grp":
162  case "cat":
163  case "cont":
164  $item["obj_type_txt"] = $this->lng->txt("obj_".$cont_type);
165  $item["obj_title"] = ilObject::_lookupTitle($usage["id"]);
166  $ref_id = $this->getFirstWritableRefId($usage["id"]);
167  if ($ref_id > 0)
168  {
169  $item["obj_link"] = ilLink::_getStaticLink($ref_id, $cont_type);
170  }
171  break;
172 
173  default:
174  $item["obj_title"] = "Page ".$cont_type.", ".$usage["id"];
175  break;
176  }
177  break;
178 
179  case "mep":
180  $item["obj_type_txt"] = $this->lng->txt("obj_mep");
181  $item["obj_title"] = ilObject::_lookupTitle($usage["id"]);
182  $ref_id = $this->getFirstWritableRefId($usage["id"]);
183  if ($ref_id > 0)
184  {
185  $item["obj_link"] = ilLink::_getStaticLink($ref_id, "mep");
186  }
187  break;
188 
189  case "map":
190  $item["obj_type_txt"] = $this->lng->txt("obj_mob");
191  $item["obj_title"] = ilObject::_lookupTitle($usage["id"]);
192  $item["sub_txt"] = $this->lng->txt("cont_link_area");
193  break;
194 
195  case "sqst":
196  $item["obj_type_txt"] = $this->lng->txt("cont_sqst");
197  include_once("./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php");
198  $obj_id = SurveyQuestion::lookupObjFi($usage["id"]);
199  $item["obj_title"] = ilObject::_lookupTitle($obj_id);
200  $item["sub_txt"] = $this->lng->txt("question");
201  $item["sub_title"] = SurveyQuestion::_getTitle($usage["id"]);
202  $ref_id = $this->getFirstWritableRefId($obj_id);
203  if ($ref_id > 0)
204  {
205  $item["obj_link"] = ilLink::_getStaticLink($ref_id);
206  }
207 
208  break;
209 
210  case "termref":
211  $item["obj_type_txt"] = $this->lng->txt("obj_glo");
212  $item["obj_title"] = ilObject::_lookupTitle($usage["id"]);
213  $item["sub_txt"] = $this->lng->txt("glo_referenced_term");
214  $ref_id = $this->getFirstWritableRefId($usage["id"]);
215  if ($ref_id > 0)
216  {
217  $item["obj_link"] = ilLink::_getStaticLink($ref_id);
218  }
219  break;
220 
221  default:
222  $item["obj_title"] = "Type ".$usage["type"].", ".$usage["id"];
223  break;
224  }
225 
226  // show versions
227  if (is_array($usage["hist_nr"]) &&
228  (count($usage["hist_nr"]) > 1 || $usage["hist_nr"][0] > 0))
229  {
230  asort($usage["hist_nr"]);
231  $ver = $sep = "";
232  if ($usage["hist_nr"][0] == 0)
233  {
234  array_shift($usage["hist_nr"]);
235  $usage["hist_nr"][] = 0;
236  }
237  foreach ($usage["hist_nr"] as $nr)
238  {
239  if ($nr > 0)
240  {
241  $ver.= $sep.$nr;
242  }
243  else
244  {
245  $ver.= $sep.$this->lng->txt("cont_current_version");
246  }
247  $sep = ", ";
248  }
249 
250  $this->tpl->setCurrentBlock("versions");
251  $this->tpl->setVariable("TXT_VERSIONS", $this->lng->txt("cont_versions"));
252  $this->tpl->setVariable("VAL_VERSIONS", $ver);
253  $this->tpl->parseCurrentBlock();
254  }
255 
256  if ($item["obj_type_txt"] != "")
257  {
258  $this->tpl->setCurrentBlock("type");
259  $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("type"));
260  $this->tpl->setVariable("VAL_TYPE", $item["obj_type_txt"]);
261  $this->tpl->parseCurrentBlock();
262  }
263 
264  if ($usage["type"] != "clip")
265  {
266  if ($item["obj_link"])
267  {
268  $this->tpl->setCurrentBlock("linked_item");
269  $this->tpl->setVariable("TXT_OBJECT", $item["obj_title"]);
270  $this->tpl->setVariable("HREF_LINK", $item["obj_link"]);
271  $this->tpl->parseCurrentBlock();
272  }
273  else
274  {
275  $this->tpl->setVariable("TXT_OBJECT_NO_LINK", $item["obj_title"]);
276  }
277 
278  if ($item["sub_txt"] != "")
279  {
280  $this->tpl->setVariable("SEP", ", ");
281  $this->tpl->setVariable("SUB_TXT", $item["sub_txt"]);
282  if ($item["sub_title"] != "")
283  {
284  $this->tpl->setVariable("SEP2", ": ");
285  $this->tpl->setVariable("SUB_TITLE", $item["sub_title"]);
286  }
287  }
288 
289  }
290  else
291  {
292  $this->tpl->setVariable("TXT_OBJECT_NO_LINK", $this->lng->txt("cont_users_have_mob_in_clip1").
293  " ".$usage["cnt"]." ".$this->lng->txt("cont_users_have_mob_in_clip2"));
294 
295  }
296  }
297 
298  function getFirstWritableRefId($a_obj_id)
299  {
300  global $ilAccess;
301 
302  $ref_ids = ilObject::_getAllReferences($a_obj_id);
303  foreach ($ref_ids as $ref_id)
304  {
305  if ($ilAccess->checkAccess("write", "", $ref_id))
306  {
307  return $ref_id;
308  }
309  }
310  return 0;
311  }
312 }
313 ?>
static _lookupTitle($a_obj_id)
Lookup Title.
static lookupTitle($a_page_id)
Checks whether a page with given title exists.
Class ilObjLearningModule.
static _getTitle($question_id)
Returns the question title of a question with a given id.
TableGUI class for media object usages listing.
static _lookupTitle($a_id)
lookup object title
static lookupObjFi($a_qid)
Lookip obj fi.
static _lookupTitle($a_obj_id)
Lookup title.
__construct($a_parent_obj, $a_parent_cmd, $a_term_id)
Constructor.
static _getAllReferences($a_id)
get all reference ids of object
static _lookupTermId($a_def_id)
Looks up term id for a definition id.
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilTable2GUI.
static getUsages($a_term_id)
Get number of usages.
Class ilSCORM2004Page.
getItems()
Get items of current folder.
getTitle()
get object title public
Class ilWikiPage.
Glossary definition page object.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
$ref_id
Definition: sahs_server.php:39
global $lng
Definition: privfeed.php:17
getTitle()
get title of content object
setEnableHeader($a_enableheader)
Set Enable Header.
fillRow($a_set)
Standard Version of Fill Row.
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.
Class ilObjSCORMLearningModule.