Changes for page View File
Last modified by Admin Trust-IT on 2026/05/29 08:29
From version 2.2
edited by Admin Trust-IT
on 2026/05/29 08:28
on 2026/05/29 08:28
Change comment:
There is no comment for this version
Summary
-
Objects (3 modified, 2 added, 0 removed)
Details
- XWiki.WikiMacroClass[0]
-
- Macro code
-
... ... @@ -1,12 +1,28 @@ 1 -{{velocity}} 2 -#set($fileName = $xcontext.macro.params.get('att--filename')) 3 -#if("$!fileName" == "") 4 - #set($fileName = $xcontext.macro.params.name) 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)) 5 5 #end 6 - 7 -#if("$!fileName" != "") 8 - [[image:icon:attach]] [[$fileName>>attach:$fileName]] 8 +#set($attDoc = $xwiki.getDocument($docRef)) 9 +#set($att = $attDoc.getAttachment($attName)) 10 +#if(!$att) 11 + {{warning}}Allegato "$!attName" non trovato.{{/warning}} 9 9 #else 10 - //Attachment not specified// 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 11 11 #end 12 -{{/velocity}} - Execution is isolated
-
... ... @@ -1,1 +1,0 @@ 1 -No
- XWiki.WikiMacroParameterClass[1]
-
- Parameter description
-
... ... @@ -1,1 +1,1 @@ 1 - Attachmentname1 +Nome dell'allegato da mostrare. - Parameter mandatory
-
... ... @@ -1,1 +1,1 @@ 1 - No1 +Yes
- XWiki.WikiMacroParameterClass[2]
-
- Parameter description
-
... ... @@ -1,0 +1,1 @@ 1 +Pagina che contiene l'allegato (default: pagina corrente). - Parameter mandatory
-
... ... @@ -1,0 +1,1 @@ 1 +No - Parameter name
-
... ... @@ -1,1 +1,1 @@ 1 -a tt--filename1 +page
- XWiki.WikiMacroParameterClass[3]
-
- Parameter description
-
... ... @@ -1,0 +1,1 @@ 1 +Larghezza (default 100%). - Parameter mandatory
-
... ... @@ -1,0 +1,1 @@ 1 +No - Parameter name
-
... ... @@ -1,0 +1,1 @@ 1 +width
- XWiki.WikiMacroParameterClass[4]
-
- Parameter description
-
... ... @@ -1,0 +1,1 @@ 1 +Altezza (default 600px). - Parameter mandatory
-
... ... @@ -1,0 +1,1 @@ 1 +No - Parameter name
-
... ... @@ -1,0 +1,1 @@ 1 +height