###
### Separator
###
### Insert a span containing a |
###
#macro (sep)
|
#end
###
### useravatar
###
### Display the avatar of a user, or a standard image if the user has no avatar
###
### @param username The name of the user whose avatar will be displayed
###
#macro(useravatar $username)
#if(!$picturelist)
#set($picturelist = $xwiki.hashMap)
#end
#if(!$picturelist.containsKey($username))
#set($picture = "
"))
#set($profiledoc = $xwiki.getDocument($username))
#if(!$profiledoc.isNew())
#set($profileobj = $profiledoc.getObject("XWikiUsers", 0))
#if($profiledoc.attachmentList.size() != 0)
#set($hasavatar = 0)
#if($profileobj.avatar && $profileobj.avatar != "")
#foreach ($attach in $profiledoc.attachmentList)
#if($attach.filename == $profileobj.avatar)
#set($hasavatar = 1)
#end
#end
#end
#if($hasavatar == 1)
#set($pictureurl = $profiledoc.getAttachmentURL($profileobj.avatar))
#set($picture = ""))
#end
#end
#end
$!picturelist.put($username, $picture)
#end
$picturelist.get($username)
#end
###
### mimetypeimg
###
### Display an icon according to the mimetype
###
### @param mime The reported mimetype of the file
### @param fname The name of the file
###
#macro(mimetypeimg $mime $fname)
#set($idx = $fname.lastIndexOf("."))
#set($idx = $idx + 1)
#if(($idx != 0) && ($idx != -1))
#set($ext = $fname.substring($idx))
#else
#set($ext = "")
#end
##### images
#if($mime.equals("image/svg"))
#elseif($mime.equals("application/svg+xml"))
#elseif($mime.startsWith("image/"))
##### text based
#elseif($mime.equals("text/plain"))
#elseif($mime.equals("text/html"))
#elseif($mime.equals("text/css"))
#elseif($mime.startsWith("text/"))
##### documents
#elseif($mime.equals("application/xml"))
#elseif($mime.equals("application/pdf"))
#elseif($mime.equals("application/postscript"))
#elseif($mime.equals("application/msword"))
#elseif($mime.equals("application/powerpoint"))
#elseif($mime.equals("application/x-shockwave-flash"))
##### archives
#elseif($mime.equals("application/x-tar"))
#elseif($mime.equals("application/zip"))
#elseif($mime.equals("application/x-gzip"))
#elseif($mime.equals("application/java-archive"))
##### media
#elseif($mime.startsWith("audio/"))
#elseif($mime.startsWith("video/"))
##### octet-streams extensions
#elseif($mime.equals("application/octet-stream"))
#if($ext.equals("xls"))
#elseif($ext.equals("bz") || $ext.equals("bz2") || $ext.equals("tbz"))
#elseif($ext.equals("tgz"))
#elseif($ext.equals("rar"))
#elseif($ext.equals("odp") || $ext.equals("odt") || $ext.equals("odf") || $ext.equals("sxw") || $ext.equals("stw"))
#else
#end
#elseif($mime.startsWith("application/"))
#end
#end
###
### packName
###
### Display a shorter version of a string
###
### @param name The processed string
###
#macro(packName $name)
#if(!$maxnamelength)
#set($maxnamelength = 25)
#end
#set($idx = $name.lastIndexOf("."))
#if(($idx != 0) && ($idx != -1))
#set($ext = $name.substring($idx))
#else
#set($ext = "")
#set($idx = $name.length())
#end
#set($fname = $name.substring(0, $idx))
#if($fname.length() > $maxnamelength)$fname.substring(0, $maxnamelength)~$ext#else$name#end
#end
###
### Panel header
###
### Generate the starting html code for a panel
###
### @param title The panel caption title
###
#macro(panelheader $title)