aboutsummaryrefslogtreecommitdiff
path: root/lib/modules/TerminWidget.php
blob: 773e6923948d73a028c2a0483d8b3a0877c7c89d (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
<?php
/*
 * TerminWidget.php - A portal plugin for dates
 *
 * Copyright (C) 2014 - André Klaßen <klassen@elan-ev.de>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 */

class TerminWidget extends CorePlugin implements PortalPlugin
{
    public function getPluginName()
    {
        return _('Meine aktuellen Termine');
    }

    public function getMetadata()
    {
        return [
            'description' => _('Dieses Widget zeigt die eigenen aktuellen Termine an.')
        ];
    }

    public function getPortalTemplate()
    {
        $controller = app(\Trails_Dispatcher::class)->load_controller('calendar/contentbox');
        $response = $controller->relay('calendar/contentbox/display/'.$GLOBALS['user']->id);
        $template = $GLOBALS['template_factory']->open('shared/string');
        $template->content = $response->body;

        $navigation = new Navigation('', 'dispatch.php/calendar/date/add');
        $navigation->setImage(Icon::create('add', Icon::ROLE_CLICKABLE, ['title' => _('Neuen Termin anlegen')]));
        $navigation->setLinkAttributes(['data-dialog' => 'reload-on-close']);
        $template->icons = [$navigation];

        return $template;
    }
}