ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilDclLinkButton.php
Go to the documentation of this file.
1 <?php
2 
9 {
11  protected $attributes;
12  protected $useWrapper = false;
13 
14 
18  public function isUseWrapper()
19  {
20  return $this->useWrapper;
21  }
22 
23 
27  public function setUseWrapper($useWrapper)
28  {
29  $this->useWrapper = $useWrapper;
30  }
31 
32 
33  public static function getInstance()
34  {
35  return new self(self::TYPE_DATACOLLECTION_LINK);
36  }
37 
38 
39  public function prepareRender()
40  {
41  parent::prepareRender();
42 
43  $this->addAttribute('href', ($this->getUrl() ? $this->getUrl() : "#"));
44  $this->addAttribute('target', $this->getTarget());
45  }
46 
47 
48  public function render()
49  {
50  $this->prepareRender();
51 
52  $output = '';
53  if ($this->useWrapper) {
54  $output .= '<div' . $this->renderAttributesHelper($this->attributes['wrapper']) . '>';
55  }
56 
57  $output .= '<a' . $this->renderAttributes($this->attributes['default']) . '>' . $this->renderCaption() . '</a>';
58 
59  if ($this->useWrapper) {
60  $output .= '</div>';
61  }
62 
63  return $output;
64  }
65 
66 
67  public function addAttribute($key, $value, $wrapper = false)
68  {
69  $this->attributes[$this->getGroupKey($wrapper)][$key] = $value;
70  }
71 
72 
73  public function removeAttribute($key, $wrapper = false)
74  {
75  if (isset($this->attributes[$this->getGroupKey($wrapper)][$key])) {
76  unset($this->attributes[$this->getGroupKey($wrapper)][$key]);
77 
78  return true;
79  }
80 
81  return false;
82  }
83 
84 
85  public function getAttribute($key, $wrapper = false)
86  {
87  if (isset($this->attributes[$this->getGroupKey($wrapper)][$key])) {
88  return $this->attributes[$this->getGroupKey($wrapper)][$key];
89  }
90 
91  return null;
92  }
93 
94 
95  protected function getGroupKey($wrapper)
96  {
97  return ($wrapper) ? 'wrapper' : 'default';
98  }
99 }
removeAttribute($key, $wrapper=false)
renderAttributesHelper(array $a_attr)
Render HTML node attributes.
renderAttributes(array $a_additional_attr=null)
renderCaption()
Prepare caption for render.
addAttribute($key, $value, $wrapper=false)
getAttribute($key, $wrapper=false)
setUseWrapper($useWrapper)
getTarget()
Get target.
$key
Definition: croninfo.php:18