一般动作
登录
Wiki:
BROPEN
▼
:
Document Index
»
Space:
Panels
▼
:
Document Index
»
Page:
DocumentInformation
搜索
default
页面动作
导出
▼
:
以PDF格式导出
以RTF格式导出
以HTML格式导出
更多动作
▼
:
打印预览
察看源码
欢迎进入Wiki
»
面板
»
Document Information
Wiki源代码
Document Information
在2013-10-09 15:02上被
Administrator
修改
内容
·
评论
(0)
·
附件
(0)
·
记录
·
信息
隐藏行号
1: {{velocity output="false"}} 2: #macro(convertDocument $targetDoc $error $oldSyntaxId $newSyntaxId) 3: #if ($targetDoc.realLanguage == $xwiki.languagePreference) 4: #if ($request.content) 5: ## Use the content received from the client if the target document is the edited one (could be also a translation of the edited document). 6: #set ($void = $targetDoc.setContent($request.content)) 7: #end 8: #end 9: ## Use the syntax received from the client as the user might have made some changes that are not saved yet. 10: #set ($void = $targetDoc.setSyntaxId($oldSyntaxId)) 11: #if (!$services.csrf.isTokenValid($request.form_token) || !$targetDoc.convertSyntax($newSyntaxId)) 12: #set ($error = true) 13: #else 14: #set ($void = $targetDoc.save("Document converted from syntax $oldSyntaxId to syntax $newSyntaxId")) 15: #end 16: #end 17: {{/velocity}} 18: 19: {{velocity wiki="false"}} 20: #if ("$!request.action" == 'convertSyntax') 21: #set ($oldSyntaxId = $request.oldSyntaxId) 22: #set ($newSyntaxId = $request.newSyntaxId) 23: #set ($targetDoc = $xwiki.getDocument($request.documentName)) 24: #set ($error = false) 25: ## 26: ## Convert the specified document 27: ## 28: #convertDocument($targetDoc $error $oldSyntaxId $newSyntaxId) 29: ## 30: ## Convert all the translations of the specified document 31: ## 32: #set($languages = $targetDoc.translationList) 33: #if (!$error) 34: #foreach ($language in $languages) 35: #if (!$error) 36: #set ($translatedDoc = $targetDoc.getTranslatedDocument($language)) 37: #if ($translatedDoc.language != $targetDoc.language) 38: #convertDocument($translatedDoc $error $oldSyntaxId $newSyntaxId) 39: #end 40: #end 41: #end 42: #end 43: ## 44: ## Error management 45: ## 46: #if (!$error) 47: ## Conversion successful. The "ok:" prefix is needed, since otherwise an empty content will result in a "This template does not exist" exception. 48: ok:${targetDoc.content}## 49: #else 50: $response.setStatus(501) 51: ## TODO: Find a way to put the exception in the context and send it to the client. 52: failed 53: #end 54: #end 55: {{/velocity}} 56: 57: {{velocity}} 58: #if ("$!request.action" != 'convertSyntax') 59: {{include document="Panels.PanelSheet"/}} 60: #end 61: {{/velocity}}
快速链接
首页
新闻动态
FAQ