ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
9
10require_once "./Services/Object/classes/class.ilObjectGUI.php";
11
24{
28 protected $tabs;
29
33 protected $log;
34
38 protected $error;
39
43 protected $help;
44
48 protected $filesystem;
49
50 private $additionalPurposes = array("VideoPortable", "AudioPortable");
51 private $purposeSuffixes = array();
52 private $mimeTypes = array();
53
58 public function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
59 {
60 global $DIC;
61
62 $this->ctrl = $DIC->ctrl();
63 $this->lng = $DIC->language();
64 $this->user = $DIC->user();
65 $this->tabs = $DIC->tabs();
66 $this->tpl = $DIC["tpl"];
67 $this->access = $DIC->access();
68 $this->toolbar = $DIC->toolbar();
69 $this->filesystem = $DIC->filesystem()->web();
70 $this->log = $DIC["ilLog"];
71 $this->error = $DIC["ilErr"];
72 $this->help = $DIC["ilHelp"];
73 $this->locator = $DIC["ilLocator"];
74 $ilCtrl = $DIC->ctrl();
75 $lng = $DIC->language();
76
77 $this->type = "mcst";
78 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
79 $lng->loadLanguageModule("mcst");
80 $lng->loadLanguageModule("news");
81 $lng->loadLanguageModule("rep");
82
83 $ilCtrl->saveParameter($this, "item_id");
84
85 include_once("./Modules/MediaCast/classes/class.ilMediaCastSettings.php");
87 $this->purposeSuffixes = $settings->getPurposeSuffixes();
88 $this->mimeTypes = array();
89 $mime_types = $settings->getMimeTypes();
90 foreach ($mime_types as $mt) {
91 $this->mimeTypes[$mt] = $mt;
92 }
93
94 include_once("./Services/Utilities/classes/class.ilMimeTypeUtil.php");
95 foreach (ilMimeTypeUtil::getExt2MimeMap() as $mt) {
96 $this->mimeTypes[$mt] = $mt;
97 }
98 asort($this->mimeTypes);
99 }
100
101 public function executeCommand()
102 {
104 $ilTabs = $this->tabs;
105
106 $next_class = $this->ctrl->getNextClass($this);
107 $cmd = $this->ctrl->getCmd();
108 $this->prepareOutput();
109
110 switch ($next_class) {
111 case "ilinfoscreengui":
112 if (!$this->checkPermissionBool("read")) {
113 $this->checkPermission("visible");
114 }
115 $this->infoScreen(); // forwards command
116 break;
117
118 case "ilexportgui":
119// $this->prepareOutput();
120 $ilTabs->activateTab("export");
121 include_once("./Services/Export/classes/class.ilExportGUI.php");
122 $exp_gui = new ilExportGUI($this);
123 $exp_gui->addFormat("xml");
124 $ret = $this->ctrl->forwardCommand($exp_gui);
125// $this->tpl->show();
126 break;
127
128 case 'ilpermissiongui':
129 $ilTabs->activateTab("id_permissions");
130 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
131 $perm_gui = new ilPermissionGUI($this);
132 $ret = $this->ctrl->forwardCommand($perm_gui);
133 break;
134
135 case 'ilobjectcopygui':
136 include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
137 $cp = new ilObjectCopyGUI($this);
138 $cp->setType('mcst');
139 $this->ctrl->forwardCommand($cp);
140 break;
141
142 case "ilcommonactiondispatchergui":
143 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
145 $this->ctrl->forwardCommand($gui);
146 break;
147
148 case "illearningprogressgui":
149 $ilTabs->activateTab('learning_progress');
150 require_once 'Services/Tracking/classes/class.ilLearningProgressGUI.php';
151 $new_gui = new ilLearningProgressGUI(
153 $this->object->getRefId(),
154 $_GET['user_id'] ? $_GET['user_id'] : $ilUser->getId()
155 );
156 $this->ctrl->forwardCommand($new_gui);
157 $this->tabs_gui->setTabActive('learning_progress');
158 break;
159
160 default:
161 if (!$cmd) {
162 $cmd = "infoScreen";
163 }
164 $cmd .= "Object";
165 if ($cmd != "infoScreenObject") {
166 $this->checkPermission("read");
167 } else {
168 $this->checkPermission("visible");
169 }
170 $this->$cmd();
171
172 break;
173 }
174
175 $this->addHeaderAction();
176
177 return true;
178 }
179
180 protected function initCreationForms($a_new_type)
181 {
182 $forms = array(self::CFORM_NEW => $this->initCreateForm($a_new_type),
183 self::CFORM_IMPORT => $this->initImportForm($a_new_type),
184 self::CFORM_CLONE => $this->fillCloneTemplate(null, $a_new_type));
185
186 return $forms;
187 }
188
193 public function afterSave(ilObject $newObj)
194 {
195 // always send a message
196 ilUtil::sendSuccess($this->lng->txt("object_added"), true);
197 ilUtil::redirect("ilias.php?baseClass=ilMediaCastHandlerGUI&ref_id=" . $newObj->getRefId() . "&cmd=editSettings");
198 }
199
203 public function listItemsObject($a_presentation_mode = false)
204 {
207 $ilAccess = $this->access;
208 $ilTabs = $this->tabs;
209 $ilToolbar = $this->toolbar;
210
211 $this->checkPermission("read");
212
213 if ($a_presentation_mode) {
214 $this->addContentSubTabs("content");
215 } else {
216 $this->addContentSubTabs("manage");
217 }
218
219 $med_items = $this->object->getSortedItemsArray();
220
221 include_once("./Modules/MediaCast/classes/class.ilMediaCastTableGUI.php");
222 if ($a_presentation_mode) {
223 $table_gui = new ilMediaCastTableGUI($this, "showContent", false, true);
224 } else {
225 $table_gui = new ilMediaCastTableGUI($this, "listItems");
226 }
227
228 $table_gui->setData($med_items);
229
230 if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) && !$a_presentation_mode) {
231 $ilToolbar->addButton($lng->txt("add"), $this->ctrl->getLinkTarget($this, "addCastItem"));
232
233 $table_gui->addMultiCommand("confirmDeletionItems", $lng->txt("delete"));
234 $table_gui->setSelectAllCheckbox("item_id");
235 }
236
237 $feed_icon_html = $this->getFeedIconsHTML();
238 if ($feed_icon_html != "") {
239 $table_gui->setHeaderHTML($feed_icon_html);
240 }
241
242 $tpl->setContent($table_gui->getHTML());
243 }
244
251 public function getFeedIconsHTML()
252 {
254
255 $html = "";
256
257 include_once("./Services/Block/classes/class.ilBlockSetting.php");
258 $public_feed = ilBlockSetting::_lookup(
259 "news",
260 "public_feed",
261 0,
262 $this->object->getId()
263 );
264
265 // rss icon/link
266 if ($public_feed) {
267 $news_set = new ilSetting("news");
268 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
269
270 if ($enable_internal_rss) {
271 // create dummy object in db (we need an id)
272 $items = $this->object->getItemsArray();
273 include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
274 $html = "";
275 foreach (ilObjMediaCast::$purposes as $purpose) {
276 foreach ($items as $id => $item) {
277 $mob = new ilObjMediaObject($item["mob_id"]);
278 $mob->read();
279 if ($mob->hasPurposeItem($purpose)) {
280 if ($html == "") {
281 $html = " ";
282 }
283 $url = ILIAS_HTTP_PATH . "/feed.php?client_id=" . rawurlencode(CLIENT_ID) . "&" . "ref_id=" . $_GET["ref_id"] . "&purpose=$purpose";
284 $title = $lng->txt("news_feed_url");
285
286 include_once("./Services/News/classes/class.ilRSSButtonGUI.php");
287 switch (strtolower($purpose)) {
288 case "audioportable":
291 break;
292
293 case "videoportable":
296 break;
297
298 default:
301 break;
302 }
303 $row1 .= "&nbsp;" . ilRSSButtonGUI::get($type1, $url);
304 if ($this->object->getPublicFiles()) {
305 $url = preg_replace("/https?/i", "itpc", $url);
306 $title = $lng->txt("news_feed_url");
307
308 include_once("./Services/News/classes/class.ilRSSButtonGUI.php");
309 $row2 .= "&nbsp;" . ilRSSButtonGUI::get($type2, $url);
310 }
311 break;
312 }
313 }
314 }
315 if ($html != "") {
316 $html .= $row1;
317 if ($row2 != "") {
318 $html .= $row2;
319 }
320 }
321 }
322 }
323 return $html;
324 }
325
326
330 public function addCastItemObject()
331 {
333
334 $this->checkPermission("write");
335
336 $this->initAddCastItemForm();
337 $tpl->setContent($this->form_gui->getHTML());
338 }
339
343 public function editCastItemObject()
344 {
346 $ilToolbar = $this->toolbar;
348
349 $this->checkPermission("write");
350
351 // conversion toolbar
352 include_once("./Services/MediaObjects/classes/class.ilFFmpeg.php");
353 if (ilFFmpeg::enabled()) {
354 $this->mcst_item = new ilNewsItem($_GET["item_id"]);
355 include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
356 $mob = new ilObjMediaObject($this->mcst_item->getMobId());
357
358 $conv_cnt = 0;
359 // we had other purposes as source as well, but
360 // currently only "Standard" is implemented in the convertFile method
361 foreach (array("Standard") as $p) {
362 /*
363 $med = $mob->getMediaItem($p);
364 if (is_object($med))
365 {
366 $options = ilFFmpeg::getPossibleTargetMimeTypes($med->getFormat());
367 if (count($options) > 0)
368 {
369 if ($conv_cnt > 0)
370 {
371 $ilToolbar->addSeparator();
372 }
373
374 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
375 $si = new ilSelectInputGUI($this->lng->txt("mcst_conv_".
376 strtolower($p)."_to"), "target_format");
377 $si->setOptions($options);
378 $ilToolbar->addInputItem($si, true);
379
380 $si = new ilSelectInputGUI(", ".$this->lng->txt("mcst_target").": ",
381 "target_purpose");
382 $si->setOptions(array("Standard" => $this->lng->txt("mcst_purpose_standard"),
383 "VideoAlternative" => $this->lng->txt("mcst_purpose_videoalternative")
384 ));
385 $si->setValue($p);
386 $ilToolbar->addInputItem($si, true);
387
388 $ilToolbar->addFormButton($this->lng->txt("mcst_convert"), "convertFile");
389
390 $conv_cnt++;
391 }
392 }
393 */
394
395 $med = $mob->getMediaItem($p);
396 if (is_object($med)) {
397 if (ilFFmpeg::supportsImageExtraction($med->getFormat())) {
398 // second
399 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
400 $ni = new ilTextInputGUI($this->lng->txt("mcst_second"), "sec");
401 $ni->setMaxLength(4);
402 $ni->setSize(4);
403 $ni->setValue(1);
404 $ilToolbar->addInputItem($ni, true);
405
406 $ilToolbar->addFormButton($this->lng->txt("mcst_extract_preview_image"), "extractPreviewImage");
407 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
408 }
409 }
410
411 /*if ($conv_cnt > 0)
412 {
413 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
414 }*/
415 }
416 }
417
418 $this->initAddCastItemForm("edit");
419 $this->getCastItemValues();
420 $tpl->setContent($this->form_gui->getHTML());
421 }
422
426 public function initAddCastItemForm($a_mode = "create")
427 {
430 $ilTabs = $this->tabs;
431
432 $this->checkPermission("write");
433 $ilTabs->activateTab("edit_content");
434
435 $lng->loadLanguageModule("mcst");
436
437 $news_set = new ilSetting("news");
438 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
439
440 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
441 $this->form_gui = new ilPropertyFormGUI();
442 $this->form_gui->setMultipart(true);
443
444 // Property Title
445 $text_input = new ilTextInputGUI($lng->txt("title"), "title");
446 $text_input->setMaxLength(200);
447 $this->form_gui->addItem($text_input);
448
449 // Property Content
450 $text_area = new ilTextAreaInputGUI($lng->txt("description"), "description");
451 $text_area->setRequired(false);
452 $this->form_gui->addItem($text_area);
453
454 // Property Visibility
455 if ($enable_internal_rss) {
456 $radio_group = new ilRadioGroupInputGUI($lng->txt("access_scope"), "visibility");
457 $radio_option = new ilRadioOption($lng->txt("access_users"), "users");
458 $radio_group->addOption($radio_option);
459 $radio_option = new ilRadioOption($lng->txt("access_public"), "public");
460 $radio_group->addOption($radio_option);
461 $radio_group->setInfo($lng->txt("mcst_visibility_info"));
462 $radio_group->setRequired(true);
463 $radio_group->setValue($this->object->getDefaultAccess() == 0 ? "users" : "public");
464 $this->form_gui->addItem($radio_group);
465 }
466
467 // Duration
468 $dur = new ilDurationInputGUI($lng->txt("mcst_duration"), "duration");
469 $dur->setInfo($lng->txt("mcst_duration_info"));
470 $dur->setShowDays(false);
471 $dur->setShowHours(true);
472 $dur->setShowSeconds(true);
473 $this->form_gui->addItem($dur);
474
475 foreach (ilObjMediaCast::$purposes as $purpose) {
476 if ($purpose == "VideoAlternative" &&
477 $a_mode == "create") {
478 continue;
479 }
480
482 $section->setTitle($lng->txt("mcst_" . strtolower($purpose) . "_title"));
483 $this->form_gui->addItem($section);
484 if ($a_mode != "create") {
485 $value = new ilHiddenInputGUI("value_" . $purpose);
486 $label = new ilNonEditableValueGUI($lng->txt("value"));
487 $label->setPostVar("label_value_" . $purpose);
488 $label->setInfo($lng->txt("mcst_current_value_info"));
489 $this->form_gui->addItem($label);
490 $this->form_gui->addItem($value);
491 }
492 $file = new ilFileInputGUI($lng->txt("file"), "file_" . $purpose);
493 $file->setSuffixes($this->purposeSuffixes[$purpose]);
494 $this->form_gui->addItem($file);
495 $text_input = new ilRegExpInputGUI($lng->txt("url"), "url_" . $purpose);
496 $text_input->setPattern("/https?\:\/\/.+/i");
497 $text_input->setInfo($lng->txt("mcst_reference_info"));
498 $this->form_gui->addItem($text_input);
499 if ($purpose != "Standard") {
500 $clearCheckBox = new ilCheckboxInputGUI();
501 $clearCheckBox->setPostVar("delete_" . $purpose);
502 $clearCheckBox->setTitle($lng->txt("mcst_clear_purpose_title"));
503 $this->form_gui->addItem($clearCheckBox);
504 } else {
505
506 // mime type selection
507 $mimeTypeSelection = new ilSelectInputGUI();
508 $mimeTypeSelection->setPostVar("mimetype_" . $purpose);
509 $mimeTypeSelection->setTitle($lng->txt("mcst_mimetype"));
510 $mimeTypeSelection->setInfo($lng->txt("mcst_mimetype_info"));
511 $options = array("" => $lng->txt("mcst_automatic_detection"));
512 $options = array_merge($options, $this->mimeTypes);
513 $mimeTypeSelection->setOptions($options);
514 $this->form_gui->addItem($mimeTypeSelection);
515
516 // preview picure
517 $pp = new ilImageFileInputGUI($lng->txt("mcst_preview_picture"), "preview_pic");
518 $pp->setSuffixes(array("png", "jpeg", "jpg"));
519 $pp->setInfo($lng->txt("mcst_preview_picture_info") . " mp4, mp3, png, jp(e)g, gif");
520 $this->form_gui->addItem($pp);
521 }
522 }
523
524 // save/cancel button
525 if ($a_mode == "create") {
526 $this->form_gui->setTitle($lng->txt("mcst_add_new_item"));
527 $this->form_gui->addCommandButton("saveCastItem", $lng->txt("save"));
528 } else {
529 $this->form_gui->setTitle($lng->txt("mcst_edit_item"));
530 $this->form_gui->addCommandButton("updateCastItem", $lng->txt("save"));
531 }
532 $this->form_gui->addCommandButton("listItems", $lng->txt("cancel"));
533 $this->form_gui->setFormAction($ilCtrl->getFormAction($this, "saveCastItem"));
534 }
535
539 public function getCastItemValues()
540 {
542
543 // get mob
544 $this->mcst_item = new ilNewsItem($_GET["item_id"]);
545 include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
546 $mob = new ilObjMediaObject($this->mcst_item->getMobId());
547
548 // preview
549 $ppic = $mob->getVideoPreviewPic();
550 if ($ppic != "") {
551 $i = $this->form_gui->getItemByPostVar("preview_pic");
552 $i->setImage($ppic);
553 }
554
555
556 $values = array();
557 $mediaItems = $this->getMediaItems($_GET["item_id"]);
558 if (count($mediaItems) > 0) {
559 foreach ($mediaItems as $med) {
560 if (!isset($values["title"])) {
561 // first item, so set title, description, ...
562 $values["title"] = $this->mcst_item->getTitle();
563 $values["description"] = $this->mcst_item->getContent();
564 $values["visibility"] = $this->mcst_item->getVisibility();
565 $length = explode(":", $this->mcst_item->getPlaytime());
566 $values["duration"] = array("hh" => $length[0], "mm" => $length[1], "ss" => $length[2]);
567 }
568
569 $values["value_" . $med->getPurpose()] = (strlen($med->getLocation()) > 100) ? "..." . substr($med->getLocation(), strlen($med->getLocation()) - 100) : $med->getLocation();
570 $values["label_value_" . $med->getPurpose()] = (strlen($med->getLocation()) > 100) ? "..." . substr($med->getLocation(), strlen($med->getLocation()) - 100) : $med->getLocation();
571 $values["mimetype_" . $med->getPurpose()] = $med->getFormat();
572 }
573 }
574 foreach (ilObjMediaCast::$purposes as $purpose) {
575 if (!isset($values["value_" . $purpose])) {
576 $values["label_value_" . $purpose] = $lng->txt("none");
577 $values["value_" . $purpose] = $lng->txt("none");
578 }
579 }
580 $this->form_gui->setValuesByArray($values);
581 }
582
586 public function saveCastItemObject()
587 {
592 $ilTabs = $this->tabs;
593
594 $this->checkPermission("write");
595 $ilTabs->activateTab("edit_content");
596
597 $this->initAddCastItemForm();
598
599 if (!$this->form_gui->checkInput() ||
600 ($_POST["url_Standard"] == "" && !$_FILES['file_Standard']['tmp_name'])) {
601 if (($_POST["url_Standard"] == "" && !$_FILES['file_Standard']['tmp_name'])) {
602 ilUtil::sendFailure($lng->txt("mcst_input_either_file_or_url"));
603 }
604 $this->populateFormFromPost();
605 } else {
606 // create dummy object in db (we need an id)
607 include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
608 $mob = new ilObjMediaObject();
609 $mob->create();
610
611 //handle standard purpose
612 $file = $this->createMediaItemForPurpose($mob, "Standard");
613
614 // set title and description
615 // set title to basename of file if left empty
616 $title = $this->form_gui->getInput("title") != "" ? $this->form_gui->getInput("title") : basename($file);
617 $description = $this->form_gui->getInput("description");
618 $mob->setTitle($title);
619 $mob->setDescription($description);
620
621 // save preview pic
622 $prevpic = $this->form_gui->getInput("preview_pic");
623 if ($prevpic["size"] > 0) {
624 $mob->uploadVideoPreviewPic($prevpic);
625 }
626
627 // determine duration for standard purpose
628 $duration = $this->getDuration($file);
629
630 // handle other purposes
631 foreach ($this->additionalPurposes as $purpose) {
632 // check if some purpose has been uploaded
633 $file_gui = $this->form_gui->getInput("file_" . $purpose);
634 $url_gui = $this->form_gui->getInput("url_" . $purpose);
635 if ($url_gui || $file_gui["size"] > 0) {
636 $this->createMediaItemForPurpose($mob, $purpose);
637 }
638 }
639
640 $mob->update();
641
642 if ($prevpic["size"] == 0) {
643 // re-read media object
644 $mob = new ilObjMediaObject($mob->getId());
645 $mob->generatePreviewPic(320, 240);
646 }
647
648 //
649 // @todo: save usage
650 //
651
652 $news_set = new ilSetting("news");
653 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
654
655 // create new media cast item
656 include_once("./Services/News/classes/class.ilNewsItem.php");
657 $mc_item = new ilNewsItem();
658 $mc_item->setMobId($mob->getId());
659 $mc_item->setContentType(NEWS_AUDIO);
660 $mc_item->setContextObjId($this->object->getId());
661 $mc_item->setContextObjType($this->object->getType());
662 $mc_item->setUserId($ilUser->getId());
663 $mc_item->setPlaytime($duration);
664 $mc_item->setTitle($title);
665 $mc_item->setContent($description);
666 $mc_item->setLimitation(false);
667 if ($enable_internal_rss) {
668 $mc_item->setVisibility($this->form_gui->getInput("visibility"));
669 } else {
670 $mc_item->setVisibility("users");
671 }
672 $mc_item->create();
673
674 $ilCtrl->redirect($this, "listItems");
675 }
676 }
677
684 private function getDuration($file)
685 {
686 $duration = isset($this->form_gui)
687 ? $this->form_gui->getInput("duration")
688 : array("hh" => 0, "mm" => 0, "ss" => 0);
689 if ($duration["hh"] == 0 && $duration["mm"] == 0 && $duration["ss"] == 0 && is_file($file)) {
690 include_once("./Services/MediaObjects/classes/class.ilMediaAnalyzer.php");
691 $ana = new ilMediaAnalyzer();
692 $ana->setFile($file);
693 $ana->analyzeFile();
694 $dur = $ana->getPlaytimeString();
695 $dur = explode(":", $dur);
696 $duration["mm"] = $dur[0];
697 $duration["ss"] = $dur[1];
698 }
699 $duration = str_pad($duration["hh"], 2, "0", STR_PAD_LEFT) . ":" .
700 str_pad($duration["mm"], 2, "0", STR_PAD_LEFT) . ":" .
701 str_pad($duration["ss"], 2, "0", STR_PAD_LEFT);
702 return $duration;
703 }
704
711 private function createMediaItemForPurpose($mob, $purpose)
712 {
713 $mediaItem = new ilMediaItem();
714 $mob->addMediaItem($mediaItem);
715 $mediaItem->setPurpose($purpose);
716 return $this->updateMediaItem($mob, $mediaItem);
717 }
718
728 private function updateMediaItem($mob, &$mediaItem)
729 {
730 $purpose = $mediaItem->getPurpose();
731 $locationType = $mediaItem->getLocationType();
732 $url_gui = $this->form_gui->getInput("url_" . $purpose);
733 $file_gui = $this->form_gui->getInput("file_" . $purpose);
734 if ($url_gui) {
735 // http
736 $file = $this->form_gui->getInput("url_" . $purpose);
737 $title = basename($file);
738 $location = $this->form_gui->getInput("url_" . $purpose);
739 $locationType = "Reference";
740 } elseif ($file_gui["size"] > 0) {
741 // lokal
742 // determine and create mob directory, move uploaded file to directory
743 $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
744 if (!is_dir($mob_dir)) {
745 $mob->createDirectory();
746 } else {
747 $dir = LegacyPathHelper::createRelativePath($mob_dir);
748 $old_files = $this->filesystem->finder()->in([$dir])->exclude([$dir . '/mob_vpreview.png'])->files();
749 foreach ($old_files as $file) {
750 $this->filesystem->delete($file->getPath());
751 }
752 }
753
754 $file_name = ilUtil::getASCIIFilename($_FILES['file_' . $purpose]['name']);
755 $file_name = str_replace(" ", "_", $file_name);
756
757 $file = $mob_dir . "/" . $file_name;
758 $title = $file_name;
759 $locationType = "LocalFile";
760 $location = $title;
761 ilUtil::moveUploadedFile($_FILES['file_' . $purpose]['tmp_name'], $file_name, $file);
763 }
764
765 // check if not automatic mimetype detection
766 if ($_POST["mimetype_" . $purpose] != "") {
767 $mediaItem->setFormat($_POST["mimetype_" . $purpose]);
768 } elseif ($mediaItem->getLocation() != "") {
769 $format = ilObjMediaObject::getMimeType($mediaItem->getLocation(), ($locationType == "Reference"));
770 $mediaItem->setFormat($format);
771 }
772
773 if (isset($file)) {
774 // get mime type, if not already set!
775 if (!isset($format)) {
776 $format = ilObjMediaObject::getMimeType($file, ($locationType == "Reference"));
777 }
778
779 // set real meta and object data
780 $mediaItem->setFormat($format);
781 $mediaItem->setLocation($location);
782 $mediaItem->setLocationType($locationType);
783 $mediaItem->setHAlign("Left");
784 $mediaItem->setHeight(self::isAudio($format)?0:180);
785 }
786
787 if ($purpose == "Standard") {
788 if (isset($title)) {
789 $mob->setTitle($title);
790 }
791 if (isset($format)) {
792 $mob->setDescription($format);
793 }
794 }
795
796 return $file;
797 }
798
802 public function updateCastItemObject()
803 {
807
808 $this->checkPermission("write");
809
810 $this->initAddCastItemForm("edit");
811
812 if ($this->form_gui->checkInput()) {
813 // create new media cast item
814 include_once("./Services/News/classes/class.ilNewsItem.php");
815 $mc_item = new ilNewsItem($_GET["item_id"]);
816 $mob_id = $mc_item->getMobId();
817
818 // create dummy object in db (we need an id)
819 include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
820 $mob = new ilObjMediaObject($mob_id);
821
822
823 foreach (ilObjMediaCast::$purposes as $purpose) {
824 if ($this->form_gui->getInput("delete_" . $purpose)) {
825 $mob->removeMediaItem($purpose);
826 $ilLog->write("Mcst: deleting purpose $purpose");
827 continue;
828 }
829 $media_item = $mob->getMediaItem($purpose);
830 $url_gui = $this->form_gui->getInput("url_" . $purpose);
831 $file_gui = $this->form_gui->getInput("file_" . $purpose);
832
833 if ($media_item == null) {
834 if ($purpose != "Standard" &&
835 ($url_gui || $file_gui["size"] > 0)) {
836 // check if we added an additional purpose when updating
837 // either by url or by file
838 $file = $this->createMediaItemForPurpose($mob, $purpose);
839 }
840 } else {
841 $file = $this->updateMediaItem($mob, $media_item);
842 }
843
844 if ($purpose == "Standard") {
845 $duration = $this->getDuration($file);
846 $title = $this->form_gui->getInput("title") != "" ? $this->form_gui->getInput("title") : basename($file);
847 $description = $this->form_gui->getInput("description");
848
849 $mob->setTitle($title);
850 $mob->setDescription($description);
851
852 $prevpic = $this->form_gui->getInput("preview_pic");
853 if ($prevpic["size"] > 0) {
854 $mob->uploadVideoPreviewPic($prevpic);
855 } else {
856 $prevpici = $this->form_gui->getItemByPostVar("preview_pic");
857 if ($prevpici->getDeletionFlag()) {
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 $mc_item->setPlaytime($duration);
877 }
878 $mc_item->setTitle($title);
879 $mc_item->setContent($description);
880 if ($enable_internal_rss) {
881 $mc_item->setVisibility($this->form_gui->getInput("visibility"));
882 }
883 $mc_item->update();
884
885 $ilCtrl->redirect($this, "listItems");
886 } else {
887 $this->populateFormFromPost();
888 }
889 }
890
895 {
899 $ilTabs = $this->tabs;
900
901 $this->checkPermission("write");
902 $ilTabs->activateTab("edit_content");
903
904 if (!is_array($_POST["item_id"])) {
905 $this->listItemsObject();
906 return;
907 }
908
909 include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
910 $c_gui = new ilConfirmationGUI();
911
912 // set confirm/cancel commands
913 $c_gui->setFormAction($ilCtrl->getFormAction($this, "deleteItems"));
914 $c_gui->setHeaderText($lng->txt("info_delete_sure"));
915 $c_gui->setCancel($lng->txt("cancel"), "listItems");
916 $c_gui->setConfirm($lng->txt("confirm"), "deleteItems");
917
918 // add items to delete
919 include_once("./Services/News/classes/class.ilNewsItem.php");
920 foreach ($_POST["item_id"] as $item_id) {
921 $item = new ilNewsItem($item_id);
922 $c_gui->addItem(
923 "item_id[]",
924 $item_id,
925 $item->getTitle(),
926 ilUtil::getImagePath("icon_mcst.svg")
927 );
928 }
929
930 $tpl->setContent($c_gui->getHTML());
931 }
932
936 public function deleteItemsObject()
937 {
939
940 $this->checkPermission("write");
941
942 // delete all selected news items
943 foreach ($_POST["item_id"] as $item_id) {
944 $mc_item = new ilNewsItem($item_id);
945 $mc_item->delete();
946 }
947
948 $ilCtrl->redirect($this, "listItems");
949 }
950
954 public function downloadItemObject()
955 {
958
959 $this->checkPermission("read");
960 $news_item = new ilNewsItem($_GET["item_id"]);
961 $this->object->handleLPUpdate($ilUser->getId(), $news_item->getMobId());
962 if (!$news_item->deliverMobFile($_GET["purpose"], (int) $_GET["presentation"])) {
963 $ilCtrl->redirect($this, "listItems");
964 }
965 exit;
966 }
967
971 public function determinePlaytimeObject()
972 {
975
976 $mc_item = new ilNewsItem($_GET["item_id"]);
977 $mob = $mc_item->getMobId();
978 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
979 $mob = new ilObjMediaObject($mob);
980 $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
981 $m_item = $mob->getMediaItem("Standard");
982 $file = $mob_dir . "/" . $m_item->getLocation();
983 $duration = $this->getDuration($file);
984 if ($duration != "00:00:00") {
985 $mc_item->setPlaytime($duration);
986 $mc_item->update();
987 ilUtil::sendSuccess($lng->txt("mcst_set_playtime"), true);
988 } else {
989 ilUtil::sendFailure($lng->txt("mcst_unable_to_determin_playtime"), true);
990 }
991
992 $ilCtrl->redirect($this, "listItems");
993 }
994
1000 public function infoScreenObject()
1001 {
1002 if (!$this->checkPermissionBool("read")) {
1003 $this->checkPermission("visible");
1004 }
1005 $this->ctrl->setCmd("showSummary");
1006 $this->ctrl->setCmdClass("ilinfoscreengui");
1007 $this->infoScreen();
1008 }
1009
1013 public function infoScreen()
1014 {
1015 $ilAccess = $this->access;
1017 $ilTabs = $this->tabs;
1018
1019 $ilTabs->activateTab("id_info");
1020
1021 if (!$this->checkPermissionBool("read")) {
1022 $this->checkPermission("visible");
1023 }
1024
1025 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
1026 $info = new ilInfoScreenGUI($this);
1027
1028 $info->enablePrivateNotes();
1029
1030 // general information
1031 $this->lng->loadLanguageModule("meta");
1032 $this->lng->loadLanguageModule("mcst");
1033 $med_items = $this->object->getItemsArray();
1034 $info->addSection($this->lng->txt("meta_general"));
1035 $info->addProperty(
1036 $this->lng->txt("mcst_nr_items"),
1037 (int) count($med_items)
1038 );
1039
1040 if (count($med_items) > 0) {
1041 $cur = current($med_items);
1042 $last = ilDatePresentation::formatDate(new ilDateTime($cur["creation_date"], IL_CAL_DATETIME));
1043 } else {
1044 $last = "-";
1045 }
1046
1047 $info->addProperty($this->lng->txt("mcst_last_submission"), $last);
1048
1049 // forward the command
1050 $this->ctrl->forwardCommand($info);
1051 }
1052
1057 public function setTabs()
1058 {
1059 $ilAccess = $this->access;
1060 $ilTabs = $this->tabs;
1061 $lng = $this->lng;
1062 $ilHelp = $this->help;
1063
1064 $ilHelp->setScreenIdComponent("mcst");
1065
1066 // list items
1067 if ($ilAccess->checkAccess('read', "", $this->object->getRefId())) {
1068 $ilTabs->addTab(
1069 "content",
1070 $lng->txt("content"),
1071 $this->ctrl->getLinkTarget($this, "showContent")
1072 );
1073 }
1074
1075 // info screen
1076 if ($ilAccess->checkAccess('visible', "", $this->object->getRefId()) ||
1077 $ilAccess->checkAccess('read', "", $this->object->getRefId())) {
1078 $ilTabs->addTab(
1079 "id_info",
1080 $lng->txt("info_short"),
1081 $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary")
1082 );
1083 }
1084
1085 // settings
1086 if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
1087 $ilTabs->addTab(
1088 "id_settings",
1089 $lng->txt("settings"),
1090 $this->ctrl->getLinkTarget($this, "editSettings")
1091 );
1092 }
1093
1094 require_once 'Services/Tracking/classes/class.ilLearningProgressAccess.php';
1095 if (ilLearningProgressAccess::checkAccess($this->object->getRefId())) {
1096 $ilTabs->addTab(
1097 'learning_progress',
1098 $lng->txt('learning_progress'),
1099 $this->ctrl->getLinkTargetByClass(array(__CLASS__, 'illearningprogressgui'), '')
1100 );
1101 }
1102
1103 // export
1104 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1105 $ilTabs->addTab(
1106 "export",
1107 $lng->txt("export"),
1108 $this->ctrl->getLinkTargetByClass("ilexportgui", "")
1109 );
1110 }
1111
1112 // edit permissions
1113 if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId())) {
1114 $ilTabs->addTab(
1115 "id_permissions",
1116 $lng->txt("perm_settings"),
1117 $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm")
1118 );
1119 }
1120 }
1121
1128 public function addContentSubTabs($a_active = "content")
1129 {
1130 $ilTabs = $this->tabs;
1131 $ilAccess = $this->access;
1132 $lng = $this->lng;
1133
1134 $ilTabs->addSubTab(
1135 "content",
1136 $lng->txt("view"),
1137 $this->ctrl->getLinkTarget($this, "showContent")
1138 );
1139
1140 if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) {
1141 $ilTabs->addSubTab(
1142 "manage",
1143 $lng->txt("mcst_manage"),
1144 $this->ctrl->getLinkTarget($this, "listItems")
1145 );
1146
1147 if ($this->object->getOrder() == ilObjMediaCast::ORDER_MANUAL) {
1148 $ilTabs->addSubTab(
1149 "sorting",
1150 $lng->txt("mcst_ordering"),
1151 $this->ctrl->getLinkTarget($this, "editOrder")
1152 );
1153 }
1154 }
1155
1156 $ilTabs->activateSubTab($a_active);
1157 $ilTabs->activateTab("content");
1158 }
1159
1160
1164 public function editSettingsObject()
1165 {
1166 $tpl = $this->tpl;
1167 $ilTabs = $this->tabs;
1168
1169 $this->checkPermission("write");
1170 $ilTabs->activateTab("id_settings");
1171
1172 $this->initSettingsForm();
1173 $tpl->setContent($this->form_gui->getHtml());
1174 }
1175
1179 public function initSettingsForm()
1180 {
1181 $tpl = $this->tpl;
1182 $lng = $this->lng;
1184 $obj_service = $this->object_service;
1185
1186 $lng->loadLanguageModule("mcst");
1187
1188 require_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1189 $this->form_gui = new ilPropertyFormGUI();
1190 $this->form_gui->setTitle($lng->txt("mcst_settings"));
1191
1192 // Title
1193 $tit = new ilTextInputGUI($lng->txt("title"), "title");
1194 $tit->setValue($this->object->getTitle());
1195 $tit->setRequired(true);
1196 $this->form_gui->addItem($tit);
1197
1198 // description
1199 $des = new ilTextAreaInputGUI($lng->txt("description"), "description");
1200 $des->setValue($this->object->getLongDescription());
1201 $this->form_gui->addItem($des);
1202
1203 $sh = new ilFormSectionHeaderGUI();
1204 $sh->setTitle($lng->txt("rep_activation_availability"));
1205 $this->form_gui->addItem($sh);
1206
1207 // Online
1208 $online = new ilCheckboxInputGUI($lng->txt("online"), "online");
1209 $online->setChecked($this->object->getOnline());
1210 $this->form_gui->addItem($online);
1211
1212 // presentation
1213 $sh = new ilFormSectionHeaderGUI();
1214 $sh->setTitle($lng->txt("obj_presentation"));
1215 $this->form_gui->addItem($sh);
1216
1217 // tile image
1218 $obj_service->commonSettings()->legacyForm($this->form_gui, $this->object)->addTileImage();
1219
1220 // Sorting
1221 $sort = new ilRadioGroupInputGUI($lng->txt("mcst_ordering"), "order");
1222 $sort->addOption(new ilRadioOption(
1223 $lng->txt("mcst_ordering_title"),
1225 ));
1226 $sort->addOption(new ilRadioOption(
1227 $lng->txt("mcst_ordering_creation_date_asc"),
1229 ));
1230 $sort->addOption(new ilRadioOption(
1231 $lng->txt("mcst_ordering_creation_date_desc"),
1233 ));
1234 $sort->addOption(new ilRadioOption(
1235 $lng->txt("mcst_ordering_manual"),
1237 ));
1238 $sort->setValue($this->object->getOrder());
1239 $this->form_gui->addItem($sort);
1240
1241 // view mode
1242 $options = array(
1243 ilObjMediaCast::VIEW_LIST => $lng->txt("mcst_list"),
1244 ilObjMediaCast::VIEW_GALLERY => $lng->txt("mcst_gallery")
1245 );
1246 $si = new ilRadioGroupInputGUI($this->lng->txt("mcst_viewmode"), "viewmode");
1247 $si->addOption(new ilRadioOption(
1248 $lng->txt("mcst_list"),
1250 ));
1251 $si->addOption(new ilRadioOption(
1252 $lng->txt("mcst_gallery"),
1254 ));
1255
1256 // $si->setOptions($options);
1257 $si->setValue($this->object->getViewMode());
1258 $this->form_gui->addItem($si);
1259
1260
1261 // Downloadable
1262 $downloadable = new ilCheckboxInputGUI($lng->txt("mcst_downloadable"), "downloadable");
1263 $downloadable->setChecked($this->object->getDownloadable());
1264 $downloadable->setInfo($lng->txt("mcst_downloadable_info"));
1265 $this->form_gui->addItem($downloadable);
1266
1267 $news_set = new ilSetting("news");
1268 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
1269
1270 //Default Visibility
1271 if ($enable_internal_rss) {
1272 // webfeed
1273 $sh = new ilFormSectionHeaderGUI();
1274 $sh->setTitle($lng->txt("mcst_webfeed"));
1275 $this->form_gui->addItem($sh);
1276
1277 $radio_group = new ilRadioGroupInputGUI($lng->txt("news_default_visibility"), "defaultaccess");
1278 $radio_option = new ilRadioOption($lng->txt("news_visibility_users"), "0");
1279 $radio_option->setInfo($lng->txt("news_news_item_def_visibility_users_info"));
1280 $radio_group->addOption($radio_option);
1281 $radio_option = new ilRadioOption($lng->txt("news_visibility_public"), "1");
1282 $radio_option->setInfo($lng->txt("news_news_item_def_visibility_public_info"));
1283 $radio_group->addOption($radio_option);
1284 $radio_group->setRequired(false);
1285 $radio_group->setValue($this->object->getDefaultAccess());
1286 #$ch->addSubItem($radio_group);
1287 $this->form_gui->addItem($radio_group);
1288
1289 //Extra Feed
1290 include_once("./Services/Block/classes/class.ilBlockSetting.php");
1291 $public_feed = ilBlockSetting::_lookup("news", "public_feed", 0, $this->object->getId());
1292 $ch = new ilCheckboxInputGUI($lng->txt("news_public_feed"), "extra_feed");
1293 $ch->setInfo($lng->txt("news_public_feed_info"));
1294 $ch->setChecked($public_feed);
1295 $this->form_gui->addItem($ch);
1296
1297 // keep minimal x number of items
1298 $ni = new ilNumberInputGUI($this->lng->txt("news_keep_minimal_x_items"), "keep_rss_min");
1299 $ni->setMaxValue(100);
1300 $ni->setMinValue(0);
1301 $ni->setMaxLength(3);
1302 $ni->setSize(3);
1303 $ni->setInfo($this->lng->txt("news_keep_minimal_x_items_info") . " (" .
1304 ilNewsItem::_lookupRSSPeriod() . " " . (ilNewsItem::_lookupRSSPeriod() == 1 ? $lng->txt("day") : $lng->txt("days")) . ")");
1305 $ni->setValue((int) ilBlockSetting::_lookup("news", "keep_rss_min", 0, $this->object->getId()));
1306 $ch->addSubItem($ni);
1307
1308 // Include Files in Pubic Items
1309 $incl_files = new ilCheckboxInputGUI($lng->txt("mcst_incl_files_in_rss"), "public_files");
1310 $incl_files->setChecked($this->object->getPublicFiles());
1311 $incl_files->setInfo($lng->txt("mcst_incl_files_in_rss_info"));
1312 #$ch->addSubItem($incl_files);
1313 $this->form_gui->addItem($incl_files);
1314 }
1315
1316 // Form action and save button
1317 $this->form_gui->addCommandButton("saveSettings", $lng->txt("save"));
1318 $this->form_gui->setFormAction($ilCtrl->getFormAction($this, "saveSettings"));
1319 }
1320
1324 public function saveSettingsObject()
1325 {
1327 $ilTabs = $this->tabs;
1328 $obj_service = $this->object_service;
1329
1330 $this->checkPermission("write");
1331 $ilTabs->activateTab("id_settings");
1332
1333 $this->initSettingsForm();
1334 if ($this->form_gui->checkInput()) {
1335 $news_set = new ilSetting("news");
1336 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
1337
1338 $this->object->setTitle($this->form_gui->getInput("title"));
1339 $this->object->setDescription($this->form_gui->getInput("description"));
1340 $this->object->setOnline($this->form_gui->getInput("online"));
1341 $this->object->setDownloadable($this->form_gui->getInput("downloadable"));
1342 $this->object->setOrder($this->form_gui->getInput("order"));
1343 $this->object->setViewMode($this->form_gui->getInput("viewmode"));
1344
1345 // tile image
1346 $obj_service->commonSettings()->legacyForm($this->form_gui, $this->object)->saveTileImage();
1347
1348 if ($enable_internal_rss) {
1349 $this->object->setPublicFiles($this->form_gui->getInput("public_files"));
1350 $this->object->setDefaultAccess($this->form_gui->getInput("defaultaccess"));
1351 }
1352 $this->object->update();
1353
1354 if ($enable_internal_rss) {
1355 include_once("./Services/Block/classes/class.ilBlockSetting.php");
1357 "news",
1358 "public_feed",
1359 $this->form_gui->getInput("extra_feed"),
1360 0,
1361 $this->object->getId()
1362 );
1363
1365 "news",
1366 "keep_rss_min",
1367 $this->form_gui->getInput("keep_rss_min"),
1368 0,
1369 $this->object->getId()
1370 );
1371 }
1372
1373 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1374 $ilCtrl->redirect($this, "editSettings");
1375 } else {
1376 $this->form_gui->setValuesByPost();
1377 $this->tpl->setContent($this->form_gui->getHTML());
1378 }
1379 }
1380
1381 // add media cast to locator
1382 public function addLocatorItems()
1383 {
1384 $ilLocator = $this->locator;
1385
1386 if (is_object($this->object)) {
1387 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "listItems"), "", $_GET["ref_id"]);
1388 }
1389 }
1390
1391 public static function _goto($a_target)
1392 {
1393 global $DIC;
1394
1395 $ilAccess = $DIC->access();
1396 $ilErr = $DIC["ilErr"];
1397 $lng = $DIC->language();
1398
1399 if ($ilAccess->checkAccess("read", "", $a_target)) {
1400 $_GET["cmd"] = "showContent";
1401 $_GET["ref_id"] = $a_target;
1402 $_GET["baseClass"] = "ilmediacasthandlergui";
1403 $_GET["cmdClass"] = "ilobjmediacastgui";
1404 include("ilias.php");
1405 exit;
1406 } elseif ($ilAccess->checkAccess("visible", "", $a_target)) {
1407 ilObjectGUI::_gotoRepositoryNode($a_target, "infoScreen");
1408 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1409 ilUtil::sendFailure(sprintf(
1410 $lng->txt("msg_no_perm_read_item"),
1412 ));
1414 }
1415
1416 $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
1417 }
1418
1425 protected static function isAudio($extension)
1426 {
1427 return strpos($extension, "audio") !== false;
1428 }
1429
1436 protected function getMediaItem($id)
1437 {
1438 include_once("./Services/News/classes/class.ilNewsItem.php");
1439 $this->mcst_item = new ilNewsItem($id);
1440 // create dummy object in db (we need an id)
1441 include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
1442 $mob = new ilObjMediaObject($this->mcst_item->getMobId());
1443 return $mob->getMediaItem("Standard");
1444 }
1445
1452 protected function getMediaItems($id)
1453 {
1454 include_once("./Services/News/classes/class.ilNewsItem.php");
1455 $this->mcst_item = new ilNewsItem($id);
1456 // create dummy object in db (we need an id)
1457 include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
1458 $mob = new ilObjMediaObject($this->mcst_item->getMobId());
1459 return $mob->getMediaItems();
1460 }
1461
1462 private function populateFormFromPost()
1463 {
1464 $tpl = $this->tpl;
1465 //issue: we have to display the current settings
1466 // problem: POST does not contain values of disabled textfields
1467 // solution: use hidden field and label to display-> here we need to synchronize the labels
1468 // with the values from the hidden fields.
1469 foreach (ilObjMediaCast::$purposes as $purpose) {
1470 if ($_POST["value_" . $purpose]) {
1471 $_POST["label_value_" . $purpose] = $_POST["value_" . $purpose];
1472 }
1473 }
1474
1475 $this->form_gui->setValuesByPost();
1476 $tpl->setContent($this->form_gui->getHTML());
1477 }
1478
1479 protected function editOrderObject()
1480 {
1481 $ilTabs = $this->tabs;
1482 $lng = $this->lng;
1483 $tpl = $this->tpl;
1484
1485 $this->checkPermission("write");
1486 $ilTabs->activateTab("edit_content");
1487
1488 $this->addContentSubTabs("sorting");
1489
1490 // sort by order setting
1491 switch ($this->object->getOrder()) {
1495 return $this->listItemsObject();
1496
1498 // sub-tabs
1499 break;
1500 }
1501
1502 include_once("./Modules/MediaCast/classes/class.ilMediaCastTableGUI.php");
1503 $table_gui = new ilMediaCastTableGUI($this, "editOrder", true);
1504
1505 $table_gui->setTitle($lng->txt("mcst_media_cast"));
1506 $table_gui->setData($this->object->getSortedItemsArray());
1507
1508 $table_gui->addCommandButton("saveOrder", $lng->txt("mcst_save_order"));
1509
1510 $tpl->setContent($table_gui->getHTML());
1511 }
1512
1513 public function saveOrderObject()
1514 {
1515 $lng = $this->lng;
1516
1517 asort($_POST["item_id"]);
1518
1519 $items = array();
1520 foreach (array_keys($_POST["item_id"]) as $id) {
1521 $items[] = $id;
1522 }
1523 $this->object->saveOrder($items);
1524
1525 ilUtil::sendSuccess($lng->txt("settings_saved"), true);
1526 $this->ctrl->redirect($this, "editOrder");
1527 }
1528
1532
1539 public function showContentObject()
1540 {
1541 $tpl = $this->tpl;
1543
1544 // need read events for parent for LP statistics
1545 require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
1547 "mcst",
1548 $this->object->getRefId(),
1549 $this->object->getId(),
1550 $ilUser->getId()
1551 );
1552
1553 // trigger LP update
1554 require_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
1555 ilLPStatusWrapper::_updateStatus($this->object->getId(), $ilUser->getId());
1556
1557 if ($this->object->getViewMode() == ilObjMediaCast::VIEW_GALLERY) {
1558 $this->showGallery();
1559 } else {
1560 $this->listItemsObject(true);
1561 }
1562
1563 $tpl->setPermanentLink($this->object->getType(), $this->object->getRefId());
1564 }
1565
1566 public function showGallery()
1567 {
1568 $tpl = $this->tpl;
1569 $ilTabs = $this->tabs;
1571
1572 $tpl->addJavascript("./Modules/MediaCast/js/MediaCast.js");
1573
1574 $ilTabs->activateTab("content");
1575
1576 $this->addContentSubTabs("content");
1577
1578 $ctpl = new ilTemplate("tpl.mcst_content.html", true, true, "Modules/MediaCast");
1579
1580 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1581 require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
1582 foreach ($this->object->getSortedItemsArray() as $item) {
1583 $mob = new ilObjMediaObject($item["mob_id"]);
1584 $med = $mob->getMediaItem("Standard");
1585
1586 $ctpl->setCurrentBlock("item");
1587 $ctpl->setVariable("TITLE", $item["title"]);
1588 $ctpl->setVariable("TIME", $item["playtime"]);
1589 $ctpl->setVariable("ID", $item["id"]);
1590
1591 if ($mob->getVideoPreviewPic() != "") {
1592 $ctpl->setVariable(
1593 "PREVIEW_PIC",
1594 ilUtil::img(ilWACSignedPath::signFile($mob->getVideoPreviewPic()), $item["title"], 320, 240)
1595 );
1596 } else {
1597 $ctpl->setVariable(
1598 "PREVIEW_PIC",
1599 ilUtil::img(ilUtil::getImagePath("mcst_preview.svg"), $item["title"], 320, 240)
1600 );
1601 }
1602
1603 // player
1604 if (is_object($med)) {
1605 include_once("./Services/MediaObjects/classes/class.ilMediaPlayerGUI.php");
1606
1607 // the news id will be used as player id, see also ilMediaCastTableGUI
1608 $mpl = new ilMediaPlayerGUI(
1609 $item["id"],
1610 $ilCtrl->getLinkTarget($this, "handlePlayerEvent", "", true, false)
1611 );
1612
1613 if (strcasecmp("Reference", $med->getLocationType()) == 0) {
1614 $mpl->setFile(ilWACSignedPath::signFile($med->getLocation()));
1615 } else {
1616 $path_to_file = ilObjMediaObject::_getURL($mob->getId()) . "/" . $med->getLocation();
1617 $mpl->setFile(ilWACSignedPath::signFile($path_to_file));
1618 }
1619 $mpl->setMimeType($med->getFormat());
1620 //$mpl->setDisplayHeight($med->getHeight());
1621 //$mpl->setDisplayHeight("480");
1622 //$mpl->setDisplayWidth("320px");
1623 $mpl->setVideoPreviewPic(ilWACSignedPath::signFile($mob->getVideoPreviewPic()));
1624 $mpl->setTitle($item["title"]);
1625 $mpl->setDescription($item["content"]);
1626 $mpl->setForceAudioPreview(true);
1627 if ($this->object->getDownloadable()) {
1628 $ilCtrl->setParameterByClass("ilobjmediacastgui", "item_id", $item["id"]);
1629 $ilCtrl->setParameterByClass("ilobjmediacastgui", "purpose", "Standard");
1630 $mpl->setDownloadLink($ilCtrl->getLinkTargetByClass("ilobjmediacastgui", "downloadItem"));
1631 }
1632 $med_alt = $mob->getMediaItem("VideoAlternative");
1633 if (is_object($med_alt)) {
1634 $mpl->setAlternativeVideoFile(ilWACSignedPath::signFile(ilObjMediaObject::_getURL($mob->getId()) . "/" .
1635 $med_alt->getLocation()));
1636 $mpl->setAlternativeVideoMimeType($med_alt->getFormat());
1637 }
1638
1639 $ctpl->setVariable("PLAYER", $mpl->getPreviewHtml());
1640 }
1641
1642
1643 $ctpl->parseCurrentBlock();
1644 }
1645
1646 $feed_icon_html = $this->getFeedIconsHTML();
1647
1648 if ($feed_icon_html != "") {
1649 $feed_icon_html = '<p>' . $feed_icon_html . '</p>';
1650 }
1651
1652 $tpl->setContent($feed_icon_html . $ctpl->get());
1653 }
1654
1661 public function convertFileObject()
1662 {
1664
1665 $this->checkPermission("write");
1666
1667 $this->mcst_item = new ilNewsItem($_GET["item_id"]);
1668 include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
1669 $mob = new ilObjMediaObject($this->mcst_item->getMobId());
1670
1671 $target_purpose = ilUtil::stripSlashes($_POST["target_purpose"]);
1672 $target_format = ilUtil::stripSlashes($_POST["target_format"]);
1673
1674 try {
1675 include_once("./Services/MediaObjects/classes/class.ilFFmpeg.php");
1676 $med = $mob->getMediaItem("Standard");
1677 $mob_file = ilObjMediaObject::_getDirectory($mob->getId()) . "/" . $med->getLocation();
1678 $new_file = ilFFmpeg::convert($mob_file, $target_format);
1680 $pi = pathinfo($new_file);
1681 $med = $mob->getMediaItem($target_purpose);
1682 if (!is_object($med)) {
1683 $med = new ilMediaItem();
1684 $med->setMobId($mob->getId());
1685 $mob->addMediaItem($med);
1686 $mob->update();
1687 $med->setPurpose($target_purpose);
1688 }
1689 $med->setFormat($target_format);
1690 $med->setLocation($pi["basename"]);
1691 $med->setLocationType("LocalFile");
1692 $med->update();
1693
1694 $add = (is_array($ret) && count($ret) > 0)
1695 ? "<br />" . implode("<br />", $ret)
1696 : "";
1697
1698 ilUtil::sendInfo($this->lng->txt("mcst_converted_file") . $add, true);
1699 } catch (ilException $e) {
1701 $add = (is_array($ret) && count($ret) > 0)
1702 ? "<br />" . implode("<br />", $ret)
1703 : "";
1704 ilUtil::sendFailure($e->getMessage() . $add, true);
1705 }
1706
1707
1708 $ilCtrl->redirect($this, "editCastItem");
1709 }
1710
1718 {
1720
1721 $this->checkPermission("write");
1722
1723 $this->mcst_item = new ilNewsItem($_GET["item_id"]);
1724 include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
1725 $mob = new ilObjMediaObject($this->mcst_item->getMobId());
1726
1727 try {
1728 $sec = (int) $_POST["sec"];
1729 if ($sec < 0) {
1730 $sec = 0;
1731 }
1732 if ($mob->getVideoPreviewPic() != "") {
1733 $mob->removeAdditionalFile($mob->getVideoPreviewPic(true));
1734 }
1735 include_once("./Services/MediaObjects/classes/class.ilFFmpeg.php");
1736 $med = $mob->getMediaItem("Standard");
1737 $mob_file = ilObjMediaObject::_getDirectory($mob->getId()) . "/" . $med->getLocation();
1738 $new_file = ilFFmpeg::extractImage(
1739 $mob_file,
1740 "mob_vpreview.png",
1741 ilObjMediaObject::_getDirectory($mob->getId()),
1742 $sec
1743 );
1744
1745 if ($new_file != "") {
1746 ilUtil::sendInfo($this->lng->txt("mcst_image_extracted"), true);
1747 } else {
1748 ilUtil::sendFailure($this->lng->txt("mcst_no_extraction_possible"), true);
1749 }
1750 } catch (ilException $e) {
1751 if (DEVMODE == 1) {
1753 $add = (is_array($ret) && count($ret) > 0)
1754 ? "<br />" . implode("<br />", $ret)
1755 : "";
1756 }
1757 ilUtil::sendFailure($e->getMessage() . $add, true);
1758 }
1759
1760
1761 $ilCtrl->redirect($this, "editCastItem");
1762 }
1763
1770 public function handlePlayerEventObject()
1771 {
1772 if ($_GET["event"] == "play") {
1773 $player = explode("_", $_GET["player"]);
1774 $news_id = (int) $player[1];
1775 include_once("./Services/News/classes/class.ilNewsItem.php");
1776 $item = new ilNewsItem($news_id);
1777 $item->increasePlayCounter();
1778
1779 $mob_id = $item->getMobId();
1780 if ($mob_id) {
1782 $this->object->handleLPUpdate($ilUser->getId(), $mob_id);
1783 }
1784 }
1785 exit;
1786 }
1787}
user()
Definition: user.php:4
$section
Definition: Utf8Test.php:83
$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 moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
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)
help()
Definition: help.php:2
global $ilCtrl
Definition: ilias.php:18
Interface Filesystem.
Definition: Filesystem.php:27
exit
Definition: login.php:29
$format
Definition: metadata.php:218
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
$url
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46