コード例 #1
0
ファイル: Package.java プロジェクト: neototo/xwiki-platform
  public boolean add(String docFullName, int DefaultAction, XWikiContext context)
      throws XWikiException {
    XWikiDocument doc = context.getWiki().getDocument(docFullName, context);
    add(doc, DefaultAction, context);
    List<String> languages = doc.getTranslationList(context);
    for (String language : languages) {
      if (!((language == null)
          || (language.equals(""))
          || (language.equals(doc.getDefaultLanguage())))) {
        add(doc.getTranslatedDocument(language, context), DefaultAction, context);
      }
    }

    return true;
  }
コード例 #2
0
 /**
  * Gets the translated version of a document, in the specified language. If the translation does
  * not exist, a new document translation is created. If the requested language does not correspond
  * to a translation (is not defined or is the same as the main document), then the main document
  * is returned.
  *
  * @param doc the main (default, untranslated) document to translate
  * @param language the requested document language
  * @param context the current request context
  * @return the translated document, or the original untranslated document if the requested
  *     language is not a translation
  * @throws XWikiException if the translation cannot be retrieved from the database
  */
 protected XWikiDocument getTranslatedDocument(
     XWikiDocument doc, String language, XWikiContext context) throws XWikiException {
   XWikiDocument tdoc;
   if (StringUtils.isBlank(language)
       || language.equals("default")
       || language.equals(doc.getDefaultLanguage())) {
     tdoc = doc;
   } else {
     tdoc = doc.getTranslatedDocument(language, context);
     if (tdoc == doc) {
       tdoc = new XWikiDocument(doc.getDocumentReference());
       tdoc.setLanguage(language);
       tdoc.setStore(doc.getStore());
     }
     tdoc.setTranslation(1);
   }
   return tdoc;
 }