Examples of PageElementTemplate


Examples of org.wikipediacleaner.api.data.PageElementTemplate

        int currentPos = end;
        while ((currentPos < maxSize) && (contents.charAt(currentPos) == ' ')) {
          currentPos++;
        }
        if ((currentPos < maxSize) && (contents.charAt(currentPos) == '{')) {
          PageElementTemplate nextTemplate = pageAnalysis.isInTemplate(currentPos);
          if (nextTemplate != null) {
            for (String templateAfter : templatesAfter) {
              if (Page.areSameTitle(templateAfter, nextTemplate.getTemplateName())) {
                styleType = ConfigurationValueStyle.HELP_REQUESTED;
                end = nextTemplate.getEndIndex();
              }
            }
          }
        }
      }
View Full Code Here

Examples of org.wikipediacleaner.api.data.PageElementTemplate

              shouldCount = false;
            }
          }
          if (shouldCount) {
            // Check for template
            PageElementTemplate template = analysis.isInTemplate(currentIndex);
            if (template != null) {
              for (int numParam = 0; numParam < template.getParameterCount(); numParam++) {
                if (template.getParameterValueStartIndex(numParam) == currentIndex) {
                  shouldCount = false;
                }
              }
            }
          }
View Full Code Here

Examples of org.wikipediacleaner.api.data.PageElementTemplate

      return createDefaultPopupExternalLink(pageAnalysis, position, externalLink);
    }

    // Menu for template
    if (element instanceof PageElementTemplate) {
      PageElementTemplate template = (PageElementTemplate) element;
      return createDefaultPopupTemplate(pageAnalysis, position, template);
    }

    // Menu for category
    if (element instanceof PageElementCategory) {
View Full Code Here

Examples of org.wikipediacleaner.api.data.PageElementTemplate

    if (referencesTemplates != null) {
      List<PageElementTemplate> allTemplates = analysis.getTemplates();
      int templateNum = allTemplates.size();
      while (templateNum > 0) {
        templateNum--;
        PageElementTemplate template = allTemplates.get(templateNum);
        for (String referencesTemplate : referencesTemplates) {
          if (Page.areSameTitle(template.getTemplateName(), referencesTemplate)) {
            return false;
          }
        }
      }
    }
View Full Code Here

Examples of org.wikipediacleaner.api.data.PageElementTemplate

          addHelpNeededTemplates(analysis, errorResult, isbn);
          addHelpNeededComment(analysis, errorResult, isbn);
          String value = isbn.getISBN();
          addSearchEngines(analysis, errorResult, value);
          if (isbn.isTemplateParameter()) {
            PageElementTemplate template = analysis.isInTemplate(isbn.getBeginIndex());
            addSearchEngines(analysis, errorResult, template);
          }
          if (length == 8) {
            addSearchEnginesISSN(analysis, errorResult, isbn.getISBN());
          } else if (length == 9) {
View Full Code Here

Examples of org.wikipediacleaner.api.data.PageElementTemplate

        if (!value.equals(isbn.getISBNNotTrimmed())) {
          errorResult.addReplacement(isbnValues.get(0));
        }
      } else if (isbnValues.size() > 0) {
        if (isbn.isTemplateParameter()) {
          PageElementTemplate template = analysis.isInTemplate(isbn.getBeginIndex());
          if (template != null) {
            Parameter param = template.getParameterAtIndex(isbn.getBeginIndex());
            if ((param != null) &&
                (param.getName() != null) &&
                (param.getName().trim().length() > 0)) {
              String name = param.getName().trim();
              int index = name.length();
              while ((index > 0) &&
                     (Character.isDigit(name.charAt(index - 1)))) {
                index--;
              }
              int currentNum = 1;
              if (index < name.length()) {
                currentNum = Integer.valueOf(name.substring(index));
                name = name.substring(0, index);
              }
              currentNum++;
              StringBuilder buffer = new StringBuilder();
              buffer.append(isbnValues.get(0));
              for (int isbnNum = 1; isbnNum < isbnValues.size(); isbnNum++) {
                while (template.getParameterIndex(name + Integer.toString(currentNum)) >= 0) {
                  currentNum++;
                }
                buffer.append(" |");
                buffer.append(name);
                buffer.append(Integer.toString(currentNum));
View Full Code Here

Examples of org.wikipediacleaner.api.data.PageElementTemplate

        (TemplateMatcher) attrTemplateMatcher : null;
    MWPaneDisambiguationMenuCreator menu = new MWPaneDisambiguationMenuCreator();

    // Manage TemplateMatcher
    if (attrPageElement instanceof PageElementTemplate) {
      PageElementTemplate template = (PageElementTemplate) attrPageElement;

      String templateTitle = getWikipedia().getWikiConfiguration().getPageTitle(
          Namespace.TEMPLATE,
          template.getTemplateName());
      JPopupMenu popup = menu.createPopupMenu(templateTitle);
      if ((matcher != null) &&
          (matcher.getExplanation() != null) &&
          (matcher.getExplanation().length() > 0)) {
        menu.addDisabledText(popup, "→ " + matcher.getExplanation() + " ←");
View Full Code Here

Examples of org.wikipediacleaner.api.data.PageElementTemplate

          (analysis.getSurroundingTag(PageElementTag.TAG_WIKI_SYNTAXHIGHLIGHT, currentIndex) != null) ||
          (analysis.isInTag(currentIndex) != null)) {
        shouldCount = false;
      }
      if (shouldCount) {
        PageElementTemplate template = analysis.isInTemplate(currentIndex - 1);
        if ((template != null) &&
            (template.getEndIndex() == currentIndex) &&
            (contents.startsWith("[[", template.getBeginIndex() - 2))) {
          shouldCount = false;
        }
      }
      if (shouldCount) {
        PageElementExternalLink link = analysis.isInExternalLink(currentIndex);
View Full Code Here

Examples of org.wikipediacleaner.api.data.PageElementTemplate

            creator, modifiers, stats);
      }

      // If talk page has a template linking to the "To do" sub-page,
      // the warning must be on the "To do" sub-page
      PageElementTemplate templateTodoLink = getExistingTemplateTodoLink(talkPage, talkPage.getContents());
      if (templateTodoLink != null) {
        return manageWarningOnTodoSubpage(
            pageAnalysis, pageRevId, todoSubpage, talkPage,
            creator, modifiers, stats);
      }
View Full Code Here

Examples of org.wikipediacleaner.api.data.PageElementTemplate

    String contents = todoSubpage.getContents();
    if (contents == null) {
      contents = "";
    }
    PageAnalysis analysis = todoSubpage.getAnalysis(contents, true);
    PageElementTemplate templateWarning = getFirstWarningTemplate(analysis);

    // If warning is missing, add it
    if (templateWarning == null) {
      if (!createWarning) {
        return false;
      }
      setText(getMessageUpdateWarning(todoSubpage.getTitle()));
      StringBuilder tmp = new StringBuilder(contents);
      if ((tmp.length() > 0) && (tmp.charAt(tmp.length() - 1) != '\n')) {
        tmp.append('\n');
      }
      tmp.append("* ");
      addWarning(tmp, pageRevId, elements);
      tmp.append('\n');
      updatePage(
          todoSubpage, tmp.toString(),
          wiki.formatComment(
              getWarningComment(elements),
              automaticEdit),
          false);

      // Inform creator and modifiers of the page
      informContributors(analysis, elements, creator, modifiers);

      return true;
    }

    // Check if modifications are needed
    if (isModified(elements, templateWarning)) {
      StringBuilder tmp = new StringBuilder();
      int index = templateWarning.getBeginIndex();
      while ((index > 0) && (contents.charAt(index) != '\n')) {
        index--;
      }
      if (index > 0) {
        tmp.append(contents.substring(0, index));
        tmp.append('\n');
      }
      tmp.append("* ");
      addWarning(tmp, pageRevId, elements);
      tmp.append('\n');
      index = templateWarning.getEndIndex();
      while ((index < contents.length()) && (contents.charAt(index) != '\n')) {
        index++;
      }
      index++;
      if (index < contents.length()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.