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