19 declare(strict_types=1);
34 protected \ILIAS\Notes\Service
$notes;
51 object $a_access_handler = null,
54 bool $a_enable_public_notes =
true,
55 bool $a_may_contribute =
true,
56 int $a_style_sheet_id = 0
60 $this->
tabs = $DIC->tabs();
61 $this->
locator = $DIC[
"ilLocator"];
63 $this->
user = $DIC->user();
65 $lng = $DIC->language();
66 $this->blog_request = $DIC->blog()
73 $this->node_id = $a_node_id;
74 $this->access_handler = $a_access_handler;
75 $this->enable_public_notes = $a_enable_public_notes;
80 $this->getBlogPosting()->setBlogNodeId($this->node_id, $this->
isInWorkspace());
81 $this->getBlogPosting()->getPageConfig()->setEditLockSupport(!$this->
isInWorkspace());
84 $this->may_contribute = $a_may_contribute;
91 "LOCATION_SYNTAX_STYLESHEET",
99 "LOCATION_CONTENT_STYLESHEET",
107 $this->blpg = $this->blog_request->getBlogPage();
108 $this->fetchall = $this->blog_request->getFetchAll();
109 $this->term = $this->blog_request->getTerm();
111 $this->reading_time_manager = new \ILIAS\Blog\ReadingTime\ReadingTimeManager();
112 $this->notes = $DIC->notes();
113 $this->profile_gui = $DIC->blog()->internal()->gui()->profile();
114 $this->blog_gui = $DIC->blog()->internal()->gui();
123 $next_class = $ilCtrl->getNextClass($this);
125 $posting = $this->getBlogPosting();
126 $ilCtrl->setParameter($this,
"blpg", $posting->getId());
128 switch ($next_class) {
135 if ($ilCtrl->getCmd() ===
"deactivatePageToList") {
136 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"blog_draft_info"),
true);
137 } elseif ($ilCtrl->getCmd() ===
"activatePageToList") {
138 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"blog_new_posting_info"),
true);
143 $posting->getTitle());
146 $this->
lng->txt(
"obj_blog")
150 $posting->getTitle(),
151 $ilCtrl->getLinkTarget($this,
"preview")
153 return parent::executeCommand();
171 if ($a_cmd ===
"contribute") {
174 return $this->access_handler->checkAccess($a_cmd,
"", $this->node_id);
178 string $a_mode = null
188 $this->getBlogPosting()->increaseViewCnt();
191 "tpl.blog_page_view_main_column.html",
200 $this->
ctrl->redirect($this,
"previewFullscreen");
203 $callback = array($this,
"observeNoteAction");
207 $may_delete_comments = ($this->
checkAccess(
"contribute") &&
213 $this->getBlogPosting(),
215 $this->enable_public_notes,
216 $may_delete_comments,
221 if ($a_mode !==
"embedded") {
228 $this->blog_gui->permanentLink(
$ref_id, $wsp_id)->setPermanentLink($this->blpg);
231 $wtpl->setVariable(
"PAGE", parent::preview());
235 $ilCtrl->setParameter($this,
"blpg", $this->getBlogPosting()->
getId());
245 return $this->
preview(
"embedded");
253 $this->add_date =
true;
254 return $this->
preview(
"fullscreen");
264 if ($a_title !==
"") {
270 $this->getBlogPosting()->increaseViewCnt();
271 return parent::showPage();
280 if (is_object($this->access_handler)) {
281 $class = get_class($this->access_handler);
284 return (
bool) stristr($class,
"workspace");
320 $author_id = $this->getBlogPosting()->getAuthor();
322 $authors[] = $this->profile_gui->getNamePresentation($author_id);
326 if ($editor[
"user_id"] != $author_id) {
327 $authors[] = $this->profile_gui->getNamePresentation($editor[
"user_id"]);
332 $author = implode(
", ", $authors) .
" - ";
337 $tpl =
new ilTemplate(
"tpl.posting_head.html",
true,
true,
"Modules/Blog");
340 $reading_time = $this->reading_time_manager->getReadingTime(
341 $this->getBlogPosting()->getParentId(),
342 $this->getBlogPosting()->
getId()
344 if (!is_null($reading_time)) {
345 $this->
lng->loadLanguageModule(
"copg");
349 $this->
lng->txt(
"copg_est_reading_time") .
": " .
350 sprintf($this->
lng->txt(
"copg_x_minutes"), $reading_time)
364 public function getTabs(
string $a_activate =
""): void
370 parent::getTabs($a_activate);
381 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
382 $confirmation_gui->setHeaderText(
$lng->
txt(
"blog_posting_deletion_confirmation"));
383 $confirmation_gui->setCancel(
$lng->
txt(
"cancel"),
"cancelBlogPostingDeletion");
384 $confirmation_gui->setConfirm(
$lng->
txt(
"delete"),
"confirmBlogPostingDeletion");
387 "tpl.blog_posting_deletion_confirmation.html",
393 $dtpl->setVariable(
"PAGE_TITLE", $this->getBlogPosting()->getTitle());
396 $cnt_note_users = $this->notes->domain()->getUserCount(
397 $this->getBlogPosting()->getParentId(),
398 $this->getBlogPosting()->
getId(),
402 "TXT_NUMBER_USERS_NOTES_OR_COMMENTS",
403 $lng->
txt(
"blog_number_users_notes_or_comments")
405 $dtpl->setVariable(
"TXT_NR_NOTES_COMMENTS", $cnt_note_users);
407 $confirmation_gui->addItem(
"",
"", $dtpl->get());
418 $ilCtrl->redirectByClass(
"ilobjbloggui",
"render");
428 $md_section = $this->getBlogPosting()->getMDSection();
429 foreach ($md_section->getKeywordIds() as
$id) {
430 $md_key = $md_section->getKeyword(
$id);
434 $this->getBlogPosting()->delete();
435 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
"blog_posting_deleted"),
true);
438 $ilCtrl->setParameterByClass(
"ilobjbloggui",
"blpg",
"");
439 $ilCtrl->redirectByClass(
"ilobjbloggui",
"render");
448 $ilTabs->setBackTarget($this->
lng->txt(
"back"), $this->
ctrl->getLinkTargetByClass(
"ilobjblogGUI"));
450 $ilTabs->activateTab(
"edit");
470 $page->handleNews(
true);
472 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
"settings_saved"),
true);
474 $this->
ctrl->redirectByClass(
"ilObjBlogGUI",
"");
492 $title->setRequired(
true);
509 $ilTabs->setBackTarget($this->
lng->txt(
"back"), $this->
ctrl->getLinkTargetByClass(
"ilobjblogGUI"));
511 $ilTabs->activateTab(
"edit");
528 $dt = $dt->getDate();
531 $page->setCreated($dt);
534 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
"settings_saved"),
true);
536 $this->
ctrl->redirectByClass(
"ilObjBlogGUI",
"");
555 $date->setShowTime(
true);
556 $date->setInfo(
$lng->
txt(
'blog_edit_date_info'));
569 $this->
ctrl->redirectByClass(
"ilObjBlogGUI",
"");
580 $note = $this->notes->domain()->getById($a_note_id);
581 $text = $note->getText();
589 return array(
"deactivatePage" =>
$lng->
txt(
"blog_toggle_draft"),
590 "activatePage" =>
$lng->
txt(
"blog_toggle_final"));
601 $this->getBlogPosting()->unpublish();
605 $this->
ctrl->redirect($this,
"edit");
607 $this->
ctrl->setParameterByClass(
"ilobjbloggui",
"blpg",
"");
608 $this->
ctrl->redirectByClass(
"ilobjbloggui",
"");
623 $this->getBlogPosting()->setActive(
true);
624 $this->getBlogPosting()->update(
true,
false);
627 $this->
ctrl->redirect($this,
"edit");
629 $this->
ctrl->setParameterByClass(
"ilobjbloggui",
"blpg",
"");
630 $this->
ctrl->redirectByClass(
"ilobjbloggui",
"");
641 $renderer = $DIC->ui()->renderer();
646 $ilTabs->clearTargets();
647 $ilTabs->setBackTarget($this->
lng->txt(
"back"), $this->
ctrl->getLinkTargetByClass(
"ilobjblogGUI"));
653 $ilTabs->activateTab(
"pg");
665 $ui_factory = $DIC->ui()->factory();
667 $md_section = $this->getBlogPosting()->getMDSection();
670 foreach ($ids = $md_section->getKeywordIds() as
$id) {
671 $md_key = $md_section->getKeyword(
$id);
672 if (trim($md_key->getKeyword()) !==
"") {
673 $keywords[] = $md_key->getKeyword();
680 if ($posting_id != $this->getBlogPosting()->
getId()) {
685 $other = array_unique($other);
686 sort($other, SORT_LOCALE_STRING);
688 $input_tag = $ui_factory->input()->field()->tag($this->
lng->txt(
"blog_keywords"), $other, $this->
lng->txt(
"blog_keyword_enter"))->withUserCreatedTagsAllowed(
true);
689 if (count($keywords) > 0) {
690 $input_tag = $input_tag->withValue($keywords);
693 $DIC->ctrl()->setParameter(
699 $section = $ui_factory->input()->field()->section([$input_tag], $this->
lng->txt(
"blog_edit_keywords"),
"");
701 $form_action = $DIC->ctrl()->getFormAction($this,
"saveKeywordsForm");
702 return $ui_factory->input()->container()->form()->standard($form_action, [
"tags" => $section]);
707 if ($this->node_id) {
709 return $this->access_handler->getTree()->lookupObjectId($this->node_id);
724 if (
$request->getMethod() ===
"POST" 725 &&
$request->getQueryParams()[
'tags'] ==
'tags_processing') {
727 $result =
$form->getData();
729 $keywords = $result[
"tags"][0];
732 if (is_array($keywords)) {
733 $this->getBlogPosting()->updateKeywords($keywords);
735 $this->getBlogPosting()->updateKeywords([]);
739 $this->
ctrl->setParameterByClass(ilObjBlogGUI::class,
"blpg",
"");
740 $this->
ctrl->redirectByClass(
"ilObjBlogGUI",
"");
749 bool $a_truncate =
false,
750 int $a_truncate_length = 500,
751 string $a_truncate_sign =
"...",
752 bool $a_include_picture =
false,
753 int $a_picture_width = 144,
754 int $a_picture_height = 144,
755 string $a_export_directory = null
757 $bpgui =
new self(0, null, $a_id);
761 if ($a_include_picture) {
762 $img = $bpgui->getFirstMediaObjectAsTag($a_picture_width, $a_picture_height, $a_export_directory);
765 $bpgui->setRawPageContent(
true);
766 $bpgui->setAbstractOnly(
true);
769 $bpgui->setFileDownloadLink(
".");
770 $bpgui->setFullscreenLink(
".");
771 $bpgui->setSourcecodeDownloadScript(
".");
772 $bpgui->setProfileBackUrl(
".");
775 $page = $bpgui->showPage();
782 $page =
'<div>' . $img . $page .
'</div><div style="clear:both;"></div>';
791 string $a_export_directory = null
793 $this->obj->buildDom();
794 $mob_ids = $this->obj->collectMediaObjects();
796 foreach ($mob_ids as $mob_id) {
798 $mob_item = $mob_obj->getMediaItem(
"Standard");
799 if (stripos($mob_item->getFormat(),
"image") !==
false) {
800 $mob_size = $mob_item->getOriginalSize();
801 if (is_null($mob_size)) {
804 if ($mob_size[
"width"] >= $a_width ||
805 $mob_size[
"height"] >= $a_height) {
806 if (!$a_export_directory) {
810 $mob_dir =
"./mobs/mm_" . $mob_obj->getId();
812 $mob_res = self::parseImage(
820 $location = $mob_item->getLocationType() ===
"Reference" 821 ? $mob_item->getLocation()
822 : $mob_dir .
"/" . $mob_item->getLocation();
826 ' width="' . $mob_res[0] .
'"' .
827 ' height="' . $mob_res[1] .
'"' .
828 ' class="ilBlogListItemSnippetPreviewImage ilFloatLeft noMirror"' .
843 $ratio_width = $ratio_height = 1;
844 if ($src_width > $tgt_width) {
845 $ratio_width = $tgt_width / $src_width;
847 if ($src_height > $tgt_height) {
848 $ratio_height = $tgt_height / $src_height;
850 $shrink_ratio = min($ratio_width, $ratio_height);
853 (
int) round($src_width * $shrink_ratio),
854 (
int) round($src_height * $shrink_ratio)
860 return $this->
lng->txt(
"blog_draft_text");
866 $this->getBlogPosting(),
868 $this->enable_public_notes,
881 $this->
ctrl->setParameterByClass(
"ilobjbloggui",
"bmn",
"");
882 $this->
ctrl->redirectByClass(
"ilobjbloggui",
"render");
previewEmbedded()
Needed for portfolio/blog handling.
editTitle(ilPropertyFormGUI $a_form=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getAllPostings(int $a_blog_id, int $a_limit=1000, int $a_offset=0)
Get all postings of blog.
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider .
Class ilBlogPosting GUI class.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
preview(string $a_mode=null)
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
setParameterByClass(string $a_class, string $a_parameter, $a_value)
editKeywords()
Diplay the keywords form.
static getPageContributors(string $a_parent_type, int $a_page_id, string $a_lang="-")
Get all contributors for parent object.
loadLanguageModule(string $a_module)
Load language module.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
deactivatePage(bool $a_to_list=false)
setLoginTargetPar(string $a_val)
Set target parameter for login (public sector).
setTitleIcon(string $a_icon_path, string $a_icon_desc="")
set title icon
setStyleId(int $a_styleid)
static useRelativeDates()
setTemplateOutput(bool $a_output=true)
static _lookupObjId(int $ref_id)
static parseImage(int $src_width, int $src_height, int $tgt_width, int $tgt_height)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS Blog ReadingTime ReadingTimeManager $reading_time_manager
getFirstMediaObjectAsTag(int $a_width=144, int $a_height=144, string $a_export_directory=null)
StandardGUIRequest $blog_request
previewFullscreen()
Needed for portfolio/blog handling.
static truncateHTML(string $a_text, int $a_length=100, string $a_ending='...', bool $a_exact=false, bool $a_consider_html=true)
Truncate (html) string.
__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)
static sendNotification(string $a_action, bool $a_in_wsp, int $a_blog_node_id, int $a_posting_id, ?string $a_comment=null)
static _lookupTitle(int $obj_id)
setContent(string $a_html)
Sets content for standard template.
setBlogPosting(ilBlogPosting $a_posting)
ilGlobalTemplateInterface $tpl
setPageObject(ilPageObject $a_pg_obj)
ILIAS Blog InternalGUIService $blog_gui
editDate(ilPropertyFormGUI $a_form=null)
clearTargets()
clear all targets
observeNoteAction(int $a_blog_id, int $a_posting_id, string $a_type, string $a_action, int $a_note_id)
static getSyntaxStylePath()
setPresentationTitle(string $a_title="")
checkAccess(string $a_cmd)
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
confirmBlogPostingDeletion()
activatePage(bool $a_to_list=false)
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
postOutputProcessing(string $a_output)
Finalizing output processing.
getPageHeading()
Get page heading see also https://docu.ilias.de/goto_docu_wiki_wpage_5793_1357.html the presentation ...
isInWorkspace()
Is current page part of personal workspace blog?
static getSnippet(int $a_id, 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.
showPage(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)
Get html for public and/or private notes.
static getKeywords(int $a_obj_id, int $a_posting_id)
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
bool $enable_public_notes
static setUseRelativeDates(bool $a_status)
set use relative dates
getTabs(string $a_activate="")
deleteBlogPostingConfirmationScreen()
ILIAS Notes Service $notes
cancelBlogPostingDeletion()
setEnableEditing(bool $a_enableediting)