ILIAS  trunk Revision v13.0_alpha-52-g21c366bbdd4
class.ilBlogPostingGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28
36{
40 protected \ILIAS\Notes\Service $notes;
43 protected ilTabsGUI $tabs;
46 protected LOMServices $lom_services;
48 protected int $node_id;
50 protected \ILIAS\COPage\Page\PageManagerInterface $page_manager;
51 protected ?object $access_handler = null;
52 protected bool $enable_public_notes = false;
53 protected bool $may_contribute = false;
54 protected bool $fetchall = false;
55 protected int $blpg = 0;
56 protected string $term = "";
57 public bool $add_date = false;
58
59 public function __construct(
60 int $a_node_id,
61 ?object $a_access_handler = null,
62 int $a_id = 0,
63 int $a_old_nr = 0,
64 bool $a_enable_public_notes = true,
65 bool $a_may_contribute = true,
66 int $a_style_sheet_id = 0
67 ) {
68 global $DIC;
69
70 $service = $DIC->blog()->internal();
71 $this->domain = $service->domain();
72 $this->blog_gui = $DIC->blog()->internal()->gui();
73
74 $this->tabs = $this->blog_gui->tabs();
75 $this->locator = $this->blog_gui->locator();
76 $this->settings = $this->domain->settings();
77 $this->user = $this->domain->user();
78 $tpl = $this->blog_gui->ui()->mainTemplate();
79 $lng = $this->domain->lng();
80 $this->blog_request = $this->blog_gui->standardRequest();
81 $this->lom_services = $DIC->learningObjectMetadata();
82
83 $lng->loadLanguageModule("blog");
84
85 $this->node_id = $a_node_id;
86 $this->access_handler = $a_access_handler;
87 $this->enable_public_notes = $a_enable_public_notes;
88
89 parent::__construct("blp", $a_id, $a_old_nr);
90
91 // needed for notification
92 $this->getBlogPosting()->setBlogNodeId($this->node_id, $this->isInWorkspace());
93 $this->getBlogPosting()->getPageConfig()->setEditLockSupport(!$this->isInWorkspace());
94
95 // #11151
96 $this->may_contribute = $a_may_contribute;
97 $this->setEnableEditing($a_may_contribute);
98
99 // content style
100
101 $tpl->setCurrentBlock("SyntaxStyle");
103 "LOCATION_SYNTAX_STYLESHEET",
105 );
107
108 // needed for editor
109 $this->setStyleId($a_style_sheet_id);
110
111 $this->blpg = $this->blog_request->getBlogPage();
112 $this->fetchall = $this->blog_request->getFetchAll();
113 $this->term = $this->blog_request->getTerm();
114
115 $this->reading_time_manager = new ReadingTimeManager();
116 $this->notes = $DIC->notes();
117 $this->profile_gui = $DIC->blog()->internal()->gui()->profile();
118 $this->posting_manager = $DIC->blog()->internal()->domain()->posting();
119 $this->page_manager = $this->domain->pageManager();
120 $this->toolbar = $DIC->toolbar();
121 }
122
123 public function executeCommand(): string
124 {
125 $ilCtrl = $this->ctrl;
126 $ilLocator = $this->locator;
128
129 $next_class = $ilCtrl->getNextClass($this);
130
131 $posting = $this->getBlogPosting();
132 $ilCtrl->setParameter($this, "blpg", $posting->getId());
133
134 switch ($next_class) {
135 case "ilcommentgui":
136 // $this->getTabs();
137 // $ilTabs->setTabActive("pg");
138 return $this->previewFullscreen();
139
140 default:
141 if ($ilCtrl->getCmd() === "deactivatePageToList") {
142 $this->tpl->setOnScreenMessage('success', $this->lng->txt("blog_draft_info"), true);
143 } elseif ($ilCtrl->getCmd() === "activatePageToList") {
144 $this->tpl->setOnScreenMessage('success', $this->lng->txt("blog_new_posting_info"), true);
145 }
146 $this->setPresentationTitle($posting->getTitle());
147
148 $tpl->setTitle(ilObject::_lookupTitle($this->getBlogPosting()->getBlogId()) . ": " . // #15017
149 $posting->getTitle());
151 ilUtil::getImagePath("standard/icon_blog.svg"),
152 $this->lng->txt("obj_blog")
153 ); // #12879
154
155 $ilLocator->addItem(
156 $posting->getTitle(),
157 $ilCtrl->getLinkTarget($this, "preview")
158 );
159 return parent::executeCommand();
160 }
161 }
162
163 public function setBlogPosting(ilBlogPosting $a_posting): void
164 {
165 $this->setPageObject($a_posting);
166 }
167
168 public function getBlogPosting(): ilBlogPosting
169 {
171 $bp = $this->getPageObject();
172 return $bp;
173 }
174
175 protected function checkAccess(string $a_cmd): bool
176 {
177 if ($a_cmd === "contribute") {
179 }
180 return $this->access_handler->checkAccess($a_cmd, "", $this->node_id);
181 }
182
183 public function preview(
184 ?string $a_mode = null
185 ): string {
186 $ilCtrl = $this->ctrl;
189
191 $append = "";
192
193 $this->getBlogPosting()->increaseViewCnt();
194
195 $wtpl = new ilTemplate(
196 "tpl.blog_page_view_main_column.html",
197 true,
198 true,
199 "components/ILIAS/Blog"
200 );
201
202 // page commands
203 if (!$a_mode) {
204 if (!$this->getEnableEditing()) {
205 $this->ctrl->redirect($this, "previewFullscreen");
206 }
207 } else {
208 $callback = array($this, "observeNoteAction");
209
210 // notes
211
212 $may_delete_comments = ($this->checkAccess("contribute") &&
213 $ilSetting->get("comments_del_tutor", '1'));
214
215 //$wtpl->setVariable("TOOLBAR", $toolbar->getHTML());
216
217 $wtpl->setVariable("NOTES", $this->getNotesHTML(
218 $this->getBlogPosting(),
219 false,
220 $this->enable_public_notes,
221 $may_delete_comments,
222 $callback,
223 false,
224 !$this->isInWorkspace()
225 ));
226 }
227 // permanent link
228 $ref_id = $this->isInWorkspace()
229 ? 0
231 $wsp_id = $this->isInWorkspace()
232 ? $this->node_id
233 : 0;
234 $this->blog_gui->permanentLink($ref_id, $wsp_id)->setPermanentLink($this->blpg);
235
236 $wtpl->setVariable("PAGE", parent::preview());
237
238 $tpl->setLoginTargetPar("blog_" . $this->node_id . $append);
239
240 $ilCtrl->setParameter($this, "blpg", $this->getBlogPosting()->getId());
241
242 return $wtpl->get();
243 }
244
245
249 public function previewFullscreen(): string
250 {
251 $this->add_date = true;
252 return $this->preview("fullscreen");
253 }
254
255 public function showPage(
256 string $a_title = ""
257 ): string {
258 $this->setTemplateOutput(false);
259
260 $this->setPresentationTitle("");
261 if (!$this->getAbstractOnly() && !$this->showPageHeading()) {
262 if ($a_title !== "") {
263 $this->setPresentationTitle($a_title);
264 } else {
265 $this->setPresentationTitle($this->getBlogPosting()->getTitle());
266 }
267 }
268 $this->getBlogPosting()->increaseViewCnt();
269 return parent::showPage();
270 }
271
275 protected function isInWorkspace(): bool
276 {
277 $class = '';
278 if (is_object($this->access_handler)) {
279 $class = get_class($this->access_handler);
280 }
281
282 return (bool) stristr($class, "workspace");
283 }
284
288 public function postOutputProcessing(
289 string $a_output
290 ): string {
291 // #8626/#9370
292 if ($this->showPageHeading()) {
293 $a_output = $this->getPageHeading() . $a_output;
294 }
295
296 return $a_output;
297 }
298
299 protected function showPageHeading(): bool
300 {
301 if (!$this->getAbstractOnly() && $this->add_date) {
302 return true;
303 }
304
305 return false;
306 }
307
313 protected function getPageHeading(): string
314 {
315 $author = "";
316 if (!$this->isInWorkspace()) {
317 $authors = array();
318 $author_id = $this->getBlogPosting()->getAuthor();
319 if ($author_id) {
320 $authors[] = $this->profile_gui->getNamePresentation($author_id);
321 }
322
323 foreach ($this->page_manager->getPageContributors("blp", $this->getBlogPosting()->getId()) as $editor) {
324 if ($editor["user_id"] != $author_id) {
325 $authors[] = $this->profile_gui->getNamePresentation($editor["user_id"]);
326 }
327 }
328
329 if ($authors) {
330 $author = implode(", ", $authors) . " - ";
331 }
332 }
335 $tpl = new ilTemplate("tpl.posting_head.html", true, true, "components/ILIAS/Blog");
336
337 // reading time
338 $reading_time = $this->reading_time_manager->getReadingTime(
339 $this->getBlogPosting()->getParentId(),
340 $this->getBlogPosting()->getId()
341 );
342 if (!is_null($reading_time)) {
343 $this->lng->loadLanguageModule("copg");
344 $tpl->setCurrentBlock("reading_time");
346 "READING_TIME",
347 $this->lng->txt("copg_est_reading_time") . ": " .
348 sprintf($this->lng->txt("copg_x_minutes"), $reading_time)
349 );
351 }
352
353 $tpl->setVariable("TITLE", $this->getBlogPosting()->getTitle());
355 "DATETIME",
356 $author . ilDatePresentation::formatDate($this->getBlogPosting()->getCreated())
357 );
359 return $tpl->get();
360 }
361
362 public function getTabs(string $a_activate = ""): void
363 {
364 $ilCtrl = $this->ctrl;
365
366 $ilCtrl->setParameterByClass("ilobjbloggui", "blpg", $this->getBlogPosting()->getId());
367
368 parent::getTabs($a_activate);
369 }
370
372 {
374 $ilCtrl = $this->ctrl;
376
377 if ($this->checkAccess("write") || $this->checkAccess("contribute")) {
378 $confirmation_gui = new ilConfirmationGUI();
379 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
380 $confirmation_gui->setHeaderText($lng->txt("blog_posting_deletion_confirmation"));
381 $confirmation_gui->setCancel($lng->txt("cancel"), "cancelBlogPostingDeletion");
382 $confirmation_gui->setConfirm($lng->txt("delete"), "confirmBlogPostingDeletion");
383
384 $dtpl = new ilTemplate(
385 "tpl.blog_posting_deletion_confirmation.html",
386 true,
387 true,
388 "components/ILIAS/Blog"
389 );
390
391 $dtpl->setVariable("PAGE_TITLE", $this->getBlogPosting()->getTitle());
392
393 // notes/comments
394 $cnt_note_users = $this->notes->domain()->getUserCount(
395 $this->getBlogPosting()->getParentId(),
396 $this->getBlogPosting()->getId(),
397 "blp"
398 );
399 $dtpl->setVariable(
400 "TXT_NUMBER_USERS_NOTES_OR_COMMENTS",
401 $lng->txt("blog_number_users_notes_or_comments")
402 );
403 $dtpl->setVariable("TXT_NR_NOTES_COMMENTS", $cnt_note_users);
404
405 $confirmation_gui->addItem("", "", $dtpl->get());
406
407 $tpl->setContent($confirmation_gui->getHTML());
408 }
409 }
410
411 public function cancelBlogPostingDeletion(): void
412 {
413 $ilCtrl = $this->ctrl;
414
415 $ilCtrl->setParameterByClass("ilobjbloggui", "blpg", ""); // #14363
416 $ilCtrl->redirectByClass("ilobjbloggui", "render");
417 }
418
419 public function confirmBlogPostingDeletion(): void
420 {
421 $ilCtrl = $this->ctrl;
423
424 if ($this->checkAccess("write") || $this->checkAccess("contribute")) {
425 // delete all md keywords
426 $this->lom_services->deleteAll(
427 $this->getBlogPosting()->getBlogId(),
428 $this->getBlogPosting()->getId(),
429 "blp"
430 );
431
432 $this->getBlogPosting()->delete();
433 $this->tpl->setOnScreenMessage('success', $lng->txt("blog_posting_deleted"), true);
434 }
435
436 $ilCtrl->setParameterByClass("ilobjbloggui", "blpg", ""); // #14363
437 $ilCtrl->redirectByClass("ilobjbloggui", "render");
438 }
439
440 public function editTitle(?ilPropertyFormGUI $a_form = null): void
441 {
443 $ilTabs = $this->tabs;
444
445 $ilTabs->clearTargets();
446 $ilTabs->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTargetByClass("ilobjblogGUI"));
447
448 $ilTabs->activateTab("edit");
449
450 if (!$a_form) {
451 $a_form = $this->initTitleForm();
452 }
453
454 $tpl->setContent($a_form->getHTML());
455 }
456
457 public function updateTitle(): void
458 {
460
461 $form = $this->initTitleForm();
462 if ($form->checkInput()) {
463 if ($this->checkAccess("write") || $this->checkAccess("contribute")) {
464 $page = $this->getPageObject();
465 $page->setTitle($form->getInput("title"));
466 $page->update();
467 $this->domain->news()->handle($page, true);
468
469 $this->tpl->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
470 //$ilCtrl->redirect($this, "preview");
471 $this->ctrl->redirectByClass("ilObjBlogGUI", "");
472 }
473 }
474
475 $form->setValuesByPost();
476 $this->editTitle($form);
477 }
478
480 {
482 $ilCtrl = $this->ctrl;
483
484 $form = new ilPropertyFormGUI();
485 $form->setFormAction($ilCtrl->getFormAction($this));
486 $form->setTitle($lng->txt('blog_rename_posting'));
487
488 $title = new ilTextInputGUI($lng->txt("title"), "title");
489 $title->setRequired(true);
490 $form->addItem($title);
491
492 $title->setValue($this->getPageObject()->getTitle());
493
494 $form->addCommandButton('updateTitle', $lng->txt('save'));
495 $form->addCommandButton('cancelEdit', $lng->txt('cancel'));
496
497 return $form;
498 }
499
500 public function editDate(?ilPropertyFormGUI $a_form = null): void
501 {
503 $ilTabs = $this->tabs;
504
505 $ilTabs->clearTargets();
506 $ilTabs->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTargetByClass("ilobjblogGUI"));
507
508 $ilTabs->activateTab("edit");
509
510 if (!$a_form) {
511 $a_form = $this->initDateForm();
512 }
513
514 $tpl->setContent($a_form->getHTML());
515 }
516
517 public function updateDate(): void
518 {
520
521 $form = $this->initDateForm();
522 if ($form->checkInput()) {
523 if ($this->checkAccess("write") || $this->checkAccess("contribute")) {
524 $dt = $form->getItemByPostVar("date");
525 $dt = $dt->getDate();
526
527 $page = $this->getPageObject();
528 $page->setCreated($dt);
529 $page->update();
530
531 $this->tpl->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
532 //$ilCtrl->redirect($this, "preview");
533 $this->ctrl->redirectByClass("ilObjBlogGUI", "");
534 }
535 }
536
537 $form->setValuesByPost();
538 $this->editTitle($form);
539 }
540
542 {
544 $ilCtrl = $this->ctrl;
545
546 $form = new ilPropertyFormGUI();
547 $form->setFormAction($ilCtrl->getFormAction($this));
548 $form->setTitle($lng->txt('blog_edit_date'));
549
550 $date = new ilDateTimeInputGUI($lng->txt("date"), "date");
551 $date->setRequired(true);
552 $date->setShowTime(true);
553 $date->setInfo($lng->txt('blog_edit_date_info'));
554 $form->addItem($date);
555
556 $date->setDate($this->getPageObject()->getCreated());
557
558 $form->addCommandButton('updateDate', $lng->txt('save'));
559 $form->addCommandButton('cancelEdit', $lng->txt('cancel'));
560
561 return $form;
562 }
563
564 protected function cancelEdit(): void
565 {
566 $this->ctrl->redirectByClass("ilObjBlogGUI", "");
567 }
568
569 public function observeNoteAction(
570 int $a_blog_id,
571 int $a_posting_id,
572 string $a_type,
573 string $a_action,
574 int $a_note_id
575 ): void {
576 // #10040 - get note text
577 $note = $this->notes->domain()->getById($a_note_id);
578 $text = $note->getText();
579 $this->domain->notification()->sendNotification("comment", $this->isInWorkspace(), $this->node_id, $a_posting_id, $text);
580 }
581
582 public function getActivationCaptions(): array
583 {
585
586 return array("deactivatePage" => $lng->txt("blog_toggle_draft"),
587 "activatePage" => $lng->txt("blog_toggle_final"));
588 }
589
590 public function deactivatePageToList(): void
591 {
592 $this->deactivatePage(true);
593 }
594
595 public function deactivatePage(bool $a_to_list = false): void
596 {
597 if ($this->checkAccess("write") || $this->checkAccess("contribute")) {
598 $this->getBlogPosting()->unpublish();
599 }
600
601 if (!$a_to_list) {
602 $this->ctrl->redirect($this, "edit");
603 } else {
604 $this->ctrl->setParameterByClass("ilobjbloggui", "blpg", "");
605 $this->ctrl->redirectByClass(
606 [
607 ilObjBlogGUI::class,
608 \ILIAS\Blog\Editing\EditingGUI::class,
609 ],
610 ""
611 );
612 }
613 }
614
615 public function activatePageToList(): void
616 {
617 $this->activatePage(true);
618 }
619
620 public function activatePage(bool $a_to_list = false): void
621 {
622 // send notifications
623 $this->domain->notification()->sendNotification("new", $this->isInWorkspace(), $this->node_id, $this->getBlogPosting()->getId());
624
625 if ($this->checkAccess("write") || $this->checkAccess("contribute")) {
626 $this->getBlogPosting()->setActive(true);
627 $this->getBlogPosting()->update(true, false);
628 }
629 if (!$a_to_list) {
630 $this->ctrl->redirect($this, "edit");
631 } else {
632 $this->ctrl->setParameterByClass("ilobjbloggui", "blpg", "");
633 $this->ctrl->redirectByClass(
634 [
635 ilObjBlogGUI::class,
636 \ILIAS\Blog\Editing\EditingGUI::class,
637 ],
638 ""
639 );
640 }
641 }
642
646 public function editKeywords(): void
647 {
648 $renderer = $this->blog_gui->ui()->renderer();
649
650 $ilTabs = $this->tabs;
652
653 $ilTabs->clearTargets();
654 $ilTabs->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTargetByClass("ilobjblogGUI"));
655
656 if (!$this->checkAccess("contribute")) {
657 return;
658 }
659
660 $ilTabs->activateTab("pg");
661
662 $tpl->setContent($renderer->render($this->initKeywordsForm()));
663 }
664
668 protected function initKeywordsForm(): \ILIAS\UI\Component\Input\Container\Form\Standard
669 {
670 $ui_factory = $this->blog_gui->ui()->factory();
671
672 $keywords = $this->posting_manager->getKeywords(
673 $this->getBlogPosting()->getBlogId(),
674 $this->getBlogPosting()->getId()
675 );
676
677 // other keywords in blog
678 $other = array();
679 foreach ($this->posting_manager->getAllByBlog($this->getBlogPosting()->getBlogId(), 0) as $posting) {
680 $pid = $posting->getId();
681 if ($pid !== $this->getBlogPosting()->getId()) {
682 $other = array_merge(
683 $other,
684 $this->posting_manager->getKeywords($this->getBlogPosting()->getBlogId(), $pid)
685 );
686 }
687 }
688 // #17414
689 $other = array_unique($other);
690 sort($other, SORT_LOCALE_STRING);
691
692 $input_tag = $ui_factory->input()->field()->tag($this->lng->txt("blog_keywords"), $other, $this->lng->txt("blog_keyword_enter"))->withUserCreatedTagsAllowed(true);
693 if (count($keywords) > 0) {
694 $input_tag = $input_tag->withValue($keywords);
695 }
696
697 $this->ctrl->setParameter(
698 $this,
699 'tags',
700 'tags_processing'
701 );
702
703 $section = $ui_factory->input()->field()->section([$input_tag], $this->lng->txt("blog_edit_keywords"), "");
704
705 $form_action = $this->ctrl->getFormAction($this, "saveKeywordsForm");
706 return $ui_factory->input()->container()->form()->standard($form_action, ["tags" => $section]);
707 }
708
709 protected function getParentObjId(): int
710 {
711 if ($this->node_id) {
712 if ($this->isInWorkspace()) {
713 return $this->access_handler->getTree()->lookupObjectId($this->node_id);
714 }
715
716 return ilObject::_lookupObjId($this->node_id);
717 }
718 return 0;
719 }
720
721 public function saveKeywordsForm(): void
722 {
723 $request = $this->blog_gui->http()->request();
724 $form = $this->initKeywordsForm();
725
726 if ($request->getMethod() === "POST"
727 && $request->getQueryParams()['tags'] == 'tags_processing') {
728 $form = $form->withRequest($request);
729 $result = $form->getData();
730 //TODO identify the input instead of use 0
731 $keywords = $result["tags"][0];
732
733 if ($this->checkAccess("write") || $this->checkAccess("contribute")) {
734 if (is_array($keywords)) {
735 $this->getBlogPosting()->updateKeywords($keywords);
736 } else {
737 $this->getBlogPosting()->updateKeywords([]);
738 }
739 }
740
741 $this->ctrl->setParameterByClass(ilObjBlogGUI::class, "blpg", "");
742 $this->ctrl->redirectByClass("ilObjBlogGUI", "");
743 }
744 }
745
749 public function getSnippet(
750 bool $a_truncate = false,
751 int $a_truncate_length = 500,
752 string $a_truncate_sign = "...",
753 bool $a_include_picture = false,
754 int $a_picture_width = 144,
755 int $a_picture_height = 144,
756 ?string $a_export_directory = null
757 ): string {
758 // scan the full page for media objects
759 $img = "";
760 if ($a_include_picture) {
761 $img = $this->getFirstMediaObjectAsTag($a_picture_width, $a_picture_height, $a_export_directory);
762 }
763
764 $this->setRawPageContent(true);
765 $this->setAbstractOnly(true);
766
767 // #8627: export won't work - should we set offline mode?
768 $this->setFileDownloadLink(".");
769 $this->setFullscreenLink(".");
770 $this->setSourcecodeDownloadScript(".");
771 $this->setProfileBackUrl(".");
772
773 // render without title
774 $page = $this->showPage();
775
776 if ($a_truncate) {
777 $page = ilPageObject::truncateHTML($page, $a_truncate_length, $a_truncate_sign);
778 }
779
780 if ($img) {
781 $page = '<div>' . $img . $page . '</div><div style="clear:both;"></div>';
782 }
783
784 return $page;
785 }
786
787 protected function getFirstMediaObjectAsTag(
788 int $a_width = 144,
789 int $a_height = 144,
790 ?string $a_export_directory = null
791 ): string {
792 $this->obj->buildDom();
793 $mob_ids = $this->obj->collectMediaObjects();
794 if ($mob_ids) {
795 foreach ($mob_ids as $mob_id) {
796 $mob_obj = new ilObjMediaObject((int) $mob_id);
797 $mob_item = $mob_obj->getMediaItem("Standard");
798 if (stripos($mob_item->getFormat(), "image") !== false) {
799 if ($mob_item->getFormat() === "image/svg+xml") {
800 $location = $mob_obj->getStandardSrc();
801 return '<img' .
802 ' src="' . $location . '"' .
803 ' style="max-width: ' . $a_width . 'px; height: auto;"' .
804 ' class="ilBlogListItemSnippetPreviewImage ilFloatLeft noMirror"' .
805 ' />';
806 }
807 $mob_size = $mob_item->getOriginalSize();
808 if (is_null($mob_size)) {
809 continue;
810 }
811 if ($mob_size["width"] >= $a_width ||
812 $mob_size["height"] >= $a_height) {
813 if (!$a_export_directory) {
814 $mob_dir = ilObjMediaObject::_getDirectory($mob_obj->getId());
815 } else {
816 // see ilCOPageHTMLExport::exportHTMLMOB()
817 $mob_dir = "./mobs/mm_" . $mob_obj->getId();
818 }
819 $mob_res = $this->parseImage(
820 $mob_size["width"],
821 $mob_size["height"],
822 $a_width,
823 $a_height
824 );
825
826
827 $location = $mob_obj->getStandardSrc();
828
829 return '<img' .
830 ' src="' . $location . '"' .
831 ' width="' . $mob_res[0] . '"' .
832 ' height="' . $mob_res[1] . '"' .
833 ' class="ilBlogListItemSnippetPreviewImage ilFloatLeft noMirror"' .
834 ' />';
835 }
836 }
837 }
838 }
839 return "";
840 }
841
842 protected function parseImage(
843 int $src_width,
844 int $src_height,
845 int $tgt_width,
846 int $tgt_height
847 ): array {
848 $ratio_width = $ratio_height = 1;
849 if ($src_width > $tgt_width) {
850 $ratio_width = $tgt_width / $src_width;
851 }
852 if ($src_height > $tgt_height) {
853 $ratio_height = $tgt_height / $src_height;
854 }
855 $shrink_ratio = min($ratio_width, $ratio_height);
856
857 return array(
858 (int) round($src_width * $shrink_ratio),
859 (int) round($src_height * $shrink_ratio)
860 );
861 }
862
863 public function getDisabledText(): string
864 {
865 return $this->lng->txt("blog_draft_text");
866 }
867
868 public function getCommentsHTMLExport(): string
869 {
870 return $this->getNotesHTML(
871 $this->getBlogPosting(),
872 false,
873 $this->enable_public_notes,
874 false,
875 null,
876 true,
877 !$this->isInWorkspace()
878 );
879 }
880
881 protected function showEditToolbar(): void
882 {
883 }
884
885 public function finishEditing(): void
886 {
887 $this->ctrl->setParameterByClass("ilobjbloggui", "bmn", "");
888 $this->ctrl->redirectByClass(
889 [
890 ilObjBlogGUI::class,
891 \ILIAS\Blog\Editing\EditingGUI::class
892 ],
893 ""
894 );
895 }
896}
$location
Definition: buildRTE.php:22
$renderer
Class ilBlogPosting GUI class.
PostingManager $posting_manager
getActivationCaptions()
Get captions for activation action menu entries.
isInWorkspace()
Is current page part of personal workspace blog?
InternalGUIService $blog_gui
__construct(int $a_node_id, ?object $a_access_handler=null, int $a_id=0, int $a_old_nr=0, bool $a_enable_public_notes=true, bool $a_may_contribute=true, int $a_style_sheet_id=0)
getTabs(string $a_activate="")
previewFullscreen()
Needed for portfolio/blog handling.
ILIAS Notes Service $notes
ReadingTimeManager $reading_time_manager
getSnippet(bool $a_truncate=false, int $a_truncate_length=500, string $a_truncate_sign="...", bool $a_include_picture=false, int $a_picture_width=144, int $a_picture_height=144, ?string $a_export_directory=null)
Get first text paragraph of page.
InternalDomainService $domain
observeNoteAction(int $a_blog_id, int $a_posting_id, string $a_type, string $a_action, int $a_note_id)
postOutputProcessing(string $a_output)
Finalizing output processing.
executeCommand()
execute command
setBlogPosting(ilBlogPosting $a_posting)
preview(?string $a_mode=null)
editDate(?ilPropertyFormGUI $a_form=null)
getFirstMediaObjectAsTag(int $a_width=144, int $a_height=144, ?string $a_export_directory=null)
editTitle(?ilPropertyFormGUI $a_form=null)
getPageHeading()
Get page heading see also https://docu.ilias.de/goto_docu_wiki_wpage_5793_1357.html the presentation ...
ILIAS COPage Page PageManagerInterface $page_manager
parseImage(int $src_width, int $src_height, int $tgt_width, int $tgt_height)
deactivatePage(bool $a_to_list=false)
StandardGUIRequest $blog_request
showPage(string $a_title="")
showEditToolbar()
Show edit toolbar.
editKeywords()
Diplay the keywords form.
activatePage(bool $a_to_list=false)
Class ilBlogPosting.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
This class represents a date/time property in a property form.
loadLanguageModule(string $a_module)
Load language module.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getDirectory(int $a_mob_id)
Get absolute directory.
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
Class ilPageObjectGUI.
setStyleId(int $a_styleid)
setPresentationTitle(string $a_title="")
getNotesHTML(?object $a_content_object=null, bool $a_enable_private_notes=true, bool $a_enable_public_notes=false, bool $a_enable_notes_deletion=false, ?callable $a_callback=null, bool $export=false, bool $a_repository_mode=true)
Get html for public and/or private notes.
ilGlobalTemplateInterface $tpl
setEnableEditing(bool $a_enableediting)
setPageObject(ilPageObject $a_pg_obj)
static truncateHTML(string $a_text, int $a_length=100, string $a_ending='...', bool $a_exact=false, bool $a_consider_html=true)
Truncate (html) string.
This class represents a property form user interface.
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
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...
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
setLoginTargetPar(string $a_val)
Set target parameter for login (public sector).
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
setTitleIcon(string $a_icon_path, string $a_icon_desc="")
set title icon
setContent(string $a_html)
Sets content for standard template.
$request
@ilCtrl_Calls ilObjLearningSequenceContentGUI: ilObjLearningSequenceConditionsGUI
Definition: ltiauth.php:39
$service
Definition: ltiresult.php:44
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
readonly ilGlobalTemplateInterface $tpl
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $lng
Definition: privfeed.php:26
global $ilSetting
Definition: privfeed.php:26
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
$text
Definition: xapiexit.php:21