General Actions:
Log-in
Wiki:
L3D's Wiki
▼
:
Document Index
»
Space:
XWiki
▼
:
Document Index
»
Page:
ClassSheet
Search
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
Welcome to your wiki
»
XWiki Space
»
Data types
»
Default Class Sheet
Wiki source code of
Default Class Sheet
Last modified by
Administrator
on 2011/03/02 17:34
Content
·
Comments
(0)
·
Attachments
(0)
·
History
·
Information
Show line numbers
{{velocity}} #if($doc.fullName == 'XWiki.ClassSheet') ## Viewing the sheet document itself You can edit this document to change the default presentation of classes, or you can copy it to create a customized view just for one or several classes. #else #if("$!request.docName" != '') ## Request for creating a new instance #set($targetDocName = "${request.spaceName}.${request.docName}") #if(!$xwiki.exists($targetDocName) && $xwiki.hasAccessLevel('edit', $context.user, $targetDocName)) $response.sendRedirect($xwiki.getURL($targetDocName, 'inline', "template=${request.template}&parent=${request.parent}")) ## Stop processing, since we already sent a redirect. #stop #end #end #if($doc.name.endsWith('Class')) #set($className = $doc.name.substring(0, $doc.name.lastIndexOf('Class'))) #else #set($className = $doc.name) #end #set($classSheetDoc = $xwiki.getDocument("${doc.space}.${className}Sheet")) ## Before XWiki 2.0, the default class sheet was suffixed with "ClassSheet". Since 2.0, the suffix is just "Sheet". #if($xwiki.exists("${doc.space}.${className}ClassSheet")) #set($classSheetDoc = $xwiki.getDocument("${doc.space}.${className}ClassSheet")) #else #set($classSheetDoc = $xwiki.getDocument("${doc.space}.${className}Sheet")) #end ## Before XWiki 2.0, the default class template was suffixed with "ClassTemplate". Since 2.0, the suffix is just "Template". #if($xwiki.exists("${doc.space}.${className}ClassTemplate")) #set($classTemplateDoc = $xwiki.getDocument("${doc.space}.${className}ClassTemplate")) #else #set($classTemplateDoc = $xwiki.getDocument("${doc.space}.${className}Template")) #end #set($classSheetExists = !($classSheetDoc.isNew())) #set($classTemplateExists = !($classTemplateDoc.isNew())) #if(!$defaultSpace) #set($defaultSpace = 'Main') #end #if(!$defaultParent) #set($defaultParent = ${doc.fullName}) #end = Class: $className = #if($doc.getxWikiClass().properties.size() == 0) {{warning}}The class does not have any properties yet. You can use the {{html}}<a href="$doc.getURL('edit', 'editor=class')">class editor</a>{{/html}} to define them.{{/warning}} #else Class properties: #foreach($property in $doc.getxWikiClass().properties) * $property.prettyName (${property.name}: $xwiki.metaclass.get($property.classType).prettyName) #end * //You can use the class editor to {{html}}<a href="$doc.getURL('edit', 'editor=class')">add or modify the class properties</a>{{/html}}.// #end #if ($classSheetExists && $classTemplateExists) = Create a new document = #if("$!targetDocName" != '' && $xwiki.exists($targetDocName)) {{warning}}The target document already exists. Please choose a different name, or [[view the existing document>>$targetDocName]]{{/warning}} #elseif("$!targetDocName" != '') {{warning}}You don't have permission to create that document{{/warning}} #end {{html}} <form action="" id="newdoc" method="post"> <div> <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" /> <input type="hidden" name="parent" value="${defaultParent}"/> <input type="hidden" name="template" value="${classTemplateDoc}"/> <input type="hidden" name="sheet" value="1"/> <label for="spaceName">Space: </label><input type="text" id="spaceName" name="spaceName" value="${defaultSpace}" size="8"/> <label for="docName">Document: </label><input type="text" id="docName" name="docName" value="Document name" class="withTip"'/> <span class="buttonwrapper"><input type="submit" value="Create this document" class="button"/></span> </div> </form> {{/html}} = Existing documents = #set($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='${doc.fullName}' and obj.name<>'${classTemplateDoc.fullName}'") #foreach ($item in $xwiki.searchDocuments($sql)) * [[$item]] #end #end ## class sheet and class template exist = The class sheet = #if (!$classSheetExists || !$classTemplateExists) Before using this class you must first create the sheet and template for it. Follow the instructions below to do this. #end {{info}}The //Sheet// allows to control the presentation of documents of this data type. You can use the default presentation, which enumerates all the available fields, or you can design your own presentation. You can also choose different presentations for the viewing and for the editing modes.{{/info}} #if(!$classSheetExists) {{html}} <form action="$classSheetDoc.getURL('save', 'editor=wiki')" method="post"> <div> <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" /> <input type="hidden" name="parent" value="${doc.fullName}"/> <input type="hidden" name="xredirect" value="${doc.URL}"/> <input type="hidden" name="content" value="$xwiki.getFormEncoded($xwiki.getDocument('XWiki.ObjectSheet').getContent().replaceAll('XWiki.MyClass', $doc.fullName))"/> <input type="hidden" name="title" value="$doc.name Sheet"/> <span class="buttonwrapper"><input type="submit" value="Create the document sheet" class="button"/></span> </div> </form> {{/html}} #else #if($classSheetExists && !$classSheetDoc.getObject('XWiki.SheetClass')) #set($xredirect = $request.getRequestURL()) #set($createUrl = $classSheetDoc.getURL('objectadd', "classname=XWiki.SheetClass&xredirect=${xredirect}&form_token=$!{services.csrf.getToken()}")) {{warning}} The sheet does not contain an object of type //XWiki.SheetClass//. To trigger the inline edit mode automatically, {{html}}<a href="$createUrl">add a SheetClass object to the sheet »</a>.{{/html}} {{/warning}} #end [[View the sheet document (${classSheetDoc.fullName}) »>>${classSheetDoc.fullName}]] #end = The class template = {{info}}The //Template// is the document used as the model for documents of this data type. It will automatically contain a reference to the //Sheet// and an instance of your //Class//.{{/info}} #if (!$classTemplateExists) {{html}} <form action="$classTemplateDoc.getURL('save', 'editor=wiki')" method="post"> <div> <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" /> <input type="hidden" name="parent" value="${doc.fullName}"/> <input type="hidden" name="xredirect" value="${doc.URL}"/> <input type="hidden" name="content" value="$xwiki.getFormEncoded($xwiki.getDocument('XWiki.ObjectTemplate').getContent().replaceAll('XWiki.MySheet', $classSheetDoc.fullName))"/> <input type="hidden" name="title" value="$doc.name Template"/> <span class="buttonwrapper"><input type="submit" value="Create the document template" class="button"/></span> </div> </form> {{/html}} #else #if($classTemplateExists && !$classTemplateDoc.getObject(${doc.fullName})) #set($xredirect = $request.getRequestURL()) #set($createUrl = $classTemplateDoc.getURL('objectadd', "classname=${doc.fullName}&xredirect=${xredirect}&form_token=$!{services.csrf.getToken()}")) {{warning}} The template does not contain an object of type //${className}Class//. {{html}}<a href="$createUrl">Add a ${className} object to the template »</a>.{{/html}} {{/warning}} #end [[View the template document (${classTemplateDoc.fullName}) »>>${classTemplateDoc.fullName}]] #end #end ## doc == XWiki.ClassSheet {{/velocity}}
Quick Links
L3D Calendar
Wiki Dashboard
Document Index
Blog
Sandbox