ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilEditClipboardGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
25 
38 {
43  function ilEditClipboardGUI()
44  {
45  global $lng, $ilCtrl;
46 
47  $this->multiple = false;
48  $this->page_back_title = $lng->txt("cont_back");
49  if ($_GET["returnCommand"] != "")
50  {
51  $this->mode = "getObject";
52  }
53  else
54  {
55  $this->mode = "";
56  }
57 
58  $ilCtrl->setParameter($this, "returnCommand",
59  rawurlencode($_GET["returnCommand"]));
60 
61  $ilCtrl->saveParameter($this, array("clip_item_id"));
62  }
63 
69  function _forwards()
70  {
71  return array("ilObjMediaObjectGUI");
72  }
73 
77  function &executeCommand()
78  {
79  global $ilUser, $ilCtrl, $ilTabs, $lng;
80 
81  $next_class = $ilCtrl->getNextClass($this);
82  $cmd = $ilCtrl->getCmd();
83 
84  switch($next_class)
85  {
86  case "ilobjmediaobjectgui":
87  $ilCtrl->setReturn($this, "view");
88  $ilTabs->clearTargets();
89  $ilTabs->setBackTarget($lng->txt("back"),
90  $ilCtrl->getLinkTarget($this, "view"));
91  require_once("classes/class.ilTabsGUI.php");
92  //$id = explode(":",$_GET["clip_item_id"]);
93  $mob_gui =& new ilObjMediaObjectGUI("", $_GET["clip_item_id"],false, false);
94  $mob_gui->setTabs();
95  $ret =& $ilCtrl->forwardCommand($mob_gui);
96  switch($cmd)
97  {
98  case "save":
99  $ilUser->addObjectToClipboard($ret->getId(), "mob", $ret->getTitle());
100  $ilCtrl->redirect($this, "view");
101  break;
102  }
103  break;
104 
105  default:
106  $ret =& $this->$cmd();
107  break;
108  }
109 
110  return $ret;
111  }
112 
116  function setMultipleSelections($a_multiple = true)
117  {
118  $this->multiple = $a_multiple;
119  }
120 
125  {
126  return $this->multiple;
127  }
128 
134  function setInsertButtonTitle($a_insertbuttontitle)
135  {
136  $this->insertbuttontitle = $a_insertbuttontitle;
137  }
138 
145  {
146  global $lng;
147 
148  if ($this->insertbuttontitle == "")
149  {
150  return $lng->txt("insert");
151  }
152 
153  return $this->insertbuttontitle;
154  }
155 
156  /*
157  * display clipboard content
158  */
159  function view()
160  {
161  global $tree, $ilUser, $ilCtrl, $lng, $tpl;
162 
163  $tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
164 
165  $tpl->setCurrentBlock("btn_cell");
166  $tpl->setVariable("BTN_LINK",
167  $ilCtrl->getLinkTargetByClass("ilobjmediaobjectgui", "create"));
168  $tpl->setVariable("BTN_TXT", $lng->txt("cont_create_mob"));
169  $tpl->parseCurrentBlock();
170 
171  include_once("./Services/Clipboard/classes/class.ilClipboardTableGUI.php");
172  $table_gui = new ilClipboardTableGUI($this, "view");
173  $tpl->setContent($table_gui->getHTML());
174  }
175 
176 
180  function getObject()
181  {
182  $this->mode = "getObject";
183  $this->view();
184  }
185 
186 
190  function remove()
191  {
192  global $ilias, $ilUser, $lng, $ilCtrl;
193 
194  // check number of objects
195  if (!isset($_POST["id"]))
196  {
197  $ilias->raiseError($lng->txt("no_checkbox"),$ilias->error_obj->MESSAGE);
198  }
199 
200  foreach($_POST["id"] AS $obj_id)
201  {
202  $id = explode(":", $obj_id);
203  if ($id[0] == "mob")
204  {
205  $ilUser->removeObjectFromClipboard($id[1], "mob");
206  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
207  $mob = new ilObjMediaObject($id[1]);
208  $mob->delete(); // this method don't delete, if mob is used elsewhere
209  }
210  if ($id[0] == "incl")
211  {
212  $ilUser->removeObjectFromClipboard($id[1], "incl");
213  }
214  }
215  $ilCtrl->redirect($this, "view");
216  }
217 
221  function insert()
222  {
223  global $ilias, $lng;
224 
225  // check number of objects
226  if (!isset($_POST["id"]))
227  {
228  $ilias->raiseError($lng->txt("no_checkbox"),$ilias->error_obj->MESSAGE);
229  }
230 
231  if (!$this->getMultipleSelections())
232  {
233  if(count($_POST["id"]) > 1)
234  {
235  $ilias->raiseError($lng->txt("cont_select_max_one_item"),$ilias->error_obj->MESSAGE);
236  }
237  }
238 
239  $_SESSION["ilEditClipboard_mob_id"] = $_POST["id"];
240  ilUtil::redirect($_GET["returnCommand"]);
241  }
242 
243  function _getSelectedIDs()
244  {
245  return $_SESSION["ilEditClipboard_mob_id"];
246  }
247 
251  function setTabs()
252  {
253  global $ilTabs, $lng, $tpl;
254 
255  $tpl->setTitleIcon(ilUtil::getImagePath("icon_clip_b.gif"));
256  $tpl->setTitle($lng->txt("clipboard"));
257  $this->getTabs($ilTabs);
258  }
259 
263  function setPageBackTitle($a_title)
264  {
265  $this->page_back_title = $a_title;
266  }
267 
273  function getTabs(&$tabs_gui)
274  {
275  global $ilCtrl;
276 
277  // back to upper context
278  $tabs_gui->setBackTarget($this->page_back_title,
279  $ilCtrl->getParentReturn($this));
280  }
281 
282 }
283 ?>