ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 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 messes up the db ordering, where the id is also taken into
51  // account, if the creation date is the same (this happens e.g. on import)
52 // $this->setDefaultOrderField("creation_date");
53 // $this->setDefaultOrderDirection("desc");
54  }
55 
60  protected function fillRow($a_set)
61  {
62  global $lng, $ilCtrl, $ilAccess;
63 
64  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
65 
66  $news_set = new ilSetting("news");
67  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
68 
69  // access
70  if ($enable_internal_rss && !$this->presentation_mode)
71  {
72  $this->tpl->setCurrentBlock("access");
73  $this->tpl->setVariable("TXT_ACCESS", $lng->txt("news_news_item_visibility"));
74  if ($a_set["visibility"] == NEWS_PUBLIC)
75  {
76  $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public"));
77  }
78  else
79  {
80  $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users"));
81  }
82  $this->tpl->parseCurrentBlock();
83  }
84 
85  $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", "");
86 
87  if (ilObject::_exists($a_set["mob_id"]))
88  {
89  if ($a_set["update_date"] != "")
90  {
91  $this->tpl->setCurrentBlock("last_update");
92  $this->tpl->setVariable("TXT_LAST_UPDATE",
93  $lng->txt("last_update"));
94  $this->tpl->setVariable("VAL_LAST_UPDATE",
95  ilDatePresentation::formatDate(new ilDateTime($a_set["update_date"], IL_CAL_DATETIME)));
96  $this->tpl->parseCurrentBlock();
97  }
98 
99  $mob = new ilObjMediaObject($a_set["mob_id"]);
100  $med = $mob->getMediaItem("Standard");
101 
102  $this->tpl->setVariable("VAL_TITLE",
103  $a_set["title"]);
104  $this->tpl->setVariable("VAL_DESCRIPTION",
105  $a_set["content"]);
106  $this->tpl->setVariable("TXT_CREATED",
107  $lng->txt("created"));
108  $this->tpl->setVariable("VAL_CREATED",
109  ilDatePresentation::formatDate(new ilDateTime($a_set["creation_date"], IL_CAL_DATETIME)));
110 
111  $this->tpl->setVariable("TXT_DURATION",
112  $lng->txt("mcst_play_time"));
113 
114  if ($a_set["playtime"] != "00:00:00")
115  {
116  $this->tpl->setVariable("VAL_DURATION",
117  $a_set["playtime"]);
118  }
119  else
120  {
121  $this->tpl->setVariable("VAL_DURATION", "-");
122  }
123 
124  if(!$this->edit_order)
125  {
126  if ($this->downloadable)
127  {
128  $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", $a_set["id"]);
129  // to keep always the order of the purposes
130  // iterate through purposes and display the according mediaitems
131  foreach (ilObjMediaCast::$purposes as $purpose)
132  {
133  $a_mob = $mob->getMediaItem($purpose);
134  if (!is_object($a_mob))
135  continue;
136  $ilCtrl->setParameterByClass("ilobjmediacastgui", "purpose", $a_mob->getPurpose());
137  $file = ilObjMediaObject::_lookupItemPath($a_mob->getMobId(), false, false, $a_mob->getPurpose());
138  if (is_file($file))
139  {
140  $size = filesize($file);
141  $size = ", ".sprintf("%.1f MB",$size/1024/1024);
142  }
143  $format = ($a_mob->getFormat()!= "")?$a_mob->getFormat():"audio/mpeg";
144  $this->tpl->setCurrentBlock("downloadable");
145  $this->tpl->setVariable("TXT_DOWNLOAD", $lng->txt("mcst_download_" . strtolower($a_mob->getPurpose())));
146  $this->tpl->setVariable("CMD_DOWNLOAD", $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "downloadItem"));
147  $this->tpl->setVariable("TITLE_DOWNLOAD", "(".$format.$size.")");
148  $this->tpl->parseCurrentBlock();
149  }
150  }
151 
152  include_once("./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php");
153  $mpl = new ilMediaPlayerGUI();
154  if (is_object($med))
155  {
156  if (strcasecmp("Reference", $med->getLocationType()) == 0)
157  $mpl->setFile($med->getLocation());
158  else
159  $mpl->setFile(ilObjMediaObject::_getURL($mob->getId())."/".$med->getLocation());
160  $mpl->setMimeType ($med->getFormat());
161  //$mpl->setDisplayHeight($med->getHeight());
162  $mpl->setDisplayWidth("640");
163  $mpl->setDisplayHeight("480");
164  $mpl->setVideoPreviewPic($mob->getVideoPreviewPic());
165  $mpl->setTitle($a_set["title"]);
166  $mpl->setDescription($a_set["content"]);
167 
168  $med_alt = $mob->getMediaItem("VideoAlternative");
169  if (is_object($med_alt))
170  {
171  $mpl->setAlternativeVideoFile(ilObjMediaObject::_getURL($mob->getId())."/".
172  $med_alt->getLocation());
173  $mpl->setAlternativeVideoMimeType($med_alt->getFormat());
174  }
175  }
176 
177  //$this->tpl->setVariable("PLAYER", $mpl->getMp3PlayerHtml());
178  $this->tpl->setVariable("PLAYER", $mpl->getPreviewHtml());
179 
180  // edit link
181  $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", $a_set["id"]);
182  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) &&
183  !$this->presentation_mode)
184  {
185  $this->tpl->setCurrentBlock("edit");
186  $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
187  $this->tpl->setVariable("CMD_EDIT",
188  $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "editCastItem"));
189 
190  if (!is_int(strpos($med->getFormat(), "image/")))
191  {
192  $this->tpl->setVariable("TXT_DET_PLAYTIME", $lng->txt("mcst_det_playtime"));
193  $this->tpl->setVariable("CMD_DET_PLAYTIME",
194  $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "determinePlaytime"));
195  }
196  $this->tpl->parseCurrentBlock();
197 
198  $this->tpl->setCurrentBlock("edit_checkbox");
199  $this->tpl->setVariable("VAL_ID", $a_set["id"]);
200  $this->tpl->parseCurrentBlock();
201 // $this->tpl->touchBlock("contrl_col");
202  }
203  }
204  else
205  {
206  $this->tpl->setCurrentBlock("edit_order");
207  $this->tpl->setVariable("VAL_ID", $a_set["id"]);
208  $this->tpl->setVariable("VAL_ORDER", $a_set["order"]);
209  $this->tpl->parseCurrentBlock();
210 // $this->tpl->touchBlock("contrl_col");
211  }
212 
213 
214  }
215 
216  }
217 
218 }
219 ?>