| ... |
... |
@@ -1,6 +1,4 @@ |
| 1 |
|
-{{include reference="Blog.BlogParameters" author="target" /}} |
| 2 |
|
- |
| 3 |
|
-{{velocity output="false"}} |
|
1 |
+#includeMacros("Blog.BlogParameters") |
| 4 |
4 |
## |
| 5 |
5 |
## |
| 6 |
6 |
## |
| ... |
... |
@@ -79,14 +79,7 @@ |
| 79 |
79 |
#set($blogDoc = $xwiki.getDocument("${space}.Blog")) |
| 80 |
80 |
#if(!$blogDoc.getObject($blogClassname)) |
| 81 |
81 |
## Third, try searching for a blog document in the current space |
| 82 |
|
-#set ($legacyRawc2c39d3a2e_1 = $services.query.hql(", BaseObject obj where doc.space = '${space}' and obj.name = doc.fullName and obj.className = '$blogClassname' order by doc.name").execute()) |
| 83 |
|
-#set ($legacyVisiblec2c39d3a2e_1 = []) |
| 84 |
|
-#foreach ($legacyEntryc2c39d3a2e_1 in $legacyRawc2c39d3a2e_1) |
| 85 |
|
- #if ($xwiki.hasAccessLevel('view', $xcontext.user, $legacyEntryc2c39d3a2e_1)) |
| 86 |
|
- #set ($legacyVisibilityDiscard = $legacyVisiblec2c39d3a2e_1.add($legacyEntryc2c39d3a2e_1)) |
| 87 |
|
- #end |
| 88 |
|
-#end |
| 89 |
|
- #set($blogDocs = $legacyVisiblec2c39d3a2e_1) |
|
80 |
+ #set($blogDocs = $services.query.hql(", BaseObject obj where doc.space = '${space}' and obj.name = doc.fullName and obj.className = '$blogClassname' order by doc.name").addFilter('view').execute()) |
| 90 |
90 |
#if($blogDocs.size() > 0) |
| 91 |
91 |
#set($blogDoc = $xwiki.getDocument($blogDocs.get(0))) |
| 92 |
92 |
#else |
| ... |
... |
@@ -106,12 +106,7 @@ |
| 106 |
106 |
* @param title The resulting title. |
| 107 |
107 |
*### |
| 108 |
108 |
#macro(getBlogTitle $blogDoc $title) |
| 109 |
|
- ## The blog title is the rendered document title. It is displayed as data (never evaluated as |
| 110 |
|
- ## Velocity), so an unprivileged user storing script in Blog.BlogClass.title cannot run it. See |
| 111 |
|
- ## Blog.BlogSheet, which renders the title literally and falls back to the blog.code.title |
| 112 |
|
- ## translation when the stored title is empty. |
| 113 |
|
- #set ($title = $NULL) |
| 114 |
|
- #setVariable ("$title" $!blogDoc.displayTitle) |
|
100 |
+ #getBlogProperty($blogDoc 'title' $!blogDoc.displayTitle $title) |
| 115 |
115 |
#end |
| 116 |
116 |
## |
| 117 |
117 |
## |
| ... |
... |
@@ -124,9 +124,7 @@ |
| 124 |
124 |
* @param description The resulting description. |
| 125 |
125 |
*### |
| 126 |
126 |
#macro(getBlogDescription $blogDoc $description) |
| 127 |
|
- #getBlogProperty($blogDoc 'description' '' $result) |
| 128 |
|
- #set ($description = $NULL) |
| 129 |
|
- #setVariable ("$description" $result) |
|
113 |
+ #getBlogProperty($blogDoc 'description' '' $description) |
| 130 |
130 |
#end |
| 131 |
131 |
## |
| 132 |
132 |
## |
| ... |
... |
@@ -177,15 +177,8 @@ |
| 177 |
177 |
#set($defaultItemsPerPage = $util.parseInt($defaultItemsPerPage)) |
| 178 |
178 |
## This macro is defined in the default macros.vm library. It also sets $itemsPerPage and $startAt. |
| 179 |
179 |
#preparePagedViewParams($totalEntries $defaultItemsPerPage) |
| 180 |
|
-#set ($legacyRawc2c39d3a2e_2 = $services.query.hql("${query} order by publishDate.value desc").setLimit($itemsPerPage).setOffset($startAt).execute()) |
| 181 |
|
-#set ($legacyVisiblec2c39d3a2e_2 = []) |
| 182 |
|
-#foreach ($legacyEntryc2c39d3a2e_2 in $legacyRawc2c39d3a2e_2) |
| 183 |
|
- #if ($xwiki.hasAccessLevel('view', $xcontext.user, $legacyEntryc2c39d3a2e_2)) |
| 184 |
|
- #set ($legacyVisibilityDiscard = $legacyVisiblec2c39d3a2e_2.add($legacyEntryc2c39d3a2e_2)) |
| 185 |
|
- #end |
|
164 |
+ #set($entries = $services.query.hql("${query} order by publishDate.value desc").setLimit($itemsPerPage).setOffset($startAt).addFilter('view').execute()) |
| 186 |
186 |
#end |
| 187 |
|
- #set($entries = $legacyVisiblec2c39d3a2e_2) |
| 188 |
|
-#end |
| 189 |
189 |
## |
| 190 |
190 |
## |
| 191 |
191 |
## |
| ... |
... |
@@ -206,15 +206,8 @@ |
| 206 |
206 |
#set($maxDay = $dateFormatter.print($weekDate.toMutableDateTime().weekOfWeekyear().roundCeiling())) |
| 207 |
207 |
#set($query = "${query} and publishDate.value >= '$minDay' and publishDate.value < '$maxDay'") |
| 208 |
208 |
#set($totalEntries = $xwiki.countDocuments(${query})) |
| 209 |
|
-#set ($legacyRawc2c39d3a2e_3 = $services.query.hql("${query} order by publishDate.value desc").execute()) |
| 210 |
|
-#set ($legacyVisiblec2c39d3a2e_3 = []) |
| 211 |
|
-#foreach ($legacyEntryc2c39d3a2e_3 in $legacyRawc2c39d3a2e_3) |
| 212 |
|
- #if ($xwiki.hasAccessLevel('view', $xcontext.user, $legacyEntryc2c39d3a2e_3)) |
| 213 |
|
- #set ($legacyVisibilityDiscard = $legacyVisiblec2c39d3a2e_3.add($legacyEntryc2c39d3a2e_3)) |
| 214 |
|
- #end |
|
186 |
+ #set($entries = $services.query.hql("${query} order by publishDate.value desc").addFilter('view').execute()) |
| 215 |
215 |
#end |
| 216 |
|
- #set($entries = $legacyVisiblec2c39d3a2e_3) |
| 217 |
|
-#end |
| 218 |
218 |
## |
| 219 |
219 |
## |
| 220 |
220 |
## |
| ... |
... |
@@ -235,15 +235,8 @@ |
| 235 |
235 |
#set($maxDay = $dateFormatter.print($monthDate.toMutableDateTime().monthOfYear().roundCeiling())) |
| 236 |
236 |
#set($query = "${query} and publishDate.value >= '$minDay' and publishDate.value < '$maxDay'") |
| 237 |
237 |
#set($totalEntries = $xwiki.countDocuments(${query})) |
| 238 |
|
-#set ($legacyRawc2c39d3a2e_4 = $services.query.hql("${query} order by publishDate.value desc").execute()) |
| 239 |
|
-#set ($legacyVisiblec2c39d3a2e_4 = []) |
| 240 |
|
-#foreach ($legacyEntryc2c39d3a2e_4 in $legacyRawc2c39d3a2e_4) |
| 241 |
|
- #if ($xwiki.hasAccessLevel('view', $xcontext.user, $legacyEntryc2c39d3a2e_4)) |
| 242 |
|
- #set ($legacyVisibilityDiscard = $legacyVisiblec2c39d3a2e_4.add($legacyEntryc2c39d3a2e_4)) |
| 243 |
|
- #end |
|
208 |
+ #set($entries = $services.query.hql("${query} order by publishDate.value desc").addFilter('view').execute()) |
| 244 |
244 |
#end |
| 245 |
|
- #set($entries = $legacyVisiblec2c39d3a2e_4) |
| 246 |
|
-#end |
| 247 |
247 |
## |
| 248 |
248 |
## |
| 249 |
249 |
## |
| ... |
... |
@@ -257,15 +257,8 @@ |
| 257 |
257 |
*### |
| 258 |
258 |
#macro(getAllBlogEntries $blogDoc $query $entries) |
| 259 |
259 |
#set($totalEntries = $xwiki.countDocuments(${query})) |
| 260 |
|
-#set ($legacyRawc2c39d3a2e_5 = $services.query.hql("${query} order by publishDate.value desc").execute()) |
| 261 |
|
-#set ($legacyVisiblec2c39d3a2e_5 = []) |
| 262 |
|
-#foreach ($legacyEntryc2c39d3a2e_5 in $legacyRawc2c39d3a2e_5) |
| 263 |
|
- #if ($xwiki.hasAccessLevel('view', $xcontext.user, $legacyEntryc2c39d3a2e_5)) |
| 264 |
|
- #set ($legacyVisibilityDiscard = $legacyVisiblec2c39d3a2e_5.add($legacyEntryc2c39d3a2e_5)) |
| 265 |
|
- #end |
|
223 |
+ #set($entries = $services.query.hql("${query} order by publishDate.value desc").addFilter('view').execute()) |
| 266 |
266 |
#end |
| 267 |
|
- #set($entries = $legacyVisiblec2c39d3a2e_5) |
| 268 |
|
-#end |
| 269 |
269 |
## |
| 270 |
270 |
## |
| 271 |
271 |
## |
| ... |
... |
@@ -280,15 +280,8 @@ |
| 280 |
280 |
#macro(getUnpublishedBlogEntries $blogDoc $query $entries) |
| 281 |
281 |
#set($query = "${query} and isPublished.value = 0") |
| 282 |
282 |
#set($totalEntries = $xwiki.countDocuments(${query})) |
| 283 |
|
-#set ($legacyRawc2c39d3a2e_6 = $services.query.hql("${query} order by publishDate.value desc").execute()) |
| 284 |
|
-#set ($legacyVisiblec2c39d3a2e_6 = []) |
| 285 |
|
-#foreach ($legacyEntryc2c39d3a2e_6 in $legacyRawc2c39d3a2e_6) |
| 286 |
|
- #if ($xwiki.hasAccessLevel('view', $xcontext.user, $legacyEntryc2c39d3a2e_6)) |
| 287 |
|
- #set ($legacyVisibilityDiscard = $legacyVisiblec2c39d3a2e_6.add($legacyEntryc2c39d3a2e_6)) |
| 288 |
|
- #end |
|
239 |
+ #set($entries = $services.query.hql("${query} order by publishDate.value desc").addFilter('view').execute()) |
| 289 |
289 |
#end |
| 290 |
|
- #set($entries = $legacyVisiblec2c39d3a2e_6) |
| 291 |
|
-#end |
| 292 |
292 |
## |
| 293 |
293 |
## |
| 294 |
294 |
## |
| ... |
... |
@@ -303,15 +303,8 @@ |
| 303 |
303 |
#set($defaultItemsPerPage = 20) |
| 304 |
304 |
## This macro is defined in the default macros.vm library. It also sets $itemsPerPage and $startAt. |
| 305 |
305 |
#preparePagedViewParams($totalEntries $defaultItemsPerPage) |
| 306 |
|
-#set ($legacyRawc2c39d3a2e_7 = $services.query.hql("${query} order by publishDate.value desc").setLimit($itemsPerPage).setOffset($startAt).execute()) |
| 307 |
|
-#set ($legacyVisiblec2c39d3a2e_7 = []) |
| 308 |
|
-#foreach ($legacyEntryc2c39d3a2e_7 in $legacyRawc2c39d3a2e_7) |
| 309 |
|
- #if ($xwiki.hasAccessLevel('view', $xcontext.user, $legacyEntryc2c39d3a2e_7)) |
| 310 |
|
- #set ($legacyVisibilityDiscard = $legacyVisiblec2c39d3a2e_7.add($legacyEntryc2c39d3a2e_7)) |
| 311 |
|
- #end |
|
255 |
+ #set($entries = $services.query.hql("${query} order by publishDate.value desc").setLimit($itemsPerPage).setOffset($startAt).addFilter('view').execute()) |
| 312 |
312 |
#end |
| 313 |
|
- #set($entries = $legacyVisiblec2c39d3a2e_7) |
| 314 |
|
-#end |
| 315 |
315 |
## |
| 316 |
316 |
## |
| 317 |
317 |
## |
| ... |
... |
@@ -322,7 +322,13 @@ |
| 322 |
322 |
* @param query The basic query for selecting blog entries. |
| 323 |
323 |
*### |
| 324 |
324 |
#macro(getBlogEntriesBaseQuery $query) |
| 325 |
|
- #getAllBlogPostsQuery($query) |
|
267 |
+ #set ($query = ", BaseObject obj, IntegerProperty isPublished, IntegerProperty hidden, DateProperty publishDate |
|
268 |
+ where doc.fullName <> 'Blog.BlogPostTemplate' and |
|
269 |
+ obj.name = doc.fullName and obj.className = '${blogPostClassname}' and |
|
270 |
+ publishDate.id.id = obj.id and publishDate.id.name = 'publishDate' and |
|
271 |
+ isPublished.id.id = obj.id and isPublished.id.name = 'published' and |
|
272 |
+ hidden.id.id = obj.id and hidden.id.name = 'hidden' and |
|
273 |
+ (doc.creator = '$context.user' or (isPublished.value = 1 and hidden.value = 0))") |
| 326 |
326 |
#end |
| 327 |
327 |
## |
| 328 |
328 |
## |
| ... |
... |
@@ -352,9 +352,7 @@ |
| 352 |
352 |
* @param displayType The resulting string. If the blog object does not define anything, it is considered paginated. |
| 353 |
353 |
*### |
| 354 |
354 |
#macro(getBlogDisplayType $blogDoc $displayType) |
| 355 |
|
- #getBlogProperty($blogDoc 'displayType' 'paginated' $result) |
| 356 |
|
- #set ($displayType = $NULL) |
| 357 |
|
- #setVariable ("$displayType" $result) |
|
303 |
+ #getBlogProperty($blogDoc 'displayType' 'paginated' $displayType) |
| 358 |
358 |
#end |
| 359 |
359 |
## |
| 360 |
360 |
## |
| ... |
... |
@@ -846,200 +846,8 @@ |
| 846 |
846 |
* @param propertyValue The resulting value. |
| 847 |
847 |
*### |
| 848 |
848 |
#macro(getBlogProperty $blogDoc $propertyName $defaultValue $propertyValue) |
| 849 |
|
- #set($result = "$!{blogDoc.getObject(${blogClassname}).getProperty($propertyName).value}") |
| 850 |
|
- #if($result == '') |
| 851 |
|
- #set($result = $defaultValue) |
|
795 |
+ #set($propertyValue = "$!{blogDoc.getObject(${blogClassname}).getProperty($propertyName).value}") |
|
796 |
+ #if($propertyValue == '') |
|
797 |
+ #set($propertyValue = $defaultValue) |
| 852 |
852 |
#end |
| 853 |
|
- #set ($propertyValue = $NULL) |
| 854 |
|
- #setVariable ("$propertyValue" $result) |
| 855 |
855 |
#end |
| 856 |
|
-## Compatibility helpers from the installed Blog 9.15.15 package. |
| 857 |
|
-#macro(bindQueryParameters $queryObj $queryParams) |
| 858 |
|
- #set ($output = $queryObj) |
| 859 |
|
- #foreach( $key in $queryParams.keySet() ) |
| 860 |
|
- #set($output = $queryObj.bindValue($key, $queryParams.get($key))) |
| 861 |
|
- #end |
| 862 |
|
- #setVariable("$queryObj" $output) |
| 863 |
|
-#end |
| 864 |
|
- |
| 865 |
|
-#macro(blog__actionResponseError $status $text $parameters) |
| 866 |
|
- $response.setStatus($status) |
| 867 |
|
- #if($request.ajax) |
| 868 |
|
- $services.localization.render($text, $!parameters) |
| 869 |
|
- #else |
| 870 |
|
- {{error}}$services.localization.render($text, $!parameters){{/error}} |
| 871 |
|
- #end |
| 872 |
|
-#end |
| 873 |
|
- |
| 874 |
|
-#macro(displayBlogPostsBasedOnContext $targetDoc $postsVisiblity $layout $layoutParams $limit) |
| 875 |
|
- #if ($layout == 'link') |
| 876 |
|
- #set ($macro.paginated = 'no') |
| 877 |
|
- #end |
| 878 |
|
- #if ($targetDoc.space == $defaultBlogSpace && !$targetDoc.getObject($blogCategoryClassname)) |
| 879 |
|
- ## Display all posts that are in the default blog space('Blog') or in category 'Blog.%' |
| 880 |
|
- #getBlogPostsLayout($xwiki.getDocument("${defaultBlogSpace}.WebHome") $postsLayout) |
| 881 |
|
- #if ("$!layout" == '') |
| 882 |
|
- #set ($layout = $postsLayout) |
| 883 |
|
- #end |
| 884 |
|
- #if ($postsVisiblity == 'recent') |
| 885 |
|
- {{blogpostlist blog="${defaultBlogSpace.replaceAll('~', '~~').replaceAll('"', '~"')}.WebHome" published='yes' hidden='no' layout="$!layout.replaceAll('~', '~~').replaceAll('"', '~"')" layoutParams="$!layoutParams.replaceAll('~', '~~').replaceAll('"', '~"')" paginated="$!macro.paginated" limit="$limit" /}} |
| 886 |
|
- #elseif($postsVisiblity == 'unpublished') |
| 887 |
|
- {{blogpostlist blog="${defaultBlogSpace.replaceAll('~', '~~').replaceAll('"', '~"')}.WebHome" published='no' layout="$!layout.replaceAll('~', '~~').replaceAll('"', '~"')" layoutParams="$!layoutParams.replaceAll('~', '~~').replaceAll('"', '~"')" paginated="$!macro.paginated" limit="$limit" /}} |
| 888 |
|
- #end |
| 889 |
|
- #elseif($targetDoc.getObject($blogCategoryClassname)) |
| 890 |
|
- ## Display all posts that are in a category aCategorySpace.aCategory |
| 891 |
|
- #getBlogDocumentForCategoriesSpace($targetDoc.space $blogDoc) |
| 892 |
|
- #getBlogPostsLayout($blogDoc $postsLayout) |
| 893 |
|
- #if ("$!layout" == '') |
| 894 |
|
- #set ($layout = $postsLayout) |
| 895 |
|
- #end |
| 896 |
|
- #if ($postsVisiblity == 'recent') |
| 897 |
|
- {{blogpostlist category="$targetDoc.fullName.replaceAll('~', '~~').replaceAll('"', '~"')" published='yes' hidden='no' layout="$!layout.replaceAll('~', '~~').replaceAll('"', '~"')" layoutParams="$!layoutParams.replaceAll('~', '~~').replaceAll('"', '~"')" paginated="$!macro.paginated" limit="$limit" /}} |
| 898 |
|
- #elseif($postsVisiblity == 'unpublished') |
| 899 |
|
- {{blogpostlist category="$targetDoc.fullName.replaceAll('~', '~~').replaceAll('"', '~"')" published='no' layout="$!layout.replaceAll('~', '~~').replaceAll('"', '~"')" layoutParams="$!layoutParams.replaceAll('~', '~~').replaceAll('"', '~"')" paginated="$!macro.paginated" limit="$limit" /}} |
| 900 |
|
- #end |
| 901 |
|
- #elseif($targetDoc.getObject('XWiki.DocumentSheetBinding').sheet == 'Blog.CategoriesSheet') |
| 902 |
|
- ## Display all posts that are in a category aCategorySpace.% |
| 903 |
|
- #getBlogDocumentForCategoriesSpace($targetDoc.space $blogDoc) |
| 904 |
|
- #getBlogPostsLayout($blogDoc $postsLayout) |
| 905 |
|
- #if ("$!layout" == '') |
| 906 |
|
- #set ($layout = $postsLayout) |
| 907 |
|
- #end |
| 908 |
|
- #if ($postsVisiblity == 'recent') |
| 909 |
|
- {{blogpostlist category="$targetDoc.space.replaceAll('~', '~~').replaceAll('"', '~"')" published='yes' hidden='no' layout="$!layout.replaceAll('~', '~~').replaceAll('"', '~"')" layoutParams="$!layoutParams.replaceAll('~', '~~').replaceAll('"', '~"')" paginated="$!macro.paginated" limit="$limit" /}} |
| 910 |
|
- #elseif($postsVisiblity == 'unpublished') |
| 911 |
|
- {{blogpostlist category="$targetDoc.space.replaceAll('~', '~~').replaceAll('"', '~"')" published='no' layout="$!layout.replaceAll('~', '~~').replaceAll('"', '~"')" layoutParams="$!layoutParams.replaceAll('~', '~~').replaceAll('"', '~"')" paginated="$!macro.paginated" limit="$limit" /}} |
| 912 |
|
- #end |
| 913 |
|
- #else |
| 914 |
|
- ## Display all posts in blog space aBlog |
| 915 |
|
- #getBlogDocument($targetDoc.space $blogDoc) |
| 916 |
|
- #getBlogPostsLayout($blogDoc $postsLayout) |
| 917 |
|
- #if ("$!layout" == '') |
| 918 |
|
- #set ($layout = $postsLayout) |
| 919 |
|
- #end |
| 920 |
|
- #if ($postsVisiblity == 'recent') |
| 921 |
|
- {{blogpostlist blog="$blogDoc.fullName.replaceAll('~', '~~').replaceAll('"', '~"')" published='yes' hidden='no' layout="$!layout.replaceAll('~', '~~').replaceAll('"', '~"')" paginated="$!macro.paginated" limit="$limit" /}} |
| 922 |
|
- #elseif($postsVisiblity == 'unpublished') |
| 923 |
|
- {{blogpostlist blog="$blogDoc.fullName.replaceAll('~', '~~').replaceAll('"', '~"')" published='no' layout="$!layout.replaceAll('~', '~~').replaceAll('"', '~"')" layoutParams="$!layoutParams.replaceAll('~', '~~').replaceAll('"', '~"')" paginated="$!macro.paginated" limit="$limit" /}} |
| 924 |
|
- #end |
| 925 |
|
- #end |
| 926 |
|
-#end |
| 927 |
|
- |
| 928 |
|
-#macro(displayEntryBlogLocation $entryDoc $entryObj) |
| 929 |
|
- #getBlogPostsLocation($entryDoc.getSpace() $blogPostsLocation) ## |
| 930 |
|
- #if("$!blogPostsLocation" != "") ## |
| 931 |
|
- #set($blogSpaceRef = $services.model.resolveSpace($blogPostsLocation)) ## |
| 932 |
|
- #set($blogDocRef = $services.model.createDocumentReference($services.model.getEntityReference('DOCUMENT', 'default').getName(), $blogSpaceRef)) ## |
| 933 |
|
- #if($doc.documentReference != $blogDocRef) ## |
| 934 |
|
- #set($blogDoc = $xwiki.getDocument($blogDocRef)) ## |
| 935 |
|
- #set($blogObj = $blogDoc.getObject('Blog.BlogClass')) ## |
| 936 |
|
- #if($blogObj) (% class="blogrefpath" %)((( ## |
| 937 |
|
- $services.localization.render('blog.code.postedin') {{html clean="false" wiki="false"}} #hierarchy($blogDocRef, {'selfIsActive' : true, 'local': true}) {{/html}} ## |
| 938 |
|
- )))(%%)## |
| 939 |
|
- #end |
| 940 |
|
- #end |
| 941 |
|
- #end |
| 942 |
|
-#end |
| 943 |
|
- |
| 944 |
|
-#macro(getAllBlogPostsQuery $query) |
| 945 |
|
- #set ($query = $NULL) |
| 946 |
|
- #setVariable("$query" ", BaseObject as obj, IntegerProperty isPublished, |
| 947 |
|
- IntegerProperty hidden, DateProperty publishDate |
| 948 |
|
- where doc.fullName <> '$blogPostTemplate' and |
| 949 |
|
- obj.name=doc.fullName and obj.className='$blogPostClassname' and |
| 950 |
|
- isPublished.id.id = obj.id and isPublished.id.name = 'published' and |
| 951 |
|
- hidden.id.id = obj.id and hidden.id.name='hidden' and |
| 952 |
|
- publishDate.id.id = obj.id and publishDate.id.name='publishDate' and |
| 953 |
|
- (doc.creator = '$escapetool.sql($xcontext.user)' or (isPublished.value = 1 and hidden.value = 0))") |
| 954 |
|
-#end |
| 955 |
|
- |
| 956 |
|
-#macro(getAllBlogPostsQueryBasedOnDisplayContext $targetDoc $query $queryParams) |
| 957 |
|
- #set ($query = $NULL) |
| 958 |
|
- #set ($queryParams = $NULL) |
| 959 |
|
- #getCategoryAllBlogPostsQuery($resultQuery) |
| 960 |
|
- #set ($resultQueryParams = {}) |
| 961 |
|
- #set($sanitizedSpace = $targetDoc.space.replaceAll('([%_!])', '!$1').concat('.%')) |
| 962 |
|
- #if ($targetDoc.space == $defaultBlogSpace && !$targetDoc.getObject($blogCategoryClassname)) |
| 963 |
|
- ## Get all posts that are in the default blog space('Blog') or in category 'Blog.%' |
| 964 |
|
- #set ($discard = $resultQueryParams.put('space', $targetDoc.space)) |
| 965 |
|
- #set ($discard = $resultQueryParams.put('catList', $sanitizedSpace)) |
| 966 |
|
- #set($resultQuery = "${resultQuery} and (doc.space = :space or catList like :catList escape '!')") |
| 967 |
|
- #elseif($targetDoc.getObject($blogCategoryClassname)) |
| 968 |
|
- ## Get all posts that are in a category aCategorySpace.aCategory |
| 969 |
|
- #set ($discard = $resultQueryParams.put('catList', $targetDoc.fullName)) |
| 970 |
|
- #set($resultQuery = "${resultQuery} and (catList=:catList)") |
| 971 |
|
- #elseif($targetDoc.getObject('XWiki.DocumentSheetBinding').sheet == 'Blog.CategoriesSheet') |
| 972 |
|
- ## Get all posts that are in a category aCategorySpace.% |
| 973 |
|
- #set ($discard = $resultQueryParams.put('catList', $sanitizedSpace)) |
| 974 |
|
- ## Exclude incategorized posts |
| 975 |
|
- #set ($excludedCategory = "${targetDoc.space}.WebHome") |
| 976 |
|
- #if ($targetDoc.space == $defaultBlogSpace) |
| 977 |
|
- #set ($excludedCategory = "Blog.Categories.WebHome") |
| 978 |
|
- #end |
| 979 |
|
- #set ($discard = $resultQueryParams.put('excludedCategory', $excludedCategory)) |
| 980 |
|
- #set($resultQuery = "${resultQuery} and (catList<>:excludedCategory) and (catList like :catList escape '!')") |
| 981 |
|
- #else |
| 982 |
|
- ## Get all posts in blog space aBlog |
| 983 |
|
- #getAllBlogPostsQuery($resultQuery) |
| 984 |
|
- #getBlogPostsLocation($targetDoc.space $postsLocation) |
| 985 |
|
- #set ($discard = $resultQueryParams.put('space', $postsLocation)) |
| 986 |
|
- #set($resultQuery = "${resultQuery} and doc.space = :space") |
| 987 |
|
- #end |
| 988 |
|
- #setVariable("$query" $resultQuery) |
| 989 |
|
- #setVariable("$queryParams" $resultQueryParams) |
| 990 |
|
-#end |
| 991 |
|
- |
| 992 |
|
-#macro(getBlogCategoriesLocation $blogSpace $categoriesLocation) |
| 993 |
|
- #getBlogDocument($blogSpace $blogDoc) |
| 994 |
|
- ## Since 9.15, category data may exist in Blog or Blog.Categories. Code supports both paths to maintain backward compatibility. |
| 995 |
|
- #set ($defaultBlogCategoryLocation = 'Blog.Categories') |
| 996 |
|
- #if ($services.blog.hasLegacyCategoryAssignments()) |
| 997 |
|
- #set ($defaultBlogCategoryLocation = 'Blog') |
| 998 |
|
- #end |
| 999 |
|
- #getBlogProperty($blogDoc 'categoriesLocation' $defaultBlogCategoryLocation $result) |
| 1000 |
|
- #set ($postsLocation = $NULL) |
| 1001 |
|
- #setVariable ("$categoriesLocation" $result) |
| 1002 |
|
-#end |
| 1003 |
|
- |
| 1004 |
|
-#macro(getBlogDocumentForCategoriesSpace $categoriesSpace $blogDoc) |
| 1005 |
|
- #set($macro.blogDocs = $services.query.hql(", BaseObject obj, StringProperty as categoriesLocationProp where obj.name = doc.fullName and obj.className = '$blogClassname' and obj.id=categoriesLocationProp.id.id and categoriesLocationProp.id.name='categoriesLocation' and categoriesLocationProp.value=:categoriesLocation order by doc.creationDate").setLimit(1).setOffset(0).bindValue('categoriesLocation', $categoriesSpace).execute()) |
| 1006 |
|
- #if($macro.blogDocs.size() > 0 && $categoriesSpace != $defaultBlogSpace) |
| 1007 |
|
- #set($macro.result = $xwiki.getDocument($macro.blogDocs.get(0))) |
| 1008 |
|
- #else |
| 1009 |
|
- ## Fallback to Blog.WebHome, the default blog |
| 1010 |
|
- #set($macro.result = $xwiki.getDocument('Blog.WebHome')) |
| 1011 |
|
- #end |
| 1012 |
|
- #set ($blogDoc = $NULL) |
| 1013 |
|
- #setVariable ("$blogDoc" $macro.result) |
| 1014 |
|
-#end |
| 1015 |
|
- |
| 1016 |
|
-#macro(getBlogPostsLayout $blogDoc $postsLayout) |
| 1017 |
|
- #getBlogProperty($blogDoc 'postsLayout' 'full' $res) |
| 1018 |
|
- #set ($postsLayout = $NULL) |
| 1019 |
|
- #setVariable ("$postsLayout" $res) |
| 1020 |
|
-#end |
| 1021 |
|
- |
| 1022 |
|
-#macro(getBlogPostsLocation $blogSpace $postsLocation) |
| 1023 |
|
- #getBlogDocument($blogSpace $blogDoc) |
| 1024 |
|
- #getBlogProperty($blogDoc 'postsLocation' $blogDoc.space $result) |
| 1025 |
|
- #set ($postsLocation = $NULL) |
| 1026 |
|
- #setVariable ("$postsLocation" $result) |
| 1027 |
|
-#end |
| 1028 |
|
- |
| 1029 |
|
-#macro(getCategoryAllBlogPostsQuery $query) |
| 1030 |
|
- #set ($query = $NULL) |
| 1031 |
|
- #getAllBlogPostsQuery($baseQuery) |
| 1032 |
|
- #set ($baseQuery = $baseQuery.replace('DateProperty publishDate', 'DateProperty publishDate, DBStringListProperty as category left join category.list catList')) |
| 1033 |
|
- #setVariable("$query" "${baseQuery} and obj.id=category.id.id and category.id.name='category'") |
| 1034 |
|
-#end |
| 1035 |
|
- |
| 1036 |
|
-#macro(isDefaultBlog $blogDoc $isDefault) |
| 1037 |
|
- #set ($result = false) |
| 1038 |
|
- #if ($blogDoc.space == 'Blog') |
| 1039 |
|
- #set ($result = true) |
| 1040 |
|
- #end |
| 1041 |
|
- #setVariable("$isDefault" $result) |
| 1042 |
|
-#end |
| 1043 |
|
- |
| 1044 |
|
-{{/velocity}} |
| 1045 |
|
- |