ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilPCMediaObjectGUI.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/COPage/classes/class.ilPageContentGUI.php");
5require_once("./Services/COPage/classes/class.ilMediaAliasItem.php");
6require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
7
20// Todo: extend ilObjMediaObjectGUI !?
22{
26 protected $tabs;
27
31 protected $access;
32
36 protected $toolbar;
37
41 protected $user;
42
43 public $header;
44 public $ctrl;
45
46 public function __construct($a_pg_obj, $a_content_obj, $a_hier_id = 0, $a_pc_id = "")
47 {
48 global $DIC;
49
50 $this->tpl = $DIC["tpl"];
51 $this->lng = $DIC->language();
52 $this->tabs = $DIC->tabs();
53 $this->access = $DIC->access();
54 $this->toolbar = $DIC->toolbar();
55 $this->user = $DIC->user();
56 $ilCtrl = $DIC->ctrl();
57
58 $this->ctrl = $ilCtrl;
59 // var_dump($_POST);
60 //ilUtil::printBacktrace(10); exit;
61 //echo "constructor target:".$_SESSION["il_map_il_target"].":<br>";
62 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
63
64 $this->setCharacteristics(array(
65 "MediaContainer" => $this->lng->txt("cont_Media"),
66 "MediaContainerMax50" => "MediaContainerMax50",
67 "MediaContainerFull100" => "MediaContainerFull100"
68 ));
69 }
70
71 public function setHeader($a_title = "")
72 {
73 $this->header = $a_title;
74 }
75
76 public function getHeader()
77 {
78 return $this->header;
79 }
80
86 public function setEnabledMapAreas($a_enabledmapareas)
87 {
88 $this->enabledmapareas = $a_enabledmapareas;
89 }
90
96 public function getEnabledMapAreas()
97 {
98 return $this->enabledmapareas;
99 }
100
104 public function executeCommand()
105 {
108 $ilTabs = $this->tabs;
109
110 $this->getCharacteristicsOfCurrentStyle("media_cont"); // scorm-2004
111
112 // get next class that processes or forwards current command
113 $next_class = $this->ctrl->getNextClass($this);
114
115 // get current command
116 $cmd = $this->ctrl->getCmd();
117
118 if (is_object($this->content_obj)) {
119 $this->tpl->clearHeader();
120 $tpl->setTitleIcon(ilUtil::getImagePath("icon_mob.svg"));
121 $this->getTabs($this->tabs_gui);
122
123 $mob = $this->content_obj->getMediaObject();
124 if (is_object($mob)) {
125 $tpl->setVariable("HEADER", $lng->txt("mob") . ": " .
126 $this->content_obj->getMediaObject()->getTitle());
127 $mob_gui = new ilObjMediaObjectGUI("", $this->content_obj->getMediaObject()->getId(), false, false);
128 $mob_gui->setBackTitle($this->page_back_title);
129 $mob_gui->setEnabledMapAreas($this->getEnabledMapAreas());
130 $mob_gui->getTabs($this->tabs_gui);
131 }
132 } else {
133 }
134
135 switch ($next_class) {
136 case "ilobjmediaobjectgui":
137 include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
138 $this->tpl->clearHeader();
139 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_mob.svg"));
140 $this->tpl->setTitle($this->lng->txt("mob") . ": " .
141 $this->content_obj->getMediaObject()->getTitle());
142 $mob_gui = new ilObjMediaObjectGUI("", $this->content_obj->getMediaObject()->getId(), false, false);
143 $mob_gui->setBackTitle($this->page_back_title);
144 $mob_gui->setEnabledMapAreas($this->getEnabledMapAreas());
145 $ret = $this->ctrl->forwardCommand($mob_gui);
146 break;
147
148 // instance image map editing
149 case "ilpcimagemapeditorgui":
150 require_once("./Services/COPage/classes/class.ilPCImageMapEditorGUI.php");
151 $ilTabs->setTabActive("cont_inst_map_areas");
152 $image_map_edit = new ilPCImageMapEditorGUI(
153 $this->content_obj,
154 $this->pg_obj
155 );
156 $ret = $this->ctrl->forwardCommand($image_map_edit);
157 $tpl->setContent($ret);
158 $this->checkFixSize();
159 break;
160
161 default:
162 $ret = $this->$cmd();
163 break;
164 }
165
166 return $ret;
167 }
168
172 public function insert($a_post_cmd = "edpost", $a_submit_cmd = "create_mob", $a_input_error = false)
173 {
174 $ilTabs = $this->tabs;
178
179 if ($_GET["subCmd"] == "insertNew") {
180 $_SESSION["cont_media_insert"] = "insertNew";
181 }
182 if ($_GET["subCmd"] == "insertFromPool") {
183 $_SESSION["cont_media_insert"] = "insertFromPool";
184 }
185
186 if (($_GET["subCmd"] == "") && $_SESSION["cont_media_insert"] != "") {
187 $_GET["subCmd"] = $_SESSION["cont_media_insert"];
188 }
189
190 switch ($_GET["subCmd"]) {
191 case "insertFromPool":
192 $this->insertFromPool();
193 break;
194
195 case "poolSelection":
196 $this->poolSelection();
197 break;
198
199 case "selectPool":
200 $this->selectPool();
201 break;
202
203 case "insertNew":
204 default:
205 $this->getTabs($ilTabs, true);
206 $ilTabs->setSubTabActive("cont_new_mob");
207
208 include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
209 if ($a_input_error) {
211 } else {
212 $mob_gui = new ilObjMediaObjectGUI("");
213 $mob_gui->initForm("create");
214 $form = $mob_gui->getForm();
215 }
216 $form->setFormAction($ilCtrl->getFormAction($this, "create_mob"));
217 $form->clearCommandButtons();
218 $form->addCommandButton("create_mob", $lng->txt("save"));
219 $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
220
221 $this->displayValidationError();
222
223 $tpl->setContent($form->getHTML());
224
225 break;
226 }
227 }
228
232 public function changeObjectReference()
233 {
234 $ilTabs = $this->tabs;
237
238 if ($_GET["subCmd"] == "insertNew") {
239 $_SESSION["cont_media_insert"] = "insertNew";
240 }
241 if ($_GET["subCmd"] == "insertFromPool") {
242 $_SESSION["cont_media_insert"] = "insertFromPool";
243 }
244
245 if (($_GET["subCmd"] == "") && $_SESSION["cont_media_insert"] != "") {
246 $_GET["subCmd"] = $_SESSION["cont_media_insert"];
247 }
248
249 switch ($_GET["subCmd"]) {
250 case "insertFromPool":
251 $this->insertFromPool(true);
252 break;
253
254 case "poolSelection":
255 $this->poolSelection(true);
256 break;
257
258 case "selectPool":
259 $this->selectPool(true);
260 break;
261
262 case "insertNew":
263 default:
264 $ilCtrl->setParameter($this, "subCmd", "changeObjectReference");
265 $this->getTabs($ilTabs, true, true);
266 $ilTabs->setSubTabActive("cont_new_mob");
267
268 $this->displayValidationError();
269
270 $mob_gui = new ilObjMediaObjectGUI("");
271 $mob_gui->initForm("create");
272 $form = $mob_gui->getForm();
273 $form->setFormAction($ilCtrl->getFormAction($this));
274 $form->clearCommandButtons();
275 $form->addCommandButton("createNewObjectReference", $lng->txt("save"));
276 $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
277 $this->tpl->setContent($form->getHTML());
278 }
279 }
280
281
285 protected function checkFixSize()
286 {
287 $std_alias_item = new ilMediaAliasItem(
288 $this->dom,
289 $this->getHierId(),
290 "Standard",
291 $this->content_obj->getPcId()
292 );
293 $std_item = $this->content_obj->getMediaObject()->getMediaItem("Standard");
294
295 $ok = false;
296 if (($std_alias_item->getWidth() != "" && $std_alias_item->getHeight() != "")) {
297 $ok = true;
298 }
299 if ($std_alias_item->getWidth() == "" && $std_alias_item->getHeight() == ""
300 && $std_item->getWidth() != "" && $std_item->getHeight() != "") {
301 $ok = true;
302 }
303
304 if (!$ok) {
305 ilUtil::sendFailure($this->lng->txt("mob_no_fixed_size_map_editing"));
306 }
307 }
308
312 public function insertFromPool($a_change_obj_ref = false)
313 {
315 $ilAccess = $this->access;
316 $ilTabs = $this->tabs;
319 $ilToolbar = $this->toolbar;
320
321 if ($_SESSION["cont_media_pool"] != "" &&
322 $ilAccess->checkAccess("write", "", $_SESSION["cont_media_pool"])
323 && ilObject::_lookupType(ilObject::_lookupObjId($_SESSION["cont_media_pool"])) == "mep") {
324 $html = "";
325 $tb = new ilToolbarGUI();
326
327 $ilCtrl->setParameter($this, "subCmd", "poolSelection");
328 if ($a_change_obj_ref) {
329 $tb->addButton(
330 $lng->txt("cont_switch_to_media_pool"),
331 $ilCtrl->getLinkTarget($this, "changeObjectReference")
332 );
333 } else {
334 $tb->addButton(
335 $lng->txt("cont_switch_to_media_pool"),
336 $ilCtrl->getLinkTarget($this, "insert")
337 );
338 }
339 $ilCtrl->setParameter($this, "subCmd", "");
340
341 $html = $tb->getHTML();
342
343 $this->getTabs($ilTabs, true, $a_change_obj_ref);
344 $ilTabs->setSubTabActive("cont_mob_from_media_pool");
345
346 include_once("./Modules/MediaPool/classes/class.ilObjMediaPool.php");
347 include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
348 $pool = new ilObjMediaPool($_SESSION["cont_media_pool"]);
349 $ilCtrl->setParameter($this, "subCmd", "insertFromPool");
350 $tcmd = ($a_change_obj_ref)
351 ? "changeObjectReference"
352 : "insert";
353 $tmode = ($a_change_obj_ref)
356 $mpool_table = new ilMediaPoolTableGUI(
357 $this,
358 $tcmd,
359 $pool,
360 "mep_folder",
361 $tmode
362 );
363
364 $html.= $mpool_table->getHTML();
365
366 $tpl->setContent($html);
367 } else {
368 $this->poolSelection($a_change_obj_ref);
369 }
370 }
371
375 public function selectPool($a_change_obj_ref = false)
376 {
378
379 $_SESSION["cont_media_pool"] = $_GET["pool_ref_id"];
380 $ilCtrl->setParameter($this, "subCmd", "insertFromPool");
381 if ($a_change_obj_ref) {
382 $ilCtrl->redirect($this, "changeObjectReference");
383 } else {
384 $ilCtrl->redirect($this, "insert");
385 }
386 }
387
391 public function poolSelection($a_change_obj_ref = false)
392 {
394 $ilTabs = $this->tabs;
396
397 $this->getTabs($ilTabs, true, $a_change_obj_ref);
398 $ilTabs->setSubTabActive("cont_mob_from_media_pool");
399
400 include_once "./Services/COPage/classes/class.ilPoolSelectorGUI.php";
401
402 if ($a_change_obj_ref) {
403 $ilCtrl->setParameter($this, "subCmd", "poolSelection");
404 $exp = new ilPoolSelectorGUI($this, "changeObjectReference", $this, "changeObjectReference");
405 } else {
406 $ilCtrl->setParameter($this, "subCmd", "poolSelection");
407 $exp = new ilPoolSelectorGUI($this, "insert");
408 }
409
410 // filter
411 $exp->setTypeWhiteList(array("root", "cat", "grp", "fold", "crs", "mep"));
412 $exp->setClickableTypes(array('mep'));
413
414 if (!$exp->handleCommand()) {
415 $tpl->setContent($exp->getHTML());
416 }
417 }
418
419
424 public function createNewObjectReference()
425 {
426 $this->create(false, true);
427 }
428
433 public function selectObjectReference()
434 {
437 if (is_array($_POST["id"]) && count($_POST["id"]) == 1) {
438 include_once("./Services/COPage/classes/class.ilPCMediaObject.php");
439 include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
441 $this->content_obj->readMediaObject($fid);
442 $this->content_obj->updateObjectReference();
443 $this->updated = $this->pg_obj->update();
444 } else {
445 ilUtil::sendInfo($lng->txt("cont_select_max_one_item"), true);
446 $ilCtrl->redirect($this, "changeObjectReference");
447 }
448 $ilCtrl->redirect($this, "editAlias");
449 }
450
454 public function &create($a_create_alias = true, $a_change_obj_ref = false)
455 {
458
459 if ($_GET["subCmd"] == "insertFromPool") {
460 if (is_array($_POST["id"])) {
461 for ($i = count($_POST["id"]) - 1; $i>=0; $i--) {
462 include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
464 include_once("./Services/COPage/classes/class.ilPCMediaObject.php");
465 $this->content_obj = new ilPCMediaObject($this->getPage());
466 $this->content_obj->readMediaObject($fid);
467 $this->content_obj->createAlias($this->pg_obj, $_GET["hier_id"], $this->pc_id);
468 }
469 $this->updated = $this->pg_obj->update();
470 }
471
472 $ilCtrl->returnToParent($this);
473 }
474
475 // check form input
476 $mob_gui = new ilObjMediaObjectGUI("");
477 $mob_gui->initForm("create");
478
479 if (!$mob_gui->checkFormInput()) {
480 $this->form = $mob_gui->getForm();
481 $this->insert("edpost", "create_mob", true);
482 return;
483 }
484 // create dummy object in db (we need an id)
485 include_once("./Services/COPage/classes/class.ilPCMediaObject.php");
486 if ($a_change_obj_ref != true) {
487 $this->content_obj = new ilPCMediaObject($this->getPage());
488 }
489 $this->content_obj->createMediaObject();
490 $media_obj = $this->content_obj->getMediaObject();
491
492 include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
494
495 if ($a_create_alias) {
496 // need a pcmediaobject here
497 //$this->node = $this->createPageContentNode();
498
499 $this->content_obj->createAlias($this->pg_obj, $this->hier_id, $this->pc_id);
500 $this->updated = $this->pg_obj->update();
501 if ($this->updated === true) {
502 $this->pg_obj->stripHierIDs();
503 $this->pg_obj->addHierIDs();
504 $ilCtrl->setParameter($this, "hier_id", $this->content_obj->readHierId());
505 $ilCtrl->setParameter($this, "pc_id", $this->content_obj->readPCId());
506 $this->content_obj->setHierId($this->content_obj->readHierId());
507 $this->setHierId($this->content_obj->readHierId());
508 $this->content_obj->setPCId($this->content_obj->readPCId());
509 ilUtil::sendSuccess($lng->txt("saved_media_object"), true);
510 $this->ctrl->redirectByClass("ilobjmediaobjectgui", "edit");
511
512 //$this->ctrl->returnToParent($this, "jump".$this->hier_id);
513 } else {
514 $this->insert();
515 }
516 } else {
517 if ($a_change_obj_ref == true) {
518 $this->content_obj->updateObjectReference();
519 $this->updated = $this->pg_obj->update();
520 $this->ctrl->redirect($this, "editAlias");
521 }
522 return $this->content_obj;
523 }
524 }
525
526
530 public function editAlias()
531 {
533
534 $this->initAliasForm();
535 $this->getAliasValues();
536 $tpl->setContent($this->form_gui->getHTML());
537 }
538
542 public function initAliasForm()
543 {
546
547 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
548
549 $this->form_gui = new ilPropertyFormGUI();
550
551 // standard view resource
552 $std_alias_item = new ilMediaAliasItem(
553 $this->dom,
554 $this->getHierId(),
555 "Standard",
556 $this->content_obj->getPcId()
557 );
558 $std_item = $this->content_obj->getMediaObject()->getMediaItem("Standard");
559
560 // title, location and format
561 $title = new ilNonEditableValueGUI($lng->txt("title"), "title");
562 $this->form_gui->addItem($title);
563 $loc = new ilNonEditableValueGUI(
564 $this->lng->txt("cont_" . strtolower($std_item->getLocationType())),
565 "st_location"
566 );
567 $this->form_gui->addItem($loc);
569 $this->lng->txt("cont_format"),
570 "st_format"
571 );
572 $this->form_gui->addItem($format);
573
574 // standard size
575 $radio_size = new ilRadioGroupInputGUI($lng->txt("size"), "st_derive_size");
576 $orig_size = $std_item->getOriginalSize();
577 $add_str = ($orig_size["width"] != "" && $orig_size["height"] != "")
578 ? " (" . $orig_size["width"] . " x " . $orig_size["height"] . ")"
579 : "";
580 $op1 = new ilRadioOption($lng->txt("cont_default") . $add_str, "y");
581 $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
582 $radio_size->addOption($op1);
583
584 // width height
585 include_once("./Services/MediaObjects/classes/class.ilWidthHeightInputGUI.php");
586 $width_height = new ilWidthHeightInputGUI($lng->txt("cont_width") .
587 " / " . $lng->txt("cont_height"), "st_width_height");
588 $width_height->setConstrainProportions(true);
589 $op2->addSubItem($width_height);
590
591 $radio_size->addOption($op2);
592 $this->form_gui->addItem($radio_size);
593
594 // standard caption
595 $rad_caption = new ilRadioGroupInputGUI($lng->txt("cont_caption"), "st_derive_caption");
596 $op1 = new ilRadioOption($lng->txt("cont_default"), "y");
597 $def_cap = new ilNonEditableValueGUI("", "def_caption");
598 $op1->addSubItem($def_cap);
599 $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
600 $rad_caption->addOption($op1);
601
602 $caption = new ilTextAreaInputGUI("", "st_caption");
603 $caption->setCols(30);
604 $caption->setRows(2);
605 $op2->addSubItem($caption);
606
607 /*$caption = new ilTextInputGUI("", "st_caption");
608 $caption->setSize(40);
609 $caption->setMaxLength(200);
610 $op2->addSubItem($caption);*/
611 $rad_caption->addOption($op2);
612 $this->form_gui->addItem($rad_caption);
613
614 // standard text representation
615 if (substr($std_item->getFormat(), 0, 5) == "image") {
616 $rad_tr = new ilRadioGroupInputGUI($lng->txt("text_repr"), "st_derive_text_representation");
617 $op1 = new ilRadioOption($lng->txt("cont_default"), "y");
618 $def_tr = new ilNonEditableValueGUI("", "def_text_representation");
619 $op1->addSubItem($def_tr);
620 $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
621 $tr = new ilTextAreaInputGUI("", "st_text_representation");
622 $tr->setCols(30);
623 $tr->setRows(2);
624 $rad_tr->addOption($op1);
625 $op2->addSubItem($tr);
626 $rad_tr->addOption($op2);
627 $this->form_gui->addItem($rad_tr);
628 $rad_tr->setInfo($lng->txt("text_repr_info"));
629 }
630
631 // standard parameters
632 if (!in_array($std_item->getFormat(), ilObjMediaObject::_getSimpleMimeTypes())) {
634 $std_item->getLocation(),
635 $std_item->getFormat()
636 )) { // autostart
637 $par = $std_item->getParameters();
638 $def_str = ($par["autostart"] == "true")
639 ? " (" . $lng->txt("yes") . ")"
640 : " (" . $lng->txt("no") . ")";
641 $rad_auto = new ilRadioGroupInputGUI(
642 $lng->txt("cont_autostart"),
643 "st_derive_parameters"
644 );
645 $op1 = new ilRadioOption($lng->txt("cont_default") . $def_str, "y");
646 $rad_auto->addOption($op1);
647 $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
648 $auto = new ilCheckboxInputGUI($lng->txt("enabled"), "st_autostart");
649 $op2->addSubItem($auto);
650 $rad_auto->addOption($op2);
651 $this->form_gui->addItem($rad_auto);
652 } else { // parameters
653 $rad_parameters = new ilRadioGroupInputGUI($lng->txt("cont_parameter"), "st_derive_parameters");
654 $op1 = new ilRadioOption($lng->txt("cont_default"), "y");
655 $def_par = new ilNonEditableValueGUI("", "def_parameters");
656 $op1->addSubItem($def_par);
657 $rad_parameters->addOption($op1);
658 $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
659 $par = new ilTextAreaInputGUI("", "st_parameters");
660 $par->setRows(5);
661 $par->setCols(50);
662 $op2->addSubItem($par);
663 $rad_parameters->addOption($op2);
664 $this->form_gui->addItem($rad_parameters);
665 }
666 }
667
668 // fullscreen view
669 if ($this->content_obj->getMediaObject()->hasFullScreenItem()) {
670 $full_alias_item = new ilMediaAliasItem(
671 $this->dom,
672 $this->getHierId(),
673 "Fullscreen",
674 $this->content_obj->getPcId()
675 );
676 $full_item = $this->content_obj->getMediaObject()->getMediaItem("Fullscreen");
677
678 $fs_sec = new ilFormSectionHeaderGUI();
679 $fs_sec->setTitle($lng->txt("cont_fullscreen"));
680 $this->form_gui->addItem($fs_sec);
681
682
683 // resource
684 $radio_prop = new ilRadioGroupInputGUI($lng->txt("cont_resource"), "fullscreen");
685 $op1 = new ilRadioOption($lng->txt("cont_none"), "n");
686 $radio_prop->addOption($op1);
687 $op2 = new ilRadioOption($this->lng->txt("cont_" . strtolower($full_item->getLocationType())) . ": " .
688 $full_item->getLocation(), "y");
689 $radio_prop->addOption($op2);
690 $this->form_gui->addItem($radio_prop);
691
692 // format
694 $this->lng->txt("cont_format"),
695 "full_format"
696 );
697 $this->form_gui->addItem($format);
698
699 // full size
700 $radio_size = new ilRadioGroupInputGUI($lng->txt("size"), "full_derive_size");
701 $fw_size = $std_item->getOriginalSize();
702 $add_str = ($fw_size["width"] != "" && $fw_size["height"] != "")
703 ? " (" . $fw_size["width"] . " x " . $fw_size["height"] . ")"
704 : "";
705 $op1 = new ilRadioOption($lng->txt("cont_default") . $add_str, "y");
706 $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
707 $radio_size->addOption($op1);
708
709 // width height
710 include_once("./Services/MediaObjects/classes/class.ilWidthHeightInputGUI.php");
711 $width_height = new ilWidthHeightInputGUI($lng->txt("cont_width") .
712 " / " . $lng->txt("cont_height"), "full_width_height");
713 $width_height->setConstrainProportions(true);
714 $op2->addSubItem($width_height);
715
716 $radio_size->addOption($op2);
717 $this->form_gui->addItem($radio_size);
718
719 // fullscreen caption
720 $rad_caption = new ilRadioGroupInputGUI($lng->txt("cont_caption"), "full_derive_caption");
721 $op1 = new ilRadioOption($lng->txt("cont_default"), "y");
722 $def_cap = new ilNonEditableValueGUI("", "full_def_caption");
723 $op1->addSubItem($def_cap);
724 $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
725 $rad_caption->addOption($op1);
726
727 $caption = new ilTextAreaInputGUI("", "full_caption");
728 $caption->setCols(30);
729 $caption->setRows(2);
730 $op2->addSubItem($caption);
731
732 /*$caption = new ilTextInputGUI("", "full_caption");
733 $caption->setSize(40);
734 $caption->setMaxLength(200);
735 $op2->addSubItem($caption);*/
736 $rad_caption->addOption($op2);
737 $this->form_gui->addItem($rad_caption);
738
739 // fullscreen text representation
740 if (substr($full_item->getFormat(), 0, 5) == "image") {
741 $rad_tr = new ilRadioGroupInputGUI($lng->txt("text_repr"), "full_derive_text_representation");
742 $op1 = new ilRadioOption($lng->txt("cont_default"), "y");
743 $def_tr = new ilNonEditableValueGUI("", "full_def_text_representation");
744 $op1->addSubItem($def_tr);
745 $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
746 $tr = new ilTextAreaInputGUI("", "full_text_representation");
747 $tr->setCols(30);
748 $tr->setRows(2);
749 $rad_tr->addOption($op1);
750 $op2->addSubItem($tr);
751 $rad_tr->addOption($op2);
752 $this->form_gui->addItem($rad_tr);
753 $rad_tr->setInfo($lng->txt("text_repr_info"));
754 }
755
756 // fullscreen parameters
757 if (!in_array($full_item->getFormat(), ilObjMediaObject::_getSimpleMimeTypes())) {
759 $full_item->getLocation(),
760 $full_item->getFormat()
761 )) { // autostart
762 $par = $full_item->getParameters();
763 $def_str = ($par["autostart"] == "true")
764 ? " (" . $lng->txt("yes") . ")"
765 : " (" . $lng->txt("no") . ")";
766 $rad_auto = new ilRadioGroupInputGUI(
767 $lng->txt("cont_autostart"),
768 "full_derive_parameters"
769 );
770 $op1 = new ilRadioOption($lng->txt("cont_default") . $def_str, "y");
771 $rad_auto->addOption($op1);
772 $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
773 $auto = new ilCheckboxInputGUI($lng->txt("enabled"), "full_autostart");
774 $op2->addSubItem($auto);
775 $rad_auto->addOption($op2);
776 $this->form_gui->addItem($rad_auto);
777 } else { // parameters
778 $rad_parameters = new ilRadioGroupInputGUI($lng->txt("cont_parameter"), "full_derive_parameters");
779 $op1 = new ilRadioOption($lng->txt("cont_default"), "y");
780 $def_par = new ilNonEditableValueGUI("", "full_def_parameters");
781 $op1->addSubItem($def_par);
782 $rad_parameters->addOption($op1);
783 $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
784 $par = new ilTextAreaInputGUI("", "full_parameters");
785 $par->setRows(5);
786 $par->setCols(50);
787 $op2->addSubItem($par);
788 $rad_parameters->addOption($op2);
789 $this->form_gui->addItem($rad_parameters);
790 }
791 }
792 }
793
794 $this->form_gui->setTitle($lng->txt("cont_edit_mob_alias_prop"));
795 $this->form_gui->addCommandButton("saveAliasProperties", $lng->txt("save"));
796 $lm_set = new ilSetting("lm");
797 if ($lm_set->get("replace_mob_feature")) {
798 $this->form_gui->addCommandButton("changeObjectReference", $lng->txt("cont_change_object_reference"));
799 }
800 $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
801 }
802
806 public function getAliasValues()
807 {
809
810 // standard view resource
811 $std_alias_item = new ilMediaAliasItem(
812 $this->dom,
813 $this->getHierId(),
814 "Standard",
815 $this->content_obj->getPcId()
816 );
817 $std_item = $this->content_obj->getMediaObject()->getMediaItem("Standard");
818
819 $values["title"] = $this->content_obj->getMediaObject()->getTitle();
820 $values["st_location"] = $std_item->getLocation();
821 $values["st_format"] = $std_item->getFormat();
822
823 // size
824 $values["st_width_height"]["width"] = $std_alias_item->getWidth();
825 $values["st_width_height"]["height"] = $std_alias_item->getHeight();
826 $values["st_width_height"]["constr_prop"] = true;
827
828 // caption
829 $values["st_caption"] = $std_alias_item->getCaption();
830 if (trim($std_item->getCaption()) == "") {
831 $values["def_caption"] = "<i>" . $lng->txt("cont_no_caption") . "</i>";
832 } else {
833 $values["def_caption"] = $std_item->getCaption();
834 }
835
836 // text representation
837 $values["st_text_representation"] = $std_alias_item->getTextRepresentation();
838 if (trim($std_item->getTextRepresentation()) == "") {
839 $values["def_text_representation"] = "<i>" . $lng->txt("cont_no_text") . "</i>";
840 } else {
841 $values["def_text_representation"] = $std_item->getTextRepresentation();
842 }
843
844 // parameters / autostart
846 $std_item->getLocation(),
847 $std_item->getFormat()
848 )) { // autostart
849 $par = $std_alias_item->getParameters();
850 if ($par["autostart"] == "true") {
851 $values["st_autostart"] = true;
852 }
853 } else { // parameters
854 $values["st_parameters"] = $std_alias_item->getParameterString();
855 }
856
857 // size
858 $values["st_derive_size"] = $std_alias_item->definesSize()
859 ? "n"
860 : "y";
861 if ($values["st_derive_size"] == "y") {
862 $values["st_width_height"]["width"] = $std_item->getWidth();
863 $values["st_width_height"]["height"] = $std_item->getHeight();
864 }
865 $values["st_derive_caption"] = $std_alias_item->definesCaption()
866 ? "n"
867 : "y";
868 $values["st_derive_text_representation"] = $std_alias_item->definesTextRepresentation()
869 ? "n"
870 : "y";
871 $values["st_derive_parameters"] = $std_alias_item->definesParameters()
872 ? "n"
873 : "y";
874 if (trim($std_item->getParameterString()) == "") {
875 $values["def_parameters"] = "<i>" . $lng->txt("cont_no_parameters") . "</i>";
876 } else {
877 $values["def_parameters"] = $std_item->getParameterString();
878 }
879
880 // fullscreen properties
881 if ($this->content_obj->getMediaObject()->hasFullScreenItem()) {
882 $full_alias_item = new ilMediaAliasItem(
883 $this->dom,
884 $this->getHierId(),
885 "Fullscreen",
886 $this->content_obj->getPcId()
887 );
888 $full_item = $this->content_obj->getMediaObject()->getMediaItem("Fullscreen");
889
890 $values["fullscreen"] = "n";
891 if ($full_alias_item->exists()) {
892 $values["fullscreen"] = "y";
893 }
894
895 $values["full_location"] = $full_item->getLocation();
896 $values["full_format"] = $full_item->getFormat();
897 $values["full_width_height"]["width"] = $full_alias_item->getWidth();
898 $values["full_width_height"]["height"] = $full_alias_item->getHeight();
899 $values["full_width_height"]["constr_prop"] = true;
900 $values["full_caption"] = $full_alias_item->getCaption();
901 if (trim($full_item->getCaption()) == "") {
902 $values["full_def_caption"] = "<i>" . $lng->txt("cont_no_caption") . "</i>";
903 } else {
904 $values["full_def_caption"] = $full_item->getCaption();
905 }
906 $values["full_text_representation"] = $full_alias_item->getTextRepresentation();
907 if (trim($full_item->getTextRepresentation()) == "") {
908 $values["full_def_text_representation"] = "<i>" . $lng->txt("cont_no_text") . "</i>";
909 } else {
910 $values["full_def_text_representation"] = $full_item->getTextRepresentation();
911 }
912 $values["full_parameters"] = $full_alias_item->getParameterString();
913 $values["full_derive_size"] = $full_alias_item->definesSize()
914 ? "n"
915 : "y";
916 if ($values["full_derive_size"] == "y") {
917 $values["full_width_height"]["width"] = $full_item->getWidth();
918 $values["full_width_height"]["height"] = $full_item->getHeight();
919 }
920 $values["full_derive_caption"] = $full_alias_item->definesCaption()
921 ? "n"
922 : "y";
923 $values["full_derive_text_representation"] = $full_alias_item->definesTextRepresentation()
924 ? "n"
925 : "y";
926
927 // parameters
929 $full_item->getLocation(),
930 $full_item->getFormat()
931 )) { // autostart
932 $par = $full_alias_item->getParameters();
933 if ($par["autostart"] == "true") {
934 $values["full_autostart"] = true;
935 }
936 } else { // parameters
937 $values["full_parameters"] = $full_alias_item->getParameterString();
938 }
939
940 $values["full_derive_parameters"] = $full_alias_item->definesParameters()
941 ? "n"
942 : "y";
943 if (trim($full_item->getParameterString()) == "") {
944 $values["full_def_parameters"] = "<i>" . $lng->txt("cont_no_parameters") . "</i>";
945 } else {
946 $values["full_def_parameters"] = $full_item->getParameterString();
947 }
948 }
949
950 $this->form_gui->setValuesByArray($values);
951 }
952
956 public function saveAliasProperties()
957 {
958 $std_alias_item = new ilMediaAliasItem(
959 $this->dom,
960 $this->getHierId(),
961 "Standard",
962 $this->content_obj->getPcId()
963 );
964 $full_alias_item = new ilMediaAliasItem(
965 $this->dom,
966 $this->getHierId(),
967 "Fullscreen",
968 $this->content_obj->getPcId()
969 );
970 $std_item = $this->content_obj->getMediaObject()->getMediaItem("Standard");
971 $full_item = $this->content_obj->getMediaObject()->getMediaItem("Fullscreen");
972
973 // standard size
974 if ($_POST["st_derive_size"] == "y") {
975 $std_alias_item->deriveSize();
976 } else {
977 $std_alias_item->setWidth(ilUtil::stripSlashes($_POST["st_width_height"]["width"]));
978 $std_alias_item->setHeight(ilUtil::stripSlashes($_POST["st_width_height"]["height"]));
979 }
980
981 // standard caption
982 if ($_POST["st_derive_caption"] == "y") {
983 $std_alias_item->deriveCaption();
984 } else {
985 $std_alias_item->setCaption(ilUtil::stripSlashes($_POST["st_caption"]));
986 }
987
988 // text representation
989 if ($_POST["st_derive_text_representation"] == "y") {
990 $std_alias_item->deriveTextRepresentation();
991 } else {
992 $std_alias_item->setTextRepresentation(ilUtil::stripSlashes($_POST["st_text_representation"]));
993 }
994
995 // standard parameters
996 if ($_POST["st_derive_parameters"] == "y") {
997 $std_alias_item->deriveParameters();
998 } else {
1000 $std_item->getLocation(),
1001 $std_item->getFormat()
1002 )) { // autostart
1003 if ($_POST["st_autostart"]) {
1004 $std_alias_item->setParameters(ilUtil::extractParameterString('autostart="true"'));
1005 } else {
1006 $std_alias_item->setParameters(ilUtil::extractParameterString('autostart="false"'));
1007 }
1008 } else { // parameters
1009 $std_alias_item->setParameters(ilUtil::extractParameterString(ilUtil::stripSlashes(utf8_decode($_POST["st_parameters"]))));
1010 }
1011 }
1012
1013 if ($this->content_obj->getMediaObject()->hasFullscreenItem()) {
1014 if ($_POST["fullscreen"] == "y") {
1015 if (!$full_alias_item->exists()) {
1016 $full_alias_item->insert();
1017 }
1018
1019 // fullscreen size
1020 if ($_POST["full_derive_size"] == "y") {
1021 $full_alias_item->deriveSize();
1022 } else {
1023 $full_alias_item->setWidth(ilUtil::stripSlashes($_POST["full_width_height"]["width"]));
1024 $full_alias_item->setHeight(ilUtil::stripSlashes($_POST["full_width_height"]["height"]));
1025 }
1026
1027 // fullscreen caption
1028 if ($_POST["full_derive_caption"] == "y") {
1029 $full_alias_item->deriveCaption();
1030 } else {
1031 $full_alias_item->setCaption(ilUtil::stripSlashes($_POST["full_caption"]));
1032 }
1033
1034 // fullscreen text representation
1035 if ($_POST["full_derive_text_representation"] == "y") {
1036 $full_alias_item->deriveTextRepresentation();
1037 } else {
1038 $full_alias_item->setTextRepresentation(ilUtil::stripSlashes($_POST["full_text_representation"]));
1039 }
1040
1041 // fullscreen parameters
1042 if ($_POST["full_derive_parameters"] == "y") {
1043 $full_alias_item->deriveParameters();
1044 } else {
1046 $full_item->getLocation(),
1047 $full_item->getFormat()
1048 )) { // autostart
1049 if ($_POST["full_autostart"]) {
1050 $full_alias_item->setParameters(ilUtil::extractParameterString('autostart="true"'));
1051 } else {
1052 $full_alias_item->setParameters(ilUtil::extractParameterString('autostart="false"'));
1053 }
1054 } else {
1055 $full_alias_item->setParameters(ilUtil::extractParameterString(ilUtil::stripSlashes(utf8_decode($_POST["full_parameters"]))));
1056 }
1057 }
1058 } else {
1059 if ($full_alias_item->exists()) {
1060 $full_alias_item->delete();
1061 }
1062 }
1063 }
1064
1065 $this->updated = $this->pg_obj->update();
1066 if ($this->updated === true) {
1067 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1068 $this->ctrl->redirect($this, "editAlias");
1069 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
1070 } else {
1071 $this->pg_obj->addHierIDs();
1072 $this->editAlias();
1073 }
1074 }
1075
1079 public function copyToClipboard()
1080 {
1082
1083 $ilUser->addObjectToClipboard($this->content_obj->getMediaObject()->getId(), $this->content_obj->getMediaObject()->getType(), $this->content_obj->getMediaObject()->getTitle());
1084 ilUtil::sendSuccess($this->lng->txt("copied_to_clipboard"), true);
1085 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
1086 }
1087
1091 public function centerAlign()
1092 {
1093 $std_alias_item = new ilMediaAliasItem(
1094 $this->dom,
1095 $this->getHierId(),
1096 "Standard",
1097 $this->content_obj->getPcId()
1098 );
1099 $std_alias_item->setHorizontalAlign("Center");
1100 $_SESSION["il_pg_error"] = $this->pg_obj->update();
1101 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
1102 }
1103
1107 public function leftAlign()
1108 {
1109 $std_alias_item = new ilMediaAliasItem(
1110 $this->dom,
1111 $this->getHierId(),
1112 "Standard",
1113 $this->content_obj->getPcId()
1114 );
1115 $std_alias_item->setHorizontalAlign("Left");
1116 $_SESSION["il_pg_error"] = $this->pg_obj->update();
1117 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
1118 }
1119
1123 public function rightAlign()
1124 {
1125 $std_alias_item = new ilMediaAliasItem(
1126 $this->dom,
1127 $this->getHierId(),
1128 "Standard",
1129 $this->content_obj->getPcId()
1130 );
1131 $std_alias_item->setHorizontalAlign("Right");
1132 $_SESSION["il_pg_error"] = $this->pg_obj->update();
1133 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
1134 }
1135
1139 public function leftFloatAlign()
1140 {
1141 $std_alias_item = new ilMediaAliasItem(
1142 $this->dom,
1143 $this->getHierId(),
1144 "Standard",
1145 $this->content_obj->getPcId()
1146 );
1147 $std_alias_item->setHorizontalAlign("LeftFloat");
1148 $_SESSION["il_pg_error"] = $this->pg_obj->update();
1149 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
1150 }
1151
1155 public function rightFloatAlign()
1156 {
1157 $std_alias_item = new ilMediaAliasItem(
1158 $this->dom,
1159 $this->getHierId(),
1160 "Standard",
1161 $this->content_obj->getPcId()
1162 );
1163 $std_alias_item->setHorizontalAlign("RightFloat");
1164 $_SESSION["il_pg_error"] = $this->pg_obj->update();
1165 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
1166 }
1167
1171 public function checkStyleSelection()
1172 {
1173 // check whether there is more than one style class
1174 $chars = $this->getCharacteristics();
1175
1176 if (count($chars) > 1 ||
1177 ($this->content_obj->getClass() != "" && $this->content_obj->getClass() != "Media")) {
1178 return true;
1179 }
1180 return false;
1181 }
1182
1186 public function editStyle()
1187 {
1189 $tpl = $this->tpl;
1190 $lng = $this->lng;
1191
1192 $this->displayValidationError();
1193
1194 // edit form
1195 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1196 $form = new ilPropertyFormGUI();
1197 $form->setFormAction($ilCtrl->getFormAction($this));
1198 $form->setTitle($this->lng->txt("cont_edit_style"));
1199
1200 // characteristic selection
1201 require_once("./Services/Form/classes/class.ilAdvSelectInputGUI.php");
1202 $char_prop = new ilAdvSelectInputGUI(
1203 $this->lng->txt("cont_characteristic"),
1204 "characteristic"
1205 );
1206
1207 $chars = $this->getCharacteristics();
1208 if (is_object($this->content_obj)) {
1209 if ($chars[$a_seleted_value] == "" && ($this->content_obj->getClass() != "")) {
1210 $chars = array_merge(
1211 array($this->content_obj->getClass() => $this->content_obj->getClass()),
1212 $chars
1213 );
1214 }
1215 }
1216
1217 $selected = $this->content_obj->getClass();
1218 if ($selected == "") {
1219 $selected = "MediaContainer";
1220 }
1221
1222 foreach ($chars as $k => $char) {
1223 $html = '<div class="ilCOPgEditStyleSelectionItem">' .
1224 $char . '</div>';
1225 $char_prop->addOption($k, $char, $html);
1226 }
1227
1228 $char_prop->setValue($selected);
1229 $form->addItem($char_prop);
1230
1231 // save button
1232 $form->addCommandButton("saveStyle", $lng->txt("save"));
1233
1234 $html = $form->getHTML();
1235 $tpl->setContent($html);
1236 return $ret;
1237 }
1238
1242 public function saveStyle()
1243 {
1244 $this->content_obj->setClass($_POST["characteristic"]);
1245 $this->updated = $this->pg_obj->update();
1246 if ($this->updated === true) {
1247 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
1248 } else {
1249 $this->pg_obj->addHierIDs();
1250 $this->editStyle();
1251 }
1252 }
1253
1260 public function getTabs(&$tab_gui, $a_create = false, $a_change_obj_ref = false)
1261 {
1263 $ilTabs = $this->tabs;
1264
1265 if (!$a_create) {
1266 if ($this->checkStyleSelection()) {
1267 $ilTabs->addTarget(
1268 "cont_style",
1269 $ilCtrl->getLinkTarget($this, "editStyle"),
1270 "editStyle",
1271 get_class($this)
1272 );
1273 }
1274
1275 $ilTabs->addTarget(
1276 "cont_mob_inst_prop",
1277 $ilCtrl->getLinkTarget($this, "editAlias"),
1278 "editAlias",
1279 get_class($this)
1280 );
1281
1282 if ($this->getEnabledMapAreas()) {
1283 $st_item = $this->content_obj->getMediaObject()->getMediaItem("Standard");
1284 if (is_object($st_item)) {
1285 $format = $st_item->getFormat();
1286 if (substr($format, 0, 5) == "image" && !is_int(strpos($format, "svg"))) {
1287 $ilTabs->addTarget(
1288 "cont_inst_map_areas",
1289 $ilCtrl->getLinkTargetByClass("ilpcimagemapeditorgui", "editMapAreas"),
1290 array(),
1291 "ilpcimagemapeditorgui"
1292 );
1293 }
1294 }
1295 }
1296 } else {
1297 if ($a_change_obj_ref) {
1298 $cmd = "changeObjectReference";
1299 } else {
1300 $cmd = "insert";
1301 }
1302
1303 $ilCtrl->setParameter($this, "subCmd", "insertNew");
1304 $ilTabs->addSubTabTarget(
1305 "cont_new_mob",
1306 $ilCtrl->getLinkTarget($this, $cmd),
1307 $cmd
1308 );
1309
1310 $ilCtrl->setParameter($this, "subCmd", "insertFromPool");
1311 $ilTabs->addSubTabTarget(
1312 "cont_mob_from_media_pool",
1313 $ilCtrl->getLinkTarget($this, $cmd),
1314 $cmd
1315 );
1316 $ilCtrl->setParameter($this, "subCmd", "");
1317 }
1318 }
1319}
user()
Definition: user.php:4
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
This class represents an advanced selection list property in a property form.
This class represents a checkbox property in a property form.
This class represents a section header in a property form.
Class ilMediaAliasItem.
static lookupForeignId($a_id)
Lookup Foreign Id.
TableGUI class for recent changes in wiki.
This class represents a non editable value in a property form.
Class ilObjMediaObjectGUI.
static setObjectPerCreationForm($a_mob)
Set media object values from creation form.
static _useAutoStartParameterOnly($a_loc, $a_format)
Check whether only autostart parameter should be supported (instead of parameters input field.
static _getSimpleMimeTypes()
Get simple mime types that deactivate parameter property files tab in ILIAS.
Media pool object.
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
User interface class for page content map editor.
Class ilPCMediaObjectGUI.
rightFloatAlign()
align media object to right, floating text
__construct($a_pg_obj, $a_content_obj, $a_hier_id=0, $a_pc_id="")
Constructor @access public.
initAliasForm()
Init alias form.
editAlias()
edit properties form
leftFloatAlign()
align media object to left, floating text
leftAlign()
align media object to left
insert($a_post_cmd="edpost", $a_submit_cmd="create_mob", $a_input_error=false)
Insert new media object form.
copyToClipboard()
copy media object to clipboard
insertFromPool($a_change_obj_ref=false)
Insert media object from pool.
& create($a_create_alias=true, $a_change_obj_ref=false)
create new media object in dom and update page in db
getAliasValues()
Put alias values into form.
centerAlign()
align media object to center
rightAlign()
align media object to right
createNewObjectReference()
Create new media object and replace currrent media item with it.
poolSelection($a_change_obj_ref=false)
Pool Selection.
checkStyleSelection()
Checks whether style selection shoudl be available or not.
selectObjectReference()
Create new media object and replace currrent media item with it.
getEnabledMapAreas()
Get Enable map areas.
changeObjectReference()
Change object reference.
setEnabledMapAreas($a_enabledmapareas)
Set Enable map areas.
getTabs(&$tab_gui, $a_create=false, $a_change_obj_ref=false)
add tabs to ilTabsGUI object
selectPool($a_change_obj_ref=false)
Select concrete pool.
saveAliasProperties()
save table properties in db and return to page edit screen
Class ilPCMediaObject.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
getHierId()
get hierarchical id in dom object
getCharacteristicsOfCurrentStyle($a_type)
Get characteristics of current style.
displayValidationError()
display validation errors
getCharacteristics()
Get characteristics.
setCharacteristics($a_chars)
Set Characteristics.
setHierId($a_hier_id)
get hierarchical id in dom object
Select media pool for adding objects into pages.
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.
ILIAS Setting Class.
This class represents a text area property in a property form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static extractParameterString($a_parstr)
extracts parameter value pairs from a string into an array
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)
This class represents a width/height item in a property form.
$i
Definition: disco.tpl.php:19
$html
Definition: example_001.php:87
global $ilCtrl
Definition: ilias.php:18
$format
Definition: metadata.php:141
$ret
Definition: parser.php:6
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7
$lm_set
$ilUser
Definition: imgupload.php:18