1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.internal.renderer.xhtml.link; |
21 |
|
|
22 |
|
import java.util.Map; |
23 |
|
import java.util.Properties; |
24 |
|
|
25 |
|
import javax.inject.Inject; |
26 |
|
import javax.inject.Named; |
27 |
|
|
28 |
|
import org.xwiki.component.annotation.Component; |
29 |
|
import org.xwiki.component.annotation.InstantiationStrategy; |
30 |
|
import org.xwiki.component.descriptor.ComponentInstantiationStrategy; |
31 |
|
import org.xwiki.rendering.configuration.RenderingConfiguration; |
32 |
|
import org.xwiki.rendering.listener.reference.InterWikiResourceReference; |
33 |
|
import org.xwiki.rendering.listener.reference.ResourceReference; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
@version |
39 |
|
@since |
40 |
|
|
41 |
|
@Component |
42 |
|
@Named("interwiki") |
43 |
|
@InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP) |
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.4 |
|
44 |
|
public class InterWikiXHTMLLinkTypeRenderer extends AbstractXHTMLLinkTypeRenderer |
45 |
|
{ |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
@Inject |
50 |
|
private RenderingConfiguration renderingConfiguration; |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
52 |
4
|
@Override... |
53 |
|
protected void beginLinkExtraAttributes(ResourceReference reference, Map<String, String> spanAttributes, |
54 |
|
Map<String, String> anchorAttributes) |
55 |
|
{ |
56 |
|
|
57 |
4
|
String interWikiAlias = reference.getParameter(InterWikiResourceReference.INTERWIKI_ALIAS); |
58 |
4
|
Properties definitions = this.renderingConfiguration.getInterWikiDefinitions(); |
59 |
4
|
if (definitions.containsKey(interWikiAlias)) { |
60 |
1
|
anchorAttributes.put(XHTMLLinkRenderer.HREF, |
61 |
|
definitions.getProperty(interWikiAlias) + reference.getReference()); |
62 |
|
} else { |
63 |
3
|
anchorAttributes.put(XHTMLLinkRenderer.HREF, reference.getReference()); |
64 |
|
} |
65 |
|
} |
66 |
|
} |