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