1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.wysiwyg.server.internal; |
21 |
|
|
22 |
|
import javax.inject.Inject; |
23 |
|
import javax.inject.Singleton; |
24 |
|
|
25 |
|
import org.apache.commons.lang3.StringUtils; |
26 |
|
import org.xwiki.bridge.DocumentAccessBridge; |
27 |
|
import org.xwiki.component.annotation.Component; |
28 |
|
import org.xwiki.context.Execution; |
29 |
|
import org.xwiki.model.EntityType; |
30 |
|
import org.xwiki.model.ModelContext; |
31 |
|
import org.xwiki.model.reference.DocumentReference; |
32 |
|
import org.xwiki.model.reference.LocalDocumentReference; |
33 |
|
import org.xwiki.model.reference.WikiReference; |
34 |
|
import org.xwiki.wysiwyg.server.WysiwygEditorConfiguration; |
35 |
|
|
36 |
|
import com.xpn.xwiki.XWiki; |
37 |
|
import com.xpn.xwiki.XWikiContext; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
@version |
43 |
|
|
44 |
|
@Component |
45 |
|
@Singleton |
|
|
| 98.4% |
Uncovered Elements: 1 (62) |
Complexity: 24 |
Complexity Density: 0.77 |
|
46 |
|
public class DefaultWysiwygEditorConfiguration implements WysiwygEditorConfiguration |
47 |
|
{ |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
private static final Integer ONE = new Integer(1); |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
private static final LocalDocumentReference CONFIG_CLASS_REFERENCE = new LocalDocumentReference(XWiki.SYSTEM_SPACE, |
57 |
|
"WysiwygEditorConfigClass"); |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
private static final LocalDocumentReference CONFIG_LOCAL_DOCUMENT_REFERENCE = new LocalDocumentReference( |
63 |
|
XWiki.SYSTEM_SPACE, "WysiwygEditorConfig"); |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
@Inject |
69 |
|
private DocumentAccessBridge documentAccessBridge; |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
@Inject |
75 |
|
private ModelContext modelContext; |
76 |
|
|
77 |
|
|
78 |
|
@Inject |
79 |
|
private Execution execution; |
80 |
|
|
81 |
|
|
82 |
|
@param |
83 |
|
@return@link |
84 |
|
@link |
85 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
86 |
327 |
private Object getProperty(String propertyName)... |
87 |
|
{ |
88 |
327 |
String currentWiki = modelContext.getCurrentEntityReference().extractReference(EntityType.WIKI).getName(); |
89 |
327 |
Object value = getProperty(propertyName, currentWiki); |
90 |
327 |
if (value == null) { |
91 |
49 |
String mainWiki = getMainWiki(); |
92 |
49 |
if (!StringUtils.equals(currentWiki, mainWiki)) { |
93 |
1 |
value = getProperty(propertyName, mainWiki); |
94 |
|
} |
95 |
|
} |
96 |
327 |
return value; |
97 |
|
} |
98 |
|
|
99 |
|
|
100 |
|
@param |
101 |
|
@param |
102 |
|
@return@link |
103 |
|
@link |
104 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
105 |
328 |
private Object getProperty(String propertyName, String wiki)... |
106 |
|
{ |
107 |
328 |
WikiReference wikiRef = new WikiReference(wiki); |
108 |
328 |
DocumentReference configDocumentReference = new DocumentReference(CONFIG_LOCAL_DOCUMENT_REFERENCE, wikiRef); |
109 |
328 |
DocumentReference configClassReference = new DocumentReference(CONFIG_CLASS_REFERENCE, wikiRef); |
110 |
328 |
return documentAccessBridge.getProperty(configDocumentReference, configClassReference, propertyName); |
111 |
|
} |
112 |
|
|
113 |
|
|
114 |
|
@return |
115 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
116 |
49 |
private String getMainWiki()... |
117 |
|
{ |
118 |
49 |
return ((XWikiContext) execution.getContext().getProperty("xwikicontext")).getMainXWiki(); |
119 |
|
} |
120 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
121 |
24 |
@Override... |
122 |
|
public Boolean areExternalImagesAllowed() |
123 |
|
{ |
124 |
24 |
Integer externalImages = (Integer) getProperty("externalImages"); |
125 |
24 |
return externalImages == null ? null : ONE.equals(externalImages); |
126 |
|
} |
127 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
128 |
24 |
@Override... |
129 |
|
public String getColorPalette() |
130 |
|
{ |
131 |
24 |
return (String) getProperty("colorPalette"); |
132 |
|
} |
133 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
134 |
24 |
@Override... |
135 |
|
public Integer getColorsPerRow() |
136 |
|
{ |
137 |
24 |
return (Integer) getProperty("colorsPerRow"); |
138 |
|
} |
139 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
140 |
24 |
@Override... |
141 |
|
public String getFontNames() |
142 |
|
{ |
143 |
24 |
return (String) getProperty("fontNames"); |
144 |
|
} |
145 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
146 |
24 |
@Override... |
147 |
|
public String getFontSizes() |
148 |
|
{ |
149 |
24 |
return (String) getProperty("fontSizes"); |
150 |
|
} |
151 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
152 |
24 |
@Override... |
153 |
|
public String getMenuBar() |
154 |
|
{ |
155 |
24 |
return (String) getProperty("menuBar"); |
156 |
|
} |
157 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
158 |
25 |
@Override... |
159 |
|
public String getPlugins() |
160 |
|
{ |
161 |
25 |
return (String) getProperty("plugins"); |
162 |
|
} |
163 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
164 |
24 |
@Override... |
165 |
|
public String getStyleNames() |
166 |
|
{ |
167 |
24 |
return (String) getProperty("styleNames"); |
168 |
|
} |
169 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
170 |
24 |
@Override... |
171 |
|
public String getToolBar() |
172 |
|
{ |
173 |
24 |
return (String) getProperty("toolBar"); |
174 |
|
} |
175 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
176 |
24 |
@Override... |
177 |
|
public Boolean isAttachmentSelectionLimited() |
178 |
|
{ |
179 |
24 |
Integer attachmentSelectionLimited = (Integer) getProperty("attachmentSelectionLimited"); |
180 |
24 |
return attachmentSelectionLimited == null ? null : ONE.equals(attachmentSelectionLimited); |
181 |
|
} |
182 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
183 |
24 |
@Override... |
184 |
|
public Boolean isImageSelectionLimited() |
185 |
|
{ |
186 |
24 |
Integer imageSelectionLimited = (Integer) getProperty("imageSelectionLimited"); |
187 |
24 |
return imageSelectionLimited == null ? null : ONE.equals(imageSelectionLimited); |
188 |
|
} |
189 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
190 |
14 |
@Override... |
191 |
|
public Boolean isSourceEditorEnabled() |
192 |
|
{ |
193 |
14 |
Integer sourceEditorEnabled = (Integer) getProperty("sourceEditorEnabled"); |
194 |
14 |
return sourceEditorEnabled == null ? null : ONE.equals(sourceEditorEnabled); |
195 |
|
} |
196 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
197 |
24 |
@Override... |
198 |
|
public Integer getHistorySize() |
199 |
|
{ |
200 |
24 |
return (Integer) getProperty("historySize"); |
201 |
|
} |
202 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
203 |
24 |
@Override... |
204 |
|
public Boolean isPasteContentCleanedAutomatically() |
205 |
|
{ |
206 |
24 |
Integer cleanPaste = (Integer) getProperty("cleanPaste"); |
207 |
24 |
return cleanPaste == null ? null : ONE.equals(cleanPaste); |
208 |
|
} |
209 |
|
} |