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