71 public function __construct($a_node_id, $a_access_handler = null, $a_id = 0, $a_old_nr = 0, $a_enable_public_notes =
true, $a_may_contribute =
true, $a_style_sheet_id = 0)
75 $this->tabs = $DIC->tabs();
76 $this->locator = $DIC[
"ilLocator"];
78 $this->
user = $DIC->user();
80 $lng = $DIC->language();
82 $lng->loadLanguageModule(
"blog");
84 $this->node_id = $a_node_id;
85 $this->access_handler = $a_access_handler;
86 $this->enable_public_notes = (bool) $a_enable_public_notes;
95 $this->may_contribute = (bool) $a_may_contribute;
100 $tpl->setCurrentBlock(
"SyntaxStyle");
102 "LOCATION_SYNTAX_STYLESHEET",
105 $tpl->parseCurrentBlock();
108 $tpl->setCurrentBlock(
"ContentStyle");
110 "LOCATION_CONTENT_STYLESHEET",
113 $tpl->parseCurrentBlock();
118 $this->blpg = (int)
$_GET[
"blpg"];
119 $this->fetchall = (bool)
$_GET[
"fetchall"];
133 $next_class =
$ilCtrl->getNextClass($this);
137 $ilCtrl->setParameter($this,
"blpg", $posting->getId());
139 switch ($next_class) {
142 $posting->getTitle());
145 $this->lng->txt(
"obj_blog")
151 if (
$ilCtrl->getCmd() ==
"deactivatePageToList") {
152 ilUtil::sendSuccess($this->lng->txt(
"blog_draft_info"),
true);
153 } elseif (
$ilCtrl->getCmd() ==
"activatePageToList") {
154 ilUtil::sendSuccess($this->lng->txt(
"blog_new_posting_info"),
true);
159 $posting->getTitle());
162 $this->lng->txt(
"obj_blog")
166 $posting->getTitle(),
167 $ilCtrl->getLinkTarget($this,
"preview")
170 return parent::executeCommand();
202 if ($a_cmd ==
"contribute") {
205 return $this->access_handler->checkAccess($a_cmd,
"", $this->node_id);
219 $toolbar = $DIC->toolbar();
224 "tpl.blog_page_view_main_column.html",
233 $this->ctrl->redirect($this,
"previewFullscreen");
253 $callback = array($this,
"observeNoteAction");
257 $may_delete_comments = ($this->
checkAccess(
"contribute") &&
260 $wtpl->setVariable(
"TOOLBAR", $toolbar->getHTML());
264 $this->enable_public_notes,
265 $may_delete_comments,
271 if ($a_mode !=
"embedded") {
272 $append = ($this->blpg > 0)
278 $tpl->setPermanentLink(
"blog", $this->node_id, $append);
281 $wtpl->setVariable(
"PAGE", parent::preview());
283 $tpl->setLoginTargetPar(
"blog_" . $this->node_id . $append);
297 return $this->
preview(
"embedded");
307 $this->add_date =
true;
308 return $this->
preview(
"fullscreen");
321 if ($a_title !=
"") {
329 return parent::showPage();
340 if (is_object($this->access_handler)) {
341 $class = get_class($this->access_handler);
344 return stristr($class,
"workspace");
367 if ($editor[
"user_id"] != $author_id) {
373 $author = implode(
", ", $authors) .
" - ";
380 $prefix =
"<div class=\"il_BlockInfo\" style=\"text-align:right\">" .
385 $a_output = $prefix . $a_output;
402 parent::getTabs($a_activate);
416 $confirmation_gui->setFormAction(
$ilCtrl->getFormAction($this));
417 $confirmation_gui->setHeaderText(
$lng->txt(
"blog_posting_deletion_confirmation"));
418 $confirmation_gui->setCancel(
$lng->txt(
"cancel"),
"cancelBlogPostingDeletion");
419 $confirmation_gui->setConfirm(
$lng->txt(
"delete"),
"confirmBlogPostingDeletion");
422 "tpl.blog_posting_deletion_confirmation.html",
428 $dtpl->setVariable(
"PAGE_TITLE", $this->
getBlogPosting()->getTitle());
437 "TXT_NUMBER_USERS_NOTES_OR_COMMENTS",
438 $lng->txt(
"blog_number_users_notes_or_comments")
440 $dtpl->setVariable(
"TXT_NR_NOTES_COMMENTS", $cnt_note_users);
442 $confirmation_gui->addItem(
"",
"", $dtpl->get());
444 $tpl->setContent($confirmation_gui->getHTML());
455 $ilCtrl->redirect($this,
"preview");
469 foreach ($md_section->getKeywordIds() as $id) {
470 $md_key = $md_section->getKeyword($id);
475 ilUtil::sendSuccess(
$lng->txt(
"blog_posting_deleted"),
true);
478 $ilCtrl->setParameterByClass(
"ilobjbloggui",
"blpg",
"");
479 $ilCtrl->redirectByClass(
"ilobjbloggui",
"render");
487 $ilTabs->clearTargets();
488 $ilTabs->setBackTarget($this->lng->txt(
"back"), $this->ctrl->getLinkTargetByClass(
"ilobjblogGUI"));
490 $ilTabs->activateTab(
"edit");
496 $tpl->setContent($a_form->getHTML());
505 if ($form->checkInput()) {
508 $page->setTitle($form->getInput(
"title"));
511 $page->handleNews(
true);
513 ilUtil::sendSuccess(
$lng->txt(
"settings_saved"),
true);
515 $this->ctrl->redirectByClass(
"ilObjBlogGUI",
"");
519 $form->setValuesByPost();
529 $form->setFormAction(
$ilCtrl->getFormAction($this));
530 $form->setTitle(
$lng->txt(
'blog_rename_posting'));
533 $title->setRequired(
true);
534 $form->addItem($title);
538 $form->addCommandButton(
'updateTitle',
$lng->txt(
'save'));
539 $form->addCommandButton(
'cancelEdit',
$lng->txt(
'cancel'));
549 $ilTabs->clearTargets();
550 $ilTabs->setBackTarget($this->lng->txt(
"back"), $this->ctrl->getLinkTargetByClass(
"ilobjblogGUI"));
552 $ilTabs->activateTab(
"edit");
558 $tpl->setContent($a_form->getHTML());
567 if ($form->checkInput()) {
569 $dt = $form->getItemByPostVar(
"date");
570 $dt = $dt->getDate();
573 $page->setCreated($dt);
576 ilUtil::sendSuccess(
$lng->txt(
"settings_saved"),
true);
578 $this->ctrl->redirectByClass(
"ilObjBlogGUI",
"");
582 $form->setValuesByPost();
592 $form->setFormAction(
$ilCtrl->getFormAction($this));
593 $form->setTitle(
$lng->txt(
'blog_edit_date'));
597 $date->setShowTime(
true);
598 $date->setInfo(
$lng->txt(
'blog_edit_date_info'));
599 $form->addItem($date);
603 $form->addCommandButton(
'updateDate',
$lng->txt(
'save'));
604 $form->addCommandButton(
'cancelEdit',
$lng->txt(
'cancel'));
617 $this->ctrl->redirectByClass(
"ilObjBlogGUI",
"");
624 $note =
new ilNote($a_note_id);
625 $note = $note->getText();
633 return array(
"deactivatePage" =>
$lng->txt(
"blog_toggle_draft"),
634 "activatePage" =>
$lng->txt(
"blog_toggle_final"));
649 $this->ctrl->redirect($this,
"edit");
651 $this->ctrl->setParameterByClass(
"ilobjbloggui",
"blpg",
"");
652 $this->ctrl->redirectByClass(
"ilobjbloggui",
"");
671 $this->ctrl->redirect($this,
"edit");
673 $this->ctrl->setParameterByClass(
"ilobjbloggui",
"blpg",
"");
674 $this->ctrl->redirectByClass(
"ilobjbloggui",
"");
686 $renderer = $DIC->ui()->renderer();
691 $ilTabs->clearTargets();
692 $ilTabs->setBackTarget($this->lng->txt(
"back"), $this->ctrl->getLinkTargetByClass(
"ilobjblogGUI"));
698 $ilTabs->activateTab(
"pg");
704 $tpl->setContent($renderer->render($a_form));
711 $ui_factory = $DIC->ui()->factory();
717 foreach ($ids = $md_section->getKeywordIds() as $id) {
718 $md_key = $md_section->getKeyword($id);
719 if (trim($md_key->getKeyword()) !=
"") {
722 $keywords[] = $md_key->getKeyword();
741 $other = array_unique($other);
742 sort($other, SORT_LOCALE_STRING);
743 if (is_array($keywords[$ulang])) {
744 $other = array_diff($other, $keywords[$ulang]);
747 $input_tag = $ui_factory->input()->field()->tag($this->lng->txt(
"blog_keywords"), $other, $this->lng->txt(
"blog_keyword_enter"));
748 if (count($keywords) > 0) {
749 $input_tag = $input_tag->withValue($keywords);
752 $DIC->ctrl()->setParameter(
758 $section = $ui_factory->input()->field()->section([$input_tag], $this->lng->txt(
"blog_edit_keywords"),
"");
760 $form_action = $DIC->ctrl()->getFormAction($this,
"saveKeywordsForm");
761 $form = $ui_factory->input()->container()->form()->standard($form_action, [
"tags" =>
$section]);
768 if ($this->node_id) {
770 return $this->access_handler->getTree()->lookupObjectId($this->node_id);
781 $request = $DIC->http()->request();
784 if ($request->getMethod() ==
"POST" 785 && $request->getQueryParams()[
'tags'] ==
'tags_processing') {
786 $form = $form->withRequest($request);
789 $keywords =
$result[
"tags"][0];
792 if (is_array($keywords)) {
799 $this->ctrl->redirectByClass(
"ilObjBlogGUI",
"");
815 public static function getSnippet($a_id, $a_truncate =
false, $a_truncate_length = 500, $a_truncate_sign =
"...", $a_include_picture =
false, $a_picture_width = 144, $a_picture_height = 144, $a_export_directory = null)
817 $bpgui =
new self(0, null, $a_id);
820 if ($a_include_picture) {
821 $img = $bpgui->getFirstMediaObjectAsTag($a_picture_width, $a_picture_height, $a_export_directory);
824 $bpgui->setRawPageContent(
true);
825 $bpgui->setAbstractOnly(
true);
828 $bpgui->setFileDownloadLink(
".");
829 $bpgui->setFullscreenLink(
".");
830 $bpgui->setSourcecodeDownloadScript(
".");
831 $bpgui->setProfileBackUrl(
".");
834 $page = $bpgui->showPage();
841 $page =
'<div>' .
$img . $page .
'</div><div style="clear:both;"></div>';
849 $this->obj->buildDom();
850 $mob_ids = $this->obj->collectMediaObjects();
852 foreach ($mob_ids as $mob_id) {
854 $mob_item = $mob_obj->getMediaItem(
"Standard");
855 if (stristr($mob_item->getFormat(),
"image")) {
856 $mob_size = $mob_item->getOriginalSize();
857 if ($mob_size[
"width"] >= $a_width ||
858 $mob_size[
"height"] >= $a_height) {
859 if (!$a_export_directory) {
863 $mob_dir =
"./mobs/mm_" . $mob_obj->getId();
865 $mob_res = self::parseImage(
873 $location = $mob_item->getLocationType() ==
"Reference" 874 ? $mob_item->getLocation()
875 : $mob_dir .
"/" . $mob_item->getLocation();
879 ' width="' . $mob_res[0] .
'"' .
880 ' height="' . $mob_res[1] .
'"' .
881 ' class="ilBlogListItemSnippetPreviewImage ilFloatLeft noMirror"' .
889 protected static function parseImage($src_width, $src_height, $tgt_width, $tgt_height)
891 $ratio_width = $ratio_height = 1;
892 if ($src_width > $tgt_width) {
893 $ratio_width = $tgt_width / $src_width;
895 if ($src_height > $tgt_height) {
896 $ratio_height = $tgt_height / $src_height;
898 $shrink_ratio = min($ratio_width, $ratio_height);
901 (
int) round($src_width * $shrink_ratio),
902 (
int) round($src_height * $shrink_ratio)
914 return $this->lng->txt(
"blog_draft_text");
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
previewEmbedded()
Needed for portfolio/blog handling.
getPageObject()
Get Page Object.
setTemplateOutput($a_output=true)
observeNoteAction($a_blog_id, $a_posting_id, $a_type, $a_action, $a_note_id)
getTabs($a_activate="")
Get tabs.
Class ilBlogPosting GUI class.
getDisabledText()
Get disabled text.
static getPageContributors($a_parent_type, $a_page_id, $a_lang="-")
Get all contributors for parent object.
__construct($a_node_id, $a_access_handler=null, $a_id=0, $a_old_nr=0, $a_enable_public_notes=true, $a_may_contribute=true, $a_style_sheet_id=0)
Constructor.
static setUseRelativeDates($a_status)
set use relative dates
static _lookupTitle($a_id)
lookup object title
setEnableEditing($a_enableediting)
Set Enable Editing.
static getKeywords($a_obj_id, $a_posting_id)
postOutputProcessing($a_output)
Finalizing output processing.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
static useRelativeDates()
check if relative dates are used
static getAllPostings($a_blog_id, $a_limit=1000, $a_offset=0)
Get all postings of blog.
getFirstMediaObjectAsTag($a_width=144, $a_height=144, $a_export_directory=null)
previewFullscreen()
Needed for portfolio/blog handling.
static getUserCount($a_rep_obj_id, $a_obj_id, $a_type)
How many users have attached a note/comment to a given object?
setBlogPosting(ilBlogPosting $a_posting)
Set blog posting.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static getSnippet($a_id, $a_truncate=false, $a_truncate_length=500, $a_truncate_sign="...", $a_include_picture=false, $a_picture_width=144, $a_picture_height=144, $a_export_directory=null)
Get first text paragraph of page.
getEnableEditing()
Get Enable Editing.
getBlogPosting()
Get blog posting.
static _lookupObjId($a_id)
setPageObject(ilPageObject $a_pg_obj)
Set Page Object.
setPresentationTitle($a_title="")
showPage($a_title="")
Embedded posting in portfolio.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static getSyntaxStylePath()
get syntax style path
getAbstractOnly()
Get abstract only.
preview($a_mode=null)
Preview blog posting.
cancelEdit()
Cancel editing.
confirmBlogPostingDeletion()
Delete the blog posting.
static truncateHTML($a_text, $a_length=100, $a_ending='...', $a_exact=false, $a_consider_html=true)
Truncate (html) string.
setStyleId($a_styleid)
Set Style Id.
static parseImage($src_width, $src_height, $tgt_width, $tgt_height)
deactivatePage($a_to_list=false)
__construct(Container $dic, ilPlugin $plugin)
isInWorkspace()
Is current page part of personal workspace blog?
editKeywords(ilPropertyFormGUI $a_form=null)
Diplay the form.
checkAccess($a_cmd)
Centralized access management.
static sendNotification($a_action, $a_in_wsp, $a_blog_node_id, $a_posting_id, $a_comment=null)
executeCommand()
execute command
getNotesHTML($a_content_object=null, $a_enable_private_notes=true, $a_enable_public_notes=false, $a_enable_notes_deletion=false, $a_callback=null)
Get html for public and/or private notes.
activatePage($a_to_list=false)
deleteBlogPostingConfirmationScreen()
Delete blog posting confirmation screen.
cancelBlogPostingDeletion()
Cancel blog posting deletion.
Confirmation screen class.