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.ilObjMediaObjectGUI.php");
00025
00037 class ilEditClipboardGUI
00038 {
00039 var $ilias;
00040 var $tpl;
00041 var $lng;
00042 var $ctrl;
00043
00048 function ilEditClipboardGUI()
00049 {
00050 global $ilias, $tpl, $lng, $ilCtrl;
00051
00052 $this->ctrl =& $ilCtrl;
00053 $this->ilias =& $ilias;
00054 $this->tpl =& $tpl;
00055 $this->lng =& $lng;
00056 $this->multiple = false;
00057 if ($_GET["returnCommand"] != "")
00058 {
00059 $this->mode = "getObject";
00060 }
00061 else
00062 {
00063 $this->mode = "";
00064 }
00065
00066 $this->ctrl->saveParameter($this, array("clip_mob_id", "returnCommand"));
00067 }
00068
00074 function _forwards()
00075 {
00076 return array("ilObjMediaObjectGUI");
00077 }
00078
00082 function &executeCommand()
00083 {
00084
00085 $next_class = $this->ctrl->getNextClass($this);
00086
00087
00088 $cmd = $this->ctrl->getCmd();
00089
00090 switch($next_class)
00091 {
00092 case "ilobjmediaobjectgui":
00093
00094 $this->ctrl->setReturn($this, "view");
00095 require_once("classes/class.ilTabsGUI.php");
00096 $tabs_gui =& new ilTabsGUI();
00097 $mob_gui =& new ilObjMediaObjectGUI("", $_GET["clip_mob_id"],false, false);
00098
00099 $mob_gui->setAdminTabs();
00100
00101
00102 $ret =& $this->ctrl->forwardCommand($mob_gui);
00103 switch($cmd)
00104 {
00105 case "save":
00106 $this->ilias->account->addObjectToClipboard($ret->getId(), "mob", $ret->getTitle());
00107 $this->ctrl->redirect($this, "view");
00108 break;
00109 }
00110 break;
00111
00112
00113 default:
00114 $ret =& $this->$cmd();
00115 break;
00116 }
00117
00118 return $ret;
00119 }
00120
00124 function setMultipleSelections($a_multiple = true)
00125 {
00126 $this->multiple = $a_multiple;
00127 }
00128
00132 function getMultipleSelections()
00133 {
00134 return $this->multiple;
00135 }
00136
00137
00138
00139
00140 function view()
00141 {
00142 global $tree;
00143
00144 $this->setTabs();
00145
00146 $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
00147
00148
00149 if ($this->mode != "getObject")
00150 {
00151 $this->tpl->setCurrentBlock("btn_cell");
00152 $this->tpl->setVariable("BTN_LINK",
00153 $this->ctrl->getLinkTargetByClass("ilobjmediaobjectgui", "create"));
00154 $this->tpl->setVariable("BTN_TXT",$this->lng->txt("cont_create_mob"));
00155 $this->tpl->parseCurrentBlock();
00156 }
00157
00158
00159 include_once "./classes/class.ilTableGUI.php";
00160
00161
00162
00163 $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
00164
00165
00166 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.clipboard_tbl_row.html", "content");
00167
00168 $num = 0;
00169
00170 $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
00171 if ($this->mode == "getObject")
00172 {
00173 $this->ctrl->setParameter($this, "returnCommand",
00174 rawurlencode($_GET["returnCommand"]));
00175 }
00176 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00177
00178
00179 $tbl = new ilTableGUI();
00180
00181
00182 $tbl->setTitle($this->lng->txt("objs_mob"));
00183
00184
00185 $tbl->setHeaderNames(array("", "", $this->lng->txt("cont_object")));
00186
00187 $cols = array("", "", "title");
00188 $header_params = $this->ctrl->getParameterArray($this, "view");
00189 $tbl->setHeaderVars($cols, $header_params);
00190 $tbl->setColumnWidth(array("1%","1%","98%"));
00191
00192
00193 $tbl->setOrderColumn($_GET["sort_by"]);
00194 $tbl->setOrderDirection($_GET["sort_order"]);
00195 $tbl->setLimit($_GET["limit"]);
00196 $tbl->setOffset($_GET["offset"]);
00197 $tbl->setMaxCount($this->maxcount);
00198
00199
00200 $this->tpl->setVariable("COLUMN_COUNTS", 3);
00201
00202 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
00203 if ($this->mode != "getObject")
00204 {
00205
00206 $this->tpl->setCurrentBlock("tbl_action_btn");
00207 $this->tpl->setVariable("BTN_NAME", "remove");
00208 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("remove"));
00209 $this->tpl->parseCurrentBlock();
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219 }
00220 else
00221 {
00222
00223 $this->tpl->setCurrentBlock("tbl_action_btn");
00224 $this->tpl->setVariable("BTN_NAME", "insert");
00225 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("insert"));
00226 $this->tpl->parseCurrentBlock();
00227 }
00228
00229
00230
00231
00232
00233 $objs = $this->ilias->account->getClipboardObjects("mob");
00234 $objs = ilUtil::sortArray($objs, $_GET["sort_by"], $_GET["sort_order"]);
00235 $tbl->setMaxCount(count($objs));
00236 $objs = array_slice($objs, $_GET["offset"], $_GET["limit"]);
00237 $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
00238
00239 $tbl->render();
00240 if(count($objs) > 0)
00241 {
00242 $i=0;
00243 foreach($objs as $obj)
00244 {
00245
00246 $mob =& new ilObjMediaObject($obj["id"]);
00247 $med =& $mob->getMediaItem("Standard");
00248 $target = $med->getThumbnailTarget();
00249 if ($target != "")
00250 {
00251 $this->tpl->setCurrentBlock("thumbnail");
00252 $this->tpl->setVariable("IMG_THUMB", $target);
00253 $this->tpl->parseCurrentBlock();
00254 }
00255
00256
00257 if ($this->mode != "getObject")
00258 {
00259
00260 $this->tpl->setCurrentBlock("edit");
00261 $this->ctrl->setParameter($this, "clip_mob_id", $obj["id"]);
00262 $this->tpl->setVariable("EDIT_LINK",
00263 $this->ctrl->getLinkTargetByClass("ilObjMediaObjectGUI", "edit",
00264 array("ilEditClipboardGUI")));
00265 $this->tpl->setVariable("TEXT_OBJECT", $obj["title"].
00266 " [".$obj["id"]."]");
00267 $this->tpl->parseCurrentBlock();
00268 }
00269 else
00270 {
00271 $this->tpl->setCurrentBlock("show");
00272 $this->tpl->setVariable("TEXT_OBJECT2", $obj["title"].
00273 " [".$obj["id"]."]");
00274 $this->tpl->parseCurrentBlock();
00275 }
00276
00277 include_once("content/classes/Media/class.ilObjMediaObjectGUI.php");
00278 $this->tpl->setVariable("MEDIA_INFO",
00279 ilObjMediaObjectGUI::_getMediaInfoHTML($mob));
00280
00281 $this->tpl->setCurrentBlock("tbl_content");
00282 $css_row = ilUtil::switchColor($i++,"tblrow1","tblrow2");
00283 $this->tpl->setVariable("CSS_ROW", $css_row);
00284 $this->tpl->setVariable("CHECKBOX_ID", $obj["id"]);
00285 $this->tpl->parseCurrentBlock();
00286 }
00287 }
00288 else
00289 {
00290 $this->tpl->setCurrentBlock("notfound");
00291 $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
00292 $this->tpl->setVariable("NUM_COLS", $num);
00293 $this->tpl->parseCurrentBlock();
00294 }
00295
00296 }
00297
00298
00302 function getObject()
00303 {
00304 $this->mode = "getObject";
00305 $this->view();
00306 }
00307
00308
00312 function remove()
00313 {
00314
00315 if (!isset($_POST["id"]))
00316 {
00317 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00318 }
00319
00320 foreach($_POST["id"] AS $obj_id)
00321 {
00322 $this->ilias->account->removeObjectFromClipboard($obj_id, "mob");
00323 include_once("content/classes/Media/class.ilObjMediaObject.php");
00324 $mob = new ilObjMediaObject($obj_id);
00325 $mob->delete();
00326 }
00327 $this->ctrl->redirect($this, "view");
00328 }
00329
00333 function insert()
00334 {
00335
00336 if (!isset($_POST["id"]))
00337 {
00338 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
00339 }
00340
00341 if (!$this->getMultipleSelections())
00342 {
00343 if(count($_POST["id"]) > 1)
00344 {
00345 $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
00346 }
00347 }
00348
00349 $_SESSION["ilEditClipboard_mob_id"] = $_POST["id"];
00350 ilUtil::redirect(ilUtil::appendUrlParameterString(
00351 $_GET["returnCommand"], "clip_obj_type=mob&clip_obj_id=".$_POST["id"][0]));
00352 }
00353
00354 function _getSelectedIDs()
00355 {
00356 return $_SESSION["ilEditClipboard_mob_id"];
00357 }
00358
00362 function createMediaInClipboard()
00363 {
00364 require_once ("content/classes/Pages/class.ilPCMediaObjectGUI.php");
00365 $mob_gui =& new ilPCMediaObjectGUI($this->obj, $this->lm_obj);
00366 $mob_gui->setTargetScript("lm_edit.php?ref_id=".$_GET["ref_id"]."&obj_id=".$_GET["obj_id"]);
00367 $mob_gui->insert("post", "saveMediaInClipboard");
00368 }
00369
00373 function saveMediaInClipboard()
00374 {
00375 require_once ("content/classes/Pages/class.ilPCMediaObjectGUI.php");
00376 $mob_gui =& new ilPCMediaObjectGUI($this->obj, $this->lm_obj);
00377 $mob =& $mob_gui->create(false);
00378 $this->ilias->account->addObjectToClipboard($mob->getId(), "mob", $mob->getTitle());
00379 $this->clipboard();
00380 }
00381
00385 function setTabs()
00386 {
00387 $this->tpl->setVariable("HEADER", $this->lng->txt("clipboard"));
00388
00389
00390 include_once("classes/class.ilTabsGUI.php");
00391 $tabs_gui =& new ilTabsGUI();
00392 $this->getTabs($tabs_gui);
00393 $this->tpl->setVariable("TABS", $tabs_gui->getHTML());
00394 }
00395
00401 function getTabs(&$tabs_gui)
00402 {
00403 if ($this->mode == "getObject")
00404 {
00405
00406 $tabs_gui->addTarget("cont_back",
00407 $_GET["returnCommand"], "",
00408 "");
00409 }
00410 else
00411 {
00412
00413 $tabs_gui->addTarget("cont_back",
00414 $this->ctrl->getParentReturn($this), "",
00415 "");
00416 }
00417 }
00418
00419 }
00420 ?>