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