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