| 1 31 32 package org.opencms.frontend.templateone; 33 34 import org.opencms.site.CmsSite; 35 import org.opencms.site.CmsSiteManager; 36 import org.opencms.util.CmsStringUtil; 37 import org.opencms.xml.content.CmsXmlContent; 38 39 import javax.servlet.http.HttpServletRequest ; 40 import javax.servlet.http.HttpServletResponse ; 41 import javax.servlet.jsp.PageContext ; 42 43 52 public class CmsTemplateImprint extends CmsTemplateBean { 53 54 55 public static final String FILENAME_CONFIGFILE = "imprint"; 56 57 58 public static final String PROPERTY_CONFIGFILE = "properties_imprint"; 59 60 61 public static final String PROPERTY_LINK_LEGAL = "link_legalnotes"; 62 63 64 public static final String PROPERTY_LINK_PRIVACY = "link_privacy"; 65 66 67 private CmsXmlContent m_configuration; 68 69 72 public CmsTemplateImprint() { 73 74 super(); 75 } 76 77 86 public CmsTemplateImprint(PageContext context, HttpServletRequest req, HttpServletResponse res) { 87 88 super(); 89 init(context, req, res); 90 } 91 92 99 public String buildEmailEntry(String className, String localeKey) { 100 101 StringBuffer result = new StringBuffer (16); 102 String nodeValue = getEmail(""); 103 if (CmsStringUtil.isNotEmpty(nodeValue)) { 104 result.append("<tr>\n\t<td class=\""); 106 result.append(className); 107 result.append("\" style=\"white-space: nowrap;\">"); 108 result.append(key(localeKey)); 109 result.append(":</td>\n\t<td class=\""); 110 result.append(className); 111 result.append("\">"); 112 result.append("<a HREF=\"mailto:"); 113 result.append(nodeValue); 114 result.append("\">"); 115 result.append(nodeValue); 116 result.append("</a></td>\n</tr>"); 117 } 118 return result.toString(); 119 } 120 121 131 public String buildImprintEntry(String className, String localeKey, String nodeName) { 132 133 StringBuffer result = new StringBuffer (16); 134 String nodeValue = ""; 135 try { 136 nodeValue = m_configuration.getStringValue(getCmsObject(), nodeName, getRequestContext().getLocale()); 138 } catch (Exception e) { 139 } 141 if (CmsStringUtil.isNotEmpty(nodeValue)) { 142 result.append("<tr>\n\t<td class=\""); 144 result.append(className); 145 result.append("\" style=\"white-space: nowrap;\">"); 146 result.append(key(localeKey)); 147 result.append(":</td>\n\t<td class=\""); 148 result.append(className); 149 result.append("\">"); 150 result.append(nodeValue); 151 result.append("</td>\n</tr>"); 152 } 153 return result.toString(); 154 } 155 156 162 public String getImprintValue(String nodeName) { 163 164 String nodeValue = ""; 165 try { 166 nodeValue = m_configuration.getStringValue(getCmsObject(), nodeName, getRequestContext().getLocale()); 168 if (CmsStringUtil.isEmpty(nodeValue)) { 169 return ""; 170 } 171 } catch (Exception e) { 172 } 174 return nodeValue; 175 } 176 177 182 public String getLinkLegalNotes() { 183 184 String link = property(PROPERTY_LINK_LEGAL, "search", ""); 185 if ("".equals(link)) { 186 return "#"; 187 } else { 188 return link(link); 189 } 190 } 191 192 197 public String getLinkPrivacy() { 198 199 String link = property(PROPERTY_LINK_PRIVACY, "search", ""); 200 if ("".equals(link)) { 201 return "#"; 202 } else { 203 return link(link); 204 } 205 } 206 207 212 public String getUrl() { 213 214 StringBuffer result = new StringBuffer (64); 215 CmsSite site = CmsSiteManager.getCurrentSite(getCmsObject()); 216 result.append(site.getUrl()); 217 result.append(link(getRequestContext().getUri())); 218 return result.toString(); 219 } 220 221 231 public void init(PageContext context, HttpServletRequest req, HttpServletResponse res) { 232 233 super.init(context, req, res); 235 String siteRoot = req.getParameter(CmsTemplateBean.PARAM_SITE); 237 if (CmsStringUtil.isNotEmpty(siteRoot)) { 238 getRequestContext().setSiteRoot(siteRoot); 239 } 240 String oldUri = getRequestContext().getUri(); 242 String uri = req.getParameter(CmsTemplateBean.PARAM_URI); 243 if (uri == null) { 244 uri = oldUri; 245 } 246 getRequestContext().setUri(uri); 247 248 String configFileName = property(PROPERTY_CONFIGFILE, "search", ""); 250 if ("".equals(configFileName)) { 251 configFileName = getConfigPath() + FILENAME_CONFIGFILE; 252 } 253 m_configuration = CmsTemplateBean.getConfigurationFile(configFileName, getCmsObject()); 255 } 256 257 264 protected String getEmail(String defaultValue) { 265 266 String nodeValue = ""; 267 try { 268 nodeValue = m_configuration.getStringValue(getCmsObject(), "email", getRequestContext().getLocale()); 270 } catch (Exception e) { 271 } 273 if (CmsStringUtil.isEmpty(nodeValue)) { 274 nodeValue = defaultValue; 276 } 277 return nodeValue; 278 } 279 280 } 281 | Popular Tags |