Wiki source code of AdminFieldsDisplaySheet
Last modified by Julien Fleury on 2020/12/12 16:55
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{velocity output="false"}} | ||
2 | #macro (__displayXProperty $prop) | ||
3 | #set ($title = $services.localization.render($prop.name)) | ||
4 | #if ($title == $prop.name) | ||
5 | #set ($title = $prop.prettyName) | ||
6 | #end | ||
7 | #if ($services.localization.get("${obj.xWikiClass.name}_${prop.name}")) | ||
8 | #set ($title = $services.localization.render("${obj.xWikiClass.name}_${prop.name}")) | ||
9 | #end | ||
10 | #set ($hint = $services.localization.render("${obj.xWikiClass.name}_${prop.name}.hint")) | ||
11 | #if ($hint == "${obj.xWikiClass.name}_${prop.name}.hint") | ||
12 | #set($hint = $NULL) | ||
13 | #end | ||
14 | <dt> | ||
15 | #set ($out = $configDoc.display($prop.name, 'edit', $obj).replaceAll('(^..html.*?}})|(../html..$)', '')) | ||
16 | #set ($newId = "${configClassName}_${obj.number}_${prop.name}") | ||
17 | <label#if ($out.matches("(?s).*id=['""]${newId}['""].*")) for="${newId}"#end class="$prop.name">## | ||
18 | #if ($out.indexOf('type=''checkbox''') != -1 && $out.indexOf('class="xwiki-form-listclass"') == -1) | ||
19 | $out ## | ||
20 | #set ($out = '') | ||
21 | #end | ||
22 | $title | ||
23 | #if ($prop.name == 'skin') | ||
24 | #set ($skin = $xwiki.skin) | ||
25 | <span class="buttonwrapper"><a href="$xwiki.getURL($skin, 'edit')"#if ($skin.indexOf('.') < 0) class="hidden"#end>$services.localization.render('admin.customize')</a></span> | ||
26 | #end | ||
27 | #if ($prop.name == 'colorTheme') | ||
28 | #if ($editor == 'globaladmin') | ||
29 | #set ($colorThemeName = $xwiki.getXWikiPreference('colorTheme')) | ||
30 | #else | ||
31 | #set ($colorThemeName = $xwiki.getSpacePreference('colorTheme')) | ||
32 | #set ($wikiColorTheme = $xwiki.getDocument($xwiki.getXWikiPreference('colorTheme'))) | ||
33 | #if (!$wikiColorTheme.isNew()) | ||
34 | #set ($colorThemeHint = $services.localization.render('admin.colortheme.wikiSetting', ["<a href='$wikiColorTheme.getURL()'>$wikiColorTheme.plainTitle</a>"])) | ||
35 | #end | ||
36 | #end | ||
37 | #if ($xwiki.exists($services.model.createDocumentReference('', 'FlamingoThemes', 'WebHome'))) | ||
38 | #set ($colorThemeHint = "$!{colorThemeHint} <strong><a href=""$xwiki.getURL($services.model.createDocumentReference('', 'FlamingoThemes', 'WebHome'))"">$services.localization.render('admin.colortheme.manage')</a></strong>") | ||
39 | #elseif ($xwiki.exists($services.model.createDocumentReference('', 'ColorThemes', 'WebHome'))) | ||
40 | #set ($colorThemeHint = "$!{colorThemeHint} <strong><a href=""$xwiki.getURL($services.model.createDocumentReference('', 'ColorThemes', 'WebHome'))"">$services.localization.render('admin.colortheme.manage')</a></strong>") | ||
41 | #end | ||
42 | <span class="buttonwrapper"><a href="$xwiki.getURL($colorThemeName, 'edit')"#if ($colorThemeName.indexOf('.') < 0) class="hidden"#end>$services.localization.render('admin.customize')</a></span> | ||
43 | #end | ||
44 | </label> | ||
45 | #if ($hint)<span class="xHint">$hint</span>#end | ||
46 | </dt> | ||
47 | #if ($out != '') | ||
48 | <dd>$out</dd> | ||
49 | #else | ||
50 | ## We always display a dd element to avoid having a last dt element alone, which would lead to an invalid html. | ||
51 | <dd class="hidden"></dd> | ||
52 | #end | ||
53 | #if ($prop.name == 'colorTheme' && $colorThemeHint) | ||
54 | <dd class="xHint">$colorThemeHint</dd> | ||
55 | #end | ||
56 | #end | ||
57 | {{/velocity}} | ||
58 | |||
59 | {{velocity}} | ||
60 | ### Sheet used to generically display the XWikiPreferences object fields in the administration sheets. | ||
61 | ### Input variables: | ||
62 | ### - $params (mandatory): list of properties to display and their associated sections | ||
63 | ### - $paramDoc (optional): document object which contains the $paramClass | ||
64 | ### - $paramClass (optional): name of the xclass type for the xobject from which to read/save from | ||
65 | #if ("$!section" != '') | ||
66 | ## clean="false" due to bug #XWIKI-4122 - the <legend> element is dropped. | ||
67 | {{html clean="false"}} | ||
68 | #if ("$!paramDoc" != '') | ||
69 | #set($configDoc = $paramDoc) | ||
70 | #else | ||
71 | #set($configDoc = $doc) | ||
72 | #end | ||
73 | #if ("$!paramClass" != '') | ||
74 | #set($configClassName = $paramClass) | ||
75 | #set($formId = "${section.toLowerCase()}_${configClassName}") | ||
76 | #else | ||
77 | #set($configClassName = 'XWiki.XWikiPreferences') | ||
78 | #set($formId = $section.toLowerCase()) | ||
79 | #end | ||
80 | <form id="$formId" method="post" action="$xwiki.getURL($configDoc, 'saveandcontinue')" onsubmit="cancelCancelEdit()" class="xform"> | ||
81 | #set($obj = $configDoc.getObject($configClassName)) | ||
82 | #foreach ($entry in $params.entrySet()) | ||
83 | #set ($fields = $entry.value) | ||
84 | <fieldset class="$entry.key"> | ||
85 | ## If there is only one section, don't display the legend | ||
86 | #if ($params.size() > 1) | ||
87 | <legend>$services.localization.render("admin.$entry.key")</legend> | ||
88 | #end | ||
89 | #if ($fields.size() > 0) | ||
90 | <dl> | ||
91 | #end | ||
92 | #foreach ($field in $fields) | ||
93 | #set ($prop = $obj.xWikiClass.get($field)) | ||
94 | #if ($prop) | ||
95 | #__displayXProperty($prop) | ||
96 | #elseif ($field.html) | ||
97 | $field.html | ||
98 | #end | ||
99 | #end | ||
100 | #if ($fields.size() > 0) | ||
101 | </dl> | ||
102 | #end | ||
103 | </fieldset> | ||
104 | #end | ||
105 | <div class="hidden"> | ||
106 | <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" /> | ||
107 | <input type="hidden" name="xcontinue" value="$xwiki.getURL($currentDoc, 'admin', "editor=${escapetool.url(${editor})}&section=${escapetool.url(${section})}&space=${escapetool.url(${currentSpace})}")" /> | ||
108 | <input type="hidden" name="xredirect" value="$xwiki.getURL($currentDoc, 'admin', "editor=${escapetool.url(${editor})}&section=${escapetool.url(${section})}&space=${escapetool.url(${currentSpace})}")" /> | ||
109 | <input type="hidden" name="classname" value="$configClassName" /> | ||
110 | </div> | ||
111 | <div class="bottombuttons"> | ||
112 | <p class="admin-buttons"> | ||
113 | <span class="buttonwrapper"><input class="button" type="submit" name="formactionsac" value="$services.localization.render('admin.save')" /></span> | ||
114 | </p> | ||
115 | </div> ## bottombuttons | ||
116 | </form> | ||
117 | {{/html}} | ||
118 | #end | ||
119 | {{/velocity}} |