| ... |
... |
@@ -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 |
## |
| ... |
... |
@@ -70,29 +70,45 @@ |
| 70 |
70 |
* @param blogDoc The resulting XDocument. |
| 71 |
71 |
*### |
| 72 |
72 |
#macro(getBlogDocument $space $blogDoc) |
| 73 |
|
- ## First, try the Space.WebHome, for a whole-space blog |
| 74 |
|
- #set($blogDoc = $xwiki.getDocument("${space}.WebHome")) |
| 75 |
|
- #if(!$blogDoc.getObject($blogClassname)) |
| 76 |
|
- ## Second, try the Space.Blog document |
| 77 |
|
- #set($blogDoc = $xwiki.getDocument("${space}.Blog")) |
| 78 |
|
- #if(!$blogDoc.getObject($blogClassname)) |
| 79 |
|
- ## Third, try searching for a blog document in the current space |
| 80 |
|
-#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()) |
| 81 |
|
-#set ($legacyVisiblec2c39d3a2e_1 = []) |
| 82 |
|
-#foreach ($legacyEntryc2c39d3a2e_1 in $legacyRawc2c39d3a2e_1) |
| 83 |
|
- #if ($xwiki.hasAccessLevel('view', $xcontext.user, $legacyEntryc2c39d3a2e_1)) |
| 84 |
|
- #set ($legacyVisibilityDiscard = $legacyVisiblec2c39d3a2e_1.add($legacyEntryc2c39d3a2e_1)) |
|
75 |
+ #set ($result = $NULL) |
|
76 |
+ ## Check if the current space has a WebPreferences page that contains a Blog.EnablePanelsConfigurationClass object. |
|
77 |
+ ## It is possible to display a blog's panels info in a page that is not inside a blog and in that case we need to |
|
78 |
+ ## identify the right blog based on a configuration object in a WebPreferences page. |
|
79 |
+ #set ($spaceReference = $services.model.resolveSpace($space)) |
|
80 |
+ #set ($preferencesDocRef = $services.model.createDocumentReference('WebPreferences', $spaceReference)) |
|
81 |
+ #set ($preferencesDoc = $xwiki.getDocument($preferencesDocRef)) |
|
82 |
+ #set ($preferencesObj = $preferencesDoc.getObject('Blog.EnablePanelsConfigurationClass')) |
|
83 |
+ #if ($preferencesObj) |
|
84 |
+ #set ($result = $xwiki.getDocument( $preferencesObj.getValue('blog'))) |
| 85 |
85 |
#end |
| 86 |
|
-#end |
| 87 |
|
- #set($blogDocs = $legacyVisiblec2c39d3a2e_1) |
| 88 |
|
- #if($blogDocs.size() > 0) |
| 89 |
|
- #set($blogDoc = $xwiki.getDocument($blogDocs.get(0))) |
| 90 |
|
- #else |
| 91 |
|
- ## Last, fallback to Blog.WebHome, the default blog |
| 92 |
|
- #set($blogDoc = $xwiki.getDocument('Blog.WebHome')) |
|
86 |
+ ## If no special case occurs (like the previous one), identify a blog by checking the current location from its hierarchy. |
|
87 |
+ #if ("$!result" == '') |
|
88 |
+ ## First, try the Space.WebHome, for a whole-space blog |
|
89 |
+ #set($result = $xwiki.getDocument("${space}.WebHome")) |
|
90 |
+ #if(!$result.getObject($blogClassname)) |
|
91 |
+ ## Second, try the Space.Blog document |
|
92 |
+ #set($result = $xwiki.getDocument("${space}.Blog")) |
|
93 |
+ #if(!$result.getObject($blogClassname)) |
|
94 |
+ ## Third, try searching for a blog document in the current space |
|
95 |
+ ## Prevent the query fail when the space contains dots '.' |
|
96 |
+ #set($blogDocs = $services.query.hql(", BaseObject obj where doc.space = :space and obj.name = doc.fullName and obj.className = '$blogClassname' order by doc.name").setLimit(1).setOffset(0).bindValue('space', $space).execute()) |
|
97 |
+ #if($blogDocs.size() > 0) |
|
98 |
+ #set($result = $xwiki.getDocument($blogDocs.get(0))) |
|
99 |
+ #else |
|
100 |
+ ## Fourth, try searching for a blog document that have the its 'postsLocation' set to the current space |
|
101 |
+ #set($blogDocs = $services.query.hql(", BaseObject obj, StringProperty as postsLocationProp where obj.name = doc.fullName and obj.className = '$blogClassname' and obj.id=postsLocationProp.id.id and postsLocationProp.id.name='postsLocation' and postsLocationProp.value=:postsLocation order by doc.name").setLimit(1).setOffset(0).bindValue('postsLocation', $space).execute()) |
|
102 |
+ #if($blogDocs.size() > 0) |
|
103 |
+ #set($result = $xwiki.getDocument($blogDocs.get(0))) |
|
104 |
+ #else |
|
105 |
+ ## Last, fallback to Blog.WebHome, the default blog |
|
106 |
+ #set($result = $xwiki.getDocument('Blog.WebHome')) |
|
107 |
+ #end |
|
108 |
+ #end |
| 93 |
93 |
#end |
| 94 |
94 |
#end |
| 95 |
95 |
#end |
|
112 |
+ #set ($blogDoc = $NULL) |
|
113 |
+ #setVariable ("$blogDoc" $result) |
| 96 |
96 |
#end |
| 97 |
97 |
## |
| 98 |
98 |
## |
| ... |
... |
@@ -104,7 +104,12 @@ |
| 104 |
104 |
* @param title The resulting title. |
| 105 |
105 |
*### |
| 106 |
106 |
#macro(getBlogTitle $blogDoc $title) |
| 107 |
|
- #getBlogProperty($blogDoc 'title' $!blogDoc.displayTitle $title) |
|
125 |
+ ## The blog title is the rendered document title. It is displayed as data (never evaluated as |
|
126 |
+ ## Velocity), so an unprivileged user storing script in Blog.BlogClass.title cannot run it. See |
|
127 |
+ ## Blog.BlogSheet, which renders the title literally and falls back to the blog.code.title |
|
128 |
+ ## translation when the stored title is empty. |
|
129 |
+ #set ($title = $NULL) |
|
130 |
+ #setVariable ("$title" $!blogDoc.displayTitle) |
| 108 |
108 |
#end |
| 109 |
109 |
## |
| 110 |
110 |
## |
| ... |
... |
@@ -117,7 +117,9 @@ |
| 117 |
117 |
* @param description The resulting description. |
| 118 |
118 |
*### |
| 119 |
119 |
#macro(getBlogDescription $blogDoc $description) |
| 120 |
|
- #getBlogProperty($blogDoc 'description' '' $description) |
|
143 |
+ #getBlogProperty($blogDoc 'description' '' $result) |
|
144 |
+ #set ($description = $NULL) |
|
145 |
+ #setVariable ("$description" $result) |
| 121 |
121 |
#end |
| 122 |
122 |
## |
| 123 |
123 |
## |
| ... |
... |
@@ -313,13 +313,7 @@ |
| 313 |
313 |
* @param query The basic query for selecting blog entries. |
| 314 |
314 |
*### |
| 315 |
315 |
#macro(getBlogEntriesBaseQuery $query) |
| 316 |
|
- #set ($query = ", BaseObject obj, IntegerProperty isPublished, IntegerProperty hidden, DateProperty publishDate |
| 317 |
|
- where doc.fullName <> 'Blog.BlogPostTemplate' and |
| 318 |
|
- obj.name = doc.fullName and obj.className = '${blogPostClassname}' and |
| 319 |
|
- publishDate.id.id = obj.id and publishDate.id.name = 'publishDate' and |
| 320 |
|
- isPublished.id.id = obj.id and isPublished.id.name = 'published' and |
| 321 |
|
- hidden.id.id = obj.id and hidden.id.name = 'hidden' and |
| 322 |
|
- (doc.creator = '$context.user' or (isPublished.value = 1 and hidden.value = 0))") |
|
341 |
+ #getAllBlogPostsQuery($query) |
| 323 |
323 |
#end |
| 324 |
324 |
## |
| 325 |
325 |
## |
| ... |
... |
@@ -349,7 +349,9 @@ |
| 349 |
349 |
* @param displayType The resulting string. If the blog object does not define anything, it is considered paginated. |
| 350 |
350 |
*### |
| 351 |
351 |
#macro(getBlogDisplayType $blogDoc $displayType) |
| 352 |
|
- #getBlogProperty($blogDoc 'displayType' 'paginated' $displayType) |
|
371 |
+ #getBlogProperty($blogDoc 'displayType' 'paginated' $result) |
|
372 |
+ #set ($displayType = $NULL) |
|
373 |
+ #setVariable ("$displayType" $result) |
| 353 |
353 |
#end |
| 354 |
354 |
## |
| 355 |
355 |
## |
| ... |
... |
@@ -402,12 +402,16 @@ |
| 402 |
402 |
* @param entryDoc The xdocument of the blog post. Each post resides in its own document. |
| 403 |
403 |
* @param entryObj The resulting xobject of the blog post. |
| 404 |
404 |
*### |
| 405 |
|
-#macro(getEntryObject $entryDoc $entryObj) |
| 406 |
|
- #set($entryObj = '') |
| 407 |
|
- #set($entryObj = $entryDoc.getObject("${blogPostClassname}")) |
| 408 |
|
- #if("$!{entryObj}" == '') |
| 409 |
|
- #set($entryObj = $entryDoc.getObject("${oldArticleClassname}")) |
|
426 |
+#macro(getEntryObject $entryDoc $__entryObj) |
|
427 |
+ #set($result = $entryDoc.getObject("${blogPostClassname}")) |
|
428 |
+ #if(!$result) |
|
429 |
+ #set($result = $entryDoc.getObject("${oldArticleClassname}")) |
| 410 |
410 |
#end |
|
431 |
+ ## NOTE: The reason we put an underscore in front of the variable name is to prevent the following line from |
|
432 |
+ ## overwriting the $entryObj variable that may be defined before this macro is called. Of course, $__entryObj may be |
|
433 |
+ ## overwritten in this case but it's less likely to have such a variable defined before. |
|
434 |
+ #set ($__entryObj = $NULL) |
|
435 |
+ #setVariable ("$__entryObj" $result) |
| 411 |
411 |
#end |
| 412 |
412 |
## |
| 413 |
413 |
## |
| ... |
... |
@@ -421,7 +421,8 @@ |
| 421 |
421 |
* @param result The resulting date, an instance of <tt>java.util.Date</tt>. |
| 422 |
422 |
*### |
| 423 |
423 |
#macro(getEntryDate $entryDoc $entryObj $result) |
| 424 |
|
- #set($result = $entryObj.getProperty('publishDate').value) |
|
449 |
+ #set ($result = $NULL) |
|
450 |
+ #setVariable ("$result" $entryObj.getProperty('publishDate').value) |
| 425 |
425 |
#end |
| 426 |
426 |
## |
| 427 |
427 |
## |
| ... |
... |
@@ -841,8 +841,200 @@ |
| 841 |
841 |
* @param propertyValue The resulting value. |
| 842 |
842 |
*### |
| 843 |
843 |
#macro(getBlogProperty $blogDoc $propertyName $defaultValue $propertyValue) |
| 844 |
|
- #set($propertyValue = "$!{blogDoc.getObject(${blogClassname}).getProperty($propertyName).value}") |
| 845 |
|
- #if($propertyValue == '') |
| 846 |
|
- #set($propertyValue = $defaultValue) |
|
870 |
+ #set($result = "$!{blogDoc.getObject(${blogClassname}).getProperty($propertyName).value}") |
|
871 |
+ #if($result == '') |
|
872 |
+ #set($result = $defaultValue) |
| 847 |
847 |
#end |
|
874 |
+ #set ($propertyValue = $NULL) |
|
875 |
+ #setVariable ("$propertyValue" $result) |
| 848 |
848 |
#end |
|
877 |
+## Compatibility helpers from the installed Blog 9.15.15 package. |
|
878 |
+#macro(bindQueryParameters $queryObj $queryParams) |
|
879 |
+ #set ($output = $queryObj) |
|
880 |
+ #foreach( $key in $queryParams.keySet() ) |
|
881 |
+ #set($output = $queryObj.bindValue($key, $queryParams.get($key))) |
|
882 |
+ #end |
|
883 |
+ #setVariable("$queryObj" $output) |
|
884 |
+#end |
|
885 |
+ |
|
886 |
+#macro(blog__actionResponseError $status $text $parameters) |
|
887 |
+ $response.setStatus($status) |
|
888 |
+ #if($request.ajax) |
|
889 |
+ $services.localization.render($text, $!parameters) |
|
890 |
+ #else |
|
891 |
+ {{error}}$services.localization.render($text, $!parameters){{/error}} |
|
892 |
+ #end |
|
893 |
+#end |
|
894 |
+ |
|
895 |
+#macro(displayBlogPostsBasedOnContext $targetDoc $postsVisiblity $layout $layoutParams $limit) |
|
896 |
+ #if ($layout == 'link') |
|
897 |
+ #set ($macro.paginated = 'no') |
|
898 |
+ #end |
|
899 |
+ #if ($targetDoc.space == $defaultBlogSpace && !$targetDoc.getObject($blogCategoryClassname)) |
|
900 |
+ ## Display all posts that are in the default blog space('Blog') or in category 'Blog.%' |
|
901 |
+ #getBlogPostsLayout($xwiki.getDocument("${defaultBlogSpace}.WebHome") $postsLayout) |
|
902 |
+ #if ("$!layout" == '') |
|
903 |
+ #set ($layout = $postsLayout) |
|
904 |
+ #end |
|
905 |
+ #if ($postsVisiblity == 'recent') |
|
906 |
+ {{blogpostlist blog="${defaultBlogSpace.replaceAll('~', '~~').replaceAll('"', '~"')}.WebHome" published='yes' hidden='no' layout="$!layout.replaceAll('~', '~~').replaceAll('"', '~"')" layoutParams="$!layoutParams.replaceAll('~', '~~').replaceAll('"', '~"')" paginated="$!macro.paginated" limit="$limit" /}} |
|
907 |
+ #elseif($postsVisiblity == 'unpublished') |
|
908 |
+ {{blogpostlist blog="${defaultBlogSpace.replaceAll('~', '~~').replaceAll('"', '~"')}.WebHome" published='no' layout="$!layout.replaceAll('~', '~~').replaceAll('"', '~"')" layoutParams="$!layoutParams.replaceAll('~', '~~').replaceAll('"', '~"')" paginated="$!macro.paginated" limit="$limit" /}} |
|
909 |
+ #end |
|
910 |
+ #elseif($targetDoc.getObject($blogCategoryClassname)) |
|
911 |
+ ## Display all posts that are in a category aCategorySpace.aCategory |
|
912 |
+ #getBlogDocumentForCategoriesSpace($targetDoc.space $blogDoc) |
|
913 |
+ #getBlogPostsLayout($blogDoc $postsLayout) |
|
914 |
+ #if ("$!layout" == '') |
|
915 |
+ #set ($layout = $postsLayout) |
|
916 |
+ #end |
|
917 |
+ #if ($postsVisiblity == 'recent') |
|
918 |
+ {{blogpostlist category="$targetDoc.fullName.replaceAll('~', '~~').replaceAll('"', '~"')" published='yes' hidden='no' layout="$!layout.replaceAll('~', '~~').replaceAll('"', '~"')" layoutParams="$!layoutParams.replaceAll('~', '~~').replaceAll('"', '~"')" paginated="$!macro.paginated" limit="$limit" /}} |
|
919 |
+ #elseif($postsVisiblity == 'unpublished') |
|
920 |
+ {{blogpostlist category="$targetDoc.fullName.replaceAll('~', '~~').replaceAll('"', '~"')" published='no' layout="$!layout.replaceAll('~', '~~').replaceAll('"', '~"')" layoutParams="$!layoutParams.replaceAll('~', '~~').replaceAll('"', '~"')" paginated="$!macro.paginated" limit="$limit" /}} |
|
921 |
+ #end |
|
922 |
+ #elseif($targetDoc.getObject('XWiki.DocumentSheetBinding').sheet == 'Blog.CategoriesSheet') |
|
923 |
+ ## Display all posts that are in a category aCategorySpace.% |
|
924 |
+ #getBlogDocumentForCategoriesSpace($targetDoc.space $blogDoc) |
|
925 |
+ #getBlogPostsLayout($blogDoc $postsLayout) |
|
926 |
+ #if ("$!layout" == '') |
|
927 |
+ #set ($layout = $postsLayout) |
|
928 |
+ #end |
|
929 |
+ #if ($postsVisiblity == 'recent') |
|
930 |
+ {{blogpostlist category="$targetDoc.space.replaceAll('~', '~~').replaceAll('"', '~"')" published='yes' hidden='no' layout="$!layout.replaceAll('~', '~~').replaceAll('"', '~"')" layoutParams="$!layoutParams.replaceAll('~', '~~').replaceAll('"', '~"')" paginated="$!macro.paginated" limit="$limit" /}} |
|
931 |
+ #elseif($postsVisiblity == 'unpublished') |
|
932 |
+ {{blogpostlist category="$targetDoc.space.replaceAll('~', '~~').replaceAll('"', '~"')" published='no' layout="$!layout.replaceAll('~', '~~').replaceAll('"', '~"')" layoutParams="$!layoutParams.replaceAll('~', '~~').replaceAll('"', '~"')" paginated="$!macro.paginated" limit="$limit" /}} |
|
933 |
+ #end |
|
934 |
+ #else |
|
935 |
+ ## Display all posts in blog space aBlog |
|
936 |
+ #getBlogDocument($targetDoc.space $blogDoc) |
|
937 |
+ #getBlogPostsLayout($blogDoc $postsLayout) |
|
938 |
+ #if ("$!layout" == '') |
|
939 |
+ #set ($layout = $postsLayout) |
|
940 |
+ #end |
|
941 |
+ #if ($postsVisiblity == 'recent') |
|
942 |
+ {{blogpostlist blog="$blogDoc.fullName.replaceAll('~', '~~').replaceAll('"', '~"')" published='yes' hidden='no' layout="$!layout.replaceAll('~', '~~').replaceAll('"', '~"')" paginated="$!macro.paginated" limit="$limit" /}} |
|
943 |
+ #elseif($postsVisiblity == 'unpublished') |
|
944 |
+ {{blogpostlist blog="$blogDoc.fullName.replaceAll('~', '~~').replaceAll('"', '~"')" published='no' layout="$!layout.replaceAll('~', '~~').replaceAll('"', '~"')" layoutParams="$!layoutParams.replaceAll('~', '~~').replaceAll('"', '~"')" paginated="$!macro.paginated" limit="$limit" /}} |
|
945 |
+ #end |
|
946 |
+ #end |
|
947 |
+#end |
|
948 |
+ |
|
949 |
+#macro(displayEntryBlogLocation $entryDoc $entryObj) |
|
950 |
+ #getBlogPostsLocation($entryDoc.getSpace() $blogPostsLocation) ## |
|
951 |
+ #if("$!blogPostsLocation" != "") ## |
|
952 |
+ #set($blogSpaceRef = $services.model.resolveSpace($blogPostsLocation)) ## |
|
953 |
+ #set($blogDocRef = $services.model.createDocumentReference($services.model.getEntityReference('DOCUMENT', 'default').getName(), $blogSpaceRef)) ## |
|
954 |
+ #if($doc.documentReference != $blogDocRef) ## |
|
955 |
+ #set($blogDoc = $xwiki.getDocument($blogDocRef)) ## |
|
956 |
+ #set($blogObj = $blogDoc.getObject('Blog.BlogClass')) ## |
|
957 |
+ #if($blogObj) (% class="blogrefpath" %)((( ## |
|
958 |
+ $services.localization.render('blog.code.postedin') {{html clean="false" wiki="false"}} #hierarchy($blogDocRef, {'selfIsActive' : true, 'local': true}) {{/html}} ## |
|
959 |
+ )))(%%)## |
|
960 |
+ #end |
|
961 |
+ #end |
|
962 |
+ #end |
|
963 |
+#end |
|
964 |
+ |
|
965 |
+#macro(getAllBlogPostsQuery $query) |
|
966 |
+ #set ($query = $NULL) |
|
967 |
+ #setVariable("$query" ", BaseObject as obj, IntegerProperty isPublished, |
|
968 |
+ IntegerProperty hidden, DateProperty publishDate |
|
969 |
+ where doc.fullName <> '$blogPostTemplate' and |
|
970 |
+ obj.name=doc.fullName and obj.className='$blogPostClassname' and |
|
971 |
+ isPublished.id.id = obj.id and isPublished.id.name = 'published' and |
|
972 |
+ hidden.id.id = obj.id and hidden.id.name='hidden' and |
|
973 |
+ publishDate.id.id = obj.id and publishDate.id.name='publishDate' and |
|
974 |
+ (doc.creator = '$escapetool.sql($xcontext.user)' or (isPublished.value = 1 and hidden.value = 0))") |
|
975 |
+#end |
|
976 |
+ |
|
977 |
+#macro(getAllBlogPostsQueryBasedOnDisplayContext $targetDoc $query $queryParams) |
|
978 |
+ #set ($query = $NULL) |
|
979 |
+ #set ($queryParams = $NULL) |
|
980 |
+ #getCategoryAllBlogPostsQuery($resultQuery) |
|
981 |
+ #set ($resultQueryParams = {}) |
|
982 |
+ #set($sanitizedSpace = $targetDoc.space.replaceAll('([%_!])', '!$1').concat('.%')) |
|
983 |
+ #if ($targetDoc.space == $defaultBlogSpace && !$targetDoc.getObject($blogCategoryClassname)) |
|
984 |
+ ## Get all posts that are in the default blog space('Blog') or in category 'Blog.%' |
|
985 |
+ #set ($discard = $resultQueryParams.put('space', $targetDoc.space)) |
|
986 |
+ #set ($discard = $resultQueryParams.put('catList', $sanitizedSpace)) |
|
987 |
+ #set($resultQuery = "${resultQuery} and (doc.space = :space or catList like :catList escape '!')") |
|
988 |
+ #elseif($targetDoc.getObject($blogCategoryClassname)) |
|
989 |
+ ## Get all posts that are in a category aCategorySpace.aCategory |
|
990 |
+ #set ($discard = $resultQueryParams.put('catList', $targetDoc.fullName)) |
|
991 |
+ #set($resultQuery = "${resultQuery} and (catList=:catList)") |
|
992 |
+ #elseif($targetDoc.getObject('XWiki.DocumentSheetBinding').sheet == 'Blog.CategoriesSheet') |
|
993 |
+ ## Get all posts that are in a category aCategorySpace.% |
|
994 |
+ #set ($discard = $resultQueryParams.put('catList', $sanitizedSpace)) |
|
995 |
+ ## Exclude incategorized posts |
|
996 |
+ #set ($excludedCategory = "${targetDoc.space}.WebHome") |
|
997 |
+ #if ($targetDoc.space == $defaultBlogSpace) |
|
998 |
+ #set ($excludedCategory = "Blog.Categories.WebHome") |
|
999 |
+ #end |
|
1000 |
+ #set ($discard = $resultQueryParams.put('excludedCategory', $excludedCategory)) |
|
1001 |
+ #set($resultQuery = "${resultQuery} and (catList<>:excludedCategory) and (catList like :catList escape '!')") |
|
1002 |
+ #else |
|
1003 |
+ ## Get all posts in blog space aBlog |
|
1004 |
+ #getAllBlogPostsQuery($resultQuery) |
|
1005 |
+ #getBlogPostsLocation($targetDoc.space $postsLocation) |
|
1006 |
+ #set ($discard = $resultQueryParams.put('space', $postsLocation)) |
|
1007 |
+ #set($resultQuery = "${resultQuery} and doc.space = :space") |
|
1008 |
+ #end |
|
1009 |
+ #setVariable("$query" $resultQuery) |
|
1010 |
+ #setVariable("$queryParams" $resultQueryParams) |
|
1011 |
+#end |
|
1012 |
+ |
|
1013 |
+#macro(getBlogCategoriesLocation $blogSpace $categoriesLocation) |
|
1014 |
+ #getBlogDocument($blogSpace $blogDoc) |
|
1015 |
+ ## Since 9.15, category data may exist in Blog or Blog.Categories. Code supports both paths to maintain backward compatibility. |
|
1016 |
+ #set ($defaultBlogCategoryLocation = 'Blog.Categories') |
|
1017 |
+ #if ($services.blog.hasLegacyCategoryAssignments()) |
|
1018 |
+ #set ($defaultBlogCategoryLocation = 'Blog') |
|
1019 |
+ #end |
|
1020 |
+ #getBlogProperty($blogDoc 'categoriesLocation' $defaultBlogCategoryLocation $result) |
|
1021 |
+ #set ($postsLocation = $NULL) |
|
1022 |
+ #setVariable ("$categoriesLocation" $result) |
|
1023 |
+#end |
|
1024 |
+ |
|
1025 |
+#macro(getBlogDocumentForCategoriesSpace $categoriesSpace $blogDoc) |
|
1026 |
+ #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()) |
|
1027 |
+ #if($macro.blogDocs.size() > 0 && $categoriesSpace != $defaultBlogSpace) |
|
1028 |
+ #set($macro.result = $xwiki.getDocument($macro.blogDocs.get(0))) |
|
1029 |
+ #else |
|
1030 |
+ ## Fallback to Blog.WebHome, the default blog |
|
1031 |
+ #set($macro.result = $xwiki.getDocument('Blog.WebHome')) |
|
1032 |
+ #end |
|
1033 |
+ #set ($blogDoc = $NULL) |
|
1034 |
+ #setVariable ("$blogDoc" $macro.result) |
|
1035 |
+#end |
|
1036 |
+ |
|
1037 |
+#macro(getBlogPostsLayout $blogDoc $postsLayout) |
|
1038 |
+ #getBlogProperty($blogDoc 'postsLayout' 'full' $res) |
|
1039 |
+ #set ($postsLayout = $NULL) |
|
1040 |
+ #setVariable ("$postsLayout" $res) |
|
1041 |
+#end |
|
1042 |
+ |
|
1043 |
+#macro(getBlogPostsLocation $blogSpace $postsLocation) |
|
1044 |
+ #getBlogDocument($blogSpace $blogDoc) |
|
1045 |
+ #getBlogProperty($blogDoc 'postsLocation' $blogDoc.space $result) |
|
1046 |
+ #set ($postsLocation = $NULL) |
|
1047 |
+ #setVariable ("$postsLocation" $result) |
|
1048 |
+#end |
|
1049 |
+ |
|
1050 |
+#macro(getCategoryAllBlogPostsQuery $query) |
|
1051 |
+ #set ($query = $NULL) |
|
1052 |
+ #getAllBlogPostsQuery($baseQuery) |
|
1053 |
+ #set ($baseQuery = $baseQuery.replace('DateProperty publishDate', 'DateProperty publishDate, DBStringListProperty as category left join category.list catList')) |
|
1054 |
+ #setVariable("$query" "${baseQuery} and obj.id=category.id.id and category.id.name='category'") |
|
1055 |
+#end |
|
1056 |
+ |
|
1057 |
+#macro(isDefaultBlog $blogDoc $isDefault) |
|
1058 |
+ #set ($result = false) |
|
1059 |
+ #if ($blogDoc.space == 'Blog') |
|
1060 |
+ #set ($result = true) |
|
1061 |
+ #end |
|
1062 |
+ #setVariable("$isDefault" $result) |
|
1063 |
+#end |
|
1064 |
+ |
|
1065 |
+{{/velocity}} |
|
1066 |
+ |