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