Skip to content
Snippets Groups Projects
Select Git revision
  • 5fe538e2b58180fb23040831fe9f62ae1e6cd45f
  • main default protected
  • step-3263
  • feature/plugins-cli
  • feature/vite
  • step-2484-peerreview
  • biest/issue-5051
  • tests/simplify-jsonapi-tests
  • fix/typo-in-1a70031
  • feature/broadcasting
  • database-seeders-and-factories
  • feature/peer-review-2
  • feature-feedback-jsonapi
  • feature/peerreview
  • feature/balloon-plus
  • feature/stock-images-unsplash
  • tic-2588
  • 5.0
  • 5.2
  • biest/unlock-blocks
  • biest-1514
21 results

NewsWidget.php

Blame
  • Forked from Stud.IP / Stud.IP
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    NewsWidget.php 2.61 KiB
    <?php
    /*
     * news.php - News controller
     *
     * Copyright (C) 2014 - Nadine Werner <nadwerner@uos.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 NewsWidget extends CorePlugin implements PortalPlugin
    {
        public function getPluginName()
        {
            return _('Ankündigungen');
        }
    
        public function getMetadata()
        {
            return [
                'description' => _('Mit diesem Widget haben Sie Zugriff auf systemweite Ankündigungen.')
            ];
        }
    
        function getPortalTemplate()
        {
            $controller = app(\Trails\Dispatcher::class)->load_controller('news');
            $response = $controller->relayWithRedirect('news/display/studip');
            $template = $GLOBALS['template_factory']->open('shared/string');
            $template->content = $response->body;
            $icons = [];
            if (StudipNews::CountUnread() > 0) {
                $navigation = new Navigation('', 'dispatch.php/news/visit_all');
                $navigation->setImage(Icon::create('refresh', Icon::ROLE_CLICKABLE, ['title' => _('Alle als gelesen markieren'), 'size' => 20]), ['class' => 'visit-all']);
                $icons[] = $navigation;
            }
    
            if (Config::get()->NEWS_RSS_EXPORT_ENABLE) {
                if ($rss_id = StudipNews::GetRssIdFromRangeId('studip')) {
                    $navigation = new Navigation('', 'rss.php', ['id' => $rss_id]);
                    $navigation->setImage(Icon::create('rss', Icon::ROLE_CLICKABLE, ['title' => _('RSS-Feed'), 'size' => 20]));
                    $icons[] = $navigation;
                }
            }
    
            if ($GLOBALS['perm']->have_perm('root')) {
                $navigation = new Navigation('', 'dispatch.php/news/edit_news/new/studip');
                $navigation->setImage(Icon::create('add', Icon::ROLE_CLICKABLE, ['title' => _('Ankündigungen bearbeiten'), 'size' => 20]), ['data-dialog' => '1']);
                $icons[] = $navigation;
                if (Config::get()->NEWS_RSS_EXPORT_ENABLE) {
                    $navigation = new Navigation('', 'dispatch.php/news/rss_config/studip');
                    $navigation->setImage(
                        Icon::create(
                            'admin',
                            Icon::ROLE_CLICKABLE,
                            ['title' => _('RSS-Feed konfigurieren')]
                        ),
                        ['data-dialog' => 'size=auto']
                    );
                    $icons[] = $navigation;
                }
            }
    
            $template->icons = $icons;
    
            return $template;
        }
    }