Änderungen von Dokument Confluence Gallery Macro
Zuletzt geändert von xwikiadmin am 2025/12/11 06:32
Von Version 2.1
bearbeitet von xwikiadmin
am 2022/08/11 16:51
am 2022/08/11 16:51
Änderungskommentar:
Migrated property [defaultCategories] from class [XWiki.WikiMacroClass]
Auf Version 3.1
bearbeitet von xwikiadmin
am 2023/04/25 11:49
am 2023/04/25 11:49
Änderungskommentar:
Install extension [com.xwiki.pro:xwiki-pro-macros/1.7.1]
Zusammenfassung
-
Objekte (1 geändert, 0 hinzugefügt, 0 gelöscht)
Details
- XWiki.WikiMacroClass[0]
-
- Makro-Code
-
... ... @@ -1,56 +1,73 @@ 1 -{{velocity}} 2 -## Get the parameters and put them in lists if necessary 3 -#set ($title = $wikimacro.parameters.title) 4 -#set ($includeString = $wikimacro.parameters.include) 5 -#set ($excludeString = $wikimacro.parameters.exclude) 6 -#set ($pagesString = $wikimacro.parameters.page) 7 -#set ($include = $includeString.split(',')) 8 -#set ($exclude = $excludeString.split(',')) 9 -#set ($pages = $pagesString.split(',')) 10 -## Display the gallery title if it is set (newlines are needed for the following macro calls to be standalone) 11 -#if ("$!title" != '') 12 - ==$title== 13 -#end 14 -## add the current page to the page list if no pages were given 15 -#if ("$!pagesString" == '') 16 - #set ($pages = [$doc.getTitle()]) 17 -#end 18 -## Collect the attachments to display 19 -#set ($attachments = []) 20 -#foreach ($page in $pages) 21 - ## Resolve page and put attachments in temporary list 22 - #set ($tempAttachments = []) 23 - #set ($query = $services.query.xwql('where doc.title = :name').bindValue('name', $page)) 24 - #set ($pageStrings = $query.execute()) 25 - #if ($pageStrings.size() > 0) 26 - #set ($pageDocument = $xwiki.getDocument($pageStrings[0])) 27 - #set ($discard = $tempAttachments.addAll($pageDocument.getAttachmentList())) 28 - ## iterate over remaining attachments and add full reference to attachment list 29 - #foreach ($attachment in $tempAttachments) 30 - #if ($attachment.isImage()) 31 - ## If includes or excludes are set, only get the desired entries from the temporary attachment list 32 - #if ("$!includeString" != '') 33 - #if ($include.contains($attachment.filename)) 1 +{{velocity output="false"}} 2 +#macro (executeMacro) 3 + ## Get the parameters and put them in lists if necessary 4 + #set ($title = $wikimacro.parameters.title) 5 + #set ($includeString = $wikimacro.parameters.include) 6 + #set ($excludeString = $wikimacro.parameters.exclude) 7 + #set ($pagesString = $wikimacro.parameters.page) 8 + #set ($include = $includeString.split(',')) 9 + #set ($exclude = $excludeString.split(',')) 10 + #set ($pages = $pagesString.split(',')) 11 + ## Display the gallery title if it is set (newlines are needed for the following macro calls to be standalone) 12 + #if ("$!title" != '') 13 + ==$title== 14 + #end 15 + ## add the current page to the page list if no pages were given 16 + #if ("$!pagesString" == '') 17 + #set ($pages = [$doc.getTitle()]) 18 + #end 19 + ## Collect the attachments to display 20 + #set ($attachments = []) 21 + #foreach ($page in $pages) 22 + ## Resolve page and put attachments in temporary list 23 + #set ($tempAttachments = []) 24 + #set ($query = $services.query.xwql('where doc.title = :name').bindValue('name', $page)) 25 + #set ($pageStrings = $query.execute()) 26 + #if ($pageStrings.size() > 0) 27 + #set ($pageDocument = $xwiki.getDocument($pageStrings[0])) 28 + #set ($discard = $tempAttachments.addAll($pageDocument.getAttachmentList())) 29 + ## iterate over remaining attachments and add full reference to attachment list 30 + #foreach ($attachment in $tempAttachments) 31 + #if ($attachment.isImage()) 32 + ## If includes or excludes are set, only get the desired entries from the temporary attachment list 33 + #if ("$!includeString" != '') 34 + #if ($include.contains($attachment.filename)) 35 + #set ($discard = $attachments.add($pageDocument+'@'+$attachment.filename)) 36 + #end 37 + #elseif ("$!excludeString" != '') 38 + #if (!$exclude.contains($attachment.filename)) 39 + #set ($discard = $attachments.add($pageDocument+'@'+$attachment.filename)) 40 + #end 41 + #else 34 34 #set ($discard = $attachments.add($pageDocument+'@'+$attachment.filename)) 35 35 #end 36 - #elseif ("$!excludeString" != '') 37 - #if (!$exclude.contains($attachment.filename)) 38 - #set ($discard = $attachments.add($pageDocument+'@'+$attachment.filename)) 39 - #end 40 - #else 41 - #set ($discard = $attachments.add($pageDocument+'@'+$attachment.filename)) 42 42 #end 43 43 #end 44 44 #end 45 45 #end 46 -#end 47 -## Display the attachments in the gallery 48 -#if ($attachments.size() > 0) 49 - {{gallery}} 50 - #foreach ($attachment in $attachments) 51 - [[image:$attachment]] 48 + ## Display the attachments in the gallery 49 + #if ($attachments.size() > 0) 50 + {{gallery}} 51 + #foreach ($attachment in $attachments) 52 + [[image:$attachment]] 53 + #end 54 + {{/gallery}} 52 52 #end 53 - {{/gallery}} 54 54 #end 55 55 {{/velocity}} 56 56 59 +{{include reference="Licenses.Code.VelocityMacros"/}} 60 + 61 +{{velocity}} 62 +## We need to check if there is a valid license because the macro is registered even if the user doesn't have view right 63 +## on the macro definition page. See XWIKI-14828: Rendering macros defined in wiki pages are available to users that 64 +## don't have view right on those pages. 65 +#if ($services.licensing.licensor.hasLicensureForEntity($xcontext.macro.doc.documentReference)) 66 + #executeMacro 67 +#else 68 + {{error}} 69 + #getMissingLicenseMessage('proMacros.extension.name') 70 + {{/error}} 71 +#end 72 +{{/velocity}} 73 +