aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/helpbar/HelpbarWidget.php
blob: 12b3850e91633a0fdab1ab2db1120bc307a7ceff (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
<?php
class HelpbarWidget extends Widget
{
    public $icon = false;
    
    public function addElement(WidgetElement $element, $index = null)
    {
        parent::addElement($element, $index);
    }

    public function setIcon($icon)
    {
        $this->icon = $icon;
    }

    /**
     * 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 = [])
    {
        $content = '';

        if ($this->hasElements()) {
            $template = $GLOBALS['template_factory']->open($this->template);
            $template->set_attributes($variables + $this->template_variables);
            $template->elements = $this->elements;
            $content = $template->render();
        }
        
        return $content;
    }
}