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