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