Исходный код вики AdminFieldsDisplaySheet

Версия 1.1 от Admin xWiKi на 15.10.2019, 13:19

Последние авторы
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 #end
50 #if ($prop.name == 'colorTheme' && $colorThemeHint)
51 <dd class="xHint">$colorThemeHint</dd>
52 #end
53 #end
54 {{/velocity}}
55
56 {{velocity}}
57 ### Sheet used to generically display the XWikiPreferences object fields in the administration sheets.
58 ### Input variables:
59 ### - $params (mandatory): list of properties to display and their associated sections
60 ### - $paramDoc (optional): document object which contains the $paramClass
61 ### - $paramClass (optional): name of the xclass type for the xobject from which to read/save from
62 #if ("$!section" != '')
63 ## clean="false" due to bug #XWIKI-4122 - the <legend> element is dropped.
64 {{html clean="false"}}
65 #if ("$!paramDoc" != '')
66 #set($configDoc = $paramDoc)
67 #else
68 #set($configDoc = $doc)
69 #end
70 #if ("$!paramClass" != '')
71 #set($configClassName = $paramClass)
72 #set($formId = "${section.toLowerCase()}_${configClassName}")
73 #else
74 #set($configClassName = 'XWiki.XWikiPreferences')
75 #set($formId = $section.toLowerCase())
76 #end
77 <form id="$formId" method="post" action="$xwiki.getURL($configDoc, 'saveandcontinue')" onsubmit="cancelCancelEdit()" class="xform">
78 #set($obj = $configDoc.getObject($configClassName))
79 #foreach ($entry in $params.entrySet())
80 #set ($fields = $entry.value)
81 <fieldset class="$entry.key">
82 ## If there is only one section, don't display the legend
83 #if ($params.size() > 1)
84 <legend>$services.localization.render("admin.$entry.key")</legend>
85 #end
86 #if ($fields.size() > 0)
87 <dl>
88 #end
89 #foreach ($field in $fields)
90 #set ($prop = $obj.xWikiClass.get($field))
91 #if ($prop)
92 #__displayXProperty($prop)
93 #elseif ($field.html)
94 $field.html
95 #end
96 #end
97 #if ($fields.size() > 0)
98 </dl>
99 #end
100 </fieldset>
101 #end
102 <div class="hidden">
103 <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" />
104 <input type="hidden" name="xcontinue" value="$xwiki.getURL($currentDoc, 'admin', "editor=${escapetool.url(${editor})}&amp;section=${escapetool.url(${section})}&amp;space=${escapetool.url(${currentSpace})}")" />
105 <input type="hidden" name="xredirect" value="$xwiki.getURL($currentDoc, 'admin', "editor=${escapetool.url(${editor})}&amp;section=${escapetool.url(${section})}&amp;space=${escapetool.url(${currentSpace})}")" />
106 <input type="hidden" name="classname" value="$configClassName" />
107 </div>
108 <div class="bottombuttons">
109 <p class="admin-buttons">
110 <span class="buttonwrapper"><input class="button" type="submit" name="formactionsac" value="$services.localization.render('admin.save')" /></span>
111 </p>
112 </div> ## bottombuttons
113 </form>
114 {{/html}}
115 #end
116 {{/velocity}}