ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
5include_once("Services/Block/classes/class.ilBlockGUI.php");
6
17{
18 static $block_type = "pdbookm";
19
24 {
25 global $ilCtrl, $lng, $ilUser;
26
27 parent::ilBlockGUI();
28
29 $this->setImage(ilUtil::getImagePath("icon_bm.svg"));
30 $this->setTitle($lng->txt("my_bms"));
31 $this->setEnableNumInfo(false);
32 $this->setLimit(99999);
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
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 {
119 }
120 else
121 {
122 $this->setRowTemplate("tpl.bookmark_pd_list.html", "Services/Bookmarks");
123 $this->getListRowData();
124 $this->setColSpan(2);
125 parent::fillDataSection();
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.svg"),
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.svg"),
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 "rel" => "noopener",
258 "target" => "_blank");
259 break;
260 }
261 }
262
263 $this->setData($data);
264 }
265
269 function fillRow($a_set)
270 {
271 global $ilUser;
272
273 $this->tpl->setVariable("IMG_BM", $a_set["img"]);
274 $this->tpl->setVariable("IMG_ALT", $a_set["alt"]);
275 $this->tpl->setVariable("BM_TITLE", $a_set["title"]);
276 $this->tpl->setVariable("BM_LINK", $a_set["link"]);
277 $this->tpl->setVariable("BM_TARGET", ilUtil::prepareFormOutput($a_set["target"]));
278 if (isset($a_set['rel'])) {
279 $this->tpl->setVariable("BM_REL", $a_set['rel']);
280 }
281
282 if ($this->getCurrentDetailLevel() > 2)
283 {
284 $this->tpl->setVariable("BM_DESCRIPTION", ilUtil::prepareFormOutput($a_set["desc"]));
285 }
286 else
287 {
288 $this->tpl->setVariable("BM_TOOLTIP", ilUtil::prepareFormOutput($a_set["desc"]));
289 }
290 }
291
295 function getOverview()
296 {
297 global $ilUser, $lng, $ilCtrl;
298
299 return '<div class="small">'.$this->num_bookmarks." ".$lng->txt("bm_num_bookmarks").", ".
300 $this->num_folders." ".$lng->txt("bm_num_bookmark_folders")."</div>";
301 }
302
306 function setPdFlatMode()
307 {
308 global $ilCtrl, $ilUser;
309
310 $ilUser->writePref("il_pd_bkm_mode", 'flat');
311 if ($ilCtrl->isAsynch())
312 {
313 echo $this->getHTML();
314 exit;
315 }
316 else
317 {
318 $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
319 }
320 }
321
325 function setPdTreeMode()
326 {
327 global $ilCtrl, $ilUser;
328
329 $ilUser->writePref("il_pd_bkm_mode", 'tree');
330 if ($ilCtrl->isAsynch())
331 {
332 echo $this->getHTML();
333 exit;
334 }
335 else
336 {
337 $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
338 }
339 }
340
345 {
346 global $ilCtrl;
347
348 $_SESSION["ilCurBMFolder"] = $_GET["curBMFolder"];
349 $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
350 }
351
352}
353
354?>
$_GET["client_id"]
$_SESSION["AccountId"]
const IL_SCREEN_SIDE
This class represents a block method of a block.
setRowTemplate($a_rowtemplatename, $a_rowtemplatedir="")
Set Row Template Name.
setLimit($a_limit)
Set Limit.
setImage($a_image)
Set Image.
getCurrentDetailLevel()
Get Current Detail Level.
setAvailableDetailLevels($a_max, $a_min=0)
Set Available Detail Levels.
setEnableDetailRow($a_enabledetailrow)
Set EnableDetailRow.
setData($a_data)
Set Data.
fillFooterLinks($a_top=false, $a_numinfo="")
Fill footer links.
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
getTitle()
Get Title.
addFooterLink($a_text, $a_href="", $a_onclick="", $a_block_id="", $a_top=false, $a_omit_separator=false, $a_checked=false)
Add a footer text/link.
setColSpan($a_colspan)
Set Columns Span.
setTitle($a_title)
Set Title.
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
getColSpan()
Get Columns Span.
Bookmark block explorer GUI class.
BlockGUI class for Bookmarks block.
setFooterLinks()
Set footer links.
fillDataSection()
Fill data section.
setPdTreeMode()
set current desktop view mode to tree
getHTML()
Handle config status.
getListRowData()
Get list data (for flat list).
static isRepositoryObject()
Is block used in repository object?
fillRow($a_set)
get flat bookmark list for personal desktop
static getBlockType()
Get block type.
setCurrentBookmarkFolder()
set current bookmarkfolder on personal desktop
getPDBookmarkListHTMLTree()
get tree bookmark list for personal desktop
setPdFlatMode()
set current desktop view mode to flat
& executeCommand()
execute command
static getScreenMode()
Get Screen Mode for current command.
_lookupTitle($a_bmf_id)
lookup bookmark folder title
_getNumberOfObjects()
Get number of folders and bookmarks for current user.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:54
global $lng
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
global $ilUser
Definition: imgupload.php:15