ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
EditingGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27use ilObjBlogGUI;
29use ilToolbarGUI;
32
37{
38 protected \ILIAS\Style\Content\Object\ObjectFacade $content_style_domain;
40
41 public function __construct(
42 protected InternalDataService $data,
43 protected InternalDomainService $domain,
44 protected InternalGUIService $gui,
45 protected BlogGUIContext $context,
46 protected \ILIAS\Style\Content\Service $content_style
47 ) {
48 $this->blog_settings = $this->domain->blogSettings()->getByObjId($context->getBlog()->getId());
49 if (!$context->isRepositoryNode()) {
50 $this->content_style_domain = $content_style->domain()->styleForObjId($context->getBlog()->getId());
51 } else {
52 $this->content_style_domain = $content_style->domain()->styleForRefId($context->getBlog()->getRefId());
53 }
54 }
55
56 public function executeCommand(): void
57 {
58 $next_class = $this->gui->ctrl()->getNextClass($this);
59 $cmd = $this->gui->ctrl()->getCmd("render");
60
61 switch ($next_class) {
62 case strtolower(ilBlogPostingGUI::class):
63 $this->forwardPosting();
64 break;
65
66 default:
67 $this->$cmd();
68 break;
69 }
70 }
71
72 protected function getLinkBuilder(): EditingLinkBuilder
73 {
74 return $this->gui->navigation()->editingLink();
75 }
76
77 protected function forwardPosting(): void
78 {
79 $ilCtrl = $this->gui->ctrl();
80 $tpl = $this->gui->ui()->mainTemplate();
81 $lng = $this->domain->lng();
82 $req = $this->context->getRequest();
83
84 $ilCtrl->saveParameter($this, "user_page");
86
87 if (!$this->context->getPermission()->mayContribute()) {
88 $tpl->setOnScreenMessage('info', $lng->txt("no_permission"));
89 return;
90 }
91
92 $style_sheet_id = $this->content_style_domain->getEffectiveStyleId();
93
94 $bpost_gui = new ilBlogPostingGUI(
95 $this->context->getNodeId(),
96 $this->context->getPermission()->getAccessHandler(),
97 $req->getBlogPage(),
98 $req->getOldNr(),
99 $this->context->getBlog()->getNotesStatus(),
100 $this->context->getPermission()->mayEditPosting($req->getBlogPage()),
101 $style_sheet_id
102 );
103
104 $this->setContentStyleSheet();
105
106 $ilCtrl->setParameterByClass(ilBlogPostingGUI::class, "blpg", $req->getBlogPage());
107 $this->gui->tabs()->addNonTabbedLink(
108 "preview",
109 $lng->txt("blog_preview"),
110 $ilCtrl->getLinkTargetByClass(ilBlogPostingGUI::class, "previewFullscreen")
111 );
112 $ilCtrl->setParameterByClass(ilBlogPostingGUI::class, "blpg", "");
113
114 $ret = $ilCtrl->forwardCommand($bpost_gui);
115
116 if ($ret != "") {
117 $is_owner = $this->context->getPermission()->mayContribute();
118 $is_active = $bpost_gui->getBlogPosting()->getActive();
119
120 // do not show inactive postings
121 $cmd = $ilCtrl->getCmd();
122 if (($cmd === "previewFullscreen")
123 && !$is_owner && !$is_active) {
124 $ilCtrl->redirectByClass(ilObjBlogGUI::class, "preview");
125 }
126
127 // infos about draft status / snippet
128 $info = array();
129 if (!$is_active) {
130 $info[] = $lng->txt("blog_draft_info_contributors");
131 }
132 $public_action = false;
133 if ($cmd !== "history" && $cmd !== "edit" && $is_active && empty($info)) {
134 $info[] = $lng->txt("blog_new_posting_info");
135 $public_action = true;
136 }
137 if ($this->context->getBlog()->getNotesStatus() &&
138 $this->blog_settings->getApproval() &&
139 !$bpost_gui->getBlogPosting()->isApproved()) {
140 // #9737
141 $info[] = $lng->txt("blog_posting_edit_approval_info");
142 }
143 if ($public_action) {
144 $tpl->setOnScreenMessage('success', implode("<br />", $info));
145 } else {
146 if (count($info) > 0) {
147 $tpl->setOnScreenMessage('info', implode("<br />", $info));
148 }
149 }
150
151 // revert to edit cmd to avoid confusion
152 $tpl->setContent($ret);
153 }
154
155 if (!$this->gui->tabs()->back_target) {
156 $ilCtrl->setParameter($this, "bmn", "");
157 $this->gui->tabs()->setBackTarget(
158 $lng->txt("back"),
159 $ilCtrl->getLinkTarget($this, "")
160 );
161 }
162 }
163
164 public function render(): void
165 {
166 $tpl = $this->gui->ui()->mainTemplate();
167 $ilTabs = $this->gui->tabs();
168 $ilCtrl = $this->gui->ctrl();
169 $lng = $this->domain->lng();
170 $ilToolbar = new ilToolbarGUI();
171
172 if (!$this->context->getPermission()->canRead()) {
173 $tpl->setOnScreenMessage('info', $lng->txt("no_permission"));
174 return;
175 }
176
177 $ilTabs->activateTab("content");
178
179 // toolbar
180 if ($this->context->getPermission()->mayContribute()) {
181 $ilToolbar->setFormAction($ilCtrl->getFormActionByClass(self::class, "createPosting"));
182
183 $title = new ilTextInputGUI($lng->txt("title"), "title");
184 $title->setSize(30);
185 $ilToolbar->addStickyItem($title, true);
187 document.getElementById('title').setAttribute('data-blog-input', 'posting-title');
188 document.getElementById('title').setAttribute('placeholder', ' ');
189 ");
190
191 $this->gui->button(
192 $lng->txt("blog_add_posting"),
193 "createPosting"
194 )->submit()->toToolbar(true, $ilToolbar);
195
196
197 // #18763
198 $items = $this->domain->postingList($this->context->getBlog()->getId())->getPostingsGroupedByMonth();
199 $keys = array_keys($items);
200 $first = array_shift($keys);
201 if ($first != $this->context->getRequest()->getMonth()) {
202 $ilToolbar->addSeparator();
203
204 $ilCtrl->setParameterByClass(ilObjBlogGUI::class, "bmn", $first);
205 $url = $ilCtrl->getLinkTargetByClass(ilObjBlogGUI::class, "");
206 $ilCtrl->setParameterByClass(ilObjBlogGUI::class, "bmn", $this->context->getRequest()->getMonth());
207
208 $ilToolbar->addComponent(
209 $this->gui->ui()->factory()->button()->standard(
210 $lng->txt("blog_show_latest"),
211 $url
212 )
213 );
214 }
215
216 // print/pdf
217 $print_view = $this->gui->presentation()->getPrintView(
218 $this->context->getNodeId(),
219 $this->context->isRepositoryNode(),
220 $this->context->getRequest()->getObjIds()
221 );
222 $modal_elements = $print_view->getModalElements(
223 $ilCtrl->getLinkTarget(
224 $this,
225 "printViewSelection"
226 )
227 );
228 $ilToolbar->addSeparator();
229 $ilToolbar->addComponent($modal_elements->button);
230 $ilToolbar->addComponent($modal_elements->modal);
231 }
232
233 $include_inactive = $this->context->getPermission()->mayContribute();
234 $list_items = $this->domain->postingList($this->context->getBlog()->getId(), $include_inactive)
235 ->getPostingsForView(
236 $this->context->getAuthor() ?? 0,
237 $this->context->getRequest()->getKeyword(),
238 $this->context->getMonth()
239 );
240
241
242 $list = $nav = "";
243 if ($list_items) {
244 $list = $this->gui->posting()->postingList(
245 $this->context->getBlog()->getId(),
246 $this->context->getPermission(),
247 $this->context->getMonth(),
248 $this->context->getNodeId(),
249 $this->context->getIdType()
250 )->render(
251 $list_items,
252 "preview",
253 "",
254 $include_inactive
255 );
256 $nav = $this->gui->navigation()->sideBar(
257 $this->context->getPermission(),
258 $this->getLinkBuilder(),
259 $this->blog_settings,
260 $this->context->getNodeId(),
261 $this->context->getIdType()
262 )->render(
263 $this->domain->postingList($this->context->getBlog()->getId())->getPostingsGroupedByMonth(),
264 $include_inactive
265 );
266 }
267
268 $this->setContentStyleSheet();
269
270 $tpl->setContent($ilToolbar->getHTML() . $list);
271 $tpl->setRightContent($nav);
272 }
273
274 public function printViewSelection(): void
275 {
276 $print_view = $this->gui->presentation()->getPrintView(
277 $this->context->getNodeId(),
278 $this->context->isRepositoryNode(),
279 $this->context->getRequest()->getObjIds()
280 );
281 $print_view->sendForm();
282 }
283
284 public function printPostings(): void
285 {
286 $print_view = $this->gui->presentation()->getPrintView(
287 $this->context->getNodeId(),
288 $this->context->isRepositoryNode(),
289 $this->context->getRequest()->getObjIds()
290 );
291 $print_view->sendPrintView();
292 }
293
294 public function approve(): void
295 {
296 $apid = $this->context->getRequest()->getApId();
297 if ($this->context->getPermission()->canManage() && $apid > 0) {
298 $post = new \ilBlogPosting($apid);
299 $post->setApproved(true);
300 $post->setBlogNodeId($this->context->getNodeId(), !$this->context->isRepositoryNode());
301 $post->update(true, false, true, "new"); // #13434
302
303 $this->gui->ui()->mainTemplate()->setOnScreenMessage(
304 'success',
305 $this->domain->lng()->txt("settings_saved"),
306 true
307 );
308 }
309
310 $this->gui->ctrl()->redirectByClass(
311 [
312 ilObjBlogGUI::class,
313 self::class,
314 ],
315 ""
316 );
317 }
318
319 public function deactivateAdmin(): void
320 {
321 $apid = $this->context->getRequest()->getApId();
322 if ($this->context->getPermission()->canWrite() && $apid > 0) {
323 // ilBlogPostingGUI::deactivatePage()
324 $post = new \ilBlogPosting($apid);
325 $post->setApproved(false);
326 $post->setActive(false);
327 $post->update(true, false, false);
328
329 $this->gui->ui()->mainTemplate()->setOnScreenMessage(
330 'success',
331 $this->domain->lng()->txt("settings_saved"),
332 true
333 );
334 }
335
336 $this->gui->ctrl()->redirect($this, "render");
337 }
338
342 public function createPosting(): void
343 {
344 $ctrl = $this->gui->ctrl();
345 $user = $this->domain->user();
346 $mt = $this->gui->ui()->mainTemplate();
347 $lng = $this->domain->lng();
348 $title = $this->context->getRequest()->getTitle();
349 if ($title) {
350 // create new posting
351 $posting = new \ilBlogPosting();
352 $posting->setTitle($title);
353 $posting->setBlogId($this->context->getBlog()->getId());
354 $posting->setActive(false);
355 $posting->setAuthor($user->getId());
356 $posting->create(false);
357
358 // switch month list to current month (will include new posting)
359 $ctrl->setParameter($this, "bmn", date("Y-m"));
360
361 $ctrl->setParameterByClass("ilblogpostinggui", "blpg", $posting->getId());
362 $ctrl->redirectByClass("ilblogpostinggui", "edit");
363 } else {
364 $mt->setOnScreenMessage('failure', $lng->txt("msg_no_title"), true);
365 $ctrl->redirect($this, "render");
366 }
367 }
368
369 public function setContentStyleSheet(): void
370 {
371 $this->content_style->gui()->addCss(
372 $this->gui->ui()->mainTemplate(),
373 $this->context->getBlog()->getRefId(),
374 $this->context->getBlog()->getId()
375 );
376 }
377
378
379}
@ilCtrl_Calls ILIAS\Blog\Editing\EditingGUI: ilRepositorySearchGUI, ilBlogPostingGUI
Definition: EditingGUI.php:37
ILIAS Style Content Object ObjectFacade $content_style_domain
Definition: EditingGUI.php:38
__construct(protected InternalDataService $data, protected InternalDomainService $domain, protected InternalGUIService $gui, protected BlogGUIContext $context, protected \ILIAS\Style\Content\Service $content_style)
Definition: EditingGUI.php:41
createPosting()
Create new posting.
Definition: EditingGUI.php:342
ILIAS Blog Settings Settings $blog_settings
Definition: EditingGUI.php:39
Class ilBlogPosting GUI class.
@ilCtrl_Calls ilObjBlogGUI: ilWorkspaceAccessGUI @ilCtrl_Calls ilObjBlogGUI: ilInfoScreenGUI,...
This class represents a text property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$info
Definition: entry_point.php:21
loadStandardTemplate()
This loads the standard template "tpl.adm_content.html" and "tpl.statusline.html" the CONTENT and STA...
setRightContent(string $a_html)
Sets content of right column.
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
setContent(string $a_html)
Sets content for standard template.
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
readonly ilGlobalTemplateInterface $tpl
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
catch(\Exception $e) $req
Definition: xapiproxy.php:81
global $lng
Definition: privfeed.php:26
$data
Definition: storeScorm.php:45