1 25 26 package org.snipsnap.render.macro; 27 28 import org.snipsnap.render.macro.parameter.SnipMacroParameter; 29 import org.snipsnap.snip.SnipSpaceFactory; 30 import org.snipsnap.user.User; 31 import org.snipsnap.user.UserManager; 32 import org.snipsnap.user.UserManagerFactory; 33 import org.radeox.util.i18n.ResourceManager; 34 35 import java.io.IOException ; 36 import java.io.Writer ; 37 import java.util.Collection ; 38 39 40 47 48 49 public class SinceLastVisitMacro extends ListOutputMacro { 50 public String getName() { 51 return "since-last-visit"; 52 } 53 54 public String getDescription() { 55 return ResourceManager.getString("i18n.messages", "macro.sincelastvisit.description"); 56 } 57 58 public String [] getParamDescription() { 59 return ResourceManager.getString("i18n.messages", "macro.sincelastvisit.params").split(";"); 60 } 61 62 public void execute(Writer writer, SnipMacroParameter params) 63 throws IllegalArgumentException , IOException { 64 String type = null; 65 boolean showSize = true; 66 String userName = null; 67 if (params.getLength() > 0) { 68 userName = params.get("0"); 69 } 70 if (params.getLength() > 1) { 71 type = params.get("1"); 72 } 73 74 if (params.getLength() > 0) { 75 User user = UserManagerFactory.getInstance().load(userName); 76 Collection c = SnipSpaceFactory.getInstance().getSince(user.getLastLogout()); 79 output(writer, params.getSnipRenderContext().getSnip(), 80 ResourceManager.getString("i18n.messages", "macro.sincelastvisit.title"), 81 c, ResourceManager.getString("i18n.messages", "macro.sincelastvisit.nochanges"), 82 type, showSize); 83 } else { 84 throw new IllegalArgumentException ("Number of arguments does not match"); 85 } 86 } 87 } 88 | Popular Tags |