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