19 declare(strict_types=1);
35 protected \ILIAS\Notes\Service
$notes;
53 object $a_access_handler = null,
56 bool $a_enable_public_notes =
true,
57 bool $a_may_contribute =
true,
58 int $a_style_sheet_id = 0
62 $this->
tabs = $DIC->tabs();
63 $this->
locator = $DIC[
"ilLocator"];
65 $this->
user = $DIC->user();
67 $lng = $DIC->language();
68 $this->blog_request = $DIC->blog()
72 $this->lom_services = $DIC->learningObjectMetadata();
76 $this->node_id = $a_node_id;
77 $this->access_handler = $a_access_handler;
78 $this->enable_public_notes = $a_enable_public_notes;
83 $this->getBlogPosting()->setBlogNodeId($this->node_id, $this->
isInWorkspace());
84 $this->getBlogPosting()->getPageConfig()->setEditLockSupport(!$this->
isInWorkspace());
87 $this->may_contribute = $a_may_contribute;
94 "LOCATION_SYNTAX_STYLESHEET",
111 $this->blpg = $this->blog_request->getBlogPage();
112 $this->fetchall = $this->blog_request->getFetchAll();
113 $this->term = $this->blog_request->getTerm();
115 $this->reading_time_manager = new \ILIAS\Blog\ReadingTime\ReadingTimeManager();
116 $this->notes = $DIC->notes();
117 $this->profile_gui = $DIC->blog()->internal()->gui()->profile();
118 $this->blog_gui = $DIC->blog()->internal()->gui();
127 $next_class = $ilCtrl->getNextClass($this);
129 $posting = $this->getBlogPosting();
130 $ilCtrl->setParameter($this,
"blpg", $posting->getId());
132 switch ($next_class) {
139 if ($ilCtrl->getCmd() ===
"deactivatePageToList") {
140 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"blog_draft_info"),
true);
141 } elseif ($ilCtrl->getCmd() ===
"activatePageToList") {
142 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"blog_new_posting_info"),
true);
147 $posting->getTitle());
150 $this->
lng->txt(
"obj_blog")
154 $posting->getTitle(),
155 $ilCtrl->getLinkTarget($this,
"preview")
157 return parent::executeCommand();
175 if ($a_cmd ===
"contribute") {
178 return $this->access_handler->checkAccess($a_cmd,
"", $this->node_id);
182 string $a_mode = null
192 $this->getBlogPosting()->increaseViewCnt();
195 "tpl.blog_page_view_main_column.html",
198 "components/ILIAS/Blog" 204 $this->
ctrl->redirect($this,
"previewFullscreen");
207 $callback = array($this,
"observeNoteAction");
211 $may_delete_comments = ($this->
checkAccess(
"contribute") &&
217 $this->getBlogPosting(),
219 $this->enable_public_notes,
220 $may_delete_comments,
231 $this->blog_gui->permanentLink(
$ref_id, $wsp_id)->setPermanentLink($this->blpg);
237 $ilCtrl->setParameter($this,
"blpg", $this->getBlogPosting()->
getId());
248 $this->add_date =
true;
249 return $this->
preview(
"fullscreen");
259 if ($a_title !==
"") {
265 $this->getBlogPosting()->increaseViewCnt();
266 return parent::showPage();
275 if (is_object($this->access_handler)) {
276 $class = get_class($this->access_handler);
279 return (
bool) stristr($class,
"workspace");
315 $author_id = $this->getBlogPosting()->getAuthor();
317 $authors[] = $this->profile_gui->getNamePresentation($author_id);
321 if ($editor[
"user_id"] != $author_id) {
322 $authors[] = $this->profile_gui->getNamePresentation($editor[
"user_id"]);
327 $author = implode(
", ", $authors) .
" - ";
332 $tpl =
new ilTemplate(
"tpl.posting_head.html",
true,
true,
"components/ILIAS/Blog");
335 $reading_time = $this->reading_time_manager->getReadingTime(
336 $this->getBlogPosting()->getParentId(),
337 $this->getBlogPosting()->
getId()
339 if (!is_null($reading_time)) {
340 $this->
lng->loadLanguageModule(
"copg");
344 $this->
lng->txt(
"copg_est_reading_time") .
": " .
345 sprintf($this->
lng->txt(
"copg_x_minutes"), $reading_time)
359 public function getTabs(
string $a_activate =
""): void
365 parent::getTabs($a_activate);
376 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
377 $confirmation_gui->setHeaderText(
$lng->
txt(
"blog_posting_deletion_confirmation"));
378 $confirmation_gui->setCancel(
$lng->
txt(
"cancel"),
"cancelBlogPostingDeletion");
379 $confirmation_gui->setConfirm(
$lng->
txt(
"delete"),
"confirmBlogPostingDeletion");
382 "tpl.blog_posting_deletion_confirmation.html",
385 "components/ILIAS/Blog" 388 $dtpl->setVariable(
"PAGE_TITLE", $this->getBlogPosting()->
getTitle());
391 $cnt_note_users = $this->notes->domain()->getUserCount(
392 $this->getBlogPosting()->getParentId(),
393 $this->getBlogPosting()->
getId(),
397 "TXT_NUMBER_USERS_NOTES_OR_COMMENTS",
398 $lng->
txt(
"blog_number_users_notes_or_comments")
400 $dtpl->setVariable(
"TXT_NR_NOTES_COMMENTS", $cnt_note_users);
402 $confirmation_gui->addItem(
"",
"", $dtpl->get());
413 $ilCtrl->redirectByClass(
"ilobjbloggui",
"render");
423 $this->lom_services->deleteAll(
424 $this->getBlogPosting()->getBlogId(),
425 $this->getBlogPosting()->
getId(),
429 $this->getBlogPosting()->delete();
430 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
"blog_posting_deleted"),
true);
433 $ilCtrl->setParameterByClass(
"ilobjbloggui",
"blpg",
"");
434 $ilCtrl->redirectByClass(
"ilobjbloggui",
"render");
443 $ilTabs->setBackTarget($this->
lng->txt(
"back"), $this->
ctrl->getLinkTargetByClass(
"ilobjblogGUI"));
445 $ilTabs->activateTab(
"edit");
465 $page->handleNews(
true);
467 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
"settings_saved"),
true);
469 $this->
ctrl->redirectByClass(
"ilObjBlogGUI",
"");
487 $title->setRequired(
true);
504 $ilTabs->setBackTarget($this->
lng->txt(
"back"), $this->
ctrl->getLinkTargetByClass(
"ilobjblogGUI"));
506 $ilTabs->activateTab(
"edit");
523 $dt = $dt->getDate();
526 $page->setCreated($dt);
529 $this->tpl->setOnScreenMessage(
'success',
$lng->
txt(
"settings_saved"),
true);
531 $this->
ctrl->redirectByClass(
"ilObjBlogGUI",
"");
550 $date->setShowTime(
true);
551 $date->setInfo(
$lng->
txt(
'blog_edit_date_info'));
564 $this->
ctrl->redirectByClass(
"ilObjBlogGUI",
"");
575 $note = $this->notes->domain()->getById($a_note_id);
576 $text = $note->getText();
584 return array(
"deactivatePage" =>
$lng->
txt(
"blog_toggle_draft"),
585 "activatePage" =>
$lng->
txt(
"blog_toggle_final"));
596 $this->getBlogPosting()->unpublish();
600 $this->
ctrl->redirect($this,
"edit");
602 $this->
ctrl->setParameterByClass(
"ilobjbloggui",
"blpg",
"");
603 $this->
ctrl->redirectByClass(
"ilobjbloggui",
"");
618 $this->getBlogPosting()->setActive(
true);
619 $this->getBlogPosting()->update(
true,
false);
622 $this->
ctrl->redirect($this,
"edit");
624 $this->
ctrl->setParameterByClass(
"ilobjbloggui",
"blpg",
"");
625 $this->
ctrl->redirectByClass(
"ilobjbloggui",
"");
641 $ilTabs->clearTargets();
642 $ilTabs->setBackTarget($this->
lng->txt(
"back"), $this->
ctrl->getLinkTargetByClass(
"ilobjblogGUI"));
648 $ilTabs->activateTab(
"pg");
660 $ui_factory = $DIC->ui()->factory();
663 $this->getBlogPosting()->getBlogId(),
664 $this->getBlogPosting()->
getId()
670 if ($posting_id != $this->getBlogPosting()->
getId()) {
675 $other = array_unique($other);
676 sort($other, SORT_LOCALE_STRING);
678 $input_tag = $ui_factory->input()->field()->tag($this->
lng->txt(
"blog_keywords"), $other, $this->
lng->txt(
"blog_keyword_enter"))->withUserCreatedTagsAllowed(
true);
679 if (count($keywords) > 0) {
680 $input_tag = $input_tag->withValue($keywords);
683 $DIC->ctrl()->setParameter(
689 $section = $ui_factory->input()->field()->section([$input_tag], $this->
lng->txt(
"blog_edit_keywords"),
"");
691 $form_action = $DIC->ctrl()->getFormAction($this,
"saveKeywordsForm");
692 return $ui_factory->input()->container()->form()->standard($form_action, [
"tags" => $section]);
697 if ($this->node_id) {
699 return $this->access_handler->getTree()->lookupObjectId($this->node_id);
714 if (
$request->getMethod() ===
"POST" 715 &&
$request->getQueryParams()[
'tags'] ==
'tags_processing') {
717 $result =
$form->getData();
719 $keywords = $result[
"tags"][0];
722 if (is_array($keywords)) {
723 $this->getBlogPosting()->updateKeywords($keywords);
725 $this->getBlogPosting()->updateKeywords([]);
729 $this->
ctrl->setParameterByClass(ilObjBlogGUI::class,
"blpg",
"");
730 $this->
ctrl->redirectByClass(
"ilObjBlogGUI",
"");
739 bool $a_truncate =
false,
740 int $a_truncate_length = 500,
741 string $a_truncate_sign =
"...",
742 bool $a_include_picture =
false,
743 int $a_picture_width = 144,
744 int $a_picture_height = 144,
745 string $a_export_directory = null
747 $bpgui =
new self(0, null, $a_id);
751 if ($a_include_picture) {
752 $img = $bpgui->getFirstMediaObjectAsTag($a_picture_width, $a_picture_height, $a_export_directory);
755 $bpgui->setRawPageContent(
true);
756 $bpgui->setAbstractOnly(
true);
759 $bpgui->setFileDownloadLink(
".");
760 $bpgui->setFullscreenLink(
".");
761 $bpgui->setSourcecodeDownloadScript(
".");
762 $bpgui->setProfileBackUrl(
".");
765 $page = $bpgui->showPage();
772 $page =
'<div>' . $img . $page .
'</div><div style="clear:both;"></div>';
781 string $a_export_directory = null
783 $this->obj->buildDom();
784 $mob_ids = $this->obj->collectMediaObjects();
786 foreach ($mob_ids as $mob_id) {
788 $mob_item = $mob_obj->getMediaItem(
"Standard");
789 if (stripos($mob_item->getFormat(),
"image") !==
false) {
790 $mob_size = $mob_item->getOriginalSize();
791 if (is_null($mob_size)) {
794 if ($mob_size[
"width"] >= $a_width ||
795 $mob_size[
"height"] >= $a_height) {
796 if (!$a_export_directory) {
800 $mob_dir =
"./mobs/mm_" . $mob_obj->getId();
802 $mob_res = self::parseImage(
814 ' width="' . $mob_res[0] .
'"' .
815 ' height="' . $mob_res[1] .
'"' .
816 ' class="ilBlogListItemSnippetPreviewImage ilFloatLeft noMirror"' .
831 $ratio_width = $ratio_height = 1;
832 if ($src_width > $tgt_width) {
833 $ratio_width = $tgt_width / $src_width;
835 if ($src_height > $tgt_height) {
836 $ratio_height = $tgt_height / $src_height;
838 $shrink_ratio = min($ratio_width, $ratio_height);
841 (
int) round($src_width * $shrink_ratio),
842 (
int) round($src_height * $shrink_ratio)
848 return $this->
lng->txt(
"blog_draft_text");
854 $this->getBlogPosting(),
856 $this->enable_public_notes,
869 $this->
ctrl->setParameterByClass(
"ilobjbloggui",
"bmn",
"");
870 $this->
ctrl->redirectByClass(
"ilobjbloggui",
"render");
static array 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,)
editTitle(ilPropertyFormGUI $a_form=null)
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...
Interface Observer Contains several chained tasks and infos about them.
Class ilBlogPosting GUI class.
LOMServices $lom_services
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
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...
ILIAS Blog ReadingTime ReadingTimeManager $reading_time_manager
preview()
description: > Example for rendering a Preview Glyph.
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)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
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.
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.
__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 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
getTabs(string $a_activate="")
deleteBlogPostingConfirmationScreen()
ILIAS Notes Service $notes
cancelBlogPostingDeletion()
setEnableEditing(bool $a_enableediting)