1 17 package org.alfresco.web.ui.repo.tag; 18 19 import java.io.IOException ; 20 import java.io.Writer ; 21 22 import javax.servlet.http.HttpServletRequest ; 23 import javax.servlet.jsp.JspException ; 24 import javax.servlet.jsp.tagext.TagSupport ; 25 26 import org.alfresco.web.app.Application; 27 import org.apache.commons.logging.Log; 28 import org.apache.commons.logging.LogFactory; 29 30 35 public class PageTag extends TagSupport 36 { 37 private static final long serialVersionUID = 8142765393181557228L; 38 39 private final static String SCRIPTS_START = "<script language=\"JavaScript1.2\" SRC=\""; 40 private final static String SCRIPTS_MENU = "/scripts/menu.js\"></script>\n"; 41 private final static String SCRIPTS_WEBDAV = "/scripts/webdav.js\"></script>\n"; 42 private final static String STYLES_START = "<link rel=\"stylesheet\" HREF=\""; 43 private final static String STYLES_MAIN = "/css/main.css\" TYPE=\"text/css\">\n"; 44 45 48 49 private final static String ALF_URL = "http://www.alfresco.com"; 50 private final static String ALF_LOGO = "http://www.alfresco.com/images/alfresco_community_horizont.gif"; 51 private final static String ALF_TEXT = "Alfresco Community"; 52 private final static String ALF_COPY = "Supplied free of charge with " + 53 "<a class=footer HREF='http://www.alfresco.com/services/support/communityterms/#support'>no support</a>, " + 54 "<a class=footer HREF='http://www.alfresco.com/unsupported.html#certification'>no certification</a>, " + 55 "<a class=footer HREF='http://www.alfresco.com/services/support/communityterms/#maintenance'>no maintenance</a>, " + 56 "<a class=footer HREF='http://www.alfresco.com/services/support/communityterms/#warranty'>no warranty</a> and " + 57 "<a class=footer HREF='http://www.alfresco.com/services/support/communityterms/#indemnity'>no indemnity</a> by " + 58 "<a class=footer HREF='http://www.alfresco.com'>Alfresco</a> or its " + 59 "<a class=footer HREF='http://www.alfresco.com/partners/'>Certified Partners</a>. " + 60 "<a class=footer HREF='http://www.alfresco.com/services/support/'>Click here for support</a>. " + 61 "Alfresco Software Inc. © 2005-2006 All rights reserved."; 62 63 private static Log logger = LogFactory.getLog(PageTag.class); 64 private static String alfresco = null; 65 private static String loginPage = null; 66 67 private long startTime = 0; 68 private String title; 69 private String titleId; 70 71 74 public String getTitle() 75 { 76 return title; 77 } 78 79 82 public void setTitle(String title) 83 { 84 this.title = title; 85 } 86 87 90 public String getTitleId() 91 { 92 return titleId; 93 } 94 95 98 public void setTitleId(String titleId) 99 { 100 this.titleId = titleId; 101 } 102 103 public void release() 104 { 105 super.release(); 106 title = null; 107 titleId = null; 108 } 109 110 113 public int doStartTag() throws JspException 114 { 115 if (logger.isDebugEnabled()) 116 startTime = System.currentTimeMillis(); 117 118 try 119 { 120 Writer out = pageContext.getOut(); 121 122 if (Application.inPortalServer() == false) 123 { 124 out.write("<html><head><title>"); 125 if (this.titleId != null && this.titleId.length() != 0) 126 { 127 out.write(Application.getMessage(pageContext.getSession(), this.titleId)); 128 } 129 else if (this.title != null && this.title.length() != 0) 130 { 131 out.write(this.title); 132 } 133 else 134 { 135 out.write("Alfresco Web Client"); 136 } 137 out.write("</title></head>"); 138 out.write("<body>\n"); 139 } 140 141 String reqPath = ((HttpServletRequest )pageContext.getRequest()).getContextPath(); 142 out.write(SCRIPTS_START); 143 out.write(reqPath); 144 out.write(SCRIPTS_MENU); 145 out.write(SCRIPTS_START); 146 out.write(reqPath); 147 out.write(SCRIPTS_WEBDAV); 148 out.write(STYLES_START); 149 out.write(reqPath); 150 out.write(STYLES_MAIN); 151 } 152 catch (IOException ioe) 153 { 154 throw new JspException (ioe.toString()); 155 } 156 157 return EVAL_BODY_INCLUDE; 158 } 159 160 163 public int doEndTag() throws JspException 164 { 165 try 166 { 167 HttpServletRequest req = (HttpServletRequest )pageContext.getRequest(); 168 if (req.getRequestURI().endsWith(getLoginPage()) == false) 169 { 170 pageContext.getOut().write(getAlfrescoButton()); 171 } 172 173 if (Application.inPortalServer() == false) 174 { 175 pageContext.getOut().write("\n</body></html>"); 176 } 177 } 178 catch (IOException ioe) 179 { 180 throw new JspException (ioe.toString()); 181 } 182 183 if (logger.isDebugEnabled()) 184 { 185 long endTime = System.currentTimeMillis(); 186 logger.debug("Time to generate page: " + (endTime - startTime) + "ms"); 187 } 188 189 return super.doEndTag(); 190 } 191 192 private String getLoginPage() 193 { 194 if (loginPage == null) 195 { 196 loginPage = Application.getLoginPage(pageContext.getServletContext()); 197 } 198 199 return loginPage; 200 } 201 202 205 206 private String getAlfrescoButton() 207 { 208 if (alfresco == null) 209 { 210 String reqPath = ((HttpServletRequest )pageContext.getRequest()).getContextPath(); 211 alfresco = "<center><table><tr><td>" + 212 "<a HREF='" + ALF_URL + "'>" + 213 "<img border=0 alt='' title='" + ALF_TEXT + "' align=absmiddle SRC='" + ALF_LOGO + "'>" + 214 "</a></td><td align=center>" + 215 "<span class=footer>" + ALF_COPY + 216 "</span></td><td><a HREF='http://sourceforge.net/projects/alfresco'><img border=0 alt='' title='SourceForge' align=absmiddle SRC='http://sflogo.sourceforge.net/sflogo.php?group_id=143373&type=1'></a>" + 217 "</td></tr></table></center>"; 218 } 219 220 return alfresco; 221 } 222 } 223 | Popular Tags |