ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjMediaObjectGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
5require_once("./Services/Link/classes/class.ilInternalLinkGUI.php");
6require_once("./Services/Object/classes/class.ilObjectGUI.php");
7
20{
24 protected $access;
25
29 protected $error;
30
34 protected $help;
35
39 protected $tabs;
40
44 protected $toolbar;
45
49 protected $user;
50
51 // $adv_ref_id - $adv_type - $adv_subtype:
52 // Object, that defines the adv md records being used. Default is $this->object, but the
53 // context may set another object (e.g. media pool for media objects)
57 protected $adv_ref_id = null;
61 protected $adv_type = null;
65 protected $adv_subtype = null;
66
70 protected $media_type;
71
72 public $ctrl;
73 public $header;
75 public $enabledmapareas = true;
76
77 public function __construct($a_data, $a_id = 0, $a_call_by_reference = false, $a_prepare_output = false)
78 {
79 global $DIC;
80
81 $this->tpl = $DIC["tpl"];
82 $this->access = $DIC->access();
83 $this->error = $DIC["ilErr"];
84 $this->help = $DIC["ilHelp"];
85 $this->tabs = $DIC->tabs();
86 $this->toolbar = $DIC->toolbar();
87 $this->user = $DIC->user();
88 $lng = $DIC->language();
89 $ilCtrl = $DIC->ctrl();
90 $this->media_type = new ILIAS\MediaObjects\MediaType\MediaType();
91
92 $this->ctrl = $ilCtrl;
93 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
94 $this->lng = $lng;
95 $this->back_title = "";
96 $this->type = "mob";
97
98 $lng->loadLanguageModule("mob");
99 }
100
107 public function setAdvMdRecordObject($a_adv_ref_id, $a_adv_type, $a_adv_subtype = "-")
108 {
109 $this->adv_ref_id = $a_adv_ref_id;
110 $this->adv_type = $a_adv_type;
111 $this->adv_subtype = $a_adv_subtype;
112 }
113
119 public function getAdvMdRecordObject()
120 {
121 if ($this->adv_type == null) {
122 return [$this->ref_id, $this->obj_type, $this->sub_type];
123 }
125 }
126
127 public function setHeader($a_title = "")
128 {
129 $this->header = $a_title;
130 }
131
132 public function getHeader()
133 {
134 return $this->header;
135 }
136
142 public function setEnabledMapAreas($a_enabledmapareas)
143 {
144 $this->enabledmapareas = $a_enabledmapareas;
145 }
146
152 public function getEnabledMapAreas()
153 {
155 }
156
162 public function setWidthPreset($a_val)
163 {
164 $this->width_preset = $a_val;
165 }
166
172 public function getWidthPreset()
173 {
174 return $this->width_preset;
175 }
176
182 public function setHeightPreset($a_val)
183 {
184 $this->height_preset = $a_val;
185 }
186
192 public function getHeightPreset()
193 {
194 return $this->height_preset;
195 }
196
202 public function getForm()
203 {
204 return $this->form_gui;
205 }
206
207 public function assignObject()
208 {
209 if ($this->id != 0) {
210 $this->object = new ilObjMediaObject($this->id);
211 }
212 }
213
214 public function returnToContextObject()
215 {
216 $this->ctrl->returnToParent($this);
217 }
218
219
225 public function executeCommand()
226 {
228 $ilAccess = $this->access;
230
231 $next_class = $this->ctrl->getNextClass($this);
232 $cmd = $this->ctrl->getCmd();
233
234 switch ($next_class) {
235 case 'ilobjectmetadatagui':
236 include_once 'Services/Object/classes/class.ilObjectMetaDataGUI.php';
237 $md_gui = new ilObjectMetaDataGUI(null, $this->object->getType(), $this->object->getId());
238 // object is subtype, so we have to do it ourselves
239 $md_gui->addMDObserver($this->object, 'MDUpdateListener', 'General');
240
241 // set adv metadata record dobject
242 if ($this->adv_type != "") {
243 $md_gui->setAdvMdRecordObject($this->adv_ref_id, $this->adv_type, $this->adv_subtype);
244 }
245
246 $this->ctrl->forwardCommand($md_gui);
247 break;
248
249 case "ilimagemapeditorgui":
250 require_once("./Services/MediaObjects/classes/class.ilImageMapEditorGUI.php");
251 $image_map_edit = new ilImageMapEditorGUI($this->object);
252 $ret = $this->ctrl->forwardCommand($image_map_edit);
253 $tpl->setContent($ret);
254 $this->checkFixSize();
255 break;
256
257 case "ilfilesystemgui":
258 include_once("./Services/FileSystem/classes/class.ilFileSystemGUI.php");
259 $fs_gui = new ilFileSystemGUI(ilUtil::getWebspaceDir() . "/mobs/mm_" . $this->object->getId());
260 $fs_gui->setAllowedSuffixes(ilObjMediaObject::getRestrictedFileTypes());
261 $fs_gui->setForbiddenSuffixes(ilObjMediaObject::getForbiddenFileTypes());
262 $fs_gui->activateLabels(true, $this->lng->txt("cont_purpose"));
263 $fs_gui->setTableId("mobfs" . $this->object->getId());
264 $fs_gui->labelFile(
265 $this->object->getMediaItem("Standard")->getLocation(),
266 $this->lng->txt("cont_std_view")
267 );
268 if ($this->object->hasFullscreenItem()) {
269 $fs_gui->labelFile(
270 $this->object->getMediaItem("Fullscreen")->getLocation(),
271 $this->lng->txt("cont_fullscreen")
272 );
273 }
274 $fs_gui->addCommand($this, "assignStandardObject", $this->lng->txt("cont_assign_std"));
275 $fs_gui->addCommand($this, "assignFullscreenObject", $this->lng->txt("cont_assign_full"));
276 ilObjMediaObject::renameExecutables(ilObjMediaObject::_getDirectory($this->object->getId())); // see #20187
277 $ret = $this->ctrl->forwardCommand($fs_gui);
278 ilObjMediaObject::renameExecutables(ilObjMediaObject::_getDirectory($this->object->getId())); // see #20187
279 include_once("./Services/MediaObjects/classes/class.ilMediaSvgSanitizer.php");
280 ilMediaSvgSanitizer::sanitizeDir(ilObjMediaObject::_getDirectory($this->object->getId())); // see #20339
281 break;
282
283
284 default:
285 if (isset($_POST["editImagemapForward"]) ||
286 isset($_POST["editImagemapForward_x"]) ||
287 isset($_POST["editImagemapForward_y"])) {
288 $cmd = "editImagemapForward";
289 }
290 $cmd .= "Object";
291 $ret = $this->$cmd();
292 break;
293 }
294
295 return $ret;
296 }
297
301 public function setBackTitle($a_title)
302 {
303 $this->back_title = $a_title;
304 }
305
309 public function createObject()
310 {
312 $ilHelp = $this->help;
313
314 $ilHelp->setScreenId("create");
315 $this->initForm();
316 $tpl->setContent($this->form_gui->getHTML());
317 }
318
322 public function initForm($a_mode = "create")
323 {
325 $ilCtrl = $this->ctrl;
326
327 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
328
329 if ($a_mode == "edit") {
330 $std_item = $this->object->getMediaItem("Standard");
331 }
332
333 $this->form_gui = new ilPropertyFormGUI();
334
335 // standard view resource
336 $title = new ilTextInputGUI($lng->txt("title"), "standard_title");
337 $title->setSize(40);
338 $title->setMaxLength(120);
339 $this->form_gui->addItem($title);
340 $radio_prop = new ilRadioGroupInputGUI($lng->txt("cont_resource"), "standard_type");
341 $op1 = new ilRadioOption($lng->txt("cont_file"), "File");
342 $up = new ilFileInputGUI("", "standard_file");
344 $up->setForbiddenSuffixes(ilObjMediaObject::getForbiddenFileTypes());
345 $up->setInfo("");
346 if ($a_mode == "create" || $std_item->getLocationType() != "LocalFile") {
347 $up->setRequired(true);
348 }
349 $op1->addSubItem($up);
350 $radio_prop->addOption($op1);
351 $op2 = new ilRadioOption($lng->txt("url"), "Reference");
352 $ref = new ilUriInputGUI("", "standard_reference");
353 $ref->setInfo($lng->txt("cont_ref_helptext"));
354 $ref->setRequired(true);
355 $op2->addSubItem($ref);
356 $radio_prop->addOption($op2);
357 $radio_prop->setValue("File");
358 $this->form_gui->addItem($radio_prop);
359
360 // standard format
361 if ($a_mode == "edit") {
362 $format = new ilNonEditableValueGUI($lng->txt("cont_format"), "standard_format");
363 $format->setValue($std_item->getFormat());
364 $this->form_gui->addItem($format);
365 }
366
367 // standard size
368 $radio_size = new ilRadioGroupInputGUI($lng->txt("size"), "standard_size");
369 if ($a_mode == "edit") {
370 if ($orig_size = $std_item->getOriginalSize()) {
371 $add_str = " (" . $orig_size["width"] . " x " . $orig_size["height"] . ")";
372 }
373 $op1 = new ilRadioOption($lng->txt("cont_resource_size") . $add_str, "original");
374 $op1->setInfo($lng->txt("cont_resource_size_info"));
375 $op2 = new ilRadioOption($lng->txt("cont_custom_size"), "selected");
376 } else {
377 $op1 = new ilRadioOption($lng->txt("cont_orig_size"), "original");
378 $op1->setInfo($lng->txt("cont_resource_size_info"));
379 $op2 = new ilRadioOption($lng->txt("cont_adjust_size"), "selected");
380 }
381 $radio_size->addOption($op1);
382
383 // width height
384 include_once("./Services/MediaObjects/classes/class.ilWidthHeightInputGUI.php");
385 $width_height = new ilWidthHeightInputGUI($lng->txt("cont_width") .
386 " / " . $lng->txt("cont_height"), "standard_width_height");
387 if ($a_mode == "edit" && is_int(strpos($std_item->getFormat(), "image"))
388 && $std_item->getLocationType() == "LocalFile") {
389 $width_height->setSupportConstraintsProps(true);
390 $width_height->setConstrainProportions(true);
391 }
392 $op2->addSubItem($width_height);
393
394 // resize image
395 if ($a_mode == "edit") {
396 $std_item = $this->object->getMediaItem("Standard");
397 if (is_int(strpos($std_item->getFormat(), "image"))
398 && $std_item->getLocationType() == "LocalFile") {
399 $resize = new ilCheckboxInputGUI($lng->txt("cont_resize_img"), "standard_resize");
400 $op2->addSubItem($resize);
401 }
402 }
403
404 $radio_size->setValue("original");
405 if ($a_mode == "create" && ($this->getHeightPreset() > 0 || $this->getWidthPreset() > 0)) {
406 $radio_size->setValue("selected");
407 $width_height->setWidth($this->getWidthPreset());
408 $width_height->setHeight($this->getHeightPreset());
409 }
410 $radio_size->addOption($op2);
411 $this->form_gui->addItem($radio_size);
412
413 // standard caption
414 $caption = new ilTextAreaInputGUI($lng->txt("cont_caption"), "standard_caption");
415 $caption->setCols(30);
416 $caption->setRows(2);
417 $this->form_gui->addItem($caption);
418
419 /*$caption = new ilTextInputGUI($lng->txt("cont_caption"), "standard_caption");
420 $caption->setSize(40);
421 $caption->setMaxLength(200);
422 $this->form_gui->addItem($caption);*/
423
424 // text representation (alt text)
425 if ($a_mode == "edit" && $this->media_type->usesAltTextProperty($std_item->getFormat())) {
426 $ta = new ilTextAreaInputGUI($lng->txt("text_repr"), "text_representation");
427 $ta->setCols(30);
428 $ta->setRows(2);
429 $ta->setInfo($lng->txt("text_repr_info"));
430 $this->form_gui->addItem($ta);
431 }
432
433 // standard parameters
434 if ($a_mode == "edit" &&
435 $this->media_type->usesParameterProperty($std_item->getFormat())) {
436 if ($this->media_type->usesAutoStartParameterOnly(
437 $std_item->getLocation(),
438 $std_item->getFormat()
439 )) { // autostart
440 /*$auto = new ilCheckboxInputGUI($lng->txt("cont_autostart"), "standard_autostart");
441 $this->form_gui->addItem($auto);*/
442 } else { // parameters
443 $par = new ilTextAreaInputGUI($lng->txt("cont_parameter"), "standard_parameters");
444 $par->setRows(5);
445 $par->setCols(50);
446 $this->form_gui->addItem($par);
447 }
448 }
449
450 if ($a_mode == "edit") {
451 $full_item = $this->object->getMediaItem("Fullscreen");
452 }
453
454 // fullscreen view resource
455 $fs_sec = new ilFormSectionHeaderGUI();
456 $fs_sec->setTitle($lng->txt("cont_fullscreen"));
457 $this->form_gui->addItem($fs_sec);
458
459 $radio_prop2 = new ilRadioGroupInputGUI($lng->txt("cont_resource"), "full_type");
460 $op1 = new ilRadioOption($lng->txt("cont_none"), "None");
461 $radio_prop2->addOption($op1);
462 $op4 = new ilRadioOption($lng->txt("cont_use_same_resource_as_above"), "Standard");
463 $radio_prop2->addOption($op4);
464 $op2 = new ilRadioOption($lng->txt("cont_file"), "File");
465 $up = new ilFileInputGUI("", "full_file");
467 $up->setForbiddenSuffixes(ilObjMediaObject::getForbiddenFileTypes());
468 $up->setInfo("");
469 if ($a_mode == "create" || !$full_item || $full_item->getLocationType() != "LocalFile") {
470 $up->setRequired(true);
471 }
472 $op2->addSubItem($up);
473 $radio_prop2->addOption($op2);
474 $op3 = new ilRadioOption($lng->txt("url"), "Reference");
475 $ref = new ilUriInputGUI("", "full_reference");
476 $ref->setInfo($lng->txt("cont_ref_helptext"));
477 $ref->setRequired(true);
478 $op3->addSubItem($ref);
479 $radio_prop2->addOption($op3);
480 $radio_prop2->setValue("None");
481 $this->form_gui->addItem($radio_prop2);
482
483 // fullscreen format
484 if ($a_mode == "edit") {
485 if ($this->object->hasFullscreenItem()) {
486 $format = new ilNonEditableValueGUI($lng->txt("cont_format"), "full_format");
487 $format->setValue($full_item->getFormat());
488 $this->form_gui->addItem($format);
489 }
490 }
491
492 // fullscreen size
493 $full_support_constraint_props = false;
494 $radio_size = new ilRadioGroupInputGUI($lng->txt("size"), "full_size");
495 if ($a_mode == "edit") {
496 $add_str = "";
497 if ($this->object->hasFullscreenItem() && ($orig_size = $full_item->getOriginalSize())) {
498 $add_str = " (" . $orig_size["width"] . " x " . $orig_size["height"] . ")";
499
500 if (is_int(strpos($full_item->getFormat(), "image"))
501 && $full_item->getLocationType() == "LocalFile") {
502 $full_support_constraint_props = true;
503 }
504 }
505 $op1 = new ilRadioOption($lng->txt("cont_resource_size") . $add_str, "original");
506 $op1->setInfo($lng->txt("cont_resource_size_info"));
507 $op2 = new ilRadioOption($lng->txt("cont_custom_size"), "selected");
508 } else {
509 $op1 = new ilRadioOption($lng->txt("cont_orig_size"), "original");
510 $op1->setInfo($lng->txt("cont_resource_size_info"));
511 $op2 = new ilRadioOption($lng->txt("cont_adjust_size"), "selected");
512 }
513 $radio_size->addOption($op1);
514
515 // width/height
516 $width_height = new ilWidthHeightInputGUI($lng->txt("cont_width") .
517 " / " . $lng->txt("cont_height"), "full_width_height");
518 if ($full_support_constraint_props) {
519 $width_height->setSupportConstraintsProps(true);
520 $width_height->setConstrainProportions(true);
521 }
522 $op2->addSubItem($width_height);
523
524 // resize image
525 if ($a_mode == "edit") {
526 $full_item = $this->object->getMediaItem("Fullscreen");
527 if ($this->object->hasFullscreenItem() &&
528 is_int(strpos($full_item->getFormat(), "image")) &&
529 $full_item->getLocationType() == "LocalFile") {
530 $resize = new ilCheckboxInputGUI(
531 $lng->txt("cont_resize_img"),
532 "full_resize"
533 );
534 $op2->addSubItem($resize);
535 }
536 }
537
538 $radio_size->setValue("original");
539 $radio_size->addOption($op2);
540 $this->form_gui->addItem($radio_size);
541
542 // fullscreen caption
543 $caption = new ilTextAreaInputGUI($lng->txt("cont_caption"), "full_caption");
544 $caption->setCols(30);
545 $caption->setRows(2);
546 $this->form_gui->addItem($caption);
547
548 /*$caption = new ilTextInputGUI($lng->txt("cont_caption"), "full_caption");
549 $caption->setSize(40);
550 $caption->setMaxLength(200);
551 $this->form_gui->addItem($caption);*/
552
553 // text representation (alt text)
554 if ($a_mode == "edit" && $this->object->hasFullscreenItem() && $this->media_type->usesAltTextProperty($std_item->getFormat())) {
555 $ta = new ilTextAreaInputGUI($lng->txt("text_repr"), "full_text_representation");
556 $ta->setCols(30);
557 $ta->setRows(2);
558 $ta->setInfo($lng->txt("text_repr_info"));
559 $this->form_gui->addItem($ta);
560 }
561
562
563 // fullscreen parameters
564 if ($a_mode == "edit" && $this->object->hasFullscreenItem() &&
565 $this->media_type->usesParameterProperty($full_item->getFormat())) {
566 if ($this->media_type->usesAutoStartParameterOnly(
567 $full_item->getLocation(),
568 $full_item->getFormat()
569 )) {
570 /*$auto = new ilCheckboxInputGUI($lng->txt("cont_autostart"), "full_autostart");
571 $this->form_gui->addItem($auto);*/
572 } else {
573 $par = new ilTextAreaInputGUI($lng->txt("cont_parameter"), "full_parameters");
574 $par->setRows(5);
575 $par->setCols(50);
576 $this->form_gui->addItem($par);
577 }
578 }
579
580 $this->form_gui->setTitle($lng->txt("cont_insert_mob"));
581 if ($a_mode == "edit") {
582 $this->form_gui->addCommandButton("saveProperties", $lng->txt("save"));
583 } else {
584 $this->form_gui->addCommandButton("save", $lng->txt("save"));
585 $this->form_gui->addCommandButton("cancel", $lng->txt("cancel"));
586 }
587 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
588 }
589
596 protected function checkFixSize()
597 {
598 $std_item = $this->object->getMediaItem("Standard");
599 if ($std_item->getWidth() == "" || $std_item->getHeight() == "") {
600 ilUtil::sendFailure($this->lng->txt("mob_no_fixed_size_map_editing"));
601 }
602 }
603
604
609 public function getValues()
610 {
611 $values = array();
612
613 $values["standard_title"] = $this->object->getTitle();
614
615 $std_item = $this->object->getMediaItem("Standard");
616 if ($std_item->getLocationType() == "LocalFile") {
617 $values["standard_type"] = "File";
618 $values["standard_file"] = $std_item->getLocation();
619 } else {
620 $values["standard_type"] = "Reference";
621 $values["standard_reference"] = $std_item->getLocation();
622 }
623 $values["standard_format"] = $std_item->getFormat();
624 $values["standard_width_height"]["width"] = $std_item->getWidth();
625 $values["standard_width_height"]["height"] = $std_item->getHeight();
626 $values["standard_width_height"]["constr_prop"] = true;
627
628 $values["standard_size"] = "selected";
629
630 $orig_size = $std_item->getOriginalSize();
631 if ($std_item->getWidth() == "" && $std_item->getHeight() == "") {
632 $values["standard_size"] = "original";
633 $values["standard_width_height"]["width"] = $orig_size["width"];
634 $values["standard_width_height"]["height"] = $orig_size["height"];
635 }
636
637 $values["standard_caption"] = $std_item->getCaption();
638 $values["text_representation"] = $std_item->getTextRepresentation();
639 if ($this->media_type->usesAutoStartParameterOnly(
640 $std_item->getLocation(),
641 $std_item->getFormat()
642 )) {
643 /*$par = $std_item->getParameters();
644 if ($par["autostart"]) {
645 $values["standard_autostart"] = true;
646 }*/
647 } else {
648 $values["standard_parameters"] = $std_item->getParameterString();
649 }
650
651 $values["full_type"] = "None";
652 $values["full_size"] = "original";
653 if ($this->object->hasFullScreenItem()) {
654 $full_item = $this->object->getMediaItem("Fullscreen");
655 if ($full_item->getLocationType() == "LocalFile") {
656 $values["full_type"] = "File";
657 $values["full_file"] = $full_item->getLocation();
658 } else {
659 $values["full_type"] = "Reference";
660 $values["full_reference"] = $full_item->getLocation();
661 }
662 $values["full_format"] = $full_item->getFormat();
663 $values["full_width_height"]["width"] = $full_item->getWidth();
664 $values["full_width_height"]["height"] = $full_item->getHeight();
665 $values["full_width_height"]["constr_prop"] = true;
666
667 $values["full_size"] = "selected";
668
669 $orig_size = $full_item->getOriginalSize();
670 if ($full_item->getWidth() == "" &&
671 $full_item->getHeight() == "") {
672 $values["full_size"] = "original";
673 $values["full_width_height"]["width"] = $orig_size["width"];
674 $values["full_width_height"]["height"] = $orig_size["height"];
675 }
676 $values["full_caption"] = $full_item->getCaption();
677 if ($this->media_type->usesAutoStartParameterOnly(
678 $full_item->getLocation(),
679 $full_item->getFormat()
680 )) {
681 /*$par = $full_item->getParameters();
682 if ($par["autostart"]) {
683 $values["full_autostart"] = true;
684 }*/
685 } else {
686 $values["full_parameters"] = $full_item->getParameterString();
687 }
688 $values["full_text_representation"] = $full_item->getTextRepresentation();
689 }
690
691 $this->form_gui->setValuesByArray($values);
692 }
693
697 public function saveObject()
698 {
701
702 $this->initForm();
703 if ($this->form_gui->checkInput()) {
704 $this->object = new ilObjMediaObject();
706 ilUtil::sendSuccess($lng->txt("saved_media_object"), true);
707 return $this->object;
708 } else {
709 $this->form_gui->setValuesByPost();
710 $tpl->setContent($this->form_gui->getHTML());
711 return false;
712 }
713 }
714
721 public function checkFormInput()
722 {
723 if (!$this->form_gui->checkInput()) {
724 $this->form_gui->setValuesByPost();
725 return false;
726 }
727 return true;
728 }
729
730
734 public static function setObjectPerCreationForm($a_mob)
735 {
736 // determinte title and format
737 if (trim($_POST["standard_title"]) != "") {
738 $title = trim($_POST["standard_title"]);
739 } else {
740 if ($_POST["standard_type"] == "File") {
741 $title = $_FILES['standard_file']['name'];
742 } else {
743 $title = ilUtil::stripSlashes($_POST["standard_reference"]);
744 }
745 }
746
747 $a_mob->setTitle($title);
748 $a_mob->setDescription("");
749 $a_mob->create();
750
751 // determine and create mob directory, move uploaded file to directory
752 //$mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob->getId();
753 $a_mob->createDirectory();
754 $mob_dir = ilObjMediaObject::_getDirectory($a_mob->getId());
755
756 $media_item = new ilMediaItem();
757 $a_mob->addMediaItem($media_item);
758 $media_item->setPurpose("Standard");
759
760 if ($_POST["standard_type"] == "File") {
761 $file_name = ilObjMediaObject::fixFilename($_FILES['standard_file']['name']);
762 $file = $mob_dir . "/" . $file_name;
764 $_FILES['standard_file']['tmp_name'],
765 $file_name,
766 $file
767 );
768
769 // get mime type
771 $location = $file_name;
772
773 // resize standard images
774 if ($_POST["standard_size"] != "original" &&
775 is_int(strpos($format, "image"))) {
777 $file,
778 (int) $_POST["standard_width_height"]["width"],
779 (int) $_POST["standard_width_height"]["height"],
780 (boolean) $_POST["standard_width_height"]["contr_prop"]
781 );
782 }
783
784 // set real meta and object data
785 $media_item->setFormat($format);
786 $media_item->setLocation($location);
787 $media_item->setLocationType("LocalFile");
788 } else { // standard type: reference
790 $media_item->setFormat($format);
791 $media_item->setLocation(ilUtil::secureLink(ilUtil::stripSlashes($_POST["standard_reference"])));
792 $media_item->setLocationType("Reference");
793 }
794 $a_mob->setDescription($format);
795
796 // determine width and height of known image types
798 $format,
799 $_POST["standard_type"],
800 $mob_dir . "/" . $location,
801 $media_item->getLocation(),
802 $_POST["standard_width_height"]["constr_prop"],
803 ($_POST["standard_size"] == "original"),
804 $_POST["standard_width_height"]["width"],
805 $_POST["standard_width_height"]["height"]
806 );
807 $media_item->setWidth($wh["width"]);
808 $media_item->setHeight($wh["height"]);
809 if ($wh["info"] != "") {
810 ilUtil::sendInfo($wh["info"], true);
811 }
812
813 if ($_POST["standard_caption"] != "") {
814 $media_item->setCaption(ilUtil::stripSlashes($_POST["standard_caption"]));
815 }
816
817
818 $media_item->setHAlign("Left");
819
820 // fullscreen view
821 if ($_POST["full_type"] != "None") {
822 $media_item2 = new ilMediaItem();
823 $a_mob->addMediaItem($media_item2);
824 $media_item2->setPurpose("Fullscreen");
825
826 // move file / set format and location
827 if ($_POST["full_type"] == "File") {
828 $format = $location = "";
829 if ($_FILES['full_file']['name'] != "") {
830 $full_file_name = ilObjMediaObject::fixFilename($_FILES['full_file']['name']);
831 $file = $mob_dir . "/" . $full_file_name;
833 $_FILES['full_file']['tmp_name'],
834 $full_file_name,
835 $file
836 );
838 $location = $full_file_name;
839 }
840 } elseif ($_POST["full_type"] == "Standard" && $_POST["standard_type"] == "File") {
841 $location = $file_name;
842 }
843
844 // resize file
845 if ($_POST["full_type"] == "File" ||
846 ($_POST["full_type"] == "Standard" && $_POST["standard_type"] == "File")) {
847 if (($_POST["full_size"] != "original" &&
848 is_int(strpos($format, "image")))
849 ) {
851 $file,
852 (int) $_POST["full_width_height"]["width"],
853 (int) $_POST["full_width_height"]["height"],
854 (boolean) $_POST["full_width_height"]["constr_prop"]
855 );
856 }
857
858 $media_item2->setFormat($format);
859 $media_item2->setLocation($location);
860 $media_item2->setLocationType("LocalFile");
861 $type = "File";
862 }
863
864 if ($_POST["full_type"] == "Reference") {
865 $format = $location = "";
866 if ($_POST["full_reference"] != "") {
867 $format = ilObjMediaObject::getMimeType($_POST["full_reference"], true);
868 $location = ilUtil::stripSlashes($_POST["full_reference"]);
869 }
870 }
871
872 if ($_POST["full_type"] == "Reference" ||
873 ($_POST["full_type"] == "Standard" && $_POST["standard_type"] == "Reference")) {
874 $media_item2->setFormat($format);
875 $media_item2->setLocation($location);
876 $media_item2->setLocationType("Reference");
877 $type = "Reference";
878 }
879
880 // determine width and height of known image types
882 $format,
883 $type,
884 $mob_dir . "/" . $location,
885 $media_item2->getLocation(),
886 $_POST["full_width_height"]["constr_prop"],
887 ($_POST["full_size"] == "original"),
888 $_POST["full_width_height"]["width"],
889 $_POST["full_width_height"]["height"]
890 );
891
892 $media_item2->setWidth($wh["width"]);
893 $media_item2->setHeight($wh["height"]);
894
895 if ($_POST["full_caption"] != "") {
896 $media_item2->setCaption(ilUtil::stripSlashes($_POST["full_caption"]));
897 }
898 }
899
901 include_once("./Services/MediaObjects/classes/class.ilMediaSvgSanitizer.php");
902 ilMediaSvgSanitizer::sanitizeDir($mob_dir); // see #20339
903 $a_mob->update();
904 }
905
906
910 public function cancelObject()
911 {
912 $this->ctrl->returnToParent($this);
913 }
914
918 public function editObject()
919 {
921
922 $this->setPropertiesSubTabs("general");
923
924 $this->initForm("edit");
925 $this->getValues();
926 $tpl->setContent($this->form_gui->getHTML());
927 }
928
929
933 public function resizeImagesObject()
934 {
935 // directory
936 $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
937
938 // standard item
939 $std_item = $this->object->getMediaItem("Standard");
940 if ($std_item->getLocationType() == "LocalFile" &&
941 is_int(strpos($std_item->getFormat(), "image"))
942 ) {
943 $file = $mob_dir . "/" . $std_item->getLocation();
945 $file,
946 $std_item->getWidth(),
947 $std_item->getHeight()
948 );
949 $std_item->setLocation($location);
950 $std_item->update();
951 }
952
953 // fullscreen item
954 if ($this->object->hasFullScreenItem()) {
955 $full_item = $this->object->getMediaItem("Fullscreen");
956 if ($full_item->getLocationType() == "LocalFile" &&
957 is_int(strpos($full_item->getFormat(), "image"))
958 ) {
959 $file = $mob_dir . "/" . $full_item->getLocation();
961 $file,
962 $full_item->getWidth(),
963 $full_item->getHeight()
964 );
965 $full_item->setLocation($location);
966 $full_item->update();
967 }
968 }
969
970 $this->ctrl->redirect($this, "edit");
971 }
972
973
977 public function getStandardSizeObject()
978 {
979 $std_item = $this->object->getMediaItem("Standard");
980 $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
981
982 if ($std_item->getLocationType() == "LocalFile") {
983 $file = $mob_dir . "/" . $std_item->getLocation();
984
985 include_once("./Services/MediaObjects/classes/class.ilMediaImageUtil.php");
987
988 $std_item->setWidth($size[0]);
989 $std_item->setHeight($size[1]);
990 $this->object->update();
991 }
992 $this->ctrl->redirect($this, "edit");
993 }
994
995
999 public function getFullscreenSizeObject()
1000 {
1001 $full_item = $this->object->getMediaItem("Fullscreen");
1002 $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
1003
1004 if ($full_item->getLocationType() == "LocalFile") {
1005 $file = $mob_dir . "/" . $full_item->getLocation();
1006 include_once("./Services/MediaObjects/classes/class.ilMediaImageUtil.php");
1008 $full_item->setWidth($size[0]);
1009 $full_item->setHeight($size[1]);
1010 $this->object->update();
1011 }
1012 $this->ctrl->redirect($this, "edit");
1013 }
1014
1018 public function savePropertiesObject()
1019 {
1020 $lng = $this->lng;
1021 $tpl = $this->tpl;
1022
1023 $this->initForm("edit");
1024 if ($this->form_gui->checkInput()) {
1025 $title = trim($_POST["standard_title"]);
1026 $this->object->setTitle($title);
1027
1028 $std_item = $this->object->getMediaItem("Standard");
1029 $location = $std_item->getLocation();
1030 $format = $std_item->getFormat();
1031 if ($_POST["standard_type"] == "Reference") {
1032 $format = ilObjMediaObject::getMimeType(ilUtil::stripSlashes($_POST["standard_reference"]), true);
1033 $std_item->setFormat($format);
1034 $std_item->setLocation(ilUtil::secureLink(ilUtil::stripSlashes($_POST["standard_reference"])));
1035 $std_item->setLocationType("Reference");
1036 }
1037 $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
1038 if ($_POST["standard_type"] == "File") {
1039 $resize = false;
1040 if ($_FILES['standard_file']['name'] != "") {
1041 $file_name = ilObjMediaObject::fixFilename($_FILES['standard_file']['name']);
1042 $file = $mob_dir . "/" . $file_name;
1044 $_FILES['standard_file']['tmp_name'],
1045 $file_name,
1046 $file
1047 );
1048
1049 // get mime type
1051 $location = $file_name;
1052
1053 $resize = true;
1054 } elseif ($_POST["standard_resize"]) {
1055 $file = $mob_dir . "/" . $location;
1056 $resize = true;
1057 }
1058
1059 // resize
1060 if ($resize) {
1061 if ($_POST["standard_size"] != "original" &&
1062 is_int(strpos($format, "image"))) {
1064 $file,
1065 (int) $_POST["standard_width_height"]["width"],
1066 (int) $_POST["standard_width_height"]["height"],
1067 (boolean) $_POST["standard_width_height"]["contr_prop"]
1068 );
1069 }
1070 $std_item->setFormat($format);
1071 $std_item->setLocation($location);
1072 }
1073
1074 $std_item->setLocationType("LocalFile");
1075 }
1076 $this->object->setDescription($format);
1077 // determine width and height of known image types
1079 $format,
1080 $_POST["standard_type"],
1081 $mob_dir . "/" . $location,
1082 $std_item->getLocation(),
1083 $_POST["standard_width_height"]["constr_prop"],
1084 ($_POST["standard_size"] == "original"),
1085 $_POST["standard_width_height"]["width"],
1086 $_POST["standard_width_height"]["height"]
1087 );
1088 if ($wh["info"] != "") {
1089 ilUtil::sendInfo($wh["info"], true);
1090 }
1091 $std_item->setWidth($wh["width"]);
1092 $std_item->setHeight($wh["height"]);
1093
1094 // set caption
1095 $std_item->setCaption(ilUtil::stripSlashes($_POST["standard_caption"]));
1096
1097 // text representation
1098 $std_item->setTextRepresentation(ilUtil::stripSlashes($_POST["text_representation"]));
1099
1100 // set parameters
1101 if ($this->media_type->usesParameterProperty($std_item->getFormat())) {
1102 if ($this->media_type->usesAutoStartParameterOnly(
1103 $std_item->getLocation(),
1104 $std_item->getFormat()
1105 )) {
1106 /*
1107 if ($_POST["standard_autostart"]) { // save only autostart flag
1108 $std_item->setParameters('autostart="true"');
1109 } else {
1110 $std_item->setParameters("");
1111 }*/
1112 } else {
1113 $std_item->setParameters(ilUtil::stripSlashes(utf8_decode($_POST["standard_parameters"])));
1114 }
1115 }
1116
1117 // "None" selected
1118 if ($_POST["full_type"] == "None") {
1119 if ($this->object->hasFullscreenItem()) { // delete existing
1120 $this->object->removeMediaItem("Fullscreen");
1121 }
1122 } else { // Not "None" -> we need one
1123 if ($this->object->hasFullscreenItem()) { // take existing one
1124 $full_item = $this->object->getMediaItem("Fullscreen");
1125 } else { // create one
1126 $full_item = new ilMediaItem();
1127 $this->object->addMediaItem($full_item);
1128 $full_item->setPurpose("Fullscreen");
1129 }
1130 $location = $full_item->getLocation();
1131 $format = $full_item->getFormat();
1132 if ($_POST["full_type"] == "Reference") {
1134 $full_item->setFormat($format);
1135 $full_item->setLocationType("Reference");
1136 $location = ilUtil::stripSlashes($_POST["full_reference"]);
1137 $type = "Reference";
1138 }
1139 $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
1140 if ($_POST["full_type"] == "File") {
1141 $resize = false;
1142 if ($_FILES['full_file']['name'] != "") {
1143 $full_file_name = ilObjMediaObject::fixFilename($_FILES['full_file']['name']);
1144 $file = $mob_dir . "/" . $full_file_name;
1146 $_FILES['full_file']['tmp_name'],
1147 $full_file_name,
1148 $file
1149 );
1150
1152 $location = $full_file_name;
1153
1154 $resize = true;
1155 } elseif ($_POST["full_resize"]) {
1156 $file = $mob_dir . "/" . $location;
1157 $resize = true;
1158 }
1159
1160 // resize
1161 if ($resize) {
1162 if ($_POST["full_size"] != "original" &&
1163 is_int(strpos($format, "image"))) {
1165 $file,
1166 (int) $_POST["full_width_height"]["width"],
1167 (int) $_POST["full_width_height"]["height"],
1168 (boolean) $_POST["full_width_height"]["contr_prop"]
1169 );
1170 }
1171 $full_item->setFormat($format);
1172 $full_item->setLocation($location);
1173 }
1174
1175 $full_item->setLocationType("LocalFile");
1176 $type = "File";
1177 }
1178 if ($_POST["full_type"] == "Standard") {
1179 $format = $std_item->getFormat();
1180 $location = $std_item->getLocation();
1181 $full_item->setLocationType($std_item->getLocationType());
1182 $full_item->setFormat($format);
1183 $full_item->setLocation($location);
1184 $type = $std_item->getLocationType();
1185 if ($type == "LocalFile") {
1186 $type = "File";
1187 }
1188 // resize image
1189 //echo "-".$_POST["full_size"]."-".is_int(strpos($format, "image"))."-".$full_item->getLocationType()."-";
1190 if ($_POST["full_size"] != "original" &&
1191 is_int(strpos($format, "image")) &&
1192 $full_item->getLocationType() == "LocalFile") {
1193 $file = $mob_dir . "/" . $location;
1195 $file,
1196 (int) $_POST["full_width_height"]["width"],
1197 (int) $_POST["full_width_height"]["height"],
1198 (boolean) $_POST["full_width_height"]["contr_prop"]
1199 );
1200 }
1201 }
1202
1203 // determine width and height of known image types
1205 $format,
1206 $type,
1207 $mob_dir . "/" . $location,
1208 $full_item->getLocation(),
1209 $_POST["full_width_height"]["constr_prop"],
1210 ($_POST["full_size"] == "original"),
1211 $_POST["full_width_height"]["width"],
1212 $_POST["full_width_height"]["height"]
1213 );
1214 if ($wh["info"] != "") {
1215 ilUtil::sendInfo($wh["info"], true);
1216 }
1217
1218 $full_item->setWidth($wh["width"]);
1219 $full_item->setHeight($wh["height"]);
1220 $full_item->setLocation($location);
1221
1222 $full_item->setCaption(ilUtil::stripSlashes($_POST["full_caption"]));
1223
1224 // text representation
1225 $full_item->setTextRepresentation(ilUtil::stripSlashes($_POST["full_text_representation"]));
1226
1227
1228 // set parameters
1229 if ($this->media_type->usesParameterProperty($std_item->getFormat())) {
1230 if ($this->media_type->usesAutoStartParameterOnly(
1231 $std_item->getLocation(),
1232 $std_item->getFormat()
1233 )) {
1234 /*
1235 if ($_POST["full_autostart"]) { // save only autostart flag
1236 $full_item->setParameters('autostart="true"');
1237 } else {
1238 $full_item->setParameters("");
1239 }*/
1240 } else {
1241 $full_item->setParameters(ilUtil::stripSlashes(utf8_decode($_POST["full_parameters"])));
1242 }
1243 }
1244 }
1245
1247 include_once("./Services/MediaObjects/classes/class.ilMediaSvgSanitizer.php");
1248 ilMediaSvgSanitizer::sanitizeDir(ilObjMediaObject::_getDirectory($this->object->getId())); // see #20339
1249
1250 $this->object->update();
1251 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1252 $this->ctrl->redirect($this, "edit");
1253 } else {
1254 $this->form_gui->setValuesByPost();
1255 $tpl->setContent($this->form_gui->getHTML());
1256 }
1257 }
1258
1259
1263 public function editFilesObject()
1264 {
1265 // standard item
1266 $std_item = $this->object->getMediaItem("Standard");
1267 if ($this->object->hasFullscreenItem()) {
1268 $full_item = $this->object->getMediaItem("Fullscreen");
1269 }
1270
1271 // create table
1272 require_once("./Services/Table/classes/class.ilTableGUI.php");
1273 $tbl = new ilTableGUI();
1274
1275 // determine directory
1276 $cur_subdir = $_GET["cdir"];
1277 if ($_GET["newdir"] == "..") {
1278 $cur_subdir = substr($cur_subdir, 0, strrpos($cur_subdir, "/"));
1279 } else {
1280 if (!empty($_GET["newdir"])) {
1281 if (!empty($cur_subdir)) {
1282 $cur_subdir = $cur_subdir . "/" . $_GET["newdir"];
1283 } else {
1284 $cur_subdir = $_GET["newdir"];
1285 }
1286 }
1287 }
1288
1289 $cur_subdir = str_replace(".", "", $cur_subdir);
1290 $mob_dir = ilUtil::getWebspaceDir() . "/mobs/mm_" . $this->object->getId();
1291 $cur_dir = (!empty($cur_subdir))
1292 ? $mob_dir . "/" . $cur_subdir
1293 : $mob_dir;
1294
1295 // load files templates
1296 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.mob_files.html", "Services/MediaObjects");
1297
1298 $this->ctrl->setParameter($this, "cdir", urlencode($cur_subdir));
1299 $this->tpl->setVariable("FORMACTION1", $this->ctrl->getFormAction($this));
1300 //echo "--".$this->getTargetScript().
1301 //"&hier_id=".$_GET["hier_id"]."&cdir=".$cur_subdir."&cmd=post"."--<br>";
1302 $this->tpl->setVariable("TXT_NEW_DIRECTORY", $this->lng->txt("cont_new_dir"));
1303 $this->tpl->setVariable("TXT_NEW_FILE", $this->lng->txt("cont_new_file"));
1304 $this->tpl->setVariable("CMD_NEW_DIR", "createDirectory");
1305 $this->tpl->setVariable("CMD_NEW_FILE", "uploadFile");
1306 $this->tpl->setVariable("BTN_NEW_DIR", $this->lng->txt("create"));
1307 $this->tpl->setVariable("BTN_NEW_FILE", $this->lng->txt("upload"));
1308
1309 //
1310 $this->tpl->addBlockfile("FILE_TABLE", "files", "tpl.table.html");
1311
1312 // load template for table content data
1313 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.mob_file_row.html", "Services/MediaObjects");
1314
1315 $num = 0;
1316
1317 $obj_str = ($this->call_by_reference) ? "" : "&obj_id=" . $this->obj_id;
1318 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1319
1320 $tbl->setTitle($this->lng->txt("cont_files") . " " . $cur_subdir);
1321 //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
1322
1323 $tbl->setHeaderNames(array("", "", $this->lng->txt("cont_dir_file"),
1324 $this->lng->txt("cont_size"), $this->lng->txt("cont_purpose")));
1325
1326 $cols = array("", "", "dir_file", "size", "purpose");
1327 $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"],
1328 "cmd" => "editFiles", "hier_id" => $_GET["hier_id"], "item_id" => $_GET["item_id"]);
1329 $tbl->setHeaderVars($cols, $header_params);
1330 $tbl->setColumnWidth(array("1%", "1%", "33%", "33%", "32%"));
1331
1332 // control
1333 $tbl->setOrderColumn($_GET["sort_by"]);
1334 $tbl->setOrderDirection($_GET["sort_order"]);
1335 $tbl->setLimit($_GET["limit"]);
1336 $tbl->setOffset($_GET["offset"]);
1337 $tbl->setMaxCount($this->maxcount); // ???
1338 //$tbl->setMaxCount(30); // ???
1339
1340 $this->tpl->setVariable("COLUMN_COUNTS", 5);
1341
1342 // delete button
1343 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
1344 $this->tpl->setCurrentBlock("tbl_action_btn");
1345 $this->tpl->setVariable("BTN_NAME", "deleteFile");
1346 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
1347 $this->tpl->parseCurrentBlock();
1348
1349 $this->tpl->setCurrentBlock("tbl_action_btn");
1350 $this->tpl->setVariable("BTN_NAME", "assignStandard");
1351 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("cont_assign_std"));
1352 $this->tpl->parseCurrentBlock();
1353
1354 $this->tpl->setCurrentBlock("tbl_action_btn");
1355 $this->tpl->setVariable("BTN_NAME", "assignFullscreen");
1356 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("cont_assign_full"));
1357 $this->tpl->parseCurrentBlock();
1358
1359 // footer
1360 $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
1361 //$tbl->disable("footer");
1362
1363 $entries = ilUtil::getDir($cur_dir);
1364
1365 //$objs = ilUtil::sortArray($objs, $_GET["sort_by"], $_GET["sort_order"]);
1366 $tbl->setMaxCount(count($entries));
1367 $entries = array_slice($entries, $_GET["offset"], $_GET["limit"]);
1368
1369 $tbl->render();
1370 if (count($entries) > 0) {
1371 $i = 0;
1372 foreach ($entries as $entry) {
1373 if (($entry["entry"] == ".") || ($entry["entry"] == ".." && empty($cur_subdir))) {
1374 continue;
1375 }
1376
1377 //$this->tpl->setVariable("ICON", $obj["title"]);
1378 if ($entry["type"] == "dir") {
1379 $this->tpl->setCurrentBlock("FileLink");
1380 $this->ctrl->setParameter($this, "cdir", $cur_subdir);
1381 $this->ctrl->setParameter($this, "newdir", rawurlencode($entry["entry"]));
1382 $this->tpl->setVariable("LINK_FILENAME", $this->ctrl->getLinkTarget($this, "editFiles"));
1383 $this->tpl->setVariable("TXT_FILENAME", $entry["entry"]);
1384 $this->tpl->parseCurrentBlock();
1385
1386 $this->tpl->setVariable("ICON", "<img src=\"" .
1387 ilUtil::getImagePath("icon_cat.svg") . "\">");
1388 } else {
1389 $this->tpl->setCurrentBlock("File");
1390 $this->tpl->setVariable("TXT_FILENAME2", $entry["entry"]);
1391 $this->tpl->parseCurrentBlock();
1392 }
1393
1394 $this->tpl->setCurrentBlock("tbl_content");
1395 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
1396 $this->tpl->setVariable("CSS_ROW", $css_row);
1397
1398 $this->tpl->setVariable("TXT_SIZE", $entry["size"]);
1399 $this->tpl->setVariable("CHECKBOX_ID", $entry["entry"]);
1400 $compare = (!empty($cur_subdir))
1401 ? $cur_subdir . "/" . $entry["entry"]
1402 : $entry["entry"];
1403 $purpose = array();
1404 if ($std_item->getLocation() == $compare) {
1405 $purpose[] = $this->lng->txt("cont_std_view");
1406 }
1407 if ($this->object->hasFullscreenItem()) {
1408 if ($full_item->getLocation() == $compare) {
1409 $purpose[] = $this->lng->txt("cont_fullscreen");
1410 }
1411 }
1412 $this->tpl->setVariable("TXT_PURPOSE", implode(", ", $purpose));
1413
1414 $this->tpl->parseCurrentBlock();
1415 }
1416 } //if is_array
1417 else {
1418 $this->tpl->setCurrentBlock("notfound");
1419 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1420 $this->tpl->setVariable("NUM_COLS", 4);
1421 $this->tpl->parseCurrentBlock();
1422 }
1423
1424 $this->tpl->parseCurrentBlock();
1425 }
1426
1427
1431 public function createDirectoryObject()
1432 {
1433 //echo "cdir:".$_GET["cdir"].":<br>";
1434 // determine directory
1435 $cur_subdir = str_replace(".", "", $_GET["cdir"]);
1436 $mob_dir = ilUtil::getWebspaceDir() . "/mobs/mm_" . $this->object->getId();
1437 $cur_dir = (!empty($cur_subdir))
1438 ? $mob_dir . "/" . $cur_subdir
1439 : $mob_dir;
1440
1441 $new_dir = str_replace(".", "", $_POST["new_dir"]);
1442 $new_dir = str_replace("/", "", $new_dir);
1443
1444 if (!empty($new_dir)) {
1445 ilUtil::makeDir($cur_dir . "/" . $new_dir);
1446 }
1447 $this->ctrl->saveParameter($this, "cdir");
1448 $this->ctrl->redirect($this, "editFiles");
1449 }
1450
1454 public function uploadFileObject()
1455 {
1456 // determine directory
1457 $cur_subdir = str_replace(".", "", $_GET["cdir"]);
1458 $mob_dir = ilUtil::getWebspaceDir() . "/mobs/mm_" . $this->object->getId();
1459 $cur_dir = (!empty($cur_subdir))
1460 ? $mob_dir . "/" . $cur_subdir
1461 : $mob_dir;
1462 if (is_file($_FILES["new_file"]["tmp_name"])) {
1463 $file_name = ilObjMediaObject::fixFilename($_FILES["new_file"]["name"]);
1464 $file = $cur_dir . "/" . $file_name;
1466 $_FILES['new_file']['tmp_name'],
1467 $file_name,
1468 $file
1469 );
1470 }
1472 include_once("./Services/MediaObjects/classes/class.ilMediaSvgSanitizer.php");
1473 ilMediaSvgSanitizer::sanitizeDir($mob_dir); // see #20339
1474
1475 $this->ctrl->saveParameter($this, "cdir");
1476 $this->ctrl->redirect($this, "editFiles");
1477 }
1478
1482 public function assignStandardObject($a_file)
1483 {
1484 // determine directory
1485 $cur_subdir = dirname($a_file);
1486 $mob_dir = ilUtil::getWebspaceDir() . "/mobs/mm_" . $this->object->getId();
1487 $cur_dir = (!empty($cur_subdir))
1488 ? $mob_dir . "/" . $cur_subdir
1489 : $mob_dir;
1490 $file = $cur_dir . "/" . basename($a_file);
1491 $location = $a_file;
1492
1493 if (!is_file($file)) {
1494 $this->ilias->raiseError($this->lng->txt("cont_select_file"), $this->ilias->error_obj->MESSAGE);
1495 }
1496
1497 $std_item = $this->object->getMediaItem("Standard");
1498 $std_item->setLocationType("LocalFile");
1499 $std_item->setLocation($location);
1501 $std_item->setFormat($format);
1502 $this->object->update();
1503 // $this->ctrl->saveParameter($this, "cdir");
1504 $this->ctrl->redirectByClass("ilfilesystemgui", "listFiles");
1505 }
1506
1507
1511 public function assignFullscreenObject($a_file)
1512 {
1513 // determine directory
1514 $cur_subdir = dirname($a_file);
1515 $mob_dir = ilUtil::getWebspaceDir() . "/mobs/mm_" . $this->object->getId();
1516 $cur_dir = (!empty($cur_subdir))
1517 ? $mob_dir . "/" . $cur_subdir
1518 : $mob_dir;
1519 $file = $cur_dir . "/" . basename($a_file);
1520 $location = $a_file;
1521
1522 if (!is_file($file)) {
1523 $this->ilias->raiseError($this->lng->txt("cont_select_file"), $this->ilias->error_obj->MESSAGE);
1524 }
1525
1526 if (!$this->object->hasFullScreenItem()) { // create new fullscreen item
1527 $std_item = $this->object->getMediaItem("Standard");
1528 $mob_dir = ilUtil::getWebspaceDir() . "/mobs/mm_" . $this->object->getId();
1529 $file = $mob_dir . "/" . $location;
1530 $full_item = new ilMediaItem();
1531 $full_item->setMobId($std_item->getMobId());
1532 $full_item->setLocation($location);
1533 $full_item->setLocationType("LocalFile");
1534 $full_item->setFormat(ilObjMediaObject::getMimeType($file));
1535 $full_item->setPurpose("Fullscreen");
1536 $this->object->addMediaItem($full_item);
1537 } else { // alter existing fullscreen item
1538 $full_item = $this->object->getMediaItem("Fullscreen");
1539
1540 $full_item->setLocationType("LocalFile");
1541 $full_item->setLocation($location);
1543 $full_item->setFormat($format);
1544 }
1545 $this->object->update();
1546 // $this->ctrl->saveParameter($this, "cdir");
1547 $this->ctrl->redirectByClass("ilfilesystemgui", "listFiles");
1548 }
1549
1550
1554 public function removeFullscreenObject()
1555 {
1556 $this->object->removeMediaItem("Fullscreen");
1557 $this->object->update();
1558
1559 $this->ctrl->redirect($this, "edit");
1560 }
1561
1562
1566 public function addFullscreenObject()
1567 {
1568 if (!$this->object->hasFullScreenItem()) {
1569 $std_item = $this->object->getMediaItem("Standard");
1570 $full_item = new ilMediaItem();
1571 $full_item->setMobId($std_item->getMobId());
1572 $full_item->setLocation($std_item->getLocation());
1573 $full_item->setLocationType($std_item->getLocationType());
1574 $full_item->setFormat($std_item->getFormat());
1575 $full_item->setWidth($std_item->getWidth());
1576 $full_item->setHeight($std_item->getHeight());
1577 $full_item->setCaption($std_item->getCaption());
1578 $full_item->setTextRepresentation($std_item->getTextRepresentation());
1579 $full_item->setPurpose("Fullscreen");
1580 $this->object->addMediaItem($full_item);
1581
1582 $this->object->update();
1583 }
1584
1585 $this->ctrl->redirect($this, "edit");
1586 }
1587
1588
1592 public function deleteFileObject()
1593 {
1594 if (!isset($_POST["file"])) {
1595 $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
1596 }
1597
1598 if (count($_POST["file"]) > 1) {
1599 $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"), $this->ilias->error_obj->MESSAGE);
1600 }
1601
1602 if ($_POST["file"][0] == "..") {
1603 $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
1604 }
1605
1606 $cur_subdir = str_replace(".", "", $_GET["cdir"]);
1607 $mob_dir = ilUtil::getWebspaceDir() . "/mobs/mm_" . $this->object->getId();
1608 $cur_dir = (!empty($cur_subdir))
1609 ? $mob_dir . "/" . $cur_subdir
1610 : $mob_dir;
1611 $file = $cur_dir . "/" . $_POST["file"][0];
1612 $location = (!empty($cur_subdir))
1613 ? $cur_subdir . "/" . $_POST["file"][0]
1614 : $_POST["file"][0];
1615
1616 $full_item = $this->object->getMediaItem("Fullscreen");
1617 $std_item = $this->object->getMediaItem("Standard");
1618
1619 if ($location == $std_item->getLocation()) {
1620 $this->ilias->raiseError($this->lng->txt("cont_cant_del_std"), $this->ilias->error_obj->MESSAGE);
1621 }
1622
1623 if ($this->object->hasFullScreenItem()) {
1624 if ($location == $full_item->getLocation()) {
1625 $this->ilias->raiseError($this->lng->txt("cont_cant_del_full"), $this->ilias->error_obj->MESSAGE);
1626 }
1627 }
1628
1629 if (@is_dir($file)) {
1630 if (substr($std_item->getLocation(), 0, strlen($location)) == $location) {
1631 $this->ilias->raiseError($this->lng->txt("cont_std_is_in_dir"), $this->ilias->error_obj->MESSAGE);
1632 }
1633
1634 if ($this->object->hasFullScreenItem()) {
1635 if (substr($full_item->getLocation(), 0, strlen($location)) == $location) {
1636 $this->ilias->raiseError($this->lng->txt("cont_full_is_in_dir"), $this->ilias->error_obj->MESSAGE);
1637 }
1638 }
1639 }
1640
1641 if (@is_file($file)) {
1642 unlink($file);
1643 }
1644
1645 if (@is_dir($file)) {
1646 ilUtil::delDir($file);
1647 }
1648
1649 $this->ctrl->saveParameter($this, "cdir");
1650 $this->ctrl->redirect($this, "editFiles");
1651 }
1652
1656 public function showAllUsagesObject()
1657 {
1658 $this->showUsagesObject(true);
1659 }
1660
1661
1665 public function showUsagesObject($a_all = false)
1666 {
1667 $tpl = $this->tpl;
1668 $ilTabs = $this->tabs;
1669 $ilTabs = $this->tabs;
1670 $lng = $this->lng;
1671 $ilCtrl = $this->ctrl;
1672
1673 $ilTabs->addSubTab(
1674 "current_usages",
1675 $lng->txt("cont_current_usages"),
1676 $ilCtrl->getLinkTarget($this, "showUsages")
1677 );
1678
1679 $ilTabs->addSubTab(
1680 "all_usages",
1681 $lng->txt("cont_all_usages"),
1682 $ilCtrl->getLinkTarget($this, "showAllUsages")
1683 );
1684
1685 if ($a_all) {
1686 $ilTabs->activateSubTab("all_usages");
1687 $cmd = "showAllUsages";
1688 } else {
1689 $ilTabs->activateSubTab("current_usages");
1690 $cmd = "showUsages";
1691 }
1692
1693 include_once("./Services/MediaObjects/classes/class.ilMediaObjectUsagesTableGUI.php");
1694 $usages_table = new ilMediaObjectUsagesTableGUI(
1695 $this,
1696 $cmd,
1697 $this->object,
1698 $a_all
1699 );
1700 $tpl->setContent($usages_table->getHTML());
1701 }
1702
1706 public static function _getMediaInfoHTML(&$a_mob)
1707 {
1708 global $DIC;
1709
1710 $lng = $DIC->language();
1711
1712 $tpl = new ilTemplate("tpl.media_info.html", true, true, "Services/MediaObjects");
1713 $types = array("Standard", "Fullscreen");
1714 foreach ($types as $type) {
1715 if ($type == "Fullscreen" && !$a_mob->hasFullScreenItem()) {
1716 continue;
1717 }
1718
1719 $med = $a_mob->getMediaItem($type);
1720 if (!$med) {
1721 return "";
1722 }
1723
1724 $tpl->setCurrentBlock("media_info");
1725 if ($type == "Standard") {
1726 $tpl->setVariable("TXT_PURPOSE", $lng->txt("cont_std_view"));
1727 } else {
1728 $tpl->setVariable("TXT_PURPOSE", $lng->txt("cont_fullscreen"));
1729 }
1730 $tpl->setVariable("TXT_TYPE", $lng->txt("cont_" . strtolower($med->getLocationType())));
1731 $tpl->setVariable("VAL_LOCATION", $med->getLocation());
1732 if ($med->getLocationType() == "LocalFile") {
1733 $file = ilObjMediaObject::_getDirectory($med->getMobId()) . "/" . $med->getLocation();
1734 if (is_file($file)) {
1735 $size = filesize($file);
1736 } else {
1737 $size = 0;
1738 }
1739 $tpl->setVariable("VAL_FILE_SIZE", " ($size " . $lng->txt("bytes") . ")");
1740 }
1741 $tpl->setVariable("TXT_FORMAT", $lng->txt("cont_format"));
1742 $tpl->setVariable("VAL_FORMAT", $med->getFormat());
1743 if ($med->getWidth() != "" && $med->getHeight() != "") {
1744 $tpl->setCurrentBlock("size");
1745 $tpl->setVariable("TXT_SIZE", $lng->txt("size"));
1746 $tpl->setVariable("VAL_SIZE", $med->getWidth() . "x" . $med->getHeight());
1747 $tpl->parseCurrentBlock();
1748 }
1749
1750 // original size
1751 if ($orig_size = $med->getOriginalSize()) {
1752 if ($orig_size["width"] != $med->getWidth() ||
1753 $orig_size["height"] != $med->getHeight()) {
1754 $tpl->setCurrentBlock("orig_size");
1755 $tpl->setVariable("TXT_ORIG_SIZE", $lng->txt("cont_orig_size"));
1756 $tpl->setVariable("ORIG_WIDTH", $orig_size["width"]);
1757 $tpl->setVariable("ORIG_HEIGHT", $orig_size["height"]);
1758 $tpl->parseCurrentBlock();
1759 }
1760 }
1761
1762 // output caption
1763 if ($med && strlen($med->getCaption())) {
1764 $tpl->setCurrentBlock('additional_info');
1765 $tpl->setVariable('ADD_INFO', $lng->txt('cont_caption') . ': ' . $med->getCaption());
1766 $tpl->parseCurrentBlock();
1767 }
1768
1769 // output keywords
1770 if ($type == "Standard") {
1771 include_once './Services/MetaData/classes/class.ilMDKeyword.php';
1772 if (count($kws = ilMDKeyword::lookupKeywords(0, $med->getMobId()))) {
1773 $tpl->setCurrentBlock('additional_info');
1774 $tpl->setVariable('ADD_INFO', $lng->txt('keywords') . ': ' . implode(', ', $kws));
1775 $tpl->parseCurrentBlock();
1776 }
1777 }
1778
1779 $tpl->setCurrentBlock("media_info");
1780 $tpl->parseCurrentBlock();
1781 }
1782
1783 return $tpl->get();
1784 }
1785
1789 //function setAdminTabs()
1790 public function setTabs()
1791 {
1792 //echo "setAdminTabs should not be called.";
1793
1794 // catch feedback message
1795 $this->getTabs();
1796
1797 //$this->tpl->clearHeader();
1798 if (is_object($this->object) && strtolower(get_class($this->object)) == "ilobjmediaobject") {
1799 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_mob.svg"));
1800 $this->tpl->setTitle($this->object->getTitle());
1801 } else {
1802 //$title = $this->object->getTitle();
1803 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_mob.svg"));
1804 $this->tpl->setTitle($this->lng->txt("cont_create_mob"));
1805 }
1806 }
1807
1808
1812 public function getTabs()
1813 {
1814 $ilHelp = $this->help;
1815
1816 $ilHelp->setScreenIdComponent("mob");
1817
1818 if (is_object($this->object) && strtolower(get_class($this->object)) == "ilobjmediaobject"
1819 && $this->object->getId() > 0) {
1820 // object properties
1821 $this->tabs_gui->addTarget(
1822 "cont_mob_def_prop",
1823 $this->ctrl->getLinkTarget($this, "edit"),
1824 "edit",
1825 get_class($this)
1826 );
1827
1828 $st_item = $this->object->getMediaItem("Standard");
1829
1830 // link areas
1831
1832 if (is_object($st_item) && $this->getEnabledMapAreas()) {
1833 $format = $st_item->getFormat();
1834 if (substr($format, 0, 5) == "image" && !is_int(strpos($format, "svg"))) {
1835 $this->tabs_gui->addTarget(
1836 "cont_def_map_areas",
1837 $this->ctrl->getLinkTargetByClass(
1838 array("ilobjmediaobjectgui", "ilimagemapeditorgui"),
1839 "editMapAreas"
1840 ),
1841 "editMapAreas",
1842 "ilimagemapeditorgui"
1843 );
1844 }
1845 }
1846
1847 // object usages
1848 $this->tabs_gui->addTarget(
1849 "cont_mob_usages",
1850 $this->ctrl->getLinkTarget($this, "showUsages"),
1851 "showUsages",
1852 get_class($this)
1853 );
1854
1855 // object files
1856 $std_item = $this->object->getMediaItem("Standard");
1857 $full_item = $this->object->getMediaItem("Fullscreen");
1858 $mset = new ilSetting("mobs");
1859 if ($mset->get("file_manager_always") ||
1860 ($this->media_type->usesParameterProperty($std_item->getFormat()) ||
1861 (is_object($full_item) && $this->media_type->usesParameterProperty($full_item->getFormat())))
1862 ) {
1863 $this->tabs_gui->addTarget(
1864 "cont_files",
1865 $this->ctrl->getLinkTargetByClass(
1866 array("ilobjmediaobjectgui", "ilfilesystemgui"),
1867 "listFiles"
1868 ),
1869 "",
1870 "ilfilesystemgui"
1871 );
1872 }
1873
1874 include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
1875 $mdgui = new ilObjectMetaDataGUI(null, $this->object->getType(), $this->object->getId());
1876 $mdtab = $mdgui->getTab("ilobjmediaobjectgui");
1877 if ($mdtab) {
1878 $this->tabs_gui->addTarget(
1879 "meta_data",
1880 $mdtab,
1881 "",
1882 "ilmdeditorgui"
1883 );
1884 }
1885 }
1886
1887 // back to upper context
1888 if ($this->back_title != "") {
1889 $this->tabs_gui->setBackTarget(
1890 $this->back_title,
1891 $this->ctrl->getParentReturn($this)
1892 );
1893 }
1894 }
1895
1902 public function showVideoToolObject()
1903 {
1904 $tpl = $this->tpl;
1905
1906 include_once("./Services/MediaObjects/classes/class.ilFFmpeg.php");
1907
1908 /*$codecs = ilFFmpeg::getSupportedCodecsInfo();
1909 $codec_str = implode($codecs, "<br />");
1910 $tpl->setContent($codec_str);*/
1911
1913 $formats_str = implode("<br />", $formats);
1914 $tpl->setContent($formats_str);
1915 }
1916
1917
1921 public static function includePresentationJS($a_tpl = null)
1922 {
1923 global $DIC;
1924
1925 $tpl = $DIC["tpl"];
1926
1927 if ($a_tpl == null) {
1928 $a_tpl = $tpl;
1929 }
1930
1931 include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
1932 iljQueryUtil::initjQUery($a_tpl);
1933 include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
1934 $a_tpl->addJavascript(iljQueryUtil::getLocalMaphilightPath());
1935 $a_tpl->addJavascript("./Services/COPage/js/ilCOPagePres.js");
1936
1937 include_once("./Services/MediaObjects/classes/class.ilPlayerUtil.php");
1939 }
1940
1946 public function setPropertiesSubTabs($a_active)
1947 {
1948 $ilTabs = $this->tabs;
1949 $ilCtrl = $this->ctrl;
1950 $lng = $this->lng;
1951
1952 $ilTabs->activateTab("cont_mob_def_prop");
1953
1954 $ilTabs->addSubTab(
1955 "general",
1956 $lng->txt("mob_general"),
1957 $ilCtrl->getLinkTarget($this, "edit")
1958 );
1959
1960 if ($this->object->getMediaItem("Standard")->getFormat() == "video/webm" ||
1961 $this->object->getMediaItem("Standard")->getFormat() == "video/mp4") {
1962 $ilTabs->addSubTab(
1963 "subtitles",
1964 $lng->txt("mob_subtitles"),
1965 $ilCtrl->getLinkTarget($this, "listSubtitleFiles")
1966 );
1967 }
1968
1969 $ilTabs->activateSubTab($a_active);
1970 }
1971
1978 public function listSubtitleFilesObject()
1979 {
1980 $ilToolbar = $this->toolbar;
1981 $tpl = $this->tpl;
1982 $ilCtrl = $this->ctrl;
1983 $lng = $this->lng;
1985
1986 $this->setPropertiesSubTabs("subtitles");
1987
1988 // upload file
1989 $ilToolbar->setFormAction($ilCtrl->getFormAction($this), true);
1990 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
1991 $fi = new ilFileInputGUI($lng->txt("mob_subtitle_file") . " (.srt)", "subtitle_file");
1992 $fi->setSuffixes(array("srt"));
1993 $ilToolbar->addInputItem($fi, true);
1994
1995 // language
1996 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1997 include_once("./Services/MetaData/classes/class.ilMDLanguageItem.php");
1999 $si = new ilSelectInputGUI($this->lng->txt("mob_language"), "language");
2000 $si->setOptions($options);
2001 $si->setValue($ilUser->getLanguage());
2002 $ilToolbar->addInputItem($si, true);
2003
2004 $ilToolbar->addFormButton($lng->txt("upload"), "uploadSubtitleFile");
2005
2006 $ilToolbar->addSeparator();
2007 $ilToolbar->addFormButton($lng->txt("mob_upload_multi_srt"), "uploadMultipleSubtitleFileForm");
2008
2009 include_once("./Services/MediaObjects/classes/class.ilMobSubtitleTableGUI.php");
2010 $tab = new ilMobSubtitleTableGUI($this, "listSubtitleFiles", $this->object);
2011
2012 $tpl->setContent($tab->getHTML());
2013 }
2014
2022 {
2023 $lng = $this->lng;
2024 $ilCtrl = $this->ctrl;
2025
2026 if ($this->object->uploadSrtFile($_FILES["subtitle_file"]["tmp_name"], ilUtil::stripSlashes($_POST["language"]))) {
2027 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2028 }
2029 $ilCtrl->redirect($this, "listSubtitleFiles");
2030 }
2031
2036 {
2037 $ilCtrl = $this->ctrl;
2038 $tpl = $this->tpl;
2039 $lng = $this->lng;
2040
2041 $lng->loadLanguageModule("meta");
2042
2043 if (!is_array($_POST["srt"]) || count($_POST["srt"]) == 0) {
2044 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
2045 $ilCtrl->redirect($this, "listSubtitleFiles");
2046 } else {
2047 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2048 $cgui = new ilConfirmationGUI();
2049 $cgui->setFormAction($ilCtrl->getFormAction($this));
2050 $cgui->setHeaderText($lng->txt("mob_really_delete_srt"));
2051 $cgui->setCancel($lng->txt("cancel"), "listSubtitleFiles");
2052 $cgui->setConfirm($lng->txt("delete"), "deleteSrtFiles");
2053
2054 foreach ($_POST["srt"] as $i) {
2055 $cgui->addItem("srt[]", $i, "subtitle_" . $i . ".srt (" . $lng->txt("meta_l_" . $i) . ")");
2056 }
2057
2058 $tpl->setContent($cgui->getHTML());
2059 }
2060 }
2061
2065 public function deleteSrtFilesObject()
2066 {
2067 $lng = $this->lng;
2068 $ilCtrl = $this->ctrl;
2069
2070 foreach ($_POST["srt"] as $i) {
2071 if (strlen($i) == 2 && !is_int(strpos($i, "."))) {
2072 $this->object->removeAdditionalFile("srt/subtitle_" . $i . ".srt");
2073 }
2074 }
2075 ilUtil::sendSuccess($lng->txt("mob_srt_files_deleted"), true);
2076 $ilCtrl->redirect($this, "listSubtitleFiles");
2077 }
2078
2086 {
2087 $ilToolbar = $this->toolbar;
2088 $lng = $this->lng;
2089 $ilCtrl = $this->ctrl;
2090
2091 ilUtil::sendInfo($lng->txt("mob_upload_multi_srt_howto"));
2092
2093 $this->setPropertiesSubTabs("subtitles");
2094
2095 // upload file
2096 $ilToolbar->setFormAction($ilCtrl->getFormAction($this), true);
2097 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
2098 $fi = new ilFileInputGUI($lng->txt("mob_subtitle_file") . " (.zip)", "subtitle_file");
2099 $fi->setSuffixes(array("zip"));
2100 $ilToolbar->addInputItem($fi, true);
2101
2102 $ilToolbar->addFormButton($lng->txt("upload"), "uploadMultipleSubtitleFile");
2103 }
2104
2109 {
2110 try {
2111 $this->object->uploadMultipleSubtitleFile(ilUtil::stripSlashesArray($_FILES["subtitle_file"]));
2112 $this->ctrl->redirect($this, "showMultiSubtitleConfirmationTable");
2113 } catch (ilMediaObjectsException $e) {
2114 ilUtil::sendFailure($e->getMessage(), true);
2115 $this->ctrl->redirect($this, "uploadMultipleSubtitleFileForm");
2116 }
2117 }
2118
2123 {
2124 $tpl = $this->tpl;
2125
2126 $this->setPropertiesSubTabs("subtitles");
2127
2128 include_once("./Services/MediaObjects/classes/class.ilMultiSrtConfirmationTable2GUI.php");
2129 $tab = new ilMultiSrtConfirmationTable2GUI($this, "showMultiSubtitleConfirmationTable");
2130 $tpl->setContent($tab->getHTML());
2131 }
2132
2136 public function cancelMultiSrtObject()
2137 {
2138 $this->object->clearMultiSrtDirectory();
2139 $this->ctrl->redirect($this, "listSubtitleFiles");
2140 }
2141
2145 public function saveMultiSrtObject()
2146 {
2147 $ilCtrl = $this->ctrl;
2148 $srt_files = $this->object->getMultiSrtFiles();
2149 if (is_array($_POST["file"])) {
2150 foreach ($_POST["file"] as $f) {
2151 foreach ($srt_files as $srt_file) {
2152 if ($f == $srt_file["filename"]) {
2153 $this->object->uploadSrtFile($this->object->getMultiSrtUploadDir() . "/" . $srt_file["filename"], $srt_file["lang"], "rename");
2154 }
2155 }
2156 }
2157 }
2158 $this->object->clearMultiSrtDirectory();
2159 $ilCtrl->redirect($this, "listSubtitleFiles");
2160 }
2161}
user()
Definition: user.php:4
$size
Definition: RandomTest.php:84
$location
Definition: buildRTE.php:44
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
This class represents a checkbox property in a property form.
Confirmation screen class.
static getSupportedFormatsInfo()
Get all supported formats.
This class represents a file property in a property form.
File System Explorer GUI class.
This class represents a section header in a property form.
User interface class for map editor.
static lookupKeywords($a_rbac_id, $a_obj_id, $a_return_ids=false)
Lookup Keywords.
static getImageSize($a_location)
Get image size from location.
Class ilMediaItem Media Item, component of a media object (file or reference)
TableGUI class for media object usages listing.
General exception class for media objects.
static sanitizeDir($a_path)
Sanitize directory recursively.
TableGUI class for subtitle list.
List srt files from zip file for upload confirmation.
This class represents a non editable value in a property form.
Class ilObjMediaObjectGUI.
showUsagesObject($a_all=false)
show all usages of mob
getAdvMdRecordObject()
Get adv md record type.
deleteSrtFilesObject()
Delete srt files.
setHeightPreset($a_val)
Set height preset.
cancelMultiSrtObject()
Cancel Multi Feedback.
static includePresentationJS($a_tpl=null)
Include media object presentation JS.
uploadSubtitleFileObject()
Upload srt file.
getValues()
Get values for form.
showAllUsagesObject()
Show all media object usages (incl history)
saveObject()
create new media object in dom and update page in db
createDirectoryObject()
create directory
showMultiSubtitleConfirmationTableObject()
List of srt files in zip file.
static _getMediaInfoHTML(&$a_mob)
get media info as html
getStandardSizeObject()
set original size of standard file
confirmSrtDeletionObject()
Confirm srt file deletion.
listSubtitleFilesObject()
List subtitls files.
removeFullscreenObject()
remove fullscreen view
uploadMultipleSubtitleFileFormObject()
Upload multiple stubtitles.
savePropertiesObject()
save properties in db and return to page edit screen
assignFullscreenObject($a_file)
assign file to fullscreen view
executeCommand()
Execute current command.
getWidthPreset()
Get width preset.
setWidthPreset($a_val)
Set width preset.
createObject()
create new media object form
setEnabledMapAreas($a_enabledmapareas)
Set Enable map areas.
setBackTitle($a_title)
set title for back tab
editFilesObject()
administrate files of media object
editObject()
edit media object properties
deleteFileObject()
delete object file
assignStandardObject($a_file)
assign file to standard view
setPropertiesSubTabs($a_active)
Set subtabs for properties.
getFullscreenSizeObject()
set original size of fullscreen file
setAdvMdRecordObject($a_adv_ref_id, $a_adv_type, $a_adv_subtype="-")
Set object, that defines the adv md records being used.
resizeImagesObject()
resize images to specified size
initForm($a_mode="create")
Init creation form.
getHeightPreset()
Get height preset.
saveMultiSrtObject()
Save selected srt files as new srt files.
uploadMultipleSubtitleFileObject()
Upload multiple subtitles.
__construct($a_data, $a_id=0, $a_call_by_reference=false, $a_prepare_output=false)
static setObjectPerCreationForm($a_mob)
Set media object values from creation form.
addFullscreenObject()
add fullscreen view
showVideoToolObject()
Show video tools.
getEnabledMapAreas()
Get Enable map areas.
Class ilObjMediaObject.
static getMimeType($a_file, $a_external=null)
get mime type for file
static getRestrictedFileTypes()
Get restricted file types (this is for the input form, this list will be empty, if "allowed list" is ...
static _getDirectory($a_mob_id)
Get absolute directory.
static fixFilename($a_name)
Fix filename of uploaded file.
static _determineWidthHeight( $a_format, $a_type, $a_file, $a_reference, $a_constrain_proportions, $a_use_original, $a_user_width, $a_user_height)
Determine width and height.
static _resizeImage($a_file, $a_width, $a_height, $a_constrain_prop=false)
resize image and return new image file ("_width_height" string appended)
static getForbiddenFileTypes()
Get forbidden file types.
static renameExecutables($a_dir)
Rename executables.
Class ilObjectGUI Basic methods of all Output classes.
Class ilObjectMetaDataGUI.
static initMediaElementJs($a_tpl=null)
Init mediaelement.js scripts.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.
ILIAS Setting Class.
Class ilTableGUI.
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.
Legacy Uri input.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static getWebspaceDir($mode="filesystem")
get webspace directory
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows)
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static secureLink($a_str)
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 makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static stripSlashesArray($a_arr, $a_strip_html=true, $a_allow="")
Strip slashes from array.
This class represents a width/height item in a property form.
static getLocalMaphilightPath()
Get local path of maphilight file.
$formats
Definition: date.php:77
global $DIC
Definition: goto.php:24
help()
Definition: help.php:2
$ilUser
Definition: imgupload.php:18
$format
Definition: metadata.php:218
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
redirection script todo: (a better solution should control the processing via a xml file)
$ret
Definition: parser.php:6
$type
$cols
Definition: xhr_table.php:11