ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
4 require_once ("./Services/COPage/classes/class.ilPageContentGUI.php");
5 require_once ("./Services/COPage/classes/class.ilMediaAliasItem.php");
6 require_once ("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
7 
20 // Todo: extend ilObjMediaObjectGUI !?
22 {
23  var $header;
24  var $ctrl;
25 
26  function ilPCMediaObjectGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id = 0, $a_pc_id = "")
27  {
28  global $ilCtrl;
29 
30  $this->ctrl =& $ilCtrl;
31 
32 //echo "constructor target:".$_SESSION["il_map_il_target"].":<br>";
33  parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
34 
35  $this->setCharacteristics(array("Media" => $this->lng->txt("cont_Media")));
36 
37  }
38 
39  function setHeader($a_title = "")
40  {
41  $this->header = $a_title;
42  }
43 
44  function getHeader()
45  {
46  return $this->header;
47  }
48 
54  function setEnabledMapAreas($a_enabledmapareas)
55  {
56  $this->enabledmapareas = $a_enabledmapareas;
57  }
58 
64  function getEnabledMapAreas()
65  {
66  return $this->enabledmapareas;
67  }
68 
72  function &executeCommand()
73  {
74  global $tpl, $lng, $ilTabs;
75 
76  $this->getCharacteristicsOfCurrentStyle("media_cont"); // scorm-2004
77 
78  // get next class that processes or forwards current command
79  $next_class = $this->ctrl->getNextClass($this);
80 
81  // get current command
82  $cmd = $this->ctrl->getCmd();
83 
84  if (is_object ($this->content_obj))
85  {
86  $tpl->setTitleIcon(ilUtil::getImagePath("icon_mob_b.png"));
87  $this->getTabs($this->tabs_gui);
88 
89  $mob = $this->content_obj->getMediaObject();
90  if (is_object($mob))
91  {
92  $tpl->setVariable("HEADER", $lng->txt("mob").": ".
93  $this->content_obj->getMediaObject()->getTitle());
94  $mob_gui =& new ilObjMediaObjectGUI("", $this->content_obj->getMediaObject()->getId(),false, false);
95  $mob_gui->setBackTitle($this->page_back_title);
96  $mob_gui->setEnabledMapAreas($this->getEnabledMapAreas());
97  $mob_gui->getTabs($this->tabs_gui);
98  }
99  }
100  else
101  {
102  }
103 
104  switch($next_class)
105  {
106  case "ilobjmediaobjectgui":
107  include_once ("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
108  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_mob_b.png"));
109  $this->tpl->setTitle($this->lng->txt("mob").": ".
110  $this->content_obj->getMediaObject()->getTitle());
111  $mob_gui =& new ilObjMediaObjectGUI("", $this->content_obj->getMediaObject()->getId(),false, false);
112  $mob_gui->setBackTitle($this->page_back_title);
113  $mob_gui->setEnabledMapAreas($this->getEnabledMapAreas());
114  $ret =& $this->ctrl->forwardCommand($mob_gui);
115  break;
116 
117  // instance image map editing
118  case "ilpcimagemapeditorgui":
119  require_once("./Services/COPage/classes/class.ilPCImageMapEditorGUI.php");
120  $ilTabs->setTabActive("cont_inst_map_areas");
121  $image_map_edit = new ilPCImageMapEditorGUI($this->content_obj,
122  $this->pg_obj);
123  $ret = $this->ctrl->forwardCommand($image_map_edit);
124  $tpl->setContent($ret);
125  break;
126 
127  default:
128  $ret =& $this->$cmd();
129  break;
130  }
131 
132  return $ret;
133  }
134 
138  function insert($a_post_cmd = "edpost", $a_submit_cmd = "create_mob", $a_input_error = false)
139  {
140  global $ilTabs, $tpl, $ilCtrl, $lng;
141 
142  if ($_GET["subCmd"] == "insertNew")
143  {
144  $_SESSION["cont_media_insert"] = "insertNew";
145  }
146  if ($_GET["subCmd"] == "insertFromPool")
147  {
148  $_SESSION["cont_media_insert"] = "insertFromPool";
149  }
150 
151  if (($_GET["subCmd"] == "") && $_SESSION["cont_media_insert"] != "")
152  {
153  $_GET["subCmd"] = $_SESSION["cont_media_insert"];
154  }
155 
156  switch ($_GET["subCmd"])
157  {
158  case "insertFromPool":
159  $this->insertFromPool();
160  break;
161 
162  case "poolSelection":
163  $this->poolSelection();
164  break;
165 
166  case "selectPool":
167  $this->selectPool();
168  break;
169 
170  case "insertNew":
171  default:
172  $this->getTabs($ilTabs, true);
173  $ilTabs->setSubTabActive("cont_new_mob");
174 
175  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
176  if ($a_input_error)
177  {
178  $form = $this->form;
179  }
180  else
181  {
182  $mob_gui = new ilObjMediaObjectGUI("");
183  $mob_gui->initForm("create");
184  $form = $mob_gui->getForm();
185  }
186  $form->setFormAction($ilCtrl->getFormAction($this, "create_mob"));
187  $form->clearCommandButtons();
188  $form->addCommandButton("create_mob", $lng->txt("save"));
189  $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
190 
191  $this->displayValidationError();
192 
193  $tpl->setContent($form->getHTML());
194 
195  break;
196  }
197  }
198 
203  {
204  global $ilTabs, $ilCtrl, $lng;
205 
206  if ($_GET["subCmd"] == "insertNew")
207  {
208  $_SESSION["cont_media_insert"] = "insertNew";
209  }
210  if ($_GET["subCmd"] == "insertFromPool")
211  {
212  $_SESSION["cont_media_insert"] = "insertFromPool";
213  }
214 
215  if (($_GET["subCmd"] == "") && $_SESSION["cont_media_insert"] != "")
216  {
217  $_GET["subCmd"] = $_SESSION["cont_media_insert"];
218  }
219 
220  switch ($_GET["subCmd"])
221  {
222  case "insertFromPool":
223  $this->insertFromPool(true);
224  break;
225 
226  case "poolSelection":
227  $this->poolSelection(true);
228  break;
229 
230  case "selectPool":
231  $this->selectPool(true);
232  break;
233 
234  case "insertNew":
235  default:
236  $ilCtrl->setParameter($this, "subCmd", "changeObjectReference");
237  $this->getTabs($ilTabs, true, true);
238  $ilTabs->setSubTabActive("cont_new_mob");
239 
240  $this->displayValidationError();
241 
242  $mob_gui = new ilObjMediaObjectGUI("");
243  $mob_gui->initForm("create");
244  $form = $mob_gui->getForm();
245  $form->setFormAction($ilCtrl->getFormAction($this));
246  $form->clearCommandButtons();
247  $form->addCommandButton("createNewObjectReference", $lng->txt("save"));
248  $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
249  $this->tpl->setContent($form->getHTML());
250  }
251  }
252 
256  function insertFromPool($a_change_obj_ref = false)
257  {
258  global $ilCtrl, $ilAccess, $ilTabs, $tpl, $lng, $ilToolbar;
259 
260 
261  if ($_SESSION["cont_media_pool"] != "" &&
262  $ilAccess->checkAccess("write", "", $_SESSION["cont_media_pool"])
263  && ilObject::_lookupType(ilObject::_lookupObjId($_SESSION["cont_media_pool"])) == "mep")
264  {
265  $tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
266  $tpl->setCurrentBlock("btn_cell");
267  $ilCtrl->setParameter($this, "subCmd", "poolSelection");
268  if ($a_change_obj_ref)
269  {
270  $tpl->setVariable("BTN_LINK",
271  $ilCtrl->getLinkTarget($this, "changeObjectReference"));
272  }
273  else
274  {
275  $tpl->setVariable("BTN_LINK",
276  $ilCtrl->getLinkTarget($this, "insert"));
277  }
278  $ilCtrl->setParameter($this, "subCmd", "");
279  $tpl->setVariable("BTN_TXT", $lng->txt("cont_switch_to_media_pool"));
280  $tpl->parseCurrentBlock();
281 
282  $this->getTabs($ilTabs, true, $a_change_obj_ref);
283  $ilTabs->setSubTabActive("cont_mob_from_media_pool");
284 
285  include_once("./Modules/MediaPool/classes/class.ilObjMediaPool.php");
286  include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
287  $pool = new ilObjMediaPool($_SESSION["cont_media_pool"]);
288  $ilCtrl->setParameter($this, "subCmd", "insertFromPool");
289  $tcmd = ($a_change_obj_ref)
290  ? "changeObjectReference"
291  : "insert";
292  $tmode = ($a_change_obj_ref)
295  $mpool_table = new ilMediaPoolTableGUI($this, $tcmd, $pool, "mep_folder",
296  $tmode);
297 
298  $tpl->setContent($mpool_table->getHTML());
299  }
300  else
301  {
302  $this->poolSelection($a_change_obj_ref);
303  }
304  }
305 
309  function selectPool($a_change_obj_ref = false)
310  {
311  global $ilCtrl;
312 
313  $_SESSION["cont_media_pool"] = $_GET["pool_ref_id"];
314  $ilCtrl->setParameter($this, "subCmd", "insertFromPool");
315  if ($a_change_obj_ref)
316  {
317  $ilCtrl->redirect($this, "changeObjectReference");
318  }
319  else
320  {
321  $ilCtrl->redirect($this, "insert");
322  }
323  }
324 
328  function poolSelection($a_change_obj_ref = false)
329  {
330  global $ilCtrl, $tree, $tpl, $ilTabs;
331 
332  $this->getTabs($ilTabs, true, $a_change_obj_ref);
333  $ilTabs->setSubTabActive("cont_mob_from_media_pool");
334 
335  include_once "./Services/COPage/classes/class.ilPoolSelectorGUI.php";
336 
337  if ($a_change_obj_ref)
338  {
339  $exp = new ilPoolSelectorGUI($this->ctrl->getLinkTarget($this, "changeObjectReference"));
340  }
341  else
342  {
343  $exp = new ilPoolSelectorGUI($this->ctrl->getLinkTarget($this, "insert"));
344  }
345  if ($_GET["expand"] == "")
346  {
347  $expanded = $tree->readRootId();
348  }
349  else
350  {
351  $expanded = $_GET["expand"];
352  }
353  $exp->setExpand($expanded);
354 
355  $exp->setTargetGet("sel_id");
356  $this->ctrl->setParameter($this, "target_type", $a_type);
357  $ilCtrl->setParameter($this, "subCmd", "poolSelection");
358  if ($a_change_obj_ref)
359  {
360  $exp->setParamsGet($this->ctrl->getParameterArray($this, "changeObjectReference"));
361  }
362  else
363  {
364  $exp->setParamsGet($this->ctrl->getParameterArray($this, "insert"));
365  }
366 
367  // filter
368  $exp->setFiltered(true);
369  $exp->setFilterMode(IL_FM_POSITIVE);
370  $exp->addFilter("root");
371  $exp->addFilter("cat");
372  $exp->addFilter("grp");
373  $exp->addFilter("fold");
374  $exp->addFilter("crs");
375  $exp->addFilter("mep");
376 
377  $sel_types = array('mep');
378 
379  $exp->setOutput(0);
380 
381  $tpl->setContent($exp->getOutput());
382  }
383 
384 
390  {
391  $this->create(false, true);
392  }
393 
399  {
400  global $ilCtrl, $lng;
401  if (is_array($_POST["id"]) && count($_POST["id"]) == 1)
402  {
403  include_once("./Services/COPage/classes/class.ilPCMediaObject.php");
404  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
405  $fid = ilMediaPoolItem::lookupForeignId($_POST["id"][0]);
406  $this->content_obj->readMediaObject($fid);
407  $this->content_obj->updateObjectReference();
408  $this->updated = $this->pg_obj->update();
409  }
410  else
411  {
412  ilUtil::sendInfo($lng->txt("cont_select_max_one_item"), true);
413  $ilCtrl->redirect($this, "changeObjectReference");
414 
415  }
416  $ilCtrl->redirect($this, "editAlias");
417  }
418 
422  function &create($a_create_alias = true, $a_change_obj_ref = false)
423  {
424  global $ilCtrl, $lng;
425 
426  if ($_GET["subCmd"] == "insertFromPool")
427  {
428  if (is_array($_POST["id"]))
429  {
430  for($i = count($_POST["id"]) - 1; $i>=0; $i--)
431  {
432  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
433  $fid = ilMediaPoolItem::lookupForeignId($_POST["id"][$i]);
434  include_once("./Services/COPage/classes/class.ilPCMediaObject.php");
435  $this->content_obj = new ilPCMediaObject($this->dom);
436  $this->content_obj->readMediaObject($fid);
437  $this->content_obj->createAlias($this->pg_obj, $_GET["hier_id"], $this->pc_id);
438  }
439  $this->updated = $this->pg_obj->update();
440  }
441 
442  $ilCtrl->returnToParent($this);
443  }
444 
445  // check form input
446  $mob_gui = new ilObjMediaObjectGUI("");
447  $mob_gui->initForm("create");
448 
449  if (!$mob_gui->checkFormInput())
450  {
451  $this->form = $mob_gui->getForm();
452  $this->insert("edpost", "create_mob", true);
453  return;
454  }
455  // create dummy object in db (we need an id)
456  include_once("./Services/COPage/classes/class.ilPCMediaObject.php");
457  if ($a_change_obj_ref != true)
458  {
459  $this->content_obj = new ilPCMediaObject($this->dom);
460  }
461  $this->content_obj->createMediaObject();
462  $media_obj = $this->content_obj->getMediaObject();
463 
464  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
466 
467  if ($a_create_alias)
468  {
469  // need a pcmediaobject here
470  //$this->node = $this->createPageContentNode();
471 
472  $this->content_obj->createAlias($this->pg_obj, $this->hier_id, $this->pc_id);
473  $this->updated = $this->pg_obj->update();
474  if ($this->updated === true)
475  {
476  $this->pg_obj->stripHierIDs();
477  $this->pg_obj->addHierIDs();
478  $ilCtrl->setParameter($this, "hier_id", $this->content_obj->readHierId());
479  $ilCtrl->setParameter($this, "pc_id", $this->content_obj->readPCId());
480  $this->content_obj->setHierId($this->content_obj->readHierId());
481  $this->setHierId($this->content_obj->readHierId());
482  $this->content_obj->setPCId($this->content_obj->readPCId());
483  ilUtil::sendSuccess($lng->txt("saved_media_object"), true);
484  $this->ctrl->redirectByClass("ilobjmediaobjectgui", "edit");
485 
486  //$this->ctrl->returnToParent($this, "jump".$this->hier_id);
487  }
488  else
489  {
490  $this->insert();
491  }
492  }
493  else
494  {
495  if ($a_change_obj_ref == true)
496  {
497  $this->content_obj->updateObjectReference();
498  $this->updated = $this->pg_obj->update();
499  $this->ctrl->redirect($this, "editAlias");
500  }
501  return $this->content_obj;
502  }
503  }
504 
505 
509  function editAlias()
510  {
511  global $tpl;
512 
513  $this->initAliasForm();
514  $this->getAliasValues();
515  $tpl->setContent($this->form_gui->getHTML());
516  }
517 
521  function initAliasForm()
522  {
523  global $lng, $ilCtrl;
524 
525  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
526 
527  $this->form_gui = new ilPropertyFormGUI();
528 
529  // standard view resource
530  $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
531  $this->content_obj->getPcId());
532  $std_item = $this->content_obj->getMediaObject()->getMediaItem("Standard");
533 
534  // title, location and format
535  $title = new ilNonEditableValueGUI($lng->txt("title"), "title");
536  $this->form_gui->addItem($title);
537  $loc = new ilNonEditableValueGUI(
538  $this->lng->txt("cont_".strtolower($std_item->getLocationType())), "st_location");
539  $this->form_gui->addItem($loc);
540  $format = new ilNonEditableValueGUI(
541  $this->lng->txt("cont_format"), "st_format");
542  $this->form_gui->addItem($format);
543 
544  // standard size
545  $radio_size = new ilRadioGroupInputGUI($lng->txt("size"), "st_derive_size");
546  $op1 = new ilRadioOption($lng->txt("cont_default").
547  " (".$std_item->getWidth()." x ".$std_item->getHeight().")", "y");
548  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
549  $radio_size->addOption($op1);
550 
551  // width height
552  include_once("./Services/MediaObjects/classes/class.ilWidthHeightInputGUI.php");
553  $width_height = new ilWidthHeightInputGUI($lng->txt("cont_width").
554  " / ".$lng->txt("cont_height"), "st_width_height");
555  $width_height->setConstrainProportions(true);
556  $op2->addSubItem($width_height);
557 
558  $radio_size->addOption($op2);
559  $this->form_gui->addItem($radio_size);
560 
561  // standard caption
562  $rad_caption = new ilRadioGroupInputGUI($lng->txt("cont_caption"), "st_derive_caption");
563  $op1 = new ilRadioOption($lng->txt("cont_default"), "y");
564  $def_cap = new ilNonEditableValueGUI("", "def_caption");
565  $op1->addSubItem($def_cap);
566  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
567  $rad_caption->addOption($op1);
568 
569  $caption = new ilTextAreaInputGUI("", "st_caption");
570  $caption->setCols(30);
571  $caption->setRows(2);
572  $op2->addSubItem($caption);
573 
574  /*$caption = new ilTextInputGUI("", "st_caption");
575  $caption->setSize(40);
576  $caption->setMaxLength(200);
577  $op2->addSubItem($caption);*/
578  $rad_caption->addOption($op2);
579  $this->form_gui->addItem($rad_caption);
580 
581  // standard text representation
582  if (substr($std_item->getFormat(), 0, 5) == "image")
583  {
584  $rad_tr = new ilRadioGroupInputGUI($lng->txt("text_repr"), "st_derive_text_representation");
585  $op1 = new ilRadioOption($lng->txt("cont_default"), "y");
586  $def_tr = new ilNonEditableValueGUI("", "def_text_representation");
587  $op1->addSubItem($def_tr);
588  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
589  $tr = new ilTextAreaInputGUI("", "st_text_representation");
590  $tr->setCols(30);
591  $tr->setRows(2);
592  $rad_tr->addOption($op1);
593  $op2->addSubItem($tr);
594  $rad_tr->addOption($op2);
595  $this->form_gui->addItem($rad_tr);
596  $rad_tr->setInfo($lng->txt("text_repr_info"));
597  }
598 
599  // standard parameters
600  if (!in_array($std_item->getFormat(), ilObjMediaObject::_getSimpleMimeTypes()))
601  {
602  if (ilObjMediaObject::_useAutoStartParameterOnly($std_item->getLocation(),
603  $std_item->getFormat())) // autostart
604  {
605  $par = $std_item->getParameters();
606  $def_str = ($par["autostart"] == "true")
607  ? " (".$lng->txt("yes").")"
608  : " (".$lng->txt("no").")";
609  $rad_auto = new ilRadioGroupInputGUI($lng->txt("cont_autostart"),
610  "st_derive_parameters");
611  $op1 = new ilRadioOption($lng->txt("cont_default").$def_str, "y");
612  $rad_auto->addOption($op1);
613  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
614  $auto = new ilCheckboxInputGUI($lng->txt("enabled"), "st_autostart");
615  $op2->addSubItem($auto);
616  $rad_auto->addOption($op2);
617  $this->form_gui->addItem($rad_auto);
618  }
619  else // parameters
620  {
621  $rad_parameters = new ilRadioGroupInputGUI($lng->txt("cont_parameter"), "st_derive_parameters");
622  $op1 = new ilRadioOption($lng->txt("cont_default"), "y");
623  $def_par = new ilNonEditableValueGUI("", "def_parameters");
624  $op1->addSubItem($def_par);
625  $rad_parameters->addOption($op1);
626  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
627  $par = new ilTextAreaInputGUI("", "st_parameters");
628  $par->setRows(5);
629  $par->setCols(50);
630  $op2->addSubItem($par);
631  $rad_parameters->addOption($op2);
632  $this->form_gui->addItem($rad_parameters);
633  }
634  }
635 
636  // fullscreen view
637  if($this->content_obj->getMediaObject()->hasFullScreenItem())
638  {
639  $full_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Fullscreen",
640  $this->content_obj->getPcId());
641  $full_item = $this->content_obj->getMediaObject()->getMediaItem("Fullscreen");
642 
643  $fs_sec = new ilFormSectionHeaderGUI();
644  $fs_sec->setTitle($lng->txt("cont_fullscreen"));
645  $this->form_gui->addItem($fs_sec);
646 
647 
648  // resource
649  $radio_prop = new ilRadioGroupInputGUI($lng->txt("cont_resource"), "fullscreen");
650  $op1 = new ilRadioOption($lng->txt("cont_none"), "n");
651  $radio_prop->addOption($op1);
652  $op2 = new ilRadioOption($this->lng->txt("cont_".strtolower($full_item->getLocationType())).": ".
653  $full_item->getLocation(), "y");
654  $radio_prop->addOption($op2);
655  $this->form_gui->addItem($radio_prop);
656 
657  // format
658  $format = new ilNonEditableValueGUI(
659  $this->lng->txt("cont_format"), "full_format");
660  $this->form_gui->addItem($format);
661 
662  // full size
663  $radio_size = new ilRadioGroupInputGUI($lng->txt("size"), "full_derive_size");
664  $op1 = new ilRadioOption($lng->txt("cont_default").
665  " (".$full_item->getWidth()." x ".$full_item->getHeight().")", "y");
666  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
667  $radio_size->addOption($op1);
668 
669  // width height
670  include_once("./Services/MediaObjects/classes/class.ilWidthHeightInputGUI.php");
671  $width_height = new ilWidthHeightInputGUI($lng->txt("cont_width").
672  " / ".$lng->txt("cont_height"), "full_width_height");
673  $width_height->setConstrainProportions(true);
674  $op2->addSubItem($width_height);
675 
676  $radio_size->addOption($op2);
677  $this->form_gui->addItem($radio_size);
678 
679  // fullscreen caption
680  $rad_caption = new ilRadioGroupInputGUI($lng->txt("cont_caption"), "full_derive_caption");
681  $op1 = new ilRadioOption($lng->txt("cont_default"), "y");
682  $def_cap = new ilNonEditableValueGUI("", "full_def_caption");
683  $op1->addSubItem($def_cap);
684  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
685  $rad_caption->addOption($op1);
686 
687  $caption = new ilTextAreaInputGUI("", "full_caption");
688  $caption->setCols(30);
689  $caption->setRows(2);
690  $op2->addSubItem($caption);
691 
692  /*$caption = new ilTextInputGUI("", "full_caption");
693  $caption->setSize(40);
694  $caption->setMaxLength(200);
695  $op2->addSubItem($caption);*/
696  $rad_caption->addOption($op2);
697  $this->form_gui->addItem($rad_caption);
698 
699  // fullscreen text representation
700  if (substr($full_item->getFormat(), 0, 5) == "image")
701  {
702  $rad_tr = new ilRadioGroupInputGUI($lng->txt("text_repr"), "full_derive_text_representation");
703  $op1 = new ilRadioOption($lng->txt("cont_default"), "y");
704  $def_tr = new ilNonEditableValueGUI("", "full_def_text_representation");
705  $op1->addSubItem($def_tr);
706  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
707  $tr = new ilTextAreaInputGUI("", "full_text_representation");
708  $tr->setCols(30);
709  $tr->setRows(2);
710  $rad_tr->addOption($op1);
711  $op2->addSubItem($tr);
712  $rad_tr->addOption($op2);
713  $this->form_gui->addItem($rad_tr);
714  $rad_tr->setInfo($lng->txt("text_repr_info"));
715  }
716 
717  // fullscreen parameters
718  if (!in_array($full_item->getFormat(), ilObjMediaObject::_getSimpleMimeTypes()))
719  {
720  if (ilObjMediaObject::_useAutoStartParameterOnly($full_item->getLocation(),
721  $full_item->getFormat())) // autostart
722  {
723  $par = $full_item->getParameters();
724  $def_str = ($par["autostart"] == "true")
725  ? " (".$lng->txt("yes").")"
726  : " (".$lng->txt("no").")";
727  $rad_auto = new ilRadioGroupInputGUI($lng->txt("cont_autostart"),
728  "full_derive_parameters");
729  $op1 = new ilRadioOption($lng->txt("cont_default").$def_str, "y");
730  $rad_auto->addOption($op1);
731  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
732  $auto = new ilCheckboxInputGUI($lng->txt("enabled"), "full_autostart");
733  $op2->addSubItem($auto);
734  $rad_auto->addOption($op2);
735  $this->form_gui->addItem($rad_auto);
736  }
737  else // parameters
738  {
739  $rad_parameters = new ilRadioGroupInputGUI($lng->txt("cont_parameter"), "full_derive_parameters");
740  $op1 = new ilRadioOption($lng->txt("cont_default"), "y");
741  $def_par = new ilNonEditableValueGUI("", "full_def_parameters");
742  $op1->addSubItem($def_par);
743  $rad_parameters->addOption($op1);
744  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
745  $par = new ilTextAreaInputGUI("", "full_parameters");
746  $par->setRows(5);
747  $par->setCols(50);
748  $op2->addSubItem($par);
749  $rad_parameters->addOption($op2);
750  $this->form_gui->addItem($rad_parameters);
751  }
752  }
753  }
754 
755  $this->form_gui->setTitle($lng->txt("cont_edit_mob_alias_prop"));
756  $this->form_gui->addCommandButton("saveAliasProperties", $lng->txt("save"));
757  $lm_set = new ilSetting("lm");
758  if ($lm_set->get("replace_mob_feature"))
759  {
760  $this->form_gui->addCommandButton("changeObjectReference", $lng->txt("cont_change_object_reference"));
761  }
762  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
763  }
764 
768  function getAliasValues()
769  {
770  global $lng;
771 
772  // standard view resource
773  $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
774  $this->content_obj->getPcId());
775  $std_item = $this->content_obj->getMediaObject()->getMediaItem("Standard");
776 
777  $values["title"] = $this->content_obj->getMediaObject()->getTitle();
778  $values["st_location"] = $std_item->getLocation();
779  $values["st_format"] = $std_item->getFormat();
780 
781  // size
782  $values["st_width_height"]["width"] = $std_alias_item->getWidth();
783  $values["st_width_height"]["height"] = $std_alias_item->getHeight();
784  $values["st_width_height"]["constr_prop"] = true;
785 
786  // caption
787  $values["st_caption"] = $std_alias_item->getCaption();
788  if (trim($std_item->getCaption()) == "")
789  {
790  $values["def_caption"] = "<i>".$lng->txt("cont_no_caption")."</i>";
791  }
792  else
793  {
794  $values["def_caption"] = $std_item->getCaption();
795  }
796 
797  // text representation
798  $values["st_text_representation"] = $std_alias_item->getTextRepresentation();
799  if (trim($std_item->getTextRepresentation()) == "")
800  {
801  $values["def_text_representation"] = "<i>".$lng->txt("cont_no_text")."</i>";
802  }
803  else
804  {
805  $values["def_text_representation"] = $std_item->getTextRepresentation();
806  }
807 
808  // parameters / autostart
809  if (ilObjMediaObject::_useAutoStartParameterOnly($std_item->getLocation(),
810  $std_item->getFormat())) // autostart
811  {
812  $par = $std_alias_item->getParameters();
813  if ($par["autostart"] == "true")
814  {
815  $values["st_autostart"] = true;
816  }
817  }
818  else // parameters
819  {
820  $values["st_parameters"] = $std_alias_item->getParameterString();
821  }
822 
823  // size
824  $values["st_derive_size"] = $std_alias_item->definesSize()
825  ? "n"
826  : "y";
827  if ($values["st_derive_size"] == "y")
828  {
829  $values["st_width_height"]["width"] = $std_item->getWidth();
830  $values["st_width_height"]["height"] = $std_item->getHeight();
831  }
832  $values["st_derive_caption"] = $std_alias_item->definesCaption()
833  ? "n"
834  : "y";
835  $values["st_derive_text_representation"] = $std_alias_item->definesTextRepresentation()
836  ? "n"
837  : "y";
838  $values["st_derive_parameters"] = $std_alias_item->definesParameters()
839  ? "n"
840  : "y";
841  if (trim($std_item->getParameterString()) == "")
842  {
843  $values["def_parameters"] = "<i>".$lng->txt("cont_no_parameters")."</i>";
844  }
845  else
846  {
847  $values["def_parameters"] = $std_item->getParameterString();
848  }
849 
850  // fullscreen properties
851  if($this->content_obj->getMediaObject()->hasFullScreenItem())
852  {
853  $full_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Fullscreen",
854  $this->content_obj->getPcId());
855  $full_item = $this->content_obj->getMediaObject()->getMediaItem("Fullscreen");
856 
857  $values["fullscreen"] = "n";
858  if ($full_alias_item->exists())
859  {
860  $values["fullscreen"] = "y";
861  }
862 
863  $values["full_location"] = $full_item->getLocation();
864  $values["full_format"] = $full_item->getFormat();
865  $values["full_width_height"]["width"] = $full_alias_item->getWidth();
866  $values["full_width_height"]["height"] = $full_alias_item->getHeight();
867  $values["full_width_height"]["constr_prop"] = true;
868  $values["full_caption"] = $full_alias_item->getCaption();
869  if (trim($full_item->getCaption()) == "")
870  {
871  $values["full_def_caption"] = "<i>".$lng->txt("cont_no_caption")."</i>";
872  }
873  else
874  {
875  $values["full_def_caption"] = $full_item->getCaption();
876  }
877  $values["full_text_representation"] = $full_alias_item->getTextRepresentation();
878  if (trim($full_item->getTextRepresentation()) == "")
879  {
880  $values["full_def_text_representation"] = "<i>".$lng->txt("cont_no_text")."</i>";
881  }
882  else
883  {
884  $values["full_def_text_representation"] = $full_item->getTextRepresentation();
885  }
886  $values["full_parameters"] = $full_alias_item->getParameterString();
887  $values["full_derive_size"] = $full_alias_item->definesSize()
888  ? "n"
889  : "y";
890  if ($values["full_derive_size"] == "y")
891  {
892  $values["full_width_height"]["width"] = $full_item->getWidth();
893  $values["full_width_height"]["height"] = $full_item->getHeight();
894  }
895  $values["full_derive_caption"] = $full_alias_item->definesCaption()
896  ? "n"
897  : "y";
898  $values["full_derive_text_representation"] = $full_alias_item->definesTextRepresentation()
899  ? "n"
900  : "y";
901 
902  // parameters
903  if (ilObjMediaObject::_useAutoStartParameterOnly($full_item->getLocation(),
904  $full_item->getFormat())) // autostart
905  {
906  $par = $full_alias_item->getParameters();
907  if ($par["autostart"] == "true")
908  {
909  $values["full_autostart"] = true;
910  }
911  }
912  else // parameters
913  {
914  $values["full_parameters"] = $full_alias_item->getParameterString();
915  }
916 
917  $values["full_derive_parameters"] = $full_alias_item->definesParameters()
918  ? "n"
919  : "y";
920  if (trim($full_item->getParameterString()) == "")
921  {
922  $values["full_def_parameters"] = "<i>".$lng->txt("cont_no_parameters")."</i>";
923  }
924  else
925  {
926  $values["full_def_parameters"] = $full_item->getParameterString();
927  }
928 
929  }
930 
931  $this->form_gui->setValuesByArray($values);
932  }
933 
938  {
939  $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
940  $this->content_obj->getPcId());
941  $full_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Fullscreen",
942  $this->content_obj->getPcId());
943  $std_item = $this->content_obj->getMediaObject()->getMediaItem("Standard");
944  $full_item = $this->content_obj->getMediaObject()->getMediaItem("Fullscreen");
945 
946  // standard size
947  if($_POST["st_derive_size"] == "y")
948  {
949  $std_alias_item->deriveSize();
950  }
951  else
952  {
953  $std_alias_item->setWidth(ilUtil::stripSlashes($_POST["st_width_height"]["width"]));
954  $std_alias_item->setHeight(ilUtil::stripSlashes($_POST["st_width_height"]["height"]));
955  }
956 
957  // standard caption
958  if($_POST["st_derive_caption"] == "y")
959  {
960  $std_alias_item->deriveCaption();
961  }
962  else
963  {
964  $std_alias_item->setCaption(ilUtil::stripSlashes($_POST["st_caption"]));
965  }
966 
967  // text representation
968  if($_POST["st_derive_text_representation"] == "y")
969  {
970  $std_alias_item->deriveTextRepresentation();
971  }
972  else
973  {
974  $std_alias_item->setTextRepresentation(ilUtil::stripSlashes($_POST["st_text_representation"]));
975  }
976 
977  // standard parameters
978  if($_POST["st_derive_parameters"] == "y")
979  {
980  $std_alias_item->deriveParameters();
981  }
982  else
983  {
984  if (ilObjMediaObject::_useAutoStartParameterOnly($std_item->getLocation(),
985  $std_item->getFormat())) // autostart
986  {
987  if ($_POST["st_autostart"])
988  {
989  $std_alias_item->setParameters(ilUtil::extractParameterString('autostart="true"'));
990  }
991  else
992  {
993  $std_alias_item->setParameters(ilUtil::extractParameterString('autostart="false"'));
994  }
995  }
996  else // parameters
997  {
998  $std_alias_item->setParameters(ilUtil::extractParameterString(ilUtil::stripSlashes(utf8_decode($_POST["st_parameters"]))));
999  }
1000  }
1001 
1002  if($this->content_obj->getMediaObject()->hasFullscreenItem())
1003  {
1004  if ($_POST["fullscreen"] == "y")
1005  {
1006  if (!$full_alias_item->exists())
1007  {
1008  $full_alias_item->insert();
1009  }
1010 
1011  // fullscreen size
1012  if($_POST["full_derive_size"] == "y")
1013  {
1014  $full_alias_item->deriveSize();
1015  }
1016  else
1017  {
1018  $full_alias_item->setWidth(ilUtil::stripSlashes($_POST["full_width_height"]["width"]));
1019  $full_alias_item->setHeight(ilUtil::stripSlashes($_POST["full_width_height"]["height"]));
1020  }
1021 
1022  // fullscreen caption
1023  if($_POST["full_derive_caption"] == "y")
1024  {
1025  $full_alias_item->deriveCaption();
1026  }
1027  else
1028  {
1029  $full_alias_item->setCaption(ilUtil::stripSlashes($_POST["full_caption"]));
1030  }
1031 
1032  // fullscreen text representation
1033  if($_POST["full_derive_text_representation"] == "y")
1034  {
1035  $full_alias_item->deriveTextRepresentation();
1036  }
1037  else
1038  {
1039  $full_alias_item->setTextRepresentation(ilUtil::stripSlashes($_POST["full_text_representation"]));
1040  }
1041 
1042  // fullscreen parameters
1043  if($_POST["full_derive_parameters"] == "y")
1044  {
1045  $full_alias_item->deriveParameters();
1046  }
1047  else
1048  {
1049  if (ilObjMediaObject::_useAutoStartParameterOnly($full_item->getLocation(),
1050  $full_item->getFormat())) // autostart
1051  {
1052  if ($_POST["full_autostart"])
1053  {
1054  $full_alias_item->setParameters(ilUtil::extractParameterString('autostart="true"'));
1055  }
1056  else
1057  {
1058  $full_alias_item->setParameters(ilUtil::extractParameterString('autostart="false"'));
1059  }
1060  }
1061  else
1062  {
1063  $full_alias_item->setParameters(ilUtil::extractParameterString(ilUtil::stripSlashes(utf8_decode($_POST["full_parameters"]))));
1064  }
1065  }
1066  }
1067  else
1068  {
1069  if ($full_alias_item->exists())
1070  {
1071  $full_alias_item->delete();
1072  }
1073  }
1074  }
1075 
1076  $this->updated = $this->pg_obj->update();
1077  if ($this->updated === true)
1078  {
1079  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
1080  }
1081  else
1082  {
1083  $this->pg_obj->addHierIDs();
1084  $this->editAlias();
1085  }
1086  }
1087 
1091  function copyToClipboard()
1092  {
1093  $this->ilias->account->addObjectToClipboard($this->content_obj->getMediaObject()->getId(), $this->content_obj->getMediaObject()->getType()
1094  , $this->content_obj->getMediaObject()->getTitle());
1095  ilUtil::sendSuccess($this->lng->txt("copied_to_clipboard"), true);
1096  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
1097  }
1098 
1102  function centerAlign()
1103  {
1104  $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
1105  $this->content_obj->getPcId());
1106  $std_alias_item->setHorizontalAlign("Center");
1107  $_SESSION["il_pg_error"] = $this->pg_obj->update();
1108  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
1109  }
1110 
1114  function leftAlign()
1115  {
1116  $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
1117  $this->content_obj->getPcId());
1118  $std_alias_item->setHorizontalAlign("Left");
1119  $_SESSION["il_pg_error"] = $this->pg_obj->update();
1120  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
1121  }
1122 
1126  function rightAlign()
1127  {
1128  $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
1129  $this->content_obj->getPcId());
1130  $std_alias_item->setHorizontalAlign("Right");
1131  $_SESSION["il_pg_error"] = $this->pg_obj->update();
1132  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
1133  }
1134 
1138  function leftFloatAlign()
1139  {
1140  $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
1141  $this->content_obj->getPcId());
1142  $std_alias_item->setHorizontalAlign("LeftFloat");
1143  $_SESSION["il_pg_error"] = $this->pg_obj->update();
1144  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
1145  }
1146 
1150  function rightFloatAlign()
1151  {
1152  $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
1153  $this->content_obj->getPcId());
1154  $std_alias_item->setHorizontalAlign("RightFloat");
1155  $_SESSION["il_pg_error"] = $this->pg_obj->update();
1156  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
1157  }
1158 
1163  {
1164  // check whether there is more than one style class
1165  $chars = $this->getCharacteristics();
1166 
1167  if (count($chars) > 1 ||
1168  ($this->content_obj->getClass() != "" && $this->content_obj->getClass() != "Media"))
1169  {
1170  return true;
1171  }
1172  return false;
1173  }
1174 
1178  function editStyle()
1179  {
1180  global $ilCtrl, $tpl, $lng;
1181 
1182  $this->displayValidationError();
1183 
1184  // edit form
1185  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1186  $form = new ilPropertyFormGUI();
1187  $form->setFormAction($ilCtrl->getFormAction($this));
1188  $form->setTitle($this->lng->txt("cont_edit_style"));
1189 
1190  // characteristic selection
1191  require_once("./Services/Form/classes/class.ilAdvSelectInputGUI.php");
1192  $char_prop = new ilAdvSelectInputGUI($this->lng->txt("cont_characteristic"),
1193  "characteristic");
1194 
1195  $chars = $this->getCharacteristics();
1196  if (is_object($this->content_obj))
1197  {
1198  if ($chars[$a_seleted_value] == "" && ($this->content_obj->getClass() != ""))
1199  {
1200  $chars = array_merge(
1201  array($this->content_obj->getClass() => $this->content_obj->getClass()),
1202  $chars);
1203  }
1204  }
1205 
1206  $selected = $this->content_obj->getClass();
1207  if ($selected == "")
1208  {
1209  $selected = "MediaContainer";
1210  }
1211 
1212  foreach ($chars as $k => $char)
1213  {
1214  $html = '<table class="ilc_media_cont_'.$k.'"><tr><td>'.
1215  $char.'</td></tr></table>';
1216  $char_prop->addOption($k, $char, $html);
1217  }
1218 
1219  $char_prop->setValue($selected);
1220  $form->addItem($char_prop);
1221 
1222  // save button
1223  $form->addCommandButton("saveStyle", $lng->txt("save"));
1224 
1225  $html = $form->getHTML();
1226  $tpl->setContent($html);
1227  return $ret;
1228  }
1229 
1233  function saveStyle()
1234  {
1235  $this->content_obj->setClass($_POST["characteristic"]);
1236  $this->updated = $this->pg_obj->update();
1237  if ($this->updated === true)
1238  {
1239  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
1240  }
1241  else
1242  {
1243  $this->pg_obj->addHierIDs();
1244  $this->editStyle();
1245  }
1246  }
1247 
1254  function getTabs(&$tab_gui, $a_create = false, $a_change_obj_ref = false)
1255  {
1256  global $ilCtrl, $ilTabs;
1257 
1258  if (!$a_create)
1259  {
1260  if ($this->checkStyleSelection())
1261  {
1262  $ilTabs->addTarget("cont_style",
1263  $ilCtrl->getLinkTarget($this, "editStyle"), "editStyle",
1264  get_class($this));
1265  }
1266 
1267  $ilTabs->addTarget("cont_mob_inst_prop",
1268  $ilCtrl->getLinkTarget($this, "editAlias"), "editAlias",
1269  get_class($this));
1270 
1271  if ($this->getEnabledMapAreas())
1272  {
1273  $st_item = $this->content_obj->getMediaObject()->getMediaItem("Standard");
1274  if (is_object($st_item))
1275  {
1276  $format = $st_item->getFormat();
1277  if (substr($format, 0, 5) == "image")
1278  {
1279  $ilTabs->addTarget("cont_inst_map_areas",
1280  $ilCtrl->getLinkTargetByClass("ilpcimagemapeditorgui", "editMapAreas"), array(),
1281  "ilpcimagemapeditorgui");
1282  }
1283  }
1284  }
1285  }
1286  else
1287  {
1288  if ($a_change_obj_ref)
1289  {
1290  $cmd = "changeObjectReference";
1291  }
1292  else
1293  {
1294  $cmd = "insert";
1295  }
1296 
1297  $ilCtrl->setParameter($this, "subCmd", "insertNew");
1298  $ilTabs->addSubTabTarget("cont_new_mob",
1299  $ilCtrl->getLinkTarget($this, $cmd), $cmd);
1300 
1301  $ilCtrl->setParameter($this, "subCmd", "insertFromPool");
1302  $ilTabs->addSubTabTarget("cont_mob_from_media_pool",
1303  $ilCtrl->getLinkTarget($this, $cmd), $cmd);
1304  $ilCtrl->setParameter($this, "subCmd", "");
1305  }
1306  }
1307 
1308 }
1309 ?>