Wiki-Quellcode von AdminFieldsDisplaySheet
Zuletzt geändert von admin am 2025/02/23 10:10
Verstecke letzte Bearbeiter
| author | version | line-number | content |
|---|---|---|---|
| |
1.1 | 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 | $escapetool.xml($title) | ||
| 23 | #if ($prop.name == 'skin') | ||
| 24 | #set ($skin = $xwiki.skin) | ||
| 25 | <span class="buttonwrapper"> | ||
| 26 | <a href="$xwiki.getURL($skin, 'edit')"#if ($skin.indexOf('.') < 0) class="hidden"#end> | ||
| 27 | $escapetool.xml($services.localization.render('admin.customize')) | ||
| 28 | </a> | ||
| 29 | </span> | ||
| 30 | #end | ||
| 31 | #if ($prop.name == 'colorTheme') | ||
| 32 | #if ($editor == 'globaladmin') | ||
| 33 | #set ($colorThemeName = $xwiki.getXWikiPreference('colorTheme')) | ||
| 34 | #else | ||
| 35 | #set ($colorThemeName = $xwiki.getSpacePreference('colorTheme')) | ||
| 36 | #set ($wikiColorTheme = $xwiki.getDocument($xwiki.getXWikiPreference('colorTheme'))) | ||
| 37 | #if (!$wikiColorTheme.isNew()) | ||
| 38 | #set ($colorThemeHint = $escapetool.xml($services.localization.render('admin.colortheme.wikiSetting', ['__LINK__'])).replaceAll('__LINK__', "<a href='$wikiColorTheme.getURL()'>$wikiColorTheme.plainTitle</a>")) | ||
| 39 | #end | ||
| 40 | #end | ||
| 41 | #if ($xwiki.exists($services.model.createDocumentReference('', 'FlamingoThemes', 'WebHome'))) | ||
| 42 | #set ($colorThemeHint = "$!{colorThemeHint} <strong><a href=""$xwiki.getURL($services.model.createDocumentReference('', 'FlamingoThemes', 'WebHome'))"">$escapetool.xml($services.localization.render('admin.colortheme.manage'))</a></strong>") | ||
| 43 | #elseif ($xwiki.exists($services.model.createDocumentReference('', 'ColorThemes', 'WebHome'))) | ||
| 44 | #set ($colorThemeHint = "$!{colorThemeHint} <strong><a href=""$xwiki.getURL($services.model.createDocumentReference('', 'ColorThemes', 'WebHome'))"">$escapetool.xml($services.localization.render('admin.colortheme.manage'))</a></strong>") | ||
| 45 | #end | ||
| 46 | <span class="buttonwrapper"> | ||
| 47 | <a href="$xwiki.getURL($colorThemeName, 'edit')"#if ($colorThemeName.indexOf('.') < 0) class="hidden"#end> | ||
| 48 | $escapetool.xml($services.localization.render('admin.customize')) | ||
| 49 | </a> | ||
| 50 | </span> | ||
| 51 | #end | ||
| 52 | </label> | ||
| 53 | #if ($hint)<span class="xHint">$escapetool.xml($hint)</span>#end | ||
| 54 | </dt> | ||
| 55 | #if ($out != '') | ||
| 56 | <dd>$out</dd> | ||
| 57 | #else | ||
| 58 | ## We always display a dd element to avoid having a last dt element alone, which would lead to an invalid html. | ||
| 59 | <dd class="hidden"></dd> | ||
| 60 | #end | ||
| 61 | #if ($prop.name == 'colorTheme' && $colorThemeHint) | ||
| 62 | <dd class="xHint">$colorThemeHint</dd> | ||
| 63 | #end | ||
| 64 | #end | ||
| 65 | {{/velocity}} | ||
| 66 | |||
| 67 | {{velocity}} | ||
| 68 | ### Sheet used to generically display the XWikiPreferences object fields in the administration sheets. | ||
| 69 | ### Input variables: | ||
| 70 | ### - $params (mandatory): list of properties to display and their associated sections | ||
| 71 | ### - $paramDoc (optional): document object which contains the $paramClass | ||
| 72 | ### - $paramClass (optional): name of the xclass type for the xobject from which to read/save from | ||
| 73 | ### - $objectPolicy (since 14.10) (optional): the update policy to use when saving the form | ||
| 74 | #if ("$!section" != '') | ||
| 75 | ## clean="false" due to bug #XWIKI-4122 - the <legend> element is dropped. | ||
| 76 | {{html clean="false"}} | ||
| 77 | #if ("$!paramDoc" != '') | ||
| 78 | #set($configDoc = $paramDoc) | ||
| 79 | #else | ||
| 80 | #set($configDoc = $doc) | ||
| 81 | #end | ||
| 82 | #if ("$!paramClass" != '') | ||
| 83 | #set($configClassName = $paramClass) | ||
| 84 | #set($formId = "${section.toLowerCase()}_${configClassName}") | ||
| 85 | #else | ||
| 86 | #set($configClassName = 'XWiki.XWikiPreferences') | ||
| 87 | #set($formId = $section.toLowerCase()) | ||
| 88 | #end | ||
| 89 | <form id="$escapetool.xml($formId)" method="post" | ||
| 90 | action="$escapetool.xml($xwiki.getURL($configDoc, 'saveandcontinue'))" | ||
| 91 | onsubmit="cancelCancelEdit()" | ||
| 92 | class="xform"> | ||
| 93 | #set($obj = $configDoc.getObject($configClassName)) | ||
| 94 | #foreach ($entry in $params.entrySet()) | ||
| 95 | #set ($fields = $entry.value) | ||
| 96 | <fieldset class="$escapetool.xml($entry.key)"> | ||
| 97 | ## If there is only one section, don't display the legend | ||
| 98 | #if ($params.size() > 1) | ||
| 99 | <legend>$escapetool.xml($services.localization.render("admin.$entry.key"))</legend> | ||
| 100 | #end | ||
| 101 | #if ($fields.size() > 0) | ||
| 102 | <dl> | ||
| 103 | #end | ||
| 104 | #foreach ($field in $fields) | ||
| 105 | #set ($prop = $obj.xWikiClass.get($field)) | ||
| 106 | #if ($prop) | ||
| 107 | #__displayXProperty($prop) | ||
| 108 | #elseif ($field.html) | ||
| 109 | $field.html | ||
| 110 | #end | ||
| 111 | #end | ||
| 112 | #if ($fields.size() > 0) | ||
| 113 | </dl> | ||
| 114 | #end | ||
| 115 | </fieldset> | ||
| 116 | #end | ||
| 117 | <div class="hidden"> | ||
| 118 | <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" /> | ||
| 119 | <input type="hidden" name="xcontinue" value="$xwiki.getURL($currentDoc, 'admin', "editor=${escapetool.url(${editor})}&section=${escapetool.url(${section})}&space=${escapetool.url(${currentSpace})}")" /> | ||
| 120 | <input type="hidden" name="xredirect" value="$xwiki.getURL($currentDoc, 'admin', "editor=${escapetool.url(${editor})}&section=${escapetool.url(${section})}&space=${escapetool.url(${currentSpace})}")" /> | ||
| 121 | <input type="hidden" name="classname" value="$escapetool.xml($configClassName)" /> | ||
| 122 | #if ("$!objectPolicy" != '') | ||
| 123 | <input type="hidden" name="objectPolicy" value="$escapetool.xml($objectPolicy)" /> | ||
| 124 | #end | ||
| 125 | </div> | ||
| 126 | <div class="bottombuttons"> | ||
| 127 | <p class="admin-buttons"> | ||
| 128 | <span class="buttonwrapper"><input class="button" type="submit" name="formactionsac" | ||
| 129 | value="$escapetool.xml($services.localization.render('admin.save'))" /></span> | ||
| 130 | </p> | ||
| 131 | </div> ## bottombuttons | ||
| 132 | </form> | ||
| 133 | {{/html}} | ||
| 134 | #end | ||
| 135 | {{/velocity}} |