ILIAS  eassessment Revision 61809
 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 
21  function __construct($a_type, $a_id, $a_append = "", $a_target = "")
22  {
23  $this->setType($a_type);
24  $this->setId($a_id);
25  $this->setAppend($a_append);
26  $this->setIncludePermanentLinkText(true);
27  $this->setTarget($a_target);
28  }
29 
35  function setIncludePermanentLinkText($a_includepermanentlinktext)
36  {
37  $this->includepermanentlinktext = $a_includepermanentlinktext;
38  }
39 
46  {
47  return $this->includepermanentlinktext;
48  }
49 
55  function setType($a_type)
56  {
57  $this->type = $a_type;
58  }
59 
65  function getType()
66  {
67  return $this->type;
68  }
69 
75  function setId($a_id)
76  {
77  $this->id = $a_id;
78  }
79 
85  function getId()
86  {
87  return $this->id;
88  }
89 
95  function setAppend($a_append)
96  {
97  $this->append = $a_append;
98  }
99 
105  function getAppend()
106  {
107  return $this->append;
108  }
109 
115  function setTarget($a_target)
116  {
117  $this->target = $a_target;
118  }
119 
125  function getTarget()
126  {
127  return $this->target;
128  }
129 
135  function setTitle($a_val)
136  {
137  $this->title = $a_val;
138  }
139 
145  function getTitle()
146  {
147  return $this->title;
148  }
149 
155  function setAlignCenter($a_val)
156  {
157  $this->align_center = $a_val;
158  }
159 
165  function getAlignCenter()
166  {
167  return $this->align_center;
168  }
169 
173  function getHTML()
174  {
175  global $lng, $ilCtrl, $ilObjDataCache;
176 
177  $tpl = new ilTemplate("tpl.permanent_link.html", true, true,
178  "Services/PermanentLink");
179 
180  include_once('classes/class.ilLink.php');
181  $href = ilLink::_getStaticLink($this->getId(), $this->getType(),
182  true, $this->getAppend());
183  if ($this->getIncludePermanentLinkText())
184  {
185  $tpl->setVariable("TXT_PERMA", $lng->txt("perma_link").":");
186  }
187 
188  $title = '';
189 
190  // fetch default title for bookmark
191 
192  if ($this->getTitle() != "")
193  {
194  $title = $this->getTitle();
195  }
196  else
197  {
198  $obj_id = $ilObjDataCache->lookupObjId($this->getId());
199  $title = $ilObjDataCache->lookupTitle($obj_id);
200  }
201  #if (!$title)
202  # $bookmark->setTitle("untitled");
203 
204  $tpl->setVariable("TXT_BOOKMARK_DEFAULT", $title);
205 
206  $tpl->setVariable("LINK", $href);
207 
208  if ($this->getAlignCenter())
209  {
210  $tpl->setVariable("ALIGN", "center");
211  }
212  else
213  {
214  $tpl->setVariable("ALIGN", "left");
215  }
216 
217  if ($this->getTarget() != "")
218  {
219  $tpl->setVariable("TARGET", 'target="'.$this->getTarget().'"');
220  }
221 
222 
223  // bookmark links
224  $bm_html = self::_getBookmarksSelectionList($title, $href);
225 
226  if ($bm_html)
227  {
228  $tpl->setVariable('SELECTION_LIST', $bm_html);
229  }
230 
231  return $tpl->get();
232  }
233 
234 
239  public static function _getBookmarksSelectionList($title, $href)
240  {
241  global $ilDB, $lng, $ilSetting;
242 
243  require_once 'Services/PermanentLink/classes/class.ilPermanentLink.php';
244 
245  // social bookmarkings
246 
248 
249  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
250 
251  $current_selection_list = new ilAdvancedSelectionListGUI();
252  $current_selection_list->setListTitle($lng->txt("bm_add_to_social_bookmarks"));
253  $current_selection_list->setId("socialbm_actions");
254  $current_selection_list->setUseImages(true);
255 
256  $cnt = 0;
257 
258  if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID && !$ilSetting->get('disable_bookmarks'))
259  {
260  $linktpl = 'ilias.php?cmd=redirect&baseClass=ilPersonalDesktopGUI&redirectClass=ilbookmarkadministrationgui&redirectCmd=newFormBookmark&param_bmf_id=1&param_return_to=true&param_bm_title='. urlencode($title) . '&param_bm_link=' . urlencode(urlencode($href))."&param_return_to_url=".urlencode(urlencode($_SERVER['REQUEST_URI']));
261  $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');
262  $cnt++;
263  }
264 
265  foreach ($rset as $row)
266  {
267  $linktpl = $row->sbm_link;
268  $linktpl = str_replace('{LINK}', urlencode($href), $linktpl);
269  $linktpl = str_replace('{TITLE}', urlencode($title), $linktpl);
270  $current_selection_list->addItem($row->sbm_title, '', $linktpl, $row->sbm_icon, $row->title, '_blank');
271  $cnt++;
272  }
273 
274  if ($cnt == 1 && $_SESSION["AccountId"] != ANONYMOUS_USER_ID && !$ilSetting->get('disable_bookmarks'))
275  {
276  $loc_tpl = new ilTemplate('tpl.single_link.html', true, true, 'Services/PermanentLink');
277  $loc_tpl->setVariable("TXT_ADD_TO_ILIAS_BM", $lng->txt("bm_add_to_ilias"));
278  $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($title) . '&param_bm_link=' . urlencode(urlencode($href))."&param_return_to_url=".urlencode(urlencode($_SERVER['REQUEST_URI'])));
279  $loc_tpl->setVariable("ICON", ilUtil::getImagePath('icon_bm.gif'));
280  return $loc_tpl->get();
281  }
282  else if ($cnt >= 1)
283  {
284  return $current_selection_list->getHTML();
285  }
286  else
287  return '';
288 
289  }
290 }
291 
292 ?>