Hide last authors
Vincent Massol 17.1 1 {{template name="locationPicker_macros.vm" /}}
2
Admin 1.1 3 {{velocity}}
Marius Dumitru Florea 12.1 4 ## This document can be copied in order to be customized so we cannot rely on its name to determine if the currently
5 ## displayed document is a class or the class sheet itself. We look for the sheet descriptor instead.
6 #set ($isSheet = $doc.getObject('XWiki.SheetDescriptorClass'))
7 #if ($isSheet)
8 ## Viewing the sheet document itself.
Thomas Mortagne 18.1 9 {{translation key="platform.xclass.defaultClassSheet.description"/}}
Marius Dumitru Florea 11.1 10 #elseif ("$!request.bindSheet" != '' && $hasEdit)
11 #if ($services.csrf.isTokenValid($request.getParameter('form_token')))
12 ## Bind the sheet to the class.
13 #set ($classSheetReference = $services.model.resolveDocument($request.bindSheet))
14 #if ($services.sheet.bindClassSheet($doc, $classSheetReference))
Thomas Mortagne 18.1 15 $doc.save($services.localization.render('platform.xclass.defaultClassSheet.sheets.bind'))
Marius Dumitru Florea 11.1 16 #end
17 $response.sendRedirect($request.xredirect)
18 #else
19 $response.sendRedirect($services.csrf.getResubmissionURL())
Admin 1.1 20 #end
Vincent Massol 6.1 21 ## Stop processing, since we already sent a redirect.
22 #stop
23 #elseif("$!request.docName" != '')
Thomas Mortagne 18.1 24 ## Request for creating a new instance.
25 ## We don't actually create a new instance here, we just redirect to the edit mode.
Vincent Massol 17.1 26 #set ($targetSpaceRef = $services.model.resolveSpace($request.spaceName))
27 #set ($targetDocRef = $services.model.createDocumentReference($request.docName, $targetSpaceRef))
28 #if (!$xwiki.exists($targetDocRef) && $services.security.authorization.hasAccess('edit', $targetDocRef))
Thomas Mortagne 18.1 29 ## Compute the default edit mode to ensure backward compatibility with documents that are still using the deprecated
30 ## inline action.
Vincent Massol 17.1 31 #set ($editAction = $xwiki.getDocument($request.template).getDefaultEditMode())
32 $response.sendRedirect($xwiki.getURL($targetDocRef, $editAction, $escapetool.url({
33 'template': $request.template,
34 'parent': $request.parent,
35 'title': $request.docName
36 })))
Vincent Massol 6.1 37 ## Stop processing, since we already sent a redirect.
38 #stop
39 #end
40 #end
41 {{/velocity}}
42
43 {{velocity}}
Marius Dumitru Florea 12.1 44 ## If this sheet is explicitly bound to the displayed class then print the class document content before the
Vincent Massol 6.1 45 ## sheet output. Class authors can put the description of the class in the class document content.
46 #set($classSheetReference = $services.model.createDocumentReference($doc.wiki, 'XWiki', 'ClassSheet'))
47 #if($services.sheet.getDocumentSheets($doc).contains($classSheetReference))
Vincent Massol 14.1 48 {{include reference="" /}}
Vincent Massol 6.1 49 #end
50 {{/velocity}}
51
52 {{velocity}}
Marius Dumitru Florea 12.1 53 #if (!$isSheet)
Thomas Mortagne 18.1 54 #set ($className = $doc.pageReference.name)
Vincent Massol 17.1 55 #set ($className = $stringtool.removeEnd($className, 'Class'))
Vincent Massol 6.1 56 ## Determine the class sheets.
Vincent Massol 17.1 57 #set ($classSheetReferences = $services.sheet.getClassSheets($doc))
Vincent Massol 6.1 58 #if ($classSheetReferences.isEmpty())
59 ## There is no class sheet explicitly bound to this class. Fall-back on naming convention.
60 ## Before XWiki 2.0, the default class sheet was suffixed with "ClassSheet". Since 2.0, the suffix is just "Sheet".
Vincent Massol 17.1 61 #set ($defaultClassSheetReference = $services.model.createDocumentReference("${className}ClassSheet",
62 $doc.documentReference.parent))
63 #if (!$xwiki.exists($defaultClassSheetReference))
64 #set ($defaultClassSheetReference = $services.model.createDocumentReference("${className}Sheet",
65 $doc.documentReference.parent))
Vincent Massol 6.1 66 #end
Admin 1.1 67 #end
Vincent Massol 6.1 68 ## Determine the template using naming convention.
Thomas Mortagne 18.1 69 ## Before XWiki 2.0, the default class template was suffixed with "ClassTemplate".
70 ## Since 2.0, the suffix is just "Template".
Vincent Massol 17.1 71 #set ($classTemplateReference = $services.model.createDocumentReference("${className}ClassTemplate",
72 $doc.documentReference.parent))
73 #if (!$xwiki.exists($classTemplateReference))
74 #set ($classTemplateReference = $services.model.createDocumentReference("${className}Template",
75 $doc.documentReference.parent))
Admin 1.1 76 #end
Thomas Mortagne 18.1 77 ## Determine the template provider using naming convention.
78 #set ($classTemplateProviderReference = $services.model.createDocumentReference("${className}TemplateProvider",
79 $doc.documentReference.parent))
80 #set ($classTemplateProviderDoc = $xwiki.getDocument($classTemplateProviderReference))
81 #set ($hasClassTemplateProvider = !$classTemplateProviderDoc.isNew())
Vincent Massol 6.1 82 #set($classTemplateDoc = $xwiki.getDocument($classTemplateReference))
83 #set($hasClassSheets = !$classSheetReferences.isEmpty() || $xwiki.exists($defaultClassSheetReference))
84 #set($hasClassTemplate = !$classTemplateDoc.isNew())
Admin 1.1 85 #if(!$defaultSpace)
Vincent Massol 17.1 86 #set($defaultSpace = $doc.space)
Admin 1.1 87 #end
88 #if(!$defaultParent)
89 #set($defaultParent = ${doc.fullName})
90 #end
91
Thomas Mortagne 18.1 92 #set ($classEditorURL = $doc.getURL('edit', 'editor=class'))
Admin 1.1 93 #if($doc.getxWikiClass().properties.size() == 0)
Thomas Mortagne 18.1 94 {{warning}}$services.localization.render('platform.xclass.defaultClassSheet.properties.empty', [
95 "{{html}}<a href='$classEditorURL'>",
96 '</a>{{/html}}'
97 ]){{/warning}}
Admin 1.1 98 #else
Thomas Mortagne 18.1 99 (% id="HClassProperties" %)
100 = {{translation key="platform.xclass.defaultClassSheet.properties.heading"/}} =
Admin 1.1 101 #foreach($property in $doc.getxWikiClass().properties)
Vincent Massol 17.1 102 * $services.rendering.escape("$property.prettyName ($property.name: $xwiki.metaclass.get($property.classType).prettyName)", $xwiki.currentContentSyntaxId)
Admin 1.1 103 #end
Thomas Mortagne 18.1 104 * //$services.localization.render('platform.xclass.defaultClassSheet.properties.edit', [
105 "{{html}}<a href='$classEditorURL'>",
106 '</a>{{/html}}'
107 ])//
Admin 1.1 108
109 #end
Vincent Massol 6.1 110 #if ($hasClassSheets && $hasClassTemplate)
Thomas Mortagne 18.1 111 (% id="HCreatePage" %)
112 = {{translation key="platform.xclass.defaultClassSheet.createPage.heading"/}} =
Vincent Massol 17.1 113 #if("$!targetDocRef" != '' && $xwiki.exists($targetDocRef))
Admin 1.1 114
Thomas Mortagne 18.1 115 {{warning}}$services.localization.render('platform.xclass.defaultClassSheet.createPage.pageAlreadyExists', [
116 '[[',
117 ">>$services.model.serialize($targetDocRef)]]"
118 ]){{/warning}}
Vincent Massol 17.1 119 #elseif("$!targetDocRef" != '')
120
Thomas Mortagne 18.1 121 {{warning}}{{translation key="platform.xclass.defaultClassSheet.createPage.denied"/}}{{/warning}}
Admin 1.1 122 #end
123
124 {{html}}
Vincent Massol 17.1 125 <form action="$doc.getURL()" id="newdoc" method="post" class="xform half">
126 <div class="hidden">
127 <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" />
128 <input type="hidden" name="parent" value="${defaultParent}"/>
129 <input type="hidden" name="template" value="${classTemplateDoc}"/>
130 <input type="hidden" name="sheet" value="1"/>
131 </div>
132 #locationPicker({
133 'id': 'target',
134 'title': {
135 'label': 'core.create.title',
136 'hint': 'core.create.title.hint',
137 'name': 'docTitle',
138 'placeholder': 'core.create.name.placeholder'
139 },
140 'preview': {
141 'label': 'core.create.locationPreview.label',
142 'hint': 'core.create.locationPreview.hint'
143 },
144 'parent': {
145 'label': 'core.create.spaceReference.label',
146 'hint': 'core.create.spaceReference.hint',
147 'name': 'spaceName',
148 'reference': $services.model.resolveSpace($defaultSpace),
149 'placeholder': 'core.create.spaceReference.placeholder'
150 },
151 'name': {
152 'label': 'core.create.name.label',
153 'hint': 'core.create.name.hint',
154 'name': 'docName',
155 'placeholder': 'core.create.name.placeholder'
156 }
157 })
158 <p>
159 <span class="buttonwrapper">
Thomas Mortagne 18.1 160 <input type="submit" class="button" value="$escapetool.xml($services.localization.render(
161 'platform.xclass.defaultClassSheet.createPage.label'))"/>
Vincent Massol 17.1 162 </span>
163 </p>
164 </form>
Admin 1.1 165 {{/html}}
166
Thomas Mortagne 18.1 167 #end## has class sheet and class template
168 (% id="HExistingPages" %)
169 = {{translation key="platform.xclass.defaultClassSheet.pages.heading"/}} =
Admin 1.1 170
Thomas Mortagne 18.1 171 {{translation key="platform.xclass.defaultClassSheet.pages.description"/}}
172
Vincent Massol 17.1 173 {{html}}
Thomas Mortagne 18.1 174 #set ($columns = ['doc.title', 'doc.location', 'doc.date', 'doc.author', 'doc.objectCount', '_actions'])
Vincent Massol 17.1 175 #set ($columnsProperties = {
Thomas Mortagne 18.1 176 'doc.title': {'link': 'view'},
177 'doc.location': {'html': true},
178 'doc.author': {'link': 'author'},
179 'doc.objectCount': {'type': 'numeric', 'filterable': false, 'sortable': false},
Vincent Massol 17.1 180 '_actions': {'sortable': false, 'filterable': false, 'html': true, 'actions': ['edit', 'delete']}
181 })
182 #set ($options = {
183 'className': $doc.fullName,
184 'translationPrefix' : 'platform.index.',
185 'rowCount': 10,
Thomas Mortagne 18.1 186 'outputOnlyHtml': true,
187 'queryFilters': ['unique']
Vincent Massol 17.1 188 })
189 #livetable("classEntries" $columns $columnsProperties $options)
190 {{/html}}
191
Thomas Mortagne 18.1 192 (% id="HClassSheets" %)
193 = {{translation key="platform.xclass.defaultClassSheet.sheets.heading"/}} =
Vincent Massol 17.1 194 #if (!$hasClassSheets || !$hasClassTemplate)
Admin 1.1 195
Thomas Mortagne 18.1 196 {{translation key="platform.xclass.defaultClassSheet.sheets.missing"/}}
Admin 1.1 197 #end
198
Thomas Mortagne 18.1 199 {{info}}$services.localization.render('platform.xclass.defaultClassSheet.sheets.description', ['//', '//']){{/info}}
Admin 1.1 200
Vincent Massol 6.1 201 #if(!$hasClassSheets)
Admin 1.1 202 {{html}}
Vincent Massol 6.1 203 <form action="$xwiki.getURL($defaultClassSheetReference, 'save', 'editor=wiki')" method="post">
Admin 1.1 204 <div>
Admin 3.1 205 <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" />
Admin 1.1 206 <input type="hidden" name="parent" value="${doc.fullName}"/>
207 <input type="hidden" name="xredirect" value="${doc.URL}"/>
Thomas Mortagne 18.1 208 #set ($sheetContent = $xwiki.getDocument('XWiki.ObjectSheet').getContent().replace('XWiki.MyClass',
209 $doc.fullName))
Marius Dumitru Florea 12.1 210 ## We have to encode the new line characters in order to preserve them, otherwise they are replace with a
211 ## space when the HTML is cleaned.
212 ## FIXME: Use a dedicated escape tool method when XCOMMONS-405 is implemented.
213 #set ($sheetContent = $escapetool.xml($sheetContent).replaceAll("\n", '&#10;'))
214 <input type="hidden" name="content" value="$sheetContent"/>
Thomas Mortagne 18.1 215 <input type="hidden" name="title" value="${escapetool.h}if(${escapetool.d}doc.documentReference.name == '$escapetool.xml($defaultClassSheetReference.name)')$escapetool.xml($className) Sheet${escapetool.h}{else}${escapetool.d}services.display.title(${escapetool.d}doc, {'displayerHint': 'default', 'outputSyntaxId': 'plain/1.0'})${escapetool.h}end"/>
216 <span class="buttonwrapper"><input type="submit" class="button" value="$escapetool.xml(
217 $services.localization.render('platform.xclass.defaultClassSheet.sheets.create'))"/></span>
Admin 1.1 218 </div>
219 </form>
220 {{/html}}
221 #else
Vincent Massol 6.1 222 #set($defaultClassSheetDoc = $xwiki.getDocument($defaultClassSheetReference))
223 #if($classSheetReferences.isEmpty() && !$defaultClassSheetDoc.getObject('XWiki.SheetClass'))
224 ## The sheet is not bound to the class.
Marius Dumitru Florea 11.1 225 #set($xredirect = $xwiki.relativeRequestURL)
Vincent Massol 6.1 226 #set($defaultClassSheetStringReference = $services.model.serialize($defaultClassSheetReference, "default"))
227 #set($bindURL = $doc.getURL('view', "bindSheet=${escapetool.url($defaultClassSheetStringReference)}&xredirect=${escapetool.url($xredirect)}&form_token=$!{services.csrf.getToken()}"))
Admin 2.1 228 {{warning}}
Thomas Mortagne 18.1 229 {{translation key="platform.xclass.defaultClassSheet.sheets.notBound"/}} ##
230 #if ($hasEdit)
231 {{html}}
232 <a href="$bindURL">$services.localization.render('platform.xclass.defaultClassSheet.sheets.bind') »</a>.
233 {{/html}}
234 #end
Admin 2.1 235 {{/warning}}
236
237 #end
Vincent Massol 6.1 238 #if ($classSheetReferences.size() < 2)
239 #set($classSheetDoc = $defaultClassSheetDoc)
240 #if(!$classSheetReferences.isEmpty())
241 #set($classSheetDoc = $xwiki.getDocument($classSheetReferences.get(0)))
242 #end
Vincent Massol 17.1 243 #set ($sheetPath = "#hierarchy($classSheetDoc.documentReference, {'plain': true, 'local': true, 'limit': 4})")
Thomas Mortagne 18.1 244 [[$services.localization.render('platform.xclass.defaultClassSheet.sheets.view', [$sheetPath.trim()]) »>>${classSheetDoc.fullName}]]
Vincent Massol 6.1 245 #else
Thomas Mortagne 18.1 246 {{translation key="platform.xclass.defaultClassSheet.sheets.list"/}}
Vincent Massol 6.1 247
248 #foreach($classSheetReference in $classSheetReferences)
249 * [[$services.model.serialize($classSheetReference, "default")]]
250 #end
251 #end
Admin 1.1 252 #end
253
Thomas Mortagne 18.1 254 (% id="HClassTemplate" %)
255 = {{translation key="platform.xclass.defaultClassSheet.template.heading"/}} =
Admin 1.1 256
Thomas Mortagne 18.1 257 {{info}}$services.localization.render('platform.xclass.defaultClassSheet.template.description',
258 ['//', '//']){{/info}}
Admin 1.1 259
Vincent Massol 6.1 260 #if (!$hasClassTemplate)
Admin 1.1 261 {{html}}
262 <form action="$classTemplateDoc.getURL('save', 'editor=wiki')" method="post">
263 <div>
Admin 3.1 264 <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" />
Admin 1.1 265 <input type="hidden" name="parent" value="${doc.fullName}"/>
266 <input type="hidden" name="xredirect" value="${doc.URL}"/>
Admin 8.1 267 <input type="hidden" name="title" value="$className Template"/>
Thomas Mortagne 18.1 268 <span class="buttonwrapper"><input type="submit" class="button" value="$escapetool.xml(
269 $services.localization.render('platform.xclass.defaultClassSheet.template.create'))"/></span>
Admin 1.1 270 </div>
271 </form>
272 {{/html}}
273 #else
Vincent Massol 6.1 274 #if(!$classTemplateDoc.getObject(${doc.fullName}))
Marius Dumitru Florea 11.1 275 #set($xredirect = $xwiki.relativeRequestURL)
Vincent Massol 17.1 276 #set($createUrl = $classTemplateDoc.getURL('objectadd', "classname=${escapetool.url($doc.fullName)}&amp;xredirect=${escapetool.url($xredirect)}&amp;form_token=$!{services.csrf.getToken()}"))
Admin 1.1 277 {{warning}}
Thomas Mortagne 18.1 278 $services.localization.render('platform.xclass.defaultClassSheet.template.missingObject', ["//$className//"]) ##
279 {{html}}<a href="$createUrl">$escapetool.xml($services.localization.render(
280 'platform.xclass.defaultClassSheet.template.addObject', [$className])) »</a>.{{/html}}
Admin 1.1 281 {{/warning}}
282
283 #end
Vincent Massol 17.1 284 #set ($templatePath = "#hierarchy($classTemplateDoc.documentReference, {'plain': true, 'local': true, 'limit': 4})")
Thomas Mortagne 18.1 285 [[$services.localization.render('platform.xclass.defaultClassSheet.template.view',
286 [$templatePath.trim()]) »>>${classTemplateDoc.fullName}]]
Admin 3.1 287 #end
Thomas Mortagne 18.1 288 ## Create a template provider only if a template for the current class exists.
289 #if ($classTemplateDoc.getObject(${doc.fullName}))
290 (% id="HClassTemplateProvider" %)
291 = {{translation key="platform.xclass.defaultClassSheet.templateProvider.heading"/}} =
Admin 1.1 292
Thomas Mortagne 18.1 293 {{info}}$services.localization.render('platform.xclass.defaultClassSheet.templateProvider.description',
294 ['//']){{/info}}
295
296 #if (!$hasClassTemplateProvider)
297 #set ($templateProviderClassName = 'XWiki.TemplateProviderClass')
298 ## Do the page creation and object addition in one step, providing some default values.
299 ## In order to get the root space of the class and use it as restrictionSpace, we need to be sure that we have
300 ## the expected result for multiple level hierarchies, like MyApplication.Code.MyApplicationClass. In this case,
301 ## the template provider in enabled in MyApplication space.
302 #set ($restrictionSpace = $doc.documentReference.spaceReferences.get(0).name)
303 #set ($createUrlQueryString = $escapetool.url({
304 'classname': $templateProviderClassName,
305 'xredirect': $xwiki.relativeRequestURL,
306 'form_token': $services.csrf.token,
307 "${templateProviderClassName}_name": $className,
308 "${templateProviderClassName}_description":
309 $services.localization.render('platform.xclass.templateProvider.defaultDescription', [$className]),
310 "${templateProviderClassName}_template": $classTemplateDoc,
311 "${templateProviderClassName}_visibilityRestrictions": $restrictionSpace}))
312 #set ($createUrl = $classTemplateProviderDoc.getURL('objectadd', $createUrlQueryString))
313 {{html}}
314 <form action="$classTemplateProviderDoc.getURL('save', 'editor=wiki')" method="post">
315 <div>
316 <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" />
317 <input type="hidden" name="parent" value="${doc.fullName}"/>
318 <input type="hidden" name="xredirect" value="$createUrl"/>
319 <input type="hidden" name="title" value="$className Template Provider"/>
320 <span class="buttonwrapper"><input type="submit" class="button" value="$escapetool.xml(
321 $services.localization.render('platform.xclass.defaultClassSheet.templateProvider.create'))"/></span>
322 </div>
323 </form>
324 {{/html}}
325 #else
326 #set ($templateProviderPath = "#hierarchy($classTemplateProviderDoc.documentReference, {'plain': true, 'local': true, 'limit': 4})")
327 [[$services.localization.render('platform.xclass.defaultClassSheet.templateProvider.view',
328 [$templateProviderPath.trim()]) »>>${classTemplateProviderDoc.fullName}]]
329 #end
330 #end
331
Vincent Massol 17.1 332 #end## !$isSheet
Admin 1.1 333 {{/velocity}}

Get Connected