19 declare(strict_types=1);
40 protected \ILIAS\Notes\Service
$notes;
59 ?
object $a_access_handler =
null,
62 bool $a_enable_public_notes =
true,
63 bool $a_may_contribute =
true,
64 int $a_style_sheet_id = 0
70 $this->blog_gui = $DIC->blog()->internal()->gui();
72 $this->
tabs = $this->blog_gui->tabs();
73 $this->
locator = $this->blog_gui->locator();
74 $this->
settings = $this->domain->settings();
75 $this->
user = $this->domain->user();
76 $tpl = $this->blog_gui->ui()->mainTemplate();
77 $lng = $this->domain->lng();
78 $this->blog_request = $this->blog_gui->standardRequest();
79 $this->lom_services = $DIC->learningObjectMetadata();
83 $this->node_id = $a_node_id;
84 $this->access_handler = $a_access_handler;
85 $this->enable_public_notes = $a_enable_public_notes;
90 $this->getBlogPosting()->setBlogNodeId($this->node_id, $this->
isInWorkspace());
91 $this->getBlogPosting()->getPageConfig()->setEditLockSupport(!$this->
isInWorkspace());
94 $this->may_contribute = $a_may_contribute;
101 "LOCATION_SYNTAX_STYLESHEET",
109 $this->blpg = $this->blog_request->getBlogPage();
110 $this->fetchall = $this->blog_request->getFetchAll();
111 $this->term = $this->blog_request->getTerm();
114 $this->notes = $DIC->notes();
115 $this->profile_gui = $DIC->blog()->internal()->gui()->profile();
116 $this->posting_manager = $DIC->blog()->internal()->domain()->posting();
125 $next_class = $ilCtrl->getNextClass($this);
127 $posting = $this->getBlogPosting();
128 $ilCtrl->setParameter($this,
"blpg", $posting->getId());
130 switch ($next_class) {
137 if ($ilCtrl->getCmd() ===
"deactivatePageToList") {
138 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"blog_draft_info"),
true);
139 } elseif ($ilCtrl->getCmd() ===
"activatePageToList") {
140 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"blog_new_posting_info"),
true);
145 $posting->getTitle());
148 $this->
lng->txt(
"obj_blog")
152 $posting->getTitle(),
153 $ilCtrl->getLinkTarget($this,
"preview")
155 return parent::executeCommand();
173 if ($a_cmd ===
"contribute") {
176 return $this->access_handler->checkAccess($a_cmd,
"", $this->node_id);
180 ?
string $a_mode =
null 190 $this->getBlogPosting()->increaseViewCnt();
193 "tpl.blog_page_view_main_column.html",
196 "components/ILIAS/Blog" 202 $this->
ctrl->redirect($this,
"previewFullscreen");
205 $callback = array($this,
"observeNoteAction");
209 $may_delete_comments = ($this->
checkAccess(
"contribute") &&
215 $this->getBlogPosting(),
217 $this->enable_public_notes,
218 $may_delete_comments,
229 $this->blog_gui->permanentLink(
$ref_id, $wsp_id)->setPermanentLink($this->blpg);
235 $ilCtrl->setParameter($this,
"blpg", $this->getBlogPosting()->
getId());
246 $this->add_date =
true;
247 return $this->
preview(
"fullscreen");
257 if ($a_title !==
"") {
263 $this->getBlogPosting()->increaseViewCnt();
264 return parent::showPage();
273 if (is_object($this->access_handler)) {
274 $class = get_class($this->access_handler);
277 return (
bool) stristr($class,
"workspace");
313 $author_id = $this->getBlogPosting()->getAuthor();
315 $authors[] = $this->profile_gui->getNamePresentation($author_id);
319 if ($editor[
"user_id"] != $author_id) {
320 $authors[] = $this->profile_gui->getNamePresentation($editor[
"user_id"]);
325 $author = implode(
", ", $authors) .
" - ";
330 $tpl =
new ilTemplate(
"tpl.posting_head.html",
true,
true,
"components/ILIAS/Blog");
333 $reading_time = $this->reading_time_manager->getReadingTime(
334 $this->getBlogPosting()->getParentId(),
335 $this->getBlogPosting()->
getId()
337 if (!is_null($reading_time)) {
338 $this->
lng->loadLanguageModule(
"copg");
342 $this->
lng->txt(
"copg_est_reading_time") .
": " .
343 sprintf($this->
lng->txt(
"copg_x_minutes"), $reading_time)
357 public function getTabs(
string $a_activate =
""): void
363 parent::getTabs($a_activate);
374 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
375 $confirmation_gui->setHeaderText(
$lng->
txt(
"blog_posting_deletion_confirmation"));
376 $confirmation_gui->setCancel(
$lng->
txt(
"cancel"),
"cancelBlogPostingDeletion");
377 $confirmation_gui->setConfirm(
$lng->
txt(
"delete"),
"confirmBlogPostingDeletion");
380 "tpl.blog_posting_deletion_confirmation.html",
383 "components/ILIAS/Blog" 386 $dtpl->setVariable(
"PAGE_TITLE", $this->getBlogPosting()->
getTitle());
389 $cnt_note_users = $this->notes->domain()->getUserCount(
390 $this->getBlogPosting()->getParentId(),
391 $this->getBlogPosting()->
getId(),
395 "TXT_NUMBER_USERS_NOTES_OR_COMMENTS",
396 $lng->
txt(
"blog_number_users_notes_or_comments")
398 $dtpl->setVariable(
"TXT_NR_NOTES_COMMENTS", $cnt_note_users);
400 $confirmation_gui->addItem(
"",
"", $dtpl->get());
411 $ilCtrl->redirectByClass(
"ilobjbloggui",
"render");
421 $this->lom_services->deleteAll(
422 $this->getBlogPosting()->getBlogId(),
423 $this->getBlogPosting()->
getId(),
427 $this->getBlogPosting()->delete();
428 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
"blog_posting_deleted"),
true);
431 $ilCtrl->setParameterByClass(
"ilobjbloggui",
"blpg",
"");
432 $ilCtrl->redirectByClass(
"ilobjbloggui",
"render");
441 $ilTabs->setBackTarget($this->
lng->txt(
"back"), $this->
ctrl->getLinkTargetByClass(
"ilobjblogGUI"));
443 $ilTabs->activateTab(
"edit");
462 $this->domain->news()->handle($page,
true);
464 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
"settings_saved"),
true);
466 $this->
ctrl->redirectByClass(
"ilObjBlogGUI",
"");
484 $title->setRequired(
true);
501 $ilTabs->setBackTarget($this->
lng->txt(
"back"), $this->
ctrl->getLinkTargetByClass(
"ilobjblogGUI"));
503 $ilTabs->activateTab(
"edit");
520 $dt = $dt->getDate();
523 $page->setCreated($dt);
526 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
"settings_saved"),
true);
528 $this->
ctrl->redirectByClass(
"ilObjBlogGUI",
"");
547 $date->setShowTime(
true);
548 $date->setInfo(
$lng->
txt(
'blog_edit_date_info'));
561 $this->
ctrl->redirectByClass(
"ilObjBlogGUI",
"");
572 $note = $this->notes->domain()->getById($a_note_id);
573 $text = $note->getText();
581 return array(
"deactivatePage" =>
$lng->
txt(
"blog_toggle_draft"),
582 "activatePage" =>
$lng->
txt(
"blog_toggle_final"));
593 $this->getBlogPosting()->unpublish();
597 $this->
ctrl->redirect($this,
"edit");
599 $this->
ctrl->setParameterByClass(
"ilobjbloggui",
"blpg",
"");
600 $this->
ctrl->redirectByClass(
"ilobjbloggui",
"");
615 $this->getBlogPosting()->setActive(
true);
616 $this->getBlogPosting()->update(
true,
false);
619 $this->
ctrl->redirect($this,
"edit");
621 $this->
ctrl->setParameterByClass(
"ilobjbloggui",
"blpg",
"");
622 $this->
ctrl->redirectByClass(
"ilobjbloggui",
"");
638 $ilTabs->clearTargets();
639 $ilTabs->setBackTarget($this->
lng->txt(
"back"), $this->
ctrl->getLinkTargetByClass(
"ilobjblogGUI"));
645 $ilTabs->activateTab(
"pg");
657 $ui_factory = $DIC->ui()->factory();
660 $this->getBlogPosting()->getBlogId(),
661 $this->getBlogPosting()->
getId()
666 foreach ($this->posting_manager->getAllByBlog($this->getBlogPosting()->getBlogId(), 0) as $posting) {
667 $pid = $posting->getId();
668 if ($pid !== $this->getBlogPosting()->
getId()) {
669 $other = array_merge(
676 $other = array_unique($other);
677 sort($other, SORT_LOCALE_STRING);
679 $input_tag = $ui_factory->input()->field()->tag($this->
lng->txt(
"blog_keywords"), $other, $this->
lng->txt(
"blog_keyword_enter"))->withUserCreatedTagsAllowed(
true);
680 if (count($keywords) > 0) {
681 $input_tag = $input_tag->withValue($keywords);
684 $DIC->ctrl()->setParameter(
690 $section = $ui_factory->input()->field()->section([$input_tag], $this->
lng->txt(
"blog_edit_keywords"),
"");
692 $form_action = $DIC->ctrl()->getFormAction($this,
"saveKeywordsForm");
693 return $ui_factory->input()->container()->form()->standard($form_action, [
"tags" => $section]);
698 if ($this->node_id) {
700 return $this->access_handler->getTree()->lookupObjectId($this->node_id);
715 if (
$request->getMethod() ===
"POST" 716 &&
$request->getQueryParams()[
'tags'] ==
'tags_processing') {
718 $result =
$form->getData();
720 $keywords = $result[
"tags"][0];
723 if (is_array($keywords)) {
724 $this->getBlogPosting()->updateKeywords($keywords);
726 $this->getBlogPosting()->updateKeywords([]);
730 $this->
ctrl->setParameterByClass(ilObjBlogGUI::class,
"blpg",
"");
731 $this->
ctrl->redirectByClass(
"ilObjBlogGUI",
"");
740 bool $a_truncate =
false,
741 int $a_truncate_length = 500,
742 string $a_truncate_sign =
"...",
743 bool $a_include_picture =
false,
744 int $a_picture_width = 144,
745 int $a_picture_height = 144,
746 ?
string $a_export_directory =
null 748 $bpgui =
new self(0,
null, $a_id);
752 if ($a_include_picture) {
753 $img = $bpgui->getFirstMediaObjectAsTag($a_picture_width, $a_picture_height, $a_export_directory);
756 $bpgui->setRawPageContent(
true);
757 $bpgui->setAbstractOnly(
true);
760 $bpgui->setFileDownloadLink(
".");
761 $bpgui->setFullscreenLink(
".");
762 $bpgui->setSourcecodeDownloadScript(
".");
763 $bpgui->setProfileBackUrl(
".");
766 $page = $bpgui->showPage();
773 $page =
'<div>' . $img . $page .
'</div><div style="clear:both;"></div>';
782 ?
string $a_export_directory =
null 784 $this->obj->buildDom();
785 $mob_ids = $this->obj->collectMediaObjects();
787 foreach ($mob_ids as $mob_id) {
789 $mob_item = $mob_obj->getMediaItem(
"Standard");
790 if (stripos($mob_item->getFormat(),
"image") !==
false) {
791 $mob_size = $mob_item->getOriginalSize();
792 if (is_null($mob_size)) {
795 if ($mob_size[
"width"] >= $a_width ||
796 $mob_size[
"height"] >= $a_height) {
797 if (!$a_export_directory) {
801 $mob_dir =
"./mobs/mm_" . $mob_obj->getId();
803 $mob_res = self::parseImage(
815 ' width="' . $mob_res[0] .
'"' .
816 ' height="' . $mob_res[1] .
'"' .
817 ' class="ilBlogListItemSnippetPreviewImage ilFloatLeft noMirror"' .
832 $ratio_width = $ratio_height = 1;
833 if ($src_width > $tgt_width) {
834 $ratio_width = $tgt_width / $src_width;
836 if ($src_height > $tgt_height) {
837 $ratio_height = $tgt_height / $src_height;
839 $shrink_ratio = min($ratio_width, $ratio_height);
842 (
int) round($src_width * $shrink_ratio),
843 (
int) round($src_height * $shrink_ratio)
849 return $this->
lng->txt(
"blog_draft_text");
855 $this->getBlogPosting(),
857 $this->enable_public_notes,
870 $this->
ctrl->setParameterByClass(
"ilobjbloggui",
"bmn",
"");
871 $this->
ctrl->redirectByClass(
"ilobjbloggui",
"render");
static array static setUseRelativeDates(bool $a_status)
set use relative dates
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
getFirstMediaObjectAsTag(int $a_width=144, int $a_height=144, ?string $a_export_directory=null)
editDate(?ilPropertyFormGUI $a_form=null)
PostingManager $posting_manager
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...
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
editTitle(?ilPropertyFormGUI $a_form=null)
Interface Observer Contains several chained tasks and infos about them.
Class ilBlogPosting GUI class.
LOMServices $lom_services
setContent(string $a_html)
Sets content for standard template.
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.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
loadLanguageModule(string $a_module)
Load language module.
deactivatePage(bool $a_to_list=false)
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.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
setStyleId(int $a_styleid)
sort()
description: > Example for rendering a Sort Glyph.
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...
preview()
description: > Example for rendering a Preview Glyph.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
StandardGUIRequest $blog_request
preview(?string $a_mode=null)
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.
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)
setBlogPosting(ilBlogPosting $a_posting)
InternalGUIService $blog_gui
InternalDomainService $domain
ilGlobalTemplateInterface $tpl
ReadingTimeManager $reading_time_manager
setPageObject(ilPageObject $a_pg_obj)
setLoginTargetPar(string $a_val)
Set target parameter for login (public sector).
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
__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)
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)
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
confirmBlogPostingDeletion()
activatePage(bool $a_to_list=false)
postOutputProcessing(string $a_output)
Finalizing output processing.
__construct(Container $dic, ilPlugin $plugin)
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 formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
showPage(string $a_title="")
static getKeywords(int $a_obj_id, int $a_posting_id)
bool $enable_public_notes
getTabs(string $a_activate="")
deleteBlogPostingConfirmationScreen()
ILIAS Notes Service $notes
cancelBlogPostingDeletion()
setEnableEditing(bool $a_enableediting)
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.