ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilBookmarkBlockGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("Services/Block/classes/class.ilBlockGUI.php");
6 
17 {
18  static $block_type = "pdbookm";
19 
23  function ilBookmarkBlockGUI()
24  {
25  global $ilCtrl, $lng, $ilUser;
26 
28 
29  $this->setImage(ilUtil::getImagePath("icon_bm_s.png"));
30  $this->setTitle($lng->txt("my_bms"));
31  $this->setEnableNumInfo(false);
32  $this->setLimit(99999);
33  $this->setAvailableDetailLevels(3);
34 
35  $this->id = (empty($_GET["bmf_id"]))
36  ? $bmf_id = 1
37  : $_GET["bmf_id"];
38  }
39 
45  static function getBlockType()
46  {
47  return self::$block_type;
48  }
49 
55  static function isRepositoryObject()
56  {
57  return false;
58  }
59 
60 
64  static function getScreenMode()
65  {
66  switch($_GET["cmd"])
67  {
68  default:
69  return IL_SCREEN_SIDE;
70  break;
71  }
72  }
73 
77  function &executeCommand()
78  {
79  global $ilCtrl;
80 
81  $next_class = $ilCtrl->getNextClass();
82  $cmd = $ilCtrl->getCmd("getHTML");
83 
84  return $this->$cmd();
85  }
86 
87  function getHTML()
88  {
89  // workaround to show details row
90  $this->setData(array("dummy"));
91 
92  if ($this->getCurrentDetailLevel() == 0)
93  {
94  return "";
95  }
96  else
97  {
98  return parent::getHTML();
99  }
100  }
101 
105  function fillDataSection()
106  {
107  global $ilUser;
108 
109  include_once("./Services/Bookmarks/classes/class.ilBookmarkFolder.php");
111  $this->num_bookmarks = $bm_items["bookmarks"];
112  $this->num_folders = $bm_items["folders"];
113 
114  if ($this->getCurrentDetailLevel() > 1 &&
115  ($this->num_bookmarks > 0 || $this->num_folders > 0))
116  {
117  if ($ilUser->getPref("il_pd_bkm_mode") == 'tree')
118  {
119  $this->setDataSection($this->getPDBookmarkListHTMLTree());
120  }
121  else
122  {
123  $this->setRowTemplate("tpl.bookmark_pd_list.html", "Services/Bookmarks");
124  $this->getListRowData();
125  $this->setColSpan(2);
127  }
128  }
129  else
130  {
131  if ($this->num_bookmarks == 0 && $this->num_folders == 0)
132  {
133  $this->setEnableDetailRow(false);
134  }
135  $this->setDataSection($this->getOverview());
136  }
137  }
138 
143  {
144  global $ilCtrl, $ilUser;
145 
146  include_once("./Services/Bookmarks/classes/class.ilBookmarkExplorer.php");
147 
148  $showdetails = ($this->getCurrentDetailLevel() > 2);
149 
150  $exp = new ilBookmarkExplorer($ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "show"),
151  $_SESSION["AccountId"]);
152  $exp->setAllowedTypes(array('dum','bmf','bm'));
153  $exp->setEnableSmallMode(true);
154  $exp->setTargetGet("bmf_id");
155  $exp->setSessionExpandVariable('mexpand');
156  $ilCtrl->setParameter($this, "bmf_id", $this->id);
157  $exp->setExpandTarget($ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "show"));
158  if ($_GET["mexpand"] == "")
159  {
160  $expanded = $this->id;
161  }
162  else
163  {
164  $expanded = $_GET["mexpand"];
165  }
166  $exp->setExpand($expanded);
167  $exp->setShowDetails($showdetails);
168 
169  // build html-output
170  $exp->setOutput(0);
171  return $exp->getOutput();
172  }
173 
177  function fillFooter()
178  {
179  global $ilCtrl, $lng, $ilUser;
180 
181  $this->setFooterLinks();
182  $this->fillFooterLinks();
183  $this->tpl->setVariable("FCOLSPAN", $this->getColSpan());
184  if ($this->tpl->blockExists("block_footer"))
185  {
186  $this->tpl->setCurrentBlock("block_footer");
187  $this->tpl->parseCurrentBlock();
188  }
189  }
190 
194  function setFooterLinks()
195  {
196  global $ilUser, $ilCtrl, $lng;
197 
198  if ($this->num_bookmarks == 0 && $this->num_folders == 0)
199  {
200  return;
201  }
202 
203  // flat
204 // if ($ilUser->getPref("il_pd_bkm_mode") == 'tree')
205 // {
206  $this->addFooterLink( $lng->txt("list"),
207  $ilCtrl->getLinkTarget($this, "setPdFlatMode"),
208  $ilCtrl->getLinkTarget($this, "setPdFlatMode",
209  "", true),
210  "block_".$this->getBlockType()."_".$this->block_id,
211  false, false, ($ilUser->getPref("il_pd_bkm_mode") != 'tree'));
212 // }
213 // else
214 // {
215 // $this->addFooterLink($lng->txt("list"));
216 // }
217 
218  // as tree
219 // if ($ilUser->getPref("il_pd_bkm_mode") == 'tree')
220 // {
221 // $this->addFooterLink($lng->txt("tree"));
222 // }
223 // else
224 // {
225  $this->addFooterLink($lng->txt("tree"),
226  $ilCtrl->getLinkTarget($this,
227  "setPdTreeMode"),
228  $ilCtrl->getLinkTarget($this,
229  "setPdTreeMode", "", true),
230  "block_".$this->getBlockType()."_".$this->block_id,
231  false, false, ($ilUser->getPref("il_pd_bkm_mode") == 'tree')
232  );
233 // }
234  }
235 
239  function getListRowData()
240  {
241  global $ilUser, $lng, $ilCtrl;
242 
243  include_once("./Services/Bookmarks/classes/class.ilBookmarkFolder.php");
244 
245  $data = array();
246 
247  $sess_cur_bm_folder = "";
248  if (isset($_SESSION["ilCurBMFolder"]))
249  {
250  $sess_cur_bm_folder = $_SESSION["ilCurBMFolder"];
251  }
252 
253  $bm_items = ilBookmarkFolder::getObjects($sess_cur_bm_folder);
254 
255  if (!ilBookmarkFolder::isRootFolder($sess_cur_bm_folder)
256  && !empty($_SESSION["ilCurBMFolder"]))
257  {
258  $ilCtrl->setParameter($this, "curBMFolder",
259  ilBookmarkFolder::_getParentId($sess_cur_bm_folder));
260 
261  $data[] = array(
262  "img" => ilUtil::getImagePath("icon_bmf_s.png"),
263  "alt" => $lng->txt("bmf"),
264  "title" => "..",
265  "link" => $ilCtrl->getLinkTarget($this, "setCurrentBookmarkFolder"));
266 
267  $this->setTitle($this->getTitle().": ".ilBookmarkFolder::_lookupTitle($sess_cur_bm_folder));
268  }
269 
270  foreach ($bm_items as $bm_item)
271  {
272  switch ($bm_item["type"])
273  {
274  case "bmf":
275  $ilCtrl->setParameter($this, "curBMFolder", $bm_item["obj_id"]);
276  $data[] = array(
277  "img" => ilUtil::getImagePath("icon_bmf_s.png"),
278  "alt" => $lng->txt("bmf"),
279  "title" => ilUtil::prepareFormOutput($bm_item["title"]),
280  "desc" => ilUtil::prepareFormOutput($bm_item["desc"]),
281  "link" => $ilCtrl->getLinkTarget($this,
282  "setCurrentBookmarkFolder"),
283  "target" => "");
284  break;
285 
286  case "bm":
287  $data[] = array(
288  "img" => ilUtil::getImagePath("spacer.png"),
289  "alt" => $lng->txt("bm"),
290  "title" => ilUtil::prepareFormOutput($bm_item["title"]),
291  "desc" => ilUtil::prepareFormOutput($bm_item["desc"]),
292  "link" => ilUtil::prepareFormOutput($bm_item["target"]),
293  "target" => "_blank");
294  break;
295  }
296  }
297 
298  $this->setData($data);
299  }
300 
304  function fillRow($a_set)
305  {
306  global $ilUser;
307 
308  $this->tpl->setVariable("IMG_BM", $a_set["img"]);
309  $this->tpl->setVariable("IMG_ALT", $a_set["alt"]);
310  $this->tpl->setVariable("BM_TITLE", $a_set["title"]);
311  $this->tpl->setVariable("BM_LINK", $a_set["link"]);
312  $this->tpl->setVariable("BM_TARGET", ilUtil::prepareFormOutput($a_set["target"]));
313 
314  if ($this->getCurrentDetailLevel() > 2)
315  {
316  $this->tpl->setVariable("BM_DESCRIPTION", ilUtil::prepareFormOutput($a_set["desc"]));
317  }
318  else
319  {
320  $this->tpl->setVariable("BM_TOOLTIP", ilUtil::prepareFormOutput($a_set["desc"]));
321  }
322  }
323 
327  function getOverview()
328  {
329  global $ilUser, $lng, $ilCtrl;
330 
331  return '<div class="small">'.$this->num_bookmarks." ".$lng->txt("bm_num_bookmarks").", ".
332  $this->num_folders." ".$lng->txt("bm_num_bookmark_folders")."</div>";
333  }
334 
338  function setPdFlatMode()
339  {
340  global $ilCtrl, $ilUser;
341 
342  $ilUser->writePref("il_pd_bkm_mode", 'flat');
343  if ($ilCtrl->isAsynch())
344  {
345  echo $this->getHTML();
346  exit;
347  }
348  else
349  {
350  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
351  }
352  }
353 
357  function setPdTreeMode()
358  {
359  global $ilCtrl, $ilUser;
360 
361  $ilUser->writePref("il_pd_bkm_mode", 'tree');
362  if ($ilCtrl->isAsynch())
363  {
364  echo $this->getHTML();
365  exit;
366  }
367  else
368  {
369  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
370  }
371  }
372 
377  {
378  global $ilCtrl;
379 
380  $_SESSION["ilCurBMFolder"] = $_GET["curBMFolder"];
381  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
382  }
383 
384 }
385 
386 ?>