1 25 package org.snipsnap.render.macro; 26 27 import org.radeox.util.i18n.ResourceManager; 28 import org.snipsnap.app.Application; 29 import org.snipsnap.render.macro.parameter.SnipMacroParameter; 30 31 import java.io.IOException ; 32 import java.io.Writer ; 33 import java.text.MessageFormat ; 34 import java.util.List ; 35 36 42 43 public class LoginsMacro extends ListOutputMacro { 44 public String getName() { 45 return "logins"; 46 } 47 48 public String getDescription() { 49 return ResourceManager.getString("i18n.messages", "macro.logins.description"); 50 } 51 52 public String [] getParamDescription() { 53 return ResourceManager.getString("i18n.messages", "macro.logins.description").split(";"); 54 } 55 56 public void execute(Writer writer, SnipMacroParameter params) 57 throws IllegalArgumentException , IOException { 58 59 String type = "Vertical"; 60 boolean showSize = true; 61 if (params.getLength() > 0) { 62 type = params.get("0"); 63 } 64 if (params.getLength() <= 1) { 65 List users = Application.getCurrentUsers(); 66 users.addAll(Application.getCurrentNonUsers()); 67 68 output(writer, params.getSnipRenderContext().getSnip(), 69 ResourceManager.getString("i18n.messages", "macro.logins.users"), users, "", type, showSize); 70 int guests = Application.getGuestCount(); 71 if (guests > 0) { 72 MessageFormat formatter = new MessageFormat (ResourceManager.getString("i18n.messages", "macro.logins.guests"), 73 ResourceManager.getLocale("i18n.messages")); 74 writer.write(formatter.format(new Object []{new Integer (guests)})); 75 } 76 } else { 77 throw new IllegalArgumentException ("Number of arguments does not match"); 78 } 79 } 80 } 81 | Popular Tags |