| ... |
... |
@@ -1,4 +1,6 @@ |
| 1 |
|
-#includeMacros("Blog.BlogParameters") |
|
1 |
+{{include reference="Blog.BlogParameters" author="target" /}} |
|
2 |
+ |
|
3 |
+{{velocity output="false"}} |
| 2 |
2 |
## |
| 3 |
3 |
## |
| 4 |
4 |
## |
| ... |
... |
@@ -77,7 +77,14 @@ |
| 77 |
77 |
#set($blogDoc = $xwiki.getDocument("${space}.Blog")) |
| 78 |
78 |
#if(!$blogDoc.getObject($blogClassname)) |
| 79 |
79 |
## Third, try searching for a blog document in the current space |
| 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()) |
|
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) |
| 81 |
81 |
#if($blogDocs.size() > 0) |
| 82 |
82 |
#set($blogDoc = $xwiki.getDocument($blogDocs.get(0))) |
| 83 |
83 |
#else |
| ... |
... |
@@ -97,7 +97,12 @@ |
| 97 |
97 |
* @param title The resulting title. |
| 98 |
98 |
*### |
| 99 |
99 |
#macro(getBlogTitle $blogDoc $title) |
| 100 |
|
- #getBlogProperty($blogDoc 'title' $!blogDoc.displayTitle $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) |
| 101 |
101 |
#end |
| 102 |
102 |
## |
| 103 |
103 |
## |
| ... |
... |
@@ -110,7 +110,9 @@ |
| 110 |
110 |
* @param description The resulting description. |
| 111 |
111 |
*### |
| 112 |
112 |
#macro(getBlogDescription $blogDoc $description) |
| 113 |
|
- #getBlogProperty($blogDoc 'description' '' $description) |
|
127 |
+ #getBlogProperty($blogDoc 'description' '' $result) |
|
128 |
+ #set ($description = $NULL) |
|
129 |
+ #setVariable ("$description" $result) |
| 114 |
114 |
#end |
| 115 |
115 |
## |
| 116 |
116 |
## |
| ... |
... |
@@ -161,8 +161,15 @@ |
| 161 |
161 |
#set($defaultItemsPerPage = $util.parseInt($defaultItemsPerPage)) |
| 162 |
162 |
## This macro is defined in the default macros.vm library. It also sets $itemsPerPage and $startAt. |
| 163 |
163 |
#preparePagedViewParams($totalEntries $defaultItemsPerPage) |
| 164 |
|
- #set($entries = $services.query.hql("${query} order by publishDate.value desc").setLimit($itemsPerPage).setOffset($startAt).addFilter('view').execute()) |
|
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 |
| 165 |
165 |
#end |
|
187 |
+ #set($entries = $legacyVisiblec2c39d3a2e_2) |
|
188 |
+#end |
| 166 |
166 |
## |
| 167 |
167 |
## |
| 168 |
168 |
## |
| ... |
... |
@@ -183,8 +183,15 @@ |
| 183 |
183 |
#set($maxDay = $dateFormatter.print($weekDate.toMutableDateTime().weekOfWeekyear().roundCeiling())) |
| 184 |
184 |
#set($query = "${query} and publishDate.value >= '$minDay' and publishDate.value < '$maxDay'") |
| 185 |
185 |
#set($totalEntries = $xwiki.countDocuments(${query})) |
| 186 |
|
- #set($entries = $services.query.hql("${query} order by publishDate.value desc").addFilter('view').execute()) |
|
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 |
| 187 |
187 |
#end |
|
216 |
+ #set($entries = $legacyVisiblec2c39d3a2e_3) |
|
217 |
+#end |
| 188 |
188 |
## |
| 189 |
189 |
## |
| 190 |
190 |
## |
| ... |
... |
@@ -205,8 +205,15 @@ |
| 205 |
205 |
#set($maxDay = $dateFormatter.print($monthDate.toMutableDateTime().monthOfYear().roundCeiling())) |
| 206 |
206 |
#set($query = "${query} and publishDate.value >= '$minDay' and publishDate.value < '$maxDay'") |
| 207 |
207 |
#set($totalEntries = $xwiki.countDocuments(${query})) |
| 208 |
|
- #set($entries = $services.query.hql("${query} order by publishDate.value desc").addFilter('view').execute()) |
|
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 |
| 209 |
209 |
#end |
|
245 |
+ #set($entries = $legacyVisiblec2c39d3a2e_4) |
|
246 |
+#end |
| 210 |
210 |
## |
| 211 |
211 |
## |
| 212 |
212 |
## |
| ... |
... |
@@ -220,8 +220,15 @@ |
| 220 |
220 |
*### |
| 221 |
221 |
#macro(getAllBlogEntries $blogDoc $query $entries) |
| 222 |
222 |
#set($totalEntries = $xwiki.countDocuments(${query})) |
| 223 |
|
- #set($entries = $services.query.hql("${query} order by publishDate.value desc").addFilter('view').execute()) |
|
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 |
| 224 |
224 |
#end |
|
267 |
+ #set($entries = $legacyVisiblec2c39d3a2e_5) |
|
268 |
+#end |
| 225 |
225 |
## |
| 226 |
226 |
## |
| 227 |
227 |
## |
| ... |
... |
@@ -236,8 +236,15 @@ |
| 236 |
236 |
#macro(getUnpublishedBlogEntries $blogDoc $query $entries) |
| 237 |
237 |
#set($query = "${query} and isPublished.value = 0") |
| 238 |
238 |
#set($totalEntries = $xwiki.countDocuments(${query})) |
| 239 |
|
- #set($entries = $services.query.hql("${query} order by publishDate.value desc").addFilter('view').execute()) |
|
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 |
| 240 |
240 |
#end |
|
290 |
+ #set($entries = $legacyVisiblec2c39d3a2e_6) |
|
291 |
+#end |
| 241 |
241 |
## |
| 242 |
242 |
## |
| 243 |
243 |
## |
| ... |
... |
@@ -252,8 +252,15 @@ |
| 252 |
252 |
#set($defaultItemsPerPage = 20) |
| 253 |
253 |
## This macro is defined in the default macros.vm library. It also sets $itemsPerPage and $startAt. |
| 254 |
254 |
#preparePagedViewParams($totalEntries $defaultItemsPerPage) |
| 255 |
|
- #set($entries = $services.query.hql("${query} order by publishDate.value desc").setLimit($itemsPerPage).setOffset($startAt).addFilter('view').execute()) |
|
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 |
| 256 |
256 |
#end |
|
313 |
+ #set($entries = $legacyVisiblec2c39d3a2e_7) |
|
314 |
+#end |
| 257 |
257 |
## |
| 258 |
258 |
## |
| 259 |
259 |
## |
| ... |
... |
@@ -264,13 +264,7 @@ |
| 264 |
264 |
* @param query The basic query for selecting blog entries. |
| 265 |
265 |
*### |
| 266 |
266 |
#macro(getBlogEntriesBaseQuery $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))") |
|
325 |
+ #getAllBlogPostsQuery($query) |
| 274 |
274 |
#end |
| 275 |
275 |
## |
| 276 |
276 |
## |
| ... |
... |
@@ -300,7 +300,9 @@ |
| 300 |
300 |
* @param displayType The resulting string. If the blog object does not define anything, it is considered paginated. |
| 301 |
301 |
*### |
| 302 |
302 |
#macro(getBlogDisplayType $blogDoc $displayType) |
| 303 |
|
- #getBlogProperty($blogDoc 'displayType' 'paginated' $displayType) |
|
355 |
+ #getBlogProperty($blogDoc 'displayType' 'paginated' $result) |
|
356 |
+ #set ($displayType = $NULL) |
|
357 |
+ #setVariable ("$displayType" $result) |
| 304 |
304 |
#end |
| 305 |
305 |
## |
| 306 |
306 |
## |
| ... |
... |
@@ -792,8 +792,200 @@ |
| 792 |
792 |
* @param propertyValue The resulting value. |
| 793 |
793 |
*### |
| 794 |
794 |
#macro(getBlogProperty $blogDoc $propertyName $defaultValue $propertyValue) |
| 795 |
|
- #set($propertyValue = "$!{blogDoc.getObject(${blogClassname}).getProperty($propertyName).value}") |
| 796 |
|
- #if($propertyValue == '') |
| 797 |
|
- #set($propertyValue = $defaultValue) |
|
849 |
+ #set($result = "$!{blogDoc.getObject(${blogClassname}).getProperty($propertyName).value}") |
|
850 |
+ #if($result == '') |
|
851 |
+ #set($result = $defaultValue) |
| 798 |
798 |
#end |
|
853 |
+ #set ($propertyValue = $NULL) |
|
854 |
+ #setVariable ("$propertyValue" $result) |
| 799 |
799 |
#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 |
+ |