ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilBlogPostingGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
14 {
18  protected $tabs;
19 
23  protected $locator;
24 
28  protected $settings;
29 
33  protected $node_id;
34  protected $access_handler; // [object]
35 
40 
44  protected $may_contribute;
45 
49  protected $fetchall;
50 
54  protected $blpg;
55 
59  protected $term;
60 
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)
72  {
73  global $DIC;
74 
75  $this->tabs = $DIC->tabs();
76  $this->locator = $DIC["ilLocator"];
77  $this->settings = $DIC->settings();
78  $this->user = $DIC->user();
79  $tpl = $DIC["tpl"];
80  $lng = $DIC->language();
81 
82  $lng->loadLanguageModule("blog");
83 
84  $this->node_id = $a_node_id;
85  $this->access_handler = $a_access_handler;
86  $this->enable_public_notes = (bool) $a_enable_public_notes;
87 
88  parent::__construct("blp", $a_id, $a_old_nr);
89 
90  // needed for notification
91  $this->getBlogPosting()->setBlogNodeId($this->node_id, $this->isInWorkspace());
92  $this->getBlogPosting()->getPageConfig()->setEditLockSupport(!$this->isInWorkspace());
93 
94  // #11151
95  $this->may_contribute = (bool) $a_may_contribute;
96  $this->setEnableEditing($a_may_contribute);
97 
98  // content style
99 
100  $tpl->setCurrentBlock("SyntaxStyle");
101  $tpl->setVariable(
102  "LOCATION_SYNTAX_STYLESHEET",
104  );
105  $tpl->parseCurrentBlock();
106 
107  // #17814
108  $tpl->setCurrentBlock("ContentStyle");
109  $tpl->setVariable(
110  "LOCATION_CONTENT_STYLESHEET",
111  ilObjStyleSheet::getContentStylePath($a_style_sheet_id)
112  );
113  $tpl->parseCurrentBlock();
114 
115  // needed for editor
116  $this->setStyleId($a_style_sheet_id);
117 
118  $this->blpg = (int) $_GET["blpg"];
119  $this->fetchall = (bool) $_GET["fetchall"];
120  $this->term = ilUtil::stripSlashes($_GET["term"]);
121  }
122 
126  public function executeCommand()
127  {
128  $ilCtrl = $this->ctrl;
129  $ilTabs = $this->tabs;
130  $ilLocator = $this->locator;
131  $tpl = $this->tpl;
132 
133  $next_class = $ilCtrl->getNextClass($this);
134  $cmd = $ilCtrl->getCmd();
135 
136  $posting = $this->getBlogPosting();
137  $ilCtrl->setParameter($this, "blpg", $posting->getId());
138 
139  switch ($next_class) {
140  case "ilnotegui":
141  // $this->getTabs();
142  // $ilTabs->setTabActive("pg");
143  return $this->previewFullscreen();
144 
145  default:
146  if ($posting) {
147  if ($ilCtrl->getCmd() == "deactivatePageToList") {
148  ilUtil::sendSuccess($this->lng->txt("blog_draft_info"), true);
149  } elseif ($ilCtrl->getCmd() == "activatePageToList") {
150  ilUtil::sendSuccess($this->lng->txt("blog_new_posting_info"), true);
151  }
152  $this->setPresentationTitle($posting->getTitle());
153 
154  $tpl->setTitle(ilObject::_lookupTitle($this->getBlogPosting()->getBlogId()) . ": " . // #15017
155  $posting->getTitle());
156  $tpl->setTitleIcon(
157  ilUtil::getImagePath("icon_blog.svg"),
158  $this->lng->txt("obj_blog")
159  ); // #12879
160 
161  $ilLocator->addItem(
162  $posting->getTitle(),
163  $ilCtrl->getLinkTarget($this, "preview")
164  );
165  }
166  return parent::executeCommand();
167  }
168  }
169 
175  public function setBlogPosting(ilBlogPosting $a_posting)
176  {
177  $this->setPageObject($a_posting);
178  }
179 
185  public function getBlogPosting()
186  {
187  return $this->getPageObject();
188  }
189 
196  protected function checkAccess($a_cmd)
197  {
198  if ($a_cmd == "contribute") {
199  return $this->may_contribute;
200  }
201  return $this->access_handler->checkAccess($a_cmd, "", $this->node_id);
202  }
203 
207  public function preview($a_mode = null)
208  {
209  global $DIC;
210  $ilCtrl = $this->ctrl;
211  $tpl = $this->tpl;
213 
214  $toolbar = $DIC->toolbar();
215 
216  $this->getBlogPosting()->increaseViewCnt();
217 
218  $wtpl = new ilTemplate(
219  "tpl.blog_page_view_main_column.html",
220  true,
221  true,
222  "Modules/Blog"
223  );
224 
225  // page commands
226  if (!$a_mode) {
227  if (!$this->getEnableEditing()) {
228  $this->ctrl->redirect($this, "previewFullscreen");
229  }
230  /*
231  // delete
232  $page_commands = false;
233  if ($this->checkAccess("write"))
234  {
235  $wtpl->setCurrentBlock("page_command");
236  $wtpl->setVariable("HREF_PAGE_CMD",
237  $ilCtrl->getLinkTarget($this, "deleteBlogPostingConfirmationScreen"));
238  $wtpl->setVariable("TXT_PAGE_CMD", $lng->txt("delete"));
239  $wtpl->parseCurrentBlock();
240  }
241  if ($page_commands)
242  {
243  $wtpl->setCurrentBlock("page_commands");
244  $wtpl->parseCurrentBlock();
245  }
246  */
247  } else {
248  $callback = array($this, "observeNoteAction");
249 
250  // notes
251 
252  $may_delete_comments = ($this->checkAccess("contribute") &&
253  $ilSetting->get("comments_del_tutor", 1));
254 
255  $wtpl->setVariable("TOOLBAR", $toolbar->getHTML());
256 
257  $wtpl->setVariable("NOTES", $this->getNotesHTML(
258  $this->getBlogPosting(),
259  false,
260  $this->enable_public_notes,
261  $may_delete_comments,
262  $callback
263  ));
264  }
265 
266  // permanent link
267  if ($a_mode != "embedded") {
268  $append = ($this->blpg > 0)
269  ? "_" . $this->blpg
270  : "";
271  if ($this->isInWorkspace()) {
272  $append .= "_wsp";
273  }
274  $tpl->setPermanentLink("blog", $this->node_id, $append);
275  }
276 
277  $wtpl->setVariable("PAGE", parent::preview());
278 
279  $tpl->setLoginTargetPar("blog_" . $this->node_id . $append);
280 
281  $ilCtrl->setParameter($this, "blpg", $this->getBlogPosting()->getId());
282 
283  return $wtpl->get();
284  }
285 
291  public function previewEmbedded()
292  {
293  return $this->preview("embedded");
294  }
295 
301  public function previewFullscreen()
302  {
303  $this->add_date = true;
304  return $this->preview("fullscreen");
305  }
306 
312  public function showPage($a_title = "")
313  {
314  $this->setTemplateOutput(false);
315 
316  if (!$this->getAbstractOnly()) {
317  if ($a_title != "") {
318  $this->setPresentationTitle($a_title);
319  } else {
320  $this->setPresentationTitle($this->getBlogPosting()->getTitle());
321  }
322  }
323  $this->getBlogPosting()->increaseViewCnt();
324 
325  return parent::showPage();
326  }
327 
333  protected function isInWorkspace()
334  {
335  $class = '';
336  if (is_object($this->access_handler)) {
337  $class = get_class($this->access_handler);
338  }
339 
340  return stristr($class, "workspace");
341  }
342 
349  public function postOutputProcessing($a_output)
350  {
351  // #8626/#9370
352  if (($this->getOutputMode() == "preview" || $this->getOutputMode() == "offline")
353  && !$this->getAbstractOnly() && $this->add_date) {
354  $author = "";
355  if (!$this->isInWorkspace()) {
356  $authors = array();
357  $author_id = $this->getBlogPosting()->getAuthor();
358  if ($author_id) {
359  $authors[] = ilUserUtil::getNamePresentation($author_id);
360  }
361 
362  foreach (ilBlogPosting::getPageContributors("blp", $this->getBlogPosting()->getId()) as $editor) {
363  if ($editor["user_id"] != $author_id) {
364  $authors[] = ilUserUtil::getNamePresentation($editor["user_id"]);
365  }
366  }
367 
368  if ($authors) {
369  $author = implode(", ", $authors) . " - ";
370  }
371  }
372 
373  // prepend creation date
376  $prefix = "<div class=\"il_BlockInfo\" style=\"text-align:right\">" .
377  $author . ilDatePresentation::formatDate($this->getBlogPosting()->getCreated()) .
378  "</div>";
380 
381  $a_output = $prefix . $a_output;
382  }
383 
384  return $a_output;
385  }
386 
392  public function getTabs($a_activate = "")
393  {
394  $ilCtrl = $this->ctrl;
395 
396  $ilCtrl->setParameterByClass("ilobjbloggui", "blpg", $this->getBlogPosting()->getId());
397 
398  parent::getTabs($a_activate);
399  }
400 
405  {
406  $tpl = $this->tpl;
407  $ilCtrl = $this->ctrl;
408  $lng = $this->lng;
409 
410  if ($this->checkAccess("write") || $this->checkAccess("contribute")) {
411  $confirmation_gui = new ilConfirmationGUI();
412  $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
413  $confirmation_gui->setHeaderText($lng->txt("blog_posting_deletion_confirmation"));
414  $confirmation_gui->setCancel($lng->txt("cancel"), "cancelBlogPostingDeletion");
415  $confirmation_gui->setConfirm($lng->txt("delete"), "confirmBlogPostingDeletion");
416 
417  $dtpl = new ilTemplate(
418  "tpl.blog_posting_deletion_confirmation.html",
419  true,
420  true,
421  "Modules/Blog"
422  );
423 
424  $dtpl->setVariable("PAGE_TITLE", $this->getBlogPosting()->getTitle());
425 
426  // notes/comments
427  $cnt_note_users = ilNote::getUserCount(
428  $this->getBlogPosting()->getParentId(),
429  $this->getBlogPosting()->getId(),
430  "wpg"
431  );
432  $dtpl->setVariable(
433  "TXT_NUMBER_USERS_NOTES_OR_COMMENTS",
434  $lng->txt("blog_number_users_notes_or_comments")
435  );
436  $dtpl->setVariable("TXT_NR_NOTES_COMMENTS", $cnt_note_users);
437 
438  $confirmation_gui->addItem("", "", $dtpl->get());
439 
440  $tpl->setContent($confirmation_gui->getHTML());
441  }
442  }
443 
447  public function cancelBlogPostingDeletion()
448  {
449  $ilCtrl = $this->ctrl;
450 
451  $ilCtrl->redirect($this, "preview");
452  }
453 
457  public function confirmBlogPostingDeletion()
458  {
459  $ilCtrl = $this->ctrl;
460  $lng = $this->lng;
461 
462  if ($this->checkAccess("write") || $this->checkAccess("contribute")) {
463  // delete all md keywords
464  $md_section = $this->getBlogPosting()->getMDSection();
465  foreach ($md_section->getKeywordIds() as $id) {
466  $md_key = $md_section->getKeyword($id);
467  $md_key->delete();
468  }
469 
470  $this->getBlogPosting()->delete();
471  ilUtil::sendSuccess($lng->txt("blog_posting_deleted"), true);
472  }
473 
474  $ilCtrl->setParameterByClass("ilobjbloggui", "blpg", ""); // #14363
475  $ilCtrl->redirectByClass("ilobjbloggui", "render");
476  }
477 
478  public function editTitle($a_form = null)
479  {
480  $tpl = $this->tpl;
481  $ilTabs = $this->tabs;
482 
483  $ilTabs->clearTargets();
484  $ilTabs->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTargetByClass("ilobjblogGUI"));
485 
486  $ilTabs->activateTab("edit");
487 
488  if (!$a_form) {
489  $a_form = $this->initTitleForm();
490  }
491 
492  $tpl->setContent($a_form->getHTML());
493  }
494 
495  public function updateTitle()
496  {
497  $ilCtrl = $this->ctrl;
498  $lng = $this->lng;
499 
500  $form = $this->initTitleForm();
501  if ($form->checkInput()) {
502  if ($this->checkAccess("write") || $this->checkAccess("contribute")) {
503  $page = $this->getPageObject();
504  $page->setTitle($form->getInput("title"));
505  $page->update();
506 
507  $page->handleNews(true);
508 
509  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
510  //$ilCtrl->redirect($this, "preview");
511  $this->ctrl->redirectByClass("ilObjBlogGUI", "");
512  }
513  }
514 
515  $form->setValuesByPost();
516  $this->editTitle($form);
517  }
518 
519  public function initTitleForm()
520  {
521  $lng = $this->lng;
522  $ilCtrl = $this->ctrl;
523 
524  $form = new ilPropertyFormGUI();
525  $form->setFormAction($ilCtrl->getFormAction($this));
526  $form->setTitle($lng->txt('blog_rename_posting'));
527 
528  $title = new ilTextInputGUI($lng->txt("title"), "title");
529  $title->setRequired(true);
530  $form->addItem($title);
531 
532  $title->setValue($this->getPageObject()->getTitle());
533 
534  $form->addCommandButton('updateTitle', $lng->txt('save'));
535  $form->addCommandButton('cancelEdit', $lng->txt('cancel'));
536 
537  return $form;
538  }
539 
540  public function editDate($a_form = null)
541  {
542  $tpl = $this->tpl;
543  $ilTabs = $this->tabs;
544 
545  $ilTabs->clearTargets();
546  $ilTabs->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTargetByClass("ilobjblogGUI"));
547 
548  $ilTabs->activateTab("edit");
549 
550  if (!$a_form) {
551  $a_form = $this->initDateForm();
552  }
553 
554  $tpl->setContent($a_form->getHTML());
555  }
556 
557  public function updateDate()
558  {
559  $ilCtrl = $this->ctrl;
560  $lng = $this->lng;
561 
562  $form = $this->initDateForm();
563  if ($form->checkInput()) {
564  if ($this->checkAccess("write") || $this->checkAccess("contribute")) {
565  $dt = $form->getItemByPostVar("date");
566  $dt = $dt->getDate();
567 
568  $page = $this->getPageObject();
569  $page->setCreated($dt);
570  $page->update();
571 
572  ilUtil::sendSuccess($lng->txt("settings_saved"), true);
573  //$ilCtrl->redirect($this, "preview");
574  $this->ctrl->redirectByClass("ilObjBlogGUI", "");
575  }
576  }
577 
578  $form->setValuesByPost();
579  $this->editTitle($form);
580  }
581 
582  public function initDateForm()
583  {
584  $lng = $this->lng;
585  $ilCtrl = $this->ctrl;
586 
587  $form = new ilPropertyFormGUI();
588  $form->setFormAction($ilCtrl->getFormAction($this));
589  $form->setTitle($lng->txt('blog_edit_date'));
590 
591  $date = new ilDateTimeInputGUI($lng->txt("date"), "date");
592  $date->setRequired(true);
593  $date->setShowTime(true);
594  $date->setInfo($lng->txt('blog_edit_date_info'));
595  $form->addItem($date);
596 
597  $date->setDate($this->getPageObject()->getCreated());
598 
599  $form->addCommandButton('updateDate', $lng->txt('save'));
600  $form->addCommandButton('cancelEdit', $lng->txt('cancel'));
601 
602  return $form;
603  }
604 
611  protected function cancelEdit()
612  {
613  $this->ctrl->redirectByClass("ilObjBlogGUI", "");
614  }
615 
616 
617  public function observeNoteAction($a_blog_id, $a_posting_id, $a_type, $a_action, $a_note_id)
618  {
619  // #10040 - get note text
620  $note = new ilNote($a_note_id);
621  $note = $note->getText();
622  ilObjBlog::sendNotification("comment", $this->isInWorkspace(), $this->node_id, $a_posting_id, $note);
623  }
624 
625  public function getActivationCaptions()
626  {
627  $lng = $this->lng;
628 
629  return array("deactivatePage" => $lng->txt("blog_toggle_draft"),
630  "activatePage" => $lng->txt("blog_toggle_final"));
631  }
632 
633  public function deactivatePageToList()
634  {
635  $this->deactivatePage(true);
636  }
637 
638  public function deactivatePage($a_to_list = false)
639  {
640  if ($this->checkAccess("write") || $this->checkAccess("contribute")) {
641  $this->getBlogPosting()->unpublish();
642  }
643 
644  if (!$a_to_list) {
645  $this->ctrl->redirect($this, "edit");
646  } else {
647  $this->ctrl->setParameterByClass("ilobjbloggui", "blpg", "");
648  $this->ctrl->redirectByClass("ilobjbloggui", "");
649  }
650  }
651 
652  public function activatePageToList()
653  {
654  $this->activatePage(true);
655  }
656 
657  public function activatePage($a_to_list = false)
658  {
659  // send notifications
660  ilObjBlog::sendNotification("new", $this->isInWorkspace(), $this->node_id, $this->getBlogPosting()->getId());
661 
662  if ($this->checkAccess("write") || $this->checkAccess("contribute")) {
663  $this->getBlogPosting()->setActive(true);
664  $this->getBlogPosting()->update(true, false, false);
665  }
666  if (!$a_to_list) {
667  $this->ctrl->redirect($this, "edit");
668  } else {
669  $this->ctrl->setParameterByClass("ilobjbloggui", "blpg", "");
670  $this->ctrl->redirectByClass("ilobjbloggui", "");
671  }
672  }
673 
678  public function editKeywords(ilPropertyFormGUI $a_form = null)
679  {
680  global $DIC;
681 
682  $renderer = $DIC->ui()->renderer();
683 
684  $ilTabs = $this->tabs;
685  $tpl = $this->tpl;
686 
687  $ilTabs->clearTargets();
688  $ilTabs->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTargetByClass("ilobjblogGUI"));
689 
690  if (!$this->checkAccess("contribute")) {
691  return;
692  }
693 
694  $ilTabs->activateTab("pg");
695 
696  if (!$a_form) {
697  $a_form = $this->initKeywordsForm();
698  }
699 
700  $tpl->setContent($renderer->render($a_form));
701  }
702 
703  protected function initKeywordsForm()
704  {
705  global $DIC;
706 
707  $ui_factory = $DIC->ui()->factory();
708  //$ilUser = $this->user;
709 
710  $md_section = $this->getBlogPosting()->getMDSection();
711 
712  $keywords = array();
713  foreach ($ids = $md_section->getKeywordIds() as $id) {
714  $md_key = $md_section->getKeyword($id);
715  if (trim($md_key->getKeyword()) != "") {
716  //$keywords[$md_key->getKeywordLanguageCode()][]
717  // = $md_key->getKeyword();
718  $keywords[] = $md_key->getKeyword();
719  }
720  }
721 
722  // language is not "used" anywhere
723  /*$ulang = $ilUser->getLanguage();
724  if($keywords[$ulang])
725  {
726  asort($keywords[$ulang]);
727  }*/
728 
729  // other keywords in blog
730  $other = array();
731  foreach (array_keys(ilBlogPosting::getAllPostings($this->getBlogPosting()->getBlogId())) as $posting_id) {
732  if ($posting_id != $this->getBlogPosting()->getId()) {
733  $other = array_merge($other, ilBlogPosting::getKeywords($this->getBlogPosting()->getBlogId(), $posting_id));
734  }
735  }
736  // #17414
737  $other = array_unique($other);
738  sort($other, SORT_LOCALE_STRING);
739  if (is_array($keywords[$ulang])) {
740  $other = array_diff($other, $keywords[$ulang]);
741  }
742 
743  $input_tag = $ui_factory->input()->field()->tag($this->lng->txt("blog_keywords"), $other, $this->lng->txt("blog_keyword_enter"))->withUserCreatedTagsAllowed(true);
744  if (count($keywords) > 0) {
745  $input_tag = $input_tag->withValue($keywords);
746  }
747 
748  $DIC->ctrl()->setParameter(
749  $this,
750  'tags',
751  'tags_processing'
752  );
753 
754  $section = $ui_factory->input()->field()->section([$input_tag], $this->lng->txt("blog_edit_keywords"), "");
755 
756  $form_action = $DIC->ctrl()->getFormAction($this, "saveKeywordsForm");
757  $form = $ui_factory->input()->container()->form()->standard($form_action, ["tags" => $section]);
758 
759  return $form;
760  }
761 
762  protected function getParentObjId()
763  {
764  if ($this->node_id) {
765  if ($this->isInWorkspace()) {
766  return $this->access_handler->getTree()->lookupObjectId($this->node_id);
767  } else {
768  return ilObject::_lookupObjId($this->node_id);
769  }
770  }
771  }
772 
773  public function saveKeywordsForm()
774  {
775  global $DIC;
776 
777  $request = $DIC->http()->request();
778  $form = $this->initKeywordsForm();
779 
780  if ($request->getMethod() == "POST"
781  && $request->getQueryParams()['tags'] == 'tags_processing') {
782  $form = $form->withRequest($request);
783  $result = $form->getData();
784  //TODO identify the input instead of use 0
785  $keywords = $result["tags"][0];
786 
787  if ($this->checkAccess("write") || $this->checkAccess("contribute")) {
788  if (is_array($keywords)) {
789  $this->getBlogPosting()->updateKeywords($keywords);
790  } else {
791  $this->getBlogPosting()->updateKeywords([]);
792  }
793  }
794 
795  $this->ctrl->redirectByClass("ilObjBlogGUI", "");
796  }
797  }
798 
811  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)
812  {
813  $bpgui = new self(0, null, $a_id);
814 
815  // scan the full page for media objects
816  if ($a_include_picture) {
817  $img = $bpgui->getFirstMediaObjectAsTag($a_picture_width, $a_picture_height, $a_export_directory);
818  }
819 
820  $bpgui->setRawPageContent(true);
821  $bpgui->setAbstractOnly(true);
822 
823  // #8627: export won't work - should we set offline mode?
824  $bpgui->setFileDownloadLink(".");
825  $bpgui->setFullscreenLink(".");
826  $bpgui->setSourcecodeDownloadScript(".");
827  $bpgui->setProfileBackUrl(".");
828 
829  // render without title
830  $page = $bpgui->showPage();
831 
832  if ($a_truncate) {
833  $page = ilPageObject::truncateHTML($page, $a_truncate_length, $a_truncate_sign);
834  }
835 
836  if ($img) {
837  $page = '<div>' . $img . $page . '</div><div style="clear:both;"></div>';
838  }
839 
840  return $page;
841  }
842 
843  protected function getFirstMediaObjectAsTag($a_width = 144, $a_height = 144, $a_export_directory = null)
844  {
845  $this->obj->buildDom();
846  $mob_ids = $this->obj->collectMediaObjects();
847  if ($mob_ids) {
848  foreach ($mob_ids as $mob_id) {
849  $mob_obj = new ilObjMediaObject($mob_id);
850  $mob_item = $mob_obj->getMediaItem("Standard");
851  if (stristr($mob_item->getFormat(), "image")) {
852  $mob_size = $mob_item->getOriginalSize();
853  if ($mob_size["width"] >= $a_width ||
854  $mob_size["height"] >= $a_height) {
855  if (!$a_export_directory) {
856  $mob_dir = ilObjMediaObject::_getDirectory($mob_obj->getId());
857  } else {
858  // see ilCOPageHTMLExport::exportHTMLMOB()
859  $mob_dir = "./mobs/mm_" . $mob_obj->getId();
860  }
861  $mob_res = self::parseImage(
862  $mob_size["width"],
863  $mob_size["height"],
864  $a_width,
865  $a_height
866  );
867 
868 
869  $location = $mob_item->getLocationType() == "Reference"
870  ? $mob_item->getLocation()
871  : $mob_dir . "/" . $mob_item->getLocation();
872 
873  return '<img' .
874  ' src="' . $location . '"' .
875  ' width="' . $mob_res[0] . '"' .
876  ' height="' . $mob_res[1] . '"' .
877  ' class="ilBlogListItemSnippetPreviewImage ilFloatLeft noMirror"' .
878  ' />';
879  }
880  }
881  }
882  }
883  }
884 
885  protected static function parseImage($src_width, $src_height, $tgt_width, $tgt_height)
886  {
887  $ratio_width = $ratio_height = 1;
888  if ($src_width > $tgt_width) {
889  $ratio_width = $tgt_width / $src_width;
890  }
891  if ($src_height > $tgt_height) {
892  $ratio_height = $tgt_height / $src_height;
893  }
894  $shrink_ratio = min($ratio_width, $ratio_height);
895 
896  return array(
897  (int) round($src_width * $shrink_ratio),
898  (int) round($src_height * $shrink_ratio)
899  );
900  }
901 
908  public function getDisabledText()
909  {
910  return $this->lng->txt("blog_draft_text");
911  }
912 
916  public function getCommentsHTMLExport()
917  {
918  return $this->getNotesHTML(
919  $this->getBlogPosting(),
920  false,
921  $this->enable_public_notes,
922  false,
923  null,
924  true
925  );
926  }
927 
931  protected function showEditToolbar()
932  {
933  }
934 
935  public function finishEditing()
936  {
937  $this->ctrl->setParameterByClass("ilobjbloggui", "bmn", "");
938  $this->ctrl->redirectByClass("ilobjbloggui", "render");
939  }
940 }
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
previewEmbedded()
Needed for portfolio/blog handling.
settings()
Definition: settings.php:2
getPageObject()
Get Page Object.
Class ilBlogPosting.
$result
setTemplateOutput($a_output=true)
This class represents a property form user interface.
observeNoteAction($a_blog_id, $a_posting_id, $a_type, $a_action, $a_note_id)
getTabs($a_activate="")
Get tabs.
$_GET["client_id"]
$location
Definition: buildRTE.php:44
Class ilBlogPosting GUI class.
getDisabledText()
Get disabled text.
Class ilPageObjectGUI.
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)
showEditToolbar()
Show edit toolbar.
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.
user()
Definition: user.php:4
static _getDirectory($a_mob_id)
Get absolute directory.
Note class.
static useRelativeDates()
check if relative dates are used
This class represents a date/time property in a property form.
static getAllPostings($a_blog_id, $a_limit=1000, $a_offset=0)
Get all postings of blog.
$section
Definition: Utf8Test.php:83
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.
global $DIC
Definition: goto.php:24
setPresentationTitle($a_title="")
showPage($a_title="")
Embedded posting in portfolio.
Class ilObjMediaObject.
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.
$img
Definition: imgupload.php:57
setStyleId($a_styleid)
Set Style Id.
static parseImage($src_width, $src_height, $tgt_width, $tgt_height)
deactivatePage($a_to_list=false)
static truncateHTML( $a_text, $a_length=100, $a_ending='...', $a_exact=false, $a_consider_html=true)
Truncate (html) string.
global $ilSetting
Definition: privfeed.php:17
__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, $export=false)
Get html for public and/or private notes.
activatePage($a_to_list=false)
setRequired($a_required)
Set Required.
deleteBlogPostingConfirmationScreen()
Delete blog posting confirmation screen.
cancelBlogPostingDeletion()
Cancel blog posting deletion.
Confirmation screen class.