19declare(strict_types=1);
40 protected \ILIAS\Notes\Service
$notes;
61 ?
object $a_access_handler =
null,
64 bool $a_enable_public_notes =
true,
65 bool $a_may_contribute =
true,
66 int $a_style_sheet_id = 0
72 $this->blog_gui =
$DIC->blog()->internal()->gui();
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();
85 $this->node_id = $a_node_id;
86 $this->access_handler = $a_access_handler;
87 $this->enable_public_notes = $a_enable_public_notes;
92 $this->getBlogPosting()->setBlogNodeId($this->node_id, $this->
isInWorkspace());
93 $this->getBlogPosting()->getPageConfig()->setEditLockSupport(!$this->
isInWorkspace());
96 $this->may_contribute = $a_may_contribute;
103 "LOCATION_SYNTAX_STYLESHEET",
111 $this->blpg = $this->blog_request->getBlogPage();
112 $this->fetchall = $this->blog_request->getFetchAll();
113 $this->term = $this->blog_request->getTerm();
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();
129 $next_class = $ilCtrl->getNextClass($this);
131 $posting = $this->getBlogPosting();
132 $ilCtrl->setParameter($this,
"blpg", $posting->getId());
134 switch ($next_class) {
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);
149 $posting->getTitle());
152 $this->
lng->txt(
"obj_blog")
156 $posting->getTitle(),
157 $ilCtrl->getLinkTarget($this,
"preview")
159 return parent::executeCommand();
177 if ($a_cmd ===
"contribute") {
180 return $this->access_handler->checkAccess($a_cmd,
"", $this->node_id);
184 ?
string $a_mode =
null
186 $ilCtrl = $this->
ctrl;
193 $this->getBlogPosting()->increaseViewCnt();
196 "tpl.blog_page_view_main_column.html",
199 "components/ILIAS/Blog"
205 $this->
ctrl->redirect($this,
"previewFullscreen");
208 $callback = array($this,
"observeNoteAction");
212 $may_delete_comments = ($this->
checkAccess(
"contribute") &&
218 $this->getBlogPosting(),
220 $this->enable_public_notes,
221 $may_delete_comments,
234 $this->blog_gui->permanentLink($ref_id, $wsp_id)->setPermanentLink($this->blpg);
240 $ilCtrl->setParameter($this,
"blpg", $this->getBlogPosting()->
getId());
251 $this->add_date =
true;
252 return $this->
preview(
"fullscreen");
258 $this->setTemplateOutput(false);
260 $this->setPresentationTitle(
"");
261 if (!$this->getAbstractOnly() && !$this->showPageHeading()) {
262 if ($a_title !==
"") {
263 $this->setPresentationTitle($a_title);
265 $this->setPresentationTitle($this->getBlogPosting()->
getTitle());
268 $this->getBlogPosting()->increaseViewCnt();
269 return parent::showPage();
278 if (is_object($this->access_handler)) {
279 $class = get_class($this->access_handler);
282 return (
bool) stristr($class,
"workspace");
292 if ($this->showPageHeading()) {
293 $a_output = $this->getPageHeading() . $a_output;
301 if (!$this->getAbstractOnly() && $this->add_date) {
316 if (!$this->isInWorkspace()) {
318 $author_id = $this->getBlogPosting()->getAuthor();
320 $authors[] = $this->profile_gui->getNamePresentation($author_id);
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"]);
330 $author = implode(
", ", $authors) .
" - ";
335 $tpl =
new ilTemplate(
"tpl.posting_head.html",
true,
true,
"components/ILIAS/Blog");
338 $reading_time = $this->reading_time_manager->getReadingTime(
339 $this->getBlogPosting()->getParentId(),
340 $this->getBlogPosting()->
getId()
342 if (!is_null($reading_time)) {
343 $this->
lng->loadLanguageModule(
"copg");
347 $this->
lng->txt(
"copg_est_reading_time") .
": " .
348 sprintf($this->
lng->txt(
"copg_x_minutes"), $reading_time)
362 public function getTabs(
string $a_activate =
""): void
364 $ilCtrl = $this->ctrl;
366 $ilCtrl->setParameterByClass(
"ilobjbloggui",
"blpg", $this->getBlogPosting()->
getId());
368 parent::getTabs($a_activate);
374 $ilCtrl = $this->ctrl;
377 if ($this->checkAccess(
"write") || $this->checkAccess(
"contribute")) {
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");
385 "tpl.blog_posting_deletion_confirmation.html",
388 "components/ILIAS/Blog"
391 $dtpl->setVariable(
"PAGE_TITLE", $this->getBlogPosting()->
getTitle());
394 $cnt_note_users = $this->notes->domain()->getUserCount(
395 $this->getBlogPosting()->getParentId(),
396 $this->getBlogPosting()->
getId(),
400 "TXT_NUMBER_USERS_NOTES_OR_COMMENTS",
401 $lng->txt(
"blog_number_users_notes_or_comments")
403 $dtpl->setVariable(
"TXT_NR_NOTES_COMMENTS", $cnt_note_users);
405 $confirmation_gui->addItem(
"",
"", $dtpl->get());
413 $ilCtrl = $this->ctrl;
415 $ilCtrl->setParameterByClass(
"ilobjbloggui",
"blpg",
"");
416 $ilCtrl->redirectByClass(
"ilobjbloggui",
"render");
421 $ilCtrl = $this->ctrl;
424 if ($this->checkAccess(
"write") || $this->checkAccess(
"contribute")) {
426 $this->lom_services->deleteAll(
427 $this->getBlogPosting()->getBlogId(),
428 $this->getBlogPosting()->
getId(),
432 $this->getBlogPosting()->delete();
433 $this->tpl->setOnScreenMessage(
'success',
$lng->txt(
"blog_posting_deleted"),
true);
436 $ilCtrl->setParameterByClass(
"ilobjbloggui",
"blpg",
"");
437 $ilCtrl->redirectByClass(
"ilobjbloggui",
"render");
443 $ilTabs = $this->tabs;
445 $ilTabs->clearTargets();
446 $ilTabs->setBackTarget($this->
lng->txt(
"back"), $this->ctrl->getLinkTargetByClass(
"ilobjblogGUI"));
448 $ilTabs->activateTab(
"edit");
451 $a_form = $this->initTitleForm();
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"));
467 $this->domain->news()->handle(
$page,
true);
469 $this->tpl->setOnScreenMessage(
'success',
$lng->txt(
"settings_saved"),
true);
471 $this->
ctrl->redirectByClass(
"ilObjBlogGUI",
"");
475 $form->setValuesByPost();
476 $this->editTitle($form);
482 $ilCtrl = $this->ctrl;
485 $form->setFormAction($ilCtrl->getFormAction($this));
486 $form->setTitle(
$lng->txt(
'blog_rename_posting'));
489 $title->setRequired(
true);
490 $form->addItem($title);
492 $title->setValue($this->getPageObject()->
getTitle());
494 $form->addCommandButton(
'updateTitle',
$lng->txt(
'save'));
495 $form->addCommandButton(
'cancelEdit',
$lng->txt(
'cancel'));
503 $ilTabs = $this->tabs;
505 $ilTabs->clearTargets();
506 $ilTabs->setBackTarget($this->
lng->txt(
"back"), $this->ctrl->getLinkTargetByClass(
"ilobjblogGUI"));
508 $ilTabs->activateTab(
"edit");
511 $a_form = $this->initDateForm();
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();
527 $page = $this->getPageObject();
528 $page->setCreated($dt);
531 $this->tpl->setOnScreenMessage(
'success',
$lng->txt(
"settings_saved"),
true);
533 $this->
ctrl->redirectByClass(
"ilObjBlogGUI",
"");
537 $form->setValuesByPost();
538 $this->editTitle($form);
544 $ilCtrl = $this->ctrl;
547 $form->setFormAction($ilCtrl->getFormAction($this));
548 $form->setTitle(
$lng->txt(
'blog_edit_date'));
551 $date->setRequired(
true);
552 $date->setShowTime(
true);
553 $date->setInfo(
$lng->txt(
'blog_edit_date_info'));
554 $form->addItem($date);
556 $date->setDate($this->getPageObject()->getCreated());
558 $form->addCommandButton(
'updateDate',
$lng->txt(
'save'));
559 $form->addCommandButton(
'cancelEdit',
$lng->txt(
'cancel'));
566 $this->
ctrl->redirectByClass(
"ilObjBlogGUI",
"");
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);
586 return array(
"deactivatePage" =>
$lng->txt(
"blog_toggle_draft"),
587 "activatePage" =>
$lng->txt(
"blog_toggle_final"));
592 $this->deactivatePage(
true);
597 if ($this->checkAccess(
"write") || $this->checkAccess(
"contribute")) {
598 $this->getBlogPosting()->unpublish();
602 $this->
ctrl->redirect($this,
"edit");
604 $this->
ctrl->setParameterByClass(
"ilobjbloggui",
"blpg",
"");
605 $this->
ctrl->redirectByClass(
608 \
ILIAS\Blog\Editing\EditingGUI::class,
617 $this->activatePage(
true);
623 $this->domain->notification()->sendNotification(
"new", $this->isInWorkspace(), $this->node_id, $this->getBlogPosting()->
getId());
625 if ($this->checkAccess(
"write") || $this->checkAccess(
"contribute")) {
626 $this->getBlogPosting()->setActive(
true);
627 $this->getBlogPosting()->update(
true,
false);
630 $this->
ctrl->redirect($this,
"edit");
632 $this->
ctrl->setParameterByClass(
"ilobjbloggui",
"blpg",
"");
633 $this->
ctrl->redirectByClass(
636 \
ILIAS\Blog\Editing\EditingGUI::class,
648 $renderer = $this->blog_gui->ui()->renderer();
650 $ilTabs = $this->tabs;
653 $ilTabs->clearTargets();
654 $ilTabs->setBackTarget($this->
lng->txt(
"back"), $this->ctrl->getLinkTargetByClass(
"ilobjblogGUI"));
656 if (!$this->checkAccess(
"contribute")) {
660 $ilTabs->activateTab(
"pg");
670 $ui_factory = $this->blog_gui->ui()->factory();
672 $keywords = $this->posting_manager->getKeywords(
673 $this->getBlogPosting()->getBlogId(),
674 $this->getBlogPosting()->
getId()
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(
684 $this->posting_manager->getKeywords($this->getBlogPosting()->getBlogId(), $pid)
689 $other = array_unique($other);
690 sort($other, SORT_LOCALE_STRING);
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);
697 $this->
ctrl->setParameter(
703 $section = $ui_factory->input()->field()->section([$input_tag], $this->
lng->txt(
"blog_edit_keywords"),
"");
705 $form_action = $this->
ctrl->getFormAction($this,
"saveKeywordsForm");
706 return $ui_factory->input()->container()->form()->standard($form_action, [
"tags" => $section]);
711 if ($this->node_id) {
712 if ($this->isInWorkspace()) {
713 return $this->access_handler->getTree()->lookupObjectId($this->node_id);
723 $request = $this->blog_gui->http()->request();
724 $form = $this->initKeywordsForm();
726 if (
$request->getMethod() ===
"POST"
727 &&
$request->getQueryParams()[
'tags'] ==
'tags_processing') {
728 $form = $form->withRequest(
$request);
729 $result = $form->getData();
731 $keywords = $result[
"tags"][0];
733 if ($this->checkAccess(
"write") || $this->checkAccess(
"contribute")) {
734 if (is_array($keywords)) {
735 $this->getBlogPosting()->updateKeywords($keywords);
737 $this->getBlogPosting()->updateKeywords([]);
741 $this->
ctrl->setParameterByClass(ilObjBlogGUI::class,
"blpg",
"");
742 $this->
ctrl->redirectByClass(
"ilObjBlogGUI",
"");
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
760 if ($a_include_picture) {
761 $img = $this->getFirstMediaObjectAsTag($a_picture_width, $a_picture_height, $a_export_directory);
764 $this->setRawPageContent(
true);
765 $this->setAbstractOnly(
true);
768 $this->setFileDownloadLink(
".");
769 $this->setFullscreenLink(
".");
770 $this->setSourcecodeDownloadScript(
".");
771 $this->setProfileBackUrl(
".");
774 $page = $this->showPage();
781 $page =
'<div>' . $img .
$page .
'</div><div style="clear:both;"></div>';
790 ?
string $a_export_directory =
null
792 $this->obj->buildDom();
793 $mob_ids = $this->obj->collectMediaObjects();
795 foreach ($mob_ids as $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") {
803 ' style="max-width: ' . $a_width .
'px; height: auto;"' .
804 ' class="ilBlogListItemSnippetPreviewImage ilFloatLeft noMirror"' .
807 $mob_size = $mob_item->getOriginalSize();
808 if (is_null($mob_size)) {
811 if ($mob_size[
"width"] >= $a_width ||
812 $mob_size[
"height"] >= $a_height) {
813 if (!$a_export_directory) {
817 $mob_dir =
"./mobs/mm_" . $mob_obj->getId();
819 $mob_res = $this->parseImage(
831 ' width="' . $mob_res[0] .
'"' .
832 ' height="' . $mob_res[1] .
'"' .
833 ' class="ilBlogListItemSnippetPreviewImage ilFloatLeft noMirror"' .
848 $ratio_width = $ratio_height = 1;
849 if ($src_width > $tgt_width) {
850 $ratio_width = $tgt_width / $src_width;
852 if ($src_height > $tgt_height) {
853 $ratio_height = $tgt_height / $src_height;
855 $shrink_ratio = min($ratio_width, $ratio_height);
858 (
int) round($src_width * $shrink_ratio),
859 (
int) round($src_height * $shrink_ratio)
865 return $this->
lng->txt(
"blog_draft_text");
870 return $this->getNotesHTML(
871 $this->getBlogPosting(),
873 $this->enable_public_notes,
877 !$this->isInWorkspace()
887 $this->
ctrl->setParameterByClass(
"ilobjbloggui",
"bmn",
"");
888 $this->
ctrl->redirectByClass(
891 \
ILIAS\Blog\Editing\EditingGUI::class
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
LOMServices $lom_services
__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
deleteBlogPostingConfirmationScreen()
setBlogPosting(ilBlogPosting $a_posting)
cancelBlogPostingDeletion()
preview(?string $a_mode=null)
editDate(?ilPropertyFormGUI $a_form=null)
getFirstMediaObjectAsTag(int $a_width=144, int $a_height=144, ?string $a_export_directory=null)
confirmBlogPostingDeletion()
editTitle(?ilPropertyFormGUI $a_form=null)
getPageHeading()
Get page heading see also https://docu.ilias.de/goto_docu_wiki_wpage_5793_1357.html the presentation ...
bool $enable_public_notes
checkAccess(string $a_cmd)
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static useRelativeDates()
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,)
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 getSyntaxStylePath()
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
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 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.
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
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
readonly ilGlobalTemplateInterface $tpl
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
if(!file_exists('../ilias.ini.php'))