ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPDNewsGUI.php
Go to the documentation of this file.
1<?php
2
24
32{
35 protected \ILIAS\News\Dashboard\DashboardSessionRepository $dash_news_repo;
38 protected ilLanguage $lng;
39 protected ilCtrl $ctrl;
40 protected ilHelpGUI $help;
41 protected ilObjUser $user;
44
45 public function __construct()
46 {
47 global $DIC;
48
49 $this->help = $DIC["ilHelp"];
50 $this->user = $DIC->user();
51 $tpl = $DIC->ui()->mainTemplate();
52 $lng = $DIC->language();
53 $ilCtrl = $DIC->ctrl();
54 $ilHelp = $DIC["ilHelp"];
55
56 $ilHelp->setScreenIdComponent("news");
57
58 $this->std_request = $DIC->news()
59 ->internal()
60 ->gui()
61 ->standardRequest();
62
63 // initiate variables
64 $this->tpl = $tpl;
65 $this->lng = $lng;
66 $this->ctrl = $ilCtrl;
67
68 $lng->loadLanguageModule("news");
69
70 $this->ctrl->saveParameter($this, "news_ref_id");
71 $this->fav_manager = new ilFavouritesManager();
72 $this->gui = $DIC->news()
73 ->internal()
74 ->gui();
75 $this->domain = $DIC->news()
76 ->internal()
77 ->domain();
78 $this->dash_news_repo = $DIC->news()
79 ->internal()
80 ->repo()
81 ->dashboard();
82 $this->dash_news_manager = $DIC->news()
83 ->internal()
84 ->domain()
85 ->dashboard();
86 }
87
88 public function executeCommand(): bool
89 {
90 $next_class = $this->ctrl->getNextClass();
91
92 if (!$this->domain->settings()->get("block_activated_news")) {
93 return false;
94 }
95
96 switch ($next_class) {
97 case "ilnewstimelinegui":
98 $t = $this->gui->dashboard()->getTimelineGUI();
99 $this->ctrl->forwardCommand($t);
100 break;
101
102 case "ilcommonactiondispatchergui":
104 $this->ctrl->forwardCommand($gui);
105 break;
106
107 default:
108 $cmd = $this->ctrl->getCmd("view");
109 $this->displayHeader();
110 $this->$cmd();
111 break;
112 }
113 $this->tpl->printToStdout();
114 return true;
115 }
116
117 public function displayHeader(): void
118 {
119 $this->tpl->setTitle($this->lng->txt("news"));
120 $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_nwss.svg"));
121 }
122
123 public function view(): void
124 {
125 $filter = $this->gui->dashboard()->getFilter();
126 $this->saveFilterValues($filter);
127 // we need to get the filte again, since the saving above influences
128 // the drop down (number of news per object displayed in parentheses dependeds on period)
129 $filter = $this->gui->dashboard()->getFilter(true);
130 $t = $this->gui->dashboard()->getTimelineGUI();
131
132 $this->tpl->setContent(
133 $filter->render() .
134 $this->ctrl->getHTML($t)
135 );
136 }
137
138 public function applyFilter(): void
139 {
140 $ilUser = $this->user;
141
142 $news_ref_id = $this->std_request->getNewsRefId();
143 $news_per = $this->std_request->getNewsPer();
144
145 $this->ctrl->setParameter($this, "news_ref_id", $news_ref_id);
146 $ilUser->writePref("news_sel_ref_id", (string) $news_ref_id);
147 if ($news_per > 0) {
148 ilSession::set("news_pd_news_per", $news_per);
149 }
150 $this->ctrl->redirect($this, "view");
151 }
152
153 protected function saveFilterValues(FilterAdapterGUI $filter): void
154 {
155 $this->dash_news_manager->saveFilterData($filter->getData());
156 }
157}
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Class ilCtrl provides processing control methods.
Manages favourites, currently the interface for other components, needs discussion.
Help GUI class.
language handling
loadLanguageModule(string $a_module)
Load language module.
User class.
ilGlobalTemplateInterface $tpl
DashboardNewsManager $dash_news_manager
saveFilterValues(FilterAdapterGUI $filter)
InternalDomainService $domain
ILIAS News Dashboard DashboardSessionRepository $dash_news_repo
StandardGUIRequest $std_request
ilLanguage $lng
ilFavouritesManager $fav_manager
InternalGUIService $gui
static set(string $a_var, $a_val)
Set a value.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: shib_login.php:26