ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPermanentLinkGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
18 {
19  protected $align_center = true;
20 
24  function __construct($a_type, $a_id, $a_append = "", $a_target = "")
25  {
26  $this->setType($a_type);
27  $this->setId($a_id);
28  $this->setAppend($a_append);
29  $this->setIncludePermanentLinkText(true);
30  $this->setTarget($a_target);
31  }
32 
38  function setIncludePermanentLinkText($a_includepermanentlinktext)
39  {
40  $this->includepermanentlinktext = $a_includepermanentlinktext;
41  }
42 
49  {
50  return $this->includepermanentlinktext;
51  }
52 
58  function setType($a_type)
59  {
60  $this->type = $a_type;
61  }
62 
68  function getType()
69  {
70  return $this->type;
71  }
72 
78  function setId($a_id)
79  {
80  $this->id = $a_id;
81  }
82 
88  function getId()
89  {
90  return $this->id;
91  }
92 
98  function setAppend($a_append)
99  {
100  $this->append = $a_append;
101  }
102 
108  function getAppend()
109  {
110  return $this->append;
111  }
112 
118  function setTarget($a_target)
119  {
120  $this->target = $a_target;
121  }
122 
128  function getTarget()
129  {
130  return $this->target;
131  }
132 
138  function setTitle($a_val)
139  {
140  $this->title = $a_val;
141  }
142 
148  function getTitle()
149  {
150  return $this->title;
151  }
152 
158  function setAlignCenter($a_val)
159  {
160  $this->align_center = $a_val;
161  }
162 
168  function getAlignCenter()
169  {
170  return $this->align_center;
171  }
172 
176  function getHTML()
177  {
178  global $lng, $ilCtrl, $ilObjDataCache;
179 
180  $tpl = new ilTemplate("tpl.permanent_link.html", true, true,
181  "Services/PermanentLink");
182 
183  include_once('./Services/Link/classes/class.ilLink.php');
184  $href = ilLink::_getStaticLink($this->getId(), $this->getType(),
185  true, $this->getAppend());
186  if ($this->getIncludePermanentLinkText())
187  {
188  $tpl->setVariable("TXT_PERMA", $lng->txt("perma_link").":");
189  }
190 
191  $title = '';
192 
193  // fetch default title for bookmark
194 
195  if ($this->getTitle() != "")
196  {
197  $title = $this->getTitle();
198  }
199  else
200  {
201  $obj_id = $ilObjDataCache->lookupObjId($this->getId());
202  $title = $ilObjDataCache->lookupTitle($obj_id);
203  }
204  #if (!$title)
205  # $bookmark->setTitle("untitled");
206 
207  $tpl->setVariable("TXT_BOOKMARK_DEFAULT", $title);
208 
209  $tpl->setVariable("LINK", $href);
210 
211  if ($this->getAlignCenter())
212  {
213  $tpl->setVariable("ALIGN", "center");
214  }
215  else
216  {
217  $tpl->setVariable("ALIGN", "left");
218  }
219 
220  if ($this->getTarget() != "")
221  {
222  $tpl->setVariable("TARGET", 'target="'.$this->getTarget().'"');
223  }
224 
225 
226  // bookmark links
227  $bm_html = self::_getBookmarksSelectionList($title, $href);
228 
229  if ($bm_html)
230  {
231  $tpl->setVariable('SELECTION_LIST', $bm_html);
232  }
233 
234  return $tpl->get();
235  }
236 
237 
242  public static function _getBookmarksSelectionList($title, $href)
243  {
244  global $ilDB, $lng, $ilSetting;
245 
246  require_once 'Services/PermanentLink/classes/class.ilPermanentLink.php';
247 
248  // social bookmarkings
249 
251 
252  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
253 
254  $current_selection_list = new ilAdvancedSelectionListGUI();
255  //$current_selection_list->setListTitle($lng->txt("bm_add_to_social_bookmarks"));
256  $current_selection_list->setId("socialbm_actions");
257  $current_selection_list->setUseImages(true);
258 
259  $cnt = 0;
260 
261  if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID && !$ilSetting->get('disable_bookmarks'))
262  {
263  $linktpl = 'ilias.php?cmd=redirect&baseClass=ilPersonalDesktopGUI&redirectClass=ilbookmarkadministrationgui&redirectCmd=newFormBookmark&param_bmf_id=1&param_return_to=true&param_bm_title='. urlencode(urlencode($title)) . '&param_bm_link=' . urlencode(urlencode($href))."&param_return_to_url=".urlencode(urlencode($_SERVER['REQUEST_URI']));
264  $current_selection_list->addItem($lng->txt("bm_add_to_ilias"), '', $linktpl, ilUtil::getImagePath('socialbookmarks/icon_bm_15x15.gif') , $lng->txt("bm_add_to_ilias"), '_top');
265  $cnt++;
266  }
267 
268  foreach ($rset as $row)
269  {
270  $linktpl = $row->sbm_link;
271  $linktpl = str_replace('{LINK}', urlencode($href), $linktpl);
272  $linktpl = str_replace('{TITLE}', urlencode($title), $linktpl);
273  $current_selection_list->addItem($row->sbm_title, '', $linktpl, $row->sbm_icon, $row->title, '_blank');
274  $cnt++;
275  }
276 
277  if ($cnt == 1 && $_SESSION["AccountId"] != ANONYMOUS_USER_ID && !$ilSetting->get('disable_bookmarks'))
278  {
279  $loc_tpl = new ilTemplate('tpl.single_link.html', true, true, 'Services/PermanentLink');
280  $loc_tpl->setVariable("TXT_ADD_TO_ILIAS_BM", $lng->txt("bm_add_to_ilias"));
281  $loc_tpl->setVariable("URL_ADD_TO_BM", 'ilias.php?cmd=redirect&baseClass=ilPersonalDesktopGUI&redirectClass=ilbookmarkadministrationgui&redirectCmd=newFormBookmark&param_bmf_id=1&param_return_to=true&param_bm_title='. urlencode(urlencode($title)) . '&param_bm_link=' . urlencode(urlencode($href))."&param_return_to_url=".urlencode(urlencode($_SERVER['REQUEST_URI'])));
282  $loc_tpl->setVariable("ICON", ilUtil::getImagePath('icon_bm.svg'));
283  return $loc_tpl->get();
284  }
285  else if ($cnt >= 1)
286  {
287  return $current_selection_list->getHTML();
288  }
289  else
290  return '';
291 
292  }
293 }
294 
295 ?>