ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilMediaCastTableGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5
6include_once("Services/Table/classes/class.ilTable2GUI.php");
7
17{
18 protected $downloadable = false;
19 protected $edit_order;
20
21 function ilMediaCastTableGUI($a_parent_obj, $a_parent_cmd = "", $a_edit_order = false,
22 $a_presentation_mode = false)
23 {
24 global $ilCtrl, $lng;
25
26 $this->edit_order = (bool)$a_edit_order;
27 $this->presentation_mode = (bool)$a_presentation_mode;
28
29 parent::__construct($a_parent_obj, $a_parent_cmd);
30
31 // Check whether download-buttons will be displayed
32 $mediacast = new ilObjMediaCast($a_parent_obj->id);
33 $this->downloadable = $mediacast->getDownloadable();
34
35 if (!$this->presentation_mode)
36 {
37 $this->addColumn("", "", "1");
38 }
39 $this->addColumn($lng->txt("title"));
40 $this->addColumn($lng->txt("properties"));
41 if(!$this->edit_order)
42 {
43 $this->addColumn($lng->txt("mcst_play"), "", "320px");
44 }
45
46 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
47 $this->setRowTemplate("tpl.table_media_cast_row.html",
48 "Modules/MediaCast");
49
50 $this->setShowRowsSelector(true);
51
52 // this messes up the db ordering, where the id is also taken into
53 // account, if the creation date is the same (this happens e.g. on import)
54// $this->setDefaultOrderField("creation_date");
55// $this->setDefaultOrderDirection("desc");
56 }
57
62 protected function fillRow($a_set)
63 {
64 global $lng, $ilCtrl, $ilAccess;
65
66 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
67
68 $news_set = new ilSetting("news");
69 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
70
71 if ($this->presentation_mode)
72 {
73 $ilCtrl->setParameterByClass("ilobjmediacastgui", "presentation", "1");
74 }
75
76 // access
77 if ($enable_internal_rss && !$this->presentation_mode)
78 {
79 $this->tpl->setCurrentBlock("access");
80 $this->tpl->setVariable("TXT_ACCESS", $lng->txt("news_news_item_visibility"));
81 if ($a_set["visibility"] == NEWS_PUBLIC)
82 {
83 $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public"));
84 }
85 else
86 {
87 $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users"));
88 }
89 $this->tpl->parseCurrentBlock();
90 }
91
92 $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", "");
93
94 if (ilObject::_exists($a_set["mob_id"]))
95 {
96 if ($a_set["update_date"] != "")
97 {
98 $this->tpl->setCurrentBlock("last_update");
99 $this->tpl->setVariable("TXT_LAST_UPDATE",
100 $lng->txt("last_update"));
101 $this->tpl->setVariable("VAL_LAST_UPDATE",
102 ilDatePresentation::formatDate(new ilDateTime($a_set["update_date"], IL_CAL_DATETIME)));
103 $this->tpl->parseCurrentBlock();
104 }
105
106 $mob = new ilObjMediaObject($a_set["mob_id"]);
107 $med = $mob->getMediaItem("Standard");
108
109 $this->tpl->setVariable("VAL_TITLE",
110 $a_set["title"]);
111 $this->tpl->setVariable("VAL_DESCRIPTION",
112 $a_set["content"]);
113 $this->tpl->setVariable("TXT_CREATED",
114 $lng->txt("created"));
115 $this->tpl->setVariable("VAL_CREATED",
116 ilDatePresentation::formatDate(new ilDateTime($a_set["creation_date"], IL_CAL_DATETIME)));
117
118 $this->tpl->setVariable("TXT_DURATION",
119 $lng->txt("mcst_play_time"));
120
121 if ($a_set["playtime"] != "00:00:00")
122 {
123 $this->tpl->setVariable("VAL_DURATION",
124 $a_set["playtime"]);
125 }
126 else
127 {
128 $this->tpl->setVariable("VAL_DURATION", "-");
129 }
130
131 if(!$this->edit_order)
132 {
133 if ($this->downloadable)
134 {
135 $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", $a_set["id"]);
136 // to keep always the order of the purposes
137 // iterate through purposes and display the according mediaitems
138 foreach (ilObjMediaCast::$purposes as $purpose)
139 {
140 $a_mob = $mob->getMediaItem($purpose);
141 if (!is_object($a_mob))
142 continue;
143 $ilCtrl->setParameterByClass("ilobjmediacastgui", "purpose", $a_mob->getPurpose());
144 $file = ilObjMediaObject::_lookupItemPath($a_mob->getMobId(), false, false, $a_mob->getPurpose());
145 if (is_file($file))
146 {
147 $size = filesize($file);
148 $size = ", ".sprintf("%.1f MB",$size/1024/1024);
149 }
150 $format = ($a_mob->getFormat()!= "")?$a_mob->getFormat():"audio/mpeg";
151 $this->tpl->setCurrentBlock("downloadable");
152 $this->tpl->setVariable("TXT_DOWNLOAD", $lng->txt("mcst_download_" . strtolower($a_mob->getPurpose())));
153 $this->tpl->setVariable("CMD_DOWNLOAD", $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "downloadItem"));
154 $this->tpl->setVariable("TITLE_DOWNLOAD", "(".$format.$size.")");
155 $this->tpl->parseCurrentBlock();
156 }
157 }
158
159 include_once("./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php");
160
161 // the news id will be used as player id, see also ilObjMediaCastGUI
162 $event_url = ($this->presentation_mode)
163 ? $ilCtrl->getLinkTarget($this->parent_obj, "handlePlayerEvent", "", true, false)
164 : "";
165 $mpl = new ilMediaPlayerGUI($a_set["id"], $event_url);
166 if (is_object($med))
167 {
168 if (strcasecmp("Reference", $med->getLocationType()) == 0)
169 $mpl->setFile($med->getLocation());
170 else
171 $mpl->setFile(ilObjMediaObject::_getURL($mob->getId())."/".$med->getLocation());
172 $mpl->setMimeType ($med->getFormat());
173 //$mpl->setDisplayHeight($med->getHeight());
174 $mpl->setDisplayWidth("640");
175 $mpl->setDisplayHeight("480");
176 $mpl->setVideoPreviewPic($mob->getVideoPreviewPic());
177 $mpl->setTitle($a_set["title"]);
178 $mpl->setDescription($a_set["content"]);
179
180 $med_alt = $mob->getMediaItem("VideoAlternative");
181 if (is_object($med_alt))
182 {
183 $mpl->setAlternativeVideoFile(ilObjMediaObject::_getURL($mob->getId())."/".
184 $med_alt->getLocation());
185 $mpl->setAlternativeVideoMimeType($med_alt->getFormat());
186 }
187 }
188
189 //$this->tpl->setVariable("PLAYER", $mpl->getMp3PlayerHtml());
190 $this->tpl->setVariable("PLAYER", $mpl->getPreviewHtml());
191
192 // edit link
193 $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", $a_set["id"]);
194 if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) &&
195 !$this->presentation_mode)
196 {
197 $this->tpl->setCurrentBlock("edit");
198 $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
199 $this->tpl->setVariable("CMD_EDIT",
200 $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "editCastItem"));
201
202 if (!is_int(strpos($med->getFormat(), "image/")))
203 {
204 $this->tpl->setVariable("TXT_DET_PLAYTIME", $lng->txt("mcst_det_playtime"));
205 $this->tpl->setVariable("CMD_DET_PLAYTIME",
206 $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "determinePlaytime"));
207 }
208 $this->tpl->parseCurrentBlock();
209
210 $this->tpl->setCurrentBlock("edit_checkbox");
211 $this->tpl->setVariable("VAL_ID", $a_set["id"]);
212 $this->tpl->parseCurrentBlock();
213// $this->tpl->touchBlock("contrl_col");
214 }
215 }
216 else
217 {
218 $this->tpl->setCurrentBlock("edit_order");
219 $this->tpl->setVariable("VAL_ID", $a_set["id"]);
220 $this->tpl->setVariable("VAL_ORDER", $a_set["order"]);
221 $this->tpl->parseCurrentBlock();
222// $this->tpl->touchBlock("contrl_col");
223 }
224
225 // download and play counter
226 if (!$this->presentation_mode)
227 {
228 if ($a_set["mob_cnt_download"] > 0)
229 {
230 $this->tpl->setCurrentBlock("prop");
231 $this->tpl->setVariable("TXT_PROP", $lng->txt("mcst_download_cnt"));
232 $this->tpl->setVariable("VAL_PROP", $a_set["mob_cnt_download"]);
233 $this->tpl->parseCurrentBlock();
234 }
235 if ($a_set["mob_cnt_play"] > 0)
236 {
237 $this->tpl->setCurrentBlock("prop");
238 $this->tpl->setVariable("TXT_PROP", $lng->txt("mcst_play_cnt"));
239 $this->tpl->setVariable("VAL_PROP", $a_set["mob_cnt_play"]);
240 $this->tpl->parseCurrentBlock();
241 }
242 }
243 }
244
245 }
246
247}
248?>
print $file
$size
Definition: RandomTest.php:79
$_GET["client_id"]
const IL_CAL_DATETIME
const NEWS_PUBLIC
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
TableGUI class for table NewsForContext.
fillRow($a_set)
Standard Version of Fill Row.
ilMediaCastTableGUI($a_parent_obj, $a_parent_cmd="", $a_edit_order=false, $a_presentation_mode=false)
User interface for media player.
Class ilObjMediaCast.
Class ilObjMediaObject.
_getURL($a_mob_id)
get directory for files of media object (static)
static _lookupItemPath($a_mob_id, $a_url_encode=false, $a_web=true, $a_purpose="")
Get path for item with specific purpose.
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
ILIAS Setting Class.
Class ilTable2GUI.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40