ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMediaPoolTableGUI.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 include_once("Services/Table/classes/class.ilTable2GUI.php");
25 
35 {
36  const IL_MEP_SELECT = "select";
37  const IL_MEP_EDIT = "edit";
38 
42  function __construct($a_parent_obj, $a_parent_cmd,
43  $a_media_pool, $a_folder_par = "obj_id",
45  {
46  global $ilCtrl, $lng, $ilAccess, $lng;
47 
48  parent::__construct($a_parent_obj, $a_parent_cmd);
49  $this->setMode($a_mode);
50  $lng->loadLanguageModule("mep");
51 
52  $this->media_pool = $a_media_pool;
53  $this->tree = ilObjMediaPool::getPoolTree($this->media_pool->getId());
54  $this->folder_par = $a_folder_par;
55 
56  // folder determination
57  if ($_GET[$this->folder_par] > 0)
58  {
59  $this->current_folder = $_GET[$this->folder_par];
60  }
61  else if ($_SESSION["mep_pool_folder"] > 0 && $this->tree->isInTree($_SESSION["mep_pool_folder"]))
62  {
63  $this->current_folder = $_SESSION["mep_pool_folder"];
64  }
65  else
66  {
67  $this->current_folder = $this->tree->getRootId();
68  }
69  $_SESSION["mep_pool_folder"] = $this->current_folder;
70 
71  $this->addColumn("", "", "1"); // checkbox
72  $this->addColumn($lng->txt("mep_thumbnail"), "", "1");
73  $this->addColumn($lng->txt("mep_title_and_description"), "", "100%");
74  $this->setEnableHeader(true);
75  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
76  $this->setRowTemplate("tpl.mep_list_row.html", "Modules/MediaPool");
77  $this->getItems();
78 
79  // title
80  if ($this->current_folder != $this->tree->getRootId())
81  {
82  $node = $this->tree->getNodeData($this->current_folder);
83  $this->setTitle($node["title"], "icon_fold.gif",
84  $node["title"]);
85  }
86  else
87  {
88  $this->setTitle(ilObject::_lookupTitle($this->media_pool->getId()),
89  "icon_mep.gif",
90  ilObject::_lookupTitle($this->media_pool->getId()));
91  }
92 
93  // action commands
94  if ($ilAccess->checkAccess("write", "", $this->media_pool->getRefId()) &&
96  {
97  $this->addMultiCommand("copyToClipboard", $lng->txt("cont_copy_to_clipboard"));
98  $this->addMultiCommand("confirmRemove", $lng->txt("remove"));
99 
100  $this->addCommandButton("createFolderForm", $lng->txt("mep_create_folder"));
101  $this->addCommandButton("createMediaObject", $lng->txt("mep_create_mob"));
102  }
103 
105  {
106  // maybe this is a little bit to strong coupled with ilpcmediaobjectgui
107  $this->addMultiCommand("create_mob", $lng->txt("insert"));
108  $this->addCommandButton("cancelCreate", $lng->txt("cancel"));
109  }
110 
112  {
113  $this->setSelectAllCheckbox("id");
114  }
115 
116  if ($this->current_folder != $this->tree->getRootId())
117  {
118  $ilCtrl->setParameter($this->parent_obj, $this->folder_par,
119  $this->tree->getParentId($this->current_folder));
120  $this->addHeaderCommand($ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd),
121  $lng->txt("mep_parent_folder"));
122  }
123 
124  }
125 
131  function setMode($a_mode)
132  {
133  $this->mode = $a_mode;
134  }
135 
141  function getMode()
142  {
143  return $this->mode;
144  }
145 
149  function getItems()
150  {
151  $fobjs = $this->media_pool->getChilds($this->current_folder, "fold");
152  $f2objs = array();
153  foreach ($fobjs as $obj)
154  {
155  $f2objs[$obj["title"].":".$obj["id"]] = $obj;
156  }
157  ksort($f2objs);
158 
159  // get current media objects
160  $mobjs = $this->media_pool->getChilds($this->current_folder, "mob");
161  $m2objs = array();
162  foreach ($mobjs as $obj)
163  {
164  $m2objs[$obj["title"].":".$obj["id"]] = $obj;
165  }
166  ksort($m2objs);
167 
168  // merge everything together
169  $objs = array_merge($f2objs, $m2objs);
170 
171  $this->setData($objs);
172  }
173 
178  protected function fillRow($a_set)
179  {
180  global $lng, $ilCtrl, $ilAccess;
181 
182  $this->tpl->setCurrentBlock("link");
183 
184  switch($a_set["type"])
185  {
186  case "fold":
187  $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
188  $ilCtrl->setParameter($this->parent_obj, $this->folder_par, $a_set["obj_id"]);
189  $this->tpl->setVariable("LINK_VIEW",
190  $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
191  $this->tpl->parseCurrentBlock();
192 
193  if ($ilAccess->checkAccess("write", "", $this->media_pool->getRefId()) &&
195  {
196  $this->tpl->setCurrentBlock("edit");
197  $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
198  $ilCtrl->setParameterByClass("ilobjfoldergui", $this->folder_par, $a_set["obj_id"]);
199  $this->tpl->setVariable("EDIT_LINK",
200  $ilCtrl->getLinkTargetByClass("ilobjfoldergui", "edit"));
201  $this->tpl->parseCurrentBlock();
202  }
203 
204  $this->tpl->setCurrentBlock("tbl_content");
205  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_".$a_set["type"].".gif"));
206  $ilCtrl->setParameter($this->parent_obj, $this->folder_par, $this->current_folder);
207  break;
208 
209  case "mob":
211  {
212  $this->tpl->setVariable("TXT_NO_LINK_TITLE", $a_set["title"]);
213  }
214  else
215  {
216  $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
217  $this->tpl->touchBlock("nf");
218  $ilCtrl->setParameterByClass("ilobjmediaobjectgui", "obj_id", $a_set["obj_id"]);
219  $ilCtrl->setParameter($this->parent_obj, "mob_id", $a_set["obj_id"]);
220  $this->tpl->setVariable("LINK_VIEW",
221  $ilCtrl->getLinkTarget($this->parent_obj, "showMedia"));
222  }
223 
224  // edit link
225  if ($ilAccess->checkAccess("write", "", $this->media_pool->getRefId()) &&
227  {
228  $this->tpl->setCurrentBlock("edit");
229  $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
230  $this->tpl->setVariable("EDIT_LINK",
231  $ilCtrl->getLinkTargetByClass("ilobjmediaobjectgui", "edit"));
232  $this->tpl->parseCurrentBlock();
233  }
234 
235  $this->tpl->setCurrentBlock("link");
236  $this->tpl->setCurrentBlock("tbl_content");
237 
238  // output thumbnail (or mob icon)
239  $mob = new ilObjMediaObject($a_set["obj_id"]);
240  $med = $mob->getMediaItem("Standard");
241  $target = $med->getThumbnailTarget();
242  if ($target != "")
243  {
244  $this->tpl->setVariable("IMG_OBJ", $target);
245  }
246  else
247  {
248  $this->tpl->setVariable("IMG_OBJ", ilUtil::getImagePath("icon_".$a_set["type"].".gif"));
249  }
250 
251  // output media info
252  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
253  $this->tpl->setVariable("MEDIA_INFO",
255  $ilCtrl->setParameter($this->parent_obj, $this->folder_par, $this->current_folder);
256  break;
257  }
258 
259  if ($ilAccess->checkAccess("write", "", $this->media_pool->getRefId()) &&
260  ($this->getMode() == ilMediaPoolTableGUI::IL_MEP_EDIT || $a_set["type"] == "mob"))
261  {
262  $this->tpl->setCurrentBlock("chbox");
263  $this->tpl->setVariable("CHECKBOX_ID", $a_set["obj_id"]);
264  $this->tpl->parseCurrentBlock();
265  $this->tpl->setCurrentBlock("tbl_content");
266  }
267  }
268 
269 }
270 ?>