ILIAS  Release_3_10_x_branch Revision 61812
 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_mob_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  $mob_gui =& new ilObjMediaObjectGUI("", $_GET["clip_mob_id"],false, false);
93  $mob_gui->setAdminTabs();
94  $ret =& $ilCtrl->forwardCommand($mob_gui);
95  switch($cmd)
96  {
97  case "save":
98  $ilUser->addObjectToClipboard($ret->getId(), "mob", $ret->getTitle());
99  $ilCtrl->redirect($this, "view");
100  break;
101  }
102  break;
103 
104  default:
105  $ret =& $this->$cmd();
106  break;
107  }
108 
109  return $ret;
110  }
111 
115  function setMultipleSelections($a_multiple = true)
116  {
117  $this->multiple = $a_multiple;
118  }
119 
124  {
125  return $this->multiple;
126  }
127 
133  function setInsertButtonTitle($a_insertbuttontitle)
134  {
135  $this->insertbuttontitle = $a_insertbuttontitle;
136  }
137 
144  {
145  global $lng;
146 
147  if ($this->insertbuttontitle == "")
148  {
149  return $lng->txt("insert");
150  }
151 
152  return $this->insertbuttontitle;
153  }
154 
155  /*
156  * display clipboard content
157  */
158  function view()
159  {
160  global $tree, $ilUser, $ilCtrl, $lng, $tpl;
161 
162  $tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
163 
164  $tpl->setCurrentBlock("btn_cell");
165  $tpl->setVariable("BTN_LINK",
166  $ilCtrl->getLinkTargetByClass("ilobjmediaobjectgui", "create"));
167  $tpl->setVariable("BTN_TXT", $lng->txt("cont_create_mob"));
168  $tpl->parseCurrentBlock();
169 
170  include_once("./Services/Clipboard/classes/class.ilClipboardTableGUI.php");
171  $table_gui = new ilClipboardTableGUI($this, "view");
172  $tpl->setContent($table_gui->getHTML());
173  }
174 
175 
179  function getObject()
180  {
181  $this->mode = "getObject";
182  $this->view();
183  }
184 
185 
189  function remove()
190  {
191  global $ilias, $ilUser, $lng, $ilCtrl;
192 
193  // check number of objects
194  if (!isset($_POST["id"]))
195  {
196  $ilias->raiseError($lng->txt("no_checkbox"),$ilias->error_obj->MESSAGE);
197  }
198 
199  foreach($_POST["id"] AS $obj_id)
200  {
201  $ilUser->removeObjectFromClipboard($obj_id, "mob");
202  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
203  $mob = new ilObjMediaObject($obj_id);
204  $mob->delete(); // this method don't delete, if mob is used elsewhere
205  }
206  $ilCtrl->redirect($this, "view");
207  }
208 
212  function insert()
213  {
214  global $ilias, $lng;
215 
216  // check number of objects
217  if (!isset($_POST["id"]))
218  {
219  $ilias->raiseError($lng->txt("no_checkbox"),$ilias->error_obj->MESSAGE);
220  }
221 
222  if (!$this->getMultipleSelections())
223  {
224  if(count($_POST["id"]) > 1)
225  {
226  $ilias->raiseError($lng->txt("cont_select_max_one_item"),$ilias->error_obj->MESSAGE);
227  }
228  }
229 
230  $_SESSION["ilEditClipboard_mob_id"] = $_POST["id"];
232  $_GET["returnCommand"], "clip_obj_type=mob&clip_obj_id=".$_POST["id"][0]));
233  }
234 
235  function _getSelectedIDs()
236  {
237  return $_SESSION["ilEditClipboard_mob_id"];
238  }
239 
243  function setTabs()
244  {
245  global $ilTabs, $lng, $tpl;
246 
247  $tpl->setTitleIcon(ilUtil::getImagePath("icon_clip_b.gif"));
248  $tpl->setTitle($lng->txt("clipboard"));
249  $this->getTabs($ilTabs);
250  }
251 
255  function setPageBackTitle($a_title)
256  {
257  $this->page_back_title = $a_title;
258  }
259 
265  function getTabs(&$tabs_gui)
266  {
267  global $ilCtrl;
268 
269  // back to upper context
270  $tabs_gui->setBackTarget($this->page_back_title,
271  $ilCtrl->getParentReturn($this));
272  }
273 
274 }
275 ?>