Wiki source code of $services.localization.render('xe.officeimporter.import.title')
Version 1.1 by superadmin on 2025/05/22 17:44
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
1.1 | 1 | {{velocity output="false"}} |
| 2 | #macro (officeImporterForm) | ||
| 3 | #set ($targetReference = $services.model.resolveDocument($request.page)) | ||
| 4 | #set ($targetPageIsNested = $targetReference.name == $services.model.getEntityReference('DOCUMENT', 'default').name) | ||
| 5 | #set ($discard = $xwiki.ssx.use('XWiki.OfficeImporter')) | ||
| 6 | #set ($discard = $xwiki.jsx.use('XWiki.OfficeImporter')) | ||
| 7 | {{html clean="false"}} | ||
| 8 | <form id="officeImportForm" class="xform" method="post" enctype="multipart/form-data" | ||
| 9 | action="$escapetool.xml($xwiki.getURL('XWiki.OfficeImporterResults'))" | ||
| 10 | data-progress-message="$escapetool.xml($services.localization.render('office.import.inProgress'))" | ||
| 11 | data-done-message="$escapetool.xml($services.localization.render('office.import.done'))" | ||
| 12 | data-failed-message="$escapetool.xml($services.localization.render('office.import.failed'))"> | ||
| 13 | <fieldset> | ||
| 14 | <dl class="row"> | ||
| 15 | ## | ||
| 16 | ## Left part | ||
| 17 | ## | ||
| 18 | <div class="col-xs-12 col-md-6"> | ||
| 19 | #officeImporterForm_officeDocument() | ||
| 20 | #officeImporterForm_targetPage() | ||
| 21 | #if ($xwiki.exists($targetReference)) | ||
| 22 | #officeImporterForm_overwriteContent() | ||
| 23 | #end | ||
| 24 | </div> | ||
| 25 | ## | ||
| 26 | ## Right part | ||
| 27 | ## | ||
| 28 | <div class="col-xs-12 col-md-6"> | ||
| 29 | #officeImporterForm_filterStyles() | ||
| 30 | #officeImporterForm_splitDocument() | ||
| 31 | #officeImporterForm_headingLevelsToSplit() | ||
| 32 | #officeImporterForm_childPagesNamingMethod() | ||
| 33 | #officeImporterForm_terminalChildPages() | ||
| 34 | </div> | ||
| 35 | </dl> | ||
| 36 | ## | ||
| 37 | ## Hidden inputs | ||
| 38 | ## | ||
| 39 | <input type="hidden" name="form_token" value="$!escapetool.xml($services.csrf.token)" /> | ||
| 40 | ## Normalize the parent reference of the new document so that even in a subwiki it points to the current wiki. | ||
| 41 | #set ($normalizedParentReference = $services.model.resolveDocument("$!request.parent", 'current')) | ||
| 42 | <input type="hidden" name="parent" value="$escapetool.xml($normalizedParentReference)" /> | ||
| 43 | <input type="hidden" name="target" value="$escapetool.xml($services.model.serialize($targetReference, | ||
| 44 | 'default'))" /> | ||
| 45 | ## | ||
| 46 | ## Form action buttons | ||
| 47 | ## | ||
| 48 | <div class="buttons"> | ||
| 49 | <span class="buttonwrapper"> | ||
| 50 | <button id="submit"> | ||
| 51 | $escapetool.xml($services.localization.render('xe.officeimporter.import.import')) | ||
| 52 | </button> | ||
| 53 | </span> | ||
| 54 | <span class="buttonwrapper"> | ||
| 55 | <a class="secondary button" href="$escapetool.xml($xwiki.getURL($targetReference))"> | ||
| 56 | $escapetool.xml($services.localization.render('cancel')) | ||
| 57 | </a> | ||
| 58 | </span> | ||
| 59 | </div> | ||
| 60 | </fieldset> | ||
| 61 | </form> | ||
| 62 | {{/html}} | ||
| 63 | #end | ||
| 64 | |||
| 65 | #macro (officeImporterForm_officeDocument) | ||
| 66 | ## FIXME: The following list of file name extensions and media types are duplicated from the office resource reference | ||
| 67 | ## picker (templates/html_displayer/officeresourcereference/edit.vm). | ||
| 68 | #set ($officeFileNameExtensions = $stringtool.join([ | ||
| 69 | '.doc', '.docx', | ||
| 70 | '.xls', '.xlsx', | ||
| 71 | '.ppt', '.pptx', | ||
| 72 | '.odt', '.ott', '.fodt', | ||
| 73 | '.ods', '.ots', '.fods', | ||
| 74 | '.odp', '.otp', '.fodp', | ||
| 75 | '.sxw', '.sxc', '.sxi' | ||
| 76 | ], ',')) | ||
| 77 | #set ($officeMediaTypes = $stringtool.join([ | ||
| 78 | 'application/msword', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', | ||
| 79 | 'application/vnd.oasis.opendocument.', | ||
| 80 | 'application/vnd.openxmlformats-officedocument.', | ||
| 81 | 'application/vnd.sun.xml.' | ||
| 82 | ], ',')) | ||
| 83 | <dt> | ||
| 84 | <label for="filePath"> | ||
| 85 | $escapetool.xml($services.localization.render('xe.officeimporter.import.document')) | ||
| 86 | </label> | ||
| 87 | <span class="xHint"> | ||
| 88 | $escapetool.xml($services.localization.render('office.import.document.hint')) | ||
| 89 | </span> | ||
| 90 | </dt> | ||
| 91 | <dd class="buttonwrapper"> | ||
| 92 | <input type="file" id="filePath" name="filePath" value="" size="40" class="button secondary" required | ||
| 93 | accept="$escapetool.xml("$officeFileNameExtensions,$officeMediaTypes")" /> | ||
| 94 | </dd> | ||
| 95 | #end | ||
| 96 | |||
| 97 | #macro (officeImporterForm_targetPage) | ||
| 98 | <dt> | ||
| 99 | <label> | ||
| 100 | $escapetool.xml($services.localization.render('xe.officeimporter.import.target')) | ||
| 101 | </label> | ||
| 102 | <span class="xHint"> | ||
| 103 | $escapetool.xml($services.localization.render('office.import.target.hint')) | ||
| 104 | </span> | ||
| 105 | </dt> | ||
| 106 | <dd> | ||
| 107 | #template('hierarchy_macros.vm') | ||
| 108 | #hierarchy($targetReference) | ||
| 109 | </dd> | ||
| 110 | #end | ||
| 111 | |||
| 112 | #macro (officeImporterForm_overwriteContent) | ||
| 113 | <dt class="box warningmessage"> | ||
| 114 | <label> | ||
| 115 | <input name="overwriteContent" type="checkbox" value="true" checked /> | ||
| 116 | $escapetool.xml($services.localization.render('office.import.overwriteContent')) | ||
| 117 | </label> | ||
| 118 | <span class="xHint"> | ||
| 119 | $escapetool.xml($services.localization.render('office.import.overwriteContent.hint')) | ||
| 120 | </span> | ||
| 121 | </dt> | ||
| 122 | <dd> | ||
| 123 | #officeImporterForm_confirmationModal({ | ||
| 124 | 'cssClass': 'confirmation-overwriteContent', | ||
| 125 | 'title': 'office.import.overwriteContent', | ||
| 126 | 'message': 'office.import.overwriteContent.confirmationMessage', | ||
| 127 | 'action': 'office.import.overwriteContent.confirmationAction' | ||
| 128 | }) | ||
| 129 | </dd> | ||
| 130 | #end | ||
| 131 | |||
| 132 | #macro (officeImporterForm_confirmationModal $config) | ||
| 133 | <div class="confirmation modal fade $!escapetool.xml($config.cssClass)" tabindex="-1" role="dialog"> | ||
| 134 | <div class="modal-dialog"> | ||
| 135 | <div class="modal-content"> | ||
| 136 | <div class="modal-header"> | ||
| 137 | <button type="button" class="close" data-dismiss="modal">×</button> | ||
| 138 | <div class="modal-title"> | ||
| 139 | $escapetool.xml($services.localization.render($config.title)) | ||
| 140 | </div> | ||
| 141 | </div> | ||
| 142 | <div class="modal-body"> | ||
| 143 | $escapetool.xml($services.localization.render($config.message)) | ||
| 144 | </div> | ||
| 145 | <div class="modal-footer"> | ||
| 146 | <input type="button" class="btn btn-danger" data-dismiss="modal" | ||
| 147 | value="$escapetool.xml($services.localization.render($config.action))"> | ||
| 148 | <input type="button" class="btn btn-default" data-dismiss="modal" | ||
| 149 | value="$escapetool.xml($services.localization.render('cancel'))"> | ||
| 150 | </div> | ||
| 151 | </div> | ||
| 152 | </div> | ||
| 153 | </div> | ||
| 154 | #end | ||
| 155 | |||
| 156 | #macro (officeImporterForm_filterStyles) | ||
| 157 | <dt> | ||
| 158 | <label> | ||
| 159 | <input name="filterStyles" type="checkbox" value="strict" checked /> | ||
| 160 | $escapetool.xml($services.localization.render('xe.officeimporter.import.filterstyles')) | ||
| 161 | </label> | ||
| 162 | <span class="xHint"> | ||
| 163 | $escapetool.xml($services.localization.render('xe.officeimporter.import.help.styles')) | ||
| 164 | </span> | ||
| 165 | </dt> | ||
| 166 | <dd></dd> | ||
| 167 | #end | ||
| 168 | |||
| 169 | #macro (officeImporterForm_splitDocument) | ||
| 170 | <dt> | ||
| 171 | <label> | ||
| 172 | <input name="splitDocument" type="checkbox" value="true" /> | ||
| 173 | $escapetool.xml($services.localization.render('xe.officeimporter.import.splitting.splitdocument')) | ||
| 174 | </label> | ||
| 175 | <span class="xHint"> | ||
| 176 | $escapetool.xml($services.localization.render('xe.officeimporter.import.help.splitting')) | ||
| 177 | </span> | ||
| 178 | </dt> | ||
| 179 | <dd></dd> | ||
| 180 | #end | ||
| 181 | |||
| 182 | #macro (officeImporterForm_headingLevelsToSplit) | ||
| 183 | <dt> | ||
| 184 | <label for="headingLevelsToSplitInputId"> | ||
| 185 | $escapetool.xml($services.localization.render('xe.officeimporter.import.splitting.headinglevels')) | ||
| 186 | </label> | ||
| 187 | <span class="xHint"> | ||
| 188 | $escapetool.xml($services.localization.render('office.import.headingLevelsToSplit.hint')) | ||
| 189 | </span> | ||
| 190 | </dt> | ||
| 191 | <dd> | ||
| 192 | <select id="headingLevelsToSplitInputId" name="headingLevelsToSplit" multiple required size="6" | ||
| 193 | class="splitDocument-setting"> | ||
| 194 | #foreach ($level in [1..6]) | ||
| 195 | <option value="$level"#if ($level == 1) selected#end> | ||
| 196 | $escapetool.xml($services.localization.render('xe.officeimporter.import.splitting.heading')) $level | ||
| 197 | </option> | ||
| 198 | #end | ||
| 199 | </select> | ||
| 200 | </dd> | ||
| 201 | #end | ||
| 202 | |||
| 203 | #macro (officeImporterForm_childPagesNamingMethod) | ||
| 204 | ## Hide the field when the target page is nested (not terminal) because the only logical strategy in this case is to | ||
| 205 | ## use "headingNames". It creates pages as children of the target, which seems to be the correct way in the nested | ||
| 206 | ## pages paradigm. The other choices have no sense: | ||
| 207 | ## - "mainPageNameAndHeading" will create pages called "WebHome-Title1" instead of "targetPage/Title1". | ||
| 208 | ## - "mainPageNameAndNumbering" will create pages called "WebHome-1" instead of "targetPage/1". | ||
| 209 | ## In both cases, the "WebHome" part of the names is meaningless. | ||
| 210 | <dt#if ($targetPageIsNested) hidden#end> | ||
| 211 | <label for="childPagesNamingMethodInputId"> | ||
| 212 | $escapetool.xml($services.localization.render('xe.officeimporter.import.splitting.naming')) | ||
| 213 | </label> | ||
| 214 | <span class="xHint"> | ||
| 215 | $escapetool.xml($services.localization.render('office.import.childPagesNaming.hint')) | ||
| 216 | </span> | ||
| 217 | </dt> | ||
| 218 | <dd> | ||
| 219 | <select id="childPagesNamingMethodInputId" name="childPagesNamingMethod" class="splitDocument-setting" | ||
| 220 | #if ($targetPageIsNested) hidden#end> | ||
| 221 | <option value="headingNames"#if ($targetPageIsNested) selected#end> | ||
| 222 | $escapetool.xml($services.localization.render('xe.officeimporter.import.splitting.naming.headingnames')) | ||
| 223 | </option> | ||
| 224 | <option value="mainPageNameAndHeading"#if (!$targetPageIsNested) selected#end> | ||
| 225 | $escapetool.xml($services.localization.render( | ||
| 226 | 'xe.officeimporter.import.splitting.naming.mainpagenameandheading')) | ||
| 227 | </option> | ||
| 228 | <option value="mainPageNameAndNumbering"> | ||
| 229 | $escapetool.xml($services.localization.render( | ||
| 230 | 'xe.officeimporter.import.splitting.naming.mainpagenameandnumbering')) | ||
| 231 | </option> | ||
| 232 | </select> | ||
| 233 | </dd> | ||
| 234 | #end | ||
| 235 | |||
| 236 | #macro (officeImporterForm_terminalChildPages) | ||
| 237 | #set ($hidden = !($targetPageIsNested && ($isAdvancedUser || $isSuperAdmin))) | ||
| 238 | <dt#if ($hidden) hidden#end> | ||
| 239 | <label> | ||
| 240 | <input type="checkbox" name="terminalChildPages" value="true"#if ($hidden) checked#end | ||
| 241 | class="splitDocument-setting" /> | ||
| 242 | $escapetool.xml($services.localization.render('office.import.terminalChildPages')) | ||
| 243 | </label> | ||
| 244 | <span class="xHint"> | ||
| 245 | $escapetool.xml($services.localization.render('office.import.terminalChildPages.hint')) | ||
| 246 | </span> | ||
| 247 | </dt> | ||
| 248 | <dd></dd> | ||
| 249 | #end | ||
| 250 | |||
| 251 | #macro (officeImporter_translationWithLink $key $linkTarget) | ||
| 252 | #set ($targetSyntax = 'xwiki/2.1') | ||
| 253 | #set ($translation = $services.localization.render($key, $targetSyntax, ['LINKSTART', 'LINKEND'])) | ||
| 254 | #set ($linkLabel = $stringtool.substringBetween($translation, 'LINKSTART', 'LINKEND')) | ||
| 255 | #if ($linkLabel) | ||
| 256 | #set ($escapedLinkLabel = $services.rendering.escape($linkLabel, $targetSyntax)) | ||
| 257 | #set ($escapedLinkTarget = $services.rendering.escape($linkTarget, $targetSyntax)) | ||
| 258 | $translation.replace("LINKSTART${linkLabel}LINKEND", "[[$escapedLinkLabel>>$escapedLinkTarget]]") | ||
| 259 | #else | ||
| 260 | $services.localization.render($key, $targetSyntax, ['', '']) | ||
| 261 | #end | ||
| 262 | #end | ||
| 263 | {{/velocity}} | ||
| 264 | |||
| 265 | {{velocity}} | ||
| 266 | #if ("$!request.page" == '') | ||
| 267 | {{error}} | ||
| 268 | ## This page does not propose to select the target page anymore. The create action should be used instead. | ||
| 269 | ## Note: The link points to the main page because the user might not have create right on the current "XWiki" space, | ||
| 270 | ## which is reserved anyway for technical pages. | ||
| 271 | #set ($createURL = $xwiki.getURL($services.wiki.currentWikiDescriptor.mainPageReference, 'create', 'type=office')) | ||
| 272 | #officeImporter_translationWithLink('office.form.error.noDocument' "path:$createURL") | ||
| 273 | {{/error}} | ||
| 274 | #else | ||
| 275 | ## Hide UI elements that are not needed for office import. | ||
| 276 | #set ($displayContentMenu = false) | ||
| 277 | #set ($displayContentFooter = false) | ||
| 278 | #set ($displayDocExtra = false) | ||
| 279 | #if ($isguest) | ||
| 280 | {{error}}$services.localization.render('xe.officeimporter.notallowed', 'xwiki/2.1'){{/error}} | ||
| 281 | #elseif (!$services.officemanager.isConnected()) | ||
| 282 | #if ($hasAdmin) | ||
| 283 | {{error}} | ||
| 284 | #set ($documentationURL = 'http://extensions.xwiki.org/xwiki/bin/Extension/Office%20Importer%20Application') | ||
| 285 | #officeImporter_translationWithLink('xe.officeimporter.error.adminuser' $documentationURL) | ||
| 286 | {{/error}} | ||
| 287 | #else | ||
| 288 | {{error}}$services.localization.render('xe.officeimporter.error.normaluser', 'xwiki/2.1'){{/error}} | ||
| 289 | #end | ||
| 290 | #else | ||
| 291 | #officeImporterForm() | ||
| 292 | #end | ||
| 293 | #end | ||
| 294 | {{/velocity}} |