blob: 026ca0cda70c9ee2a148a57f2be69cce17bbf011 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
<?php
/**
* A widget for the sidebar.
*
* @author Jan-Hendrik Willms <tleilax+studip@gmail.com>
* @license GPL 2 or later
* @since 3.1
* @see Sidebar
*/
class SidebarWidget extends Widget
{
protected $id = '';
public function __construct()
{
$this->layout = 'sidebar/widget-layout.php';
}
/**
* Sets the ID of the HTML element that represents the widget.
*
* @param $id The element-ID to be used for the widget.
*
*/
public function setId(string $id)
{
$this->id = $id;
}
/**
* Returns the ID of this widget, if it is set.
*
* @return string The ID of the widget or an empty string, if it is not set.
*/
public function getId() : string
{
return $this->id;
}
/**
* Sets the title of the widget.
*
* @param String $title The title of the widget
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* Returns the title of the widget
*
* @return mixed The title of the widget of false if no title has been set
*/
public function getTitle()
{
return $this->title;
}
/**
* Removes the title of the widget.
*/
public function removeTitle()
{
$this->title = false;
}
public function setExtra($extra)
{
$this->extra = $extra;
}
public function getExtra()
{
return $this->extra;
}
public function removeExtra()
{
$this->extra = false;
}
/**
* Renders the widget.
* The widget will only be rendered if it contains at least one element.
*
* @return String The THML code of the rendered sidebar widget
*/
public function render($variables = [])
{
if ($this->id) {
$this->template_variables['id'] = $this->id;
}
return parent::render($variables);
}
}
|