/** * get notes/comments list as html code */ function getNoteListHTML($a_type = IL_NOTE_PRIVATE, $a_init_form = true) { global $lng, $ilCtrl, $ilUser; include_once "./Services/User/classes/class.ilUserUtil.php"; $suffix = $a_type == IL_NOTE_PRIVATE ? "private" : "public"; /* user settings are deprecated $user_setting_notes_public_all = $ilUser->getPref("notes_pub_all"); $user_setting_notes_by_type = $ilUser->getPref("notes_".$suffix); */ $user_setting_notes_public_all = "y"; $user_setting_notes_by_type = "y"; if ($this->delete_note || $this->export_html || $this->print) { if ($_GET["note_id"] != "") { $filter = $_GET["note_id"]; } else { $filter = $_POST["note"]; } } $notes = ilNote::_getNotesOfObject($this->rep_obj_id, $this->obj_id, $this->obj_type, $a_type, $this->inc_sub, $filter, $user_setting_notes_public_all, $this->repository_mode, (bool) $_SESSION["comments_sort_asc"]); $all_notes = ilNote::_getNotesOfObject($this->rep_obj_id, $this->obj_id, $this->obj_type, $a_type, $this->inc_sub, $filter, "", $this->repository_mode); $tpl = new ilTemplate("tpl.notes_list.html", true, true, "Services/Notes"); if ($this->ajax) { include_once "./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php"; $tpl->setCurrentBlock("close_img"); $tpl->setVariable("CLOSE_IMG", ilGlyphGUI::get(ilGlyphGUI::CLOSE)); $tpl->parseCurrentBlock(); } // show counter if notes are hidden $cnt_str = count($all_notes) > 0 ? " (" . count($all_notes) . ")" : ""; // title if ($this->ajax) { switch ($this->obj_type) { case "catr": case "crsr": include_once "Services/ContainerReference/classes/class.ilContainerReference.php"; $title = ilContainerReference::_lookupTitle($this->rep_obj_id); break; default: $title = ilObject::_lookupTitle($this->rep_obj_id); break; } $img = ilUtil::img(ilObject::_getIcon($this->rep_obj_id, "tiny")); // add sub-object if given if ($this->obj_id) { $sub_title = $this->getSubObjectTitle($this->rep_obj_id, $this->obj_id); if ($sub_title) { $title .= " - " . $sub_title; } } $tpl->setCurrentBlock("title"); $tpl->setVariable("TITLE", $img . " " . $title); $tpl->parseCurrentBlock(); } if ($this->delete_note) { $cnt_str = ""; } if ($a_type == IL_NOTE_PRIVATE) { $tpl->setVariable("TXT_NOTES", $lng->txt("private_notes") . $cnt_str); $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PRIVATE); } else { $tpl->setVariable("TXT_NOTES", $lng->txt("notes_public_comments") . $cnt_str); $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PUBLIC); } $anch = $this->anchor_jump ? "notes_top" : ""; $tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this, "getNotesHTML", $anch)); if ($this->ajax) { $os = "onsubmit = \"ilNotes.cmdAjaxForm(event, '" . $ilCtrl->getFormActionByClass("ilnotegui", "", "", true) . "'); return false;\""; $tpl->setVariable("ON_SUBMIT_FORM", $os); $tpl->setVariable("FORM_ID", "Ajax"); } if ($this->export_html || $this->print) { $tpl->touchBlock("print_style"); } // show add new note button if (!$this->add_note_form && !$this->edit_note_form && !$this->delete_note && !$this->export_html && !$this->print && $ilUser->getId() != ANONYMOUS_USER_ID) { if (!$this->inc_sub) { // are displayed if ($this->rep_obj_id > 0 || $a_type != IL_NOTE_PUBLIC) { $tpl->setCurrentBlock("add_note_btn"); if ($a_type == IL_NOTE_PUBLIC) { $tpl->setVariable("TXT_ADD_NOTE", $lng->txt("notes_add_comment")); } else { $tpl->setVariable("TXT_ADD_NOTE", $lng->txt("add_note")); } $tpl->setVariable("LINK_ADD_NOTE", $ilCtrl->getLinkTargetByClass("ilnotegui", "addNoteForm") . "#note_edit"); $tpl->parseCurrentBlock(); } } } // show show/hide button for note list if (count($all_notes) > 0 && $this->enable_hiding && !$this->delete_note && !$this->export_html && !$this->print && !$this->edit_note_form && !$this->add_note_form) { if ($user_setting_notes_by_type == "n") { if ($a_type == IL_NOTE_PUBLIC) { $txt = $lng->txt("notes_show_comments"); } else { $txt = $lng->txt("show_" . $suffix . "_notes"); } $this->renderLink($tpl, "show_notes", $txt, "showNotes", "notes_top"); } else { // never individually hide for anonymous users if ($ilUser->getId() != ANONYMOUS_USER_ID) { if ($a_type == IL_NOTE_PUBLIC) { $txt = $lng->txt("notes_hide_comments"); } else { $txt = $lng->txt("hide_" . $suffix . "_notes"); } $this->renderLink($tpl, "hide_notes", $txt, "hideNotes", "notes_top"); // show all public notes / my notes only switch if ($a_type == IL_NOTE_PUBLIC) { if ($user_setting_notes_public_all == "n") { $this->renderLink($tpl, "all_pub_notes", $lng->txt("notes_all_comments"), "showAllPublicNotes", "notes_top"); } else { $this->renderLink($tpl, "my_pub_notes", $lng->txt("notes_my_comments"), "showMyPublicNotes", "notes_top"); } } } } } // show add new note text area if (!$this->edit_note_form && $user_setting_notes_by_type != "n" && !$this->delete_note && $ilUser->getId() != ANONYMOUS_USER_ID) { if ($a_init_form) { $this->initNoteForm("create", $a_type); } $tpl->setCurrentBlock("edit_note_form"); // $tpl->setVariable("EDIT_FORM", $this->form->getHTML()); $tpl->setVariable("EDIT_FORM", $this->form_tpl->get()); $tpl->parseCurrentBlock(); $tpl->parseCurrentBlock(); $tpl->setCurrentBlock("note_row"); $tpl->parseCurrentBlock(); } // list all notes if ($user_setting_notes_by_type != "n" || !$this->enable_hiding) { $reldates = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); if (sizeof($notes)) { if ((int) $_SESSION["comments_sort_asc"] == 1) { $sort_txt = $lng->txt("notes_sort_desc"); $sort_cmd = "listSortDesc"; } else { $sort_txt = $lng->txt("notes_sort_asc"); $sort_cmd = "listSortAsc"; } $this->renderLink($tpl, "sort_list", $sort_txt, $sort_cmd, $anch); } $notes_given = false; foreach ($notes as $note) { if ($this->edit_note_form && $note->getId() == $_GET["note_id"] && $a_type == $_GET["note_type"]) { if ($a_init_form) { $this->initNoteForm("edit", $a_type, $note); } $tpl->setCurrentBlock("edit_note_form"); // $tpl->setVariable("EDIT_FORM", $this->form->getHTML()); $tpl->setVariable("EDIT_FORM", $this->form_tpl->get()); $tpl->parseCurrentBlock(); } else { $cnt_col = 2; // delete note stuff for all private notes if ($this->checkDeletion($note) && !$this->delete_note && !$this->export_html && !$this->print && !$this->edit_note_form && !$this->add_note_form) { $ilCtrl->setParameterByClass("ilnotegui", "note_id", $note->getId()); $this->renderLink($tpl, "delete_note", $lng->txt("delete"), "deleteNote", "note_" . $note->getId()); } // checkboxes in multiselection mode if ($this->multi_selection && !$this->delete_note) { $tpl->setCurrentBlock("checkbox_col"); $tpl->setVariable("CHK_NOTE", "note[]"); $tpl->setVariable("CHK_NOTE_ID", $note->getId()); $tpl->parseCurrentBlock(); $cnt_col = 1; } // edit note stuff for all private notes if ($this->checkEdit($note)) { if (!$this->delete_note && !$this->export_html && !$this->print && !$this->edit_note_form && !$this->add_note_form) { $ilCtrl->setParameterByClass("ilnotegui", "note_id", $note->getId()); $this->renderLink($tpl, "edit_note", $lng->txt("edit"), "editNoteForm", "note_edit"); } } $tpl->setVariable("CNT_COL", $cnt_col); // output author account if ($a_type == IL_NOTE_PUBLIC && ilObject::_exists($note->getAuthor())) { //$tpl->setCurrentBlock("author"); //$tpl->setVariable("VAL_AUTHOR", ilObjUser::_lookupLogin($note->getAuthor())); //$tpl->parseCurrentBlock(); $tpl->setCurrentBlock("user_img"); $tpl->setVariable("USR_IMG", ilObjUser::_getPersonalPicturePath($note->getAuthor(), "xxsmall")); $tpl->setVariable("USR_ALT", $lng->txt("user_image") . ": " . ilObjUser::_lookupLogin($note->getAuthor())); $tpl->parseCurrentBlock(); $tpl->setVariable("TXT_USR", ilUserUtil::getNamePresentation($note->getAuthor(), false, false) . " - "); } // last edited if ($note->getUpdateDate() != null) { $tpl->setVariable("TXT_LAST_EDIT", $lng->txt("last_edited_on")); $tpl->setVariable("DATE_LAST_EDIT", ilDatePresentation::formatDate(new ilDate($note->getUpdateDate(), IL_CAL_DATETIME))); } else { $tpl->setVariable("VAL_DATE", ilDatePresentation::formatDate(new ilDate($note->getCreationDate(), IL_CAL_DATETIME))); } // hidden note ids for deletion if ($this->delete_note) { $tpl->setCurrentBlock("delete_ids"); $tpl->setVariable("HID_NOTE", "note[]"); $tpl->setVariable("HID_NOTE_ID", $note->getId()); $tpl->parseCurrentBlock(); } $target = $note->getObject(); // target objects $this->showTargets($tpl, $this->rep_obj_id, $note->getId(), $target["obj_type"], $target["obj_id"]); $rowclass = $rowclass != "tblrow1" ? "tblrow1" : "tblrow2"; if (!$this->export_html && !$this->print) { $tpl->setCurrentBlock("note_img"); if ($a_type == IL_NOTE_PUBLIC) { $tpl->setVariable("IMG_NOTE", $this->comment_img[$note->getLabel()]["img"]); $tpl->setVariable("ALT_NOTE", $this->comment_img[$note->getLabel()]["alt"]); } else { $tpl->setVariable("IMG_NOTE", $this->note_img[$note->getLabel()]["img"]); $tpl->setVariable("ALT_NOTE", $this->note_img[$note->getLabel()]["alt"]); } $tpl->parseCurrentBlock(); } else { switch ($note->getLabel()) { case IL_NOTE_UNLABELED: $tpl->setVariable("EXP_ICON", "[ ]"); break; case IL_NOTE_IMPORTANT: $tpl->setVariable("EXP_ICON", "[!]"); break; case IL_NOTE_QUESTION: $tpl->setVariable("EXP_ICON", "[?]"); break; case IL_NOTE_PRO: $tpl->setVariable("EXP_ICON", "[+]"); break; case IL_NOTE_CONTRA: $tpl->setVariable("EXP_ICON", "[-]"); break; } } $tpl->setCurrentBlock("note"); $tpl->setVariable("ROWCLASS", $rowclass); $text = trim($note->getText()) != "" ? nl2br($note->getText()) : "<p class='subtitle'>" . $lng->txt("note_content_removed") . "</p>"; $tpl->setVariable("NOTE_TEXT", $text); $tpl->setVariable("VAL_SUBJECT", $note->getSubject()); $tpl->setVariable("NOTE_ID", $note->getId()); $tpl->setVariable("CLASS", $a_type == IL_NOTE_PUBLIC ? "ilComment" : "ilNote"); $tpl->parseCurrentBlock(); } $tpl->setCurrentBlock("note_row"); $tpl->parseCurrentBlock(); $notes_given = true; } if (!$notes_given) { $tpl->setCurrentBlock("no_notes"); if ($a_type == IL_NOTE_PUBLIC) { $tpl->setVariable("NO_NOTES", $lng->txt("notes_no_comments")); } /* else { $tpl->setVariable("NO_NOTES", $lng->txt("notes_no_notes")); }*/ $tpl->parseCurrentBlock(); } ilDatePresentation::setUseRelativeDates($reldates); // multiple items commands if ($this->multi_selection && !$this->delete_note && !$this->edit_note_form && count($notes) > 0) { if ($a_type == IL_NOTE_PRIVATE) { $tpl->setCurrentBlock("delete_cmd"); $tpl->setVariable("TXT_DELETE_NOTES", $this->lng->txt("delete")); $tpl->parseCurrentBlock(); } $tpl->setCurrentBlock("multiple_commands"); $tpl->setVariable("TXT_SELECT_ALL", $this->lng->txt("select_all")); $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg")); $tpl->setVariable("ALT_ARROW", $this->lng->txt("actions")); $tpl->setVariable("TXT_PRINT_NOTES", $this->lng->txt("print")); $tpl->setVariable("TXT_EXPORT_NOTES", $this->lng->txt("exp_html")); $tpl->parseCurrentBlock(); } // delete / cancel row if ($this->delete_note) { $tpl->setCurrentBlock("delete_cancel"); $tpl->setVariable("TXT_DEL_NOTES", $this->lng->txt("delete")); $tpl->setVariable("TXT_CANCEL_DEL_NOTES", $this->lng->txt("cancel")); $tpl->parseCurrentBlock(); } // print if ($this->print) { $tpl->touchBlock("print_js"); $tpl->setCurrentBlock("print_back"); $tpl->setVariable("LINK_BACK", $this->ctrl->getLinkTarget($this, "showNotes")); $tpl->setVariable("TXT_BACK", $this->lng->txt("back")); $tpl->parseCurrentBlock(); } } // message switch ($_GET["note_mess"] != "" ? $_GET["note_mess"] : $this->note_mess) { case "mod": $mtype = "success"; $mtxt = $lng->txt("msg_obj_modified"); break; case "ntsdel": $mtype = "success"; $mtxt = $a_type == IL_NOTE_PRIVATE ? $lng->txt("notes_notes_deleted") : $lng->txt("notes_comments_deleted"); break; case "ntdel": $mtype = "success"; $mtxt = $a_type == IL_NOTE_PRIVATE ? $lng->txt("notes_note_deleted") : $lng->txt("notes_comment_deleted"); break; case "frmfld": $mtype = "failure"; $mtxt = $lng->txt("form_input_not_valid"); break; case "qdel": $mtype = "question"; $mtxt = $lng->txt("info_delete_sure"); break; case "noc": $mtype = "failure"; $mtxt = $lng->txt("no_checkbox"); break; } if ($mtxt != "") { $tpl->setVariable("MESS", $tpl->getMessageHTML($mtxt, $mtype)); } else { $tpl->setVariable("MESS", ""); } if ($this->delete_note && count($notes) == 0) { return ""; } else { return $tpl->get(); } }
/** * Build posting month list * * @param array $items * @param string $a_month * @param string $a_cmd * @param bool $a_link_template * @param bool $a_show_inactive * @return string */ function renderList(array $items, $a_month, $a_cmd = "preview", $a_link_template = null, $a_show_inactive = false) { global $lng, $ilCtrl; include_once "Services/Calendar/classes/class.ilCalendarUtil.php"; $wtpl = new ilTemplate("tpl.blog_list.html", true, true, "Modules/Blog"); // title according to current "filter"/navigation if ($this->keyword) { $title = $lng->txt("blog_keyword") . ": " . $this->keyword; } else { if ($this->author) { include_once "Services/User/classes/class.ilUserUtil.php"; $title = $lng->txt("blog_author") . ": " . ilUserUtil::getNamePresentation($this->author); } else { include_once "Services/Calendar/classes/class.ilCalendarUtil.php"; $title = ilCalendarUtil::_numericMonthToString((int) substr($a_month, 5)) . " " . substr($a_month, 0, 4); } } $wtpl->setVariable("TXT_CURRENT_MONTH", $title); $can_approve = $this->object->hasApproval() && $this->checkPermissionBool("write"); $can_deactivate = $this->checkPermissionBool("write"); include_once "./Modules/Blog/classes/class.ilBlogPostingGUI.php"; foreach ($items as $item) { // only published items $is_active = ilBlogPosting::_lookupActive($item["id"], "blp"); if (!$is_active && !$a_show_inactive) { continue; } if (!$a_link_template) { $ilCtrl->setParameterByClass("ilblogpostinggui", "bmn", $this->month); $ilCtrl->setParameterByClass("ilblogpostinggui", "blpg", $item["id"]); $preview = $ilCtrl->getLinkTargetByClass("ilblogpostinggui", $a_cmd); } else { $preview = $this->buildExportLink($a_link_template, "posting", $item["id"]); } // actions $item_contribute = $this->mayContribute($item["id"], $item["author"]); if (($item_contribute || $can_approve || $can_deactivate) && !$a_link_template && $a_cmd == "preview") { include_once "./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php"; $alist = new ilAdvancedSelectionListGUI(); $alist->setId($item["id"]); $alist->setListTitle($lng->txt("actions")); if ($is_active && $this->object->hasApproval() && !$item["approved"]) { if ($can_approve) { $ilCtrl->setParameter($this, "apid", $item["id"]); $alist->addItem($lng->txt("blog_approve"), "approve", $ilCtrl->getLinkTarget($this, "approve")); $ilCtrl->setParameter($this, "apid", ""); } $wtpl->setVariable("APPROVAL", $lng->txt("blog_needs_approval")); } if ($item_contribute) { $alist->addItem($lng->txt("edit_content"), "edit", $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edit")); // #11858 if ($is_active) { $alist->addItem($lng->txt("blog_toggle_draft"), "deactivate", $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deactivatePageToList")); } else { $alist->addItem($lng->txt("blog_toggle_final"), "activate", $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "activatePageToList")); } $alist->addItem($lng->txt("rename"), "rename", $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "edittitle")); $alist->addItem($lng->txt("blog_edit_keywords"), "keywords", $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editKeywords")); $alist->addItem($lng->txt("blog_edit_date"), "editdate", $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "editdate")); $alist->addItem($lng->txt("delete"), "delete", $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deleteBlogPostingConfirmationScreen")); } else { if ($can_deactivate) { // #10513 if ($is_active) { $ilCtrl->setParameter($this, "apid", $item["id"]); $alist->addItem($lng->txt("blog_toggle_draft_admin"), "deactivate", $ilCtrl->getLinkTarget($this, "deactivateAdmin")); $ilCtrl->setParameter($this, "apid", ""); } $alist->addItem($lng->txt("delete"), "delete", $ilCtrl->getLinkTargetByClass("ilblogpostinggui", "deleteBlogPostingConfirmationScreen")); } } $wtpl->setCurrentBlock("actions"); $wtpl->setVariable("ACTION_SELECTOR", $alist->getHTML()); $wtpl->parseCurrentBlock(); } // comments if ($this->object->getNotesStatus() && !$a_link_template && !$this->disable_notes) { // count (public) notes include_once "Services/Notes/classes/class.ilNote.php"; $count = sizeof(ilNote::_getNotesOfObject($this->obj_id, $item["id"], "blp", IL_NOTE_PUBLIC)); if ($a_cmd != "preview") { $wtpl->setCurrentBlock("comments"); $wtpl->setVariable("TEXT_COMMENTS", $lng->txt("blog_comments")); $wtpl->setVariable("URL_COMMENTS", $preview); $wtpl->setVariable("COUNT_COMMENTS", $count); $wtpl->parseCurrentBlock(); } /* we disabled comments in edit mode (should always be done via pagegui) else { $hash = ilCommonActionDispatcherGUI::buildAjaxHash(ilCommonActionDispatcherGUI::TYPE_WORKSPACE, $this->node_id, "blog", $this->obj_id, "blp", $item["id"]); $notes_link = "#\" onclick=\"".ilNoteGUI::getListCommentsJSCall($hash); } */ } // permanent link if ($a_cmd != "preview" && $a_cmd != "previewEmbedded") { if ($this->id_type == self::WORKSPACE_NODE_ID) { $goto = $this->getAccessHandler()->getGotoLink($this->node_id, $this->obj_id, "_" . $item["id"]); } else { include_once "Services/Link/classes/class.ilLink.php"; $goto = ilLink::_getStaticLink($this->node_id, $this->getType(), true, "_" . $item["id"]); } $wtpl->setCurrentBlock("permalink"); $wtpl->setVariable("URL_PERMALINK", $goto); $wtpl->setVariable("TEXT_PERMALINK", $lng->txt("blog_permanent_link")); $wtpl->parseCurrentBlock(); } $snippet = ilBlogPostingGUI::getSnippet($item["id"]); if ($snippet) { $wtpl->setCurrentBlock("more"); $wtpl->setVariable("URL_MORE", $preview); $wtpl->setVariable("TEXT_MORE", $lng->txt("blog_list_more")); $wtpl->parseCurrentBlock(); } $wtpl->setCurrentBlock("posting"); if (!$is_active) { $wtpl->setVariable("DRAFT_CLASS", " ilBlogListItemDraft"); } $author = ""; if ($this->id_type == self::REPOSITORY_NODE_ID) { $author_id = $item["author"]; if ($author_id) { include_once "Services/User/classes/class.ilUserUtil.php"; $author = ilUserUtil::getNamePresentation($author_id) . " - "; } } // title $wtpl->setVariable("URL_TITLE", $preview); $wtpl->setVariable("TITLE", $item["title"]); $wtpl->setVariable("DATETIME", $author . ilDatePresentation::formatDate($item["created"], IL_CAL_DATE)); // content $wtpl->setVariable("CONTENT", $snippet); $wtpl->parseCurrentBlock(); } // notes /* if($a_cmd == "previewFullscreen" && $this->object->getNotesStatus()) { $wtpl->setVariable("NOTES", $this->getNotesHTML()); } */ // permalink if ($a_cmd == "previewFullscreen") { $wtpl->setVariable("PERMALINK", $this->getPermanentLinkWidget(null, true)); } return $wtpl->get(); }
/** * Get all comments of this record * * @return array ilNote[] */ public function getComments() { if ($this->comments === null) { $this->comments = ilNote::_getNotesOfObject($this->table->getCollectionObject()->getId(), $this->getId(), 'dcl', IL_NOTE_PUBLIC); } return $this->comments; }