diff options
| author | Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de> | 2022-05-11 07:19:42 +0000 |
|---|---|---|
| committer | Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de> | 2022-05-11 07:19:42 +0000 |
| commit | 20240b2aacb15ab3264afbfbbc9dae952db4bb63 (patch) | |
| tree | 597cae73c5ae7ab9eda6d066d45430c3f17a4560 /lib/modules/NewsWidget.php | |
| parent | c054faf90288a75fc3680480434ba93b7f5b287b (diff) | |
convert old core plugins to new model, re #814
Merge request studip/studip!440
Diffstat (limited to 'lib/modules/NewsWidget.php')
| -rw-r--r-- | lib/modules/NewsWidget.php | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/modules/NewsWidget.php b/lib/modules/NewsWidget.php new file mode 100644 index 0000000..60af752 --- /dev/null +++ b/lib/modules/NewsWidget.php @@ -0,0 +1,65 @@ +<?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. + */ + +require_once 'app/controllers/news.php'; + +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() + { + $dispatcher = new StudipDispatcher(); + $controller = new NewsController($dispatcher); + $response = $controller->relay('news/display/studip'); + $template = $GLOBALS['template_factory']->open('shared/string'); + $template->content = $response->body; + + if (StudipNews::CountUnread() > 0) { + $navigation = new Navigation('', 'dispatch.php/news/visit_all'); + $navigation->setImage(Icon::create('refresh', 'clickable', ["title" => _('Alle als gelesen markieren')])); + $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', 'clickable', ["title" => _('RSS-Feed')])); + $icons[] = $navigation; + } + } + + if ($GLOBALS['perm']->have_perm('root')) { + $navigation = new Navigation('', 'dispatch.php/news/edit_news/new/studip'); + $navigation->setImage(Icon::create('add', 'clickable', ["title" => _('Ankündigungen bearbeiten')]), ['rel' => 'get_dialog']); + $icons[] = $navigation; + if (Config::get()->NEWS_RSS_EXPORT_ENABLE) { + $navigation = new Navigation('', 'dispatch.php/news/rss_config/studip'); + $navigation->setImage(Icon::create('rss+add', 'clickable', ["title" => _('RSS-Feed konfigurieren')]), ["rel" => 'size=auto']); + $icons[] = $navigation; + } + } + + $template->icons = $icons; + + return $template; + } +} |
