ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 public static $block_type = "pdbookm";
19
23 public function __construct()
24 {
25 global $DIC;
26
27 $this->ctrl = $DIC->ctrl();
28 $this->lng = $DIC->language();
29 $this->user = $DIC->user();
30 $lng = $DIC->language();
31
32 parent::__construct();
33
34 $this->setImage(ilUtil::getImagePath("icon_bm.svg"));
35 $this->setTitle($lng->txt("my_bms"));
36 $this->setEnableNumInfo(false);
37 $this->setLimit(99999);
39
40 $this->id = (empty($_GET["bmf_id"]))
41 ? $bmf_id = 1
42 : $_GET["bmf_id"];
43 }
44
48 public function getBlockType() : string
49 {
50 return self::$block_type;
51 }
52
56 protected function isRepositoryObject() : bool
57 {
58 return false;
59 }
60
61
65 public static function getScreenMode()
66 {
67 switch ($_GET["cmd"]) {
68 default:
69 return IL_SCREEN_SIDE;
70 break;
71 }
72 }
73
77 public function executeCommand()
78 {
80
81 $next_class = $ilCtrl->getNextClass();
82 $cmd = $ilCtrl->getCmd("getHTML");
83
84 return $this->$cmd();
85 }
86
87 public function getHTML()
88 {
89 // workaround to show details row
90 $this->setData(array("dummy"));
91 if ($this->getCurrentDetailLevel() == 0) {
92 return "";
93 } else {
94 return parent::getHTML();
95 }
96 }
97
101 public function fillDataSection()
102 {
104
105 include_once("./Services/Bookmarks/classes/class.ilBookmarkFolder.php");
107 $this->num_bookmarks = $bm_items["bookmarks"];
108 $this->num_folders = $bm_items["folders"];
109
110 if ($this->getCurrentDetailLevel() > 1 &&
111 ($this->num_bookmarks > 0 || $this->num_folders > 0)) {
112 if ($ilUser->getPref("il_pd_bkm_mode") == 'tree') {
114 } else {
115 $this->setRowTemplate("tpl.bookmark_pd_list.html", "Services/Bookmarks");
116 $this->getListRowData();
117 $this->setColSpan(2);
118 parent::fillDataSection();
119 }
120 } else {
121 if ($this->num_bookmarks == 0 && $this->num_folders == 0) {
122 $this->setEnableDetailRow(false);
123 }
124 $this->setDataSection($this->getOverview());
125 }
126 }
127
132 {
135
136 include_once("./Services/Bookmarks/classes/class.ilBookmarkBlockExplorerGUI.php");
137 $exp = new ilBookmarkBlockExplorerGUI($this, "getPDBookmarkListHTMLTree");
138 if (!$exp->handleCommand()) {
139 return "<div id='tree_div'>" . $exp->getHTML() . "</div>";
140 }
141 }
142
146 public function fillFooter()
147 {
148 $this->setFooterLinks();
149 $this->fillFooterLinks();
150 $this->tpl->setVariable("FCOLSPAN", $this->getColSpan());
151 if ($this->tpl->blockExists("block_footer")) {
152 $this->tpl->setCurrentBlock("block_footer");
153 $this->tpl->parseCurrentBlock();
154 }
155 }
156
160 public function setFooterLinks()
161 {
165
166 if ($this->num_bookmarks == 0 && $this->num_folders == 0) {
167 return;
168 }
169
170 // flat
171 $this->addFooterLink(
172 $lng->txt("list"),
173 $ilCtrl->getLinkTarget($this, "setPdFlatMode"),
174 $ilCtrl->getLinkTarget(
175 $this,
176 "setPdFlatMode",
177 "",
178 true
179 ),
180 "block_" . $this->getBlockType() . "_" . $this->block_id,
181 false,
182 false,
183 ($ilUser->getPref("il_pd_bkm_mode") != 'tree')
184 );
185
186 // as tree
187 $this->addFooterLink(
188 $lng->txt("tree"),
189 $ilCtrl->getLinkTarget(
190 $this,
191 "setPdTreeMode"
192 ),
193 "",
194 "block_" . $this->getBlockType() . "_" . $this->block_id,
195 false,
196 false,
197 ($ilUser->getPref("il_pd_bkm_mode") == 'tree')
198 );
199 }
200
204 public function getListRowData()
205 {
209
210 include_once("./Services/Bookmarks/classes/class.ilBookmarkFolder.php");
211
212 $data = array();
213
214 $sess_cur_bm_folder = "";
215 if (isset($_SESSION["ilCurBMFolder"])) {
216 $sess_cur_bm_folder = $_SESSION["ilCurBMFolder"];
217 }
218
219 $bm_items = ilBookmarkFolder::getObjects($sess_cur_bm_folder);
220
221 if (!ilBookmarkFolder::isRootFolder($sess_cur_bm_folder)
222 && !empty($_SESSION["ilCurBMFolder"])) {
223 $ilCtrl->setParameter(
224 $this,
225 "curBMFolder",
226 ilBookmarkFolder::_getParentId($sess_cur_bm_folder)
227 );
228
229 $data[] = array(
230 "img" => ilUtil::getImagePath("icon_bmf.svg"),
231 "alt" => $lng->txt("bmf"),
232 "title" => "..",
233 "link" => $ilCtrl->getLinkTarget($this, "setCurrentBookmarkFolder"));
234
235 $this->setTitle($this->getTitle() . ": " . ilBookmarkFolder::_lookupTitle($sess_cur_bm_folder));
236 }
237
238 foreach ($bm_items as $bm_item) {
239 switch ($bm_item["type"]) {
240 case "bmf":
241 $ilCtrl->setParameter($this, "curBMFolder", $bm_item["obj_id"]);
242 $data[] = array(
243 "img" => ilUtil::getImagePath("icon_bmf.svg"),
244 "alt" => $lng->txt("bmf"),
245 "title" => ilUtil::prepareFormOutput($bm_item["title"]),
246 "desc" => ilUtil::prepareFormOutput($bm_item["desc"]),
247 "link" => $ilCtrl->getLinkTarget(
248 $this,
249 "setCurrentBookmarkFolder"
250 ),
251 "target" => "");
252 break;
253
254 case "bm":
255 $data[] = array(
256 "img" => ilUtil::getImagePath("spacer.png"),
257 "alt" => $lng->txt("bm"),
258 "title" => ilUtil::prepareFormOutput($bm_item["title"]),
259 "desc" => ilUtil::prepareFormOutput($bm_item["desc"]),
260 "link" => ilUtil::prepareFormOutput($bm_item["target"]),
261 "rel" => "noopener",
262 "target" => "_blank");
263 break;
264 }
265 }
266
267 $this->setData($data);
268 }
269
273 public function fillRow($a_set)
274 {
276
277 $this->tpl->setVariable("IMG_BM", $a_set["img"]);
278 $this->tpl->setVariable("IMG_ALT", $a_set["alt"]);
279 $this->tpl->setVariable("BM_TITLE", $a_set["title"]);
280 $this->tpl->setVariable("BM_LINK", $a_set["link"]);
281 $this->tpl->setVariable("BM_TARGET", ilUtil::prepareFormOutput($a_set["target"]));
282 if (isset($a_set['rel'])) {
283 $this->tpl->setVariable("BM_REL", $a_set['rel']);
284 }
285
286 if ($this->getCurrentDetailLevel() > 2) {
287 $this->tpl->setVariable("BM_DESCRIPTION", ilUtil::prepareFormOutput($a_set["desc"]));
288 } else {
289 $this->tpl->setVariable("BM_TOOLTIP", ilUtil::prepareFormOutput($a_set["desc"]));
290 }
291 }
292
296 public function getOverview()
297 {
301
302 return '<div class="small">' . $this->num_bookmarks . " " . $lng->txt("bm_num_bookmarks") . ", " .
303 $this->num_folders . " " . $lng->txt("bm_num_bookmark_folders") . "</div>";
304 }
305
309 public function setPdFlatMode()
310 {
313
314 $ilUser->writePref("il_pd_bkm_mode", 'flat');
315 if ($ilCtrl->isAsynch()) {
316 echo $this->getHTML();
317 exit;
318 } else {
319 $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
320 }
321 }
322
326 public function setPdTreeMode()
327 {
330
331 $ilUser->writePref("il_pd_bkm_mode", 'tree');
332 if ($ilCtrl->isAsynch()) {
333 echo $this->getHTML();
334 exit;
335 } else {
336 $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
337 }
338 }
339
343 public function setCurrentBookmarkFolder()
344 {
346
347 $_SESSION["ilCurBMFolder"] = $_GET["curBMFolder"];
348 $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
349 }
350}
user()
Definition: user.php:4
exit
Definition: backend.php:16
$_GET["client_id"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
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.
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.
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.
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).
fillRow($a_set)
get flat bookmark list for personal desktop
setCurrentBookmarkFolder()
set current bookmarkfolder on personal desktop
isRepositoryObject()
Returns whether block has a corresponding repository object.bool
executeCommand()
execute command
getPDBookmarkListHTMLTree()
get tree bookmark list for personal desktop
setPdFlatMode()
set current desktop view mode to flat
static getScreenMode()
Get Screen Mode for current command.
static _getNumberOfObjects()
Get number of folders and bookmarks for current user.
static _lookupTitle($a_bmf_id)
lookup bookmark folder title
static getObjects($a_id)
static
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
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18