コード例 #1
0
 @Override
 protected void processEvent(Event<PreviewPageActionComponent> event) throws Exception {
   UIWikiPortlet wikiPortlet = event.getSource().getAncestorOfType(UIWikiPortlet.class);
   WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
   ResourceBundle res = context.getApplicationResourceBundle();
   UIWikiMaskWorkspace uiMaskWS = wikiPortlet.getChild(UIWikiMaskWorkspace.class);
   UIWikiPageEditForm wikiPageEditForm =
       event.getSource().getAncestorOfType(UIWikiPageEditForm.class);
   UIWikiPagePreview wikiPagePreview =
       uiMaskWS.createUIComponent(UIWikiPagePreview.class, null, null);
   UIWikiRichTextArea wikiRichTextArea = wikiPageEditForm.getChild(UIWikiRichTextArea.class);
   UIWikiPageTitleControlArea wikiPageTitleArea =
       wikiPageEditForm.getChild(UIWikiPageTitleControlArea.class);
   String markupSyntax = Utils.getDefaultSyntax();
   boolean isRichTextRendered = wikiRichTextArea.isRendered();
   RenderingService renderingService =
       (RenderingService) PortalContainer.getComponent(RenderingService.class);
   String markup;
   if (isRichTextRendered) {
     String htmlContent = wikiRichTextArea.getUIFormTextAreaInput().getValue();
     markup =
         renderingService.render(
             htmlContent, Syntax.XHTML_1_0.toIdString(), markupSyntax, false);
     Utils.feedDataForWYSIWYGEditor(wikiPageEditForm, markup);
   } else {
     UIFormTextAreaInput markupInput =
         wikiPageEditForm.findComponentById(UIWikiPageEditForm.FIELD_CONTENT);
     markup = (markupInput.getValue() == null) ? "" : markupInput.getValue();
   }
   wikiPagePreview.renderWikiMarkup(markup, markupSyntax);
   String pageTitle = wikiPageTitleArea.getTitle();
   if (pageTitle != null) wikiPagePreview.setPageTitle(wikiPageTitleArea.getTitle());
   else {
     wikiPagePreview.setPageTitle(res.getString("UIWikiPageTitleControlArea.label.Untitled"));
   }
   uiMaskWS.setUIComponent(wikiPagePreview);
   uiMaskWS.setShow(true);
   uiMaskWS.setPopupTitle(res.getString("UIEditorTabs.action.PreviewPage"));
   event.getRequestContext().addUIComponentToUpdateByAjax(uiMaskWS);
   super.processEvent(event);
 }
コード例 #2
0
  @Override
  public void processRender(WebuiRequestContext context) throws Exception {
    RenderingService renderingService =
        (RenderingService) PortalContainer.getComponent(RenderingService.class);
    WikiService wikiService = (WikiService) PortalContainer.getComponent(WikiService.class);
    String syntaxId = org.exoplatform.wiki.commons.Utils.getDefaultSyntax();

    PageImpl syntaxHelpPage = wikiService.getHelpSyntaxPage(syntaxId);
    this.syntaxName = syntaxId.replace("/", " ").toUpperCase();
    if (syntaxHelpPage != null) {
      String markup = syntaxHelpPage.getContent().getText();
      this.htmlOutput =
          renderingService.render(markup, syntaxId, Syntax.XHTML_1_0.toIdString(), false);
      this.syntaxFullPageUrl =
          "/"
              + PortalContainer.getInstance().getRestContextName()
              + "/wiki/help/"
              + syntaxId.replace("/", Utils.SLASH).replace(".", Utils.DOT);
    } else {
      this.htmlOutput = null;
    }
    super.processRender(context);
  }