4 include_once(
"./Services/COPage/classes/class.ilPageObjectGUI.php");
5 include_once(
"./Modules/Blog/classes/class.ilBlogPosting.php");
36 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)
40 $lng->loadLanguageModule(
"blog");
42 $this->node_id = $a_node_id;
43 $this->access_handler = $a_access_handler;
44 $this->enable_public_notes = (bool)$a_enable_public_notes;
52 $this->may_contribute = (bool)$a_may_contribute;
56 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
58 $tpl->setCurrentBlock(
"SyntaxStyle");
59 $tpl->setVariable(
"LOCATION_SYNTAX_STYLESHEET",
61 $tpl->parseCurrentBlock();
64 $tpl->setCurrentBlock(
"ContentStyle");
65 $tpl->setVariable(
"LOCATION_CONTENT_STYLESHEET",
67 $tpl->parseCurrentBlock();
80 $next_class = $ilCtrl->getNextClass($this);
81 $cmd = $ilCtrl->getCmd();
84 $ilCtrl->setParameter($this,
"blpg", $posting->getId());
104 case "ilpageobjectgui":
105 die(
"Deprecated. Blog Posting gui forwarding to ilpageobject");
114 $posting->getTitle());
116 $this->lng->txt(
"obj_blog"));
118 $ilLocator->addItem($posting->getTitle(),
119 $ilCtrl->getLinkTarget($this,
"preview"));
153 if($a_cmd ==
"contribute")
157 return $this->access_handler->checkAccess($a_cmd,
"", $this->node_id);
169 $wtpl =
new ilTemplate(
"tpl.blog_page_view_main_column.html",
170 true,
true,
"Modules/Blog");
195 $callback = array($this,
"observeNoteAction");
199 $may_delete_comments = ($this->
checkAccess(
"contribute") &&
200 $ilSetting->get(
"comments_del_tutor", 1));
203 false, $this->enable_public_notes, $may_delete_comments, $callback));
207 if($a_mode !=
"embedded")
209 $append = (
$_GET[
"blpg"] !=
"")
216 $tpl->setPermanentLink(
"blog", $this->node_id, $append);
219 $wtpl->setVariable(
"PAGE", parent::preview());
221 $tpl->setLoginTargetPar(
"blog_".$this->node_id.$append);
235 return $this->
preview(
"embedded");
245 $this->add_date =
true;
246 return $this->
preview(
"fullscreen");
274 return stristr(get_class($this->access_handler),
"workspace");
295 include_once
"Services/User/classes/class.ilUserUtil.php";
303 $prefix =
"<div class=\"il_BlockInfo\" style=\"text-align:right\">".
304 $author.ilDatePresentation::formatDate($this->
getBlogPosting()->getCreated()).
308 $a_output = $prefix.$a_output;
337 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
339 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
340 $confirmation_gui->setHeaderText($lng->txt(
"blog_posting_deletion_confirmation"));
341 $confirmation_gui->setCancel($lng->txt(
"cancel"),
"cancelBlogPostingDeletion");
342 $confirmation_gui->setConfirm($lng->txt(
"delete"),
"confirmBlogPostingDeletion");
344 $dtpl =
new ilTemplate(
"tpl.blog_posting_deletion_confirmation.html",
true,
345 true,
"Modules/Blog");
347 $dtpl->setVariable(
"PAGE_TITLE", $this->
getBlogPosting()->getTitle());
350 include_once(
"./Services/Notes/classes/class.ilNote.php");
353 $dtpl->setVariable(
"TXT_NUMBER_USERS_NOTES_OR_COMMENTS",
354 $lng->txt(
"blog_number_users_notes_or_comments"));
355 $dtpl->setVariable(
"TXT_NR_NOTES_COMMENTS", $cnt_note_users);
357 $confirmation_gui->addItem(
"",
"", $dtpl->get());
359 $tpl->setContent($confirmation_gui->getHTML());
370 $ilCtrl->redirect($this,
"preview");
384 foreach($md_section->getKeywordIds() as $id)
386 $md_key = $md_section->getKeyword($id);
394 $ilCtrl->setParameterByClass(
"ilobjbloggui",
"blpg",
"");
395 $ilCtrl->redirectByClass(
"ilobjbloggui",
"render");
400 global
$tpl, $ilTabs;
402 $ilTabs->activateTab(
"edit");
409 $tpl->setContent($a_form->getHTML());
417 if($form->checkInput())
420 $page->setTitle($form->getInput(
"title"));
424 $ilCtrl->redirect($this,
"preview");
427 $form->setValuesByPost();
435 include_once(
'Services/Form/classes/class.ilPropertyFormGUI.php');
437 $form->setFormAction($ilCtrl->getFormAction($this));
438 $form->setTitle($lng->txt(
'blog_rename_posting'));
442 $form->addItem($title);
446 $form->addCommandButton(
'updateTitle', $lng->txt(
'save'));
447 $form->addCommandButton(
'preview', $lng->txt(
'cancel'));
454 global
$tpl, $ilTabs;
456 $ilTabs->activateTab(
"edit");
463 $tpl->setContent($a_form->getHTML());
471 if($form->checkInput())
473 $dt = $form->getInput(
"date");
477 $page->setCreated($dt);
481 $ilCtrl->redirect($this,
"preview");
484 $form->setValuesByPost();
492 include_once(
'Services/Form/classes/class.ilPropertyFormGUI.php');
494 $form->setFormAction($ilCtrl->getFormAction($this));
495 $form->setTitle($lng->txt(
'blog_edit_date'));
499 $date->setShowTime(
true);
500 $date->setInfo($lng->txt(
'blog_edit_date_info'));
501 $form->addItem($date);
505 $form->addCommandButton(
'updateDate', $lng->txt(
'save'));
506 $form->addCommandButton(
'preview', $lng->txt(
'cancel'));
514 include_once
"Services/Notes/classes/class.ilNote.php";
515 $note =
new ilNote($a_note_id);
516 $note = $note->getText();
518 include_once
"Modules/Blog/classes/class.ilObjBlog.php";
526 return array(
"deactivatePage" => $lng->txt(
"blog_toggle_draft"),
527 "activatePage" => $lng->txt(
"blog_toggle_final"));
542 $this->ctrl->redirect($this,
"edit");
546 $this->ctrl->redirectByClass(
"ilobjbloggui",
"");
558 include_once
"Modules/Blog/classes/class.ilObjBlog.php";
565 $this->ctrl->redirect($this,
"edit");
569 $this->ctrl->redirectByClass(
"ilobjbloggui",
"");
575 global $ilTabs,
$tpl;
582 $ilTabs->activateTab(
"pg");
589 $tpl->setContent($a_form->getHTML());
596 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
598 $form->setFormAction($this->ctrl->getFormAction($this,
"saveKeywordsForm"));
599 $form->setTitle($this->lng->txt(
"blog_edit_keywords"));
603 $txt->setMulti(
true);
604 $txt->setDataSource($this->ctrl->getLinkTarget($this,
"keywordAutocomplete",
"",
true));
605 $txt->setMaxLength(200);
607 $txt->setInfo($this->lng->txt(
"blog_keywords_info"));
608 $form->addItem(
$txt);
613 foreach($ids = $md_section->getKeywordIds() as $id)
615 $md_key = $md_section->getKeyword($id);
616 if (trim($md_key->getKeyword()) !=
"")
618 $keywords[$md_key->getKeywordLanguageCode()][]
619 = $md_key->getKeyword();
624 $ulang = $ilUser->getLanguage();
625 if($keywords[$ulang])
627 asort($keywords[$ulang]);
628 $txt->setValue($keywords[$ulang]);
641 $other = array_unique($other);
642 sort($other, SORT_LOCALE_STRING);
643 if(is_array($keywords[$ulang]))
645 $other = array_diff($other, $keywords[$ulang]);
650 foreach($other as $item)
652 $html .=
'<span class="ilTag">'.$item.
'</span>';
655 $info->
setInfo($this->lng->txt(
"blog_keywords_other_info"));
656 $info->setValue($html);
657 $form->addItem($info);
660 $form->addCommandButton(
"saveKeywordsForm", $this->lng->txt(
"save"));
661 $form->addCommandButton(
"preview", $this->lng->txt(
"cancel"));
672 return $this->access_handler->getTree()->lookupObjectId($this->node_id);
684 if($form->checkInput())
686 $keywords = $form->getInput(
"keywords");
687 if(is_array($keywords))
692 $this->ctrl->redirect($this,
"preview");
695 $form->setValuesByPost();
701 $force_all = (bool)
$_GET[
"fetchall"];
703 include_once(
"./Services/MetaData/classes/class.ilMDKeyword.php");
707 include_once(
"./Services/Search/classes/class.ilSearchSettings.php");
715 sizeof(
$result[
"items"]) >= $cut)
720 $entry =
new stdClass();
726 $result[
"hasMoreResults"] = $has_more;
728 include_once
'./Services/JSON/classes/class.ilJsonUtil.php';
745 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)
747 $bpgui =
new self(0, null, $a_id);
750 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(
".");
764 $page = $bpgui->showPage();
773 $page =
'<div>'.$img.$page.
'</div><div style="clear:both;"></div>';
781 $this->obj->buildDom();
782 $mob_ids = $this->obj->collectMediaObjects();
785 require_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
786 foreach($mob_ids as $mob_id)
789 $mob_item = $mob_obj->getMediaItem(
"Standard");
790 if(stristr($mob_item->getFormat(),
"image"))
792 $mob_size = $mob_item->getOriginalSize();
793 if($mob_size[
"width"] >= $a_width ||
794 $mob_size[
"height"] >= $a_height)
796 if(!$a_export_directory)
803 $mob_dir =
"./mobs/mm_".$mob_obj->getId();
806 $mob_size[
"height"], $a_width, $a_height);
809 ' src="'.$mob_dir.
"/".$mob_item->getLocation().
'"'.
810 ' width="'.$mob_res[0].
'"'.
811 ' height="'.$mob_res[1].
'"'.
812 ' class="ilBlogListItemSnippetPreviewImage ilFloatLeft noMirror"'.
820 protected static function parseImage($src_width, $src_height, $tgt_width, $tgt_height)
822 $ratio_width = $ratio_height = 1;
823 if($src_width > $tgt_width)
825 $ratio_width = $tgt_width / $src_width;
827 if($src_height > $tgt_height)
829 $ratio_height = $tgt_height / $src_height;
831 $shrink_ratio = min($ratio_width, $ratio_height);
834 (
int)round($src_width*$shrink_ratio),
835 (
int)round($src_height*$shrink_ratio)