ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 {
18  protected $downloadable = false;
19  protected $edit_order;
20 
21  function __construct($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  require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
169  if (strcasecmp("Reference", $med->getLocationType()) == 0) {
170  $a_file = $med->getLocation();
171  }
172  else {
173  $a_file = ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation();
174  }
175  $mpl->setFile(ilWACSignedPath::signFile($a_file));
176  $mpl->setMimeType ($med->getFormat());
177  //$mpl->setDisplayHeight($med->getHeight());
178  $mpl->setDisplayWidth("640");
179  $mpl->setDisplayHeight("480");
180  $mpl->setVideoPreviewPic(ilWACSignedPath::signFile($mob->getVideoPreviewPic()));
181  $mpl->setTitle($a_set["title"]);
182  $mpl->setDescription($a_set["content"]);
183 
184  $med_alt = $mob->getMediaItem("VideoAlternative");
185  if (is_object($med_alt))
186  {
187  $a_val = ilObjMediaObject::_getURL($mob->getId()) . "/" . $med_alt->getLocation();
188  $mpl->setAlternativeVideoFile(ilWACSignedPath::signFile($a_val));
189  $mpl->setAlternativeVideoMimeType($med_alt->getFormat());
190  }
191  }
192 
193  //$this->tpl->setVariable("PLAYER", $mpl->getMp3PlayerHtml());
194  $this->tpl->setVariable("PLAYER", $mpl->getPreviewHtml());
195 
196  // edit link
197  $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", $a_set["id"]);
198  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) &&
199  !$this->presentation_mode)
200  {
201  $this->tpl->setCurrentBlock("edit");
202  $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
203  $this->tpl->setVariable("CMD_EDIT",
204  $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "editCastItem"));
205 
206  if (!is_int(strpos($med->getFormat(), "image/")))
207  {
208  $this->tpl->setVariable("TXT_DET_PLAYTIME", $lng->txt("mcst_det_playtime"));
209  $this->tpl->setVariable("CMD_DET_PLAYTIME",
210  $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "determinePlaytime"));
211  }
212  $this->tpl->parseCurrentBlock();
213 
214  $this->tpl->setCurrentBlock("edit_checkbox");
215  $this->tpl->setVariable("VAL_ID", $a_set["id"]);
216  $this->tpl->parseCurrentBlock();
217 // $this->tpl->touchBlock("contrl_col");
218  }
219  }
220  else
221  {
222  $this->tpl->setCurrentBlock("edit_order");
223  $this->tpl->setVariable("VAL_ID", $a_set["id"]);
224  $this->tpl->setVariable("VAL_ORDER", $a_set["order"]);
225  $this->tpl->parseCurrentBlock();
226 // $this->tpl->touchBlock("contrl_col");
227  }
228 
229  // download and play counter
230  if (!$this->presentation_mode)
231  {
232  if ($a_set["mob_cnt_download"] > 0)
233  {
234  $this->tpl->setCurrentBlock("prop");
235  $this->tpl->setVariable("TXT_PROP", $lng->txt("mcst_download_cnt"));
236  $this->tpl->setVariable("VAL_PROP", $a_set["mob_cnt_download"]);
237  $this->tpl->parseCurrentBlock();
238  }
239  if ($a_set["mob_cnt_play"] > 0)
240  {
241  $this->tpl->setCurrentBlock("prop");
242  $this->tpl->setVariable("TXT_PROP", $lng->txt("mcst_play_cnt"));
243  $this->tpl->setVariable("VAL_PROP", $a_set["mob_cnt_play"]);
244  $this->tpl->parseCurrentBlock();
245  }
246  }
247  }
248 
249  }
250 
251 }
252 ?>
fillRow($a_set)
Standard Version of Fill Row.
ILIAS Setting Class.
$size
Definition: RandomTest.php:79
const IL_CAL_DATETIME
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
$_GET["client_id"]
__construct($a_parent_obj, $a_parent_cmd="", $a_edit_order=false, $a_presentation_mode=false)
static _getURL($a_mob_id)
get directory for files of media object (static)
global $ilCtrl
Definition: ilias.php:18
Class ilTable2GUI.
const NEWS_PUBLIC
Class ilObjMediaCast.
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
Class ilObjMediaObject.
static signFile($path_to_file)
setRowTemplate($a_template, $a_template_dir="")
Set row template.
static _lookupItemPath($a_mob_id, $a_url_encode=false, $a_web=true, $a_purpose="")
Get path for item with specific purpose.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
User interface for media player.
global $lng
Definition: privfeed.php:17
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
TableGUI class for table NewsForContext.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
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.