Changes for page View File

Last modified by Admin Trust-IT on 2026/05/29 08:29

From version 1.1
edited by Admin Trust-IT
on 2026/05/29 07:35
Change comment: Imported from XAR
To version 1.2
edited by Admin Trust-IT
on 2026/05/29 07:46
Change comment: There is no comment for this version

Summary

Details

XWiki.WikiMacroClass[0]
Macro code
... ... @@ -1,28 +1,10 @@
1 -#set($attName = $xcontext.macro.params.name)
2 -#set($targetPage = $xcontext.macro.params.page)
3 -#if("$!targetPage" == '')
4 - #set($docRef = $doc.documentReference)
5 -#else
6 - #set($docRef = $services.model.resolveDocument($targetPage))
1 +#set($fileName = $xcontext.macro.params.get('att--filename'))
2 +#if("$!fileName" == "")
3 + #set($fileName = $xcontext.macro.params.name)
7 7  #end
8 -#set($attDoc = $xwiki.getDocument($docRef))
9 -#set($att = $attDoc.getAttachment($attName))
10 -#if(!$att)
11 - {{warning}}Allegato "$!attName" non trovato.{{/warning}}
5 +
6 +#if("$!fileName" != "")
7 + [[image:icon:attach]] [[$fileName>>attach:$fileName]]
12 12  #else
13 - #set($url = $attDoc.getAttachmentURL($attName))
14 - #set($mime = $att.getMimeType())
15 - #set($w = $xcontext.macro.params.width)
16 - #set($h = $xcontext.macro.params.height)
17 - #if("$!w" == '')#set($w = '100%')#end
18 - #if("$!h" == '')#set($h = '600px')#end
19 - #if($mime.startsWith('image/'))
20 - [[image:$attName||width="$w"]]
21 - #elseif($mime == 'application/pdf')
22 - {{html clean="false"}}<iframe src="$url" width="$w" height="$h" style="border:1px solid #ccc;"></iframe>{{/html}}
23 - #elseif($mime.contains('word') || $mime.contains('excel') || $mime.contains('powerpoint') || $mime.contains('opendocument'))
24 - {{office attachment="$attName"/}}
25 - #else
26 - [[$attName>>attach:$attName]]
27 - #end
9 + //Allegato non specificato//
28 28  #end
Execution is isolated
... ... @@ -1,0 +1,1 @@
1 +No