Changes for page Blog Archive
Last modified by Ecaterina Valica on 2018/09/25 12:51
From version 1.1
edited by Ludovic Dubost
on 2012/08/06 21:16
on 2012/08/06 21:16
Change comment:
Copied from incubator:Blog.Archive
To version 8.1
edited by Ecaterina Valica
on 2018/09/25 12:51
on 2018/09/25 12:51
Change comment:
Install extension [org.xwiki.platform:xwiki-platform-blog-ui/9.2]
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 - xwiki:XWiki.ludovic1 +XWiki.evalica - Syntax
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki 2. 01 +XWiki 2.1 - Content
-
... ... @@ -1,4 +1,4 @@ 1 -{{include document="Blog.BlogCode"/}}1 +{{include reference="Blog.BlogCode"/}} 2 2 3 3 {{velocity filter="none"}} 4 4 {{html clean="false" wiki="true"}} ... ... @@ -12,17 +12,17 @@ 12 12 ## Create a Jodatime date formatter that will be used to format dates 13 13 #set($monthFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern('MMMM')) 14 14 #set($tempDate = $xwiki.jodatime.mutableDateTime) 15 - #set($currentYear = $xwiki.formatDate($ util.date, 'yyyy'))16 - #set($currentMonth = $xwiki.formatDate($ util.date, 'M'))15 + #set($currentYear = $xwiki.formatDate($datetool.date, 'yyyy')) 16 + #set($currentMonth = $xwiki.formatDate($datetool.date, 'M')) 17 17 #set($firstYear = '') 18 18 #set($lastYear = '') 19 - #foreach($firstEntry in $ xwiki.searchDocuments("${query} order by year(publishDate.value)",1, 0,$queryParams))19 + #foreach($firstEntry in $services.query.hql("${query} order by year(publishDate.value)").setLimit(1).bindValues($queryParams).execute()) 20 20 #set($discard = $xwiki.getDocument($firstEntry)) 21 21 #getEntryObject($discard $entryObj) 22 22 #getEntryDate($discard $entryObj $firstYear) 23 23 #set($firstYear = $mathtool.toInteger($xwiki.formatDate($firstYear, 'yyyy'))) 24 24 #end 25 - #foreach($lastEntry in $ xwiki.searchDocuments("${query} order by year(publishDate.value) desc",1, 0,$queryParams))25 + #foreach($lastEntry in $services.query.hql("${query} order by year(publishDate.value) desc").setLimit(1).bindValues($queryParams).execute()) 26 26 #set($discard = $xwiki.getDocument($lastEntry)) 27 27 #getEntryObject($discard $entryObj) 28 28 #getEntryDate($discard $entryObj $lastYear) ... ... @@ -30,20 +30,23 @@ 30 30 #end 31 31 #if("$!{firstYear}" != '') ## At least one entry exists 32 32 #foreach($year in [$firstYear..$lastYear]) 33 - #set($yearArticleCount = $ xwiki.countDocuments("${query} and year(publishDate.value) = $year",$queryParams))33 + #set($yearArticleCount = $services.query.hql("${query} and year(publishDate.value) = $year").bindValues($queryParams).count()) 34 34 #if($yearArticleCount > 0) 35 - * [[$year ($yearArticleCount)>>Blog.Archive?space=${blogDoc.space}&year=${year}]] 35 + #set ($queryString = "space=$escapetool.url($blogDoc.space)&year=${year}") 36 + * [[$year ($yearArticleCount)>>Blog.Archive||queryString="${queryString}"]] 36 36 #foreach($month in [1..12]) 37 - #set($monthArticleCount = $xwiki.countDocuments("${query} and year(publishDate.value) = $year and month(publishDate.value) = $month", $queryParams)) 38 + #set ($statement = "${query} and year(publishDate.value) = $year and month(publishDate.value) = $month") 39 + #set ($monthArticleCount = $services.query.hql($statement).bindValues($queryParams).count()) 38 38 #if($monthArticleCount > 0) 39 39 $tempDate.setMonthOfYear($month) 40 - ** [[$monthFormatter.print($tempDate) (${monthArticleCount})>>Blog.Archive?space=${blogDoc.space}&year=${year}&month=${month}]] 42 + #set($queryString = "space=${escapetool.url($blogDoc.space)}&year=${year}&month=${month}") 43 + ** [[$monthFormatter.print($tempDate) (${monthArticleCount})>>Blog.Archive||queryString="${queryString}"]] 41 41 #end 42 42 #end 43 43 #end 44 44 #end 45 45 #else 46 - #info($ msg.get('xe.blog.archive.noarticle'))49 + #info($services.localization.render('xe.blog.archive.noarticle')) 47 47 #end 48 48 #end 49 49 ## ... ... @@ -50,32 +50,33 @@ 50 50 ## 51 51 ## 52 52 #macro(displayBlogYearArchive $blogDoc $year) 53 -= $ msg.get('xe.blog.archive.postsyear', [$year]) =56 += $services.localization.render('xe.blog.archive.postsyear', [$year]) = 54 54 #getBlogEntriesBaseQuery($query) 55 55 #set($query = "${query} and (doc.space = ? or doc.parent = ?)") 56 - #set 59 + #set($queryParams = [$blogDoc.space, $blogDoc.fullName]) 57 57 #set($query = "${query} and year(publishDate.value) = $year") 58 58 ## Create a Jodatime date formatter that will be used to format dates 59 59 #set($monthFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern('MMMM')) 60 60 #set($tempDate = $xwiki.jodatime.mutableDateTime) 61 - #set($yearArticleCount = $ xwiki.countDocuments(${query},$queryParams))64 + #set($yearArticleCount = $services.query.hql($query).bindValues($queryParams).count()) 62 62 #if($yearArticleCount > 0) 63 63 #foreach($month in [1..12]) 64 - #set($monthArticleCount = $ xwiki.countDocuments("${query} and month(publishDate.value) = $month",$queryParams))67 + #set($monthArticleCount = $services.query.hql("${query} and month(publishDate.value) = $month").bindValues($queryParams).count()) 65 65 #if($monthArticleCount > 0) 66 66 $tempDate.setMonthOfYear($month) 67 -== [[$monthFormatter.print($tempDate) (${monthArticleCount})>>Blog.Archive?space=${blogDoc.space}&year=${year}&month=${month}]] == 68 - #foreach($entryDoc in $xwiki.wrapDocs($xwiki.searchDocuments("${query} and month(publishDate.value) = $month order by publishDate.value", $queryParams))) 70 + #set($queryString = "space=${escapetool.url($blogDoc.space)}&year=${year}&month=${month}") 71 +== [[$monthFormatter.print($tempDate) (${monthArticleCount})>>Blog.Archive||queryString="${queryString}"]] == 72 + #foreach($entryDoc in $xwiki.wrapDocs($services.query.hql("${query} and month(publishDate.value) = $month order by publishDate.value", $queryParams).execute())) 69 69 #getEntryObject($entryDoc $entryObj) 70 70 #isPublished($entryObj $isPublished) 71 71 #isHidden($entryObj $isHidden) 72 - * [[$entryDoc.display('title', 'view', $entryObj)>>$entryDoc]]#if(!$isPublished) $ msg.get('xe.blog.archive.unpublished')#elseif($isHidden) $msg.get('xe.blog.archive.hidden')#end76 + * [[$entryDoc.display('title', 'view', $entryObj)>>$entryDoc]]#if(!$isPublished) $services.localization.render('xe.blog.archive.unpublished')#elseif($isHidden) $services.localization.render('xe.blog.archive.hidden')#end 73 73 74 74 #end 75 75 #end 76 76 #end 77 77 #else 78 - #info($ msg.get('xe.blog.archive.noarticlesyear'))82 + #info($services.localization.render('xe.blog.archive.noarticlesyear')) 79 79 #end 80 80 #end 81 81 ## ... ... @@ -86,19 +86,19 @@ 86 86 #set($tempDate = $xwiki.jodatime.mutableDateTime) 87 87 $tempDate.setYear($mathtool.toInteger($year))## 88 88 $tempDate.setMonthOfYear($mathtool.toInteger($month))## 89 -= $ msg.get('xe.blog.archive.postsfor') $dateFormatter.print($tempDate) =93 += $services.localization.render('xe.blog.archive.postsfor') $dateFormatter.print($tempDate) = 90 90 #getBlogEntriesBaseQuery($query) 91 91 #set($query = "${query} and (doc.space = ? or doc.parent = ?)") 92 92 #set ($queryParams = [$blogDoc.space, $blogDoc.fullName]) 93 93 #set($query = "${query} and year(publishDate.value) = $year and month(publishDate.value) = $month") 94 - #set($monthArticleCount = $ xwiki.countDocuments(${query},$queryParams))98 + #set($monthArticleCount = $services.query.hql($query).bindValues($queryParams).count()) 95 95 #if($monthArticleCount > 0) 96 - #foreach($entryDoc in $xwiki.wrapDocs($ xwiki.searchDocuments("${query} order by publishDate.value",$queryParams)))100 + #foreach($entryDoc in $xwiki.wrapDocs($services.query.hql("${query} order by publishDate.value").bindValues($queryParams).execute())) 97 97 #getEntryObject($entryDoc $entryObj) 98 98 #displayEntry($entryDoc $entryObj true true) 99 99 #end 100 100 #else 101 - #info($ msg.get('xe.blog.archive.noarticlesmonth'))105 + #info($services.localization.render('xe.blog.archive.noarticlesmonth')) 102 102 #end 103 103 #end 104 104 ##