Changes for page Blog Archive

Last modified by Ecaterina Valica on 2018/09/25 12:51

From version 7.1
edited by Ecaterina Valica
on 2013/05/08 07:49
Change comment: Import
To version 8.1
edited by Ecaterina Valica
on 2018/09/25 12:51
Change comment: Install extension [org.xwiki.platform:xwiki-platform-blog-ui/9.2]

Summary

Details

Page properties
Syntax
... ... @@ -1,1 +1,1 @@
1 -XWiki 2.0
1 +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,14 +30,17 @@
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
... ... @@ -53,19 +53,20 @@
53 53  = $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 ($queryParams = [$blogDoc.space, $blogDoc.fullName])
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)
... ... @@ -91,9 +91,9 @@
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