ILIAS  Release_4_0_x_branch Revision 61816
 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.gif"));
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.gif"));
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")
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  $mob_gui = new ilObjMediaObjectGUI("");
177  $mob_gui->initForm("create");
178  $form = $mob_gui->getForm();
179  $form->setFormAction($ilCtrl->getFormAction($this));
180  $form->clearCommandButtons();
181  $form->addCommandButton("create_mob", $lng->txt("save"));
182  $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
183 
184  $this->displayValidationError();
185 
186  $tpl->setContent($form->getHTML());
187 
188  break;
189  }
190  }
191 
192  // #openconst-start
197  {
198  global $ilTabs, $ilCtrl, $lng;
199 
200  if ($_GET["subCmd"] == "insertNew")
201  {
202  $_SESSION["cont_media_insert"] = "insertNew";
203  }
204  if ($_GET["subCmd"] == "insertFromPool")
205  {
206  $_SESSION["cont_media_insert"] = "insertFromPool";
207  }
208 
209  if (($_GET["subCmd"] == "") && $_SESSION["cont_media_insert"] != "")
210  {
211  $_GET["subCmd"] = $_SESSION["cont_media_insert"];
212  }
213 
214  switch ($_GET["subCmd"])
215  {
216  case "insertFromPool":
217  $this->insertFromPool(true);
218  break;
219 
220  case "poolSelection":
221  $this->poolSelection(true);
222  break;
223 
224  case "selectPool":
225  $this->selectPool(true);
226  break;
227 
228  case "insertNew":
229  default:
230  $ilCtrl->setParameter($this, "subCmd", "changeObjectReference");
231  $this->getTabs($ilTabs, true, true);
232  $ilTabs->setSubTabActive("cont_new_mob");
233 
234  $this->displayValidationError();
235 
236  $mob_gui = new ilObjMediaObjectGUI("");
237  $mob_gui->initForm("create");
238  $form = $mob_gui->getForm();
239  $form->setFormAction($ilCtrl->getFormAction($this));
240  $form->clearCommandButtons();
241  $form->addCommandButton("createNewObjectReference", $lng->txt("save"));
242  $form->addCommandButton("cancelCreate", $lng->txt("cancel"));
243  $this->tpl->setContent($form->getHTML());
244  }
245  }
246  // #openconst-end
247 
251  function insertFromPool($a_change_obj_ref = false)
252  {
253  global $ilCtrl, $ilAccess, $ilTabs, $tpl, $lng;
254 
255 
256  if ($_SESSION["cont_media_pool"] != "" &&
257  $ilAccess->checkAccess("write", "", $_SESSION["cont_media_pool"])
258  && ilObject::_lookupType(ilObject::_lookupObjId($_SESSION["cont_media_pool"])) == "mep")
259  {
260  $tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
261  $tpl->setCurrentBlock("btn_cell");
262  $ilCtrl->setParameter($this, "subCmd", "poolSelection");
263  if ($a_change_obj_ref)
264  {
265  $tpl->setVariable("BTN_LINK",
266  $ilCtrl->getLinkTarget($this, "changeObjectReference"));
267  }
268  else
269  {
270  $tpl->setVariable("BTN_LINK",
271  $ilCtrl->getLinkTarget($this, "insert"));
272  }
273  $ilCtrl->setParameter($this, "subCmd", "");
274  $tpl->setVariable("BTN_TXT", $lng->txt("cont_select_media_pool"));
275  $tpl->parseCurrentBlock();
276 
277  $this->getTabs($ilTabs, true, $a_change_obj_ref);
278  $ilTabs->setSubTabActive("cont_mob_from_media_pool");
279 
280  include_once("./Modules/MediaPool/classes/class.ilObjMediaPool.php");
281  include_once("./Modules/MediaPool/classes/class.ilMediaPoolTableGUI.php");
282  $pool = new ilObjMediaPool($_SESSION["cont_media_pool"]);
283  $ilCtrl->setParameter($this, "subCmd", "insertFromPool");
284  $tcmd = ($a_change_obj_ref)
285  ? "changeObjectReference"
286  : "insert";
287  $tmode = ($a_change_obj_ref)
290  $mpool_table = new ilMediaPoolTableGUI($this, $tcmd, $pool, "mep_folder",
291  $tmode);
292 
293  $tpl->setContent($mpool_table->getHTML());
294  }
295  else
296  {
297  $this->poolSelection($a_change_obj_ref);
298  }
299  }
300 
304  function selectPool($a_change_obj_ref = false)
305  {
306  global $ilCtrl;
307 
308  $_SESSION["cont_media_pool"] = $_GET["pool_ref_id"];
309  $ilCtrl->setParameter($this, "subCmd", "insertFromPool");
310  if ($a_change_obj_ref)
311  {
312  $ilCtrl->redirect($this, "changeObjectReference");
313  }
314  else
315  {
316  $ilCtrl->redirect($this, "insert");
317  }
318  }
319 
323  function poolSelection($a_change_obj_ref = false)
324  {
325  global $ilCtrl, $tree, $tpl, $ilTabs;
326 
327  $this->getTabs($ilTabs, true, $a_change_obj_ref);
328  $ilTabs->setSubTabActive("cont_mob_from_media_pool");
329 
330  include_once "./Services/COPage/classes/class.ilPoolSelectorGUI.php";
331 
332  if ($a_change_obj_ref)
333  {
334  $exp = new ilPoolSelectorGUI($this->ctrl->getLinkTarget($this, "changeObjectReference"));
335  }
336  else
337  {
338  $exp = new ilPoolSelectorGUI($this->ctrl->getLinkTarget($this, "insert"));
339  }
340  if ($_GET["expand"] == "")
341  {
342  $expanded = $tree->readRootId();
343  }
344  else
345  {
346  $expanded = $_GET["expand"];
347  }
348  $exp->setExpand($expanded);
349 
350  $exp->setTargetGet("sel_id");
351  $this->ctrl->setParameter($this, "target_type", $a_type);
352  $ilCtrl->setParameter($this, "subCmd", "poolSelection");
353  if ($a_change_obj_ref)
354  {
355  $exp->setParamsGet($this->ctrl->getParameterArray($this, "changeObjectReference"));
356  }
357  else
358  {
359  $exp->setParamsGet($this->ctrl->getParameterArray($this, "insert"));
360  }
361 
362  // filter
363  $exp->setFiltered(true);
364  $exp->setFilterMode(IL_FM_POSITIVE);
365  $exp->addFilter("root");
366  $exp->addFilter("cat");
367  $exp->addFilter("grp");
368  $exp->addFilter("fold");
369  $exp->addFilter("crs");
370  $exp->addFilter("mep");
371 
372  $sel_types = array('mep');
373 
374  $exp->setOutput(0);
375 
376  $tpl->setContent($exp->getOutput());
377  }
378 
379 
385  {
386  $this->create(false, true);
387  }
388 
394  {
395  global $ilCtrl, $lng;
396  if (is_array($_POST["id"]) && count($_POST["id"]) == 1)
397  {
398  include_once("./Services/COPage/classes/class.ilPCMediaObject.php");
399  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
400  $fid = ilMediaPoolItem::lookupForeignId($_POST["id"][0]);
401  $this->content_obj->readMediaObject($fid);
402  $this->content_obj->updateObjectReference();
403  $this->updated = $this->pg_obj->update();
404  }
405  else
406  {
407  ilUtil::sendInfo($lng->txt("cont_select_max_one_item"), true);
408  $ilCtrl->redirect($this, "changeObjectReference");
409 
410  }
411  $ilCtrl->redirect($this, "editAlias");
412  }
413 
417  function &create($a_create_alias = true, $a_change_obj_ref = false)
418  {
419  global $ilCtrl, $lng;
420 
421  if ($_GET["subCmd"] == "insertFromPool")
422  {
423  if (is_array($_POST["id"]))
424  {
425  for($i = count($_POST["id"]) - 1; $i>=0; $i--)
426  {
427  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
428  $fid = ilMediaPoolItem::lookupForeignId($_POST["id"][$i]);
429  include_once("./Services/COPage/classes/class.ilPCMediaObject.php");
430  $this->content_obj = new ilPCMediaObject($this->dom);
431  $this->content_obj->readMediaObject($fid);
432  $this->content_obj->createAlias($this->pg_obj, $_GET["hier_id"], $this->pc_id);
433  }
434  $this->updated = $this->pg_obj->update();
435  }
436 
437  $ilCtrl->returnToParent($this);
438  }
439 
440  // create dummy object in db (we need an id)
441  include_once("./Services/COPage/classes/class.ilPCMediaObject.php");
442  if ($a_change_obj_ref != true)
443  {
444  $this->content_obj = new ilPCMediaObject($this->dom);
445  }
446  $this->content_obj->createMediaObject();
447  $media_obj = $this->content_obj->getMediaObject();
448 
449  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
451 
452  if ($a_create_alias)
453  {
454  // need a pcmediaobject here
455  //$this->node = $this->createPageContentNode();
456 
457  $this->content_obj->createAlias($this->pg_obj, $this->hier_id, $this->pc_id);
458  $this->updated = $this->pg_obj->update();
459  if ($this->updated === true)
460  {
461  $this->pg_obj->stripHierIDs();
462  $this->pg_obj->addHierIDs();
463  $ilCtrl->setParameter($this, "hier_id", $this->content_obj->readHierId());
464  $ilCtrl->setParameter($this, "pc_id", $this->content_obj->readPCId());
465  $this->content_obj->setHierId($this->content_obj->readHierId());
466  $this->setHierId($this->content_obj->readHierId());
467  $this->content_obj->setPCId($this->content_obj->readPCId());
468  ilUtil::sendSuccess($lng->txt("saved_media_object"), true);
469  $this->ctrl->redirectByClass("ilobjmediaobjectgui", "edit");
470 
471  //$this->ctrl->returnToParent($this, "jump".$this->hier_id);
472  }
473  else
474  {
475  $this->insert();
476  }
477  }
478  else
479  {
480  if ($a_change_obj_ref == true)
481  {
482  $this->content_obj->updateObjectReference();
483  $this->updated = $this->pg_obj->update();
484  $this->ctrl->redirect($this, "editAlias");
485  }
486  return $this->content_obj;
487  }
488  }
489 
490 
494  function editAlias()
495  {
496  global $tpl;
497 
498  $this->initAliasForm();
499  $this->getAliasValues();
500  $tpl->setContent($this->form_gui->getHTML());
501  }
502 
506  function initAliasForm()
507  {
508  global $lng, $ilCtrl;
509 
510  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
511 
512  $this->form_gui = new ilPropertyFormGUI();
513 
514  // standard view resource
515  $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
516  $this->content_obj->getPcId());
517  $std_item = $this->content_obj->getMediaObject()->getMediaItem("Standard");
518 
519  // title, location and format
520  $title = new ilNonEditableValueGUI($lng->txt("title"), "title");
521  $this->form_gui->addItem($title);
522  $loc = new ilNonEditableValueGUI(
523  $this->lng->txt("cont_".strtolower($std_item->getLocationType())), "st_location");
524  $this->form_gui->addItem($loc);
525  $format = new ilNonEditableValueGUI(
526  $this->lng->txt("cont_format"), "st_format");
527  $this->form_gui->addItem($format);
528 
529  // standard size
530  $radio_size = new ilRadioGroupInputGUI($lng->txt("size"), "st_derive_size");
531  $op1 = new ilRadioOption($lng->txt("cont_default").
532  " (".$std_item->getWidth()." x ".$std_item->getHeight().")", "y");
533  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
534  $radio_size->addOption($op1);
535 
536  // width height
537  include_once("./Services/MediaObjects/classes/class.ilWidthHeightInputGUI.php");
538  $width_height = new ilWidthHeightInputGUI($lng->txt("cont_width").
539  " / ".$lng->txt("cont_height"), "st_width_height");
540  $width_height->setConstrainProportions(true);
541  $op2->addSubItem($width_height);
542 
543  $radio_size->addOption($op2);
544  $this->form_gui->addItem($radio_size);
545 
546  // standard caption
547  $rad_caption = new ilRadioGroupInputGUI($lng->txt("cont_caption"), "st_derive_caption");
548  $op1 = new ilRadioOption($lng->txt("cont_default"), "y");
549  $def_cap = new ilNonEditableValueGUI("", "def_caption");
550  $op1->addSubItem($def_cap);
551  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
552  $caption = new ilTextInputGUI("", "st_caption");
553  $rad_caption->addOption($op1);
554  $caption->setSize(40);
555  $caption->setMaxLength(200);
556  $op2->addSubItem($caption);
557  $rad_caption->addOption($op2);
558  $this->form_gui->addItem($rad_caption);
559 
560  // standard text representation
561  if (substr($std_item->getFormat(), 0, 5) == "image")
562  {
563  $rad_tr = new ilRadioGroupInputGUI($lng->txt("text_repr"), "st_derive_text_representation");
564  $op1 = new ilRadioOption($lng->txt("cont_default"), "y");
565  $def_tr = new ilNonEditableValueGUI("", "def_text_representation");
566  $op1->addSubItem($def_tr);
567  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
568  $tr = new ilTextAreaInputGUI("", "st_text_representation");
569  $tr->setCols(30);
570  $tr->setRows(2);
571  $rad_tr->addOption($op1);
572  $op2->addSubItem($tr);
573  $rad_tr->addOption($op2);
574  $this->form_gui->addItem($rad_tr);
575  $rad_tr->setInfo($lng->txt("text_repr_info"));
576  }
577 
578  // standard parameters
579  if (!in_array($std_item->getFormat(), ilObjMediaObject::_getSimpleMimeTypes()))
580  {
581  if (ilObjMediaObject::_useAutoStartParameterOnly($std_item->getLocation(),
582  $std_item->getFormat())) // autostart
583  {
584  $par = $std_item->getParameters();
585  $def_str = ($par["autostart"] == "true")
586  ? " (".$lng->txt("yes").")"
587  : " (".$lng->txt("no").")";
588  $rad_auto = new ilRadioGroupInputGUI($lng->txt("cont_autostart"),
589  "st_derive_parameters");
590  $op1 = new ilRadioOption($lng->txt("cont_default").$def_str, "y");
591  $rad_auto->addOption($op1);
592  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
593  $auto = new ilCheckboxInputGUI($lng->txt("enabled"), "st_autostart");
594  $op2->addSubItem($auto);
595  $rad_auto->addOption($op2);
596  $this->form_gui->addItem($rad_auto);
597  }
598  else // parameters
599  {
600  $rad_parameters = new ilRadioGroupInputGUI($lng->txt("cont_parameter"), "st_derive_parameters");
601  $op1 = new ilRadioOption($lng->txt("cont_default"), "y");
602  $def_par = new ilNonEditableValueGUI("", "def_parameters");
603  $op1->addSubItem($def_par);
604  $rad_parameters->addOption($op1);
605  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
606  $par = new ilTextAreaInputGUI("", "st_parameters");
607  $par->setRows(5);
608  $par->setCols(50);
609  $op2->addSubItem($par);
610  $rad_parameters->addOption($op2);
611  $this->form_gui->addItem($rad_parameters);
612  }
613  }
614 
615  // fullscreen view
616  if($this->content_obj->getMediaObject()->hasFullScreenItem())
617  {
618  $full_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Fullscreen",
619  $this->content_obj->getPcId());
620  $full_item = $this->content_obj->getMediaObject()->getMediaItem("Fullscreen");
621 
622  $fs_sec = new ilFormSectionHeaderGUI();
623  $fs_sec->setTitle($lng->txt("cont_fullscreen"));
624  $this->form_gui->addItem($fs_sec);
625 
626 
627  // resource
628  $radio_prop = new ilRadioGroupInputGUI($lng->txt("cont_resource"), "fullscreen");
629  $op1 = new ilRadioOption($lng->txt("cont_none"), "n");
630  $radio_prop->addOption($op1);
631  $op2 = new ilRadioOption($this->lng->txt("cont_".strtolower($full_item->getLocationType())).": ".
632  $full_item->getLocation(), "y");
633  $radio_prop->addOption($op2);
634  $this->form_gui->addItem($radio_prop);
635 
636  // format
637  $format = new ilNonEditableValueGUI(
638  $this->lng->txt("cont_format"), "full_format");
639  $this->form_gui->addItem($format);
640 
641  // full size
642  $radio_size = new ilRadioGroupInputGUI($lng->txt("size"), "full_derive_size");
643  $op1 = new ilRadioOption($lng->txt("cont_default").
644  " (".$full_item->getWidth()." x ".$full_item->getHeight().")", "y");
645  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
646  $radio_size->addOption($op1);
647 
648  // width height
649  include_once("./Services/MediaObjects/classes/class.ilWidthHeightInputGUI.php");
650  $width_height = new ilWidthHeightInputGUI($lng->txt("cont_width").
651  " / ".$lng->txt("cont_height"), "full_width_height");
652  $width_height->setConstrainProportions(true);
653  $op2->addSubItem($width_height);
654 
655  $radio_size->addOption($op2);
656  $this->form_gui->addItem($radio_size);
657 
658  // fullscreen caption
659  $rad_caption = new ilRadioGroupInputGUI($lng->txt("cont_caption"), "full_derive_caption");
660  $op1 = new ilRadioOption($lng->txt("cont_default"), "y");
661  $def_cap = new ilNonEditableValueGUI("", "full_def_caption");
662  $op1->addSubItem($def_cap);
663  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
664  $caption = new ilTextInputGUI("", "full_caption");
665  $rad_caption->addOption($op1);
666  $caption->setSize(40);
667  $caption->setMaxLength(200);
668  $op2->addSubItem($caption);
669  $rad_caption->addOption($op2);
670  $this->form_gui->addItem($rad_caption);
671 
672  // fullscreen text representation
673  if (substr($full_item->getFormat(), 0, 5) == "image")
674  {
675  $rad_tr = new ilRadioGroupInputGUI($lng->txt("text_repr"), "full_derive_text_representation");
676  $op1 = new ilRadioOption($lng->txt("cont_default"), "y");
677  $def_tr = new ilNonEditableValueGUI("", "full_def_text_representation");
678  $op1->addSubItem($def_tr);
679  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
680  $tr = new ilTextAreaInputGUI("", "full_text_representation");
681  $tr->setCols(30);
682  $tr->setRows(2);
683  $rad_tr->addOption($op1);
684  $op2->addSubItem($tr);
685  $rad_tr->addOption($op2);
686  $this->form_gui->addItem($rad_tr);
687  $rad_tr->setInfo($lng->txt("text_repr_info"));
688  }
689 
690  // fullscreen parameters
691  if (!in_array($full_item->getFormat(), ilObjMediaObject::_getSimpleMimeTypes()))
692  {
693  if (ilObjMediaObject::_useAutoStartParameterOnly($full_item->getLocation(),
694  $full_item->getFormat())) // autostart
695  {
696  $par = $full_item->getParameters();
697  $def_str = ($par["autostart"] == "true")
698  ? " (".$lng->txt("yes").")"
699  : " (".$lng->txt("no").")";
700  $rad_auto = new ilRadioGroupInputGUI($lng->txt("cont_autostart"),
701  "full_derive_parameters");
702  $op1 = new ilRadioOption($lng->txt("cont_default").$def_str, "y");
703  $rad_auto->addOption($op1);
704  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
705  $auto = new ilCheckboxInputGUI($lng->txt("enabled"), "full_autostart");
706  $op2->addSubItem($auto);
707  $rad_auto->addOption($op2);
708  $this->form_gui->addItem($rad_auto);
709  }
710  else // parameters
711  {
712  $rad_parameters = new ilRadioGroupInputGUI($lng->txt("cont_parameter"), "full_derive_parameters");
713  $op1 = new ilRadioOption($lng->txt("cont_default"), "y");
714  $def_par = new ilNonEditableValueGUI("", "full_def_parameters");
715  $op1->addSubItem($def_par);
716  $rad_parameters->addOption($op1);
717  $op2 = new ilRadioOption($lng->txt("cont_custom"), "n");
718  $par = new ilTextAreaInputGUI("", "full_parameters");
719  $par->setRows(5);
720  $par->setCols(50);
721  $op2->addSubItem($par);
722  $rad_parameters->addOption($op2);
723  $this->form_gui->addItem($rad_parameters);
724  }
725  }
726  }
727 
728  $this->form_gui->setTitle($lng->txt("cont_edit_mob_alias_prop"));
729  $this->form_gui->addCommandButton("saveAliasProperties", $lng->txt("save"));
730  $lm_set = new ilSetting("lm");
731  if ($lm_set->get("replace_mob_feature"))
732  {
733  $this->form_gui->addCommandButton("changeObjectReference", $lng->txt("cont_change_object_reference"));
734  }
735  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
736  }
737 
741  function getAliasValues()
742  {
743  global $lng;
744 
745  // standard view resource
746  $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
747  $this->content_obj->getPcId());
748  $std_item = $this->content_obj->getMediaObject()->getMediaItem("Standard");
749 
750  $values["title"] = $this->content_obj->getMediaObject()->getTitle();
751  $values["st_location"] = $std_item->getLocation();
752  $values["st_format"] = $std_item->getFormat();
753 
754  // size
755  $values["st_width_height"]["width"] = $std_alias_item->getWidth();
756  $values["st_width_height"]["height"] = $std_alias_item->getHeight();
757  $values["st_width_height"]["constr_prop"] = true;
758 
759  // caption
760  $values["st_caption"] = $std_alias_item->getCaption();
761  if (trim($std_item->getCaption()) == "")
762  {
763  $values["def_caption"] = "<i>".$lng->txt("cont_no_caption")."</i>";
764  }
765  else
766  {
767  $values["def_caption"] = $std_item->getCaption();
768  }
769 
770  // text representation
771  $values["st_text_representation"] = $std_alias_item->getTextRepresentation();
772  if (trim($std_item->getTextRepresentation()) == "")
773  {
774  $values["def_text_representation"] = "<i>".$lng->txt("cont_no_text")."</i>";
775  }
776  else
777  {
778  $values["def_text_representation"] = $std_item->getTextRepresentation();
779  }
780 
781  // parameters / autostart
782  if (ilObjMediaObject::_useAutoStartParameterOnly($std_item->getLocation(),
783  $std_item->getFormat())) // autostart
784  {
785  $par = $std_alias_item->getParameters();
786  if ($par["autostart"] == "true")
787  {
788  $values["st_autostart"] = true;
789  }
790  }
791  else // parameters
792  {
793  $values["st_parameters"] = $std_alias_item->getParameterString();
794  }
795 
796  // size
797  $values["st_derive_size"] = $std_alias_item->definesSize()
798  ? "n"
799  : "y";
800  if ($values["st_derive_size"] == "y")
801  {
802  $values["st_width_height"]["width"] = $std_item->getWidth();
803  $values["st_width_height"]["height"] = $std_item->getHeight();
804  }
805  $values["st_derive_caption"] = $std_alias_item->definesCaption()
806  ? "n"
807  : "y";
808  $values["st_derive_text_representation"] = $std_alias_item->definesTextRepresentation()
809  ? "n"
810  : "y";
811  $values["st_derive_parameters"] = $std_alias_item->definesParameters()
812  ? "n"
813  : "y";
814  if (trim($std_item->getParameterString()) == "")
815  {
816  $values["def_parameters"] = "<i>".$lng->txt("cont_no_parameters")."</i>";
817  }
818  else
819  {
820  $values["def_parameters"] = $std_item->getParameterString();
821  }
822 
823  // fullscreen properties
824  if($this->content_obj->getMediaObject()->hasFullScreenItem())
825  {
826  $full_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Fullscreen",
827  $this->content_obj->getPcId());
828  $full_item = $this->content_obj->getMediaObject()->getMediaItem("Fullscreen");
829 
830  $values["fullscreen"] = "n";
831  if ($full_alias_item->exists())
832  {
833  $values["fullscreen"] = "y";
834  }
835 
836  $values["full_location"] = $full_item->getLocation();
837  $values["full_format"] = $full_item->getFormat();
838  $values["full_width_height"]["width"] = $full_alias_item->getWidth();
839  $values["full_width_height"]["height"] = $full_alias_item->getHeight();
840  $values["full_width_height"]["constr_prop"] = true;
841  $values["full_caption"] = $full_alias_item->getCaption();
842  if (trim($full_item->getCaption()) == "")
843  {
844  $values["full_def_caption"] = "<i>".$lng->txt("cont_no_caption")."</i>";
845  }
846  else
847  {
848  $values["full_def_caption"] = $full_item->getCaption();
849  }
850  $values["full_text_representation"] = $full_alias_item->getTextRepresentation();
851  if (trim($full_item->getTextRepresentation()) == "")
852  {
853  $values["full_def_text_representation"] = "<i>".$lng->txt("cont_no_text")."</i>";
854  }
855  else
856  {
857  $values["full_def_text_representation"] = $full_item->getTextRepresentation();
858  }
859  $values["full_parameters"] = $full_alias_item->getParameterString();
860  $values["full_derive_size"] = $full_alias_item->definesSize()
861  ? "n"
862  : "y";
863  if ($values["full_derive_size"] == "y")
864  {
865  $values["full_width_height"]["width"] = $full_item->getWidth();
866  $values["full_width_height"]["height"] = $full_item->getHeight();
867  }
868  $values["full_derive_caption"] = $full_alias_item->definesCaption()
869  ? "n"
870  : "y";
871  $values["full_derive_text_representation"] = $full_alias_item->definesTextRepresentation()
872  ? "n"
873  : "y";
874 
875  // parameters
876  if (ilObjMediaObject::_useAutoStartParameterOnly($full_item->getLocation(),
877  $full_item->getFormat())) // autostart
878  {
879  $par = $full_alias_item->getParameters();
880  if ($par["autostart"] == "true")
881  {
882  $values["full_autostart"] = true;
883  }
884  }
885  else // parameters
886  {
887  $values["full_parameters"] = $full_alias_item->getParameterString();
888  }
889 
890  $values["full_derive_parameters"] = $full_alias_item->definesParameters()
891  ? "n"
892  : "y";
893  if (trim($full_item->getParameterString()) == "")
894  {
895  $values["full_def_parameters"] = "<i>".$lng->txt("cont_no_parameters")."</i>";
896  }
897  else
898  {
899  $values["full_def_parameters"] = $full_item->getParameterString();
900  }
901 
902  }
903 
904  $this->form_gui->setValuesByArray($values);
905  }
906 
911  {
912  $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
913  $this->content_obj->getPcId());
914  $full_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Fullscreen",
915  $this->content_obj->getPcId());
916  $std_item = $this->content_obj->getMediaObject()->getMediaItem("Standard");
917  $full_item = $this->content_obj->getMediaObject()->getMediaItem("Fullscreen");
918 
919  // standard size
920  if($_POST["st_derive_size"] == "y")
921  {
922  $std_alias_item->deriveSize();
923  }
924  else
925  {
926  $std_alias_item->setWidth($_POST["st_width_height"]["width"]);
927  $std_alias_item->setHeight($_POST["st_width_height"]["height"]);
928  }
929 
930  // standard caption
931  if($_POST["st_derive_caption"] == "y")
932  {
933  $std_alias_item->deriveCaption();
934  }
935  else
936  {
937  $std_alias_item->setCaption($_POST["st_caption"]);
938  }
939 
940  // text representation
941  if($_POST["st_derive_text_representation"] == "y")
942  {
943  $std_alias_item->deriveTextRepresentation();
944  }
945  else
946  {
947  $std_alias_item->setTextRepresentation($_POST["st_text_representation"]);
948  }
949 
950  // standard parameters
951  if($_POST["st_derive_parameters"] == "y")
952  {
953  $std_alias_item->deriveParameters();
954  }
955  else
956  {
957  if (ilObjMediaObject::_useAutoStartParameterOnly($std_item->getLocation(),
958  $std_item->getFormat())) // autostart
959  {
960  if ($_POST["st_autostart"])
961  {
962  $std_alias_item->setParameters(ilUtil::extractParameterString('autostart="true"'));
963  }
964  else
965  {
966  $std_alias_item->setParameters(ilUtil::extractParameterString('autostart="false"'));
967  }
968  }
969  else // parameters
970  {
971  $std_alias_item->setParameters(ilUtil::extractParameterString(ilUtil::stripSlashes(utf8_decode($_POST["st_parameters"]))));
972  }
973  }
974 
975  if($this->content_obj->getMediaObject()->hasFullscreenItem())
976  {
977  if ($_POST["fullscreen"] == "y")
978  {
979  if (!$full_alias_item->exists())
980  {
981  $full_alias_item->insert();
982  }
983 
984  // fullscreen size
985  if($_POST["full_derive_size"] == "y")
986  {
987  $full_alias_item->deriveSize();
988  }
989  else
990  {
991  $full_alias_item->setWidth($_POST["full_width_height"]["width"]);
992  $full_alias_item->setHeight($_POST["full_width_height"]["height"]);
993  }
994 
995  // fullscreen caption
996  if($_POST["full_derive_caption"] == "y")
997  {
998  $full_alias_item->deriveCaption();
999  }
1000  else
1001  {
1002  $full_alias_item->setCaption($_POST["full_caption"]);
1003  }
1004 
1005  // fullscreen text representation
1006  if($_POST["full_derive_text_representation"] == "y")
1007  {
1008  $full_alias_item->deriveTextRepresentation();
1009  }
1010  else
1011  {
1012  $full_alias_item->setTextRepresentation($_POST["full_text_representation"]);
1013  }
1014 
1015  // fullscreen parameters
1016  if($_POST["full_derive_parameters"] == "y")
1017  {
1018  $full_alias_item->deriveParameters();
1019  }
1020  else
1021  {
1022  if (ilObjMediaObject::_useAutoStartParameterOnly($full_item->getLocation(),
1023  $full_item->getFormat())) // autostart
1024  {
1025  if ($_POST["full_autostart"])
1026  {
1027  $full_alias_item->setParameters(ilUtil::extractParameterString('autostart="true"'));
1028  }
1029  else
1030  {
1031  $full_alias_item->setParameters(ilUtil::extractParameterString('autostart="false"'));
1032  }
1033  }
1034  else
1035  {
1036  $full_alias_item->setParameters(ilUtil::extractParameterString(ilUtil::stripSlashes(utf8_decode($_POST["full_parameters"]))));
1037  }
1038  }
1039  }
1040  else
1041  {
1042  if ($full_alias_item->exists())
1043  {
1044  $full_alias_item->delete();
1045  }
1046  }
1047  }
1048 
1049  $this->updated = $this->pg_obj->update();
1050  if ($this->updated === true)
1051  {
1052  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
1053  }
1054  else
1055  {
1056  $this->pg_obj->addHierIDs();
1057  $this->editAlias();
1058  }
1059  }
1060 
1064  function copyToClipboard()
1065  {
1066  $this->ilias->account->addObjectToClipboard($this->content_obj->getMediaObject()->getId(), $this->content_obj->getMediaObject()->getType()
1067  , $this->content_obj->getMediaObject()->getTitle());
1068  ilUtil::sendSuccess($this->lng->txt("copied_to_clipboard"), true);
1069  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
1070  }
1071 
1075  function centerAlign()
1076  {
1077  $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
1078  $this->content_obj->getPcId());
1079  $std_alias_item->setHorizontalAlign("Center");
1080  $_SESSION["il_pg_error"] = $this->pg_obj->update();
1081  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
1082  }
1083 
1087  function leftAlign()
1088  {
1089  $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
1090  $this->content_obj->getPcId());
1091  $std_alias_item->setHorizontalAlign("Left");
1092  $_SESSION["il_pg_error"] = $this->pg_obj->update();
1093  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
1094  }
1095 
1099  function rightAlign()
1100  {
1101  $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
1102  $this->content_obj->getPcId());
1103  $std_alias_item->setHorizontalAlign("Right");
1104  $_SESSION["il_pg_error"] = $this->pg_obj->update();
1105  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
1106  }
1107 
1111  function leftFloatAlign()
1112  {
1113  $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
1114  $this->content_obj->getPcId());
1115  $std_alias_item->setHorizontalAlign("LeftFloat");
1116  $_SESSION["il_pg_error"] = $this->pg_obj->update();
1117  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
1118  }
1119 
1123  function rightFloatAlign()
1124  {
1125  $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard",
1126  $this->content_obj->getPcId());
1127  $std_alias_item->setHorizontalAlign("RightFloat");
1128  $_SESSION["il_pg_error"] = $this->pg_obj->update();
1129  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
1130  }
1131 
1136  {
1137  // check whether there is more than one style class
1138  $chars = $this->getCharacteristics();
1139 
1140  if (count($chars) > 1 ||
1141  ($this->content_obj->getClass() != "" && $this->content_obj->getClass() != "Media"))
1142  {
1143  return true;
1144  }
1145  return false;
1146  }
1147 
1151  function editStyle()
1152  {
1153  global $ilCtrl, $tpl, $lng;
1154 
1155  $this->displayValidationError();
1156 
1157  // edit form
1158  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1159  $form = new ilPropertyFormGUI();
1160  $form->setFormAction($ilCtrl->getFormAction($this));
1161  $form->setTitle($this->lng->txt("cont_edit_style"));
1162 
1163  // characteristic selection
1164  require_once("./Services/Form/classes/class.ilAdvSelectInputGUI.php");
1165  $char_prop = new ilAdvSelectInputGUI($this->lng->txt("cont_characteristic"),
1166  "characteristic");
1167 
1168  $chars = $this->getCharacteristics();
1169  if (is_object($this->content_obj))
1170  {
1171  if ($chars[$a_seleted_value] == "" && ($this->content_obj->getClass() != ""))
1172  {
1173  $chars = array_merge(
1174  array($this->content_obj->getClass() => $this->content_obj->getClass()),
1175  $chars);
1176  }
1177  }
1178 
1179  $selected = $this->content_obj->getClass();
1180  if ($selected == "")
1181  {
1182  $selected = "MediaContainer";
1183  }
1184 
1185  foreach ($chars as $k => $char)
1186  {
1187  $html = '<table class="ilc_media_cont_'.$k.'"><tr><td>'.
1188  $char.'</td></tr></table>';
1189  $char_prop->addOption($k, $char, $html);
1190  }
1191 
1192  $char_prop->setValue($selected);
1193  $form->addItem($char_prop);
1194 
1195  // save button
1196  $form->addCommandButton("saveStyle", $lng->txt("save"));
1197 
1198  $html = $form->getHTML();
1199  $tpl->setContent($html);
1200  return $ret;
1201  }
1202 
1206  function saveStyle()
1207  {
1208  $this->content_obj->setClass($_POST["characteristic"]);
1209  $this->updated = $this->pg_obj->update();
1210  if ($this->updated === true)
1211  {
1212  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
1213  }
1214  else
1215  {
1216  $this->pg_obj->addHierIDs();
1217  $this->editStyle();
1218  }
1219  }
1220 
1227  function getTabs(&$tab_gui, $a_create = false, $a_change_obj_ref = false)
1228  {
1229  global $ilCtrl, $ilTabs;
1230 
1231  if (!$a_create)
1232  {
1233  if ($this->checkStyleSelection())
1234  {
1235  $ilTabs->addTarget("cont_style",
1236  $ilCtrl->getLinkTarget($this, "editStyle"), "editStyle",
1237  get_class($this));
1238  }
1239 
1240  $ilTabs->addTarget("cont_mob_inst_prop",
1241  $ilCtrl->getLinkTarget($this, "editAlias"), "editAlias",
1242  get_class($this));
1243 
1244  if ($this->getEnabledMapAreas())
1245  {
1246  $st_item = $this->content_obj->getMediaObject()->getMediaItem("Standard");
1247  if (is_object($st_item))
1248  {
1249  $format = $st_item->getFormat();
1250  if (substr($format, 0, 5) == "image")
1251  {
1252  $ilTabs->addTarget("cont_inst_map_areas",
1253  $ilCtrl->getLinkTargetByClass("ilpcimagemapeditorgui", "editMapAreas"), array(),
1254  "ilpcimagemapeditorgui");
1255  }
1256  }
1257  }
1258  }
1259  else
1260  {
1261  if ($a_change_obj_ref)
1262  {
1263  $cmd = "changeObjectReference";
1264  }
1265  else
1266  {
1267  $cmd = "insert";
1268  }
1269 
1270  $ilCtrl->setParameter($this, "subCmd", "insertNew");
1271  $ilTabs->addSubTabTarget("cont_new_mob",
1272  $ilCtrl->getLinkTarget($this, $cmd), $cmd);
1273 
1274  $ilCtrl->setParameter($this, "subCmd", "insertFromPool");
1275  $ilTabs->addSubTabTarget("cont_mob_from_media_pool",
1276  $ilCtrl->getLinkTarget($this, $cmd), $cmd);
1277  $ilCtrl->setParameter($this, "subCmd", "");
1278  }
1279  }
1280 
1281 }
1282 ?>