diff --git a/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml b/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml index eade57c3b882..818df538f282 100644 --- a/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml +++ b/xwiki-platform-core/xwiki-platform-appwithinminutes/xwiki-platform-appwithinminutes-ui/src/main/resources/AppWithinMinutes/ClassEditSheet.xml @@ -256,9 +256,13 @@ xcontext.put('propertyCustomDisplayer', new PropertyCustomDisplayer(xcontext)) #set ($class = 'wikicreatelink') #set ($action = 'create') #set ($discard = $params.put('parent', $doc.fullName)) + #set ($title = $escapetool.xml($services.localization.render('core.create.inline.label',[$reference.name]))) #end - <span class="$class"><a href="$escapetool.xml($xwiki.getURL($reference, $action, $escapetool.url($params)))" - >$escapetool.xml($reference.name)</a></span>## + <span class="$class" #if(!$xwiki.exists($reference))title="$title"#end> + <a href="$escapetool.xml($xwiki.getURL($reference, $action, $escapetool.url($params)))"> + $escapetool.xml($reference.name) + </a> + </span>## #end #** diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties b/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties index a38f8bd5985b..11dee7026bcc 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/resources/ApplicationResources.properties @@ -2086,6 +2086,14 @@ rendering.async.context.entry.user=User rendering.async.error.failed=Failed to execute asynchronous content +#################### +# XWiki Syntax +#################### +rendering.xwiki.wantedLink.default.label=Create reference: {0} +rendering.xwiki.wantedLink.page.label=Create page: {0} +rendering.xwiki.wantedLink.space.label=Create space: {0} +rendering.xwiki.wantedLink.attachment.label=Create attachment: {0} + #################### # Plugins #################### diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/pom.xml b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/pom.xml index bd67193e8a7e..85c8c2dcc2ab 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/pom.xml +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/pom.xml @@ -52,6 +52,11 @@ xwiki-platform-template-api ${project.version} + + org.xwiki.platform + xwiki-platform-localization-api + ${project.version} + org.xwiki.platform xwiki-platform-bridge diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiAttachmentWantedLinkTitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiAttachmentWantedLinkTitleGenerator.java new file mode 100644 index 000000000000..126c73eea034 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiAttachmentWantedLinkTitleGenerator.java @@ -0,0 +1,77 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.rendering.internal.renderer; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.xwiki.component.annotation.Component; +import org.xwiki.localization.ContextualLocalizationManager; +import org.xwiki.model.reference.AttachmentReferenceResolver; +import org.xwiki.model.reference.PageAttachmentReferenceResolver; +import org.xwiki.rendering.listener.reference.ResourceReference; +import org.xwiki.rendering.listener.reference.ResourceType; +import org.xwiki.rendering.renderer.reference.link.WantedLinkTitleGenerator; + +/** + * Generates a wanted link title for an attachment resource reference. + * This implementation uses translations to generate localized titles. + * + * @version $Id$ + * @since 16.3.0RC1 + */ +@Component(hints = {"pageAttach", "attach"}) +@Singleton +public class XWikiAttachmentWantedLinkTitleGenerator implements WantedLinkTitleGenerator +{ + @Inject + private ContextualLocalizationManager contextLocalization; + + /** + * Used to extract the attachment name part in an attachment reference. + */ + @Inject + @Named("current") + private AttachmentReferenceResolver currentAttachmentReferenceResolver; + + /** + * Used to extract the page attachment name part in a page attachment reference. + */ + @Inject + @Named("current") + private PageAttachmentReferenceResolver currentPageAttachmentReferenceResolver; + + @Override + public String generateWantedLinkTitle(ResourceReference reference) + { + String attachmentTitleTranslationKey = "rendering.xwiki.wantedLink.attachment.label"; + String attachmentName; + if (reference.isTyped() && reference.getType() == ResourceType.ATTACHMENT) { + attachmentName = this.currentAttachmentReferenceResolver.resolve(reference.getReference()).getName(); + } else if (reference.isTyped() && reference.getType() == ResourceType.PAGE_ATTACHMENT) { + attachmentName = this.currentPageAttachmentReferenceResolver.resolve(reference.getReference()).getName(); + } else { + attachmentName = reference.getReference(); + } + return this.contextLocalization.getTranslationPlain(attachmentTitleTranslationKey, + attachmentName); + } +} diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDefaultWantedLinkTitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDefaultWantedLinkTitleGenerator.java new file mode 100644 index 000000000000..f03ebf7d5537 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDefaultWantedLinkTitleGenerator.java @@ -0,0 +1,52 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.rendering.internal.renderer; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.xwiki.component.annotation.Component; +import org.xwiki.localization.ContextualLocalizationManager; +import org.xwiki.rendering.listener.reference.ResourceReference; +import org.xwiki.rendering.renderer.reference.link.WantedLinkTitleGenerator; + +/** + * Fallback to generate a wanted link title for a resource which type doesn't have a specific implementation yet. + * This implementation uses translations to generate localized titles. + * This implementation uses the reference itself, it should be overridden by type specific implementations using a + * human-readable name instead. E.g. {@link XWikiDocumentWantedLinkTitleGenerator} + * + * @version $Id$ + * @since 16.3.0RC1 + */ +@Component +@Singleton +public class XWikiDefaultWantedLinkTitleGenerator implements WantedLinkTitleGenerator +{ + @Inject + private ContextualLocalizationManager contextLocalization; + + @Override + public String generateWantedLinkTitle(ResourceReference reference) + { + return this.contextLocalization.getTranslationPlain("rendering.xwiki.wantedLink.default.label", + reference.getReference()); + } +} diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentWantedLinkTitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentWantedLinkTitleGenerator.java new file mode 100644 index 000000000000..e1bb4b1d7c67 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiDocumentWantedLinkTitleGenerator.java @@ -0,0 +1,77 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.rendering.internal.renderer; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.xwiki.component.annotation.Component; +import org.xwiki.model.reference.DocumentReferenceResolver; +import org.xwiki.model.reference.PageReferenceResolver; +import org.xwiki.rendering.listener.reference.ResourceReference; +import org.xwiki.localization.ContextualLocalizationManager; +import org.xwiki.rendering.listener.reference.ResourceType; +import org.xwiki.rendering.renderer.reference.link.WantedLinkTitleGenerator; + +/** + * Generates a wanted link title for a document resource reference. + * This implementation uses translations to generate localized titles. + * + * @version $Id$ + * @since 16.3.0RC1 + */ +@Component(hints = {"doc", "page"}) +@Singleton +public class XWikiDocumentWantedLinkTitleGenerator implements WantedLinkTitleGenerator +{ + @Inject + private ContextualLocalizationManager contextLocalization; + + /** + * Used to extract the document name part in a document reference. + */ + @Inject + @Named("current") + private DocumentReferenceResolver currentDocumentReferenceResolver; + + /** + * Used to extract the page name part in a page reference. + */ + @Inject + @Named("current") + private PageReferenceResolver currentPageReferenceResolver; + + @Override + public String generateWantedLinkTitle(ResourceReference reference) + { + String documentTitleTranslationKey = "rendering.xwiki.wantedLink.document.label"; + String documentName; + if (reference.isTyped() && reference.getType() == ResourceType.DOCUMENT) { + documentName = this.currentDocumentReferenceResolver.resolve(reference.getReference()).getName(); + } else if (reference.isTyped() && reference.getType() == ResourceType.PAGE) { + documentName = this.currentPageReferenceResolver.resolve(reference.getReference()).getName(); + } else { + documentName = reference.getReference(); + } + return this.contextLocalization.getTranslationPlain(documentTitleTranslationKey, + documentName); + } +} diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiSpaceWantedLinkTitleGenerator.java b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiSpaceWantedLinkTitleGenerator.java new file mode 100644 index 000000000000..9ff4da393783 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/internal/renderer/XWikiSpaceWantedLinkTitleGenerator.java @@ -0,0 +1,63 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.rendering.internal.renderer; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.xwiki.component.annotation.Component; +import org.xwiki.localization.ContextualLocalizationManager; +import org.xwiki.model.reference.SpaceReference; +import org.xwiki.model.reference.SpaceReferenceResolver; +import org.xwiki.rendering.listener.reference.ResourceReference; +import org.xwiki.rendering.renderer.reference.link.WantedLinkTitleGenerator; + +/** + * Generates a wanted link title for a space resource reference. + * This implementation uses translations to generate localized titles. + * + * @version $Id$ + * @since 16.3.0RC1 + */ +@Component +@Named("space") +@Singleton +public class XWikiSpaceWantedLinkTitleGenerator implements WantedLinkTitleGenerator +{ + @Inject + private ContextualLocalizationManager contextLocalization; + + /** + * Used to extract the space name part in a space reference. + */ + @Inject + @Named("current") + private SpaceReferenceResolver currentSpaceReferenceResolver; + + @Override + public String generateWantedLinkTitle(ResourceReference reference) + { + SpaceReference spaceReference = + this.currentSpaceReferenceResolver.resolve(reference.getReference()); + return this.contextLocalization.getTranslationPlain("rendering.xwiki.wantedLink.space.label", + spaceReference.getName()); + } +} diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt index 235f63519a7b..cb6de81bda6f 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/resources/META-INF/components.txt @@ -1,6 +1,10 @@ 500:org.xwiki.rendering.internal.renderer.XWikiAttachmentURILabelGenerator 500:org.xwiki.rendering.internal.renderer.XWikiLinkLabelGenerator 500:org.xwiki.rendering.internal.renderer.XWikiPageAttachmentURILabelGenerator +480:org.xwiki.rendering.internal.renderer.XWikiDefaultWantedLinkTitleGenerator +500:org.xwiki.rendering.internal.renderer.XWikiDocumentWantedLinkTitleGenerator +500:org.xwiki.rendering.internal.renderer.XWikiSpaceWantedLinkTitleGenerator +500:org.xwiki.rendering.internal.renderer.XWikiAttachmentWantedLinkTitleGenerator 500:org.xwiki.rendering.internal.util.XWikiErrorBlockGenerator 500:org.xwiki.rendering.internal.wiki.XWikiWikiModel 500:org.xwiki.rendering.internal.macro.XWikiHTMLRawBlockFilter diff --git a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm index c88b398773ea..52ce5a341aa2 100644 --- a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm +++ b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-templates/src/main/resources/templates/displayer_page.vm @@ -57,7 +57,12 @@ #else #set ($title = $escapetool.xml($pageDoc.plainTitle)) #if ($pageDoc.isNew()) - $title + + + $title + + #else $title #end