ILIAS  Release_4_4_x_branch Revision 61816
 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  if ($this->getCurrentDetailLevel() == 0)
92  {
93  return "";
94  }
95  else
96  {
97  return parent::getHTML();
98  }
99  }
100 
104  function fillDataSection()
105  {
106  global $ilUser;
107 
108  include_once("./Services/Bookmarks/classes/class.ilBookmarkFolder.php");
110  $this->num_bookmarks = $bm_items["bookmarks"];
111  $this->num_folders = $bm_items["folders"];
112 
113  if ($this->getCurrentDetailLevel() > 1 &&
114  ($this->num_bookmarks > 0 || $this->num_folders > 0))
115  {
116  if ($ilUser->getPref("il_pd_bkm_mode") == 'tree')
117  {
118  $this->setDataSection($this->getPDBookmarkListHTMLTree());
119  }
120  else
121  {
122  $this->setRowTemplate("tpl.bookmark_pd_list.html", "Services/Bookmarks");
123  $this->getListRowData();
124  $this->setColSpan(2);
126  }
127  }
128  else
129  {
130  if ($this->num_bookmarks == 0 && $this->num_folders == 0)
131  {
132  $this->setEnableDetailRow(false);
133  }
134  $this->setDataSection($this->getOverview());
135  }
136  }
137 
142  {
143  global $ilCtrl, $ilUser;
144 
145  include_once("./Services/Bookmarks/classes/class.ilBookmarkBlockExplorerGUI.php");
146  $exp = new ilBookmarkBlockExplorerGUI($this, "getPDBookmarkListHTMLTree");
147  if (!$exp->handleCommand())
148  {
149  return "<div id='tree_div'>".$exp->getHTML()."</div>";
150  }
151  }
152 
156  function fillFooter()
157  {
158  global $ilCtrl, $lng, $ilUser;
159 
160  $this->setFooterLinks();
161  $this->fillFooterLinks();
162  $this->tpl->setVariable("FCOLSPAN", $this->getColSpan());
163  if ($this->tpl->blockExists("block_footer"))
164  {
165  $this->tpl->setCurrentBlock("block_footer");
166  $this->tpl->parseCurrentBlock();
167  }
168  }
169 
173  function setFooterLinks()
174  {
175  global $ilUser, $ilCtrl, $lng;
176 
177  if ($this->num_bookmarks == 0 && $this->num_folders == 0)
178  {
179  return;
180  }
181 
182  // flat
183  $this->addFooterLink( $lng->txt("list"),
184  $ilCtrl->getLinkTarget($this, "setPdFlatMode"),
185  $ilCtrl->getLinkTarget($this, "setPdFlatMode",
186  "", true),
187  "block_".$this->getBlockType()."_".$this->block_id,
188  false, false, ($ilUser->getPref("il_pd_bkm_mode") != 'tree'));
189 
190  // as tree
191  $this->addFooterLink($lng->txt("tree"),
192  $ilCtrl->getLinkTarget($this,
193  "setPdTreeMode"),
194  "",
195  "block_".$this->getBlockType()."_".$this->block_id,
196  false, false, ($ilUser->getPref("il_pd_bkm_mode") == 'tree')
197  );
198  }
199 
203  function getListRowData()
204  {
205  global $ilUser, $lng, $ilCtrl;
206 
207  include_once("./Services/Bookmarks/classes/class.ilBookmarkFolder.php");
208 
209  $data = array();
210 
211  $sess_cur_bm_folder = "";
212  if (isset($_SESSION["ilCurBMFolder"]))
213  {
214  $sess_cur_bm_folder = $_SESSION["ilCurBMFolder"];
215  }
216 
217  $bm_items = ilBookmarkFolder::getObjects($sess_cur_bm_folder);
218 
219  if (!ilBookmarkFolder::isRootFolder($sess_cur_bm_folder)
220  && !empty($_SESSION["ilCurBMFolder"]))
221  {
222  $ilCtrl->setParameter($this, "curBMFolder",
223  ilBookmarkFolder::_getParentId($sess_cur_bm_folder));
224 
225  $data[] = array(
226  "img" => ilUtil::getImagePath("icon_bmf_s.png"),
227  "alt" => $lng->txt("bmf"),
228  "title" => "..",
229  "link" => $ilCtrl->getLinkTarget($this, "setCurrentBookmarkFolder"));
230 
231  $this->setTitle($this->getTitle().": ".ilBookmarkFolder::_lookupTitle($sess_cur_bm_folder));
232  }
233 
234  foreach ($bm_items as $bm_item)
235  {
236  switch ($bm_item["type"])
237  {
238  case "bmf":
239  $ilCtrl->setParameter($this, "curBMFolder", $bm_item["obj_id"]);
240  $data[] = array(
241  "img" => ilUtil::getImagePath("icon_bmf_s.png"),
242  "alt" => $lng->txt("bmf"),
243  "title" => ilUtil::prepareFormOutput($bm_item["title"]),
244  "desc" => ilUtil::prepareFormOutput($bm_item["desc"]),
245  "link" => $ilCtrl->getLinkTarget($this,
246  "setCurrentBookmarkFolder"),
247  "target" => "");
248  break;
249 
250  case "bm":
251  $data[] = array(
252  "img" => ilUtil::getImagePath("spacer.png"),
253  "alt" => $lng->txt("bm"),
254  "title" => ilUtil::prepareFormOutput($bm_item["title"]),
255  "desc" => ilUtil::prepareFormOutput($bm_item["desc"]),
256  "link" => ilUtil::prepareFormOutput($bm_item["target"]),
257  "target" => "_blank");
258  break;
259  }
260  }
261 
262  $this->setData($data);
263  }
264 
268  function fillRow($a_set)
269  {
270  global $ilUser;
271 
272  $this->tpl->setVariable("IMG_BM", $a_set["img"]);
273  $this->tpl->setVariable("IMG_ALT", $a_set["alt"]);
274  $this->tpl->setVariable("BM_TITLE", $a_set["title"]);
275  $this->tpl->setVariable("BM_LINK", $a_set["link"]);
276  $this->tpl->setVariable("BM_TARGET", ilUtil::prepareFormOutput($a_set["target"]));
277 
278  if ($this->getCurrentDetailLevel() > 2)
279  {
280  $this->tpl->setVariable("BM_DESCRIPTION", ilUtil::prepareFormOutput($a_set["desc"]));
281  }
282  else
283  {
284  $this->tpl->setVariable("BM_TOOLTIP", ilUtil::prepareFormOutput($a_set["desc"]));
285  }
286  }
287 
291  function getOverview()
292  {
293  global $ilUser, $lng, $ilCtrl;
294 
295  return '<div class="small">'.$this->num_bookmarks." ".$lng->txt("bm_num_bookmarks").", ".
296  $this->num_folders." ".$lng->txt("bm_num_bookmark_folders")."</div>";
297  }
298 
302  function setPdFlatMode()
303  {
304  global $ilCtrl, $ilUser;
305 
306  $ilUser->writePref("il_pd_bkm_mode", 'flat');
307  if ($ilCtrl->isAsynch())
308  {
309  echo $this->getHTML();
310  exit;
311  }
312  else
313  {
314  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
315  }
316  }
317 
321  function setPdTreeMode()
322  {
323  global $ilCtrl, $ilUser;
324 
325  $ilUser->writePref("il_pd_bkm_mode", 'tree');
326  if ($ilCtrl->isAsynch())
327  {
328  echo $this->getHTML();
329  exit;
330  }
331  else
332  {
333  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
334  }
335  }
336 
341  {
342  global $ilCtrl;
343 
344  $_SESSION["ilCurBMFolder"] = $_GET["curBMFolder"];
345  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
346  }
347 
348 }
349 
350 ?>