00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 require_once ("content/classes/Media/class.ilObjMediaObject.php");
00025 require_once ("content/classes/class.ilInternalLinkGUI.php");
00026 require_once ("classes/class.ilObjectGUI.php");
00027
00039 class ilObjMediaObjectGUI extends ilObjectGUI
00040 {
00041 var $ctrl;
00042 var $header;
00043 var $target_script;
00044
00045 function ilObjMediaObjectGUI($a_data, $a_id = 0, $a_call_by_reference = false, $a_prepare_output = false)
00046 {
00047 global $lng, $ilCtrl;
00048
00049 $this->ctrl =& $ilCtrl;
00050 parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
00051 $this->lng =& $lng;
00052 $this->back_title = "";
00053 $this->type = "mob";
00054 }
00055
00056 function _forwards()
00057 {
00058 return array("ilInternalLinkGUI");
00059 }
00060
00061 function setHeader($a_title = "")
00062 {
00063 $this->header = $a_title;
00064 }
00065
00066 function getHeader()
00067 {
00068 return $this->header;
00069 }
00070
00071 function assignObject()
00072 {
00073 if ($this->id != 0)
00074 {
00075 $this->object =& new ilObjMediaObject($this->id);
00076 }
00077 }
00078
00079 function returnToContextObject()
00080 {
00081 $this->ctrl->returnToParent($this);
00082 }
00083
00084
00085 function &executeCommand()
00086 {
00087 $next_class = $this->ctrl->getNextClass($this);
00088 $cmd = $this->ctrl->getCmd();
00089
00090 switch($next_class)
00091 {
00092 case 'ilmdeditorgui':
00093
00094 include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
00095
00096 $md_gui =& new ilMDEditorGUI(0, $this->object->getId(), $this->object->getType());
00097 $md_gui->addObserver($this->object,'MDUpdateListener','General');
00098
00099 $this->ctrl->forwardCommand($md_gui);
00100 break;
00101
00102 case "ilinternallinkgui":
00103 require_once("content/classes/class.ilInternalLinkGUI.php");
00104 $link_gui = new ilInternalLinkGUI("Media_Media", 0);
00105 $link_gui->setMode("link");
00106 $link_gui->setSetLinkTargetScript(
00107 $this->ctrl->getLinkTargetByClass("ilObjMediaObjectGUI",
00108 "setInternalLink", "", true));
00109 $link_gui->filterLinkType("Media");
00110
00111 $ret =& $this->ctrl->forwardCommand($link_gui);
00112 break;
00113
00114 default:
00115 if (isset($_POST["editImagemapForward"]) ||
00116 isset($_POST["editImagemapForward_x"]) ||
00117 isset($_POST["editImagemapForward_y"]))
00118 {
00119 $cmd = "editImagemapForward";
00120 }
00121 $cmd.= "Object";
00122 $ret =& $this->$cmd();
00123 break;
00124 }
00125
00126 return $ret;
00127 }
00128
00132 function setBackTitle($a_title)
00133 {
00134 $this->back_title = $a_title;
00135 }
00136
00140 function createObject()
00141 {
00142 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mob_new.html", "content");
00143 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_mob"));
00144 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00145
00146
00147 $this->tpl->setVariable("TXT_STANDARD_VIEW", $this->lng->txt("cont_std_view"));
00148 $this->tpl->setVariable("TXT_FILE", $this->lng->txt("cont_file"));
00149 $this->tpl->setVariable("TXT_REFERENCE", $this->lng->txt("cont_reference"));
00150 $this->tpl->setVariable("TXT_REF_HELPTEXT", $this->lng->txt("cont_ref_helptext"));
00151 $this->tpl->setVariable("TXT_WIDTH", $this->lng->txt("cont_width"));
00152 $this->tpl->setVariable("TXT_HEIGHT", $this->lng->txt("cont_height"));
00153 $this->tpl->setVariable("TXT_ORIGINAL_SIZE", $this->lng->txt("cont_orig_size"));
00154 $this->tpl->setVariable("TXT_CAPTION", $this->lng->txt("cont_caption"));
00155 $this->tpl->setVariable("TXT_FULLSCREEN_VIEW", $this->lng->txt("cont_fullscreen"));
00156 $this->tpl->setVariable("TXT_PARAMETER", $this->lng->txt("cont_parameter"));
00157 $this->tpl->setVariable("TXT_RESIZE", $this->lng->txt("cont_resize_image"));
00158 $this->tpl->setVariable("TXT_RESIZE_EXPLANATION", $this->lng->txt("cont_resize_explanation"));
00159 $this->tpl->parseCurrentBlock();
00160
00161
00162 $this->tpl->setCurrentBlock("commands");
00163 $this->tpl->setVariable("BTN_NAME", "save");
00164 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00165 $this->tpl->setVariable("BTN_CANCEL", "cancel");
00166 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00167 $this->tpl->parseCurrentBlock();
00168
00169 }
00170
00174 function saveObject()
00175 {
00176
00177 if ($_POST["standard_type"] == "File")
00178 {
00179 $title = $_FILES['standard_file']['name'];
00180 }
00181 else
00182 {
00183 $title = $_POST["standard_reference"];
00184 }
00185
00186
00187 $this->object = new ilObjMediaObject();
00188
00189 $this->object->setTitle($title);
00190 $this->object->setDescription("");
00191 $this->object->create();
00192
00193
00194
00195 $this->object->createDirectory();
00196 $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
00197
00198 $media_item =& new ilMediaItem();
00199 $this->object->addMediaItem($media_item);
00200 $media_item->setPurpose("Standard");
00201
00202
00203
00204 if ($_POST["standard_type"] == "File")
00205 {
00206 $file = $mob_dir."/".$_FILES['standard_file']['name'];
00207
00208 ilUtil::moveUploadedFile($_FILES['standard_file']['tmp_name'],
00209 $_FILES['standard_file']['name'], $file);
00210
00211
00212 $format = ilObjMediaObject::getMimeType($file);
00213 $location = $_FILES['standard_file']['name'];
00214
00215
00216 if ($_POST["standard_size"] != "original" &&
00217 $_POST["standard_resize"] == "y" &&
00218 is_int(strpos($format, "image")))
00219 {
00220 $location = ilObjMediaObject::_resizeImage($file, $_POST["standard_width"],
00221 $_POST["standard_height"]);
00222 }
00223
00224
00225 $media_item->setFormat($format);
00226 $media_item->setLocation($location);
00227 $media_item->setLocationType("LocalFile");
00228
00229
00230
00231 $this->object->setTitle($_FILES['standard_file']['name']);
00232 }
00233 else
00234 {
00235 $format = ilObjMediaObject::getMimeType($_POST["standard_reference"]);
00236 $media_item->setFormat($format);
00237 $media_item->setLocation($_POST["standard_reference"]);
00238 $media_item->setLocationType("Reference");
00239
00240
00241
00242 $this->object->setTitle($_POST["standard_reference"]);
00243 }
00244
00245 $this->object->setDescription($format);
00246
00247
00248 if ($_POST["standard_size"] == "original")
00249 {
00250 if (ilUtil::deducibleSize($format))
00251 {
00252 $size = getimagesize($file);
00253 $media_item->setWidth($size[0]);
00254 $media_item->setHeight($size[1]);
00255 }
00256 }
00257 else
00258 {
00259 $media_item->setWidth($_POST["standard_width"]);
00260 $media_item->setHeight($_POST["standard_height"]);
00261 }
00262
00263 if ($_POST["standard_caption"] != "")
00264 {
00265 $media_item->setCaption($_POST["standard_caption"]);
00266 }
00267
00268 if ($_POST["standard_param"] != "")
00269 {
00270 $media_item->setParameters(ilUtil::stripSlashes(utf8_decode($_POST["standard_param"])));
00271 }
00272
00273 $media_item->setHAlign("Left");
00274
00275
00276 if ($_POST["fullscreen"] == "y")
00277 {
00278 $media_item =& new ilMediaItem();
00279 $this->object->addMediaItem($media_item);
00280 $media_item->setPurpose("Fullscreen");
00281
00282
00283 if ($_POST["full_type"] == "File")
00284 {
00285 if ($_FILES['full_file']['name'] != "")
00286 {
00287 $file = $mob_dir."/".$_FILES['full_file']['name'];
00288
00289 ilUtil::moveUploadedFile($_FILES['full_file']['tmp_name'],
00290 $_FILES['full_file']['name'], $file);
00291 }
00292
00293 if ($_FILES['full_file']['name'] != "" ||
00294 ($_POST["full_size"] != "original" &&
00295 $_POST["full_resize"] == "y" &&
00296 is_int(strpos($format, "image")))
00297 )
00298 {
00299
00300 $format = ilObjMediaObject::getMimeType($file);
00301 $location = $_FILES['full_file']['name'];
00302
00303
00304 if ($_POST["full_size"] != "original" &&
00305 $_POST["full_resize"] == "y" &&
00306 is_int(strpos($format, "image")))
00307 {
00308 $location = ilObjMediaObject::_resizeImage($file, $_POST["full_width"],
00309 $_POST["full_height"]);
00310 }
00311 }
00312
00313 $media_item->setFormat($format);
00314 $media_item->setLocation($location);
00315 $media_item->setLocationType("LocalFile");
00316
00317
00318
00319
00320
00321
00322
00323 }
00324 else
00325 {
00326 if ($_POST["full_reference"] != "")
00327 {
00328 $format = ilObjMediaObject::getMimeType($_POST["full_reference"]);
00329 $media_item->setFormat($format);
00330 $media_item->setLocation($_POST["full_reference"]);
00331 $media_item->setLocationType("Reference");
00332
00333
00334
00335
00336 }
00337 }
00338
00339
00340 if ($_POST["full_size"] == "original")
00341 {
00342 if (ilUtil::deducibleSize($format))
00343 {
00344 $size = getimagesize($file);
00345 $media_item->setWidth($size[0]);
00346 $media_item->setHeight($size[1]);
00347 }
00348 }
00349 else
00350 {
00351 $media_item->setWidth($_POST["full_width"]);
00352 $media_item->setHeight($_POST["full_height"]);
00353 }
00354
00355 if ($_POST["full_caption"] != "")
00356 {
00357 $media_item->setCaption($_POST["full_caption"]);
00358 }
00359
00360 if ($_POST["full_param"] != "")
00361 {
00362 $media_item->setParameters(ilUtil::stripSlashes(utf8_decode($_POST["full_param"])));
00363 }
00364
00365 }
00366
00367 ilUtil::renameExecutables($mob_dir);
00368 $this->object->update();
00369
00370 return $this->object;
00371
00372 }
00373
00374 function cancelObject()
00375 {
00376 $this->ctrl->returnToParent($this);
00377 }
00378
00382 function editObject()
00383 {
00384
00385 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00386
00387
00388 $std_item =& $this->object->getMediaItem("Standard");
00389
00390
00391 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mob_properties.html", "content");
00392
00393
00394 if ($std_item->getLocationType() == "LocalFile" &&
00395 ilUtil::deducibleSize($std_item->getFormat()))
00396 {
00397 $this->tpl->setCurrentBlock("get_size");
00398 $this->tpl->setVariable("CMD_SIZE", "getStandardSize");
00399 $this->tpl->setVariable("TXT_GET_SIZE", $this->lng->txt("cont_get_orig_size"));
00400 $this->tpl->parseCurrentBlock();
00401
00402 }
00403
00404 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_mob_properties"));
00405 $this->tpl->setVariable("TXT_STANDARD_VIEW", $this->lng->txt("cont_std_view"));
00406
00407 $this->tpl->setVariable("TXT_FILE", $this->lng->txt("cont_LocalFile"));
00408 $this->tpl->setVariable("TXT_REFERENCE", $this->lng->txt("cont_Reference"));
00409 $this->tpl->setVariable("TXT_REF_HELPTEXT", $this->lng->txt("cont_ref_helptext"));
00410 if ($std_item->getLocationType() == "LocalFile")
00411 {
00412 $this->tpl->setVariable("FILE_CHECKED", "checked=\"1\"");
00413 $this->tpl->setVariable("VAL_FILE", $std_item->getLocation());
00414 }
00415 else
00416 {
00417 $this->tpl->setVariable("REF_CHECKED", "checked=\"1\"");
00418 $this->tpl->setVariable("VAL_REFERENCE", $std_item->getLocation());
00419 }
00420
00421 $this->tpl->setVariable("TXT_FORMAT", $this->lng->txt("cont_format"));
00422 $this->tpl->setVariable("VAL_FORMAT", $std_item->getFormat());
00423 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00424
00425
00426 $this->tpl->setVariable("TXT_MOB_WIDTH", $this->lng->txt("cont_width"));
00427 $this->tpl->setVariable("INPUT_MOB_WIDTH", "mob_width");
00428 $this->tpl->setVariable("VAL_MOB_WIDTH", $std_item->getWidth());
00429
00430
00431 $this->tpl->setVariable("TXT_MOB_HEIGHT", $this->lng->txt("cont_height"));
00432 $this->tpl->setVariable("INPUT_MOB_HEIGHT", "mob_height");
00433 $this->tpl->setVariable("VAL_MOB_HEIGHT", $std_item->getHeight());
00434
00435
00436 if ($orig_size = $std_item->getOriginalSize())
00437 {
00438 $this->tpl->setCurrentBlock("orig_size");
00439 $this->tpl->setVariable("TXT_ORIGINAL_SIZE", $this->lng->txt("cont_orig_size"));
00440 $this->tpl->setVariable("VAL_ORIG_WIDTH", $orig_size["width"]);
00441 $this->tpl->setVariable("VAL_ORIG_HEIGHT", $orig_size["height"]);
00442 $this->tpl->parseCurrentBlock();
00443 }
00444
00445
00446 $this->tpl->setVariable("TXT_CAPTION", $this->lng->txt("cont_caption"));
00447 $this->tpl->setVariable("INPUT_CAPTION", "mob_caption");
00448 $this->tpl->setVariable("VAL_CAPTION", $std_item->getCaption());
00449 $this->tpl->parseCurrentBlock();
00450
00451
00452 $this->tpl->setVariable("TXT_PARAMETER", $this->lng->txt("cont_parameter"));
00453 $this->tpl->setVariable("INPUT_PARAMETERS", "mob_parameters");
00454 $this->tpl->setVariable("VAL_PARAMETERS", $std_item->getParameterString());
00455 $this->tpl->parseCurrentBlock();
00456
00457
00458 if($this->object->hasFullScreenItem())
00459 {
00460 $full_item =& $this->object->getMediaItem("Fullscreen");
00461
00462 if ($full_item->getLocationType() == "LocalFile" &&
00463 ilUtil::deducibleSize($full_item->getFormat()))
00464 {
00465 $this->tpl->setCurrentBlock("get_full_size");
00466 $this->tpl->setVariable("CMD_FULL_SIZE", "getFullscreenSize");
00467 $this->tpl->setVariable("TXT_GET_FULL_SIZE", $this->lng->txt("cont_get_orig_size"));
00468 $this->tpl->parseCurrentBlock();
00469 }
00470
00471 $this->tpl->setCurrentBlock("fullscreen");
00472
00473
00474 $this->tpl->setVariable("TXT_FULLSCREEN_VIEW", $this->lng->txt("cont_fullscreen"));
00475
00476 $this->tpl->setVariable("TXT_FULL_FILE", $this->lng->txt("cont_LocalFile"));
00477 $this->tpl->setVariable("TXT_FULL_REFERENCE", $this->lng->txt("cont_Reference"));
00478 $this->tpl->setVariable("TXT_FULL_REF_HELPTEXT", $this->lng->txt("cont_ref_helptext"));
00479 if ($full_item->getLocationType() == "LocalFile")
00480 {
00481 $this->tpl->setVariable("FULL_FILE_CHECKED", "checked=\"1\"");
00482 $this->tpl->setVariable("VAL_FULL_FILE", $full_item->getLocation());
00483 }
00484 else
00485 {
00486 $this->tpl->setVariable("FULL_REF_CHECKED", "checked=\"1\"");
00487 $this->tpl->setVariable("VAL_FULL_REFERENCE", $full_item->getLocation());
00488 }
00489
00490
00491
00492 $this->tpl->setVariable("TXT_FULL_FORMAT", $this->lng->txt("cont_format"));
00493 $this->tpl->setVariable("VAL_FULL_FORMAT", $full_item->getFormat());
00494
00495
00496 $this->tpl->setVariable("TXT_FULL_WIDTH", $this->lng->txt("cont_width"));
00497 $this->tpl->setVariable("INPUT_FULL_WIDTH", "full_width");
00498 $this->tpl->setVariable("VAL_FULL_WIDTH", $full_item->getWidth());
00499
00500
00501 $this->tpl->setVariable("TXT_FULL_HEIGHT", $this->lng->txt("cont_height"));
00502 $this->tpl->setVariable("INPUT_FULL_HEIGHT", "full_height");
00503 $this->tpl->setVariable("VAL_FULL_HEIGHT", $full_item->getHeight());
00504
00505
00506 if ($orig_size = $full_item->getOriginalSize())
00507 {
00508 $this->tpl->setCurrentBlock("orig_full_size");
00509 $this->tpl->setVariable("TXT_ORIGINAL_SIZE", $this->lng->txt("cont_orig_size"));
00510 $this->tpl->setVariable("VAL_ORIG_WIDTH", $orig_size["width"]);
00511 $this->tpl->setVariable("VAL_ORIG_HEIGHT", $orig_size["height"]);
00512 $this->tpl->parseCurrentBlock();
00513 }
00514
00515
00516 $this->tpl->setVariable("TXT_FULL_CAPTION", $this->lng->txt("cont_caption"));
00517 $this->tpl->setVariable("INPUT_FULL_CAPTION", "full_caption");
00518 $this->tpl->setVariable("VAL_FULL_CAPTION", $full_item->getCaption());
00519
00520
00521 $this->tpl->setVariable("TXT_FULL_PARAMETER", $this->lng->txt("cont_parameter"));
00522 $this->tpl->setVariable("INPUT_FULL_PARAMETERS", "full_parameters");
00523 $this->tpl->setVariable("VAL_FULL_PARAMETERS", $full_item->getParameterString());
00524
00525 $this->tpl->parseCurrentBlock();
00526 }
00527
00528
00529 if($this->object->hasFullScreenItem())
00530 {
00531 $this->tpl->setCurrentBlock("remove_full");
00532 $this->tpl->setVariable("CMD_REMOVE_FULL", "removeFullscreen");
00533 $this->tpl->setVariable("TXT_REMOVE_FULL", $this->lng->txt("cont_remove_fullscreen"));
00534 $this->tpl->parseCurrentBlock();
00535 }
00536 else
00537 {
00538 $this->tpl->setCurrentBlock("add_full");
00539 $this->tpl->setVariable("CMD_ADD_FULL", "addFullscreen");
00540 $this->tpl->setVariable("TXT_ADD_FULL", $this->lng->txt("cont_add_fullscreen"));
00541 $this->tpl->parseCurrentBlock();
00542 }
00543 $this->tpl->setCurrentBlock("commands");
00544
00545 $this->tpl->setVariable("BTN_RESIZE", "resizeImages");
00546 $this->tpl->setVariable("TXT_RESIZE", $this->lng->txt("cont_resize_image")." [*]");
00547 $this->tpl->setVariable("BTN_NAME", "saveProperties");
00548 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00549 $this->tpl->parseCurrentBlock();
00550
00551 $this->tpl->setVariable("TXT_RESIZE_EXPLANATION",
00552 $this->lng->txt("cont_resize_explanation2"));
00553 }
00554
00555
00559 function resizeImagesObject()
00560 {
00561
00562 $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
00563
00564
00565 $std_item =& $this->object->getMediaItem("Standard");
00566 if ($std_item->getLocationType() == "LocalFile" &&
00567 is_int(strpos($std_item->getFormat(), "image"))
00568 )
00569 {
00570 $file = $mob_dir."/".$std_item->getLocation();
00571 $location = ilObjMediaObject::_resizeImage($file, $std_item->getWidth(),
00572 $std_item->getHeight());
00573 $std_item->setLocation($location);
00574 $std_item->update();
00575 }
00576
00577
00578 if($this->object->hasFullScreenItem())
00579 {
00580 $full_item =& $this->object->getMediaItem("Fullscreen");
00581 if ($full_item->getLocationType() == "LocalFile" &&
00582 is_int(strpos($full_item->getFormat(), "image"))
00583 )
00584 {
00585 $file = $mob_dir."/".$full_item->getLocation();
00586 $location = ilObjMediaObject::_resizeImage($file, $full_item->getWidth(),
00587 $full_item->getHeight());
00588 $full_item->setLocation($location);
00589 $full_item->update();
00590 }
00591 }
00592
00593 $this->ctrl->redirect($this, "edit");
00594 }
00595
00596
00600 function getStandardSizeObject()
00601 {
00602 $std_item =& $this->object->getMediaItem("Standard");
00603 $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
00604
00605 if ($std_item->getLocationType() == "LocalFile")
00606 {
00607 $file = $mob_dir."/".$std_item->getLocation();
00608 $size = getimagesize($file);
00609 $std_item->setWidth($size[0]);
00610 $std_item->setHeight($size[1]);
00611 $this->object->update();
00612 }
00613 $this->ctrl->redirect($this, "edit");
00614 }
00615
00616
00620 function getFullscreenSizeObject()
00621 {
00622 $full_item =& $this->object->getMediaItem("Fullscreen");
00623 $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
00624
00625 if ($full_item->getLocationType() == "LocalFile")
00626 {
00627 $file = $mob_dir."/".$full_item->getLocation();
00628 $size = getimagesize($file);
00629 $full_item->setWidth($size[0]);
00630 $full_item->setHeight($size[1]);
00631 $this->object->update();
00632 }
00633 $this->ctrl->redirect($this, "edit");
00634 }
00635
00639 function savePropertiesObject()
00640 {
00641 $std_item =& $this->object->getMediaItem("Standard");
00642 if ($_POST["standard_type"] == "Reference")
00643 {
00644 $std_item->setLocationType("Reference");
00645 $std_item->setFormat(ilObjMediaObject::getMimeType($_POST["standard_reference"]));
00646 $std_item->setLocation($_POST["standard_reference"]);
00647 }
00648 if ($_POST["standard_type"] == "LocalFile")
00649 {
00650 if ($_FILES['standard_file']['name'] != "")
00651 {
00652 $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
00653 $file = $mob_dir."/".$_FILES['standard_file']['name'];
00654
00655 ilUtil::moveUploadedFile($_FILES['standard_file']['tmp_name'],
00656 $_FILES['standard_file']['name'], $file);
00657
00658 $format = ilObjMediaObject::getMimeType($file);
00659 $std_item->setFormat($format);
00660 $std_item->setLocation($_FILES['standard_file']['name']);
00661 }
00662 $std_item->setLocationType("LocalFile");
00663 }
00664 $std_item->setWidth($_POST["mob_width"]);
00665 $std_item->setHeight($_POST["mob_height"]);
00666 $std_item->setCaption($_POST["mob_caption"]);
00667 $std_item->setParameters(ilUtil::stripSlashes(utf8_decode($_POST["mob_parameters"])));
00668
00669 if($this->object->hasFullscreenItem())
00670 {
00671 $full_item =& $this->object->getMediaItem("Fullscreen");
00672 if ($_POST["full_type"] == "Reference")
00673 {
00674 $full_item->setLocationType("Reference");
00675 $full_item->setFormat(ilObjMediaObject::getMimeType($_POST["full_reference"]));
00676 $full_item->setLocation($_POST["full_reference"]);
00677 }
00678 if ($_POST["full_type"] == "LocalFile")
00679 {
00680 if ($_FILES['full_file']['name'] != "")
00681 {
00682 $mob_dir = ilObjMediaObject::_getDirectory($this->object->getId());
00683 $file = $mob_dir."/".$_FILES['full_file']['name'];
00684
00685 ilUtil::moveUploadedFile($_FILES['full_file']['tmp_name'],
00686 $_FILES['full_file']['name'], $file);
00687
00688 $format = ilObjMediaObject::getMimeType($file);
00689 $full_item->setFormat($format);
00690 $full_item->setLocation($_FILES['full_file']['name']);
00691 }
00692 $full_item->setLocationType("LocalFile");
00693 }
00694 $full_item->setWidth($_POST["full_width"]);
00695 $full_item->setHeight($_POST["full_height"]);
00696 $full_item->setCaption($_POST["full_caption"]);
00697 $full_item->setParameters(ilUtil::stripSlashes(utf8_decode($_POST["full_parameters"])));
00698 }
00699
00700 $this->object->update();
00701
00702 $this->ctrl->redirect($this, "edit");
00703 }
00704
00705
00709 function editFilesObject()
00710 {
00711
00712 $std_item =& $this->object->getMediaItem("Standard");
00713 if($this->object->hasFullscreenItem())
00714 {
00715 $full_item =& $this->object->getMediaItem("Fullscreen");
00716 }
00717
00718
00719 require_once("classes/class.ilTableGUI.php");
00720 $tbl = new ilTableGUI();
00721
00722
00723 $cur_subdir = $_GET["cdir"];
00724 if($_GET["newdir"] == "..")
00725 {
00726 $cur_subdir = substr($cur_subdir, 0, strrpos($cur_subdir, "/"));
00727 }
00728 else
00729 {
00730 if (!empty($_GET["newdir"]))
00731 {
00732 if (!empty($cur_subdir))
00733 {
00734 $cur_subdir = $cur_subdir."/".$_GET["newdir"];
00735 }
00736 else
00737 {
00738 $cur_subdir = $_GET["newdir"];
00739 }
00740 }
00741 }
00742
00743 $cur_subdir = str_replace(".", "", $cur_subdir);
00744 $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
00745 $cur_dir = (!empty($cur_subdir))
00746 ? $mob_dir."/".$cur_subdir
00747 : $mob_dir;
00748
00749
00750 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.mob_files.html", "content");
00751
00752
00753
00754
00755 $this->ctrl->setParameter($this, "cdir", urlencode($cur_subdir));
00756 $this->tpl->setVariable("FORMACTION1", $this->ctrl->getFormAction($this));
00757
00758
00759 $this->tpl->setVariable("TXT_NEW_DIRECTORY", $this->lng->txt("cont_new_dir"));
00760 $this->tpl->setVariable("TXT_NEW_FILE", $this->lng->txt("cont_new_file"));
00761 $this->tpl->setVariable("CMD_NEW_DIR", "createDirectory");
00762 $this->tpl->setVariable("CMD_NEW_FILE", "uploadFile");
00763 $this->tpl->setVariable("BTN_NEW_DIR", $this->lng->txt("create"));
00764 $this->tpl->setVariable("BTN_NEW_FILE", $this->lng->txt("upload"));
00765
00766
00767 $this->tpl->addBlockfile("FILE_TABLE", "files", "tpl.table.html");
00768
00769
00770 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.mob_file_row.html", "content");
00771
00772 $num = 0;
00773
00774 $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
00775 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00776
00777 $tbl->setTitle($this->lng->txt("cont_files")." ".$cur_subdir);
00778
00779
00780 $tbl->setHeaderNames(array("", "", $this->lng->txt("cont_dir_file"),
00781 $this->lng->txt("cont_size"), $this->lng->txt("cont_purpose")));
00782
00783 $cols = array("", "", "dir_file", "size", "purpose");
00784 $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"],
00785 "cmd" => "editFiles", "hier_id" => $_GET["hier_id"]);
00786 $tbl->setHeaderVars($cols, $header_params);
00787 $tbl->setColumnWidth(array("1%", "1%", "33%", "33%", "32%"));
00788
00789
00790 $tbl->setOrderColumn($_GET["sort_by"]);
00791 $tbl->setOrderDirection($_GET["sort_order"]);
00792 $tbl->setLimit($_GET["limit"]);
00793 $tbl->setOffset($_GET["offset"]);
00794 $tbl->setMaxCount($this->maxcount);
00795
00796
00797 $this->tpl->setVariable("COLUMN_COUNTS", 5);
00798
00799
00800 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00801 $this->tpl->setCurrentBlock("tbl_action_btn");
00802 $this->tpl->setVariable("BTN_NAME", "deleteFile");
00803 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
00804 $this->tpl->parseCurrentBlock();
00805
00806 $this->tpl->setCurrentBlock("tbl_action_btn");
00807 $this->tpl->setVariable("BTN_NAME", "assignStandard");
00808 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("cont_assign_std"));
00809 $this->tpl->parseCurrentBlock();
00810
00811 $this->tpl->setCurrentBlock("tbl_action_btn");
00812 $this->tpl->setVariable("BTN_NAME", "assignFullscreen");
00813 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("cont_assign_full"));
00814 $this->tpl->parseCurrentBlock();
00815
00816
00817 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00818
00819
00820
00821
00822
00823 $entries = ilUtil::getDir($cur_dir);
00824
00825
00826 $tbl->setMaxCount(count($entries));
00827 $entries = array_slice($entries, $_GET["offset"], $_GET["limit"]);
00828
00829 $tbl->render();
00830 if(count($entries) > 0)
00831 {
00832 $i=0;
00833 foreach($entries as $entry)
00834 {
00835 if(($entry["entry"] == ".") || ($entry["entry"] == ".." && empty($cur_subdir)))
00836 {
00837 continue;
00838 }
00839
00840
00841 if($entry["type"] == "dir")
00842 {
00843 $this->tpl->setCurrentBlock("FileLink");
00844 $this->ctrl->setParameter($this, "cdir", $cur_subdir);
00845 $this->ctrl->setParameter($this, "newdir", rawurlencode($entry["entry"]));
00846 $this->tpl->setVariable("LINK_FILENAME", $this->ctrl->getLinkTarget($this, "editFiles"));
00847 $this->tpl->setVariable("TXT_FILENAME", $entry["entry"]);
00848 $this->tpl->parseCurrentBlock();
00849
00850 $this->tpl->setVariable("ICON", "<img src=\"".
00851 ilUtil::getImagePath("icon_cat.gif")."\">");
00852 }
00853 else
00854 {
00855 $this->tpl->setCurrentBlock("File");
00856 $this->tpl->setVariable("TXT_FILENAME2", $entry["entry"]);
00857 $this->tpl->parseCurrentBlock();
00858 }
00859
00860 $this->tpl->setCurrentBlock("tbl_content");
00861 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
00862 $this->tpl->setVariable("CSS_ROW", $css_row);
00863
00864 $this->tpl->setVariable("TXT_SIZE", $entry["size"]);
00865 $this->tpl->setVariable("CHECKBOX_ID", $entry["entry"]);
00866 $compare = (!empty($cur_subdir))
00867 ? $cur_subdir."/".$entry["entry"]
00868 : $entry["entry"];
00869 $purpose = array();
00870 if ($std_item->getLocation() == $compare)
00871 {
00872 $purpose[] = $this->lng->txt("cont_std_view");
00873 }
00874 if($this->object->hasFullscreenItem())
00875 {
00876 if ($full_item->getLocation() == $compare)
00877 {
00878 $purpose[] = $this->lng->txt("cont_fullscreen");
00879 }
00880 }
00881 $this->tpl->setVariable("TXT_PURPOSE", implode($purpose, ", "));
00882
00883 $this->tpl->parseCurrentBlock();
00884 }
00885 }
00886 else
00887 {
00888 $this->tpl->setCurrentBlock("notfound");
00889 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
00890 $this->tpl->setVariable("NUM_COLS", 4);
00891 $this->tpl->parseCurrentBlock();
00892 }
00893
00894 $this->tpl->parseCurrentBlock();
00895 }
00896
00897
00901 function createDirectoryObject()
00902 {
00903
00904
00905 $cur_subdir = str_replace(".", "", $_GET["cdir"]);
00906 $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
00907 $cur_dir = (!empty($cur_subdir))
00908 ? $mob_dir."/".$cur_subdir
00909 : $mob_dir;
00910
00911 $new_dir = str_replace(".", "", $_POST["new_dir"]);
00912 $new_dir = str_replace("/", "", $new_dir);
00913
00914 if (!empty($new_dir))
00915 {
00916 ilUtil::makeDir($cur_dir."/".$new_dir);
00917 }
00918 $this->ctrl->saveParameter($this, "cdir");
00919 $this->ctrl->redirect($this, "editFiles");
00920 }
00921
00925 function uploadFileObject()
00926 {
00927
00928 $cur_subdir = str_replace(".", "", $_GET["cdir"]);
00929 $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
00930 $cur_dir = (!empty($cur_subdir))
00931 ? $mob_dir."/".$cur_subdir
00932 : $mob_dir;
00933 if (is_file($_FILES["new_file"]["tmp_name"]))
00934 {
00935
00936
00937 $file = $cur_dir."/".$_FILES["new_file"]["name"];
00938 ilUtil::moveUploadedFile($_FILES['new_file']['tmp_name'],
00939 $_FILES['new_file']['name'], $file);
00940
00941 }
00942 ilUtil::renameExecutables($mob_dir);
00943 $this->ctrl->saveParameter($this, "cdir");
00944 $this->ctrl->redirect($this, "editFiles");
00945 }
00946
00950 function assignStandardObject()
00951 {
00952 if (!isset($_POST["file"]))
00953 {
00954 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00955 }
00956
00957 if (count($_POST["file"]) > 1)
00958 {
00959 $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
00960 }
00961
00962
00963 $cur_subdir = str_replace(".", "", $_GET["cdir"]);
00964 $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
00965 $cur_dir = (!empty($cur_subdir))
00966 ? $mob_dir."/".$cur_subdir
00967 : $mob_dir;
00968 $file = $cur_dir."/".$_POST["file"][0];
00969 $location = (!empty($cur_subdir))
00970 ? $cur_subdir."/".$_POST["file"][0]
00971 : $_POST["file"][0];
00972
00973 if(!is_file($file))
00974 {
00975 $this->ilias->raiseError($this->lng->txt("cont_select_file"),$this->ilias->error_obj->MESSAGE);
00976 }
00977
00978 $std_item =& $this->object->getMediaItem("Standard");
00979 $std_item->setLocationType("LocalFile");
00980 $std_item->setLocation($location);
00981 $format = ilObjMediaObject::getMimeType($file);
00982 $std_item->setFormat($format);
00983 $this->object->update();
00984 $this->ctrl->saveParameter($this, "cdir");
00985 $this->ctrl->redirect($this, "editFiles");
00986
00987 $this->ctrl->saveParameter($this, "cdir");
00988 $this->ctrl->redirect($this, "editFiles");
00989 }
00990
00991
00995 function assignFullscreenObject()
00996 {
00997 if (!isset($_POST["file"]))
00998 {
00999 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01000 }
01001
01002 if (count($_POST["file"]) > 1)
01003 {
01004 $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
01005 }
01006
01007
01008 $cur_subdir = str_replace(".", "", $_GET["cdir"]);
01009 $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
01010 $cur_dir = (!empty($cur_subdir))
01011 ? $mob_dir."/".$cur_subdir
01012 : $mob_dir;
01013 $file = $cur_dir."/".$_POST["file"][0];
01014 $location = (!empty($cur_subdir))
01015 ? $cur_subdir."/".$_POST["file"][0]
01016 : $_POST["file"][0];
01017
01018 if(!is_file($file))
01019 {
01020 $this->ilias->raiseError($this->lng->txt("cont_select_file"),$this->ilias->error_obj->MESSAGE);
01021 }
01022
01023 if(!$this->object->hasFullScreenItem())
01024 {
01025 $std_item =& $this->object->getMediaItem("Standard");
01026 $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
01027 $file = $mob_dir."/".$location;
01028 $full_item =& new ilMediaItem();
01029 $full_item->setMobId($std_item->getMobId());
01030 $full_item->setLocation($location);
01031 $full_item->setLocationType("LocalFile");
01032 $full_item->setFormat(ilObjMediaObject::getMimeType($file));
01033 $full_item->setPurpose("Fullscreen");
01034 $this->object->addMediaItem($full_item);
01035 }
01036 else
01037 {
01038 $full_item =& $this->object->getMediaItem("Fullscreen");
01039
01040 $full_item->setLocationType("LocalFile");
01041 $full_item->setLocation($location);
01042 $format = ilObjMediaObject::getMimeType($file);
01043 $full_item->setFormat($format);
01044 }
01045 $this->object->update();
01046 $this->ctrl->saveParameter($this, "cdir");
01047 $this->ctrl->redirect($this, "editFiles");
01048 }
01049
01050
01054 function removeFullscreenObject()
01055 {
01056 $this->object->removeMediaItem("Fullscreen");
01057 $this->object->update();
01058
01059 $this->ctrl->redirect($this, "edit");
01060 }
01061
01062
01066 function addFullscreenObject()
01067 {
01068 if (!$this->object->hasFullScreenItem())
01069 {
01070 $std_item =& $this->object->getMediaItem("Standard");
01071 $full_item =& new ilMediaItem();
01072 $full_item->setMobId($std_item->getMobId());
01073 $full_item->setLocation($std_item->getLocation());
01074 $full_item->setLocationType($std_item->getLocationType());
01075 $full_item->setFormat($std_item->getFormat());
01076 $full_item->setWidth($std_item->getWidth());
01077 $full_item->setHeight($std_item->getHeight());
01078 $full_item->setCaption($std_item->getCaption());
01079 $full_item->setPurpose("Fullscreen");
01080 $this->object->addMediaItem($full_item);
01081
01082 $this->object->update();
01083 }
01084
01085 $this->ctrl->redirect($this, "edit");
01086 }
01087
01088
01092 function deleteFileObject()
01093 {
01094 if (!isset($_POST["file"]))
01095 {
01096 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01097 }
01098
01099 if (count($_POST["file"]) > 1)
01100 {
01101 $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
01102 }
01103
01104 if ($_POST["file"][0] == "..")
01105 {
01106 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
01107 }
01108
01109 $cur_subdir = str_replace(".", "", $_GET["cdir"]);
01110 $mob_dir = ilUtil::getWebspaceDir()."/mobs/mm_".$this->object->getId();
01111 $cur_dir = (!empty($cur_subdir))
01112 ? $mob_dir."/".$cur_subdir
01113 : $mob_dir;
01114 $file = $cur_dir."/".$_POST["file"][0];
01115 $location = (!empty($cur_subdir))
01116 ? $cur_subdir."/".$_POST["file"][0]
01117 : $_POST["file"][0];
01118
01119 $full_item =& $this->object->getMediaItem("Fullscreen");
01120 $std_item =& $this->object->getMediaItem("Standard");
01121
01122 if ($location == $std_item->getLocation())
01123 {
01124 $this->ilias->raiseError($this->lng->txt("cont_cant_del_std"),$this->ilias->error_obj->MESSAGE);
01125 }
01126
01127 if($this->object->hasFullScreenItem())
01128 {
01129 if ($location == $full_item->getLocation())
01130 {
01131 $this->ilias->raiseError($this->lng->txt("cont_cant_del_full"),$this->ilias->error_obj->MESSAGE);
01132 }
01133 }
01134
01135 if (@is_dir($file))
01136 {
01137 if (substr($std_item->getLocation(), 0 ,strlen($location)) == $location)
01138 {
01139 $this->ilias->raiseError($this->lng->txt("cont_std_is_in_dir"),$this->ilias->error_obj->MESSAGE);
01140 }
01141
01142 if($this->object->hasFullScreenItem())
01143 {
01144 if (substr($full_item->getLocation(), 0 ,strlen($location)) == $location)
01145 {
01146 $this->ilias->raiseError($this->lng->txt("cont_full_is_in_dir"),$this->ilias->error_obj->MESSAGE);
01147 }
01148 }
01149 }
01150
01151 if (@is_file($file))
01152 {
01153 unlink($file);
01154 }
01155
01156 if (@is_dir($file))
01157 {
01158 ilUtil::delDir($file);
01159 }
01160
01161 $this->ctrl->saveParameter($this, "cdir");
01162 $this->ctrl->redirect($this, "editFiles");
01163 }
01164
01165
01169 function showUsagesObject()
01170 {
01171
01172 require_once("classes/class.ilTableGUI.php");
01173 $tbl = new ilTableGUI();
01174
01175 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
01176
01177
01178 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.mob_usage_row.html", "content");
01179
01180 $num = 0;
01181
01182 $tbl->setTitle($this->lng->txt("cont_mob_usages"));
01183
01184
01185 $tbl->setHeaderNames(array($this->lng->txt("container"),
01186 $this->lng->txt("context")));
01187
01188 $cols = array("object", "context");
01189 $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"],
01190 "cmd" => "showUsages", "hier_id" => $_GET["hier_id"], "cmdClass" => "ilObjMediaObjectGUI");
01191 $tbl->setHeaderVars($cols, $header_params);
01192
01193
01194
01195 $tbl->setOrderColumn($_GET["sort_by"]);
01196 $tbl->setOrderDirection($_GET["sort_order"]);
01197 $tbl->setLimit($_GET["limit"]);
01198 $tbl->setOffset($_GET["offset"]);
01199 $tbl->setMaxCount($this->maxcount);
01200
01201
01202
01203
01204
01205 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
01206
01207
01208
01209
01210
01211
01212 $usages = $this->object->getUsages();
01213
01214
01215 $tbl->setMaxCount(count($usages));
01216 $usages = array_slice($usages, $_GET["offset"], $_GET["limit"]);
01217
01218 $tbl->render();
01219 if(count($usages) > 0)
01220 {
01221 $i=0;
01222 $clip_cnt = 0;
01223 foreach($usages as $usage)
01224 {
01225 if ($usage["type"] == "clip")
01226 {
01227 $clip_cnt++;
01228 continue;
01229 }
01230
01231 $this->tpl->setCurrentBlock("tbl_content");
01232
01233
01234 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
01235 $this->tpl->setVariable("CSS_ROW", $css_row);
01236
01237 if(is_int(strpos($usage["type"], ":")))
01238 {
01239 $us_arr = explode(":", $usage["type"]);
01240 $usage["type"] = $us_arr[1];
01241 $cont_type = $us_arr[0];
01242 }
01243
01244 switch($usage["type"])
01245 {
01246 case "pg":
01247
01248 require_once("content/classes/Pages/class.ilPageObject.php");
01249 $page_obj = new ilPageObject($cont_type, $usage["id"]);
01250
01251
01252 switch ($cont_type)
01253 {
01254 case "lm":
01255 case "dbk":
01256 require_once("content/classes/class.ilObjContentObject.php");
01257 require_once("content/classes/class.ilLMObject.php");
01258 $lm_obj =& new ilObjContentObject($page_obj->getParentId(), false);
01259 $this->tpl->setVariable("TXT_OBJECT", $this->lng->txt("obj_".$cont_type).
01260 ": ".$lm_obj->getTitle().", ".$this->lng->txt("page").": ".
01261 ilLMObject::_lookupTitle($page_obj->getId()));
01262 break;
01263 }
01264 break;
01265
01266 case "mep":
01267 $this->tpl->setVariable("TXT_OBJECT", $this->lng->txt("obj_mep").
01268 ": ".ilObject::_lookupTitle($usage["id"]));
01269 break;
01270
01271 case "map":
01272 $this->tpl->setVariable("TXT_OBJECT", $this->lng->txt("obj_mob").
01273 " (".$this->lng->txt("cont_link_area")."): ".
01274 ilObject::_lookupTitle($usage["id"]));
01275 break;
01276
01277 }
01278
01279
01280 $this->tpl->setVariable("TXT_CONTEXT", "-");
01281
01282 $this->tpl->parseCurrentBlock();
01283 }
01284
01285
01286 if ($clip_cnt > 0)
01287 {
01288 $this->tpl->setCurrentBlock("tbl_content");
01289
01290
01291 $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
01292 $this->tpl->setVariable("CSS_ROW", $css_row);
01293 $this->tpl->setVariable("TXT_OBJECT", $this->lng->txt("cont_users_have_mob_in_clip1").
01294 " ".$clip_cnt." ".$this->lng->txt("cont_users_have_mob_in_clip2"));
01295 $this->tpl->setVariable("TXT_CONTEXT", "-");
01296
01297 $this->tpl->parseCurrentBlock();
01298
01299 }
01300
01301
01302 }
01303 else
01304 {
01305 $this->tpl->setCurrentBlock("notfound");
01306 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
01307 $this->tpl->setVariable("NUM_COLS", 4);
01308 $this->tpl->parseCurrentBlock();
01309 }
01310
01311 $this->tpl->parseCurrentBlock();
01312 }
01313
01314
01318 function editMapAreasObject()
01319 {
01320 $_SESSION["il_map_edit_target_script"] = $this->ctrl->getLinkTarget($this, "addArea");
01321
01322
01323 $this->handleMapParameters();
01324
01325 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.map_edit.html", "content");
01326
01327 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01328
01329 $this->tpl->setVariable("TXT_IMAGEMAP", $this->lng->txt("cont_imagemap"));
01330
01331
01332 $st_item =& $this->object->getMediaItem("Standard");
01333 $st_item->makeMapWorkCopy();
01334
01335
01336 $xml = "<dummy>";
01337 $xml.= $this->object->getXML(IL_MODE_ALIAS);
01338 $xml.= $this->object->getXML(IL_MODE_OUTPUT);
01339 $xml.="</dummy>";
01340
01341 $xsl = file_get_contents("./content/page.xsl");
01342 $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
01343 $xh = xslt_create();
01344 $wb_path = ilUtil::getWebspaceDir("output");
01345 $mode = "media";
01346 $params = array ('map_item' => $st_item->getId(),
01347 'mode' => $mode,
01348 'link_params' => "ref_id=".$_GET["ref_id"]."&rand=".rand(1,999999),
01349 'ref_id' => $_GET["ref_id"],
01350 'pg_frame' => "",
01351 'image_map_link' => $this->ctrl->getLinkTarget($this, "showImageMap"),
01352 'webspace_path' => $wb_path);
01353 $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
01354
01355 echo xslt_error($xh);
01356 xslt_free($xh);
01357 $this->tpl->setVariable("IMAGE_MAP", $output);
01358
01359 $this->tpl->setCurrentBlock("area_table");
01360
01361
01362 $this->tpl->setVariable("TXT_NAME", $this->lng->txt("cont_name"));
01363 $this->tpl->setVariable("TXT_SHAPE", $this->lng->txt("cont_shape"));
01364 $this->tpl->setVariable("TXT_COORDS", $this->lng->txt("cont_coords"));
01365 $this->tpl->setVariable("TXT_LINK", $this->lng->txt("cont_link"));
01366
01367
01368 $this->tpl->setCurrentBlock("commands");
01369 $sel_arr = array("Rect" => $this->lng->txt("cont_Rect"),
01370 "Circle" => $this->lng->txt("cont_Circle"),
01371 "Poly" => $this->lng->txt("cont_Poly"));
01372 $sel_str = ilUtil::formSelect("", "areatype", $sel_arr, false, true);
01373 $sel_str2 = ilUtil::formSelect("", "areatype2", $sel_arr, false, true);
01374 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
01375 $this->tpl->setVariable("BTN_DELETE", "deleteAreas");
01376 $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
01377 $this->tpl->setVariable("SELECT_TYPE", $sel_str);
01378 $this->tpl->setVariable("SELECT_TYPE2", $sel_str2);
01379 $this->tpl->setVariable("BTN_UPDATE", "updateAreas");
01380 $this->tpl->setVariable("TXT_UPDATE", $this->lng->txt("cont_update_names"));
01381 $this->tpl->setVariable("BTN_ADD_AREA", "newArea");
01382 $this->tpl->setVariable("TXT_ADD_AREA", $this->lng->txt("cont_add_area"));
01383 $this->tpl->setVariable("BTN_SET_LINK", "editLink");
01384 $this->tpl->setVariable("TXT_SET_LINK", $this->lng->txt("cont_set_link"));
01385 $this->tpl->setVariable("BTN_SET_SHAPE", "editShape");
01386 $this->tpl->setVariable("TXT_SET_SHAPE", $this->lng->txt("cont_set_shape"));
01387 $this->tpl->parseCurrentBlock();
01388
01389
01390 $st_item =& $this->object->getMediaItem("Standard");
01391 $max = ilMapArea::_getMaxNr($st_item->getId());
01392 for ($i=1; $i<=$max; $i++)
01393 {
01394 $this->tpl->setCurrentBlock("area_row");
01395
01396 $css_row = ilUtil::switchColor($i, "tblrow1", "tblrow2");
01397 $this->tpl->setVariable("CSS_ROW", $css_row);
01398
01399 $area =& new ilMapArea($st_item->getId(), $i);
01400 $this->tpl->setVariable("CHECKBOX",
01401 ilUtil::formCheckBox("", "area[]", $i));
01402 $this->tpl->setVariable("VAR_NAME", "name_".$i);
01403 $this->tpl->setVariable("VAL_NAME", $area->getTitle());
01404 $this->tpl->setVariable("VAL_SHAPE", $area->getShape());
01405 $this->tpl->setVariable("VAL_COORDS",
01406 implode(explode(",", $area->getCoords()), ", "));
01407 switch ($area->getLinkType())
01408 {
01409 case "ext":
01410 $this->tpl->setVariable("VAL_LINK", $area->getHRef());
01411 break;
01412
01413 case "int":
01414 $link_str = $this->getMapAreaLinkString($area->getTarget(),
01415 $area->getType(), $area->getTargetFrame());
01416 $this->tpl->setVariable("VAL_LINK", $link_str);
01417 break;
01418 }
01419 $this->tpl->parseCurrentBlock();
01420 }
01421
01422 $this->tpl->parseCurrentBlock();
01423 }
01424
01428 function showImageMapObject()
01429 {
01430 $item =& new ilMediaItem($_GET["item_id"]);
01431 $item->outputMapWorkCopy();
01432 }
01433
01434
01435
01439 function handleMapParameters()
01440 {
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451 if($_GET["ref_id"] != "")
01452 {
01453 $_SESSION["il_map_edit_ref_id"] = $_GET["ref_id"];
01454 }
01455
01456 if($_GET["obj_id"] != "")
01457 {
01458 $_SESSION["il_map_edit_obj_id"] = $_GET["obj_id"];
01459 }
01460
01461 if($_GET["hier_id"] != "")
01462 {
01463 $_SESSION["il_map_edit_hier_id"] = $_GET["hier_id"];
01464 }
01465
01466
01467
01468
01469
01470
01471
01472 }
01473
01474
01478 function _recoverParameters()
01479 {
01480 $_GET["ref_id"] = $_SESSION["il_map_edit_ref_id"];
01481 $_GET["obj_id"] = $_SESSION["il_map_edit_obj_id"];
01482 $_GET["hier_id"] = $_SESSION["il_map_edit_hier_id"];
01483
01484
01485 }
01486
01487 function clearParameters()
01488 {
01489 $_SESSION["il_map_el_href"] = "";
01490 }
01491
01492
01496 function initMapParameters()
01497 {
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511 }
01512
01513 function newAreaObject()
01514 {
01515 $_SESSION["il_map_edit_coords"] = "";
01516 $_SESSION["il_map_edit_mode"] = "";
01517 $_SESSION["il_map_el_href"] = "";
01518 $_SESSION["il_map_il_type"] = "";
01519 $_SESSION["il_map_il_ltype"] = "";
01520 $_SESSION["il_map_il_target"] = "";
01521 $_SESSION["il_map_il_targetframe"] = "";
01522 $_SESSION["il_map_edit_area_type"] = $_POST["areatype"];
01523 $this->addAreaObject(false);
01524 }
01525
01529 function addAreaObject($a_handle = true)
01530 {
01531
01532
01533
01534
01535
01536
01537
01538
01539 if($a_handle)
01540 {
01541 $this->handleMapParameters();
01542 }
01543
01544 $area_type = $_SESSION["il_map_edit_area_type"];
01545 $coords = $_SESSION["il_map_edit_coords"];
01546 $cnt_coords = ilMapArea::countCoords($coords);
01547
01548
01549 switch ($area_type)
01550 {
01551
01552 case "Rect" :
01553 if ($cnt_coords < 2)
01554 {
01555 $this->editMapArea(true, false, false);
01556 }
01557 else if ($cnt_coords == 2)
01558 {
01559
01560 $this->editMapArea(false, true, true);
01561 }
01562 break;
01563
01564
01565 case "Circle":
01566
01567 if ($cnt_coords <= 1)
01568 {
01569 $this->editMapArea(true, false, false);
01570 }
01571 else
01572 {
01573 if ($cnt_coords == 2)
01574 {
01575 $c = explode(",",$coords);
01576 $coords = $c[0].",".$c[1].",";
01577 $coords .= round(sqrt(pow(abs($c[3]-$c[1]),2)+pow(abs($c[2]-$c[0]),2)));
01578 }
01579 $_SESSION["il_map_edit_coords"] = $coords;
01580
01581 $this->editMapArea(false, true, true);
01582 }
01583 break;
01584
01585
01586 case "Poly":
01587 if ($cnt_coords < 1)
01588 {
01589 $this->editMapArea(true, false, false);
01590 }
01591 else if ($cnt_coords < 3)
01592 {
01593 $this->editMapArea(true, true, false);
01594 }
01595 else
01596 {
01597 $this->editMapArea(true, true, true);
01598 }
01599 break;
01600 }
01601
01602 }
01603
01604
01613 function editMapArea($a_get_next_coordinate = false, $a_output_new_area = false,
01614 $a_save_form = false, $a_edit_property = "", $a_area_nr = 0)
01615 {
01616
01617 $area_type = $_SESSION["il_map_edit_area_type"];
01618
01619 $coords = $_SESSION["il_map_edit_coords"];
01620 $cnt_coords = ilMapArea::countCoords($coords);
01621
01622 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.map_edit.html", "content");
01623
01624 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01625
01626 $this->tpl->setVariable("TXT_IMAGEMAP", $this->lng->txt("cont_imagemap"));
01627
01628
01629
01630 $this->tpl->setCurrentBlock("instruction");
01631
01632
01633
01634 if ($a_edit_property != "link")
01635 {
01636 switch ($area_type)
01637 {
01638
01639 case "Rect" :
01640 if ($cnt_coords == 0)
01641 {
01642 $this->tpl->setVariable("INSTRUCTION", $this->lng->txt("cont_click_tl_corner"));
01643 }
01644 if ($cnt_coords == 1)
01645 {
01646 $this->tpl->setVariable("INSTRUCTION", $this->lng->txt("cont_click_br_corner"));
01647 }
01648 break;
01649
01650
01651 case "Circle" :
01652 if ($cnt_coords == 0)
01653 {
01654 $this->tpl->setVariable("INSTRUCTION", $this->lng->txt("cont_click_center"));
01655 }
01656 if ($cnt_coords == 1)
01657 {
01658 $this->tpl->setVariable("INSTRUCTION", $this->lng->txt("cont_click_circle"));
01659 }
01660 break;
01661
01662
01663 case "Poly" :
01664 if ($cnt_coords == 0)
01665 {
01666 $this->tpl->setVariable("INSTRUCTION", $this->lng->txt("cont_click_starting_point"));
01667 }
01668 else if ($cnt_coords < 3)
01669 {
01670 $this->tpl->setVariable("INSTRUCTION", $this->lng->txt("cont_click_next_point"));
01671 }
01672 else
01673 {
01674 $this->tpl->setVariable("INSTRUCTION", $this->lng->txt("cont_click_next_or_save"));
01675 }
01676 break;
01677 }
01678 }
01679 $this->tpl->parseCurrentBlock();
01680
01681 $this->tpl->setCurrentBlock("adm_content");
01682
01683
01684
01685 if ($a_save_form)
01686 {
01687 if ($a_edit_property != "link" && $a_edit_property != "shape")
01688 {
01689 $this->tpl->setCurrentBlock("edit_name");
01690 $this->tpl->setVariable("VAR_NAME2", "area_name");
01691 $this->tpl->setVariable("TXT_NAME2", $this->lng->txt("cont_name"));
01692 $this->tpl->parseCurrentBlock();
01693 }
01694
01695 if ($a_edit_property != "shape")
01696 {
01697 $this->tpl->setCurrentBlock("edit_link");
01698 $this->tpl->setVariable("TXT_LINK_EXT", $this->lng->txt("cont_link_ext"));
01699 $this->tpl->setVariable("TXT_LINK_INT", $this->lng->txt("cont_link_int"));
01700 if ($_SESSION["il_map_el_href"] != "")
01701 {
01702 $this->tpl->setVariable("VAL_LINK_EXT", $_SESSION["il_map_el_href"]);
01703 }
01704 else
01705 {
01706 $this->tpl->setVariable("VAL_LINK_EXT", "http://");
01707 }
01708 $this->tpl->setVariable("VAR_LINK_EXT", "area_link_ext");
01709 $this->tpl->setVariable("VAR_LINK_TYPE", "area_link_type");
01710 if ($_SESSION["il_map_il_ltype"] != "int")
01711 {
01712 $this->tpl->setVariable("EXT_CHECKED", "checked=\"1\"");
01713 }
01714 else
01715 {
01716 $this->tpl->setVariable("INT_CHECKED", "checked=\"1\"");
01717 }
01718
01719
01720 $link_str = "";
01721 if($_SESSION["il_map_il_target"] != "")
01722 {
01723 $link_str = $this->getMapAreaLinkString($_SESSION["il_map_il_target"],
01724 $_SESSION["il_map_il_type"], $_SESSION["il_map_il_targetframe"]);
01725 $this->tpl->setVariable("VAL_LINK_INT", $link_str);
01726 }
01727
01728
01729 $this->ctrl->setParameter($this, "linkmode", "map");
01730 $this->tpl->setVariable("LINK_ILINK",
01731 $this->ctrl->getLinkTargetByClass("ilInternalLinkGUI", "showLinkHelp",
01732 array("ilObjMediaObjectGUI"), true));
01733 $this->tpl->setVariable("TXT_ILINK", "[".$this->lng->txt("cont_get_link")."]");
01734
01735 $this->tpl->parseCurrentBlock();
01736 }
01737
01738 $this->tpl->setCurrentBlock("new_area");
01739 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
01740 $this->tpl->setVariable("BTN_SAVE", "saveArea");
01741 if ($a_edit_property == "")
01742 {
01743 $this->tpl->setVariable("TXT_NEW_AREA", $this->lng->txt("cont_new_area"));
01744 }
01745 else
01746 {
01747 $this->tpl->setVariable("TXT_NEW_AREA", $this->lng->txt("cont_edit_area"));
01748 }
01749 $this->tpl->parseCurrentBlock();
01750
01751 $this->tpl->setCurrentBlock("adm_content");
01752 }
01753
01754
01755 $st_item =& $this->object->getMediaItem("Standard");
01756
01757 if ($a_edit_property == "shape")
01758 {
01759 $st_item->makeMapWorkCopy($a_area_nr, true);
01760 }
01761 else
01762 {
01763 $st_item->makeMapWorkCopy($a_area_nr, false);
01764 }
01765
01766 if ($a_output_new_area)
01767 {
01768 $st_item->addAreaToMapWorkCopy($area_type, $coords);
01769 }
01770
01771
01772 $xml = "<dummy>";
01773 $xml.= $this->object->getXML(IL_MODE_ALIAS);
01774 $xml.= $this->object->getXML(IL_MODE_OUTPUT);
01775 $xml.="</dummy>";
01776
01777 $xsl = file_get_contents("./content/page.xsl");
01778 $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
01779 $xh = xslt_create();
01780 $wb_path = ilUtil::getWebspaceDir("output");
01781 $mode = "media";
01782 if ($a_get_next_coordinate)
01783 {
01784 $map_edit_mode = "get_coords";
01785 }
01786 else
01787 {
01788 $map_edit_mode = "";
01789 }
01790 $params = array ('map_edit_mode' => $map_edit_mode,
01791 'map_item' => $st_item->getId(),
01792 'mode' => $mode,
01793 'image_map_link' => $this->ctrl->getLinkTarget($this, "showImageMap"),
01794 'link_params' => "ref_id=".$_GET["ref_id"]."&rand=".rand(1,999999),
01795 'ref_id' => $_GET["ref_id"],
01796 'pg_frame' => "",
01797 'webspace_path' => $wb_path);
01798 $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
01799
01800 echo xslt_error($xh);
01801 xslt_free($xh);
01802 $this->tpl->setVariable("IMAGE_MAP", $output);
01803
01804 $this->tpl->parseCurrentBlock();
01805 }
01806
01807
01811 function editImagemapForwardObject()
01812 {
01813 ilObjMediaObjectGUI::_recoverParameters();
01814
01815 if ($_SESSION["il_map_edit_coords"] != "")
01816 {
01817 $_SESSION["il_map_edit_coords"] .= ",";
01818 }
01819
01820 $_SESSION["il_map_edit_coords"] .= $_POST["editImagemapForward_x"].",".
01821 $_POST["editImagemapForward_y"];
01822
01823
01824 ilUtil::redirect($_SESSION["il_map_edit_target_script"]);
01825 }
01826
01827
01833 function setInternalLinkObject()
01834 {
01835 $_SESSION["il_map_il_type"] = $_GET["linktype"];
01836 $_SESSION["il_map_il_ltype"] = "int";
01837
01838 $_SESSION["il_map_il_target"] = $_GET["linktarget"];
01839
01840 $_SESSION["il_map_il_targetframe"] = $_GET["linktargetframe"];
01841 switch ($_SESSION["il_map_edit_mode"])
01842 {
01843 case "edit_link":
01844 $this->setLink();
01845 break;
01846
01847 default:
01848
01849 $this->addAreaObject();
01850 break;
01851 }
01852 }
01853
01863 function getMapAreaLinkString($a_target, $a_type, $a_frame)
01864 {
01865 $t_arr = explode("_", $a_target);
01866 if ($a_frame != "")
01867 {
01868 $frame_str = " (".$a_frame." Frame)";
01869 }
01870 switch($a_type)
01871 {
01872 case "StructureObject":
01873 require_once("content/classes/class.ilLMObject.php");
01874 $title = ilLMObject::_lookupTitle($t_arr[count($t_arr) - 1]);
01875 $link_str = $this->lng->txt("chapter").
01876 ": ".$title." [".$t_arr[count($t_arr) - 1]."]".$frame_str;
01877 break;
01878
01879 case "PageObject":
01880 require_once("content/classes/class.ilLMObject.php");
01881 $title = ilLMObject::_lookupTitle($t_arr[count($t_arr) - 1]);
01882 $link_str = $this->lng->txt("page").
01883 ": ".$title." [".$t_arr[count($t_arr) - 1]."]".$frame_str;
01884 break;
01885
01886 case "GlossaryItem":
01887 require_once("content/classes/class.ilGlossaryTerm.php");
01888 $term =& new ilGlossaryTerm($t_arr[count($t_arr) - 1]);
01889 $link_str = $this->lng->txt("term").
01890 ": ".$term->getTerm()." [".$t_arr[count($t_arr) - 1]."]".$frame_str;
01891 break;
01892
01893 case "MediaObject":
01894 require_once("content/classes/Media/class.ilObjMediaObject.php");
01895 $mob =& new ilObjMediaObject($t_arr[count($t_arr) - 1]);
01896 $link_str = $this->lng->txt("mob").
01897 ": ".$mob->getTitle()." [".$t_arr[count($t_arr) - 1]."]".$frame_str;
01898 break;
01899
01900 case "RepositoryItem":
01901
01902 $title = ilObject::_lookupTitle(
01903 ilObject::_lookupObjId($t_arr[count($t_arr) - 1]));
01904 $link_str = $this->lng->txt("obj_".$t_arr[count($t_arr) - 2]).
01905 ": ".$title." [".$t_arr[count($t_arr) - 1]."]".$frame_str;
01906 break;
01907 }
01908
01909 return $link_str;
01910 }
01911
01915 function updateAreasObject()
01916 {
01917 $st_item =& $this->object->getMediaItem("Standard");
01918 $max = ilMapArea::_getMaxNr($st_item->getId());
01919 for ($i=1; $i<=$max; $i++)
01920 {
01921 $area =& new ilMapArea($st_item->getId(), $i);
01922 $area->setTitle(ilUtil::stripSlashes($_POST["name_".$i]));
01923 $area->update();
01924 }
01925
01926 sendInfo($this->lng->txt("cont_saved_map_data"), true);
01927 $this->ctrl->redirect($this, "editMapAreas");
01928 }
01929
01930
01934 function deleteAreasObject()
01935 {
01936 if (!isset($_POST["area"]))
01937 {
01938 sendInfo($this->lng->txt("no_checkbox"), true);
01939 $this->editMapAreasObject();
01940 return;
01941 }
01942
01943 $st_item =& $this->object->getMediaItem("Standard");
01944 $max = ilMapArea::_getMaxNr($st_item->getId());
01945
01946 if (count($_POST["area"]) > 0)
01947 {
01948 $i = 0;
01949
01950 foreach ($_POST["area"] as $area_nr)
01951 {
01952 $st_item->deleteMapArea($area_nr - $i);
01953 $i++;
01954 }
01955
01956 $this->object->update();
01957 sendInfo($this->lng->txt("cont_areas_deleted"), true);
01958 }
01959
01960 $this->ctrl->redirect($this, "editMapAreas");
01961 }
01962
01963
01967 function saveAreaObject()
01968 {
01969 switch ($_SESSION["il_map_edit_mode"])
01970 {
01971
01972 case "edit_link":
01973 $st_item =& $this->object->getMediaItem("Standard");
01974 $max = ilMapArea::_getMaxNr($st_item->getId());
01975 $area =& new ilMapArea($st_item->getId(), $_SESSION["il_map_area_nr"]);
01976
01977 if ($_POST["area_link_type"] == IL_INT_LINK)
01978 {
01979 $area->setLinkType(IL_INT_LINK);
01980 $area->setType($_SESSION["il_map_il_type"]);
01981 $area->setTarget($_SESSION["il_map_il_target"]);
01982 $area->setTargetFrame($_SESSION["il_map_il_targetframe"]);
01983 }
01984 else
01985 {
01986 $area->setLinkType(IL_EXT_LINK);
01987 $area->setHref($_POST["area_link_ext"]);
01988 }
01989 $area->update();
01990 break;
01991
01992
01993 case "edit_shape":
01994 $st_item =& $this->object->getMediaItem("Standard");
01995 $max = ilMapArea::_getMaxNr($st_item->getId());
01996 $area =& new ilMapArea($st_item->getId(), $_SESSION["il_map_area_nr"]);
01997
01998 $area->setShape($_SESSION["il_map_edit_area_type"]);
01999 $area->setCoords($_SESSION["il_map_edit_coords"]);
02000 $area->update();
02001 break;
02002
02003
02004 default:
02005 $area_type = $_SESSION["il_map_edit_area_type"];
02006 $coords = $_SESSION["il_map_edit_coords"];
02007
02008 $st_item =& $this->object->getMediaItem("Standard");
02009 $max = ilMapArea::_getMaxNr($st_item->getId());
02010
02011
02012 $area = new ilMapArea();
02013 $area->setItemId($st_item->getId());
02014 $area->setShape($area_type);
02015 $area->setCoords($coords);
02016 $area->setNr($max + 1);
02017 $area->setTitle($_POST["area_name"]);
02018 switch($_POST["area_link_type"])
02019 {
02020 case "ext":
02021 $area->setLinkType(IL_EXT_LINK);
02022 $area->setHref($_POST["area_link_ext"]);
02023 break;
02024
02025 case "int":
02026 $area->setLinkType(IL_INT_LINK);
02027 $area->setType($_SESSION["il_map_il_type"]);
02028
02029 $area->setTarget($_SESSION["il_map_il_target"]);
02030 $area->setTargetFrame($_SESSION["il_map_il_targetframe"]);
02031 break;
02032 }
02033
02034
02035 $st_item->addMapArea($area);
02036 $this->object->update();
02037 break;
02038 }
02039
02040 $this->initMapParameters();
02041 sendInfo($this->lng->txt("cont_saved_map_area"), true);
02042 $this->ctrl->redirect($this, "editMapAreas");
02043 }
02044
02045 function editLinkObject()
02046 {
02047 $_SESSION["il_map_edit_coords"] = "";
02048 $_SESSION["il_map_edit_mode"] = "";
02049 $_SESSION["il_map_el_href"] = "";
02050 $_SESSION["il_map_il_type"] = "";
02051 $_SESSION["il_map_il_ltype"] = "";
02052 $_SESSION["il_map_il_target"] = "";
02053 $_SESSION["il_map_il_targetframe"] = "";
02054 $_SESSION["il_map_area_nr"] = "";
02055 $this->setLink(false);
02056 }
02057
02061 function setLink($a_handle = true)
02062 {
02063 if($a_handle)
02064 {
02065 $this->handleMapParameters();
02066 }
02067 if ($_SESSION["il_map_area_nr"] != "")
02068 {
02069 $_POST["area"][0] = $_SESSION["il_map_area_nr"];
02070 }
02071 if (!isset($_POST["area"]))
02072 {
02073 sendInfo($this->lng->txt("no_checkbox"), true);
02074 $this->editMapAreasObject();
02075 return;
02076 }
02077
02078 if (count($_POST["area"]) > 1)
02079 {
02080
02081 sendInfo($this->lng->txt("cont_select_max_one_item"), true);
02082 $this->editMapAreasObject();
02083 return;
02084 }
02085
02086 $st_item =& $this->object->getMediaItem("Standard");
02087 $area =& $st_item->getMapArea($_POST["area"][0]);
02088
02089
02090 if ($_SESSION["il_map_edit_mode"] != "edit_link")
02091 {
02092 $_SESSION["il_map_area_nr"] = $_POST["area"][0];
02093 $_SESSION["il_map_il_ltype"] = $area->getLinkType();
02094 $_SESSION["il_map_edit_mode"] = "edit_link";
02095 $_SESSION["il_map_edit_target_script"] = $this->ctrl->getLinkTarget($this, "setLink");
02096 if ($_SESSION["il_map_il_ltype"] == IL_INT_LINK)
02097 {
02098 $_SESSION["il_map_il_type"] = $area->getType();
02099 $_SESSION["il_map_il_target"] = $area->getTarget();
02100 $_SESSION["il_map_il_targetframe"] = $area->getTargetFrame();
02101 }
02102 else
02103 {
02104 $_SESSION["il_map_el_href"] = $area->getHref();
02105 }
02106 }
02107
02108 $this->editMapArea(false, false, true, "link", $_POST["area"][0]);
02109 }
02110
02111 function editShapeObject()
02112 {
02113 $_SESSION["il_map_area_nr"] = "";
02114 $_SESSION["il_map_edit_coords"] = "";
02115 $_SESSION["il_map_edit_mode"] = "";
02116 $_SESSION["il_map_el_href"] = "";
02117 $_SESSION["il_map_il_type"] = "";
02118 $_SESSION["il_map_il_ltype"] = "";
02119 $_SESSION["il_map_il_target"] = "";
02120 $_SESSION["il_map_il_targetframe"] = "";
02121 $this->setShapeObject(false);
02122 }
02123
02127 function setShapeObject($a_handle = true)
02128 {
02129 if($a_handle)
02130 {
02131 $this->handleMapParameters();
02132 }
02133 if($_POST["areatype2"] != "")
02134 {
02135 $_SESSION["il_map_edit_area_type"] = $_POST["areatype2"];
02136 }
02137 if ($_SESSION["il_map_area_nr"] != "")
02138 {
02139 $_POST["area"][0] = $_SESSION["il_map_area_nr"];
02140 }
02141 if (!isset($_POST["area"]))
02142 {
02143 sendInfo($this->lng->txt("no_checkbox"), true);
02144 $this->editMapAreasObject();
02145 return;
02146 }
02147
02148 if (count($_POST["area"]) > 1)
02149 {
02150
02151 sendInfo($this->lng->txt("cont_select_max_one_item"), true);
02152 $this->editMapAreasObject();
02153 return;
02154 }
02155
02156 $st_item =& $this->object->getMediaItem("Standard");
02157 $area =& $st_item->getMapArea($_POST["area"][0]);
02158
02159
02160 if ($_SESSION["il_map_edit_mode"] != "edit_shape")
02161 {
02162 $_SESSION["il_map_area_nr"] = $_POST["area"][0];
02163 $_SESSION["il_map_edit_mode"] = "edit_shape";
02164 $_SESSION["il_map_edit_target_script"] = $this->ctrl->getLinkTarget($this, "setShape");
02165 }
02166
02167
02168 $area_type = $_SESSION["il_map_edit_area_type"];
02169 $coords = $_SESSION["il_map_edit_coords"];
02170 $cnt_coords = ilMapArea::countCoords($coords);
02171
02172
02173 switch ($area_type)
02174 {
02175
02176 case "Rect" :
02177 if ($cnt_coords < 2)
02178 {
02179 $this->editMapArea(true, false, false, "shape", $_POST["area"][0]);
02180 }
02181 else if ($cnt_coords == 2)
02182 {
02183 $this->saveAreaObject();
02184 }
02185 break;
02186
02187
02188 case "Circle":
02189
02190 if ($cnt_coords <= 1)
02191 {
02192 $this->editMapArea(true, false, false, "shape", $_POST["area"][0]);
02193 }
02194 else
02195 {
02196 if ($cnt_coords == 2)
02197 {
02198 $c = explode(",",$coords);
02199 $coords = $c[0].",".$c[1].",";
02200 $coords .= round(sqrt(pow(abs($c[3]-$c[1]),2)+pow(abs($c[2]-$c[0]),2)));
02201 }
02202 $_SESSION["il_map_edit_coords"] = $coords;
02203
02204 $this->saveAreaObject();
02205 }
02206 break;
02207
02208
02209 case "Poly":
02210 if ($cnt_coords < 1)
02211 {
02212 $this->editMapArea(true, false, false, "shape", $_POST["area"][0]);
02213 }
02214 else if ($cnt_coords < 3)
02215 {
02216 $this->editMapArea(true, true, false, "shape", $_POST["area"][0]);
02217 }
02218 else
02219 {
02220 $this->editMapArea(true, true, true, "shape", $_POST["area"][0]);
02221 }
02222 break;
02223 }
02224
02225 }
02226
02230 function _getMediaInfoHTML(&$a_mob)
02231 {
02232 global $lng;
02233
02234 $tpl =& new ilTemplate("tpl.media_info.html", true, true, "content");
02235 $types = array("Standard", "Fullscreen");
02236 foreach ($types as $type)
02237 {
02238 if($type == "Fullscreen" && !$a_mob->hasFullScreenItem())
02239 {
02240 continue;
02241 }
02242
02243 $med =& $a_mob->getMediaItem($type);
02244 $tpl->setCurrentBlock("media_info");
02245 if ($type == "Standard")
02246 {
02247 $tpl->setVariable("TXT_PURPOSE", $lng->txt("cont_std_view"));
02248 }
02249 else
02250 {
02251 $tpl->setVariable("TXT_PURPOSE", $lng->txt("cont_fullscreen"));
02252 }
02253 $tpl->setVariable("TXT_TYPE", $lng->txt("cont_".$med->getLocationType()));
02254 $tpl->setVariable("VAL_LOCATION", $med->getLocation());
02255 if ($med->getLocationType() == "LocalFile")
02256 {
02257 $file = ilObjMediaObject::_getDirectory($med->getMobId())."/".$med->getLocation();
02258 if (is_file($file))
02259 {
02260 $size = filesize($file);
02261 }
02262 else
02263 {
02264 $size = 0;
02265 }
02266 $tpl->setVariable("VAL_FILE_SIZE", " ($size ".$lng->txt("bytes").")");
02267 }
02268 $tpl->setVariable("TXT_FORMAT", $lng->txt("cont_format"));
02269 $tpl->setVariable("VAL_FORMAT", $med->getFormat());
02270 if ($med->getWidth() != "" && $med->getHeight() != "")
02271 {
02272 $tpl->setCurrentBlock("size");
02273 $tpl->setVariable("TXT_SIZE", $lng->txt("size"));
02274 $tpl->setVariable("VAL_SIZE", $med->getWidth()."x".$med->getHeight());
02275 $tpl->parseCurrentBlock();
02276 }
02277
02278
02279 if ($orig_size = $med->getOriginalSize())
02280 {
02281 if ($orig_size["width"] != $med->getWidth() ||
02282 $orig_size["height"] != $med->getHeight())
02283 {
02284 $tpl->setCurrentBlock("orig_size");
02285 $tpl->setVariable("TXT_ORIG_SIZE", $lng->txt("cont_orig_size"));
02286 $tpl->setVariable("ORIG_WIDTH", $orig_size["width"]);
02287 $tpl->setVariable("ORIG_HEIGHT", $orig_size["height"]);
02288 $tpl->parseCurrentBlock();
02289 }
02290 }
02291 $tpl->setCurrentBlock("media_info");
02292 $tpl->parseCurrentBlock();
02293 }
02294
02295 return $tpl->get();
02296 }
02297
02301 function setAdminTabs()
02302 {
02303
02304 sendInfo();
02305 #include_once("classes/class.ilTabsGUI.php");
02306 #$tabs_gui =& new ilTabsGUI();
02307 $this->getTabs($this->tabs_gui);
02308
02309
02310 if (is_object($this->object) && strtolower(get_class($this->object)) == "ilobjmediaobject")
02311 {
02312 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_mob_b.gif"));
02313
02314
02315
02316 $this->tpl->setCurrentBlock();
02317 $title = $this->object->getTitle();
02318 $this->tpl->setVariable("HEADER", $title);
02319 }
02320 else
02321 {
02322
02323 $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_mob_b.gif"));
02324
02325
02326
02327 $this->tpl->setVariable("HEADER", $this->lng->txt("cont_create_mob"));
02328 }
02329
02330
02331 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
02332
02333 }
02334
02335 function getTabs(&$tabs_gui)
02336 {
02337
02338 if (is_object($this->object) && strtolower(get_class($this->object)) == "ilobjmediaobject"
02339 && $this->object->getId() > 0)
02340 {
02341
02342 $tabs_gui->addTarget("cont_mob_prop",
02343 $this->ctrl->getLinkTarget($this, "edit"), "edit",
02344 get_class($this));
02345
02346
02347 $tabs_gui->addTarget("cont_mob_files",
02348 $this->ctrl->getLinkTarget($this, "editFiles"), "editFiles",
02349 get_class($this));
02350
02351
02352 $tabs_gui->addTarget("cont_mob_usages",
02353 $this->ctrl->getLinkTarget($this, "showUsages"), "showUsages",
02354 get_class($this));
02355
02356
02357 $st_item =& $this->object->getMediaItem("Standard");
02358 if (is_object($st_item))
02359 {
02360 $format = $st_item->getFormat();
02361 if (substr($format, 0, 5) == "image")
02362 {
02363 $tabs_gui->addTarget("cont_map_areas",
02364 $this->ctrl->getLinkTarget($this, "editMapAreas"), "editMapAreas",
02365 get_class($this));
02366 }
02367 }
02368
02369 $tabs_gui->addTarget("meta_data",
02370 $this->ctrl->getLinkTargetByClass(
02371 array("ilobjmediaobjectgui", "ilmdeditorgui"),'listSection'),
02372 "", "ilmdeditorgui");
02373
02374 }
02375
02376
02377 if ($this->back_title != "")
02378 {
02379 $tabs_gui->setBackTarget($this->back_title,
02380 $this->ctrl->getParentReturn($this));
02381 }
02382 }
02383
02384 }
02385 ?>