Toggle navigation
Log-in
Wiki Index
Page Index
User Index
Application Index
Blog
Blog migration
Wiki source code of
Blog migration
Last modified by superadmin on 2016/07/29 17:18
Hide line numbers
1: {{velocity filter="none"}} 2: #if($request.migrate && $!{services.csrf.isTokenValid("$!{request.getParameter('form_token')}")}) 3: #set($newContent = '#includeForm("Blog.BlogPostSheet")') 4: #set($query = ", BaseObject obj where obj.name = doc.fullName and obj.className = 'XWiki.ArticleClass'") 5: #foreach($article in $services.query.hql($query).execute()) 6: #if($xwiki.hasAccessLevel('edit', $xcontext.user, $article)) 7: #set($articleDoc = $xwiki.getDocument($article)) 8: #set($articleObj = $articleDoc.getObject('XWiki.ArticleClass')) 9: #set($entryObj = $articleDoc.newObject('Blog.BlogPostClass')) 10: #foreach($property in ['title', 'content', 'extract', 'category']) 11: $!entryObj.set($property, $articleObj.getProperty($property).value) 12: #end 13: $!entryObj.set('published', 1) 14: $!entryObj.set('publishDate', $articleDoc.creationDate) 15: $!entryObj.set('hidden', 0) 16: #set($discard = $articleDoc.removeObjects('XWiki.ArticleClass')) 17: $articleDoc.setContent($newContent) 18: $!articleDoc.save($services.localization.render('xe.blog.migration.migrated'), true) 19: * $services.localization.render('xe.blog.migration.updated') [[$entryObj.title>>${article}]] ($services.localization.render('xe.blog.migration.inspace') [[$articleDoc.space>>${articleDoc.space}.WebHome]]) 20: #else 21: * $services.localization.render('xe.blog.migration.skipping') [[$article]] 22: #end 23: #end 24: $services.localization.render('xe.blog.migration.done') [[$services.localization.render('xe.blog.migration.backtoblog')>>Blog.WebHome]] 25: #else 26: $services.localization.render('xe.blog.migration.pleaseconfirm') 27: 28: {{html clean="false" wiki="true"}} 29: <form action="$doc.getURL()" method="post"> 30: <div> 31: <input type="hidden" name="form_token" value="$!{services.csrf.getToken()}" /> 32: <input type="submit" name="migrate" value="$services.localization.render('xe.blog.migration.confirm')"/> 33: </div> 34: </form> 35: {{/html}} 36: 37: [[$services.localization.render('xe.blog.migration.backtoblog')>>Blog.WebHome]] 38: #end 39: {{/velocity}}