ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjMediaObjectGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once ("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
25 require_once ("./Modules/LearningModule/classes/class.ilInternalLinkGUI.php");
26 require_once ("classes/class.ilObjectGUI.php");
27 
40 {
41  var $ctrl;
42  var $header;
44  var $enabledmapareas = true;
45 
46  function ilObjMediaObjectGUI($a_data, $a_id = 0, $a_call_by_reference = false, $a_prepare_output = false)
47  {
48  global $lng, $ilCtrl;
49 
50  $this->ctrl =& $ilCtrl;
51  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
52  $this->lng =& $lng;
53  $this->back_title = "";
54  $this->type = "mob";
55  }
56 
57  function setHeader($a_title = "")
58  {
59  $this->header = $a_title;
60  }
61 
62  function getHeader()
63  {
64  return $this->header;
65  }
66 
72  function setEnabledMapAreas($a_enabledmapareas)
73  {
74  $this->enabledmapareas = $a_enabledmapareas;
75  }
76 
82  function getEnabledMapAreas()
83  {
85  }
86 
87  function assignObject()
88  {
89  if ($this->id != 0)
90  {
91  $this->object =& new ilObjMediaObject($this->id);
92  }
93  }
94 
96  {
97  $this->ctrl->returnToParent($this);
98  }
99 
100 
104  function &executeCommand()
105  {
106  global $tpl;
107 
108  $next_class = $this->ctrl->getNextClass($this);
109  $cmd = $this->ctrl->getCmd();
110 
111  switch($next_class)
112  {
113  case 'ilmdeditorgui':
114 
115  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
116 
117  $md_gui =& new ilMDEditorGUI(0, $this->object->getId(), $this->object->getType());
118  $md_gui->addObserver($this->object,'MDUpdateListener','General');
119 
120  $this->ctrl->forwardCommand($md_gui);
121  break;
122 
123  case "ilimagemapeditorgui":
124  require_once("./Services/MediaObjects/classes/class.ilImageMapEditorGUI.php");
125  $image_map_edit = new ilImageMapEditorGUI($this->object);
126  $ret = $this->ctrl->forwardCommand($image_map_edit);
127  $tpl->setContent($ret);
128  break;
129 
130  default:
131  if (isset($_POST["editImagemapForward"]) ||
132  isset($_POST["editImagemapForward_x"]) ||
133  isset($_POST["editImagemapForward_y"]))
134  {
135  $cmd = "editImagemapForward";
136  }
137  $cmd.= "Object";
138  $ret =& $this->$cmd();
139  break;
140  }
141 
142  return $ret;
143  }
144 
148  function setBackTitle($a_title)
149  {
150  $this->back_title = $a_title;
151  }
152 
156  function createObject()
157  {
158  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mob_new.html", "Services/MediaObjects");
159  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_mob"));
160  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
161 
162  // select fields for number of columns
163  $this->tpl->setVariable("TXT_STANDARD_VIEW", $this->lng->txt("cont_std_view"));
164  $this->tpl->setVariable("TXT_FILE", $this->lng->txt("cont_file"));
165  $this->tpl->setVariable("TXT_REFERENCE", $this->lng->txt("cont_reference"));
166  $this->tpl->setVariable("TXT_REF_HELPTEXT", $this->lng->txt("cont_ref_helptext"));
167  $this->tpl->setVariable("TXT_WIDTH", $this->lng->txt("cont_width"));
168  $this->tpl->setVariable("TXT_HEIGHT", $this->lng->txt("cont_height"));
169  $this->tpl->setVariable("TXT_ORIGINAL_SIZE", $this->lng->txt("cont_orig_size"));
170  $this->tpl->setVariable("TXT_CAPTION", $this->lng->txt("cont_caption"));
171  $this->tpl->setVariable("TXT_FULLSCREEN_VIEW", $this->lng->txt("cont_fullscreen"));
172  $this->tpl->setVariable("TXT_PARAMETER", $this->lng->txt("cont_parameter"));
173  $this->tpl->setVariable("TXT_RESIZE", $this->lng->txt("cont_resize_image"));
174  $this->tpl->setVariable("TXT_RESIZE_EXPLANATION", $this->lng->txt("cont_resize_explanation"));
175  //$this->tpl->parseCurrentBlock();
176 
177  // operations
178  $this->tpl->setCurrentBlock("commands");
179  $this->tpl->setVariable("BTN_NAME", "save");
180  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
181  $this->tpl->setVariable("BTN_CANCEL", "cancel");
182  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
183  $this->tpl->parseCurrentBlock();
184  }
185 
189  function saveObject()
190  {
191  // determinte title and format
192  if ($_POST["standard_type"] == "File")
193  {
194  $title = $_FILES['standard_file']['name'];
195  }
196  else
197  {
198  $title = ilUtil::stripSlashes($_POST["standard_reference"]);
199  }
200 
201  // create dummy object in db (we need an id)
202  $this->object = new ilObjMediaObject();
203 
204  $this->object->setTitle($title);
205  $this->object->setDescription("");
206  $this->object->create();
207 
208  // determine and create mob directory, move uploaded file to directory
209  //$mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
210  $this->object->createDirectory();
211  $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
212 
213  $media_item =& new ilMediaItem();
214  $this->object->addMediaItem($media_item);
215  $media_item->setPurpose("Standard");
216 
217  if ($_POST["standard_type"] == "File")
218  {
219  $file = $mob_dir."/".$_FILES['standard_file']['name'];
220  //move_uploaded_file($_FILES['standard_file']['tmp_name'], $file);
221  ilUtil::moveUploadedFile($_FILES['standard_file']['tmp_name'],
222  $_FILES['standard_file']['name'], $file);
223 
224  // get mime type
226  $location = $_FILES['standard_file']['name'];
227 
228  // resize standard images
229  if ($_POST["standard_size"] != "original" &&
230  $_POST["standard_resize"] == "y" &&
231  is_int(strpos($format, "image")))
232  {
233  $location = ilObjMediaObject::_resizeImage($file, (int) $_POST["standard_width"],
234  (int) $_POST["standard_height"]);
235  }
236 
237  // set real meta and object data
238  $media_item->setFormat($format);
239  $media_item->setLocation($location);
240  $media_item->setLocationType("LocalFile");
241 // $meta_technical->addFormat($format);
242 // $meta_technical->setSize($_FILES['standard_file']['size']);
243 // $meta_technical->addLocation("LocalFile", $location);
244  $this->object->setTitle($_FILES['standard_file']['name']);
245  }
246  else // standard type: reference
247  {
248  $format = ilObjMediaObject::getMimeType(ilUtil::stripSlashes($_POST["standard_reference"]));
249  $media_item->setFormat($format);
250  $media_item->setLocation(ilUtil::stripSlashes($_POST["standard_reference"]));
251  $media_item->setLocationType("Reference");
252 // $meta_technical->addFormat($format);
253 // $meta_technical->setSize(0);
254 // $meta_technical->addLocation("Reference", $_POST["standard_reference"]);
255  $this->object->setTitle(ilUtil::stripSlashes($_POST["standard_reference"]));
256  }
257 // $meta->addTechnicalSection($meta_technical);
258  $this->object->setDescription($format);
259 
260  // determine width and height of known image types
261  if ($_POST["standard_size"] == "original")
262  {
263  if (ilUtil::deducibleSize($format))
264  {
265  $size = getimagesize($file);
266  $media_item->setWidth($size[0]);
267  $media_item->setHeight($size[1]);
268  }
269  else
270  {
271  $media_item->setWidth(500);
272  $media_item->setHeight(400);
273  }
274  }
275  else
276  {
277  $media_item->setWidth((int) $_POST["standard_width"]);
278  $media_item->setHeight((int) $_POST["standard_height"]);
279  }
280 
281  if ($_POST["standard_caption"] != "")
282  {
283  $media_item->setCaption(ilUtil::stripSlashes($_POST["standard_caption"]));
284  }
285 
286  if ($_POST["standard_param"] != "")
287  {
288  $media_item->setParameters(ilUtil::stripSlashes(utf8_decode($_POST["standard_param"])));
289  }
290 
291  $media_item->setHAlign("Left");
292 
293  // fullscreen view
294  if ($_POST["fullscreen"] == "y")
295  {
296  $media_item =& new ilMediaItem();
297  $this->object->addMediaItem($media_item);
298  $media_item->setPurpose("Fullscreen");
299 
300  // file
301  if ($_POST["full_type"] == "File")
302  {
303  if ($_FILES['full_file']['name'] != "")
304  {
305  $file = $mob_dir."/".$_FILES['full_file']['name'];
306  //move_uploaded_file($_FILES['full_file']['tmp_name'], $file);
307  ilUtil::moveUploadedFile($_FILES['full_file']['tmp_name'],
308  $_FILES['full_file']['name'], $file);
309  }
310 
311  if ($_FILES['full_file']['name'] != "" ||
312  ($_POST["full_size"] != "original" &&
313  $_POST["full_resize"] == "y" &&
314  is_int(strpos($format, "image")))
315  )
316  {
317  // set real meta and object data
319  $location = $_FILES['full_file']['name'];
320 
321  // resize fullscreen images
322  if ($_POST["full_size"] != "original" &&
323  $_POST["full_resize"] == "y" &&
324  is_int(strpos($format, "image")))
325  {
326  $location = ilObjMediaObject::_resizeImage($file, (int) $_POST["full_width"],
327  (int) $_POST["full_height"]);
328  }
329  }
330 
331  $media_item->setFormat($format);
332  $media_item->setLocation($location);
333  $media_item->setLocationType("LocalFile");
334 /*
335  $meta_technical->addFormat($format);
336  $meta_technical->setSize($meta_technical->getSize()
337  + $_FILES['full_file']['size']);
338  $meta_technical->addLocation("LocalFile", $location);
339 */
340 
341  }
342  else // reference
343  {
344  if ($_POST["full_reference"] != "")
345  {
346  $format = ilObjMediaObject::getMimeType($_POST["full_reference"]);
347  $media_item->setFormat($format);
348  $media_item->setLocation(ilUtil::stripSlashes($_POST["full_reference"]));
349  $media_item->setLocationType("Reference");
350 /*
351  $meta_technical->addFormat($format);
352  $meta_technical->addLocation("Reference", $_POST["full_reference"]);
353 */
354  }
355  }
356 
357  // determine width and height of known image types
358  if ($_POST["full_size"] == "original")
359  {
360  if (ilUtil::deducibleSize($format))
361  {
362  $size = getimagesize($file);
363  $media_item->setWidth($size[0]);
364  $media_item->setHeight($size[1]);
365  }
366  else
367  {
368  $media_item->setWidth(500);
369  $media_item->setHeight(400);
370  }
371  }
372  else
373  {
374  $media_item->setWidth((int) $_POST["full_width"]);
375  $media_item->setHeight((int) $_POST["full_height"]);
376  }
377 
378  if ($_POST["full_caption"] != "")
379  {
380  $media_item->setCaption(ilUtil::stripSlashes($_POST["full_caption"]));
381  }
382 
383  if ($_POST["full_param"] != "")
384  {
385  $media_item->setParameters(ilUtil::stripSlashes(utf8_decode($_POST["full_param"])));
386  }
387 
388  }
389 //echo "-".$mob_dir."-";
390  ilUtil::renameExecutables($mob_dir);
391  $this->object->update();
392 
393  return $this->object;
394 
395  }
396 
397  function cancelObject()
398  {
399  $this->ctrl->returnToParent($this);
400  }
401 
405  function editObject()
406  {
407  //add template for view button
408  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
409 
410  // standard item
411  $std_item =& $this->object->getMediaItem("Standard");
412 
413  // edit media alias template
414  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mob_properties.html", "Services/MediaObjects");
415 
416  // deduce size button
417  if ($std_item->getLocationType() == "LocalFile" &&
418  ilUtil::deducibleSize($std_item->getFormat()))
419  {
420  $this->tpl->setCurrentBlock("get_size");
421  $this->tpl->setVariable("CMD_SIZE", "getStandardSize");
422  $this->tpl->setVariable("TXT_GET_SIZE", $this->lng->txt("cont_get_orig_size"));
423  $this->tpl->parseCurrentBlock();
424  //$this->tpl->setCurrentBlock("adm_content");
425  }
426 
427  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_mob_properties"));
428  $this->tpl->setVariable("TXT_STANDARD_VIEW", $this->lng->txt("cont_std_view"));
429 
430  $this->tpl->setVariable("TXT_FILE", $this->lng->txt("cont_localfile"));
431  $this->tpl->setVariable("TXT_REFERENCE", $this->lng->txt("cont_reference"));
432  $this->tpl->setVariable("TXT_REF_HELPTEXT", $this->lng->txt("cont_ref_helptext"));
433  if ($std_item->getLocationType() == "LocalFile")
434  {
435  $this->tpl->setVariable("FILE_CHECKED", "checked=\"1\"");
436  $this->tpl->setVariable("VAL_FILE", $std_item->getLocation());
437  }
438  else
439  {
440  $this->tpl->setVariable("REF_CHECKED", "checked=\"1\"");
441  $this->tpl->setVariable("VAL_REFERENCE", $std_item->getLocation());
442  }
443 
444  $this->tpl->setVariable("TXT_FORMAT", $this->lng->txt("cont_format"));
445  $this->tpl->setVariable("VAL_FORMAT", $std_item->getFormat());
446  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
447 
448  // width
449  $this->tpl->setVariable("TXT_MOB_WIDTH", $this->lng->txt("cont_width"));
450  $this->tpl->setVariable("INPUT_MOB_WIDTH", "mob_width");
451  $this->tpl->setVariable("VAL_MOB_WIDTH", $std_item->getWidth());
452 
453  // height
454  $this->tpl->setVariable("TXT_MOB_HEIGHT", $this->lng->txt("cont_height"));
455  $this->tpl->setVariable("INPUT_MOB_HEIGHT", "mob_height");
456  $this->tpl->setVariable("VAL_MOB_HEIGHT", $std_item->getHeight());
457 
458  // output original size
459  if ($orig_size = $std_item->getOriginalSize())
460  {
461  $this->tpl->setCurrentBlock("orig_size");
462  $this->tpl->setVariable("TXT_ORIGINAL_SIZE", $this->lng->txt("cont_orig_size"));
463  $this->tpl->setVariable("VAL_ORIG_WIDTH", $orig_size["width"]);
464  $this->tpl->setVariable("VAL_ORIG_HEIGHT", $orig_size["height"]);
465  $this->tpl->parseCurrentBlock();
466  }
467 
468  // caption
469  $this->tpl->setVariable("TXT_CAPTION", $this->lng->txt("cont_caption"));
470  $this->tpl->setVariable("INPUT_CAPTION", "mob_caption");
471  $this->tpl->setVariable("VAL_CAPTION", $std_item->getCaption());
472  //$this->tpl->parseCurrentBlock();
473 
474  // parameters
475  $this->tpl->setVariable("TXT_PARAMETER", $this->lng->txt("cont_parameter"));
476  $this->tpl->setVariable("INPUT_PARAMETERS", "mob_parameters");
477  $this->tpl->setVariable("VAL_PARAMETERS", $std_item->getParameterString());
478  //$this->tpl->parseCurrentBlock();
479 
480  // fullscreen view
481  if($this->object->hasFullScreenItem())
482  {
483  $full_item =& $this->object->getMediaItem("Fullscreen");
484 
485  if ($full_item->getLocationType() == "LocalFile" &&
486  ilUtil::deducibleSize($full_item->getFormat()))
487  {
488  $this->tpl->setCurrentBlock("get_full_size");
489  $this->tpl->setVariable("CMD_FULL_SIZE", "getFullscreenSize");
490  $this->tpl->setVariable("TXT_GET_FULL_SIZE", $this->lng->txt("cont_get_orig_size"));
491  $this->tpl->parseCurrentBlock();
492  }
493 
494  $this->tpl->setCurrentBlock("fullscreen");
495 
496  // edit media alias template
497  $this->tpl->setVariable("TXT_FULLSCREEN_VIEW", $this->lng->txt("cont_fullscreen"));
498 
499  $this->tpl->setVariable("TXT_FULL_FILE", $this->lng->txt("cont_localfile"));
500  $this->tpl->setVariable("TXT_FULL_REFERENCE", $this->lng->txt("cont_reference"));
501  $this->tpl->setVariable("TXT_FULL_REF_HELPTEXT", $this->lng->txt("cont_ref_helptext"));
502  if ($full_item->getLocationType() == "LocalFile")
503  {
504  $this->tpl->setVariable("FULL_FILE_CHECKED", "checked=\"1\"");
505  $this->tpl->setVariable("VAL_FULL_FILE", $full_item->getLocation());
506  }
507  else
508  {
509  $this->tpl->setVariable("FULL_REF_CHECKED", "checked=\"1\"");
510  $this->tpl->setVariable("VAL_FULL_REFERENCE", $full_item->getLocation());
511  }
512 
513  //$this->tpl->setVariable("TXT_FULL_TYPE", $this->lng->txt("cont_".$full_item->getLocationType()));
514  //$this->tpl->setVariable("TXT_FULL_LOCATION", $full_item->getLocation());
515  $this->tpl->setVariable("TXT_FULL_FORMAT", $this->lng->txt("cont_format"));
516  $this->tpl->setVariable("VAL_FULL_FORMAT", $full_item->getFormat());
517 
518  // width
519  $this->tpl->setVariable("TXT_FULL_WIDTH", $this->lng->txt("cont_width"));
520  $this->tpl->setVariable("INPUT_FULL_WIDTH", "full_width");
521  $this->tpl->setVariable("VAL_FULL_WIDTH", $full_item->getWidth());
522 
523  // height
524  $this->tpl->setVariable("TXT_FULL_HEIGHT", $this->lng->txt("cont_height"));
525  $this->tpl->setVariable("INPUT_FULL_HEIGHT", "full_height");
526  $this->tpl->setVariable("VAL_FULL_HEIGHT", $full_item->getHeight());
527 
528  // output original size
529  if ($orig_size = $full_item->getOriginalSize())
530  {
531  $this->tpl->setCurrentBlock("orig_full_size");
532  $this->tpl->setVariable("TXT_ORIGINAL_SIZE", $this->lng->txt("cont_orig_size"));
533  $this->tpl->setVariable("VAL_ORIG_WIDTH", $orig_size["width"]);
534  $this->tpl->setVariable("VAL_ORIG_HEIGHT", $orig_size["height"]);
535  $this->tpl->parseCurrentBlock();
536  }
537 
538  // caption
539  $this->tpl->setVariable("TXT_FULL_CAPTION", $this->lng->txt("cont_caption"));
540  $this->tpl->setVariable("INPUT_FULL_CAPTION", "full_caption");
541  $this->tpl->setVariable("VAL_FULL_CAPTION", $full_item->getCaption());
542 
543  // parameters
544  $this->tpl->setVariable("TXT_FULL_PARAMETER", $this->lng->txt("cont_parameter"));
545  $this->tpl->setVariable("INPUT_FULL_PARAMETERS", "full_parameters");
546  $this->tpl->setVariable("VAL_FULL_PARAMETERS", $full_item->getParameterString());
547 
548  $this->tpl->parseCurrentBlock();
549  }
550 
551  // operations
552  if($this->object->hasFullScreenItem())
553  {
554  $this->tpl->setCurrentBlock("remove_full");
555  $this->tpl->setVariable("CMD_REMOVE_FULL", "removeFullscreen");
556  $this->tpl->setVariable("TXT_REMOVE_FULL", $this->lng->txt("cont_remove_fullscreen"));
557  $this->tpl->parseCurrentBlock();
558  }
559  else
560  {
561  $this->tpl->setCurrentBlock("add_full");
562  $this->tpl->setVariable("CMD_ADD_FULL", "addFullscreen");
563  $this->tpl->setVariable("TXT_ADD_FULL", $this->lng->txt("cont_add_fullscreen"));
564  $this->tpl->parseCurrentBlock();
565  }
566  $this->tpl->setCurrentBlock("commands");
567 
568  $this->tpl->setVariable("BTN_RESIZE", "resizeImages");
569  $this->tpl->setVariable("TXT_RESIZE", $this->lng->txt("cont_resize_image")." [*]");
570  $this->tpl->setVariable("BTN_NAME", "saveProperties");
571  $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
572  $this->tpl->parseCurrentBlock();
573 
574  $this->tpl->setVariable("TXT_RESIZE_EXPLANATION",
575  $this->lng->txt("cont_resize_explanation2"));
576  }
577 
578 
583  {
584  // directory
585  $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
586 
587  // standard item
588  $std_item =& $this->object->getMediaItem("Standard");
589  if ($std_item->getLocationType() == "LocalFile" &&
590  is_int(strpos($std_item->getFormat(), "image"))
591  )
592  {
593  $file = $mob_dir."/".$std_item->getLocation();
594  $location = ilObjMediaObject::_resizeImage($file, $std_item->getWidth(),
595  $std_item->getHeight());
596  $std_item->setLocation($location);
597  $std_item->update();
598  }
599 
600  // fullscreen item
601  if($this->object->hasFullScreenItem())
602  {
603  $full_item =& $this->object->getMediaItem("Fullscreen");
604  if ($full_item->getLocationType() == "LocalFile" &&
605  is_int(strpos($full_item->getFormat(), "image"))
606  )
607  {
608  $file = $mob_dir."/".$full_item->getLocation();
609  $location = ilObjMediaObject::_resizeImage($file, $full_item->getWidth(),
610  $full_item->getHeight());
611  $full_item->setLocation($location);
612  $full_item->update();
613  }
614  }
615 
616  $this->ctrl->redirect($this, "edit");
617  }
618 
619 
624  {
625  $std_item =& $this->object->getMediaItem("Standard");
626  $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
627 
628  if ($std_item->getLocationType() == "LocalFile")
629  {
630  $file = $mob_dir."/".$std_item->getLocation();
631  $size = getimagesize($file);
632  $std_item->setWidth($size[0]);
633  $std_item->setHeight($size[1]);
634  $this->object->update();
635  }
636  $this->ctrl->redirect($this, "edit");
637  }
638 
639 
644  {
645  $full_item =& $this->object->getMediaItem("Fullscreen");
646  $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
647 
648  if ($full_item->getLocationType() == "LocalFile")
649  {
650  $file = $mob_dir."/".$full_item->getLocation();
651  $size = getimagesize($file);
652  $full_item->setWidth($size[0]);
653  $full_item->setHeight($size[1]);
654  $this->object->update();
655  }
656  $this->ctrl->redirect($this, "edit");
657  }
658 
663  {
664  global $lng;
665 
666  $std_item =& $this->object->getMediaItem("Standard");
667  if ($_POST["standard_type"] == "Reference")
668  {
669  $std_item->setLocationType("Reference");
670  $std_item->setFormat(ilObjMediaObject::getMimeType($_POST["standard_reference"]));
671  $std_item->setLocation(ilUtil::stripSlashes($_POST["standard_reference"]));
672  }
673  if ($_POST["standard_type"] == "LocalFile")
674  {
675  if ($_FILES['standard_file']['name'] != "")
676  {
677  $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
678  $file = $mob_dir."/".$_FILES['standard_file']['name'];
679  //move_uploaded_file($_FILES['standard_file']['tmp_name'], $file);
680  ilUtil::moveUploadedFile($_FILES['standard_file']['tmp_name'],
681  $_FILES['standard_file']['name'], $file);
682 
683  $format = ilObjMediaObject::getMimeType($file);
684  $std_item->setFormat($format);
685  $std_item->setLocation($_FILES['standard_file']['name']);
686  }
687  $std_item->setLocationType("LocalFile");
688  }
689  $std_item->setWidth((int) $_POST["mob_width"]);
690  $std_item->setHeight((int) $_POST["mob_height"]);
691  $std_item->setCaption(ilUtil::stripSlashes($_POST["mob_caption"]));
692  $std_item->setParameters(ilUtil::stripSlashes(utf8_decode($_POST["mob_parameters"])));
693 
694  if($this->object->hasFullscreenItem())
695  {
696  $full_item =& $this->object->getMediaItem("Fullscreen");
697  if ($_POST["full_type"] == "Reference")
698  {
699  $full_item->setLocationType("Reference");
700  $full_item->setFormat(ilObjMediaObject::getMimeType($_POST["full_reference"]));
701  $full_item->setLocation(ilUtil::stripSlashes($_POST["full_reference"]));
702  }
703  if ($_POST["full_type"] == "LocalFile")
704  {
705  if ($_FILES['full_file']['name'] != "")
706  {
707  $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
708  $file = $mob_dir."/".$_FILES['full_file']['name'];
709  //move_uploaded_file($_FILES['full_file']['tmp_name'], $file);
710  ilUtil::moveUploadedFile($_FILES['full_file']['tmp_name'],
711  $_FILES['full_file']['name'], $file);
712 
713  $format = ilObjMediaObject::getMimeType($file);
714  $full_item->setFormat($format);
715  $full_item->setLocation($_FILES['full_file']['name']);
716  }
717  $full_item->setLocationType("LocalFile");
718  }
719  $full_item->setWidth((int) $_POST["full_width"]);
720  $full_item->setHeight((int) $_POST["full_height"]);
721  $full_item->setCaption(ilUtil::stripSlashes($_POST["full_caption"]));
722  $full_item->setParameters(ilUtil::stripSlashes(utf8_decode($_POST["full_parameters"])));
723  }
724 
726 
727  $this->object->update();
728  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
729 
730  $this->ctrl->redirect($this, "edit");
731  }
732 
733 
737  function editFilesObject()
738  {
739  // standard item
740  $std_item =& $this->object->getMediaItem("Standard");
741  if($this->object->hasFullscreenItem())
742  {
743  $full_item =& $this->object->getMediaItem("Fullscreen");
744  }
745 
746  // create table
747  require_once("./Services/Table/classes/class.ilTableGUI.php");
748  $tbl = new ilTableGUI();
749 
750  // determine directory
751  $cur_subdir = $_GET["cdir"];
752  if($_GET["newdir"] == "..")
753  {
754  $cur_subdir = substr($cur_subdir, 0, strrpos($cur_subdir, "/"));
755  }
756  else
757  {
758  if (!empty($_GET["newdir"]))
759  {
760  if (!empty($cur_subdir))
761  {
762  $cur_subdir = $cur_subdir."/".$_GET["newdir"];
763  }
764  else
765  {
766  $cur_subdir = $_GET["newdir"];
767  }
768  }
769  }
770 
771  $cur_subdir = str_replace(".", "", $cur_subdir);
772  $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
773  $cur_dir = (!empty($cur_subdir))
774  ? $mob_dir."/".$cur_subdir
775  : $mob_dir;
776 
777  // load files templates
778  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.mob_files.html", "Services/MediaObjects");
779 
780  //$this->tpl->setVariable("FORMACTION1", "lm_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"].
781  // "&hier_id=".$_GET["hier_id"]."&cdir=".$cur_subdir."&cmd=post");
782 
783  $this->ctrl->setParameter($this, "cdir", urlencode($cur_subdir));
784  $this->tpl->setVariable("FORMACTION1", $this->ctrl->getFormAction($this));
785 //echo "--".$this->getTargetScript().
786  //"&hier_id=".$_GET["hier_id"]."&cdir=".$cur_subdir."&cmd=post"."--<br>";
787  $this->tpl->setVariable("TXT_NEW_DIRECTORY", $this->lng->txt("cont_new_dir"));
788  $this->tpl->setVariable("TXT_NEW_FILE", $this->lng->txt("cont_new_file"));
789  $this->tpl->setVariable("CMD_NEW_DIR", "createDirectory");
790  $this->tpl->setVariable("CMD_NEW_FILE", "uploadFile");
791  $this->tpl->setVariable("BTN_NEW_DIR", $this->lng->txt("create"));
792  $this->tpl->setVariable("BTN_NEW_FILE", $this->lng->txt("upload"));
793 
794  //
795  $this->tpl->addBlockfile("FILE_TABLE", "files", "tpl.table.html");
796 
797  // load template for table content data
798  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.mob_file_row.html", "Services/MediaObjects");
799 
800  $num = 0;
801 
802  $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
803  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
804 
805  $tbl->setTitle($this->lng->txt("cont_files")." ".$cur_subdir);
806  //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
807 
808  $tbl->setHeaderNames(array("", "", $this->lng->txt("cont_dir_file"),
809  $this->lng->txt("cont_size"), $this->lng->txt("cont_purpose")));
810 
811  $cols = array("", "", "dir_file", "size", "purpose");
812  $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"],
813  "cmd" => "editFiles", "hier_id" => $_GET["hier_id"]);
814  $tbl->setHeaderVars($cols, $header_params);
815  $tbl->setColumnWidth(array("1%", "1%", "33%", "33%", "32%"));
816 
817  // control
818  $tbl->setOrderColumn($_GET["sort_by"]);
819  $tbl->setOrderDirection($_GET["sort_order"]);
820  $tbl->setLimit($_GET["limit"]);
821  $tbl->setOffset($_GET["offset"]);
822  $tbl->setMaxCount($this->maxcount); // ???
823  //$tbl->setMaxCount(30); // ???
824 
825  $this->tpl->setVariable("COLUMN_COUNTS", 5);
826 
827  // delete button
828  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
829  $this->tpl->setCurrentBlock("tbl_action_btn");
830  $this->tpl->setVariable("BTN_NAME", "deleteFile");
831  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
832  $this->tpl->parseCurrentBlock();
833 
834  $this->tpl->setCurrentBlock("tbl_action_btn");
835  $this->tpl->setVariable("BTN_NAME", "assignStandard");
836  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("cont_assign_std"));
837  $this->tpl->parseCurrentBlock();
838 
839  $this->tpl->setCurrentBlock("tbl_action_btn");
840  $this->tpl->setVariable("BTN_NAME", "assignFullscreen");
841  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("cont_assign_full"));
842  $this->tpl->parseCurrentBlock();
843 
844  // footer
845  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
846  //$tbl->disable("footer");
847 
848  $entries = ilUtil::getDir($cur_dir);
849 
850  //$objs = ilUtil::sortArray($objs, $_GET["sort_by"], $_GET["sort_order"]);
851  $tbl->setMaxCount(count($entries));
852  $entries = array_slice($entries, $_GET["offset"], $_GET["limit"]);
853 
854  $tbl->render();
855  if(count($entries) > 0)
856  {
857  $i=0;
858  foreach($entries as $entry)
859  {
860  if(($entry["entry"] == ".") || ($entry["entry"] == ".." && empty($cur_subdir)))
861  {
862  continue;
863  }
864 
865  //$this->tpl->setVariable("ICON", $obj["title"]);
866  if($entry["type"] == "dir")
867  {
868  $this->tpl->setCurrentBlock("FileLink");
869  $this->ctrl->setParameter($this, "cdir", $cur_subdir);
870  $this->ctrl->setParameter($this, "newdir", rawurlencode($entry["entry"]));
871  $this->tpl->setVariable("LINK_FILENAME", $this->ctrl->getLinkTarget($this, "editFiles"));
872  $this->tpl->setVariable("TXT_FILENAME", $entry["entry"]);
873  $this->tpl->parseCurrentBlock();
874 
875  $this->tpl->setVariable("ICON", "<img src=\"".
876  ilUtil::getImagePath("icon_cat.gif")."\">");
877  }
878  else
879  {
880  $this->tpl->setCurrentBlock("File");
881  $this->tpl->setVariable("TXT_FILENAME2", $entry["entry"]);
882  $this->tpl->parseCurrentBlock();
883  }
884 
885  $this->tpl->setCurrentBlock("tbl_content");
886  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
887  $this->tpl->setVariable("CSS_ROW", $css_row);
888 
889  $this->tpl->setVariable("TXT_SIZE", $entry["size"]);
890  $this->tpl->setVariable("CHECKBOX_ID", $entry["entry"]);
891  $compare = (!empty($cur_subdir))
892  ? $cur_subdir."/".$entry["entry"]
893  : $entry["entry"];
894  $purpose = array();
895  if ($std_item->getLocation() == $compare)
896  {
897  $purpose[] = $this->lng->txt("cont_std_view");
898  }
899  if($this->object->hasFullscreenItem())
900  {
901  if ($full_item->getLocation() == $compare)
902  {
903  $purpose[] = $this->lng->txt("cont_fullscreen");
904  }
905  }
906  $this->tpl->setVariable("TXT_PURPOSE", implode($purpose, ", "));
907 
908  $this->tpl->parseCurrentBlock();
909  }
910  } //if is_array
911  else
912  {
913  $this->tpl->setCurrentBlock("notfound");
914  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
915  $this->tpl->setVariable("NUM_COLS", 4);
916  $this->tpl->parseCurrentBlock();
917  }
918 
919  $this->tpl->parseCurrentBlock();
920  }
921 
922 
927  {
928 //echo "cdir:".$_GET["cdir"].":<br>";
929  // determine directory
930  $cur_subdir = str_replace(".", "", $_GET["cdir"]);
931  $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
932  $cur_dir = (!empty($cur_subdir))
933  ? $mob_dir."/".$cur_subdir
934  : $mob_dir;
935 
936  $new_dir = str_replace(".", "", $_POST["new_dir"]);
937  $new_dir = str_replace("/", "", $new_dir);
938 
939  if (!empty($new_dir))
940  {
941  ilUtil::makeDir($cur_dir."/".$new_dir);
942  }
943  $this->ctrl->saveParameter($this, "cdir");
944  $this->ctrl->redirect($this, "editFiles");
945  }
946 
950  function uploadFileObject()
951  {
952  // determine directory
953  $cur_subdir = str_replace(".", "", $_GET["cdir"]);
954  $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
955  $cur_dir = (!empty($cur_subdir))
956  ? $mob_dir."/".$cur_subdir
957  : $mob_dir;
958  if (is_file($_FILES["new_file"]["tmp_name"]))
959  {
960  //move_uploaded_file($_FILES["new_file"]["tmp_name"],
961  //$cur_dir."/".$_FILES["new_file"]["name"]);
962  $file = $cur_dir."/".$_FILES["new_file"]["name"];
963  ilUtil::moveUploadedFile($_FILES['new_file']['tmp_name'],
964  $_FILES['new_file']['name'], $file);
965 
966  }
967  ilUtil::renameExecutables($mob_dir);
968  $this->ctrl->saveParameter($this, "cdir");
969  $this->ctrl->redirect($this, "editFiles");
970  }
971 
976  {
977  if (!isset($_POST["file"]))
978  {
979  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
980  }
981 
982  if (count($_POST["file"]) > 1)
983  {
984  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
985  }
986 
987  // determine directory
988  $cur_subdir = str_replace(".", "", $_GET["cdir"]);
989  $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
990  $cur_dir = (!empty($cur_subdir))
991  ? $mob_dir."/".$cur_subdir
992  : $mob_dir;
993  $file = $cur_dir."/".$_POST["file"][0];
994  $location = (!empty($cur_subdir))
995  ? $cur_subdir."/".$_POST["file"][0]
996  : $_POST["file"][0];
997 
998  if(!is_file($file))
999  {
1000  $this->ilias->raiseError($this->lng->txt("cont_select_file"),$this->ilias->error_obj->MESSAGE);
1001  }
1002 
1003  $std_item =& $this->object->getMediaItem("Standard");
1004  $std_item->setLocationType("LocalFile");
1005  $std_item->setLocation($location);
1007  $std_item->setFormat($format);
1008  $this->object->update();
1009  $this->ctrl->saveParameter($this, "cdir");
1010  $this->ctrl->redirect($this, "editFiles");
1011 
1012  $this->ctrl->saveParameter($this, "cdir");
1013  $this->ctrl->redirect($this, "editFiles");
1014  }
1015 
1016 
1021  {
1022  if (!isset($_POST["file"]))
1023  {
1024  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1025  }
1026 
1027  if (count($_POST["file"]) > 1)
1028  {
1029  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
1030  }
1031 
1032  // determine directory
1033  $cur_subdir = str_replace(".", "", $_GET["cdir"]);
1034  $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
1035  $cur_dir = (!empty($cur_subdir))
1036  ? $mob_dir."/".$cur_subdir
1037  : $mob_dir;
1038  $file = $cur_dir."/".$_POST["file"][0];
1039  $location = (!empty($cur_subdir))
1040  ? $cur_subdir."/".$_POST["file"][0]
1041  : $_POST["file"][0];
1042 
1043  if(!is_file($file))
1044  {
1045  $this->ilias->raiseError($this->lng->txt("cont_select_file"),$this->ilias->error_obj->MESSAGE);
1046  }
1047 
1048  if(!$this->object->hasFullScreenItem())
1049  { // create new fullscreen item
1050  $std_item =& $this->object->getMediaItem("Standard");
1051  $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
1052  $file = $mob_dir."/".$location;
1053  $full_item =& new ilMediaItem();
1054  $full_item->setMobId($std_item->getMobId());
1055  $full_item->setLocation($location);
1056  $full_item->setLocationType("LocalFile");
1057  $full_item->setFormat(ilObjMediaObject::getMimeType($file));
1058  $full_item->setPurpose("Fullscreen");
1059  $this->object->addMediaItem($full_item);
1060  }
1061  else // alter existing fullscreen item
1062  {
1063  $full_item =& $this->object->getMediaItem("Fullscreen");
1064 
1065  $full_item->setLocationType("LocalFile");
1066  $full_item->setLocation($location);
1068  $full_item->setFormat($format);
1069  }
1070  $this->object->update();
1071  $this->ctrl->saveParameter($this, "cdir");
1072  $this->ctrl->redirect($this, "editFiles");
1073  }
1074 
1075 
1080  {
1081  $this->object->removeMediaItem("Fullscreen");
1082  $this->object->update();
1083 
1084  $this->ctrl->redirect($this, "edit");
1085  }
1086 
1087 
1092  {
1093  if (!$this->object->hasFullScreenItem())
1094  {
1095  $std_item =& $this->object->getMediaItem("Standard");
1096  $full_item =& new ilMediaItem();
1097  $full_item->setMobId($std_item->getMobId());
1098  $full_item->setLocation($std_item->getLocation());
1099  $full_item->setLocationType($std_item->getLocationType());
1100  $full_item->setFormat($std_item->getFormat());
1101  $full_item->setWidth($std_item->getWidth());
1102  $full_item->setHeight($std_item->getHeight());
1103  $full_item->setCaption($std_item->getCaption());
1104  $full_item->setPurpose("Fullscreen");
1105  $this->object->addMediaItem($full_item);
1106 
1107  $this->object->update();
1108  }
1109 
1110  $this->ctrl->redirect($this, "edit");
1111  }
1112 
1113 
1117  function deleteFileObject()
1118  {
1119  if (!isset($_POST["file"]))
1120  {
1121  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1122  }
1123 
1124  if (count($_POST["file"]) > 1)
1125  {
1126  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
1127  }
1128 
1129  if ($_POST["file"][0] == "..")
1130  {
1131  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
1132  }
1133 
1134  $cur_subdir = str_replace(".", "", $_GET["cdir"]);
1135  $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
1136  $cur_dir = (!empty($cur_subdir))
1137  ? $mob_dir."/".$cur_subdir
1138  : $mob_dir;
1139  $file = $cur_dir."/".$_POST["file"][0];
1140  $location = (!empty($cur_subdir))
1141  ? $cur_subdir."/".$_POST["file"][0]
1142  : $_POST["file"][0];
1143 
1144  $full_item =& $this->object->getMediaItem("Fullscreen");
1145  $std_item =& $this->object->getMediaItem("Standard");
1146 
1147  if ($location == $std_item->getLocation())
1148  {
1149  $this->ilias->raiseError($this->lng->txt("cont_cant_del_std"),$this->ilias->error_obj->MESSAGE);
1150  }
1151 
1152  if($this->object->hasFullScreenItem())
1153  {
1154  if ($location == $full_item->getLocation())
1155  {
1156  $this->ilias->raiseError($this->lng->txt("cont_cant_del_full"),$this->ilias->error_obj->MESSAGE);
1157  }
1158  }
1159 
1160  if (@is_dir($file))
1161  {
1162  if (substr($std_item->getLocation(), 0 ,strlen($location)) == $location)
1163  {
1164  $this->ilias->raiseError($this->lng->txt("cont_std_is_in_dir"),$this->ilias->error_obj->MESSAGE);
1165  }
1166 
1167  if($this->object->hasFullScreenItem())
1168  {
1169  if (substr($full_item->getLocation(), 0 ,strlen($location)) == $location)
1170  {
1171  $this->ilias->raiseError($this->lng->txt("cont_full_is_in_dir"),$this->ilias->error_obj->MESSAGE);
1172  }
1173  }
1174  }
1175 
1176  if (@is_file($file))
1177  {
1178  unlink($file);
1179  }
1180 
1181  if (@is_dir($file))
1182  {
1184  }
1185 
1186  $this->ctrl->saveParameter($this, "cdir");
1187  $this->ctrl->redirect($this, "editFiles");
1188  }
1189 
1193  function showUsagesObject()
1194  {
1195  global $tpl;
1196 
1197  include_once("./Services/MediaObjects/classes/class.ilMediaObjectUsagesTableGUI.php");
1198  $usages_table = new ilMediaObjectUsagesTableGUI($this, "showUsages",
1199  $this->object);
1200  $tpl->setContent($usages_table->getHTML());
1201  }
1202 
1206  function _getMediaInfoHTML(&$a_mob)
1207  {
1208  global $lng;
1209 
1210  $tpl =& new ilTemplate("tpl.media_info.html", true, true, "Services/MediaObjects");
1211  $types = array("Standard", "Fullscreen");
1212  foreach ($types as $type)
1213  {
1214  if($type == "Fullscreen" && !$a_mob->hasFullScreenItem())
1215  {
1216  continue;
1217  }
1218 
1219  $med =& $a_mob->getMediaItem($type);
1220  $tpl->setCurrentBlock("media_info");
1221  if ($type == "Standard")
1222  {
1223  $tpl->setVariable("TXT_PURPOSE", $lng->txt("cont_std_view"));
1224  }
1225  else
1226  {
1227  $tpl->setVariable("TXT_PURPOSE", $lng->txt("cont_fullscreen"));
1228  }
1229  $tpl->setVariable("TXT_TYPE", $lng->txt("cont_".strtolower($med->getLocationType())));
1230  $tpl->setVariable("VAL_LOCATION", $med->getLocation());
1231  if ($med->getLocationType() == "LocalFile")
1232  {
1233  $file = ilObjMediaObject::_getDirectory($med->getMobId())."/".$med->getLocation();
1234  if (is_file($file))
1235  {
1236  $size = filesize($file);
1237  }
1238  else
1239  {
1240  $size = 0;
1241  }
1242  $tpl->setVariable("VAL_FILE_SIZE", " ($size ".$lng->txt("bytes").")");
1243  }
1244  $tpl->setVariable("TXT_FORMAT", $lng->txt("cont_format"));
1245  $tpl->setVariable("VAL_FORMAT", $med->getFormat());
1246  if ($med->getWidth() != "" && $med->getHeight() != "")
1247  {
1248  $tpl->setCurrentBlock("size");
1249  $tpl->setVariable("TXT_SIZE", $lng->txt("size"));
1250  $tpl->setVariable("VAL_SIZE", $med->getWidth()."x".$med->getHeight());
1251  $tpl->parseCurrentBlock();
1252  }
1253 
1254  // original size
1255  if ($orig_size = $med->getOriginalSize())
1256  {
1257  if ($orig_size["width"] != $med->getWidth() ||
1258  $orig_size["height"] != $med->getHeight())
1259  {
1260  $tpl->setCurrentBlock("orig_size");
1261  $tpl->setVariable("TXT_ORIG_SIZE", $lng->txt("cont_orig_size"));
1262  $tpl->setVariable("ORIG_WIDTH", $orig_size["width"]);
1263  $tpl->setVariable("ORIG_HEIGHT", $orig_size["height"]);
1264  $tpl->parseCurrentBlock();
1265  }
1266  }
1267  $tpl->setCurrentBlock("media_info");
1268  $tpl->parseCurrentBlock();
1269  }
1270 
1271  return $tpl->get();
1272  }
1273 
1277  function setAdminTabs()
1278  {
1279  // catch feedback message
1280  ilUtil::sendInfo();
1281  #include_once("classes/class.ilTabsGUI.php");
1282  #$tabs_gui =& new ilTabsGUI();
1283  $this->getTabs($this->tabs_gui);
1284 
1285  //$tabs_gui->setTargetScript($this->ctrl->getLinkTarget($this));
1286  if (is_object($this->object) && strtolower(get_class($this->object)) == "ilobjmediaobject")
1287  {
1288  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_mob_b.gif"));
1289  //$this->tpl->setCurrentBlock("header_image");
1290  //$this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_mob_b.gif"));
1291  //$this->tpl->parseCurrentBlock();
1292  $this->tpl->setCurrentBlock();
1293  $title = $this->object->getTitle();
1294  $this->tpl->setVariable("HEADER", $title);
1295  }
1296  else
1297  {
1298  //$title = $this->object->getTitle();
1299  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_mob_b.gif"));
1300  //$this->tpl->setCurrentBlock("header_image");
1301  //$this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_mob_b.gif"));
1302  //$this->tpl->parseCurrentBlock();
1303  $this->tpl->setVariable("HEADER", $this->lng->txt("cont_create_mob"));
1304  }
1305  }
1306 
1310  function getTabs(&$tabs_gui)
1311  {
1312  global $ilTabs;
1313 
1314  //$tabs_gui->setTargetScript($this->ctrl->getLinkTarget($this));
1315  if (is_object($this->object) && strtolower(get_class($this->object)) == "ilobjmediaobject"
1316  && $this->object->getId() > 0)
1317  {
1318  // object properties
1319  $ilTabs->addTarget("cont_mob_def_prop",
1320  $this->ctrl->getLinkTarget($this, "edit"), "edit",
1321  get_class($this));
1322 
1323  // link areas
1324  $st_item =& $this->object->getMediaItem("Standard");
1325  if (is_object($st_item) && $this->getEnabledMapAreas())
1326  {
1327  $format = $st_item->getFormat();
1328  if (substr($format, 0, 5) == "image")
1329  {
1330 // $ilTabs->addTarget("cont_map_areas",
1331 // $this->ctrl->getLinkTarget($this, "editMapAreas"), "editMapAreas",
1332 // get_class($this));
1333  $ilTabs->addTarget("cont_def_map_areas",
1334  $this->ctrl->getLinkTargetByClass(
1335  array("ilobjmediaobjectgui", "ilimagemapeditorgui"), "editMapAreas"), "editMapAreas",
1336  "ilimagemapeditorgui");
1337  }
1338  }
1339 
1340  // object usages
1341  $ilTabs->addTarget("cont_mob_usages",
1342  $this->ctrl->getLinkTarget($this, "showUsages"), "showUsages",
1343  get_class($this));
1344 
1345  // object files
1346  $ilTabs->addTarget("cont_files",
1347  $this->ctrl->getLinkTarget($this, "editFiles"), "editFiles",
1348  get_class($this));
1349 
1350  $ilTabs->addTarget("meta_data",
1351  $this->ctrl->getLinkTargetByClass(
1352  array("ilobjmediaobjectgui", "ilmdeditorgui"),'listSection'),
1353  "", "ilmdeditorgui");
1354 
1355  }
1356 
1357  // back to upper context
1358  if ($this->back_title != "")
1359  {
1360  $tabs_gui->setBackTarget($this->back_title,
1361  $this->ctrl->getParentReturn($this));
1362  }
1363  }
1364 
1365 }
1366 ?>