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