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