예제 #1
0
 private String buildSectionEditLink(ParserInput parserInput, int section) throws ParserException {
   if (!parserInput.getAllowSectionEdit()) {
     return "";
   }
   if (parserInput.getLocale() == null) {
     logger.info(
         "Unable to build section edit links for "
             + parserInput.getTopicName()
             + " - locale is empty");
     return "";
   }
   // FIXME - template inclusion causes section edits to break, so disable for now
   Integer inclusion = (Integer) parserInput.getTempParam(TemplateTag.TEMPLATE_INCLUSION);
   boolean disallowInclusion = (inclusion != null && inclusion > 0);
   if (disallowInclusion) {
     return "";
   }
   String url = "";
   try {
     url =
         LinkUtil.buildEditLinkUrl(
             parserInput.getContext(),
             parserInput.getVirtualWiki(),
             parserInput.getTopicName(),
             null,
             section);
   } catch (DataAccessException e) {
     logger.error(
         "Failure while building link for topic "
             + parserInput.getVirtualWiki()
             + " / "
             + parserInput.getTopicName(),
         e);
   }
   // arguments are edit link URL and edit label text
   Object[] args = new Object[2];
   args[0] = url;
   args[1] = Utilities.formatMessage("common.sectionedit", parserInput.getLocale());
   try {
     return WikiUtil.formatFromTemplate(TEMPLATE_HEADER_EDIT_LINK, args);
   } catch (IOException e) {
     throw new ParserException(e);
   }
 }
예제 #2
0
 @Override
 public boolean isTemplateTopic() {
   String topicName = fParserInput.getTopicName();
   int index = topicName.indexOf(':');
   if (index > 0) {
     String namespace = topicName.substring(0, index);
     if (isTemplateNamespace(namespace)) {
       return true;
     }
   }
   return false;
 }
예제 #3
0
  @Override
  public void buildEditLinkUrl(int section) {
    if (fParserInput.getAllowSectionEdit()) {
      TagNode divTagNode = new TagNode("div");
      divTagNode.addAttribute("style", "font-size:90%;float:right;margin-left:5px;", false);
      divTagNode.addChild(new ContentToken("["));
      append(divTagNode);

      String url = "";
      try {
        // Use correct section number.
        // Bliki starts with offset 0 so it must be "section+1"
        url =
            LinkUtil.buildEditLinkUrl(
                fParserInput.getContext(),
                fParserInput.getVirtualWiki(),
                fParserInput.getTopicName(),
                null,
                section + 1);
      } catch (Exception e) {
        logger.error(
            "Failure while building link for topic "
                + fParserInput.getVirtualWiki()
                + " / "
                + fParserInput.getTopicName(),
            e);
      }
      TagNode aTagNode = new TagNode("a");
      aTagNode.addAttribute("href", url, false);
      aTagNode.addChild(
          new ContentToken(
              Utilities.formatMessage("common.sectionedit", fParserInput.getLocale())));
      divTagNode.addChild(aTagNode);
      divTagNode.addChild(new ContentToken("]"));
    }
  }