Wiki source code of Administration
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{velocity}} | ||
2 | #set ($discard = $xwiki.jsx.use('Administration')) | ||
3 | #set ($discard = $xwiki.ssx.use('Administration')) | ||
4 | #set ($configDoc = $xwiki.getDocument('Configuration')) | ||
5 | #set ($configClass = $xwiki.getDocument('ConfigurationClass').xWikiClass) | ||
6 | #set ($configObject = $configDoc.getObject($configClass.name)) | ||
7 | ## Initialize with the default engines. | ||
8 | #set ($enginesMap = { | ||
9 | 'image' : [ | ||
10 | 'com.octo.captcha.engine.image.gimpy.DefaultGimpyEngine', | ||
11 | 'com.octo.captcha.engine.image.gimpy.SimpleListImageCaptchaEngine', | ||
12 | 'com.octo.captcha.engine.image.gimpy.NonLinearTextGimpyEngine', | ||
13 | 'com.octo.captcha.engine.image.gimpy.HotmailEngine', | ||
14 | 'com.octo.captcha.engine.image.gimpy.DeformedBaffleListGimpyEngine', | ||
15 | 'com.octo.captcha.engine.image.gimpy.BaffleListGimpyEngine', | ||
16 | 'com.octo.captcha.engine.image.gimpy.HotmailEngine2008' | ||
17 | ], | ||
18 | 'sound' : [ | ||
19 | 'com.octo.captcha.engine.sound.speller.SpellerSoundCaptchaEngine', | ||
20 | 'com.octo.captcha.engine.sound.gimpy.SimpleListSoundCaptchaEngine' | ||
21 | ], | ||
22 | 'text' : [ | ||
23 | 'org.xwiki.captcha.internal.SimpleMathCaptchaEngine' | ||
24 | ] | ||
25 | }) | ||
26 | ## Add contributed engines, through UIXs. | ||
27 | #set ($engineUIXs = $services.uix.getExtensions('org.xwiki.captcha.jcaptcha.engine')) | ||
28 | #foreach ($engineUIX in $engineUIXs) | ||
29 | #set ($type = $engineUIX.parameters.type) | ||
30 | #set ($engine = $engineUIX.parameters.engine) | ||
31 | #set ($registeredEngines = $enginesMap.get($type)) | ||
32 | #if ($registeredEngines && !$registeredEngines.contains($engine)) | ||
33 | #set ($discard = $registeredEngines.add($engine)) | ||
34 | #end | ||
35 | #end | ||
36 | {{html clean="false"}} | ||
37 | <form action="$configDoc.getURL('save')" class='xform jcaptcha'> | ||
38 | <dl> | ||
39 | <dt> | ||
40 | <label for='XWiki.Captcha.JCaptcha.ConfigurationClass_0_type'>$configClass.type.translatedPrettyName</label> | ||
41 | <span class='xHint'>$configClass.type.hint</span> | ||
42 | </dt> | ||
43 | <dd>{{/html}} | ||
44 | |||
45 | $configDoc.display('type', 'edit') | ||
46 | |||
47 | {{html clean="false"}}</dd> | ||
48 | |||
49 | <dt> | ||
50 | <label>$configClass.engine.translatedPrettyName</label> | ||
51 | <span class='xHint'>$configClass.engine.hint</span> | ||
52 | </dt> | ||
53 | <dd> | ||
54 | #set ($currentType = "$!configObject.getValue('type')") | ||
55 | #set ($currentEngine = "$!configObject.getValue('engine')") | ||
56 | #set ($isCustom = true) | ||
57 | #foreach ($type in $enginesMap.keySet()) | ||
58 | #foreach ($engine in $enginesMap.get($type)) | ||
59 | #set ($maybeChecked = '') | ||
60 | #if ($currentEngine == $engine) | ||
61 | #set ($maybeChecked = 'checked="checked"') | ||
62 | #if ($type == $currentType) | ||
63 | #set ($isCustom = false) | ||
64 | #end | ||
65 | #end | ||
66 | <div class="engine $type #if ($currentType != $type)hidden#end radio"> | ||
67 | <label> | ||
68 | <input type="radio" name="XWiki.Captcha.JCaptcha.ConfigurationClass_0_engine" value="$engine" $maybeChecked /> | ||
69 | $escapetool.xml($services.localization.render("captcha.jcaptcha.engine.$engine")) | ||
70 | </label> | ||
71 | </div> | ||
72 | #end | ||
73 | #end | ||
74 | <div class="jcaptcha radio"> | ||
75 | <div class="custom"> | ||
76 | <label> | ||
77 | ## Note: Using the same input name for the "custom" option | ||
78 | <input type="radio" name="XWiki.Captcha.JCaptcha.ConfigurationClass_0_engine" class="customActivator" #if ($isCustom)checked="checked"#end /> | ||
79 | $escapetool.xml($services.localization.render('captcha.jcaptcha.engine.custom')) | ||
80 | </label> | ||
81 | <input type="text" class="customEngine" #if ($isCustom)checked="checked" value="$currentEngine"#end /> | ||
82 | </div> | ||
83 | </div> | ||
84 | </dd> | ||
85 | </dl> | ||
86 | <div> | ||
87 | <input type="hidden" name="xredirect" value="$xwiki.requestURL" /> | ||
88 | <input type="hidden" name="form_token" value="$services.csrf.getToken()" /> | ||
89 | <input type="submit" class="button" value="$escapetool.xml($services.localization.render('admin.save'))" /> | ||
90 | </div> | ||
91 | </form> | ||
92 | {{/html}} | ||
93 | {{/velocity}} |