ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjMediaObjectGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once ("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
5 require_once ("./Modules/LearningModule/classes/class.ilInternalLinkGUI.php");
6 require_once ("classes/class.ilObjectGUI.php");
7 
20 {
21  var $ctrl;
22  var $header;
24  var $enabledmapareas = true;
25 
26  function ilObjMediaObjectGUI($a_data, $a_id = 0, $a_call_by_reference = false, $a_prepare_output = false)
27  {
28  global $lng, $ilCtrl;
29 
30  $this->ctrl =& $ilCtrl;
31  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
32  $this->lng =& $lng;
33  $this->back_title = "";
34  $this->type = "mob";
35  }
36 
37  function setHeader($a_title = "")
38  {
39  $this->header = $a_title;
40  }
41 
42  function getHeader()
43  {
44  return $this->header;
45  }
46 
52  function setEnabledMapAreas($a_enabledmapareas)
53  {
54  $this->enabledmapareas = $a_enabledmapareas;
55  }
56 
62  function getEnabledMapAreas()
63  {
65  }
66 
72  function setWidthPreset($a_val)
73  {
74  $this->width_preset = $a_val;
75  }
76 
82  function getWidthPreset()
83  {
84  return $this->width_preset;
85  }
86 
92  function setHeightPreset($a_val)
93  {
94  $this->height_preset = $a_val;
95  }
96 
102  function getHeightPreset()
103  {
104  return $this->height_preset;
105  }
106 
112  function getForm()
113  {
114  return $this->form_gui;
115  }
116 
117  function assignObject()
118  {
119  if ($this->id != 0)
120  {
121  $this->object =& new ilObjMediaObject($this->id);
122  }
123  }
124 
126  {
127  $this->ctrl->returnToParent($this);
128  }
129 
130 
134  function &executeCommand()
135  {
136  global $tpl;
137 
138  $next_class = $this->ctrl->getNextClass($this);
139  $cmd = $this->ctrl->getCmd();
140 
141  switch($next_class)
142  {
143  case 'ilmdeditorgui':
144 
145  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
146 
147  $md_gui =& new ilMDEditorGUI(0, $this->object->getId(), $this->object->getType());
148  $md_gui->addObserver($this->object,'MDUpdateListener','General');
149 
150  $this->ctrl->forwardCommand($md_gui);
151  break;
152 
153  case "ilimagemapeditorgui":
154  require_once("./Services/MediaObjects/classes/class.ilImageMapEditorGUI.php");
155  $image_map_edit = new ilImageMapEditorGUI($this->object);
156  $ret = $this->ctrl->forwardCommand($image_map_edit);
157  $tpl->setContent($ret);
158  break;
159 
160  case "ilfilesystemgui":
161  include_once("./classes/class.ilFileSystemGUI.php");
162  $fs_gui =& new ilFileSystemGUI(ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId());
163  $fs_gui->activateLabels(true, $this->lng->txt("cont_purpose"));
164  $fs_gui->setTableId("mobfs".$this->object->getId());
165  $fs_gui->labelFile($this->object->getMediaItem("Standard")->getLocation(),
166  $this->lng->txt("cont_std_view"));
167  if($this->object->hasFullscreenItem())
168  {
169  $fs_gui->labelFile($this->object->getMediaItem("Fullscreen")->getLocation(),
170  $this->lng->txt("cont_fullscreen"));
171  }
172  $fs_gui->addCommand($this, "assignStandardObject", $this->lng->txt("cont_assign_std"));
173  $fs_gui->addCommand($this, "assignFullscreenObject", $this->lng->txt("cont_assign_full"));
174  $ret =& $this->ctrl->forwardCommand($fs_gui);
175  break;
176 
177 
178  default:
179  if (isset($_POST["editImagemapForward"]) ||
180  isset($_POST["editImagemapForward_x"]) ||
181  isset($_POST["editImagemapForward_y"]))
182  {
183  $cmd = "editImagemapForward";
184  }
185  $cmd.= "Object";
186  $ret =& $this->$cmd();
187  break;
188  }
189 
190  return $ret;
191  }
192 
196  function setBackTitle($a_title)
197  {
198  $this->back_title = $a_title;
199  }
200 
204  function createObject()
205  {
206  global $tpl;
207 
208  $this->initForm();
209  $tpl->setContent($this->form_gui->getHTML());
210  }
211 
215  function initForm($a_mode = "create")
216  {
217  global $lng, $ilCtrl;
218 
219  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
220 
221  if ($a_mode == "edit")
222  {
223  $std_item = $this->object->getMediaItem("Standard");
224  }
225 
226  $this->form_gui = new ilPropertyFormGUI();
227 
228  // standard view resource
229  $title = new ilTextInputGUI($lng->txt("title"), "standard_title");
230  $title->setSize(40);
231  $title->setMaxLength(120);
232  $this->form_gui->addItem($title);
233  $radio_prop = new ilRadioGroupInputGUI($lng->txt("cont_resource"), "standard_type");
234  $op1 = new ilRadioOption($lng->txt("cont_file"), "File");
235  $up = new ilFileInputGUI("", "standard_file");
236  $up->setInfo("");
237  $op1->addSubItem($up);
238  $radio_prop->addOption($op1);
239  $op2 = new ilRadioOption($lng->txt("url"), "Reference");
240  $ref = new ilTextInputGUI("", "standard_reference");
241  $ref->setInfo($lng->txt("cont_ref_helptext"));
242  $op2->addSubItem($ref);
243  $radio_prop->addOption($op2);
244  $radio_prop->setValue("File");
245  $this->form_gui->addItem($radio_prop);
246 
247  // standard format
248  if ($a_mode == "edit")
249  {
250  $format = new ilNonEditableValueGUI($lng->txt("cont_format"), "standard_format");
251  $format->setValue($std_item->getFormat());
252  $this->form_gui->addItem($format);
253  }
254 
255  // standard size
256  $radio_size = new ilRadioGroupInputGUI($lng->txt("size"), "standard_size");
257  if ($a_mode == "edit")
258  {
259  if ($orig_size = $std_item->getOriginalSize())
260  {
261  $add_str = " (".$orig_size["width"]." x ".$orig_size["height"].")";
262  }
263  $op1 = new ilRadioOption($lng->txt("cont_resource_size").$add_str, "original");
264  $op2 = new ilRadioOption($lng->txt("cont_custom_size"), "selected");
265  }
266  else
267  {
268  $op1 = new ilRadioOption($lng->txt("cont_orig_size"), "original");
269  $op2 = new ilRadioOption($lng->txt("cont_adjust_size"), "selected");
270  }
271  $radio_size->addOption($op1);
272 
273  // width height
274  include_once("./Services/MediaObjects/classes/class.ilWidthHeightInputGUI.php");
275  $width_height = new ilWidthHeightInputGUI($lng->txt("cont_width").
276  " / ".$lng->txt("cont_height"), "standard_width_height");
277  $width_height->setConstrainProportions(true);
278  $op2->addSubItem($width_height);
279 
280  // resize image
281  if ($a_mode == "edit")
282  {
283  $std_item = $this->object->getMediaItem("Standard");
284  if (is_int(strpos($std_item->getFormat(), "image"))
285  && $std_item->getLocationType() == "LocalFile")
286  {
287  $resize = new ilCheckboxInputGUI($lng->txt("cont_resize_img")
288  , "standard_resize");
289  $op2->addSubItem($resize);
290  }
291  }
292 
293  $radio_size->setValue("original");
294  if ($a_mode == "create" && ($this->getHeightPreset() > 0 || $this->getWidthPreset() > 0))
295  {
296  $radio_size->setValue("selected");
297  $width_height->setWidth($this->getWidthPreset());
298  $width_height->setHeight($this->getHeightPreset());
299  }
300  $radio_size->addOption($op2);
301  $this->form_gui->addItem($radio_size);
302 
303  // standard caption
304  $caption = new ilTextInputGUI($lng->txt("cont_caption"), "standard_caption");
305  $caption->setSize(40);
306  $caption->setMaxLength(200);
307  $this->form_gui->addItem($caption);
308 
309  // text representation (alt text)
310  if ($a_mode == "edit" && is_int(strpos($std_item->getFormat(), "image")))
311  {
312  $ta = new ilTextAreaInputGUI($lng->txt("text_repr"), "text_representation");
313  $ta->setCols(30);
314  $ta->setRows(2);
315  $ta->setInfo($lng->txt("text_repr_info"));
316  $this->form_gui->addItem($ta);
317  }
318 
319  // standard parameters
320  if ($a_mode == "edit" &&
321  !in_array($std_item->getFormat(), ilObjMediaObject::_getSimpleMimeTypes()))
322  {
323  if (ilObjMediaObject::_useAutoStartParameterOnly($std_item->getLocation(),
324  $std_item->getFormat())) // autostart
325  {
326  $auto = new ilCheckboxInputGUI($lng->txt("cont_autostart"), "standard_autostart");
327  $this->form_gui->addItem($auto);
328  }
329  else // parameters
330  {
331  $par = new ilTextAreaInputGUI($lng->txt("cont_parameter"), "standard_parameters");
332  $par->setRows(5);
333  $par->setCols(50);
334  $this->form_gui->addItem($par);
335  }
336  }
337 
338  if ($a_mode == "edit")
339  {
340  $full_item = $this->object->getMediaItem("Fullscreen");
341  }
342 
343  // fullscreen view resource
344  $fs_sec = new ilFormSectionHeaderGUI();
345  $fs_sec->setTitle($lng->txt("cont_fullscreen"));
346  $this->form_gui->addItem($fs_sec);
347 
348  $radio_prop2 = new ilRadioGroupInputGUI($lng->txt("cont_resource"), "full_type");
349  $op1 = new ilRadioOption($lng->txt("cont_none"), "None");
350  $radio_prop2->addOption($op1);
351  $op4 = new ilRadioOption($lng->txt("cont_use_same_resource_as_above"), "Standard");
352  $radio_prop2->addOption($op4);
353  $op2 = new ilRadioOption($lng->txt("cont_file"), "File");
354  $up = new ilFileInputGUI("", "full_file");
355  $up->setInfo("");
356  $op2->addSubItem($up);
357  $radio_prop2->addOption($op2);
358  $op3 = new ilRadioOption($lng->txt("url"), "Reference");
359  $ref = new ilTextInputGUI("", "full_reference");
360  $ref->setInfo($lng->txt("cont_ref_helptext"));
361  $op3->addSubItem($ref);
362  $radio_prop2->addOption($op3);
363  $radio_prop2->setValue("None");
364  $this->form_gui->addItem($radio_prop2);
365 
366  // fullscreen format
367  if ($a_mode == "edit")
368  {
369  if ($this->object->hasFullscreenItem())
370  {
371  $format = new ilNonEditableValueGUI($lng->txt("cont_format"), "full_format");
372  $format->setValue($full_item->getFormat());
373  $this->form_gui->addItem($format);
374  }
375  }
376 
377  // fullscreen size
378  $radio_size = new ilRadioGroupInputGUI($lng->txt("size"), "full_size");
379  if ($a_mode == "edit")
380  {
381  $add_str = "";
382  if ($this->object->hasFullscreenItem() && ($orig_size = $full_item->getOriginalSize()))
383  {
384  $add_str = " (".$orig_size["width"]." x ".$orig_size["height"].")";
385  }
386  $op1 = new ilRadioOption($lng->txt("cont_resource_size").$add_str, "original");
387  $op2 = new ilRadioOption($lng->txt("cont_custom_size"), "selected");
388  }
389  else
390  {
391  $op1 = new ilRadioOption($lng->txt("cont_orig_size"), "original");
392  $op2 = new ilRadioOption($lng->txt("cont_adjust_size"), "selected");
393  }
394  $radio_size->addOption($op1);
395 
396  // width/height
397  $width_height = new ilWidthHeightInputGUI($lng->txt("cont_width").
398  " / ".$lng->txt("cont_height"), "full_width_height");
399  $width_height->setConstrainProportions(true);
400  $op2->addSubItem($width_height);
401 
402  // resize image
403  if ($a_mode == "edit")
404  {
405  $full_item = $this->object->getMediaItem("Fullscreen");
406  if ($this->object->hasFullscreenItem() &&
407  is_int(strpos($full_item->getFormat(), "image")) &&
408  $full_item->getLocationType() == "LocalFile")
409  {
410  $resize = new ilCheckboxInputGUI($lng->txt("cont_resize_img"),
411  "full_resize");
412  $op2->addSubItem($resize);
413  }
414  }
415 
416  $radio_size->setValue("original");
417  $radio_size->addOption($op2);
418  $this->form_gui->addItem($radio_size);
419 
420  // fullscreen caption
421  $caption = new ilTextInputGUI($lng->txt("cont_caption"), "full_caption");
422  $caption->setSize(40);
423  $caption->setMaxLength(200);
424  $this->form_gui->addItem($caption);
425 
426  // text representation (alt text)
427  if ($a_mode == "edit" && $this->object->hasFullscreenItem() && is_int(strpos($std_item->getFormat(), "image")))
428  {
429  $ta = new ilTextAreaInputGUI($lng->txt("text_repr"), "full_text_representation");
430  $ta->setCols(30);
431  $ta->setRows(2);
432  $ta->setInfo($lng->txt("text_repr_info"));
433  $this->form_gui->addItem($ta);
434  }
435 
436 
437  // fullscreen parameters
438  if ($a_mode == "edit" && $this->object->hasFullscreenItem() &&
439  !in_array($full_item->getFormat(), ilObjMediaObject::_getSimpleMimeTypes()))
440  {
441  if (ilObjMediaObject::_useAutoStartParameterOnly($full_item->getLocation(),
442  $full_item->getFormat()))
443  {
444  $auto = new ilCheckboxInputGUI($lng->txt("cont_autostart"), "full_autostart");
445  $this->form_gui->addItem($auto);
446  }
447  else
448  {
449  $par = new ilTextAreaInputGUI($lng->txt("cont_parameter"), "full_parameters");
450  $par->setRows(5);
451  $par->setCols(50);
452  $this->form_gui->addItem($par);
453  }
454  }
455 
456  $this->form_gui->setTitle($lng->txt("cont_insert_mob"));
457  if ($a_mode == "edit")
458  {
459  $this->form_gui->addCommandButton("saveProperties", $lng->txt("save"));
460  }
461  else
462  {
463  $this->form_gui->addCommandButton("save", $lng->txt("save"));
464  $this->form_gui->addCommandButton("cancel", $lng->txt("cancel"));
465  }
466  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
467 
468  }
469 
474  public function getValues()
475  {
476  $values = array();
477 
478  $values["standard_title"] = $this->object->getTitle();
479 
480  $std_item = $this->object->getMediaItem("Standard");
481  if ($std_item->getLocationType() == "LocalFile")
482  {
483  $values["standard_type"] = "File";
484  $values["standard_file"] = $std_item->getLocation();
485  }
486  else
487  {
488  $values["standard_type"] = "Reference";
489  $values["standard_reference"] = $std_item->getLocation();
490  }
491  $values["standard_format"] = $std_item->getFormat();
492  $values["standard_width_height"]["width"] = $std_item->getWidth();
493  $values["standard_width_height"]["height"] = $std_item->getHeight();
494  $values["standard_width_height"]["constr_prop"] = true;
495 
496  $values["standard_size"] = "selected";
497 
498  if ($orig_size = $std_item->getOriginalSize())
499  {
500  if ($orig_size["width"] == $std_item->getWidth() &&
501  $orig_size["height"] == $std_item->getHeight())
502  {
503  $values["standard_size"] = "original";
504  }
505  }
506  $values["standard_caption"] = $std_item->getCaption();
507  $values["text_representation"] = $std_item->getTextRepresentation();
508  if (ilObjMediaObject::_useAutoStartParameterOnly($std_item->getLocation(),
509  $std_item->getFormat()))
510  {
511  $par = $std_item->getParameters();
512  if ($par["autostart"])
513  {
514  $values["standard_autostart"] = true;
515  }
516  }
517  else
518  {
519  $values["standard_parameters"] = $std_item->getParameterString();
520  }
521 
522  $values["full_type"] = "None";
523  $values["full_size"] = "original";
524  if ($this->object->hasFullScreenItem())
525  {
526  $full_item = $this->object->getMediaItem("Fullscreen");
527  if ($full_item->getLocationType() == "LocalFile")
528  {
529  $values["full_type"] = "File";
530  $values["full_file"] = $full_item->getLocation();
531  }
532  else
533  {
534  $values["full_type"] = "Reference";
535  $values["full_reference"] = $full_item->getLocation();
536  }
537  $values["full_format"] = $full_item->getFormat();
538  $values["full_width_height"]["width"] = $full_item->getWidth();
539  $values["full_width_height"]["height"] = $full_item->getHeight();
540  $values["full_width_height"]["constr_prop"] = true;
541 
542  $values["full_size"] = "selected";
543 
544  if ($orig_size = $full_item->getOriginalSize())
545  {
546  if ($orig_size["width"] == $full_item->getWidth() &&
547  $orig_size["height"] == $full_item->getHeight())
548  {
549  $values["full_size"] = "original";
550  }
551  }
552  $values["full_caption"] = $full_item->getCaption();
553  if (ilObjMediaObject::_useAutoStartParameterOnly($full_item->getLocation(),
554  $full_item->getFormat()))
555  {
556  $par = $full_item->getParameters();
557  if ($par["autostart"])
558  {
559  $values["full_autostart"] = true;
560  }
561  }
562  else
563  {
564  $values["full_parameters"] = $full_item->getParameterString();
565  }
566  $values["full_text_representation"] = $full_item->getTextRepresentation();
567  }
568 
569  $this->form_gui->setValuesByArray($values);
570  }
571 
575  function saveObject()
576  {
577  global $tpl, $lng;
578 
579  $this->initForm();
580  if ($this->form_gui->checkInput())
581  {
582  $this->object = new ilObjMediaObject();
584  ilUtil::sendSuccess($lng->txt("saved_media_object"), true);
585  return $this->object;
586  }
587  else
588  {
589  $this->form_gui->setValuesByPost();
590  $tpl->setContent($this->form_gui->getHTML());
591  }
592  }
593 
594 
598  static function setObjectPerCreationForm($a_mob)
599  {
600  // determinte title and format
601  if (trim($_POST["standard_title"]) != "")
602  {
603  $title = trim($_POST["standard_title"]);
604  }
605  else
606  {
607  if ($_POST["standard_type"] == "File")
608  {
609  $title = $_FILES['standard_file']['name'];
610  }
611  else
612  {
613  $title = ilUtil::stripSlashes($_POST["standard_reference"]);
614  }
615  }
616 
617  $a_mob->setTitle($title);
618  $a_mob->setDescription("");
619  $a_mob->create();
620 
621  // determine and create mob directory, move uploaded file to directory
622  //$mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$a_mob->getId();
623  $a_mob->createDirectory();
624  $mob_dir = ilObjMediaObject::_getDirectory($a_mob->getId());
625 
626  $media_item =& new ilMediaItem();
627  $a_mob->addMediaItem($media_item);
628  $media_item->setPurpose("Standard");
629 
630  if ($_POST["standard_type"] == "File")
631  {
632  $file = $mob_dir."/".$_FILES['standard_file']['name'];
633  ilUtil::moveUploadedFile($_FILES['standard_file']['tmp_name'],
634  $_FILES['standard_file']['name'], $file);
635 
636  // get mime type
638  $location = $_FILES['standard_file']['name'];
639 
640  // resize standard images
641  if ($_POST["standard_size"] != "original" &&
642  is_int(strpos($format, "image")))
643  {
644  $location = ilObjMediaObject::_resizeImage($file, (int) $_POST["standard_width_height"]["width"],
645  (int) $_POST["standard_width_height"]["height"], (boolean) $_POST["standard_width_height"]["contr_prop"]);
646  }
647 
648  // set real meta and object data
649  $media_item->setFormat($format);
650  $media_item->setLocation($location);
651  $media_item->setLocationType("LocalFile");
652  }
653  else // standard type: reference
654  {
655  $format = ilObjMediaObject::getMimeType(ilUtil::stripSlashes($_POST["standard_reference"]));
656  $media_item->setFormat($format);
657  $media_item->setLocation(ilUtil::stripSlashes($_POST["standard_reference"]));
658  $media_item->setLocationType("Reference");
659  }
660  $a_mob->setDescription($format);
661 
662  // determine width and height of known image types
663  $wh = ilObjMediaObject::_determineWidthHeight(500, 400, $format,
664  $_POST["standard_type"], $mob_dir."/".$location, $media_item->getLocation(),
665  $_POST["standard_width_height"]["constr_prop"], ($_POST["standard_size"] == "original"),
666  $_POST["standard_width_height"]["width"], $_POST["standard_width_height"]["height"]);
667  $media_item->setWidth($wh["width"]);
668  $media_item->setHeight($wh["height"]);
669  if ($wh["info"] != "")
670  {
671  ilUtil::sendInfo($wh["info"], true);
672  }
673 
674  if ($_POST["standard_caption"] != "")
675  {
676  $media_item->setCaption(ilUtil::stripSlashes($_POST["standard_caption"]));
677  }
678 
679 
680  $media_item->setHAlign("Left");
681 
682  // fullscreen view
683  if ($_POST["full_type"] != "None")
684  {
685  $media_item2 = new ilMediaItem();
686  $a_mob->addMediaItem($media_item2);
687  $media_item2->setPurpose("Fullscreen");
688 
689  // move file / set format and location
690  if ($_POST["full_type"] == "File")
691  {
692  $format = $location = "";
693  if ($_FILES['full_file']['name'] != "")
694  {
695  $file = $mob_dir."/".$_FILES['full_file']['name'];
696  ilUtil::moveUploadedFile($_FILES['full_file']['tmp_name'],
697  $_FILES['full_file']['name'], $file);
699  $location = $_FILES['full_file']['name'];
700  }
701  }
702  else if ($_POST["full_type"] == "Standard" && $_POST["standard_type"] == "File")
703  {
704  $location = $_FILES['standard_file']['name'];
705  }
706 
707  // resize file
708  if ($_POST["full_type"] == "File" ||
709  ($_POST["full_type"] == "Standard" && $_POST["standard_type"] == "File"))
710  {
711  if (($_POST["full_size"] != "original" &&
712  is_int(strpos($format, "image")))
713  )
714  {
715  $location = ilObjMediaObject::_resizeImage($file, (int) $_POST["full_width_height"]["width"],
716  (int) $_POST["full_width_height"]["height"], (boolean) $_POST["full_width_height"]["constr_prop"]);
717  }
718 
719  $media_item2->setFormat($format);
720  $media_item2->setLocation($location);
721  $media_item2->setLocationType("LocalFile");
722  $type = "File";
723  }
724 
725  if ($_POST["full_type"] == "Reference")
726  {
727  $format = $location = "";
728  if ($_POST["full_reference"] != "")
729  {
730  $format = ilObjMediaObject::getMimeType($_POST["full_reference"]);
731  $location = ilUtil::stripSlashes($_POST["full_reference"]);
732  }
733  }
734 
735  if ($_POST["full_type"] == "Reference" ||
736  ($_POST["full_type"] == "Standard" && $_POST["standard_type"] == "Reference"))
737  {
738  $media_item2->setFormat($format);
739  $media_item2->setLocation($location);
740  $media_item2->setLocationType("Reference");
741  $type = "Reference";
742  }
743 
744  // determine width and height of known image types
745  $wh = ilObjMediaObject::_determineWidthHeight(500, 400, $format,
746  $type, $mob_dir."/".$location, $media_item2->getLocation(),
747  $_POST["full_width_height"]["constr_prop"], ($_POST["full_size"] == "original"),
748  $_POST["full_width_height"]["width"], $_POST["full_width_height"]["height"]);
749 
750  $media_item2->setWidth($wh["width"]);
751  $media_item2->setHeight($wh["height"]);
752 
753  if ($_POST["full_caption"] != "")
754  {
755  $media_item2->setCaption(ilUtil::stripSlashes($_POST["full_caption"]));
756  }
757 
758  }
759 
760  ilUtil::renameExecutables($mob_dir);
761  $a_mob->update();
762  }
763 
764 
768  function cancelObject()
769  {
770  $this->ctrl->returnToParent($this);
771  }
772 
776  function editObject()
777  {
778  global $tpl;
779 
780  $this->initForm("edit");
781  $this->getValues();
782  $tpl->setContent($this->form_gui->getHTML());
783  }
784 
785 
790  {
791  // directory
792  $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
793 
794  // standard item
795  $std_item =& $this->object->getMediaItem("Standard");
796  if ($std_item->getLocationType() == "LocalFile" &&
797  is_int(strpos($std_item->getFormat(), "image"))
798  )
799  {
800  $file = $mob_dir."/".$std_item->getLocation();
801  $location = ilObjMediaObject::_resizeImage($file, $std_item->getWidth(),
802  $std_item->getHeight());
803  $std_item->setLocation($location);
804  $std_item->update();
805  }
806 
807  // fullscreen item
808  if($this->object->hasFullScreenItem())
809  {
810  $full_item =& $this->object->getMediaItem("Fullscreen");
811  if ($full_item->getLocationType() == "LocalFile" &&
812  is_int(strpos($full_item->getFormat(), "image"))
813  )
814  {
815  $file = $mob_dir."/".$full_item->getLocation();
816  $location = ilObjMediaObject::_resizeImage($file, $full_item->getWidth(),
817  $full_item->getHeight());
818  $full_item->setLocation($location);
819  $full_item->update();
820  }
821  }
822 
823  $this->ctrl->redirect($this, "edit");
824  }
825 
826 
831  {
832  $std_item = $this->object->getMediaItem("Standard");
833  $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
834 
835  if ($std_item->getLocationType() == "LocalFile")
836  {
837  $file = $mob_dir."/".$std_item->getLocation();
838  $size = getimagesize($file);
839  $std_item->setWidth($size[0]);
840  $std_item->setHeight($size[1]);
841  $this->object->update();
842  }
843  $this->ctrl->redirect($this, "edit");
844  }
845 
846 
851  {
852  $full_item =& $this->object->getMediaItem("Fullscreen");
853  $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
854 
855  if ($full_item->getLocationType() == "LocalFile")
856  {
857  $file = $mob_dir."/".$full_item->getLocation();
858  $size = getimagesize($file);
859  $full_item->setWidth($size[0]);
860  $full_item->setHeight($size[1]);
861  $this->object->update();
862  }
863  $this->ctrl->redirect($this, "edit");
864  }
865 
870  {
871  global $lng, $tpl;
872 
873  $this->initForm();
874  if ($this->form_gui->checkInput())
875  {
876  $title = trim($_POST["standard_title"]);
877  $this->object->setTitle($title);
878 
879  $std_item = $this->object->getMediaItem("Standard");
880  $location = $std_item->getLocation();
881  $format = $std_item->getFormat();
882  if ($_POST["standard_type"] == "Reference")
883  {
884  $format = ilObjMediaObject::getMimeType(ilUtil::stripSlashes($_POST["standard_reference"]));
885  $std_item->setFormat($format);
886  $std_item->setLocation(ilUtil::stripSlashes($_POST["standard_reference"]));
887  $std_item->setLocationType("Reference");
888  }
889  $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
890  if ($_POST["standard_type"] == "File")
891  {
892  $resize = false;
893  if ($_FILES['standard_file']['name'] != "")
894  {
895  $file = $mob_dir."/".$_FILES['standard_file']['name'];
896  ilUtil::moveUploadedFile($_FILES['standard_file']['tmp_name'],
897  $_FILES['standard_file']['name'], $file);
898 
899  // get mime type
901  $location = $_FILES['standard_file']['name'];
902 
903  $resize = true;
904  }
905  else if ($_POST["standard_resize"])
906  {
907  $file = $mob_dir."/".$location;
908  $resize = true;
909  }
910 
911  // resize
912  if ($resize)
913  {
914  if ($_POST["standard_size"] != "original" &&
915  is_int(strpos($format, "image")))
916  {
917  $location = ilObjMediaObject::_resizeImage($file, (int) $_POST["standard_width_height"]["width"],
918  (int) $_POST["standard_width_height"]["height"], (boolean) $_POST["standard_width_height"]["contr_prop"]);
919  }
920  $std_item->setFormat($format);
921  $std_item->setLocation($location);
922  }
923 
924  $std_item->setLocationType("LocalFile");
925  }
926  $this->object->setDescription($format);
927 
928  // determine width and height of known image types
929  $wh = ilObjMediaObject::_determineWidthHeight(500, 400, $format,
930  $_POST["standard_type"], $mob_dir."/".$location, $std_item->getLocation(),
931  $_POST["standard_width_height"]["constr_prop"], ($_POST["standard_size"] == "original"),
932  $_POST["standard_width_height"]["width"], $_POST["standard_width_height"]["height"]);
933  if ($wh["info"] != "")
934  {
935  ilUtil::sendInfo($wh["info"], true);
936  }
937 
938  $std_item->setWidth($wh["width"]);
939  $std_item->setHeight($wh["height"]);
940 
941  // set caption
942  $std_item->setCaption(ilUtil::stripSlashes($_POST["standard_caption"]));
943 
944  // text representation
945  $std_item->setTextRepresentation(ilUtil::stripSlashes($_POST["text_representation"]));
946 
947  // set parameters
948  if (!in_array($std_item->getFormat(), ilObjMediaObject::_getSimpleMimeTypes()))
949  {
950  if (ilObjMediaObject::_useAutoStartParameterOnly($std_item->getLocation(),
951  $std_item->getFormat()))
952  {
953  if ($_POST["standard_autostart"]) // save only autostart flag
954  {
955  $std_item->setParameters('autostart="true"');
956  }
957  else
958  {
959  $std_item->setParameters("");
960  }
961  }
962  else
963  {
964  $std_item->setParameters(ilUtil::stripSlashes(utf8_decode($_POST["standard_parameters"])));
965  }
966  }
967 
968  // "None" selected
969  if ($_POST["full_type"] == "None")
970  {
971  if ($this->object->hasFullscreenItem()) // delete existing
972  {
973  $this->object->removeMediaItem("Fullscreen");
974  }
975  }
976  else // Not "None" -> we need one
977  {
978  if ($this->object->hasFullscreenItem()) // take existing one
979  {
980  $full_item = $this->object->getMediaItem("Fullscreen");
981  }
982  else // create one
983  {
984  $full_item = new ilMediaItem();
985  $this->object->addMediaItem($full_item);
986  $full_item->setPurpose("Fullscreen");
987  }
988  $location = $full_item->getLocation();
989  $format = $full_item->getFormat();
990  if ($_POST["full_type"] == "Reference")
991  {
992  $format = ilObjMediaObject::getMimeType(ilUtil::stripSlashes($_POST["full_reference"]));
993  $full_item->setFormat($format);
994  $full_item->setLocation(ilUtil::stripSlashes($_POST["full_reference"]));
995  $full_item->setLocationType("Reference");
996  $type = "Reference";
997  }
998  $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
999  if ($_POST["full_type"] == "File")
1000  {
1001  $resize = false;
1002  if ($_FILES['full_file']['name'] != "")
1003  {
1004  $file = $mob_dir."/".$_FILES['full_file']['name'];
1005  ilUtil::moveUploadedFile($_FILES['full_file']['tmp_name'],
1006  $_FILES['full_file']['name'], $file);
1007 
1009  $location = $_FILES['full_file']['name'];
1010 
1011  $resize = true;
1012  }
1013  else if ($_POST["full_resize"])
1014  {
1015  $file = $mob_dir."/".$location;
1016  $resize = true;
1017  }
1018 
1019  // resize
1020  if ($resize)
1021  {
1022  if ($_POST["full_size"] != "original" &&
1023  is_int(strpos($format, "image")))
1024  {
1025  $location = ilObjMediaObject::_resizeImage($file, (int) $_POST["full_width_height"]["width"],
1026  (int) $_POST["full_width_height"]["height"], (boolean) $_POST["full_width_height"]["contr_prop"]);
1027  }
1028  $full_item->setFormat($format);
1029  $full_item->setLocation($location);
1030  }
1031 
1032  $full_item->setLocationType("LocalFile");
1033  $type = "File";
1034  }
1035  if ($_POST["full_type"] == "Standard")
1036  {
1037  $format = $std_item->getFormat();
1038  $location = $std_item->getLocation();
1039  $full_item->setLocationType($std_item->getLocationType());
1040  $full_item->setFormat($format);
1041  $full_item->setLocation($location);
1042  $type = $std_item->getLocationType();
1043  if ($type == "LocalFile")
1044  {
1045  $type = "File";
1046  }
1047  // resize image
1048 //echo "-".$_POST["full_size"]."-".is_int(strpos($format, "image"))."-".$full_item->getLocationType()."-";
1049  if ($_POST["full_size"] != "original" &&
1050  is_int(strpos($format, "image")) &&
1051  $full_item->getLocationType() == "LocalFile")
1052  {
1053  $file = $mob_dir."/".$location;
1054  $location = ilObjMediaObject::_resizeImage($file, (int) $_POST["full_width_height"]["width"],
1055  (int) $_POST["full_width_height"]["height"], (boolean) $_POST["full_width_height"]["contr_prop"]);
1056  }
1057  }
1058 
1059  // determine width and height of known image types
1060  $wh = ilObjMediaObject::_determineWidthHeight(500, 400, $format,
1061  $type, $mob_dir."/".$location, $full_item->getLocation(),
1062  $_POST["full_width_height"]["constr_prop"], ($_POST["full_size"] == "original"),
1063  $_POST["full_width_height"]["width"], $_POST["full_width_height"]["height"]);
1064  if ($wh["info"] != "")
1065  {
1066  ilUtil::sendInfo($wh["info"], true);
1067  }
1068 
1069  $full_item->setWidth($wh["width"]);
1070  $full_item->setHeight($wh["height"]);
1071  $full_item->setLocation($location);
1072 
1073  $full_item->setCaption(ilUtil::stripSlashes($_POST["full_caption"]));
1074 
1075  // text representation
1076  $full_item->setTextRepresentation(ilUtil::stripSlashes($_POST["full_text_representation"]));
1077 
1078 
1079  // set parameters
1080  if (!in_array($std_item->getFormat(), ilObjMediaObject::_getSimpleMimeTypes()))
1081  {
1082  if (ilObjMediaObject::_useAutoStartParameterOnly($std_item->getLocation(),
1083  $std_item->getFormat()))
1084  {
1085  if ($_POST["full_autostart"]) // save only autostart flag
1086  {
1087  $full_item->setParameters('autostart="true"');
1088  }
1089  else
1090  {
1091  $full_item->setParameters("");
1092  }
1093  }
1094  else
1095  {
1096  $full_item->setParameters(ilUtil::stripSlashes(utf8_decode($_POST["full_parameters"])));
1097  }
1098  }
1099  }
1100 
1102 
1103  $this->object->update();
1104  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1105  $this->ctrl->redirect($this, "edit");
1106  }
1107  else
1108  {
1109  $this->form_gui->setValuesByPost();
1110  $tpl->setContent($this->form_gui->getHTML());
1111  }
1112  }
1113 
1114 
1118  function editFilesObject()
1119  {
1120  // standard item
1121  $std_item =& $this->object->getMediaItem("Standard");
1122  if($this->object->hasFullscreenItem())
1123  {
1124  $full_item =& $this->object->getMediaItem("Fullscreen");
1125  }
1126 
1127  // create table
1128  require_once("./Services/Table/classes/class.ilTableGUI.php");
1129  $tbl = new ilTableGUI();
1130 
1131  // determine directory
1132  $cur_subdir = $_GET["cdir"];
1133  if($_GET["newdir"] == "..")
1134  {
1135  $cur_subdir = substr($cur_subdir, 0, strrpos($cur_subdir, "/"));
1136  }
1137  else
1138  {
1139  if (!empty($_GET["newdir"]))
1140  {
1141  if (!empty($cur_subdir))
1142  {
1143  $cur_subdir = $cur_subdir."/".$_GET["newdir"];
1144  }
1145  else
1146  {
1147  $cur_subdir = $_GET["newdir"];
1148  }
1149  }
1150  }
1151 
1152  $cur_subdir = str_replace(".", "", $cur_subdir);
1153  $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
1154  $cur_dir = (!empty($cur_subdir))
1155  ? $mob_dir."/".$cur_subdir
1156  : $mob_dir;
1157 
1158  // load files templates
1159  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.mob_files.html", "Services/MediaObjects");
1160 
1161  $this->ctrl->setParameter($this, "cdir", urlencode($cur_subdir));
1162  $this->tpl->setVariable("FORMACTION1", $this->ctrl->getFormAction($this));
1163 //echo "--".$this->getTargetScript().
1164  //"&hier_id=".$_GET["hier_id"]."&cdir=".$cur_subdir."&cmd=post"."--<br>";
1165  $this->tpl->setVariable("TXT_NEW_DIRECTORY", $this->lng->txt("cont_new_dir"));
1166  $this->tpl->setVariable("TXT_NEW_FILE", $this->lng->txt("cont_new_file"));
1167  $this->tpl->setVariable("CMD_NEW_DIR", "createDirectory");
1168  $this->tpl->setVariable("CMD_NEW_FILE", "uploadFile");
1169  $this->tpl->setVariable("BTN_NEW_DIR", $this->lng->txt("create"));
1170  $this->tpl->setVariable("BTN_NEW_FILE", $this->lng->txt("upload"));
1171 
1172  //
1173  $this->tpl->addBlockfile("FILE_TABLE", "files", "tpl.table.html");
1174 
1175  // load template for table content data
1176  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.mob_file_row.html", "Services/MediaObjects");
1177 
1178  $num = 0;
1179 
1180  $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
1181  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1182 
1183  $tbl->setTitle($this->lng->txt("cont_files")." ".$cur_subdir);
1184  //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
1185 
1186  $tbl->setHeaderNames(array("", "", $this->lng->txt("cont_dir_file"),
1187  $this->lng->txt("cont_size"), $this->lng->txt("cont_purpose")));
1188 
1189  $cols = array("", "", "dir_file", "size", "purpose");
1190  $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"],
1191  "cmd" => "editFiles", "hier_id" => $_GET["hier_id"], "item_id" => $_GET["item_id"]);
1192  $tbl->setHeaderVars($cols, $header_params);
1193  $tbl->setColumnWidth(array("1%", "1%", "33%", "33%", "32%"));
1194 
1195  // control
1196  $tbl->setOrderColumn($_GET["sort_by"]);
1197  $tbl->setOrderDirection($_GET["sort_order"]);
1198  $tbl->setLimit($_GET["limit"]);
1199  $tbl->setOffset($_GET["offset"]);
1200  $tbl->setMaxCount($this->maxcount); // ???
1201  //$tbl->setMaxCount(30); // ???
1202 
1203  $this->tpl->setVariable("COLUMN_COUNTS", 5);
1204 
1205  // delete button
1206  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
1207  $this->tpl->setCurrentBlock("tbl_action_btn");
1208  $this->tpl->setVariable("BTN_NAME", "deleteFile");
1209  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
1210  $this->tpl->parseCurrentBlock();
1211 
1212  $this->tpl->setCurrentBlock("tbl_action_btn");
1213  $this->tpl->setVariable("BTN_NAME", "assignStandard");
1214  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("cont_assign_std"));
1215  $this->tpl->parseCurrentBlock();
1216 
1217  $this->tpl->setCurrentBlock("tbl_action_btn");
1218  $this->tpl->setVariable("BTN_NAME", "assignFullscreen");
1219  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("cont_assign_full"));
1220  $this->tpl->parseCurrentBlock();
1221 
1222  // footer
1223  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1224  //$tbl->disable("footer");
1225 
1226  $entries = ilUtil::getDir($cur_dir);
1227 
1228  //$objs = ilUtil::sortArray($objs, $_GET["sort_by"], $_GET["sort_order"]);
1229  $tbl->setMaxCount(count($entries));
1230  $entries = array_slice($entries, $_GET["offset"], $_GET["limit"]);
1231 
1232  $tbl->render();
1233  if(count($entries) > 0)
1234  {
1235  $i=0;
1236  foreach($entries as $entry)
1237  {
1238  if(($entry["entry"] == ".") || ($entry["entry"] == ".." && empty($cur_subdir)))
1239  {
1240  continue;
1241  }
1242 
1243  //$this->tpl->setVariable("ICON", $obj["title"]);
1244  if($entry["type"] == "dir")
1245  {
1246  $this->tpl->setCurrentBlock("FileLink");
1247  $this->ctrl->setParameter($this, "cdir", $cur_subdir);
1248  $this->ctrl->setParameter($this, "newdir", rawurlencode($entry["entry"]));
1249  $this->tpl->setVariable("LINK_FILENAME", $this->ctrl->getLinkTarget($this, "editFiles"));
1250  $this->tpl->setVariable("TXT_FILENAME", $entry["entry"]);
1251  $this->tpl->parseCurrentBlock();
1252 
1253  $this->tpl->setVariable("ICON", "<img src=\"".
1254  ilUtil::getImagePath("icon_cat.gif")."\">");
1255  }
1256  else
1257  {
1258  $this->tpl->setCurrentBlock("File");
1259  $this->tpl->setVariable("TXT_FILENAME2", $entry["entry"]);
1260  $this->tpl->parseCurrentBlock();
1261  }
1262 
1263  $this->tpl->setCurrentBlock("tbl_content");
1264  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
1265  $this->tpl->setVariable("CSS_ROW", $css_row);
1266 
1267  $this->tpl->setVariable("TXT_SIZE", $entry["size"]);
1268  $this->tpl->setVariable("CHECKBOX_ID", $entry["entry"]);
1269  $compare = (!empty($cur_subdir))
1270  ? $cur_subdir."/".$entry["entry"]
1271  : $entry["entry"];
1272  $purpose = array();
1273  if ($std_item->getLocation() == $compare)
1274  {
1275  $purpose[] = $this->lng->txt("cont_std_view");
1276  }
1277  if($this->object->hasFullscreenItem())
1278  {
1279  if ($full_item->getLocation() == $compare)
1280  {
1281  $purpose[] = $this->lng->txt("cont_fullscreen");
1282  }
1283  }
1284  $this->tpl->setVariable("TXT_PURPOSE", implode($purpose, ", "));
1285 
1286  $this->tpl->parseCurrentBlock();
1287  }
1288  } //if is_array
1289  else
1290  {
1291  $this->tpl->setCurrentBlock("notfound");
1292  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
1293  $this->tpl->setVariable("NUM_COLS", 4);
1294  $this->tpl->parseCurrentBlock();
1295  }
1296 
1297  $this->tpl->parseCurrentBlock();
1298  }
1299 
1300 
1305  {
1306 //echo "cdir:".$_GET["cdir"].":<br>";
1307  // determine directory
1308  $cur_subdir = str_replace(".", "", $_GET["cdir"]);
1309  $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
1310  $cur_dir = (!empty($cur_subdir))
1311  ? $mob_dir."/".$cur_subdir
1312  : $mob_dir;
1313 
1314  $new_dir = str_replace(".", "", $_POST["new_dir"]);
1315  $new_dir = str_replace("/", "", $new_dir);
1316 
1317  if (!empty($new_dir))
1318  {
1319  ilUtil::makeDir($cur_dir."/".$new_dir);
1320  }
1321  $this->ctrl->saveParameter($this, "cdir");
1322  $this->ctrl->redirect($this, "editFiles");
1323  }
1324 
1328  function uploadFileObject()
1329  {
1330  // determine directory
1331  $cur_subdir = str_replace(".", "", $_GET["cdir"]);
1332  $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
1333  $cur_dir = (!empty($cur_subdir))
1334  ? $mob_dir."/".$cur_subdir
1335  : $mob_dir;
1336  if (is_file($_FILES["new_file"]["tmp_name"]))
1337  {
1338  //move_uploaded_file($_FILES["new_file"]["tmp_name"],
1339  //$cur_dir."/".$_FILES["new_file"]["name"]);
1340  $file = $cur_dir."/".$_FILES["new_file"]["name"];
1341  ilUtil::moveUploadedFile($_FILES['new_file']['tmp_name'],
1342  $_FILES['new_file']['name'], $file);
1343 
1344  }
1345  ilUtil::renameExecutables($mob_dir);
1346  $this->ctrl->saveParameter($this, "cdir");
1347  $this->ctrl->redirect($this, "editFiles");
1348  }
1349 
1354  {
1355  if (!isset($_POST["file"]))
1356  {
1357  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1358  }
1359 
1360  if (count($_POST["file"]) > 1)
1361  {
1362  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
1363  }
1364 
1365  // determine directory
1366  $cur_subdir = str_replace(".", "", $_GET["cdir"]);
1367  $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
1368  $cur_dir = (!empty($cur_subdir))
1369  ? $mob_dir."/".$cur_subdir
1370  : $mob_dir;
1371  $file = $cur_dir."/".$_POST["file"][0];
1372  $location = (!empty($cur_subdir))
1373  ? $cur_subdir."/".$_POST["file"][0]
1374  : $_POST["file"][0];
1375 
1376  if(!is_file($file))
1377  {
1378  $this->ilias->raiseError($this->lng->txt("cont_select_file"),$this->ilias->error_obj->MESSAGE);
1379  }
1380 
1381  $std_item =& $this->object->getMediaItem("Standard");
1382  $std_item->setLocationType("LocalFile");
1383  $std_item->setLocation($location);
1385  $std_item->setFormat($format);
1386  $this->object->update();
1387 // $this->ctrl->saveParameter($this, "cdir");
1388  $this->ctrl->redirectByClass("ilfilesystemgui", "listFiles");
1389  }
1390 
1391 
1396  {
1397  if (!isset($_POST["file"]))
1398  {
1399  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1400  }
1401 
1402  if (count($_POST["file"]) > 1)
1403  {
1404  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
1405  }
1406 
1407  // determine directory
1408  $cur_subdir = str_replace(".", "", $_GET["cdir"]);
1409  $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
1410  $cur_dir = (!empty($cur_subdir))
1411  ? $mob_dir."/".$cur_subdir
1412  : $mob_dir;
1413  $file = $cur_dir."/".$_POST["file"][0];
1414  $location = (!empty($cur_subdir))
1415  ? $cur_subdir."/".$_POST["file"][0]
1416  : $_POST["file"][0];
1417 
1418  if(!is_file($file))
1419  {
1420  $this->ilias->raiseError($this->lng->txt("cont_select_file"),$this->ilias->error_obj->MESSAGE);
1421  }
1422 
1423  if(!$this->object->hasFullScreenItem())
1424  { // create new fullscreen item
1425  $std_item =& $this->object->getMediaItem("Standard");
1426  $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
1427  $file = $mob_dir."/".$location;
1428  $full_item =& new ilMediaItem();
1429  $full_item->setMobId($std_item->getMobId());
1430  $full_item->setLocation($location);
1431  $full_item->setLocationType("LocalFile");
1432  $full_item->setFormat(ilObjMediaObject::getMimeType($file));
1433  $full_item->setPurpose("Fullscreen");
1434  $this->object->addMediaItem($full_item);
1435  }
1436  else // alter existing fullscreen item
1437  {
1438  $full_item =& $this->object->getMediaItem("Fullscreen");
1439 
1440  $full_item->setLocationType("LocalFile");
1441  $full_item->setLocation($location);
1443  $full_item->setFormat($format);
1444  }
1445  $this->object->update();
1446 // $this->ctrl->saveParameter($this, "cdir");
1447  $this->ctrl->redirectByClass("ilfilesystemgui", "listFiles");
1448  }
1449 
1450 
1455  {
1456  $this->object->removeMediaItem("Fullscreen");
1457  $this->object->update();
1458 
1459  $this->ctrl->redirect($this, "edit");
1460  }
1461 
1462 
1467  {
1468  if (!$this->object->hasFullScreenItem())
1469  {
1470  $std_item =& $this->object->getMediaItem("Standard");
1471  $full_item =& new ilMediaItem();
1472  $full_item->setMobId($std_item->getMobId());
1473  $full_item->setLocation($std_item->getLocation());
1474  $full_item->setLocationType($std_item->getLocationType());
1475  $full_item->setFormat($std_item->getFormat());
1476  $full_item->setWidth($std_item->getWidth());
1477  $full_item->setHeight($std_item->getHeight());
1478  $full_item->setCaption($std_item->getCaption());
1479  $full_item->setTextRepresentation($std_item->getTextRepresentation());
1480  $full_item->setPurpose("Fullscreen");
1481  $this->object->addMediaItem($full_item);
1482 
1483  $this->object->update();
1484  }
1485 
1486  $this->ctrl->redirect($this, "edit");
1487  }
1488 
1489 
1493  function deleteFileObject()
1494  {
1495  if (!isset($_POST["file"]))
1496  {
1497  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1498  }
1499 
1500  if (count($_POST["file"]) > 1)
1501  {
1502  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
1503  }
1504 
1505  if ($_POST["file"][0] == "..")
1506  {
1507  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1508  }
1509 
1510  $cur_subdir = str_replace(".", "", $_GET["cdir"]);
1511  $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
1512  $cur_dir = (!empty($cur_subdir))
1513  ? $mob_dir."/".$cur_subdir
1514  : $mob_dir;
1515  $file = $cur_dir."/".$_POST["file"][0];
1516  $location = (!empty($cur_subdir))
1517  ? $cur_subdir."/".$_POST["file"][0]
1518  : $_POST["file"][0];
1519 
1520  $full_item =& $this->object->getMediaItem("Fullscreen");
1521  $std_item =& $this->object->getMediaItem("Standard");
1522 
1523  if ($location == $std_item->getLocation())
1524  {
1525  $this->ilias->raiseError($this->lng->txt("cont_cant_del_std"),$this->ilias->error_obj->MESSAGE);
1526  }
1527 
1528  if($this->object->hasFullScreenItem())
1529  {
1530  if ($location == $full_item->getLocation())
1531  {
1532  $this->ilias->raiseError($this->lng->txt("cont_cant_del_full"),$this->ilias->error_obj->MESSAGE);
1533  }
1534  }
1535 
1536  if (@is_dir($file))
1537  {
1538  if (substr($std_item->getLocation(), 0 ,strlen($location)) == $location)
1539  {
1540  $this->ilias->raiseError($this->lng->txt("cont_std_is_in_dir"),$this->ilias->error_obj->MESSAGE);
1541  }
1542 
1543  if($this->object->hasFullScreenItem())
1544  {
1545  if (substr($full_item->getLocation(), 0 ,strlen($location)) == $location)
1546  {
1547  $this->ilias->raiseError($this->lng->txt("cont_full_is_in_dir"),$this->ilias->error_obj->MESSAGE);
1548  }
1549  }
1550  }
1551 
1552  if (@is_file($file))
1553  {
1554  unlink($file);
1555  }
1556 
1557  if (@is_dir($file))
1558  {
1560  }
1561 
1562  $this->ctrl->saveParameter($this, "cdir");
1563  $this->ctrl->redirect($this, "editFiles");
1564  }
1565 
1569  function showUsagesObject()
1570  {
1571  global $tpl;
1572 
1573  include_once("./Services/MediaObjects/classes/class.ilMediaObjectUsagesTableGUI.php");
1574  $usages_table = new ilMediaObjectUsagesTableGUI($this, "showUsages",
1575  $this->object);
1576  $tpl->setContent($usages_table->getHTML());
1577  }
1578 
1582  function _getMediaInfoHTML(&$a_mob)
1583  {
1584  global $lng;
1585 
1586  $tpl =& new ilTemplate("tpl.media_info.html", true, true, "Services/MediaObjects");
1587  $types = array("Standard", "Fullscreen");
1588  foreach ($types as $type)
1589  {
1590  if($type == "Fullscreen" && !$a_mob->hasFullScreenItem())
1591  {
1592  continue;
1593  }
1594 
1595  $med =& $a_mob->getMediaItem($type);
1596  $tpl->setCurrentBlock("media_info");
1597  if ($type == "Standard")
1598  {
1599  $tpl->setVariable("TXT_PURPOSE", $lng->txt("cont_std_view"));
1600  }
1601  else
1602  {
1603  $tpl->setVariable("TXT_PURPOSE", $lng->txt("cont_fullscreen"));
1604  }
1605  $tpl->setVariable("TXT_TYPE", $lng->txt("cont_".strtolower($med->getLocationType())));
1606  $tpl->setVariable("VAL_LOCATION", $med->getLocation());
1607  if ($med->getLocationType() == "LocalFile")
1608  {
1609  $file = ilObjMediaObject::_getDirectory($med->getMobId())."/".$med->getLocation();
1610  if (is_file($file))
1611  {
1612  $size = filesize($file);
1613  }
1614  else
1615  {
1616  $size = 0;
1617  }
1618  $tpl->setVariable("VAL_FILE_SIZE", " ($size ".$lng->txt("bytes").")");
1619  }
1620  $tpl->setVariable("TXT_FORMAT", $lng->txt("cont_format"));
1621  $tpl->setVariable("VAL_FORMAT", $med->getFormat());
1622  if ($med->getWidth() != "" && $med->getHeight() != "")
1623  {
1624  $tpl->setCurrentBlock("size");
1625  $tpl->setVariable("TXT_SIZE", $lng->txt("size"));
1626  $tpl->setVariable("VAL_SIZE", $med->getWidth()."x".$med->getHeight());
1627  $tpl->parseCurrentBlock();
1628  }
1629 
1630  // original size
1631  if ($orig_size = $med->getOriginalSize())
1632  {
1633  if ($orig_size["width"] != $med->getWidth() ||
1634  $orig_size["height"] != $med->getHeight())
1635  {
1636  $tpl->setCurrentBlock("orig_size");
1637  $tpl->setVariable("TXT_ORIG_SIZE", $lng->txt("cont_orig_size"));
1638  $tpl->setVariable("ORIG_WIDTH", $orig_size["width"]);
1639  $tpl->setVariable("ORIG_HEIGHT", $orig_size["height"]);
1640  $tpl->parseCurrentBlock();
1641  }
1642  }
1643  $tpl->setCurrentBlock("media_info");
1644  $tpl->parseCurrentBlock();
1645  }
1646 
1647  return $tpl->get();
1648  }
1649 
1653  //function setAdminTabs()
1654  function setTabs()
1655  {
1656 //echo "setAdminTabs should not be called.";
1657 
1658  // catch feedback message
1659  $this->getTabs($this->tabs_gui);
1660 
1661  //$tabs_gui->setTargetScript($this->ctrl->getLinkTarget($this));
1662  if (is_object($this->object) && strtolower(get_class($this->object)) == "ilobjmediaobject")
1663  {
1664  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_mob_b.gif"));
1665  $this->tpl->setCurrentBlock();
1666  $title = $this->object->getTitle();
1667  $this->tpl->setVariable("HEADER", $title);
1668  }
1669  else
1670  {
1671  //$title = $this->object->getTitle();
1672  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_mob_b.gif"));
1673  $this->tpl->setVariable("HEADER", $this->lng->txt("cont_create_mob"));
1674  }
1675  }
1676 
1677 
1681  function getTabs(&$tabs_gui)
1682  {
1683  global $ilTabs;
1684 
1685  //$tabs_gui->setTargetScript($this->ctrl->getLinkTarget($this));
1686  if (is_object($this->object) && strtolower(get_class($this->object)) == "ilobjmediaobject"
1687  && $this->object->getId() > 0)
1688  {
1689  // object properties
1690  $ilTabs->addTarget("cont_mob_def_prop",
1691  $this->ctrl->getLinkTarget($this, "edit"), "edit",
1692  get_class($this));
1693 
1694  // link areas
1695  $st_item =& $this->object->getMediaItem("Standard");
1696  if (is_object($st_item) && $this->getEnabledMapAreas())
1697  {
1698  $format = $st_item->getFormat();
1699  if (substr($format, 0, 5) == "image")
1700  {
1701  $ilTabs->addTarget("cont_def_map_areas",
1702  $this->ctrl->getLinkTargetByClass(
1703  array("ilobjmediaobjectgui", "ilimagemapeditorgui"), "editMapAreas"), "editMapAreas",
1704  "ilimagemapeditorgui");
1705  }
1706  }
1707 
1708  // object usages
1709  $ilTabs->addTarget("cont_mob_usages",
1710  $this->ctrl->getLinkTarget($this, "showUsages"), "showUsages",
1711  get_class($this));
1712 
1713  // object files
1714  $std_item = $this->object->getMediaItem("Standard");
1715  $full_item = $this->object->getMediaItem("Fullscreen");
1716  $mset = new ilSetting("mobs");
1717  if ($mset->get("file_manager_always") ||
1718  (!in_array($std_item->getFormat(), ilObjMediaObject::_getSimpleMimeTypes()) ||
1719  (is_object($full_item) && !in_array($full_item->getFormat(), ilObjMediaObject::_getSimpleMimeTypes())))
1720  )
1721  {
1722 // $ilTabs->addTarget("cont_files",
1723 // $this->ctrl->getLinkTarget($this, "editFiles"), "editFiles",
1724 // get_class($this));
1725 
1726  $ilTabs->addTarget("cont_files",
1727  $this->ctrl->getLinkTargetByClass(
1728  array("ilobjmediaobjectgui", "ilfilesystemgui"), "listFiles"), "",
1729  "ilfilesystemgui");
1730  }
1731 
1732  $ilTabs->addTarget("meta_data",
1733  $this->ctrl->getLinkTargetByClass(
1734  array("ilobjmediaobjectgui", "ilmdeditorgui"),'listSection'),
1735  "", "ilmdeditorgui");
1736 
1737  }
1738 
1739  // back to upper context
1740  if ($this->back_title != "")
1741  {
1742  $tabs_gui->setBackTarget($this->back_title,
1743  $this->ctrl->getParentReturn($this));
1744  }
1745  }
1746 
1747 }
1748 ?>