Hi Dan, On Nov 24, 2008, at 12:43 PM, Dan Miron wrote:
Hi folks,
I could use some hints regarding this issue: My macro looks something like this:
public class UseravatarMacro extends AbstractMacro<UseravatarMacroParameters> { /** * The description of the macro. */ private static final String DESCRIPTION = "Allows displaying the avatar for a specific user.";
/** * Injected by the Component Manager. */ private DocumentAccessBridge documentAccessBridge;
//....................................................................
public List<Block> execute(UseravatarMacroParameters parameters, String content, MacroTransformationContext context) throws MacroExecutionException { String atachment = null; String userName = parameters.getUsername(); Block resultedBlock = null;
try { atachment = documentAccessBridge.getProperty(userName, "XWiki.XWikiUsers", "avatar"); Image image = new Image(userName, atachment); resultedBlock = new ImageBlock(image, false); } catch {
//.................................................................... } return Collections.singletonList(resultedBlock);
}
//....................................................................
}
Now, the problem is that, if the user doesn't have an avatar, I need to display the default one (noavatar.png) from the current skin. In velocity, it was something like this: $xwiki.getSkinFile("noavatar.png").
You need to add some skin API in the component bridge (in a new class IMO). Thanks -Vincent
Any ideas on how to get the current XWikiContext in my macro in order to be able to access the skin?
Tnx.