ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilMediaPoolPageUsagesTableGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once("Services/Table/classes/class.ilTable2GUI.php");
6
16{
17
21 function __construct($a_parent_obj, $a_parent_cmd, $a_page, $a_incl_hist)
22 {
23 global $ilCtrl, $lng, $ilAccess, $lng;
24
25 parent::__construct($a_parent_obj, $a_parent_cmd);
26 $this->page = $a_page;
27 $this->incl_hist = $a_incl_hist;
28 $this->addColumn("", "", "1"); // checkbox
29 $this->setEnableHeader(false);
30 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
31 $this->setRowTemplate("tpl.mep_page_usage_row.html", "Modules/MediaPool");
32 $this->getItems();
33 $this->setTitle($lng->txt("cont_mob_usages"));
34 }
35
39 function getItems()
40 {
41 $usages = $this->page->getUsages($this->incl_hist);
42
43 $clip_cnt = 0;
44 $to_del = array();
45 $agg_usages = array();
46 foreach($usages as $k => $usage)
47 {
48 if ($usage["type"] == "clip")
49 {
50 $clip_cnt++;
51 }
52 else
53 {
54 if (empty($agg_usages[$usage["type"].":".$usage["id"]]))
55 {
56 $usage["hist_nr"] = array($usage["hist_nr"]);
57 $agg_usages[$usage["type"].":".$usage["id"]] = $usage;
58 }
59 else
60 {
61 $agg_usages[$usage["type"].":".$usage["id"]]["hist_nr"][] =
62 $usage["hist_nr"];
63 }
64 }
65 }
66
67 // usages in clipboards
68 if ($clip_cnt > 0)
69 {
70 $agg_usages[] = array("type" => "clip", "cnt" => $clip_cnt);
71 }
72
73 $this->setData($agg_usages);
74 }
75
80 protected function fillRow($a_set)
81 {
82 global $lng, $ilCtrl, $ilAccess;
83
84 $usage = $a_set;
85
86//var_dump($usage);
87
88 if(is_int(strpos($usage["type"], ":")))
89 {
90 $us_arr = explode(":", $usage["type"]);
91 $usage["type"] = $us_arr[1];
92 $cont_type = $us_arr[0];
93 }
94//var_dump($usage);
95
96 include_once('./Services/Link/classes/class.ilLink.php');
97
98 switch($usage["type"])
99 {
100 case "pg":
101 include_once("./Services/COPage/classes/class.ilPageObjectFactory.php");
102 $page_obj = ilPageObjectFactory::getInstance($cont_type, $usage["id"]);
103 $item = array();
104
105 //$this->tpl->setVariable("TXT_OBJECT", $usage["type"].":".$usage["id"]);
106 switch ($cont_type)
107 {
108 case "lm":
109 require_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
110 require_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
111 require_once("./Modules/LearningModule/classes/class.ilLMObject.php");
112 $lm_obj = new ilObjLearningModule($page_obj->getParentId(), false);
113 $item["obj_type_txt"] = $this->lng->txt("obj_".$cont_type);
114 $item["obj_title"] = $lm_obj->getTitle();
115 $item["sub_txt"] = $this->lng->txt("pg");
116 $item["sub_title"] = ilLMObject::_lookupTitle($page_obj->getId());
117 $ref_id = $this->getFirstWritableRefId($lm_obj->getId());
118 if ($ref_id > 0)
119 {
120 $item["obj_link"] = ilLink::_getStaticLink($page_obj->getId()."_".$ref_id, "pg");
121 }
122 break;
123
124 case "wpg":
125 require_once("./Modules/Wiki/classes/class.ilWikiPage.php");
126 $item["obj_type_txt"] = $this->lng->txt("obj_wiki");
127 $item["obj_title"] = ilObject::_lookupTitle($page_obj->getParentId());
128 $item["sub_txt"] = $this->lng->txt("pg");
129 $item["sub_title"] = ilWikiPage::lookupTitle($page_obj->getId());
130 $ref_id = $this->getFirstWritableRefId($page_obj->getParentId());
131 if ($ref_id > 0)
132 {
133 $item["obj_link"] = ilLink::_getStaticLink($ref_id, "wiki");
134 }
135 break;
136
137 case "gdf":
138 require_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
139 require_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
140 $term_id = ilGlossaryDefinition::_lookupTermId($page_obj->getId());
141 $glo_id = ilGlossaryTerm::_lookGlossaryId($term_id);
142 $item["obj_type_txt"] = $this->lng->txt("obj_glo");
143 $item["obj_title"] = ilObject::_lookupTitle($glo_id);
144 $item["sub_txt"] = $this->lng->txt("cont_term");
145 $item["sub_title"] = ilGlossaryTerm::_lookGlossaryTerm($term_id);
146 $ref_id = $this->getFirstWritableRefId($page_obj->getParentId());
147 if ($ref_id > 0)
148 {
149 $item["obj_link"] = ilLink::_getStaticLink($ref_id, "glo");
150 }
151 break;
152
153 case "cont":
154 $item["obj_type_txt"] = $this->lng->txt("obj_".$cont_type);
155 $item["obj_title"] = ilObject::_lookupTitle($page_obj->getId());
156 $ref_id = $this->getFirstWritableRefId($page_obj->getId());
157 if ($ref_id > 0)
158 {
159 $item["obj_link"] = ilLink::_getStaticLink($ref_id, $cont_type);
160 }
161 break;
162 }
163 break;
164
165 case "mep":
166 $item["obj_type_txt"] = $this->lng->txt("obj_mep");
167 $item["obj_title"] = ilObject::_lookupTitle($usage["id"]);
168 $ref_id = $this->getFirstWritableRefId($usage["id"]);
169 if ($ref_id > 0)
170 {
171 $item["obj_link"] = ilLink::_getStaticLink($ref_id, "mep");
172 }
173 break;
174
175 case "map":
176 $item["obj_type_txt"] = $this->lng->txt("obj_mob");
177 $item["obj_title"] = ilObject::_lookupTitle($usage["id"]);
178 $item["sub_txt"] = $this->lng->txt("cont_link_area");
179 break;
180 }
181
182 // show versions
183 if (is_array($usage["hist_nr"]) &&
184 (count($usage["hist_nr"]) > 1 || $usage["hist_nr"][0] > 0))
185 {
186 asort($usage["hist_nr"]);
187 $ver = $sep = "";
188 if ($usage["hist_nr"][0] == 0)
189 {
190 array_shift($usage["hist_nr"]);
191 $usage["hist_nr"][] = 0;
192 }
193
194 if (count($usage["hist_nr"]) > 5)
195 {
196 $ver.= "..., ";
197 $cnt = count($usage["hist_nr"]) - 5;
198 for ($i = 0; $i < $cnt; $i++)
199 {
200 unset($usage["hist_nr"][$i]);
201 }
202 }
203 foreach ($usage["hist_nr"] as $nr)
204 {
205 if ($nr > 0)
206 {
207 $ver.= $sep.$nr;
208 }
209 else
210 {
211 $ver.= $sep.$this->lng->txt("cont_current_version");
212 }
213 $sep = ", ";
214 }
215
216 $this->tpl->setCurrentBlock("versions");
217 $this->tpl->setVariable("TXT_VERSIONS", $this->lng->txt("cont_versions"));
218 $this->tpl->setVariable("VAL_VERSIONS", $ver);
219 $this->tpl->parseCurrentBlock();
220 }
221
222 if ($item["obj_type_txt"] != "")
223 {
224 $this->tpl->setCurrentBlock("type");
225 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("type"));
226 $this->tpl->setVariable("VAL_TYPE", $item["obj_type_txt"]);
227 $this->tpl->parseCurrentBlock();
228 }
229
230 if ($usage["type"] != "clip")
231 {
232 if ($item["obj_link"])
233 {
234 $this->tpl->setCurrentBlock("linked_item");
235 $this->tpl->setVariable("TXT_OBJECT", $item["obj_title"]);
236 $this->tpl->setVariable("HREF_LINK", $item["obj_link"]);
237 $this->tpl->parseCurrentBlock();
238 }
239 else
240 {
241 $this->tpl->setVariable("TXT_OBJECT_NO_LINK", $item["obj_title"]);
242 }
243
244 if ($item["sub_txt"] != "")
245 {
246 $this->tpl->setVariable("SEP", ", ");
247 $this->tpl->setVariable("SUB_TXT", $item["sub_txt"]);
248 if ($item["sub_title"] != "")
249 {
250 $this->tpl->setVariable("SEP2", ": ");
251 $this->tpl->setVariable("SUB_TITLE", $item["sub_title"]);
252 }
253 }
254
255 }
256 else
257 {
258 $this->tpl->setVariable("TXT_OBJECT_NO_LINK", $this->lng->txt("cont_users_have_mob_in_clip1").
259 " ".$usage["cnt"]." ".$this->lng->txt("cont_users_have_mob_in_clip2"));
260
261 }
262 }
263
264 function getFirstWritableRefId($a_obj_id)
265 {
266 global $ilAccess;
267
268 $ref_ids = ilObject::_getAllReferences($a_obj_id);
269 foreach ($ref_ids as $ref_id)
270 {
271 if ($ilAccess->checkAccess("write", "", $ref_id))
272 {
273 return $ref_id;
274 }
275 }
276 return 0;
277 }
278}
279?>
_lookupTermId($a_def_id)
Looks up term id for a definition id.
static _lookGlossaryTerm($term_id)
get glossary term
static _lookupTitle($a_obj_id)
Lookup title.
TableGUI class for media pool page usages listing.
fillRow($a_set)
Standard Version of Fill Row.
__construct($a_parent_obj, $a_parent_cmd, $a_page, $a_incl_hist)
Constructor.
Class ilObjLearningModule.
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
static getInstance($a_parent_type, $a_id=0, $a_old_nr=0, $a_lang="-")
Get page object instance.
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.
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