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/Pages/class.ilPageContentGUI.php");
00025
00026 require_once ("content/classes/Pages/class.ilMediaAliasItem.php");
00027 require_once ("content/classes/Media/class.ilObjMediaObjectGUI.php");
00028
00039
00040 class ilPCMediaObjectGUI extends ilPageContentGUI
00041 {
00042 var $header;
00043 var $ctrl;
00044
00045 function ilPCMediaObjectGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id = 0)
00046 {
00047 global $ilCtrl;
00048
00049 $this->ctrl =& $ilCtrl;
00050
00051
00052 parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id);
00053 }
00054
00055 function _forwards()
00056 {
00057 return array();
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
00074 function insert($a_post_cmd = "edpost", $a_submit_cmd = "create_mob")
00075 {
00076 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mob_new.html", "content");
00077 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_mob"));
00078 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00079
00080 $this->displayValidationError();
00081
00082
00083 $this->tpl->setVariable("TXT_STANDARD_VIEW", $this->lng->txt("cont_std_view"));
00084 $this->tpl->setVariable("TXT_FILE", $this->lng->txt("cont_file"));
00085 $this->tpl->setVariable("TXT_REFERENCE", $this->lng->txt("cont_reference"));
00086 $this->tpl->setVariable("TXT_REF_HELPTEXT", $this->lng->txt("cont_ref_helptext"));
00087 $this->tpl->setVariable("TXT_WIDTH", $this->lng->txt("cont_width"));
00088 $this->tpl->setVariable("TXT_HEIGHT", $this->lng->txt("cont_height"));
00089 $this->tpl->setVariable("TXT_ORIGINAL_SIZE", $this->lng->txt("cont_orig_size"));
00090 $this->tpl->setVariable("TXT_CAPTION", $this->lng->txt("cont_caption"));
00091 $this->tpl->setVariable("TXT_FULLSCREEN_VIEW", $this->lng->txt("cont_fullscreen"));
00092 $this->tpl->setVariable("TXT_PARAMETER", $this->lng->txt("cont_parameter"));
00093 $this->tpl->parseCurrentBlock();
00094
00095
00096 $this->tpl->setCurrentBlock("commands");
00097 $this->tpl->setVariable("BTN_NAME", $a_submit_cmd);
00098 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00099 $this->tpl->parseCurrentBlock();
00100
00101 }
00102
00106 function &create($a_create_alias = true)
00107 {
00108
00109 if ($_POST["standard_type"] == "File")
00110 {
00111 $title = $_FILES['standard_file']['name'];
00112 }
00113 else
00114 {
00115 $title = $_POST["standard_reference"];
00116 }
00117
00118
00119 $this->content_obj = new ilObjMediaObject();
00120 $dummy_meta =& new ilMetaData();
00121 $dummy_meta->setObject($this->content_obj);
00122 $this->content_obj->assignMetaData($dummy_meta);
00123 $this->content_obj->setTitle($title);
00124 $this->content_obj->setDescription("");
00125 $this->content_obj->create();
00126
00127
00128
00129 $this->content_obj->createDirectory();
00130 $mob_dir = ilObjMediaObject::_getDirectory($this->content_obj->getId());
00131
00132 $media_item =& new ilMediaItem();
00133 $this->content_obj->addMediaItem($media_item);
00134 $media_item->setPurpose("Standard");
00135 $meta =& $this->content_obj->getMetaData();
00136 $meta_technical =& new ilMetaTechnical($meta);
00137
00138 if ($_POST["standard_type"] == "File")
00139 {
00140 $file = $mob_dir."/".$_FILES['standard_file']['name'];
00141
00142 if (!ilUtil::moveUploadedFile($_FILES['standard_file']['tmp_name'],
00143 $_FILES['standard_file']['name'], $file, false))
00144 {
00145 $this->content_obj->delete();
00146 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00147 return;
00148 }
00149
00150
00151 $format = ilObjMediaObject::getMimeType($file);
00152 $media_item->setFormat($format);
00153 $media_item->setLocation($_FILES['standard_file']['name']);
00154 $media_item->setLocationType("LocalFile");
00155 $meta_technical->addFormat($format);
00156 $meta_technical->setSize($_FILES['standard_file']['size']);
00157 $meta_technical->addLocation("LocalFile", $_FILES['standard_file']['name']);
00158 $this->content_obj->setTitle($_FILES['standard_file']['name']);
00159 }
00160 else
00161 {
00162 $format = ilObjMediaObject::getMimeType($_POST["standard_reference"]);
00163 $media_item->setFormat($format);
00164 $media_item->setLocation($_POST["standard_reference"]);
00165 $media_item->setLocationType("Reference");
00166 $meta_technical->addFormat($format);
00167 $meta_technical->setSize(0);
00168 $meta_technical->addLocation("Reference", $_POST["standard_reference"]);
00169 $this->content_obj->setTitle($_POST["standard_reference"]);
00170 }
00171 $meta->addTechnicalSection($meta_technical);
00172 $this->content_obj->setDescription($format);
00173
00174
00175 if ($_POST["standard_size"] == "original")
00176 {
00177 if (ilUtil::deducibleSize($format))
00178 {
00179 $size = getimagesize($file);
00180 $media_item->setWidth($size[0]);
00181 $media_item->setHeight($size[1]);
00182 }
00183 }
00184 else
00185 {
00186 $media_item->setWidth($_POST["standard_width"]);
00187 $media_item->setHeight($_POST["standard_height"]);
00188 }
00189
00190 if ($_POST["standard_caption"] != "")
00191 {
00192 $media_item->setCaption($_POST["standard_caption"]);
00193 }
00194
00195 if ($_POST["standard_param"] != "")
00196 {
00197 $media_item->setParameters(ilUtil::stripSlashes(utf8_decode($_POST["standard_param"])));
00198 }
00199
00200 $media_item->setHAlign("Left");
00201
00202
00203 if ($_POST["fullscreen"] == "y")
00204 {
00205 $media_item =& new ilMediaItem();
00206 $this->content_obj->addMediaItem($media_item);
00207 $media_item->setPurpose("Fullscreen");
00208
00209
00210 if ($_POST["full_type"] == "File")
00211 {
00212 if ($_FILES['full_file']['name'] != "")
00213 {
00214 $file = $mob_dir."/".$_FILES['full_file']['name'];
00215
00216 if (!ilUtil::moveUploadedFile($_FILES['full_file']['tmp_name'],
00217 $_FILES['full_file']['name'], $file, false))
00218 {
00219 $this->content_obj->delete();
00220 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00221 return;
00222 }
00223
00224
00225 $format = ilObjMediaObject::getMimeType($file);
00226 $media_item->setFormat($format);
00227 $media_item->setLocation($_FILES['full_file']['name']);
00228 $media_item->setLocationType("LocalFile");
00229 $meta_technical->addFormat($format);
00230 $meta_technical->setSize($meta_technical->getSize()
00231 + $_FILES['full_file']['size']);
00232 $meta_technical->addLocation("LocalFile", $_FILES['full_file']['name']);
00233 }
00234 }
00235 else
00236 {
00237 if ($_POST["full_reference"] != "")
00238 {
00239 $format = ilObjMediaObject::getMimeType($_POST["full_reference"]);
00240 $media_item->setFormat($format);
00241 $media_item->setLocation($_POST["full_reference"]);
00242 $media_item->setLocationType("Reference");
00243 $meta_technical->addFormat($format);
00244 $meta_technical->addLocation("Reference", $_POST["full_reference"]);
00245 }
00246 }
00247
00248
00249 if ($_POST["full_size"] == "original")
00250 {
00251 if (ilUtil::deducibleSize($format))
00252 {
00253 $size = getimagesize($file);
00254 $media_item->setWidth($size[0]);
00255 $media_item->setHeight($size[1]);
00256 }
00257 }
00258 else
00259 {
00260 $media_item->setWidth($_POST["full_width"]);
00261 $media_item->setHeight($_POST["full_height"]);
00262 }
00263
00264 if ($_POST["full_caption"] != "")
00265 {
00266 $media_item->setCaption($_POST["full_caption"]);
00267 }
00268
00269 if ($_POST["full_param"] != "")
00270 {
00271 $media_item->setParameters(ilUtil::stripSlashes(utf8_decode($_POST["full_param"])));
00272 }
00273
00274 }
00275 ilUtil::renameExecutables($mob_dir);
00276 $this->content_obj->update();
00277
00278 if ($a_create_alias)
00279 {
00280 $this->content_obj->setDom($this->dom);
00281 $this->content_obj->createAlias($this->pg_obj, $this->hier_id);
00282 $this->updated = $this->pg_obj->update();
00283 if ($this->updated === true)
00284 {
00285 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00286 }
00287 else
00288 {
00289 $this->insert();
00290 }
00291 }
00292 else
00293 {
00294 return $this->content_obj;
00295 }
00296 }
00297
00298
00299
00303 function editAlias()
00304 {
00305
00306 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00307
00308
00309 $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard");
00310 $std_item =& $this->content_obj->getMediaItem("Standard");
00311
00312
00313 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mob_alias_properties.html", "content");
00314 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_mob_alias_prop"));
00315 $this->tpl->setVariable("TXT_STANDARD_VIEW", $this->lng->txt("cont_std_view"));
00316 $this->tpl->setVariable("TXT_DERIVE", $this->lng->txt("cont_derive_from_obj"));
00317 $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("cont_".$std_item->getLocationType()));
00318 $this->tpl->setVariable("TXT_LOCATION", $std_item->getLocation());
00319 $this->tpl->setVariable("TXT_FORMAT", $this->lng->txt("cont_format"));
00320 $this->tpl->setVariable("VAL_FORMAT", $std_item->getFormat());
00321 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00322
00323 $this->displayValidationError();
00324
00325
00326 $this->tpl->setVariable("TXT_MOB_WIDTH", $this->lng->txt("cont_width"));
00327 $this->tpl->setVariable("INPUT_MOB_WIDTH", "mob_width");
00328 $this->tpl->setVariable("VAL_MOB_WIDTH", $std_alias_item->getWidth());
00329
00330
00331 $this->tpl->setVariable("TXT_MOB_HEIGHT", $this->lng->txt("cont_height"));
00332 $this->tpl->setVariable("INPUT_MOB_HEIGHT", "mob_height");
00333 $this->tpl->setVariable("VAL_MOB_HEIGHT", $std_alias_item->getHeight());
00334
00335
00336 $this->tpl->setVariable("TXT_CAPTION", $this->lng->txt("cont_caption"));
00337 $this->tpl->setVariable("INPUT_CAPTION", "mob_caption");
00338 $this->tpl->setVariable("VAL_CAPTION", $std_alias_item->getCaption());
00339 $this->tpl->parseCurrentBlock();
00340
00341
00342 $this->tpl->setVariable("TXT_PARAMETER", $this->lng->txt("cont_parameter"));
00343 $this->tpl->setVariable("INPUT_PARAMETERS", "mob_parameters");
00344 $this->tpl->setVariable("VAL_PARAMETERS", $std_alias_item->getParameterString());
00345 $this->tpl->parseCurrentBlock();
00346
00347
00348 $this->tpl->setVariable("VAL_OBJ_ST_SIZE", $std_item->getWidth()." / ".$std_item->getHeight());
00349 $this->tpl->setVariable("VAL_OBJ_ST_CAPTION", $std_item->getCaption());
00350 $this->tpl->setVariable("VAL_OBJ_ST_PARAMETERS", $std_item->getParameterString());
00351 if ($std_alias_item->definesSize())
00352 {
00353 $this->tpl->setVariable("DERIVE_ST_SIZE_N", "checked=\"1\"");
00354 }
00355 else
00356 {
00357 $this->tpl->setVariable("DERIVE_ST_SIZE_Y", "checked=\"1\"");
00358 }
00359 if ($std_alias_item->definesCaption())
00360 {
00361 $this->tpl->setVariable("DERIVE_ST_CAPTION_N", "checked=\"1\"");
00362 }
00363 else
00364 {
00365 $this->tpl->setVariable("DERIVE_ST_CAPTION_Y", "checked=\"1\"");
00366 }
00367 if ($std_alias_item->definesParameters())
00368 {
00369 $this->tpl->setVariable("DERIVE_ST_PARAMETER_N", "checked=\"1\"");
00370 }
00371 else
00372 {
00373 $this->tpl->setVariable("DERIVE_ST_PARAMETER_Y", "checked=\"1\"");
00374 }
00375
00376
00377 if($this->content_obj->hasFullScreenItem())
00378 {
00379 $this->tpl->setCurrentBlock("fullscreen");
00380 $full_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Fullscreen");
00381 $full_item =& $this->content_obj->getMediaItem("Fullscreen");
00382
00383 $this->tpl->setVariable("TXT_FULLSCREEN_VIEW", $this->lng->txt("cont_fullscreen"));
00384 $this->tpl->setVariable("TXT_FULL_TYPE", $this->lng->txt("cont_".$full_item->getLocationType()));
00385 $this->tpl->setVariable("TXT_FULL_LOCATION", $full_item->getLocation());
00386
00387 $this->tpl->setVariable("TXT_FULL_FORMAT", $this->lng->txt("cont_format"));
00388 $this->tpl->setVariable("VAL_FULL_FORMAT", $full_item->getFormat());
00389
00390
00391 $this->tpl->setVariable("TXT_FULL_WIDTH", $this->lng->txt("cont_width"));
00392 $this->tpl->setVariable("INPUT_FULL_WIDTH", "full_width");
00393
00394
00395 $this->tpl->setVariable("TXT_FULL_HEIGHT", $this->lng->txt("cont_height"));
00396 $this->tpl->setVariable("INPUT_FULL_HEIGHT", "full_height");
00397
00398
00399 $this->tpl->setVariable("TXT_FULL_CAPTION", $this->lng->txt("cont_caption"));
00400 $this->tpl->setVariable("INPUT_FULL_CAPTION", "full_caption");
00401
00402
00403 $this->tpl->setVariable("TXT_FULL_PARAMETER", $this->lng->txt("cont_parameter"));
00404 $this->tpl->setVariable("INPUT_FULL_PARAMETERS", "full_parameters");
00405
00406
00407 $this->tpl->setVariable("VAL_OBJ_FULL_SIZE", $full_item->getWidth()." / ".$full_item->getHeight());
00408 $this->tpl->setVariable("VAL_OBJ_FULL_CAPTION", $full_item->getCaption());
00409 $this->tpl->setVariable("VAL_OBJ_FULL_PARAMETERS", $full_item->getParameterString());
00410 if ($full_alias_item->definesSize())
00411 {
00412 $this->tpl->setVariable("DERIVE_FULL_SIZE_N", "checked=\"1\"");
00413 }
00414 else
00415 {
00416 $this->tpl->setVariable("DERIVE_FULL_SIZE_Y", "checked=\"1\"");
00417 }
00418 if ($full_alias_item->definesCaption())
00419 {
00420 $this->tpl->setVariable("DERIVE_FULL_CAPTION_N", "checked=\"1\"");
00421 }
00422 else
00423 {
00424 $this->tpl->setVariable("DERIVE_FULL_CAPTION_Y", "checked=\"1\"");
00425 }
00426 if ($full_alias_item->definesParameters())
00427 {
00428 $this->tpl->setVariable("DERIVE_FULL_PARAMETER_N", "checked=\"1\"");
00429 }
00430 else
00431 {
00432 $this->tpl->setVariable("DERIVE_FULL_PARAMETER_Y", "checked=\"1\"");
00433 }
00434
00435 if ($full_alias_item->exists())
00436 {
00437 $this->tpl->setVariable("FULLSCREEN_CHECKED", "checked=\"1\"");
00438
00439
00440 $this->tpl->setVariable("VAL_FULL_WIDTH", $full_alias_item->getWidth());
00441
00442
00443 $this->tpl->setVariable("VAL_FULL_HEIGHT", $full_alias_item->getHeight());
00444
00445
00446 $this->tpl->setVariable("VAL_FULL_CAPTION", $full_alias_item->getCaption());
00447
00448
00449 $this->tpl->setVariable("VAL_FULL_PARAMETERS", $full_alias_item->getParameterString());
00450 }
00451
00452 $this->tpl->parseCurrentBlock();
00453 }
00454
00455
00456 $this->tpl->setCurrentBlock("commands");
00457 $this->tpl->setVariable("BTN_NAME", "saveAliasProperties");
00458 $this->tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
00459 $this->tpl->parseCurrentBlock();
00460
00461 }
00462
00463
00467 function saveAliasProperties()
00468 {
00469 $std_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard");
00470 $full_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Fullscreen");
00471
00472
00473 if($_POST["derive_st_size"] == "y")
00474 {
00475 $std_item->deriveSize();
00476 }
00477 else
00478 {
00479 $std_item->setWidth($_POST["mob_width"]);
00480 $std_item->setHeight($_POST["mob_height"]);
00481 }
00482
00483
00484 if($_POST["derive_st_caption"] == "y")
00485 {
00486 $std_item->deriveCaption();
00487 }
00488 else
00489 {
00490 $std_item->setCaption($_POST["mob_caption"]);
00491 }
00492
00493
00494 if($_POST["derive_st_parameter"] == "y")
00495 {
00496 $std_item->deriveParameters();
00497 }
00498 else
00499 {
00500 $std_item->setParameters(ilUtil::extractParameterString(ilUtil::stripSlashes(utf8_decode($_POST["mob_parameters"]))));
00501 }
00502
00503 if($this->content_obj->hasFullscreenItem())
00504 {
00505 if ($_POST["fullscreen"] == "y")
00506 {
00507 if (!$full_item->exists())
00508 {
00509 $full_item->insert();
00510 }
00511
00512
00513 if($_POST["derive_full_size"] == "y")
00514 {
00515 $full_item->deriveSize();
00516 }
00517 else
00518 {
00519 $full_item->setWidth($_POST["full_width"]);
00520 $full_item->setHeight($_POST["full_height"]);
00521 }
00522
00523
00524 if($_POST["derive_full_caption"] == "y")
00525 {
00526 $full_item->deriveCaption();
00527 }
00528 else
00529 {
00530 $full_item->setCaption($_POST["full_caption"]);
00531 }
00532
00533
00534 if($_POST["derive_full_parameter"] == "y")
00535 {
00536 $full_item->deriveParameters();
00537 }
00538 else
00539 {
00540 $full_item->setParameters(ilUtil::extractParameterString(ilUtil::stripSlashes(utf8_decode($_POST["full_parameters"]))));
00541 }
00542 }
00543 else
00544 {
00545 if ($full_item->exists())
00546 {
00547 $full_item->delete();
00548 }
00549 }
00550 }
00551
00552 $this->updated = $this->pg_obj->update();
00553 if ($this->updated === true)
00554 {
00555 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00556 }
00557 else
00558 {
00559 $this->pg_obj->addHierIDs();
00560 $this->edit();
00561 }
00562 }
00563
00567 function &executeCommand()
00568 {
00569
00570 $next_class = $this->ctrl->getNextClass($this);
00571
00572
00573 $cmd = $this->ctrl->getCmd();
00574
00575 switch($next_class)
00576 {
00577 default:
00578 $ret =& $this->$cmd();
00579 break;
00580 }
00581
00582 return $ret;
00583 }
00584
00585
00589 function copyToClipboard()
00590 {
00591 $this->ilias->account->addObjectToClipboard($this->content_obj->getId(), $this->content_obj->getType()
00592 , $this->content_obj->getTitle());
00593 sendInfo($this->lng->txt("copied_to_clipboard"), true);
00594 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00595 }
00596
00600 function centerAlign()
00601 {
00602 $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard");
00603 $std_alias_item->setHorizontalAlign("Center");
00604 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00605 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00606 }
00607
00611 function leftAlign()
00612 {
00613 $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard");
00614 $std_alias_item->setHorizontalAlign("Left");
00615 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00616 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00617 }
00618
00622 function rightAlign()
00623 {
00624 $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard");
00625 $std_alias_item->setHorizontalAlign("Right");
00626 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00627 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00628 }
00629
00633 function leftFloatAlign()
00634 {
00635 $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard");
00636 $std_alias_item->setHorizontalAlign("LeftFloat");
00637 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00638 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00639 }
00640
00644 function rightFloatAlign()
00645 {
00646 $std_alias_item =& new ilMediaAliasItem($this->dom, $this->getHierId(), "Standard");
00647 $std_alias_item->setHorizontalAlign("RightFloat");
00648 $_SESSION["il_pg_error"] = $this->pg_obj->update();
00649 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
00650 }
00651
00658 function getTabs(&$tab_gui, $a_create = false)
00659 {
00660 global $ilCtrl;
00661
00662 if ($a_create)
00663 {
00664 $tab_gui->addTarget("cont_back",
00665 $ilCtrl->getParentReturn($this), "",
00666 "");
00667 }
00668 else
00669 {
00670 $tab_gui->addTarget("cont_mob_inst_prop",
00671 $ilCtrl->getLinkTarget($this, "editAlias"), "editAlias",
00672 get_class($this));
00673 }
00674 }
00675
00676 }
00677 ?>