Wiki source code of ConfigurationSheet
Last modified by superadmin on 2025/05/22 17:45
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{velocity output="false"}} | ||
| 2 | #set ($discard = $xwiki.ssx.use('XWiki.PDFExport.ConfigurationSheet')) | ||
| 3 | #set ($discard = $xwiki.jsx.use('XWiki.PDFExport.ConfigurationSheet')) | ||
| 4 | ## Load the JavaScript code required to make the object properties editable in-place. | ||
| 5 | #set ($discard = $xwiki.jsfx.use('uicomponents/edit/editableProperty.js', { | ||
| 6 | 'forceSkinAction': true, | ||
| 7 | 'language': $xcontext.locale | ||
| 8 | })) | ||
| 9 | #set ($editing = $xcontext.action == 'edit' || $xcontext.action == 'admin') | ||
| 10 | ## The object to display. | ||
| 11 | #set ($configObject = $doc.getObject('XWiki.PDFExport.ConfigurationClass')) | ||
| 12 | ## The class that describes the object properties. | ||
| 13 | #set ($configClass = $configObject.xWikiClass) | ||
| 14 | ## Make sure the following display* method calls use the right object. | ||
| 15 | #set ($discard = $doc.use($configObject)) | ||
| 16 | |||
| 17 | #macro (displayPDFExportConfigProperty $configPropertyName $options) | ||
| 18 | #set ($configProperty = $configClass.get($configPropertyName)) | ||
| 19 | <dt #if (!$editing && $services.security.authorization.hasAccess('edit')) | ||
| 20 | class="editableProperty" | ||
| 21 | #set ($configPropertyReference = $configObject.getProperty($configProperty.name).reference) | ||
| 22 | data-property="$escapetool.xml($services.model.serialize($configPropertyReference))" | ||
| 23 | data-property-type="object"#end> | ||
| 24 | ## This must match the id generated by the $doc.display() method below. | ||
| 25 | #set ($configPropertyId = "${configClass.name}_${configObject.number}_$configProperty.name$!options.idSuffix") | ||
| 26 | <label#if ($editing) for="$escapetool.xml($configPropertyId)"#end> | ||
| 27 | $escapetool.xml($configProperty.translatedPrettyName) | ||
| 28 | #if ($options.required) | ||
| 29 | <span class="xRequired">$escapetool.xml($services.localization.render('core.validation.required'))</span> | ||
| 30 | #end | ||
| 31 | </label> | ||
| 32 | ## Support for specifying a translation key as hint in the property definition. | ||
| 33 | <span class="xHint">$!escapetool.xml($services.localization.render($configProperty.hint))</span> | ||
| 34 | </dt> | ||
| 35 | #set ($displayMode = 'view') | ||
| 36 | #if ($editing) | ||
| 37 | #set ($displayMode = 'edit') | ||
| 38 | #end | ||
| 39 | <dd>#displayPDFExportConfigPropertyValue($configProperty, $displayMode)</dd> | ||
| 40 | #end | ||
| 41 | |||
| 42 | #macro (displayPDFExportConfigPropertyValue $configProperty $displayMode) | ||
| 43 | #unwrapXPropertyDisplay($doc.display($configProperty.name, $displayMode)) | ||
| 44 | #end | ||
| 45 | |||
| 46 | #macro (viewPDFExportConfig) | ||
| 47 | #foreach ($property in $configClass.properties) | ||
| 48 | #displayPDFExportConfigProperty($property.name) | ||
| 49 | #end | ||
| 50 | #end | ||
| 51 | |||
| 52 | #macro (editPDFExportConfig) | ||
| 53 | #displayPDFExportConfigProperty('templates') | ||
| 54 | <dt> | ||
| 55 | <label for="pdfGenerator"> | ||
| 56 | $escapetool.xml($services.localization.render('export.pdf.generator.label')) | ||
| 57 | </label> | ||
| 58 | <span class="xHint">$escapetool.xml($services.localization.render('export.pdf.generator.hint'))</span> | ||
| 59 | </dt> | ||
| 60 | #if (!$services.export.pdf.configuration.isServerSide()) | ||
| 61 | #set ($selectedPDFGenerator = 'userBrowser') | ||
| 62 | #elseif ("$!services.export.pdf.configuration.chromeHost" == '') | ||
| 63 | #set ($selectedPDFGenerator = 'chromeDockerContainer') | ||
| 64 | #else | ||
| 65 | #set ($selectedPDFGenerator = 'remoteChrome') | ||
| 66 | #end | ||
| 67 | <dd> | ||
| 68 | <select id="pdfGenerator"> | ||
| 69 | #foreach ($pdfGenerator in ['userBrowser', 'chromeDockerContainer', 'remoteChrome']) | ||
| 70 | <option value="$escapetool.xml($pdfGenerator)" | ||
| 71 | #if ($pdfGenerator == $selectedPDFGenerator)selected="selected" #end | ||
| 72 | title="$escapetool.xml($services.localization.render("export.pdf.generator.${pdfGenerator}.hint"))"> | ||
| 73 | $escapetool.xml($services.localization.render("export.pdf.generator.${pdfGenerator}.label")) | ||
| 74 | </option> | ||
| 75 | #end | ||
| 76 | </select> | ||
| 77 | <fieldset id="pdfGenerator-userBrowser" class="pdfGeneratorConfig | ||
| 78 | #if ($selectedPDFGenerator == 'userBrowser')"#else hidden" disabled="disabled"#end> | ||
| 79 | <legend> | ||
| 80 | $escapetool.xml($services.localization.render("export.pdf.generator.userBrowser.label")) | ||
| 81 | </legend> | ||
| 82 | <p class="xHint"> | ||
| 83 | $escapetool.xml($services.localization.render('export.pdf.generator.userBrowser.hint')) | ||
| 84 | </p> | ||
| 85 | <input type="hidden" name="${configClass.name}_${configObject.number}_serverSide" value="0" /> | ||
| 86 | </fieldset> | ||
| 87 | <fieldset id="pdfGenerator-chromeDockerContainer" class="pdfGeneratorConfig | ||
| 88 | #if ($selectedPDFGenerator == 'chromeDockerContainer')"#else hidden" disabled="disabled"#end> | ||
| 89 | <legend> | ||
| 90 | $escapetool.xml($services.localization.render('export.pdf.generator.chromeDockerContainer.label')) | ||
| 91 | </legend> | ||
| 92 | <p class="xHint"> | ||
| 93 | $escapetool.xml($services.localization.render('export.pdf.generator.chromeDockerContainer.hint')) | ||
| 94 | </p> | ||
| 95 | <input type="hidden" name="${configClass.name}_${configObject.number}_serverSide" value="1" /> | ||
| 96 | <input type="hidden" name="${configClass.name}_${configObject.number}_chromeHost" value="" /> | ||
| 97 | <dl> | ||
| 98 | #displayPDFExportConfigProperty('chromeDockerImage') | ||
| 99 | #displayPDFExportConfigProperty('chromeDockerContainerName') | ||
| 100 | #displayPDFExportConfigProperty('chromeRemoteDebuggingPort', {'min': 1, 'max': 65535}) | ||
| 101 | #displayPDFExportConfigProperty('dockerNetwork') | ||
| 102 | #displayPDFExportConfigProperty('xwikiURI') | ||
| 103 | </dl> | ||
| 104 | </fieldset> | ||
| 105 | <fieldset id="pdfGenerator-remoteChrome" class="pdfGeneratorConfig | ||
| 106 | #if ($selectedPDFGenerator == 'remoteChrome')"#else hidden" disabled="disabled"#end> | ||
| 107 | <legend> | ||
| 108 | $escapetool.xml($services.localization.render("export.pdf.generator.remoteChrome.label")) | ||
| 109 | </legend> | ||
| 110 | <p class="xHint"> | ||
| 111 | $escapetool.xml($services.localization.render('export.pdf.generator.remoteChrome.hint')) | ||
| 112 | </p> | ||
| 113 | <input type="hidden" name="${configClass.name}_${configObject.number}_serverSide" value="1" /> | ||
| 114 | <dl> | ||
| 115 | #displayPDFExportConfigProperty('chromeHost', {'required': true}) | ||
| 116 | #displayPDFExportConfigProperty('chromeRemoteDebuggingPort', { | ||
| 117 | 'idSuffix': '_remoteChrome', | ||
| 118 | 'min': 1, 'max': 65535 | ||
| 119 | }) | ||
| 120 | #displayPDFExportConfigProperty('xwikiURI', {'idSuffix': '_remoteChrome'}) | ||
| 121 | </dl> | ||
| 122 | </fieldset> | ||
| 123 | </dd> | ||
| 124 | #set ($maxSigned32BitInteger = 2147483647) | ||
| 125 | ## We ask the user to specify the page ready timeout in seconds but we actually need the milliseconds value so we | ||
| 126 | ## multiply it by 1000, thus we need to lower the upper limit. Note that the final value is passed to JavaScript's | ||
| 127 | ## setTimeout whose delay parameter max value is 2^31-1 (i.e. 32 bit integer, with one sign bit). | ||
| 128 | #displayPDFExportConfigProperty('pageReadyTimeout', {'min': 0, 'max': $mathtool.idiv($maxSigned32BitInteger, 1000)}) | ||
| 129 | #displayPDFExportConfigProperty('maxContentSize', {'min': 0, 'max': $maxSigned32BitInteger}) | ||
| 130 | #displayPDFExportConfigProperty('replaceFOP') | ||
| 131 | #end | ||
| 132 | {{/velocity}} | ||
| 133 | |||
| 134 | {{velocity}} | ||
| 135 | #if ($configObject) | ||
| 136 | {{html clean="false"}} | ||
| 137 | ## Using the xform vertical form layout. | ||
| 138 | <div class="xform"> | ||
| 139 | <dl> | ||
| 140 | #if ($editing) | ||
| 141 | #editPDFExportConfig() | ||
| 142 | #else | ||
| 143 | #viewPDFExportConfig() | ||
| 144 | #end | ||
| 145 | </dl> | ||
| 146 | </div> | ||
| 147 | {{/html}} | ||
| 148 | #end | ||
| 149 | {{/velocity}} |