ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMediaCastTableGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once("Services/Table/classes/class.ilTable2GUI.php");
25 
35 {
36  protected $downloadable = false;
37  function ilMediaCastTableGUI($a_parent_obj, $a_parent_cmd = "")
38  {
39  global $ilCtrl, $lng;
40 
41  parent::__construct($a_parent_obj, $a_parent_cmd);
42 
43  // Check whether download-buttons will be displayed
44  $mediacast = new ilObjMediaCast($a_parent_obj->id);
45  $this->downloadable = $mediacast->getDownloadable();
46 
47  $this->addColumn("", "f", "1");
48  $this->addColumn($lng->txt("mcst_entry"), "", "33%");
49  $this->addColumn("", "", "33%");
50  $this->addColumn("", "", "34%");
51  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
52  $this->setRowTemplate("tpl.table_media_cast_row.html",
53  "Modules/MediaCast");
54  $this->setDefaultOrderField("creation_date");
55  $this->setDefaultOrderDirection("desc");
56 
57  }
58 
63  protected function fillRow($a_set)
64  {
65  global $lng, $ilCtrl, $ilAccess;
66 
67  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
68 
69  $news_set = new ilSetting("news");
70  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
71 
72  // edit link
73  $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", $a_set["id"]);
74  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
75  {
76  $this->tpl->setCurrentBlock("edit");
77  $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
78  $this->tpl->setVariable("CMD_EDIT",
79  $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "editCastItem"));
80  $this->tpl->setVariable("TXT_DET_PLAYTIME", $lng->txt("mcst_det_playtime"));
81  $this->tpl->setVariable("CMD_DET_PLAYTIME",
82  $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "determinePlaytime"));
83  $this->tpl->parseCurrentBlock();
84  $this->tpl->setCurrentBlock("edit_checkbox");
85  $this->tpl->setVariable("VAL_ID", $a_set["id"]);
86  $this->tpl->parseCurrentBlock();
87  }
88 
89 
90  // access
91  if ($enable_internal_rss)
92  {
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  {
97  $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public"));
98  }
99  else
100  {
101  $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users"));
102  }
103  $this->tpl->parseCurrentBlock();
104  }
105 
106  $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", "");
107 
108  if (ilObject::_exists($a_set["mob_id"]))
109  {
110  if ($a_set["update_date"] != "")
111  {
112  $this->tpl->setCurrentBlock("last_update");
113  $this->tpl->setVariable("TXT_LAST_UPDATE",
114  $lng->txt("last_update"));
115  $this->tpl->setVariable("VAL_LAST_UPDATE",
116  ilDatePresentation::formatDate(new ilDateTime($a_set["update_date"], IL_CAL_DATETIME)));
117  $this->tpl->parseCurrentBlock();
118  }
119 
120  $mob = new ilObjMediaObject($a_set["mob_id"]);
121  $med = $mob->getMediaItem("Standard");
122 
123  $this->tpl->setVariable("VAL_TITLE",
124  $a_set["title"]);
125  $this->tpl->setVariable("VAL_DESCRIPTION",
126  $a_set["content"]);
127  $this->tpl->setVariable("TXT_FILENAME",
128  $lng->txt("filename"));
129  $this->tpl->setVariable("VAL_FILENAME",
130  $mob->getTitle());
131  $this->tpl->setVariable("TXT_CREATED",
132  $lng->txt("created"));
133  $this->tpl->setVariable("VAL_CREATED",
134  ilDatePresentation::formatDate(new ilDateTime($a_set["creation_date"], IL_CAL_DATETIME)));
135  $this->tpl->setVariable("TXT_DURATION",
136  $lng->txt("mcst_play_time"));
137  $this->tpl->setVariable("VAL_DURATION",
138  $a_set["playtime"]);
139  if ($this->downloadable) {
140  $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", $a_set["id"]);
141  // to keep always the order of the purposes
142  // iterate through purposes and display the according mediaitems
143  foreach (ilObjMediaCast::$purposes as $purpose)
144  {
145  $a_mob = $mob->getMediaItem($purpose);
146  if (!is_object($a_mob))
147  continue;
148  $ilCtrl->setParameterByClass("ilobjmediacastgui", "purpose", $a_mob->getPurpose());
149  $file = ilObjMediaObject::_lookupItemPath($a_mob->getMobId(), false, false, $a_mob->getPurpose());
150  if (is_file($file))
151  {
152  $size = filesize($file);
153  $size = ", ".sprintf("%.1f MB",$size/1024/1024);
154  }
155  $format = ($a_mob->getFormat()!= "")?$a_mob->getFormat():"audio/mpeg";
156  $this->tpl->setCurrentBlock("downloadable");
157  $this->tpl->setVariable("TXT_DOWNLOAD", $lng->txt("mcst_download_" . strtolower($a_mob->getPurpose())));
158  $this->tpl->setVariable("CMD_DOWNLOAD", $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "downloadItem"));
159  $this->tpl->setVariable("TITLE_DOWNLOAD", "(".$format.$size.")");
160  $this->tpl->parseCurrentBlock();
161  }
162  }
163 
164  include_once("./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php");
165  $mpl = new ilMediaPlayerGUI();
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  }
175 
176  $this->tpl->setVariable("PLAYER", $mpl->getMp3PlayerHtml());
177 
178  }
179 
180  }
181 
182 }
183 ?>