ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilPDNewsGUI.php
Go to the documentation of this file.
1<?php
2
24
29{
32 protected \ILIAS\News\Dashboard\DashboardSessionRepository $dash_news_repo;
35 protected ilLanguage $lng;
36 protected ilCtrl $ctrl;
37 protected ilHelpGUI $help;
38 protected ilObjUser $user;
41
42 public function __construct()
43 {
44 global $DIC;
45
46 $this->help = $DIC["ilHelp"];
47 $this->user = $DIC->user();
48 $tpl = $DIC->ui()->mainTemplate();
49 $lng = $DIC->language();
50 $ilCtrl = $DIC->ctrl();
51 $ilHelp = $DIC["ilHelp"];
52
53 $ilHelp->setScreenIdComponent("news");
54
55 $this->std_request = $DIC->news()
56 ->internal()
57 ->gui()
58 ->standardRequest();
59
60 // initiate variables
61 $this->tpl = $tpl;
62 $this->lng = $lng;
63 $this->ctrl = $ilCtrl;
64
65 $lng->loadLanguageModule("news");
66
67 $this->ctrl->saveParameter($this, "news_ref_id");
68 $this->fav_manager = new ilFavouritesManager();
69 $this->gui = $DIC->news()
70 ->internal()
71 ->gui();
72 $this->domain = $DIC->news()
73 ->internal()
74 ->domain();
75 $this->dash_news_repo = $DIC->news()
76 ->internal()
77 ->repo()
78 ->dashboard();
79 $this->dash_news_manager = $DIC->news()
80 ->internal()
81 ->domain()
82 ->dashboard();
83 }
84
85 public function executeCommand(): bool
86 {
87 $next_class = $this->ctrl->getNextClass();
88
89 if (!$this->domain->settings()->get("block_activated_news")) {
90 return false;
91 }
92
93 switch (strtolower($next_class)) {
94 case strtolower(ilNewsTimelineGUI::class):
95 $t = $this->gui->dashboard()->getTimelineGUI();
96 $this->ctrl->forwardCommand($t);
97 break;
98
99 case strtolower(ilCommonActionDispatcherGUI::class):
101 $this->ctrl->forwardCommand($gui);
102 break;
103
104 default:
105 $cmd = $this->ctrl->getCmd("view");
106 $this->displayHeader();
107 $this->$cmd();
108 break;
109 }
110 $this->tpl->printToStdout();
111 return true;
112 }
113
114 public function displayHeader(): void
115 {
116 $this->tpl->setTitle($this->lng->txt("news"));
117 $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_nwss.svg"));
118 }
119
120 public function view(): void
121 {
122 $filter = $this->gui->dashboard()->getFilter();
123 $this->saveFilterValues($filter);
124 // we need to get the filte again, since the saving above influences
125 // the drop down (number of news per object displayed in parentheses dependeds on period)
126 $filter = $this->gui->dashboard()->getFilter(true);
127 $t = $this->gui->dashboard()->getTimelineGUI();
128
129 $this->tpl->setContent(
130 $filter->render() .
131 $this->ctrl->getHTML($t)
132 );
133 }
134
135 public function applyFilter(): void
136 {
137 $ilUser = $this->user;
138
139 $news_ref_id = $this->std_request->getNewsRefId();
140 $news_per = $this->std_request->getNewsPer();
141
142 $this->ctrl->setParameter($this, "news_ref_id", $news_ref_id);
143 $ilUser->writePref("news_sel_ref_id", (string) $news_ref_id);
144 if ($news_per > 0) {
145 ilSession::set("news_pd_news_per", $news_per);
146 }
147 $this->ctrl->redirect($this, "view");
148 }
149
150 protected function saveFilterValues(FilterAdapterGUI $filter): void
151 {
152 $this->dash_news_manager->saveFilterData($filter->getData());
153 }
154}
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.
@ilCtrl_Calls ilPDNewsGUI: ilNewsTimelineGUI, ilCommonActionDispatcherGUI, ILIAS\User\Profile\PublicP...
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