ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjMediaCastGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once "./Services/Object/classes/class.ilObjectGUI.php";
6 
19 {
20 
21  private $additionalPurposes = array ("VideoPortable", "AudioPortable");
22  private $purposeSuffixes = array ();
23  private $mimeTypes = array();
24 
29  function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
30  {
31  global $ilCtrl, $lng;
32 
33  $this->type = "mcst";
34  parent::__construct($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
35  $lng->loadLanguageModule("mcst");
36  $lng->loadLanguageModule("news");
37  $lng->loadLanguageModule("rep");
38 
39  $ilCtrl->saveParameter($this, "item_id");
40 
41  include_once ("./Modules/MediaCast/classes/class.ilMediaCastSettings.php");
43  $this->purposeSuffixes = $settings->getPurposeSuffixes();
44  $this->mimeTypes = array();
45  $mime_types = $settings->getMimeTypes();
46  foreach ($mime_types as $mt)
47  {
48  $this->mimeTypes[$mt] = $mt;
49  }
50 
51  include_once("./Services/Utilities/classes/class.ilMimeTypeUtil.php");
52  foreach (ilMimeTypeUtil::getExt2MimeMap() as $mt)
53  {
54  $this->mimeTypes[$mt] = $mt;
55  }
56  asort($this->mimeTypes);
57  }
58 
59  function executeCommand()
60  {
61  global $ilUser, $ilTabs;
62 
63  $next_class = $this->ctrl->getNextClass($this);
64  $cmd = $this->ctrl->getCmd();
65  $this->prepareOutput();
66 
67  switch($next_class)
68  {
69  case "ilinfoscreengui":
70  $this->checkPermission("visible");
71  $this->infoScreen(); // forwards command
72  break;
73 
74  case "ilexportgui":
75 // $this->prepareOutput();
76  $ilTabs->activateTab("export");
77  include_once("./Services/Export/classes/class.ilExportGUI.php");
78  $exp_gui = new ilExportGUI($this);
79  $exp_gui->addFormat("xml");
80  $ret = $this->ctrl->forwardCommand($exp_gui);
81 // $this->tpl->show();
82  break;
83 
84  case 'ilpermissiongui':
85  $ilTabs->activateTab("id_permissions");
86  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
87  $perm_gui = new ilPermissionGUI($this);
88  $ret = $this->ctrl->forwardCommand($perm_gui);
89  break;
90 
91  case 'ilobjectcopygui':
92  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
93  $cp = new ilObjectCopyGUI($this);
94  $cp->setType('mcst');
95  $this->ctrl->forwardCommand($cp);
96  break;
97 
98  case "ilcommonactiondispatchergui":
99  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
101  $this->ctrl->forwardCommand($gui);
102  break;
103 
104  case "illearningprogressgui":
105  $ilTabs->activateTab('learning_progress');
106  require_once 'Services/Tracking/classes/class.ilLearningProgressGUI.php';
107  $new_gui = new ilLearningProgressGUI(
109  $this->object->getRefId(),
110  $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId()
111  );
112  $this->ctrl->forwardCommand($new_gui);
113  $this->tabs_gui->setTabActive('learning_progress');
114  break;
115 
116  default:
117  if(!$cmd)
118  {
119  $cmd = "infoScreen";
120  }
121  $cmd .= "Object";
122  if ($cmd != "infoScreenObject")
123  {
124  $this->checkPermission("read");
125  }
126  else
127  {
128  $this->checkPermission("visible");
129  }
130  $this->$cmd();
131 
132  break;
133  }
134 
135  $this->addHeaderAction();
136 
137  return true;
138  }
139 
140  protected function initCreationForms($a_new_type)
141  {
142  $forms = array(self::CFORM_NEW => $this->initCreateForm($a_new_type),
143  self::CFORM_IMPORT => $this->initImportForm($a_new_type),
144  self::CFORM_CLONE => $this->fillCloneTemplate(null, $a_new_type));
145 
146  return $forms;
147  }
148 
153  function afterSave(ilObject $newObj)
154  {
155  // always send a message
156  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
157  ilUtil::redirect("ilias.php?baseClass=ilMediaCastHandlerGUI&ref_id=".$newObj->getRefId()."&cmd=editSettings");
158  }
159 
163  function listItemsObject($a_presentation_mode = false)
164  {
165  global $tpl, $lng, $ilAccess, $ilTabs, $ilToolbar;
166 
167  $this->checkPermission("read");
168 
169  if ($a_presentation_mode)
170  {
171  $this->addContentSubTabs("content");
172  }
173  else
174  {
175  $this->addContentSubTabs("manage");
176  }
177 
178  $med_items = $this->object->getSortedItemsArray();
179 
180  include_once("./Modules/MediaCast/classes/class.ilMediaCastTableGUI.php");
181  if ($a_presentation_mode)
182  {
183  $table_gui = new ilMediaCastTableGUI($this, "showContent", false, true);
184  }
185  else
186  {
187  $table_gui = new ilMediaCastTableGUI($this, "listItems");
188  }
189 
190  $table_gui->setData($med_items);
191 
192  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) && !$a_presentation_mode)
193  {
194  $ilToolbar->addButton($lng->txt("add"), $this->ctrl->getLinkTarget($this, "addCastItem"));
195 
196  $table_gui->addMultiCommand("confirmDeletionItems", $lng->txt("delete"));
197  $table_gui->setSelectAllCheckbox("item_id");
198  }
199 
200  $feed_icon_html = $this->getFeedIconsHTML();
201  if ($feed_icon_html != "")
202  {
203  $table_gui->setHeaderHTML($feed_icon_html);
204  }
205 
206  $tpl->setContent($table_gui->getHTML());
207  }
208 
215  function getFeedIconsHTML()
216  {
217  global $lng;
218 
219  $html = "";
220 
221  include_once("./Services/Block/classes/class.ilBlockSetting.php");
222  $public_feed = ilBlockSetting::_lookup("news", "public_feed",
223  0, $this->object->getId());
224 
225  // rss icon/link
226  if ($public_feed)
227  {
228  $news_set = new ilSetting("news");
229  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
230 
231  if ($enable_internal_rss)
232  {
233  // create dummy object in db (we need an id)
234  $items = $this->object->getItemsArray();
235  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
236  $html = "";
237  foreach (ilObjMediaCast::$purposes as $purpose)
238  {
239  foreach ($items as $id => $item)
240  {
241  $mob = new ilObjMediaObject($item["mob_id"]);
242  $mob->read();
243  if ($mob->hasPurposeItem($purpose))
244  {
245  if ($html == "")
246  {
247  $html = " ";
248  }
249  $url = ILIAS_HTTP_PATH."/feed.php?client_id=".rawurlencode(CLIENT_ID)."&"."ref_id=".$_GET["ref_id"]."&purpose=$purpose";
250  $title = $lng->txt("news_feed_url");
251 
252  include_once("./Services/News/classes/class.ilRSSButtonGUI.php");
253  switch (strtolower($purpose))
254  {
255  case "audioportable":
258  break;
259 
260  case "videoportable":
263  break;
264 
265  default:
266  $type1 = ilRSSButtonGUI::ICON_RSS;
268  break;
269  }
270  $row1 .= "&nbsp;".ilRSSButtonGUI::get($type1, $url);
271  if ($this->object->getPublicFiles())
272  {
273  $url = preg_replace("/https?/i","itpc",$url);
274  $title = $lng->txt("news_feed_url");
275 
276  include_once("./Services/News/classes/class.ilRSSButtonGUI.php");
277  $row2 .= "&nbsp;".ilRSSButtonGUI::get($type2, $url);
278  }
279  break;
280  }
281  }
282  }
283  if ($html != "")
284  {
285  $html .= $row1;
286  if ($row2 != "")
287  {
288  $html .= $row2;
289  }
290  }
291  }
292  }
293  return $html;
294  }
295 
296 
300  function addCastItemObject()
301  {
302  global $tpl;
303 
304  $this->checkPermission("write");
305 
306  $this->initAddCastItemForm();
307  $tpl->setContent($this->form_gui->getHTML());
308  }
309 
314  {
315  global $tpl, $ilToolbar, $ilCtrl;
316 
317  $this->checkPermission("write");
318 
319  // conversion toolbar
320  include_once("./Services/MediaObjects/classes/class.ilFFmpeg.php");
321  if (ilFFmpeg::enabled())
322  {
323  $this->mcst_item = new ilNewsItem($_GET["item_id"]);
324  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
325  $mob = new ilObjMediaObject($this->mcst_item->getMobId());
326 
327  $conv_cnt = 0;
328  // we had other purposes as source as well, but
329  // currently only "Standard" is implemented in the convertFile method
330  foreach (array("Standard") as $p)
331  {
332  /*
333  $med = $mob->getMediaItem($p);
334  if (is_object($med))
335  {
336  $options = ilFFmpeg::getPossibleTargetMimeTypes($med->getFormat());
337  if (count($options) > 0)
338  {
339  if ($conv_cnt > 0)
340  {
341  $ilToolbar->addSeparator();
342  }
343 
344  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
345  $si = new ilSelectInputGUI($this->lng->txt("mcst_conv_".
346  strtolower($p)."_to"), "target_format");
347  $si->setOptions($options);
348  $ilToolbar->addInputItem($si, true);
349 
350  $si = new ilSelectInputGUI(", ".$this->lng->txt("mcst_target").": ",
351  "target_purpose");
352  $si->setOptions(array("Standard" => $this->lng->txt("mcst_purpose_standard"),
353  "VideoAlternative" => $this->lng->txt("mcst_purpose_videoalternative")
354  ));
355  $si->setValue($p);
356  $ilToolbar->addInputItem($si, true);
357 
358  $ilToolbar->addFormButton($this->lng->txt("mcst_convert"), "convertFile");
359 
360  $conv_cnt++;
361  }
362  }
363  */
364 
365  $med = $mob->getMediaItem($p);
366  if (is_object($med))
367  {
368  if (ilFFmpeg::supportsImageExtraction($med->getFormat()))
369  {
370  // second
371  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
372  $ni = new ilTextInputGUI($this->lng->txt("mcst_second"), "sec");
373  $ni->setMaxLength(4);
374  $ni->setSize(4);
375  $ni->setValue(1);
376  $ilToolbar->addInputItem($ni, true);
377 
378  $ilToolbar->addFormButton($this->lng->txt("mcst_extract_preview_image"), "extractPreviewImage");
379  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
380  }
381  }
382 
383  /*if ($conv_cnt > 0)
384  {
385  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
386  }*/
387  }
388  }
389 
390  $this->initAddCastItemForm("edit");
391  $this->getCastItemValues();
392  $tpl->setContent($this->form_gui->getHTML());
393  }
394 
398  function initAddCastItemForm($a_mode = "create")
399  {
400  global $lng, $ilCtrl, $ilTabs;
401 
402  $this->checkPermission("write");
403  $ilTabs->activateTab("edit_content");
404 
405  $lng->loadLanguageModule("mcst");
406 
407  $news_set = new ilSetting("news");
408  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
409 
410  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
411  $this->form_gui = new ilPropertyFormGUI();
412  $this->form_gui->setMultipart(true);
413 
414  // Property Title
415  $text_input = new ilTextInputGUI($lng->txt("title"), "title");
416  $text_input->setMaxLength(200);
417  $this->form_gui->addItem($text_input);
418 
419  // Property Content
420  $text_area = new ilTextAreaInputGUI($lng->txt("description"), "description");
421  $text_area->setRequired(false);
422  $this->form_gui->addItem($text_area);
423 
424  // Property Visibility
425  if ($enable_internal_rss)
426  {
427  $radio_group = new ilRadioGroupInputGUI($lng->txt("access_scope"), "visibility");
428  $radio_option = new ilRadioOption($lng->txt("access_users"), "users");
429  $radio_group->addOption($radio_option);
430  $radio_option = new ilRadioOption($lng->txt("access_public"), "public");
431  $radio_group->addOption($radio_option);
432  $radio_group->setInfo($lng->txt("mcst_visibility_info"));
433  $radio_group->setRequired(true);
434  $radio_group->setValue($this->object->getDefaultAccess() == 0 ? "users" : "public");
435  $this->form_gui->addItem($radio_group);
436  }
437 
438  // Duration
439  $dur = new ilDurationInputGUI($lng->txt("mcst_duration"), "duration");
440  $dur->setInfo($lng->txt("mcst_duration_info"));
441  $dur->setShowDays(false);
442  $dur->setShowHours(true);
443  $dur->setShowSeconds(true);
444  $this->form_gui->addItem($dur);
445 
446  foreach (ilObjMediaCast::$purposes as $purpose)
447  {
448  if ($purpose == "VideoAlternative" &&
449  $a_mode == "create")
450  {
451  continue;
452  }
453 
455  $section->setTitle($lng->txt("mcst_".strtolower($purpose)."_title"));
456  $this->form_gui->addItem($section);
457  if ($a_mode != "create")
458  {
459  $value = new ilHiddenInputGUI("value_".$purpose);
460  $label = new ilNonEditableValueGUI($lng->txt("value"));
461  $label->setPostVar("label_value_".$purpose);
462  $label->setInfo($lng->txt("mcst_current_value_info"));
463  $this->form_gui->addItem($label);
464  $this->form_gui->addItem($value);
465 
466  }
467  $file = new ilFileInputGUI($lng->txt("file"), "file_".$purpose);
468  $file->setSuffixes($this->purposeSuffixes[$purpose]);
469  $this->form_gui->addItem($file);
470  $text_input = new ilRegExpInputGUI($lng->txt("url"), "url_".$purpose);
471  $text_input->setPattern("/https?\:\/\/.+/i");
472  $text_input->setInfo($lng->txt("mcst_reference_info"));
473  $this->form_gui->addItem($text_input);
474  if ($purpose != "Standard")
475  {
476  $clearCheckBox = new ilCheckboxInputGUI();
477  $clearCheckBox->setPostVar("delete_".$purpose);
478  $clearCheckBox->setTitle($lng->txt("mcst_clear_purpose_title"));
479  $this->form_gui->addItem($clearCheckBox);
480  } else {
481 
482  // mime type selection
483  $mimeTypeSelection = new ilSelectInputGUI();
484  $mimeTypeSelection->setPostVar("mimetype_".$purpose);
485  $mimeTypeSelection->setTitle($lng->txt("mcst_mimetype"));
486  $mimeTypeSelection->setInfo($lng->txt("mcst_mimetype_info"));
487  $options = array("" => $lng->txt("mcst_automatic_detection"));
488  $options = array_merge($options, $this->mimeTypes);
489  $mimeTypeSelection->setOptions($options);
490  $this->form_gui->addItem($mimeTypeSelection);
491 
492  // preview picure
493  $pp = new ilImageFileInputGUI($lng->txt("mcst_preview_picture"), "preview_pic");
494  $pp->setSuffixes(array("png", "jpeg", "jpg"));
495  $pp->setInfo($lng->txt("mcst_preview_picture_info")." mp4, mp3, png, jp(e)g, gif");
496  $this->form_gui->addItem($pp);
497 
498  }
499 
500  }
501 
502  // save/cancel button
503  if ($a_mode == "create")
504  {
505  $this->form_gui->setTitle($lng->txt("mcst_add_new_item"));
506  $this->form_gui->addCommandButton("saveCastItem", $lng->txt("save"));
507  }
508  else
509  {
510  $this->form_gui->setTitle($lng->txt("mcst_edit_item"));
511  $this->form_gui->addCommandButton("updateCastItem", $lng->txt("save"));
512  }
513  $this->form_gui->addCommandButton("listItems", $lng->txt("cancel"));
514  $this->form_gui->setFormAction($ilCtrl->getFormAction($this, "saveCastItem"));
515 
516  }
517 
521  public function getCastItemValues()
522  {
523  global $lng;
524 
525  // get mob
526  $this->mcst_item = new ilNewsItem($_GET["item_id"]);
527  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
528  $mob = new ilObjMediaObject($this->mcst_item->getMobId());
529 
530  // preview
531  $ppic = $mob->getVideoPreviewPic();
532  if ($ppic != "")
533  {
534  $i = $this->form_gui->getItemByPostVar("preview_pic");
535  $i->setImage($ppic);
536  }
537 
538 
539  $values = array();
540  $mediaItems = $this->getMediaItems($_GET["item_id"]);
541  if (count ($mediaItems) > 0)
542  {
543  foreach ($mediaItems as $med)
544  {
545  if (!isset ($values["title"]))
546  {
547  // first item, so set title, description, ...
548  $values["title"] = $this->mcst_item->getTitle();
549  $values["description"] = $this->mcst_item->getContent();
550  $values["visibility"] = $this->mcst_item->getVisibility();
551  $length = explode(":", $this->mcst_item->getPlaytime());
552  $values["duration"] = array("hh" => $length[0], "mm" => $length[1], "ss" => $length[2]);
553  }
554 
555  $values["value_".$med->getPurpose()] = (strlen($med->getLocation())> 100) ? "...".substr($med->getLocation(), strlen($med->getLocation()) - 100) : $med->getLocation();
556  $values["label_value_".$med->getPurpose()] = (strlen($med->getLocation())> 100) ? "...".substr($med->getLocation(), strlen($med->getLocation()) - 100) : $med->getLocation();
557  $values["mimetype_".$med->getPurpose()] = $med->getFormat();
558  }
559  }
560  foreach (ilObjMediaCast::$purposes as $purpose) {
561  if (!isset ($values["value_".$purpose]))
562  {
563  $values["label_value_".$purpose] = $lng->txt("none");
564  $values["value_".$purpose] = $lng->txt("none");
565  }
566  }
567  $this->form_gui->setValuesByArray($values);
568  }
569 
574  {
575  global $tpl, $ilCtrl, $ilUser, $lng, $ilTabs;
576 
577  $this->checkPermission("write");
578  $ilTabs->activateTab("edit_content");
579 
580  $this->initAddCastItemForm();
581 
582  if (!$this->form_gui->checkInput() ||
583  ($_POST["url_Standard"] == "" && !$_FILES['file_Standard']['tmp_name']))
584  {
585  if (($_POST["url_Standard"] == "" && !$_FILES['file_Standard']['tmp_name']))
586  {
587  ilUtil::sendFailure($lng->txt("mcst_input_either_file_or_url"));
588  }
589  $this->populateFormFromPost();
590  }
591  else
592  {
593  // create dummy object in db (we need an id)
594  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
595  $mob = new ilObjMediaObject();
596  $mob->create();
597 
598  //handle standard purpose
599  $file = $this->createMediaItemForPurpose($mob, "Standard");
600 
601  // set title and description
602  // set title to basename of file if left empty
603  $title = $this->form_gui->getInput("title") != "" ? $this->form_gui->getInput("title") : basename($file);
604  $description = $this->form_gui->getInput("description");
605  $mob->setTitle($title);
606  $mob->setDescription($description);
607 
608  // save preview pic
609  $prevpic = $this->form_gui->getInput("preview_pic");
610  if ($prevpic["size"] > 0)
611  {
612  $mob->uploadVideoPreviewPic($prevpic);
613  }
614 
615  // determine duration for standard purpose
616  $duration = $this->getDuration($file);
617 
618  // handle other purposes
619  foreach ($this->additionalPurposes as $purpose)
620  {
621  // check if some purpose has been uploaded
622  $file_gui = $this->form_gui->getInput("file_".$purpose);
623  $url_gui = $this->form_gui->getInput("url_".$purpose);
624  if ($url_gui || $file_gui["size"] > 0)
625  {
626  $this->createMediaItemForPurpose ($mob, $purpose);
627  }
628  }
629 
630  $mob->update();
631 
632  if ($prevpic["size"] == 0)
633  {
634  // re-read media object
635  $mob = new ilObjMediaObject($mob->getId());
636  $mob->generatePreviewPic(320, 240);
637  }
638 
639  //
640  // @todo: save usage
641  //
642 
643  $news_set = new ilSetting("news");
644  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
645 
646  // create new media cast item
647  include_once("./Services/News/classes/class.ilNewsItem.php");
648  $mc_item = new ilNewsItem();
649  $mc_item->setMobId($mob->getId());
650  $mc_item->setContentType(NEWS_AUDIO);
651  $mc_item->setContextObjId($this->object->getId());
652  $mc_item->setContextObjType($this->object->getType());
653  $mc_item->setUserId($ilUser->getId());
654  $mc_item->setPlaytime($duration);
655  $mc_item->setTitle($title);
656  $mc_item->setContent($description);
657  $mc_item->setLimitation(false);
658  if ($enable_internal_rss)
659  {
660  $mc_item->setVisibility($this->form_gui->getInput("visibility"));
661  }
662  else
663  {
664  $mc_item->setVisibility("users");
665  }
666  $mc_item->create();
667 
668  $ilCtrl->redirect($this, "listItems");
669  }
670  }
671 
678  private function getDuration($file)
679  {
680  $duration = isset($this->form_gui)
681  ? $this->form_gui->getInput("duration")
682  : array("hh"=>0, "mm"=>0, "ss"=>0);
683  if ($duration["hh"] == 0 && $duration["mm"] == 0 && $duration["ss"] == 0 && is_file($file))
684  {
685  include_once("./Services/MediaObjects/classes/class.ilMediaAnalyzer.php");
686  $ana = new ilMediaAnalyzer();
687  $ana->setFile($file);
688  $ana->analyzeFile();
689  $dur = $ana->getPlaytimeString();
690  $dur = explode(":", $dur);
691  $duration["mm"] = $dur[0];
692  $duration["ss"] = $dur[1];
693  }
694  $duration = str_pad($duration["hh"], 2 , "0", STR_PAD_LEFT).":".
695  str_pad($duration["mm"], 2 , "0", STR_PAD_LEFT).":".
696  str_pad($duration["ss"], 2 , "0", STR_PAD_LEFT);
697  return $duration;
698  }
699 
706  private function createMediaItemForPurpose ($mob, $purpose)
707  {
708  $mediaItem = new ilMediaItem();
709  $mob->addMediaItem($mediaItem);
710  $mediaItem->setPurpose($purpose);
711  return $this->updateMediaItem($mob, $mediaItem);
712  }
713 
721  private function updateMediaItem ($mob, & $mediaItem)
722  {
723  $purpose = $mediaItem->getPurpose();
724  $url_gui = $this->form_gui->getInput ("url_".$purpose);
725  $file_gui = $this->form_gui->getInput ("file_".$purpose);
726  if ($url_gui)
727  {
728  // http
729  $file = $this->form_gui->getInput ("url_".$purpose);
730  $title = basename ($file);
731  $location = $this->form_gui->getInput ("url_".$purpose);
732  $locationType = "Reference";
733  } elseif ($file_gui["size"] > 0){
734  // lokal
735  // determine and create mob directory, move uploaded file to directory
736  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
737  if (!is_dir($mob_dir))
738  $mob->createDirectory();
739 
740  $file_name = ilUtil::getASCIIFilename($_FILES['file_'.$purpose]['name']);
741  $file_name = str_replace(" ", "_", $file_name);
742 
743  $file = $mob_dir."/".$file_name;
744  $title = $file_name;
745  $locationType = "LocalFile";
746  $location = $title;
747  ilUtil::moveUploadedFile($_FILES['file_'.$purpose]['tmp_name'], $file_name, $file);
748  ilUtil::renameExecutables($mob_dir);
749 
750  }
751 
752  // check if not automatic mimetype detection
753  if ($_POST["mimetype_".$purpose] != "")
754  {
755  $mediaItem->setFormat($_POST["mimetype_".$purpose]);
756  }
757  elseif ($mediaItem->getLocation () != "")
758  {
759  $format = ilObjMediaObject::getMimeType($mediaItem->getLocation(), ($locationType == "Reference"));
760  $mediaItem->setFormat($format);
761  }
762 
763  if (isset($file))
764  {
765  // get mime type, if not already set!
766  if (!isset($format))
767  {
768  $format = ilObjMediaObject::getMimeType($file, ($locationType == "Reference"));
769  }
770 
771  // set real meta and object data
772  $mediaItem->setFormat($format);
773  $mediaItem->setLocation($location);
774  $mediaItem->setLocationType($locationType);
775  $mediaItem->setHAlign("Left");
776  $mediaItem->setHeight(self::isAudio($format)?0:180);
777  }
778 
779  if ($purpose == "Standard")
780  {
781  if (isset($title))
782  $mob->setTitle ($title);
783  if (isset($format))
784  $mob->setDescription($format);
785  }
786 
787  return $file;
788  }
789 
794  {
795  global $tpl, $lng, $ilCtrl, $ilUser, $log;
796 
797  $this->checkPermission("write");
798 
799  $this->initAddCastItemForm("edit");
800 
801  if ($this->form_gui->checkInput())
802  {
803  // create new media cast item
804  include_once("./Services/News/classes/class.ilNewsItem.php");
805  $mc_item = new ilNewsItem($_GET["item_id"]);
806  $mob_id = $mc_item->getMobId();
807 
808  // create dummy object in db (we need an id)
809  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
810  $mob = new ilObjMediaObject($mob_id);
811 
812 
813  foreach (ilObjMediaCast::$purposes as $purpose)
814  {
815  if ($this->form_gui->getInput("delete_".$purpose))
816  {
817  $mob->removeMediaItem($purpose);
818  $log->write ("Mcst: deleting purpose $purpose");
819  continue;
820  }
821  $media_item = $mob->getMediaItem($purpose);
822  $url_gui = $this->form_gui->getInput("url_".$purpose);
823  $file_gui = $this->form_gui->getInput("file_".$purpose);
824 
825  if ($media_item == null)
826  {
827  if ($purpose != "Standard" &&
828  ($url_gui || $file_gui["size"]>0))
829  {
830  // check if we added an additional purpose when updating
831  // either by url or by file
832  $file = $this->createMediaItemForPurpose($mob, $purpose);
833  }
834  } else
835  {
836  $file = $this->updateMediaItem($mob, $media_item);
837  }
838 
839  if ($purpose == "Standard")
840  {
841  $duration = $this->getDuration($file);
842  $title = $this->form_gui->getInput("title") != "" ? $this->form_gui->getInput("title") : basename($file);
843  $description = $this->form_gui->getInput("description");
844 
845  $mob->setTitle($title);
846  $mob->setDescription($description);
847 
848  $prevpic = $this->form_gui->getInput("preview_pic");
849  if ($prevpic["size"] > 0)
850  {
851  $mob->uploadVideoPreviewPic($prevpic);
852  }
853  else
854  {
855  $prevpici = $this->form_gui->getItemByPostVar("preview_pic");
856  if ($prevpici->getDeletionFlag())
857  {
858  $mob->removeAdditionalFile($mob->getVideoPreviewPic(true));
859  }
860  }
861  }
862  }
863 
864  // set real meta and object data
865  $mob->update();
866 
867  //
868  // @todo: save usage
869  //
870 
871  $news_set = new ilSetting("news");
872  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
873 
874  $mc_item->setUserId($ilUser->getId());
875  if (isset($duration))
876  {
877  $mc_item->setPlaytime($duration);
878  }
879  $mc_item->setTitle($title);
880  $mc_item->setContent($description);
881  if ($enable_internal_rss)
882  {
883  $mc_item->setVisibility($this->form_gui->getInput("visibility"));
884  }
885  $mc_item->update();
886 
887  $ilCtrl->redirect($this, "listItems");
888  }
889  else
890  {
891  $this->populateFormFromPost();
892  }
893  }
894 
899  {
900  global $ilCtrl, $lng, $tpl, $ilTabs;
901 
902  $this->checkPermission("write");
903  $ilTabs->activateTab("edit_content");
904 
905  if (!is_array($_POST["item_id"]))
906  {
907  $this->listItemsObject();
908  return;
909  }
910 
911  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
912  $c_gui = new ilConfirmationGUI();
913 
914  // set confirm/cancel commands
915  $c_gui->setFormAction($ilCtrl->getFormAction($this, "deleteItems"));
916  $c_gui->setHeaderText($lng->txt("info_delete_sure"));
917  $c_gui->setCancel($lng->txt("cancel"), "listItems");
918  $c_gui->setConfirm($lng->txt("confirm"), "deleteItems");
919 
920  // add items to delete
921  include_once("./Services/News/classes/class.ilNewsItem.php");
922  foreach($_POST["item_id"] as $item_id)
923  {
924  $item = new ilNewsItem($item_id);
925  $c_gui->addItem("item_id[]", $item_id, $item->getTitle(),
926  ilUtil::getImagePath("icon_mcst.svg"));
927  }
928 
929  $tpl->setContent($c_gui->getHTML());
930  }
931 
935  function deleteItemsObject()
936  {
937  global $ilCtrl;
938 
939  $this->checkPermission("write");
940 
941  // delete all selected news items
942  foreach($_POST["item_id"] as $item_id)
943  {
944  $mc_item = new ilNewsItem($item_id);
945  $mc_item->delete();
946  }
947 
948  $ilCtrl->redirect($this, "listItems");
949  }
950 
955  {
956  global $ilCtrl;
957  $this->checkPermission("read");
958 
959  $news_item = new ilNewsItem($_GET["item_id"]);
960  if (!$news_item->deliverMobFile($_GET["purpose"], (int) $_GET["presentation"]))
961  {
962  $ilCtrl->redirect($this, "listItems");
963  }
964  else
965  {
966  global $ilUser;
967  $this->object->handleLPUpdate($ilUser->getId(), $news_item->getMobId());
968  }
969  exit;
970  }
971 
976  {
977  global $ilCtrl, $lng;
978 
979  $mc_item = new ilNewsItem($_GET["item_id"]);
980  $mob = $mc_item->getMobId();
981  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
982  $mob = new ilObjMediaObject($mob);
983  $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
984  $m_item = $mob->getMediaItem("Standard");
985  $file = $mob_dir."/".$m_item->getLocation();
986  $duration = $this->getDuration($file);
987  if ($duration != "00:00:00")
988  {
989  $mc_item->setPlaytime($duration);
990  $mc_item->update();
991  ilUtil::sendSuccess($lng->txt("mcst_set_playtime"), true);
992  }
993  else
994  {
995  ilUtil::sendFailure($lng->txt("mcst_unable_to_determin_playtime"), true);
996  }
997 
998  $ilCtrl->redirect($this, "listItems");
999  }
1000 
1006  function infoScreenObject()
1007  {
1008  $this->checkPermission("visible");
1009  $this->ctrl->setCmd("showSummary");
1010  $this->ctrl->setCmdClass("ilinfoscreengui");
1011  $this->infoScreen();
1012  }
1013 
1017  function infoScreen()
1018  {
1019  global $ilAccess, $ilUser, $ilTabs;
1020 
1021  $ilTabs->activateTab("id_info");
1022 
1023  if (!$ilAccess->checkAccess("visible", "", $this->object->getRefId()))
1024  {
1025  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
1026  }
1027 
1028  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1029  $info = new ilInfoScreenGUI($this);
1030 
1031  $info->enablePrivateNotes();
1032 
1033  /*
1034  $info->enableNews();
1035  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
1036  {
1037  //$info->enableNewsEditing();
1038  $info->setBlockProperty("news", "settings", true);
1039  }*/
1040 
1041  // general information
1042  $this->lng->loadLanguageModule("meta");
1043  $this->lng->loadLanguageModule("mcst");
1044  $med_items = $this->object->getItemsArray();
1045  $info->addSection($this->lng->txt("meta_general"));
1046  $info->addProperty($this->lng->txt("mcst_nr_items"),
1047  (int) count($med_items));
1048 
1049  if (count($med_items) > 0)
1050  {
1051  $cur = current($med_items);
1052  $last = ilDatePresentation::formatDate(new ilDateTime($cur["creation_date"], IL_CAL_DATETIME));
1053  }
1054  else
1055  {
1056  $last = "-";
1057  }
1058 
1059  $info->addProperty($this->lng->txt("mcst_last_submission"), $last);
1060 
1061  // forward the command
1062  $this->ctrl->forwardCommand($info);
1063  }
1064 
1069  function setTabs()
1070  {
1071  global $ilAccess, $ilTabs, $lng, $ilHelp;
1072 
1073  $ilHelp->setScreenIdComponent("mcst");
1074 
1075  // list items
1076  if ($ilAccess->checkAccess('read', "", $this->object->getRefId()))
1077  {
1078  $ilTabs->addTab("content",
1079  $lng->txt("content"),
1080  $this->ctrl->getLinkTarget($this, "showContent"));
1081  }
1082 
1083  // info screen
1084  if ($ilAccess->checkAccess('visible', "", $this->object->getRefId()))
1085  {
1086  $ilTabs->addTab("id_info",
1087  $lng->txt("info_short"),
1088  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"));
1089  }
1090 
1091  // settings
1092  if ($ilAccess->checkAccess('write', "", $this->object->getRefId()))
1093  {
1094  $ilTabs->addTab("id_settings",
1095  $lng->txt("settings"),
1096  $this->ctrl->getLinkTarget($this, "editSettings"));
1097  }
1098 
1099  require_once 'Services/Tracking/classes/class.ilLearningProgressAccess.php';
1100  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()))
1101  {
1102  $ilTabs->addTab(
1103  'learning_progress',
1104  $lng->txt('learning_progress'),
1105  $this->ctrl->getLinkTargetByClass(array(__CLASS__, 'illearningprogressgui'),'')
1106  );
1107  }
1108 
1109  // export
1110  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
1111  {
1112  $ilTabs->addTab("export",
1113  $lng->txt("export"),
1114  $this->ctrl->getLinkTargetByClass("ilexportgui", ""));
1115  }
1116 
1117  // edit permissions
1118  if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId()))
1119  {
1120  $ilTabs->addTab("id_permissions",
1121  $lng->txt("perm_settings"),
1122  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"));
1123  }
1124  }
1125 
1132  function addContentSubTabs($a_active = "content")
1133  {
1134  global $ilTabs, $ilAccess, $lng;
1135 
1136  $ilTabs->addSubTab("content",
1137  $lng->txt("view"),
1138  $this->ctrl->getLinkTarget($this, "showContent"));
1139 
1140  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
1141  {
1142  $ilTabs->addSubTab("manage",
1143  $lng->txt("mcst_manage"),
1144  $this->ctrl->getLinkTarget($this, "listItems"));
1145 
1146  if ($this->object->getOrder() == ilObjMediaCast::ORDER_MANUAL)
1147  {
1148  $ilTabs->addSubTab("sorting",
1149  $lng->txt("mcst_ordering"),
1150  $this->ctrl->getLinkTarget($this, "editOrder"));
1151  }
1152  }
1153 
1154  $ilTabs->activateSubTab($a_active);
1155  $ilTabs->activateTab("content");
1156  }
1157 
1158 
1163  {
1164  global $tpl, $ilTabs;
1165 
1166  $this->checkPermission("write");
1167  $ilTabs->activateTab("id_settings");
1168 
1169  $this->initSettingsForm();
1170  $tpl->setContent($this->form_gui->getHtml());
1171  }
1172 
1176  function initSettingsForm()
1177  {
1178  global $tpl, $lng, $ilCtrl;
1179 
1180  $lng->loadLanguageModule("mcst");
1181 
1182  require_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1183  $this->form_gui = new ilPropertyFormGUI();
1184  $this->form_gui->setTitle($lng->txt("mcst_settings"));
1185 
1186  // Title
1187  $tit = new ilTextInputGUI($lng->txt("title"), "title");
1188  $tit->setValue($this->object->getTitle());
1189  $tit->setRequired(true);
1190  $this->form_gui->addItem($tit);
1191 
1192  // description
1193  $des = new ilTextAreaInputGUI($lng->txt("description"), "description");
1194  $des->setValue($this->object->getLongDescription());
1195  $this->form_gui->addItem($des);
1196 
1197  $sh = new ilFormSectionHeaderGUI();
1198  $sh->setTitle($lng->txt("rep_activation_availability"));
1199  $this->form_gui->addItem($sh);
1200 
1201  // Online
1202  $online = new ilCheckboxInputGUI($lng->txt("online"), "online");
1203  $online->setChecked($this->object->getOnline());
1204  $this->form_gui->addItem($online);
1205 
1206  // presentation
1207  $sh = new ilFormSectionHeaderGUI();
1208  $sh->setTitle($lng->txt("obj_presentation"));
1209  $this->form_gui->addItem($sh);
1210 
1211  // Sorting
1212  $sort = new ilRadioGroupInputGUI($lng->txt("mcst_ordering"), "order");
1213  $sort->addOption(new ilRadioOption($lng->txt("mcst_ordering_title"),
1215  $sort->addOption(new ilRadioOption($lng->txt("mcst_ordering_creation_date_asc"),
1217  $sort->addOption(new ilRadioOption($lng->txt("mcst_ordering_creation_date_desc"),
1219  $sort->addOption(new ilRadioOption($lng->txt("mcst_ordering_manual"),
1221  $sort->setValue($this->object->getOrder());
1222  $this->form_gui->addItem($sort);
1223 
1224  // view mode
1225  $options = array(
1226  ilObjMediaCast::VIEW_LIST => $lng->txt("mcst_list"),
1227  ilObjMediaCast::VIEW_GALLERY => $lng->txt("mcst_gallery")
1228  );
1229  $si = new ilRadioGroupInputGUI($this->lng->txt("mcst_viewmode"), "viewmode");
1230  $si->addOption(new ilRadioOption($lng->txt("mcst_list"),
1232  $si->addOption(new ilRadioOption($lng->txt("mcst_gallery"),
1234 
1235 // $si->setOptions($options);
1236  $si->setValue($this->object->getViewMode());
1237  $this->form_gui->addItem($si);
1238 
1239 
1240  // Downloadable
1241  $downloadable = new ilCheckboxInputGUI($lng->txt("mcst_downloadable"), "downloadable");
1242  $downloadable->setChecked($this->object->getDownloadable());
1243  $downloadable->setInfo($lng->txt("mcst_downloadable_info"));
1244  $this->form_gui->addItem($downloadable);
1245 
1246  $news_set = new ilSetting("news");
1247  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
1248 
1249  //Default Visibility
1250  if ($enable_internal_rss)
1251  {
1252  // webfeed
1253  $sh = new ilFormSectionHeaderGUI();
1254  $sh->setTitle($lng->txt("mcst_webfeed"));
1255  $this->form_gui->addItem($sh);
1256 
1257  $radio_group = new ilRadioGroupInputGUI($lng->txt("news_default_visibility"), "defaultaccess");
1258  $radio_option = new ilRadioOption($lng->txt("news_visibility_users"), "0");
1259  $radio_option->setInfo($lng->txt("news_news_item_def_visibility_users_info"));
1260  $radio_group->addOption($radio_option);
1261  $radio_option = new ilRadioOption($lng->txt("news_visibility_public"), "1");
1262  $radio_option->setInfo($lng->txt("news_news_item_def_visibility_public_info"));
1263  $radio_group->addOption($radio_option);
1264  $radio_group->setRequired(false);
1265  $radio_group->setValue($this->object->getDefaultAccess());
1266  #$ch->addSubItem($radio_group);
1267  $this->form_gui->addItem($radio_group);
1268 
1269  //Extra Feed
1270  include_once("./Services/Block/classes/class.ilBlockSetting.php");
1271  $public_feed = ilBlockSetting::_lookup("news", "public_feed", 0, $this->object->getId());
1272  $ch = new ilCheckboxInputGUI($lng->txt("news_public_feed"), "extra_feed");
1273  $ch->setInfo($lng->txt("news_public_feed_info"));
1274  $ch->setChecked($public_feed);
1275  $this->form_gui->addItem($ch);
1276 
1277  // keep minimal x number of items
1278  $ni = new ilNumberInputGUI($this->lng->txt("news_keep_minimal_x_items"), "keep_rss_min");
1279  $ni->setMaxValue(100);
1280  $ni->setMinValue(0);
1281  $ni->setMaxLength(3);
1282  $ni->setSize(3);
1283  $ni->setInfo($this->lng->txt("news_keep_minimal_x_items_info")." (".
1284  ilNewsItem::_lookupRSSPeriod()." ".(ilNewsItem::_lookupRSSPeriod() == 1 ? $lng->txt("day") : $lng->txt("days")).")");
1285  $ni->setValue((int) ilBlockSetting::_lookup("news", "keep_rss_min", 0, $this->object->getId()));
1286  $ch->addSubItem($ni);
1287 
1288  // Include Files in Pubic Items
1289  $incl_files = new ilCheckboxInputGUI($lng->txt("mcst_incl_files_in_rss"), "public_files");
1290  $incl_files->setChecked($this->object->getPublicFiles());
1291  $incl_files->setInfo($lng->txt("mcst_incl_files_in_rss_info"));
1292  #$ch->addSubItem($incl_files);
1293  $this->form_gui->addItem($incl_files);
1294  }
1295 
1296  // Form action and save button
1297  $this->form_gui->addCommandButton("saveSettings", $lng->txt("save"));
1298  $this->form_gui->setFormAction($ilCtrl->getFormAction($this, "saveSettings"));
1299  }
1300 
1305  {
1306  global $ilCtrl, $ilTabs;
1307 
1308  $this->checkPermission("write");
1309  $ilTabs->activateTab("id_settings");
1310 
1311  $this->initSettingsForm();
1312  if ($this->form_gui->checkInput())
1313  {
1314  $news_set = new ilSetting("news");
1315  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
1316 
1317  $this->object->setTitle($this->form_gui->getInput("title"));
1318  $this->object->setDescription($this->form_gui->getInput("description"));
1319  $this->object->setOnline($this->form_gui->getInput("online"));
1320  $this->object->setDownloadable($this->form_gui->getInput("downloadable"));
1321  $this->object->setOrder($this->form_gui->getInput("order"));
1322  $this->object->setViewMode($this->form_gui->getInput("viewmode"));
1323 
1324  if ($enable_internal_rss)
1325  {
1326  $this->object->setPublicFiles($this->form_gui->getInput("public_files"));
1327  $this->object->setDefaultAccess($this->form_gui->getInput("defaultaccess"));
1328  }
1329  $this->object->update();
1330 
1331  if ($enable_internal_rss)
1332  {
1333  include_once("./Services/Block/classes/class.ilBlockSetting.php");
1334  ilBlockSetting::_write("news", "public_feed",
1335  $this->form_gui->getInput("extra_feed"),
1336  0, $this->object->getId());
1337 
1338  ilBlockSetting::_write("news", "keep_rss_min",
1339  $this->form_gui->getInput("keep_rss_min"),
1340  0, $this->object->getId());
1341  }
1342 
1343  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
1344  $ilCtrl->redirect($this, "editSettings");
1345  }
1346  else
1347  {
1348  $this->form_gui->setValuesByPost();
1349  $this->tpl->setContent($this->form_gui->getHTML());
1350  }
1351  }
1352 
1353  // add media cast to locator
1354  function addLocatorItems()
1355  {
1356  global $ilLocator;
1357 
1358  if (is_object($this->object))
1359  {
1360  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "listItems"), "", $_GET["ref_id"]);
1361  }
1362  }
1363 
1364  public static function _goto($a_target)
1365  {
1366  global $ilAccess, $ilErr, $lng;
1367 
1368  if ($ilAccess->checkAccess("read", "", $a_target))
1369  {
1370  $_GET["cmd"] = "showContent";
1371  $_GET["ref_id"] = $a_target;
1372  $_GET["baseClass"] = "ilmediacasthandlergui";
1373  $_GET["cmdClass"] = "ilobjmediacastgui";
1374  include("ilias.php");
1375  exit;
1376  }
1377  else if ($ilAccess->checkAccess("visible", "", $a_target))
1378  {
1379  ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreen");
1380  }
1381  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
1382  {
1383  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
1386  }
1387 
1388  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1389 
1390  }
1391 
1398  protected static function isAudio($extension) {
1399  return strpos($extension,"audio") !== false;
1400  }
1401 
1408  protected function getMediaItem ($id) {
1409  include_once("./Services/News/classes/class.ilNewsItem.php");
1410  $this->mcst_item = new ilNewsItem($id);
1411  // create dummy object in db (we need an id)
1412  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
1413  $mob = new ilObjMediaObject($this->mcst_item->getMobId());
1414  return $mob->getMediaItem("Standard");
1415  }
1416 
1423  protected function getMediaItems ($id) {
1424  include_once("./Services/News/classes/class.ilNewsItem.php");
1425  $this->mcst_item = new ilNewsItem($id);
1426  // create dummy object in db (we need an id)
1427  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
1428  $mob = new ilObjMediaObject($this->mcst_item->getMobId());
1429  return $mob->getMediaItems();
1430  }
1431 
1432  private function populateFormFromPost()
1433  {
1434  global $tpl;
1435  //issue: we have to display the current settings
1436  // problem: POST does not contain values of disabled textfields
1437  // solution: use hidden field and label to display-> here we need to synchronize the labels
1438  // with the values from the hidden fields.
1439  foreach (ilObjMediaCast::$purposes as $purpose)
1440  {
1441  if ($_POST["value_".$purpose])
1442  {
1443  $_POST["label_value_".$purpose] = $_POST["value_".$purpose];
1444  }
1445  }
1446 
1447  $this->form_gui->setValuesByPost();
1448  $tpl->setContent($this->form_gui->getHTML());
1449  }
1450 
1451  protected function editOrderObject()
1452  {
1453  global $ilTabs, $lng, $tpl;
1454 
1455  $this->checkPermission("write");
1456  $ilTabs->activateTab("edit_content");
1457 
1458  $this->addContentSubTabs("sorting");
1459 
1460  // sort by order setting
1461  switch($this->object->getOrder())
1462  {
1466  return $this->listItemsObject();
1467 
1469  // sub-tabs
1470  break;
1471  }
1472 
1473  include_once("./Modules/MediaCast/classes/class.ilMediaCastTableGUI.php");
1474  $table_gui = new ilMediaCastTableGUI($this, "editOrder", true);
1475 
1476  $table_gui->setTitle($lng->txt("mcst_media_cast"));
1477  $table_gui->setData($this->object->getSortedItemsArray());
1478 
1479  $table_gui->addCommandButton("saveOrder", $lng->txt("mcst_save_order"));
1480 
1481  $tpl->setContent($table_gui->getHTML());
1482  }
1483 
1484  function saveOrderObject()
1485  {
1486  global $lng;
1487 
1488  asort($_POST["item_id"]);
1489 
1490  $items = array();
1491  foreach(array_keys($_POST["item_id"]) as $id)
1492  {
1493  $items[] = $id;
1494  }
1495  $this->object->saveOrder($items);
1496 
1497  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
1498  $this->ctrl->redirect($this, "editOrder");
1499  }
1500 
1504 
1512  {
1513  global $ilUser;
1514 
1515  // need read events for parent for LP statistics
1516  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
1517  ilChangeEvent::_recordReadEvent("mcst", $this->object->getRefId(),
1518  $this->object->getId(), $ilUser->getId());
1519 
1520  if ($this->object->getViewMode() == ilObjMediaCast::VIEW_GALLERY)
1521  {
1522  $this->showGallery();
1523  }
1524  else
1525  {
1526  $this->listItemsObject(true);
1527  }
1528  global $tpl;
1529  $tpl->setPermanentLink($this->object->getType(), $this->object->getRefId());
1530  }
1531 
1532  function showGallery()
1533  {
1534  global $tpl, $ilTabs, $ilCtrl;
1535 
1536  $tpl->addJavascript("./Modules/MediaCast/js/MediaCast.js");
1537 
1538  $ilTabs->activateTab("content");
1539 
1540  $this->addContentSubTabs("content");
1541 
1542  $ctpl = new ilTemplate("tpl.mcst_content.html", true, true, "Modules/MediaCast");
1543 
1544  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1545  require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
1546  foreach ($this->object->getSortedItemsArray() as $item)
1547  {
1548  $mob = new ilObjMediaObject($item["mob_id"]);
1549  $med = $mob->getMediaItem("Standard");
1550 
1551  $ctpl->setCurrentBlock("item");
1552  $ctpl->setVariable("TITLE", $item["title"]);
1553  $ctpl->setVariable("TIME", $item["playtime"]);
1554  $ctpl->setVariable("ID", $item["id"]);
1555 
1556  if ($mob->getVideoPreviewPic() != "")
1557  {
1558  $ctpl->setVariable("PREVIEW_PIC",
1559  ilUtil::img(ilWACSignedPath::signFile($mob->getVideoPreviewPic()), $item["title"], 320, 240));
1560  }
1561  else
1562  {
1563  $ctpl->setVariable("PREVIEW_PIC",
1564  ilUtil::img(ilUtil::getImagePath("mcst_preview.svg"), $item["title"], 320, 240));
1565  }
1566 
1567  // player
1568  if (is_object($med))
1569  {
1570  include_once("./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php");
1571 
1572  // the news id will be used as player id, see also ilMediaCastTableGUI
1573  $mpl = new ilMediaPlayerGUI($item["id"],
1574  $ilCtrl->getLinkTarget($this, "handlePlayerEvent", "", true, false));
1575 
1576  if (strcasecmp("Reference", $med->getLocationType()) == 0)
1577  {
1578  ilWACSignedPath::signFolderOfStartFile($med->getLocation());
1579  $mpl->setFile($med->getLocation());
1580  }
1581  else
1582  {
1583  $path_to_file = ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation();
1585  $mpl->setFile($path_to_file);
1586  }
1587  $mpl->setMimeType ($med->getFormat());
1588  //$mpl->setDisplayHeight($med->getHeight());
1589  $mpl->setDisplayHeight("480");
1590  $mpl->setDisplayWidth("640");
1591  $mpl->setVideoPreviewPic(ilWACSignedPath::signFile($mob->getVideoPreviewPic()));
1592  $mpl->setTitle($item["title"]);
1593  $mpl->setDescription($item["content"]);
1594  $mpl->setForceAudioPreview(true);
1595  if ($this->object->getDownloadable())
1596  {
1597  $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", $item["id"]);
1598  $ilCtrl->setParameterByClass("ilobjmediacastgui", "purpose", "Standard");
1599  $mpl->setDownloadLink($ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "downloadItem"));
1600  }
1601  $med_alt = $mob->getMediaItem("VideoAlternative");
1602  if (is_object($med_alt))
1603  {
1604  $mpl->setAlternativeVideoFile(ilWACSignedPath::signFile(ilObjMediaObject::_getURL($mob->getId())."/".
1605  $med_alt->getLocation()));
1606  $mpl->setAlternativeVideoMimeType($med_alt->getFormat());
1607  }
1608 
1609  $ctpl->setVariable("PLAYER", $mpl->getPreviewHtml());
1610  }
1611 
1612 
1613  $ctpl->parseCurrentBlock();
1614  }
1615 
1616  $feed_icon_html = $this->getFeedIconsHTML();
1617 
1618  if ($feed_icon_html != "")
1619  {
1620  $feed_icon_html = '<p>'.$feed_icon_html.'</p>';
1621  }
1622 
1623  $tpl->setContent($feed_icon_html.$ctpl->get());
1624  }
1625 
1633  {
1634  global $ilCtrl;
1635 
1636  $this->checkPermission("write");
1637 
1638  $this->mcst_item = new ilNewsItem($_GET["item_id"]);
1639  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
1640  $mob = new ilObjMediaObject($this->mcst_item->getMobId());
1641 
1642  $target_purpose = ilUtil::stripSlashes($_POST["target_purpose"]);
1643  $target_format = ilUtil::stripSlashes($_POST["target_format"]);
1644 
1645  try
1646  {
1647  include_once("./Services/MediaObjects/classes/class.ilFFmpeg.php");
1648  $med = $mob->getMediaItem("Standard");
1649  $mob_file = ilObjMediaObject::_getDirectory($mob->getId())."/".$med->getLocation();
1650  $new_file = ilFFmpeg::convert($mob_file, $target_format);
1652  $pi = pathinfo($new_file);
1653  $med = $mob->getMediaItem($target_purpose);
1654  if (!is_object($med))
1655  {
1656  $med = new ilMediaItem();
1657  $med->setMobId($mob->getId());
1658  $mob->addMediaItem($med);
1659  $mob->update();
1660  $med->setPurpose($target_purpose);
1661  }
1662  $med->setFormat($target_format);
1663  $med->setLocation($pi["basename"]);
1664  $med->setLocationType("LocalFile");
1665  $med->update();
1666 
1667  $add = (is_array($ret) && count($ret) > 0)
1668  ? "<br />".implode($ret, "<br />")
1669  : "";
1670 
1671  ilUtil::sendInfo($this->lng->txt("mcst_converted_file").$add, true);
1672  }
1673  catch (ilException $e)
1674  {
1676  $add = (is_array($ret) && count($ret) > 0)
1677  ? "<br />".implode($ret, "<br />")
1678  : "";
1679  ilUtil::sendFailure($e->getMessage().$add, true);
1680  }
1681 
1682 
1683  $ilCtrl->redirect($this, "editCastItem");
1684  }
1685 
1693  {
1694  global $ilCtrl;
1695 
1696  $this->checkPermission("write");
1697 
1698  $this->mcst_item = new ilNewsItem($_GET["item_id"]);
1699  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
1700  $mob = new ilObjMediaObject($this->mcst_item->getMobId());
1701 
1702  try
1703  {
1704  $sec = (int) $_POST["sec"];
1705  if ($sec < 0)
1706  {
1707  $sec = 0;
1708  }
1709  if ($mob->getVideoPreviewPic() != "")
1710  {
1711  $mob->removeAdditionalFile($mob->getVideoPreviewPic(true));
1712  }
1713  include_once("./Services/MediaObjects/classes/class.ilFFmpeg.php");
1714  $med = $mob->getMediaItem("Standard");
1715  $mob_file = ilObjMediaObject::_getDirectory($mob->getId())."/".$med->getLocation();
1716  $new_file = ilFFmpeg::extractImage($mob_file, "mob_vpreview.png",
1717  ilObjMediaObject::_getDirectory($mob->getId()), $sec);
1718 
1719  if ($new_file != "")
1720  {
1721  ilUtil::sendInfo($this->lng->txt("mcst_image_extracted"), true);
1722  }
1723  else
1724  {
1725  ilUtil::sendFailure($this->lng->txt("mcst_no_extraction_possible"), true);
1726  }
1727  }
1728  catch (ilException $e)
1729  {
1730  if (DEVMODE == 1)
1731  {
1733  $add = (is_array($ret) && count($ret) > 0)
1734  ? "<br />".implode($ret, "<br />")
1735  : "";
1736  }
1737  ilUtil::sendFailure($e->getMessage().$add, true);
1738  }
1739 
1740 
1741  $ilCtrl->redirect($this, "editCastItem");
1742  }
1743 
1751  {
1752  if ($_GET["event"] == "play")
1753  {
1754  $player = explode("_", $_GET["player"]);
1755  $news_id = (int) $player[1];
1756  include_once("./Services/News/classes/class.ilNewsItem.php");
1757  $item = new ilNewsItem($news_id);
1758  $item->increasePlayCounter();
1759 
1760  $mob_id = $item->getMobId();
1761  if($mob_id)
1762  {
1763  global $ilUser;
1764  $this->object->handleLPUpdate($ilUser->getId(), $mob_id);
1765  }
1766  }
1767  exit;
1768  }
1769 
1770 
1771 }
1772 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
This class represents a duration (typical hh:mm:ss) property in a property form.
global $ilErr
Definition: raiseError.php:16
This class represents an option in a radio group.
ILIAS Setting Class.
static getLastReturnValues()
Get last return values.
getVideoPreviewPic($a_filename_only=false)
Get video preview pic.
Base class for ILIAS Exception handling.
Class ilInfoScreenGUI.
static _write($a_type, $a_setting, $a_value, $a_user=0, $a_block_id=0)
Write setting to database.
& getMediaItem($a_purpose)
get item for media purpose
static _lookupRSSPeriod()
getDuration($file)
get duration from form or from file analyzer
const IL_CAL_DATETIME
This class represents a selection list property in a property form.
This class represents a property form user interface.
GUI class for the workflow of copying objects.
static convert($a_file, $a_target_mime, $a_target_dir="", $a_target_filename="")
Convert file to target mime type.
initSettingsForm()
Init Settings Form.
$_GET["client_id"]
static signFolderOfStartFile($start_file_path, ilWACCookieInterface $ilWACCookieInterface=null)
$location
Definition: buildRTE.php:44
This class represents a section header in a property form.
This class represents a file property in a property form.
Class ilObject Basic functions for all objects.
$cmd
Definition: sahs_server.php:35
setPostVar($a_postvar)
Set Post Variable.
setValue($a_value)
Set Value.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
This class represents a checkbox property in a property form.
static _lookupTitle($a_id)
lookup object title
$url
Definition: shib_logout.php:72
fillCloneTemplate($a_tpl_varname, $a_type)
Fill object clone template This method can be called from any object GUI class that wants to offer ob...
setInfo($a_info)
Set Info.
static extractImage($a_file, $a_target_filename, $a_target_dir="", $a_sec=1)
Extract image from video file.
static _getURL($a_mob_id)
get directory for files of media object (static)
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
updateMediaItem($mob, & $mediaItem)
update media item from form
static _getDirectory($a_mob_id)
get directory for files of media object (static)
getMediaItem($id)
get MediaItem for id and updates local variable mcst_item
global $ilCtrl
Definition: ilias.php:18
setInfo($a_info)
Set Information Text.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$section
Definition: Utf8Test.php:83
getFeedIconsHTML()
Get feed icons HTML.
setChecked($a_checked)
Set Checked.
Export User Interface Class.
static checkAccess($a_ref_id, $a_allow_only_read=true)
check access to learning progress
initImportForm($a_new_type)
Init object import form.
setPattern($pattern)
set pattern
This class represents a hidden form property in a property form.
$info
Definition: example_052.php:80
deleteItemsObject()
Delete news items.
prepareOutput($a_show_subobjects=true)
prepare output
initAddCastItemForm($a_mode="create")
Init add cast item form.
createMediaItemForPurpose($mob, $purpose)
handle media item for given purpose
This class represents a property in a property form.
addOption($a_option)
Add Option.
getCastItemValues()
Get cast item values into form.
if(!is_array($argv)) $options
addCastItemObject()
Add media cast item.
Class ilObjMediaCastGUI.
static _gotoRepositoryNode($a_ref_id, $a_cmd="frameset")
Goto repository root.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class represents a number property in a property form.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
saveSettingsObject()
Save Settings.
updateCastItemObject()
Update cast item.
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
special template class to simplify handling of ITX/PEAR
listItemsObject($a_presentation_mode=false)
List items of media cast.
static isAudio($extension)
detect audio mimetype
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
This class represents a regular expression input property in a property form.
addContentSubTabs($a_active="content")
Add content subtabs.
Class ilMediaItem.
This class represents a text property in a property form.
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
$ilUser
Definition: imgupload.php:18
redirection script todo: (a better solution should control the processing via a xml file) ...
handlePlayerEventObject()
Handle player event.
static _recordReadEvent($a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
Class ilObjMediaObject.
setMaxLength($a_maxlength)
Set Max Length.
initCreateForm($a_new_type)
Init object creation form.
generatePreviewPic($a_width, $a_height)
Upload video preview picture.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static signFile($path_to_file)
convertFileObject()
Convert file object.
showContentObject()
Show content.
confirmDeletionItemsObject()
Confirmation Screen.
Create styles array
The data for the language used.
setMaxValue($a_maxvalue, $a_display_always=false)
Set Maximum Value.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
afterSave(ilObject $newObj)
save object public
saveCastItemObject()
Save new cast item.
This class represents an image file property in a property form.
determinePlaytimeObject()
Delete news items.
User interface for media player.
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
This class represents a non editable value in a property form.
static getMimeType($a_file, $a_external=false)
get mime type for file
Create new PHPExcel object
obj_idprivate
Analyzes media files.
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
& getMediaItems()
get all media items
downloadItemObject()
Download news media item.
getMediaItems($id)
get MediaItems for id and updates local variable mcst_item
This class represents a text area property in a property form.
editSettingsObject()
Edit settings.
$ret
Definition: parser.php:6
getRefId()
get reference id public
infoScreen()
show information screen
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
const NEWS_AUDIO
TableGUI class for table NewsForContext.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
extractPreviewImageObject()
Extract preview image.
static enabled()
Checks, whether FFmpeg support is enabled (path is set in the setup)
static _getInstance()
get singleton instance
setValue($a_value)
Set Value.
static redirect($a_script)
http redirect to other script
__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output=true)
Constructor public.
addHeaderAction()
Add header action menu.
setSuffixes($a_suffixes)
Set Accepted Suffixes.
Class ilObjUserTrackingGUI.
$_POST["username"]
$html
Definition: example_001.php:87
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
setRequired($a_required)
Set Required.
editCastItemObject()
Edit media cast item.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Confirmation screen class.
static supportsImageExtraction($a_mime)
Check if mime type supports image extraction.