ILIAS  trunk Revision v13.0_alpha-52-g21c366bbdd4
class.ilObjBlogGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
29
44{
45 protected \ILIAS\Style\Content\Service $cs;
46 protected \ILIAS\Blog\Permission\BlogCmdPermission $cmd_perm;
50
51 protected ilTabsGUI $tabs;
54
56 protected \ILIAS\Style\Content\GUIService $content_style_gui;
57 protected \ILIAS\Style\Content\Object\ObjectFacade $content_style_domain;
58
59 public function __construct(
60 int $a_id = 0,
61 int $a_id_type = self::REPOSITORY_NODE_ID,
62 int $a_parent_node_id = 0
63 ) {
64 global $DIC;
65 // other services
66 $this->cs = $DIC->contentStyle();
67 $this->tool_context = $DIC->globalScreen()->tool()->context();
68
69 // internal service
70 $service = $DIC->blog()->internal();
71
72 $this->domain = $domain = $service->domain();
73 $this->gui = $gui = $service->gui();
74
75 $this->settings = $domain->settings();
76 $this->user = $domain->user();
77 $this->tree = $domain->repositoryTree();
78 $this->lng = $domain->lng();
79
80 $this->tabs = $gui->tabs();
81 $this->toolbar = $gui->toolbar();
82 $this->locator = $gui->locator();
83
84 $this->nav_history = $DIC["ilNavigationHistory"];
85 $this->ctrl = $gui->ctrl();
86
87 $blog_request = $gui->standardRequest();
88 $month = $blog_request->getMonth();
89 $author = $blog_request->getAuthor();
90
91 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
92
93 $blog_page = $blog_request->getBlogPage();
94 if ($blog_page > 0 &&
95 $domain->posting()->lookupBlogId($blog_page) !== $this->object->getId()) {
96 throw new ilException("Posting ID does not match blog.");
97 }
98
99 if ($this->object) {
100 $this->content_style_gui = $this->cs->gui();
101 if (is_object($this->object)) {
102 if ($this->id_type !== self::REPOSITORY_NODE_ID) {
103 $this->content_style_domain = $this->cs->domain()->styleForObjId($this->object->getId());
104 } else {
105 $this->content_style_domain = $this->cs->domain()->styleForRefId($this->object->getRefId());
106 }
107 }
108
109 $view_state = $domain->postingList($this->object->getId())
110 ->prepareViewState($month, $author);
111 $month = $view_state->getMonth();
112 $author = $view_state->getAuthor();
113
114 $this->ctrl->setParameter($this, "bmn", $month);
115 }
116
117 $this->lng->loadLanguageModule("blog");
118
119 $owner = $this->object?->getOwner() ?? 0;
120 $this->perm = $domain->perm(
121 $this->node_id,
122 $this->id_type,
123 $this->user->getId(),
124 $owner
125 );
126 $this->cmd_perm = $gui->cmdPerm($this->perm, $this->node_id);
127 $this->blog_context = $gui->blogContext(
128 $this->node_id,
129 $this->id_type,
130 $this->object?->getId(),
131 $month,
132 $author,
133 $this->perm,
134 $this->call_by_reference
135 );
136 }
137
138 public function getType(): string
139 {
140 return "blog";
141 }
142
143 protected function afterSave(ilObject $new_object): void
144 {
145 $ilCtrl = $this->ctrl;
146
147 $this->tpl->setOnScreenMessage('success', $this->lng->txt("object_added"), true);
148 $ilCtrl->redirect($this, "edit");
149 }
150
151
152 public function edit(): void
153 {
154 $this->ctrl->redirectByClass(SettingsGUI::class, "");
155 }
156
157 protected function setTabs(): void
158 {
159 $this->gui->navigation()->navigationGUI($this->blog_context)->setTabs();
160 parent::setTabs();
161 }
162
163 public function executeCommand(): void
164 {
165 $ilCtrl = $this->ctrl;
166 $ilTabs = $this->tabs;
167 $ilNavigationHistory = $this->nav_history;
168
169 $next_class = $ilCtrl->getNextClass($this);
170
171 if ($next_class !== "ilexportgui") {
172 $this->triggerAssignmentTool();
173 }
174
175 // add entry to navigation history
176 if (($this->id_type === self::REPOSITORY_NODE_ID) && !$this->getCreationMode() &&
177 $this->getAccessHandler()->checkAccess("read", "", $this->node_id)) {
178 // see #22067
179 $link = $ilCtrl->getLinkTargetByClass([
180 ilRepositoryGUI::class,
181 ilObjBlogGUI::class,
182 \ILIAS\Blog\Presentation\PresentationGUI::class
183 ], "preview");
184 $ilNavigationHistory->addItem($this->node_id, $link, "blog");
185 }
186 switch ($next_class) {
187 case "ilinfoscreengui":
188 $this->prepareOutput();
189 $this->infoScreenForward();
190 break;
191
192 case "ilnotegui":
193 $this->preview();
194 break;
195
196 case "ilcommonactiondispatchergui":
198 $gui->enableCommentsSettings(false);
199 $this->prepareOutput();
200 $this->cmd_perm->forwardPermitted($this, $gui);
201 break;
202
203 case "ilpermissiongui":
204 $this->prepareOutput();
205 $ilTabs->activateTab("id_permissions");
206 $perm_gui = new ilPermissionGUI($this);
207 $this->cmd_perm->forwardPermitted($this, $perm_gui);
208 break;
209
210 case "ilobjectcopygui":
211 $this->prepareOutput();
212 $cp = new ilObjectCopyGUI($this);
213 $cp->setType("blog");
214 $this->cmd_perm->forwardPermitted($this, $cp);
215 break;
216
217 case strtolower(\ilRepositorySearchGUI::class):
218 $this->checkPermission("write");
219 $this->prepareOutput();
220 $ilTabs->activateTab("contributors");
221 $this->cmd_perm->forwardPermitted($this, $this->gui->contributor()->contributorGUI($this->node_id, $this->object));
222 break;
223
224 case 'ilexportgui':
225 $this->prepareOutput();
226 $this->tabs->activateTab("export");
227 $exp_gui = new ilExportGUI($this);
228 $this->cmd_perm->forwardPermitted($this, $exp_gui);
229 break;
230
231 case "ilobjectcontentstylesettingsgui":
232 $this->checkPermission("write");
233 $this->prepareOutput();
234 $this->addHeaderAction();
235 $ilTabs->activateTab("settings");
236 $this->gui->navigation()->navigationGUI($this->blog_context)
237 ->setSettingsSubTabs("style");
238
239
240 if ($this->id_type === self::REPOSITORY_NODE_ID) {
241 $settings_gui = $this->content_style_gui
242 ->objectSettingsGUIForRefId(
243 null,
244 $this->object->getRefId()
245 );
246 } else {
247 $settings_gui = $this->content_style_gui
248 ->objectSettingsGUIForObjId(
249 null,
250 $this->object->getId()
251 );
252 }
253 $this->cmd_perm->forwardPermitted($this, $settings_gui);
254 break;
255
256
257 case "ilblogexercisegui":
258 $this->ctrl->setReturn($this, "render");
259 $gui = $this->gui->exercise()->ilBlogExerciseGUI($this->node_id, $this->cmd_perm);
260 $this->cmd_perm->forwardPermitted($this, $gui);
261 break;
262
263 case 'ilobjnotificationsettingsgui':
264 $this->prepareOutput();
265 $ilTabs->activateTab("settings");
266 $this->gui->navigation()->navigationGUI($this->blog_context)
267 ->setSettingsSubTabs("notifications");
268 $gui = new ilObjNotificationSettingsGUI($this->object->getRefId());
269 $this->cmd_perm->forwardPermitted($this, $gui);
270 break;
271
272 case strtolower(ilObjectMetaDataGUI::class):
273 $this->checkPermission("write");
274 $this->prepareOutput();
275 $ilTabs->activateTab("meta_data");
276 $gui = new ilObjectMetaDataGUI($this->object, null, null, $this->call_by_reference);
277 $this->cmd_perm->forwardPermitted($this, $gui);
278 break;
279
280 case strtolower(SettingsGUI::class):
281 $this->checkPermission("write");
282 $this->prepareOutput();
283 $ilTabs->activateTab("settings");
284 $this->gui->navigation()->navigationGUI($this->blog_context)
285 ->setSettingsSubTabs("properties");
286 $gui = $this->gui->settings()->settingsGUI(
287 $this->obj_id,
288 $this->id_type === self::REPOSITORY_NODE_ID
289 );
290 $this->cmd_perm->forwardPermitted($this, $gui);
291 break;
292
293 case strtolower(\ILIAS\Blog\Editing\EditingGUI::class):
294 $this->prepareOutput();
295 $this->addHeaderAction();
296 $gui = $this->gui->editing()->editingGUI(
297 $this->blog_context,
298 $this->cs
299 );
300 $this->cmd_perm->forwardPermitted($this, $gui);
301 break;
302
303 case strtolower(\ILIAS\Blog\Presentation\PresentationGUI::class):
304 $this->prepareOutput();
305 $this->initHeaderAction(null, null, true);
306 $gui = $this->gui->presentation()->presentationGUI(
307 $this->blog_context,
308 $this->content_style_domain,
309 function () {
311 }
312 );
313 $this->cmd_perm->forwardPermitted($this, $gui);
314 break;
315
316 case strtolower(ContributorGUI::class):
317 $this->checkPermission("write");
318 $this->prepareOutput();
319 $ilTabs->activateTab("contributors");
320 $gui = $this->gui->contributor()->contributorGUI(
321 $this->node_id,
322 $this->object
323 );
324 $this->cmd_perm->forwardPermitted($this, $gui);
325 break;
326
327 case strtolower(\ILIAS\Blog\Settings\BlockSettingsGUI::class):
328 $this->checkPermission("write");
329 $this->prepareOutput();
330 $ilTabs->activateTab("settings");
331 $this->gui->navigation()->navigationGUI($this->blog_context)
332 ->setSettingsSubTabs("side_blocks");
333 $gui = $this->gui->settings()->blockSettingsGUI(
334 $this->obj_id,
335 $this->id_type === self::REPOSITORY_NODE_ID
336 );
337 $this->cmd_perm->forwardPermitted($this, $gui);
338 break;
339
340 case strtolower(\ILIAS\Blog\Export\ExportGUI::class):
341 $this->prepareOutput();
342 $gui = $this->gui->export()->exportGUI(
343 $this->node_id,
344 $this->object->getOwner(),
345 $this->id_type === self::REPOSITORY_NODE_ID
346 );
347 $this->cmd_perm->forwardPermitted($this, $gui);
348 break;
349
350 case "ilworkspaceaccessgui":
351 $this->checkPermission("write");
352 parent::executeCommand();
353 break;
354
355 default:
356 // desktop item handling, must be toggled before header action
357 $cmd = $ilCtrl->getCmd();
358 //$this->addHeaderActionForCommand($cmd);
359 $this->prepareOutput();
360 if ($this->cmd_perm->classImplementsMethodDirectly(get_class($this), $cmd)) {
361 $cmd = $this->cmd_perm->getPermittedCommand();
362 }
363 $this->$cmd();
364 }
365 }
366
367 protected function triggerAssignmentTool(): void
368 {
369 $be = $this->domain->exercise($this->node_id);
370 $be_gui = $this->gui->exercise()->ilBlogExerciseGUI($this->node_id, $this->cmd_perm);
371 $assignments = $be->getAssignmentsOfBlog();
372 if (count($assignments) > 0) {
373 $ass_ids = array_map(static function ($i) {
374 return $i["ass_id"];
375 }, $assignments);
376 $this->tool_context->current()->addAdditionalData(ilExerciseGSToolProvider::SHOW_EXC_ASSIGNMENT_INFO, true);
377 $this->tool_context->current()->addAdditionalData(ilExerciseGSToolProvider::EXC_ASS_IDS, $ass_ids);
378 $this->tool_context->current()->addAdditionalData(
380 $be_gui->getActionButtons()
381 );
382 }
383 }
384
388 public function infoScreen(): void
389 {
390 $this->ctrl->redirectByClass(ilInfoScreenGUI::class, "showSummary");
391 }
392
393 public function infoScreenForward(): void
394 {
395 $ilTabs = $this->tabs;
396
397 $ilTabs->activateTab("id_info");
398
399 $this->checkPermission("visible");
400
401 $info = new ilInfoScreenGUI($this);
402
403 if ($this->id_type !== self::WORKSPACE_NODE_ID) {
404 $info->enablePrivateNotes();
405 }
406
407 if ($this->checkPermissionBool("read")) {
408 $info->enableNews();
409 }
410
411 // no news editing for files, just notifications
412 $info->enableNewsEditing(false);
413 if ($this->checkPermissionBool("write")) {
414 $news_set = new ilSetting("news");
415 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
416
417 if ($enable_internal_rss) {
418 $info->setBlockProperty("news", "settings", "1");
419 $info->setBlockProperty("news", "public_notifications_option", "1");
420 }
421 }
422
423 // standard meta data
424 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
425
426 $this->cmd_perm->forwardPermitted($this, $info);
427 }
428
429 // --- helper functions
430
431 public function addPresentationHeaderAction(): void
432 {
433 $this->insertHeaderAction($this->initHeaderAction(null, null, true));
434 }
435
436 protected function initHeaderAction(
437 ?string $sub_type = null,
438 ?int $sub_id = null,
439 bool $presenation = false
440 ): ?ilObjectListGUI {
441 if (!$this->obj_id) {
442 return null;
443 }
444 $sub_type = $sub_id = null;
445 if ($this->blog_context->getRequest()->getBlogPage() > 0) {
446 $sub_type = "blp";
447 $sub_id = $this->blog_context->getRequest()->getBlogPage();
448 }
449
450 $lg = parent::initHeaderAction($sub_type, $sub_id);
451 if (!$lg) {
452 return null;
453 }
454 return $this->gui->navigation()->navigationGUI($this->blog_context)
455 ->prepareHeaderAction($lg, $presenation);
456 }
457
461 public static function lookupSubObjectTitle(
462 int $a_blog_id,
463 int $a_posting_id
464 ): string {
465 // page might be deleted, so setting halt on errors to false
466 $post = new ilBlogPosting($a_posting_id);
467 if ($post->getBlogId() === $a_blog_id) {
468 return $post->getTitle();
469 }
470 return "";
471 }
472
473 public function checkPermissionBool(
474 string $perm,
475 string $cmd = "",
476 string $type = "",
477 ?int $ref_id = null
478 ): bool {
479 return parent::checkPermissionBool($perm, $cmd, $type, $ref_id);
480 }
481
482 protected function addLocatorItems(): void
483 {
484 $this->gui->navigation()->navigationGUI($this->blog_context)
485 ->addLocatorItems();
486 }
487
488
489 protected function forwardExport(): void
490 {
491 $this->ctrl->redirectByClass(ilExportGUI::class);
492 }
493}
@ilCtrl_Calls ILIAS\Blog\Contributor\ContributorGUI: ilRepositorySearchGUI
@ilCtrl_Calls ILIAS\Blog\Editing\EditingGUI: ilRepositorySearchGUI, ilBlogPostingGUI
Definition: EditingGUI.php:37
perm(?int $node_id, int $id_type, int $user_id, int $owner)
postingList(int $obj_id, bool $include_inactive=true)
blogContext(int $node_id, int $id_type, ?int $blog_id, string $month, ?int $author, PermissionManager $permission, bool $call_by_reference=false)
cmdPerm(PermissionManager $blog_access, int $node_id)
Class ilBlogPosting.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
Base class for ILIAS Exception handling.
Export User Interface Class.
Class ilInfoScreenGUI.
Last visited history for repository items.
@ilCtrl_Calls ilObjBlogGUI: ilWorkspaceAccessGUI @ilCtrl_Calls ilObjBlogGUI: ilInfoScreenGUI,...
infoScreen()
this one is called from the info button in the repository
afterSave(ilObject $new_object)
Post (successful) object creation hook.
initHeaderAction(?string $sub_type=null, ?int $sub_id=null, bool $presenation=false)
ILIAS Style Content GUIService $content_style_gui
executeCommand()
execute command
getType()
Functions that must be overwritten.
static lookupSubObjectTitle(int $a_blog_id, int $a_posting_id)
Get title for blog posting (used in ilNotesGUI)
addLocatorItems()
Functions to be overwritten.
ILIAS Blog Permission BlogCmdPermission $cmd_perm
PermissionManager $perm
ContextServices $tool_context
ILIAS Style Content Service $cs
setTabs()
create tabs (repository/workspace switch)
InternalGUIService $gui
BlogGUIContext $blog_context
__construct(int $a_id=0, int $a_id_type=self::REPOSITORY_NODE_ID, int $a_parent_node_id=0)
ILIAS Style Content Object ObjectFacade $content_style_domain
InternalDomainService $domain
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
ilNavigationHistory $nav_history
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
New implementation of ilObjectGUI.
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
prepareOutput(bool $show_sub_objects=true)
GUI class for the workflow of copying objects.
insertHeaderAction(?ilObjectListGUI $list_gui=null)
Insert header action into main template.
addHeaderAction()
Add header action menu.
Class ilObjectMetaDataGUI.
Class ilObject Basic functions for all objects.
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
activateTab(string $a_id)
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'vtt', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$info
Definition: entry_point.php:21
$service
Definition: ltiresult.php:44
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26