Last modified by superadmin on 2026/12/02 07:12

From version Icon 6.1
edited by superadmin
on 2026/12/02 07:12
Change comment: There is no comment for this version
To version Icon 4.1 Icon
edited by superadmin
on 2026/12/02 00:14
Change comment: There is no comment for this version

Summary

Details

Icon Page properties
Syntax
... ... @@ -1,1 +1,1 @@
1 -XWiki 2.1
1 +XWiki 1.0
Content
... ... @@ -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  ##
... ... @@ -72,45 +72,29 @@
72 72   * @param blogDoc The resulting XDocument.
73 73   *###
74 74  #macro(getBlogDocument $space $blogDoc)
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')))
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))
85 85   #end
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
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'))
109 109   #end
110 110   #end
111 111   #end
112 - #set ($blogDoc = $NULL)
113 - #setVariable ("$blogDoc" $result)
114 114  #end
115 115  ##
116 116  ##
... ... @@ -122,12 +122,7 @@
122 122   * @param title The resulting title.
123 123   *###
124 124  #macro(getBlogTitle $blogDoc $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)
107 + #getBlogProperty($blogDoc 'title' $!blogDoc.displayTitle $title)
131 131  #end
132 132  ##
133 133  ##
... ... @@ -140,9 +140,7 @@
140 140   * @param description The resulting description.
141 141   *###
142 142  #macro(getBlogDescription $blogDoc $description)
143 - #getBlogProperty($blogDoc 'description' '' $result)
144 - #set ($description = $NULL)
145 - #setVariable ("$description" $result)
120 + #getBlogProperty($blogDoc 'description' '' $description)
146 146  #end
147 147  ##
148 148  ##
... ... @@ -368,9 +368,7 @@
368 368   * @param displayType The resulting string. If the blog object does not define anything, it is considered paginated.
369 369   *###
370 370  #macro(getBlogDisplayType $blogDoc $displayType)
371 - #getBlogProperty($blogDoc 'displayType' 'paginated' $result)
372 - #set ($displayType = $NULL)
373 - #setVariable ("$displayType" $result)
346 + #getBlogProperty($blogDoc 'displayType' 'paginated' $displayType)
374 374  #end
375 375  ##
376 376  ##
... ... @@ -423,16 +423,12 @@
423 423   * @param entryDoc The xdocument of the blog post. Each post resides in its own document.
424 424   * @param entryObj The resulting xobject of the blog post.
425 425   *###
426 -#macro(getEntryObject $entryDoc $__entryObj)
427 - #set($result = $entryDoc.getObject("${blogPostClassname}"))
428 - #if(!$result)
429 - #set($result = $entryDoc.getObject("${oldArticleClassname}"))
399 +#macro(getEntryObject $entryDoc $entryObj)
400 + #set($entryObj = '')
401 + #set($entryObj = $entryDoc.getObject("${blogPostClassname}"))
402 + #if("$!{entryObj}" == '')
403 + #set($entryObj = $entryDoc.getObject("${oldArticleClassname}"))
430 430   #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)
436 436  #end
437 437  ##
438 438  ##
... ... @@ -446,8 +446,7 @@
446 446   * @param result The resulting date, an instance of <tt>java.util.Date</tt>.
447 447   *###
448 448  #macro(getEntryDate $entryDoc $entryObj $result)
449 - #set ($result = $NULL)
450 - #setVariable ("$result" $entryObj.getProperty('publishDate').value)
418 + #set($result = $entryObj.getProperty('publishDate').value)
451 451  #end
452 452  ##
453 453  ##
... ... @@ -867,12 +867,10 @@
867 867   * @param propertyValue The resulting value.
868 868   *###
869 869  #macro(getBlogProperty $blogDoc $propertyName $defaultValue $propertyValue)
870 - #set($result = "$!{blogDoc.getObject(${blogClassname}).getProperty($propertyName).value}")
871 - #if($result == '')
872 - #set($result = $defaultValue)
838 + #set($propertyValue = "$!{blogDoc.getObject(${blogClassname}).getProperty($propertyName).value}")
839 + #if($propertyValue == '')
840 + #set($propertyValue = $defaultValue)
873 873   #end
874 - #set ($propertyValue = $NULL)
875 - #setVariable ("$propertyValue" $result)
876 876  #end
877 877  ## Compatibility helpers from the installed Blog 9.15.15 package.
878 878  #macro(bindQueryParameters $queryObj $queryParams)
... ... @@ -1062,5 +1062,3 @@
1062 1062   #setVariable("$isDefault" $result)
1063 1063  #end
1064 1064  
1065 -{{/velocity}}
1066 -

#includeMacros("Blog.BlogCode")
#getBlogEntriesBaseQuery($query)
#set($query = "$!{query} and isPublished.value = 1")
#set($recentEntries = $xwiki.searchDocuments("${query} order by publishDate.value desc", 10, 0))
#if($recentEntries.size() > 0 || $showEmptyPanels)
  #panelheader('Recent Blog Posts')
  #foreach($entryDoc in $xwiki.wrapDocs($recentEntries))
    #getEntryObject($entryDoc $entryObj)

  • [$!{entryDoc.display('title', 'view', $entryObj)}>$!{entryDoc.fullName}]
      #end
      #panelfooter()
    #end

#includeMacros("Blog.BlogCode")
#getBlogEntriesBaseQuery($query)
#set($query = "$!{query} and isPublished.value = 0")
#set($unpublishedEntries = $xwiki.searchDocuments("${query} order by publishDate.value desc", 5, 0))
#if($unpublishedEntries.size() > 0 || $showEmptyPanels)
  #panelheader("Unpublished Posts")
  #foreach($entryDoc in $xwiki.wrapDocs($unpublishedEntries))
    #getEntryObject($entryDoc $entryObj)

  • [$!{entryDoc.display('title', 'view', $entryObj)}>$!{entryDoc.fullName}]
      #end
      [View all ($xwiki.countDocuments($query))>Blog.Unpublished]
      #panelfooter()
    #end

#includeMacros("Blog.CategoriesCode")
#panelheader('Blog Categories')
#getCategoriesHierarchy('Blog' $tree)
#displayCategoriesHierarchy($tree 'simple')
#if($xwiki.hasAdminRights())
  <div style="font-size:75%;">(<a href="$xwiki.getURL('Blog.ManageCategories')">Edit Categories</a>)</div>
#end
#panelfooter()

{{include reference="Blog.BlogCode"/}}

{{velocity}} #getAllBlogPostsQueryBasedOnDisplayContext($doc $query $queryParams) #bindQueryParameters($queryObj $queryParams) {{/velocity}}