aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/helpbar/HelpbarTourWidget.php
blob: 60fbf44511903588e8e94b66e14b6ca129f67200 (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
<?php
class HelpbarTourWidget extends HelpbarWidget
{
    protected $template = 'helpbar/tour-widget.php';
    public $tour_data = [];

    public function __construct()
    {
        $this->tour_data = HelpTour::getHelpbarTourData();
        
        foreach ($this->tour_data['tours'] as $index => $tour) {
            $element = new LinkElement($tour->name, URLHelper::getURL('?tour_id=' . $tour->tour_id));

            $visit_state = HelpTourUser::find([$tour->tour_id, $GLOBALS['user']->id]);            
            if ($visit_state === null) {
                $element->addClass('tour-new');
            } elseif (!$visit_state->completed) {
                $element->addClass('tour-paused');
            } else {
                $element->addClass('tour-completed');
            }
            $element->addClass('tour_link');
            $element['id'] = $tour->tour_id;

            $this->addElement($element);
        }
    }
}