Code source wiki de Blog migration
Afficher les derniers auteurs
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{velocity filter="none"}} | ||
| 2 | #if($request.migrate) | ||
| 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 $xwiki.searchDocuments($query)) | ||
| 6 | #if($xwiki.hasAccessLevel('edit', $context.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($msg.get('xe.blog.migration.migrated'), true) | ||
| 19 | * $msg.get('xe.blog.migration.updated') [[$entryObj.title>>${article}]] ($msg.get('xe.blog.migration.inspace') [[$articleDoc.space>>${articleDoc.space}.WebHome]]) | ||
| 20 | #else | ||
| 21 | * $msg.get('xe.blog.migration.skipping') [[$article]] | ||
| 22 | #end | ||
| 23 | #end | ||
| 24 | $msg.get('xe.blog.migration.done') [[$msg.get('xe.blog.migration.backtoblog')>>Blog.WebHome]] | ||
| 25 | #else | ||
| 26 | $msg.get('xe.blog.migration.pleaseconfirm') | ||
| 27 | |||
| 28 | {{html clean="false" wiki="true"}} | ||
| 29 | <form action="$doc.getURL()" method="post"> | ||
| 30 | <div><input type="submit" name="migrate" value="$msg.get('xe.blog.migration.confirm')"/></div> | ||
| 31 | </form> | ||
| 32 | {{/html}} | ||
| 33 | |||
| 34 | [[$msg.get('xe.blog.migration.backtoblog')>>Blog.WebHome]] | ||
| 35 | #end | ||
| 36 | {{/velocity}} |