aboutsummaryrefslogtreecommitdiff
path: root/lib/modules/MyCoursesWidget.php
blob: 81aceeda0d7103bed8983241955866fe1f629cdc (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
<?php
/**
 * My courses widget. Displays a user's courses on the start page.
 *
 * @author  Viktoria Wiebe <viktoria.wiebe@web.de>
 * @license GPL2 or any later version
 * @since   Stud.IP 5.3
 */

require_once 'app/controllers/my_courses.php';

class MyCoursesWidget extends CorePlugin implements PortalPlugin
{
    public function getPluginName()
    {
        return _('Meine Veranstaltungen');
    }

    public function getMetadata()
    {
        return [
            'description' => _('Dieses Widget zeigt eine Liste Ihrer Veranstaltungen an.')
        ];
    }

    public function getPortalTemplate()
    {
        // get the MyCoursesController in order to prepare the correct data for the overview
        $controller = app(MyCoursesController::class, ['dispatcher' => app(\Trails_Dispatcher::class)]);
        $data = $controller->getPortalWidgetData();

        // add the json data to the head so vue can grab it
        PageLayout::addHeadElement('script', [], 'STUDIP.MyCoursesData = ' . json_encode($data) . ';');

        return $GLOBALS['template_factory']->open('start/my_courses');
    }
}