1 package info.magnolia.cms.taglibs; 2 3 import info.magnolia.cms.beans.config.Server; 4 import info.magnolia.cms.gui.misc.Sources; 5 6 import java.io.IOException ; 7 8 import javax.servlet.http.HttpServletRequest ; 9 import javax.servlet.jsp.JspException ; 10 import javax.servlet.jsp.JspWriter ; 11 import javax.servlet.jsp.tagext.TagSupport ; 12 13 import org.apache.commons.lang.exception.NestableRuntimeException; 14 15 16 22 public class LinksTag extends TagSupport { 23 24 27 private static final long serialVersionUID = 222L; 28 29 32 private boolean adminOnly = true; 33 34 37 public int doStartTag() throws JspException { 38 if (!adminOnly || Server.isAdmin()) { 39 40 HttpServletRequest request = (HttpServletRequest ) this.pageContext.getRequest(); 41 42 if (request.getAttribute(Sources.REQUEST_LINKS_DRAWN) == null) { 44 45 Sources src = new Sources(request.getContextPath()); 46 JspWriter out = this.pageContext.getOut(); 47 try { 48 out.write(src.getHtmlCss()); 49 out.write(src.getHtmlJs()); 50 } 51 catch (IOException e) { 52 throw new NestableRuntimeException(e); 54 } 55 56 request.setAttribute(Sources.REQUEST_LINKS_DRAWN, Boolean.TRUE); 57 } 58 } 59 60 return EVAL_PAGE; 61 } 62 63 68 public void setAdminOnly(boolean adminOnly) { 69 this.adminOnly = adminOnly; 70 } 71 72 75 public void release() { 76 this.adminOnly = true; 77 super.release(); 78 } 79 80 } 81 | Popular Tags |