示例#1
0
 public void onEvent(Event<UIPostForm> event, UIPostForm uiForm, String id) throws Exception {
   UIForumInputWithActions threadContent = uiForm.getChildById(FIELD_THREADCONTEN_TAB);
   int t = 0, k = 1;
   String postTitle = threadContent.getUIStringInput(FIELD_POSTTITLE_INPUT).getValue();
   String userName = UserHelper.getCurrentUser();
   String message = threadContent.getChild(UIFormWYSIWYGInput.class).getValue();
   String checksms =
       TransformHTML.cleanHtmlCode(
           message, new ArrayList<String>((new ExtendedBBCodeProvider()).getSupportedBBCodes()));
   checksms = checksms.replaceAll("&nbsp;", " ");
   t = checksms.trim().length();
   if (ForumUtils.isEmpty(postTitle)) {
     k = 0;
   }
   if (t > 0 && k != 0 && !checksms.equals("null")) {
     postTitle = CommonUtils.encodeSpecialCharInTitle(postTitle);
     Post post = uiForm.post_;
     post.setName(postTitle);
     post.setMessage(message);
     post.setOwner(userName);
     if (ForumUtils.isEmpty(uiForm.postId)) {
       post.setCreatedDate(CommonUtils.getGreenwichMeanTime().getTime());
       post.setModifiedDate(CommonUtils.getGreenwichMeanTime().getTime());
     }
     post.setModifiedBy(userName);
     post.setRemoteAddr(ForumUtils.EMPTY_STR);
     post.setIcon("uiIconForumTopic uiIconForumLightGray");
     post.setIsApproved(false);
     post.setAttachments(uiForm.getAttachFileList());
     UIPopupContainer popupContainer = uiForm.getAncestorOfType(UIPopupContainer.class);
     UIViewPost viewPost = uiForm.openPopup(popupContainer, UIViewPost.class, 670, 0);
     viewPost.setId("viewPost");
     viewPost.setPostView(post);
     viewPost.setActionForm(new String[] {"Close"});
   } else {
     String[] args = {ForumUtils.EMPTY_STR};
     if (k == 0) {
       args = new String[] {uiForm.getLabel(FIELD_POSTTITLE_INPUT)};
       if (t <= 0)
         args =
             new String[] {
               uiForm.getLabel(FIELD_POSTTITLE_INPUT)
                   + ", "
                   + uiForm.getLabel(FIELD_MESSAGECONTENT)
             };
       uiForm.warning("NameValidator.msg.ShortText", args);
     } else if (t <= 0) {
       args = new String[] {uiForm.getLabel(FIELD_MESSAGECONTENT)};
       uiForm.warning("NameValidator.msg.ShortMessage", args);
     }
   }
 }
示例#2
0
 public void onEvent(
     Event<UIModerationForum> event, UIModerationForum moderationForum, final String objectId)
     throws Exception {
   ForumSearch forumSearch = moderationForum.getObject(objectId);
   UIPopupContainer popupContainer = moderationForum.getAncestorOfType(UIPopupContainer.class);
   UIPopupAction popupAction = popupContainer.getChild(UIPopupAction.class);
   if (forumSearch.getType().equals(Utils.TOPIC)) {
     try {
       Topic topic =
           moderationForum.getForumService().getTopicByPath(forumSearch.getPath(), false);
       UIViewTopic viewTopic = popupAction.activate(UIViewTopic.class, 700);
       viewTopic.setTopic(topic);
       viewTopic.setActionForm(new String[] {"Approve", "DeleteTopic", "Close"});
       event.getRequestContext().addUIComponentToUpdateByAjax(popupAction);
     } catch (Exception e) {
       moderationForum.log.warn("Failed to view topic: ", e);
     }
   } else {
     try {
       Post post =
           moderationForum
               .getForumService()
               .getPost(
                   ForumUtils.EMPTY_STR,
                   ForumUtils.EMPTY_STR,
                   ForumUtils.EMPTY_STR,
                   forumSearch.getPath());
       UIViewPost viewPost = popupAction.activate(UIViewPost.class, 700);
       viewPost.setPostView(post);
       viewPost.setViewUserInfo(false);
       viewPost.setActionForm(new String[] {"Approve", "DeletePost", "Close", "OpenTopicLink"});
       event.getRequestContext().addUIComponentToUpdateByAjax(popupAction);
     } catch (Exception e) {
       moderationForum.log.warn("Failed to view post: ", e);
     }
   }
 }