ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
4include_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 default:
211 $item["obj_title"] = "Type ".$usage["type"].", ".$usage["id"];
212 break;
213 }
214
215 // show versions
216 if (is_array($usage["hist_nr"]) &&
217 (count($usage["hist_nr"]) > 1 || $usage["hist_nr"][0] > 0))
218 {
219 asort($usage["hist_nr"]);
220 $ver = $sep = "";
221 if ($usage["hist_nr"][0] == 0)
222 {
223 array_shift($usage["hist_nr"]);
224 $usage["hist_nr"][] = 0;
225 }
226 foreach ($usage["hist_nr"] as $nr)
227 {
228 if ($nr > 0)
229 {
230 $ver.= $sep.$nr;
231 }
232 else
233 {
234 $ver.= $sep.$this->lng->txt("cont_current_version");
235 }
236 $sep = ", ";
237 }
238
239 $this->tpl->setCurrentBlock("versions");
240 $this->tpl->setVariable("TXT_VERSIONS", $this->lng->txt("cont_versions"));
241 $this->tpl->setVariable("VAL_VERSIONS", $ver);
242 $this->tpl->parseCurrentBlock();
243 }
244
245 if ($item["obj_type_txt"] != "")
246 {
247 $this->tpl->setCurrentBlock("type");
248 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("type"));
249 $this->tpl->setVariable("VAL_TYPE", $item["obj_type_txt"]);
250 $this->tpl->parseCurrentBlock();
251 }
252
253 if ($usage["type"] != "clip")
254 {
255 if ($item["obj_link"])
256 {
257 $this->tpl->setCurrentBlock("linked_item");
258 $this->tpl->setVariable("TXT_OBJECT", $item["obj_title"]);
259 $this->tpl->setVariable("HREF_LINK", $item["obj_link"]);
260 $this->tpl->parseCurrentBlock();
261 }
262 else
263 {
264 $this->tpl->setVariable("TXT_OBJECT_NO_LINK", $item["obj_title"]);
265 }
266
267 if ($item["sub_txt"] != "")
268 {
269 $this->tpl->setVariable("SEP", ", ");
270 $this->tpl->setVariable("SUB_TXT", $item["sub_txt"]);
271 if ($item["sub_title"] != "")
272 {
273 $this->tpl->setVariable("SEP2", ": ");
274 $this->tpl->setVariable("SUB_TITLE", $item["sub_title"]);
275 }
276 }
277
278 }
279 else
280 {
281 $this->tpl->setVariable("TXT_OBJECT_NO_LINK", $this->lng->txt("cont_users_have_mob_in_clip1").
282 " ".$usage["cnt"]." ".$this->lng->txt("cont_users_have_mob_in_clip2"));
283
284 }
285 }
286
287 function getFirstWritableRefId($a_obj_id)
288 {
289 global $ilAccess;
290
291 $ref_ids = ilObject::_getAllReferences($a_obj_id);
292 foreach ($ref_ids as $ref_id)
293 {
294 if ($ilAccess->checkAccess("write", "", $ref_id))
295 {
296 return $ref_id;
297 }
298 }
299 return 0;
300 }
301}
302?>
static lookupObjFi($a_qid)
Lookip obj fi.
_getTitle($question_id)
Returns the question title of a question with a given id.
Glossary definition page object.
_lookupTermId($a_def_id)
Looks up term id for a definition id.
static getUsages($a_term_id)
Get number of usages.
static _lookGlossaryTerm($term_id)
get glossary term
static _lookupTitle($a_obj_id)
Lookup title.
Extension of ilPageObject for learning modules.
Class ilObjLearningModule.
Class ilObjSCORMLearningModule.
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
static _lookupTitle($a_obj_id)
Lookup Title.
Class ilSCORM2004Page.
Class ilTable2GUI.
setEnableHeader($a_enableheader)
Set Enable Header.
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.
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.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
TableGUI class for media object usages listing.
fillRow($a_set)
Standard Version of Fill Row.
getItems()
Get items of current folder.
__construct($a_parent_obj, $a_parent_cmd, $a_term_id)
Constructor.
Class ilWikiPage.
static lookupTitle($a_page_id)
Checks whether a page with given title exists.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$ref_id
Definition: sahs_server.php:39