ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilDclLinkButton.php
Go to the documentation of this file.
1 <?php
8 {
10 
11  protected $attributes;
12 
13  protected $useWrapper = false;
14 
18  public function isUseWrapper()
19  {
20  return $this->useWrapper;
21  }
22 
26  public function setUseWrapper($useWrapper)
27  {
28  $this->useWrapper = $useWrapper;
29  }
30 
31  public static function getInstance()
32  {
33  return new self(self::TYPE_DATACOLLECTION_LINK);
34  }
35 
36  public function prepareRender()
37  {
38  parent::prepareRender();
39 
40  $this->addAttribute('href', ($this->getUrl() ? $this->getUrl() : "#"));
41  $this->addAttribute('target', $this->getTarget());
42  }
43 
44  public function render()
45  {
46  $this->prepareRender();
47 
48  $output = '';
49  if ($this->useWrapper) {
50  $output .= '<div' . $this->renderAttributesHelper($this->attributes['wrapper']) . '>';
51  }
52 
53  $output .= '<a' . $this->renderAttributes($this->attributes['default']) . '>' . $this->renderCaption() . '</a>';
54 
55  if ($this->useWrapper) {
56  $output .= '</div>';
57  }
58  return $output;
59  }
60 
61  public function addAttribute($key, $value, $wrapper = false)
62  {
63  $this->attributes[$this->getGroupKey($wrapper)][$key] = $value;
64  }
65 
66  public function removeAttribute($key, $wrapper = false)
67  {
68  if (isset($this->attributes[$this->getGroupKey($wrapper)][$key])) {
69  unset($this->attributes[$this->getGroupKey($wrapper)][$key]);
70  return true;
71  }
72  return false;
73  }
74 
75  public function getAttribute($key, $wrapper = false)
76  {
77  if (isset($this->attributes[$this->getGroupKey($wrapper)][$key])) {
78  return $this->attributes[$this->getGroupKey($wrapper)][$key];
79  }
80  return null;
81  }
82 
83  protected function getGroupKey($wrapper)
84  {
85  return ($wrapper)? 'wrapper' : 'default';
86  }
87 }
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)
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
getAttribute($key, $wrapper=false)
setUseWrapper($useWrapper)
getTarget()
Get target.
$key
Definition: croninfo.php:18