General Actions:
Log-in
Wiki:
L3D's Wiki
▼
:
Document Index
»
Space:
Panels
▼
:
Document Index
»
Page:
DocumentInformation
Search
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
Panels
»
Document Information
Wiki source code of
Document Information
Last modified by
Administrator
on 2011/03/02 20:49
Content
·
Comments
(0)
·
Attachments
(0)
·
History
·
Information
Hide line numbers
1: ## 2: #macro(convertDocument $translatedDoc $error $oldSyntax $newSyntaxId $content) 3: #if ($translatedDoc.realLanguage == $xwiki.languagePreference) 4: #set($theDoc = $translatedDoc) 5: #if ($request.content) 6: #set($void = $translatedDoc.setContent($request.content)) 7: #end 8: #end 9: ## Use the syntax and content received from the client, as the user might have made some changes that are not on saved yet. 10: #set($void = $translatedDoc.setSyntaxId($oldSyntax)) 11: #if (!$translatedDoc.convertSyntax($newSyntaxId) || !${services.csrf.isTokenValid("$!{request.getParameter('form_token')}")}) 12: #set($error = true) 13: #else 14: #set($void = $translatedDoc.save("Document converted from syntax $oldSyntax to syntax $newSyntaxId")) 15: #end 16: #end 17: ## 18: #if("$!{request.action}" == "convertSyntax") 19: #set($oldSyntax = $request.oldSyntaxId) 20: #set($newSyntaxId = $request.newSyntaxId) 21: #set($mainDoc = $xwiki.getDocument($request.documentName)) 22: #set($theDoc = $mainDoc) 23: #set($error = false) 24: ## 25: ## Convert current document 26: ## 27: #convertDocument($mainDoc $error $oldSyntax $newSyntaxId $theDoc) 28: ## 29: ## Convert document translations 30: ## 31: #set($languages = $theDoc.translationList) 32: #if (!$error) 33: #foreach ($language in $languages) 34: #if (!$error) 35: #set($translatedDoc = $mainDoc.getTranslatedDocument($language)) 36: #if ($translatedDoc.language != $mainDoc.language) 37: #convertDocument($translatedDoc $error $oldSyntax $newSyntaxId $theDoc) 38: #end 39: #end 40: #end 41: #end 42: ## 43: ## Error management 44: ## 45: #if (!$error) 46: ## Conversion successful. The "ok:" prefix is needed, since otherwise an empty content will result in a "This template does not exist" exception. 47: ok:{pre}$theDoc.content{/pre} 48: #else 49: $response.setStatus(501) 50: ## TODO: Find a way to put the exception in the context and send it to the client. 51: failed 52: #end 53: #else 54: #includeForm("Panels.PanelSheet") 55: #end
Quick Links
L3D Calendar
Wiki Dashboard
Document Index
Blog
Sandbox