ILIAS  Release_4_0_x_branch Revision 61816
 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 
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  // edit link
72  $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", $a_set["id"]);
73  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
74  {
75  $this->tpl->setCurrentBlock("edit");
76  $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
77  $this->tpl->setVariable("CMD_EDIT",
78  $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "editCastItem"));
79  $this->tpl->setVariable("TXT_DET_PLAYTIME", $lng->txt("mcst_det_playtime"));
80  $this->tpl->setVariable("CMD_DET_PLAYTIME",
81  $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "determinePlaytime"));
82  $this->tpl->parseCurrentBlock();
83  $this->tpl->setCurrentBlock("edit_checkbox");
84  $this->tpl->setVariable("VAL_ID", $a_set["id"]);
85  $this->tpl->parseCurrentBlock();
86  }
87 
88 
89  // access
90  if ($enable_internal_rss)
91  {
92  $this->tpl->setCurrentBlock("access");
93  $this->tpl->setVariable("TXT_ACCESS", $lng->txt("news_news_item_visibility"));
94  if ($a_set["visibility"] == NEWS_PUBLIC)
95  {
96  $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_public"));
97  }
98  else
99  {
100  $this->tpl->setVariable("VAL_ACCESS", $lng->txt("news_visibility_users"));
101  }
102  $this->tpl->parseCurrentBlock();
103  }
104 
105  $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", "");
106 
107  if (ilObject::_exists($a_set["mob_id"]))
108  {
109  if ($a_set["update_date"] != "")
110  {
111  $this->tpl->setCurrentBlock("last_update");
112  $this->tpl->setVariable("TXT_LAST_UPDATE",
113  $lng->txt("last_update"));
114  $this->tpl->setVariable("VAL_LAST_UPDATE",
115  ilDatePresentation::formatDate(new ilDateTime($a_set["update_date"], IL_CAL_DATETIME)));
116  $this->tpl->parseCurrentBlock();
117  }
118 
119  $mob = new ilObjMediaObject($a_set["mob_id"]);
120  $med = $mob->getMediaItem("Standard");
121 
122  $this->tpl->setVariable("VAL_TITLE",
123  $a_set["title"]);
124  $this->tpl->setVariable("VAL_DESCRIPTION",
125  $a_set["content"]);
126  $this->tpl->setVariable("TXT_FILENAME",
127  $lng->txt("filename"));
128  $this->tpl->setVariable("VAL_FILENAME",
129  $mob->getTitle());
130  $this->tpl->setVariable("TXT_CREATED",
131  $lng->txt("created"));
132  $this->tpl->setVariable("VAL_CREATED",
133  ilDatePresentation::formatDate(new ilDateTime($a_set["creation_date"], IL_CAL_DATETIME)));
134  $this->tpl->setVariable("TXT_DURATION",
135  $lng->txt("mcst_play_time"));
136  $this->tpl->setVariable("VAL_DURATION",
137  $a_set["playtime"]);
138  if ($this->downloadable) {
139  $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", $a_set["id"]);
140  // to keep always the order of the purposes
141  // iterate through purposes and display the according mediaitems
142  foreach (ilObjMediaCast::$purposes as $purpose)
143  {
144  $a_mob = $mob->getMediaItem($purpose);
145  if (!is_object($a_mob))
146  continue;
147  $ilCtrl->setParameterByClass("ilobjmediacastgui", "purpose", $a_mob->getPurpose());
148  $file = ilObjMediaObject::_lookupItemPath($a_mob->getMobId(), false, false, $a_mob->getPurpose());
149  if (is_file($file))
150  {
151  $size = filesize($file);
152  $size = ", ".sprintf("%.1f MB",$size/1024/1024);
153  }
154  $format = ($a_mob->getFormat()!= "")?$a_mob->getFormat():"audio/mpeg";
155  $this->tpl->setCurrentBlock("downloadable");
156  $this->tpl->setVariable("TXT_DOWNLOAD", $lng->txt("mcst_download_" . strtolower($a_mob->getPurpose())));
157  $this->tpl->setVariable("CMD_DOWNLOAD", $ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "downloadItem"));
158  $this->tpl->setVariable("TITLE_DOWNLOAD", "(".$format.$size.")");
159  $this->tpl->parseCurrentBlock();
160  }
161  }
162 
163  include_once("./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php");
164  $mpl = new ilMediaPlayerGUI();
165  if (is_object($med))
166  {
167  if (strcasecmp("Reference", $med->getLocationType()) == 0)
168  $mpl->setFile($med->getLocation());
169  else
170  $mpl->setFile(ilObjMediaObject::_getURL($mob->getId())."/".$med->getLocation());
171  $mpl->setMimeType ($med->getFormat());
172  $mpl->setDisplayHeight($med->getHeight());
173  }
174 
175  $this->tpl->setVariable("PLAYER", $mpl->getMp3PlayerHtml());
176 
177  }
178 
179  }
180 
181 }
182 ?>