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