Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* aoweb-struts-core - Core API for legacy Struts-based site framework with AOServ Platform control panels.
* Copyright (C) 2007-2013, 2015, 2016, 2018, 2019 AO Industries, Inc.
* [email protected]
* 7262 Bull Pen Cir
* Mobile, AL 36695
*
* This file is part of aoweb-struts-core.
*
* aoweb-struts-core is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* aoweb-struts-core is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with aoweb-struts-core. If not, see .
*/
package com.aoindustries.website;
import com.aoindustries.aoserv.client.AOServConnector;
import com.aoindustries.aoserv.client.reseller.Brand;
import com.aoindustries.encoding.ChainWriter;
import com.aoindustries.encoding.NewEncodingUtils;
import com.aoindustries.encoding.TextInJavaScriptEncoder;
import static com.aoindustries.encoding.TextInXhtmlAttributeEncoder.encodeTextInXhtmlAttribute;
import com.aoindustries.encoding.TextInXhtmlEncoder;
import static com.aoindustries.encoding.TextInXhtmlEncoder.encodeTextInXhtml;
import com.aoindustries.net.UrlUtils;
import com.aoindustries.util.i18n.EditableResourceBundle;
import com.aoindustries.website.skintags.Child;
import com.aoindustries.website.skintags.Meta;
import com.aoindustries.website.skintags.PageAttributes;
import com.aoindustries.website.skintags.Parent;
import java.io.IOException;
import java.net.URLEncoder;
import java.sql.SQLException;
import java.util.List;
import java.util.Locale;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import org.apache.struts.Globals;
import org.apache.struts.util.MessageResources;
/**
* The skin for the home page of the site.
*
* @author AO Industries, Inc.
*/
public class TextSkin extends Skin {
/**
* Reuse a single instance, not synchronized because if more than one is
* made no big deal.
*/
private static TextSkin instance;
public static TextSkin getInstance() {
if(instance==null) instance = new TextSkin();
return instance;
}
protected TextSkin() {}
@Override
public String getName() {
return "Text";
}
@Override
public String getDisplay(HttpServletRequest req) throws JspException {
HttpSession session = req.getSession();
Locale locale = (Locale)session.getAttribute(Globals.LOCALE_KEY);
MessageResources applicationResources = (MessageResources)req.getAttribute("/ApplicationResources");
if(applicationResources==null) throw new JspException("Unable to load resources: /ApplicationResources");
return applicationResources.getMessage(locale, "TextSkin.name");
}
/**
* Print the logo for the top left part of the page.
*/
public void printLogo(HttpServletRequest req, HttpServletResponse resp, JspWriter out, String urlBase) throws JspException {
// Print no logo by default
}
/**
* Prints the search form, if any exists.
*/
public void printSearch(HttpServletRequest req, HttpServletResponse resp, JspWriter out) throws JspException {
}
/**
* Prints the common pages area, which is at the top of the site.
*/
public void printCommonPages(HttpServletRequest req, HttpServletResponse resp, JspWriter out) throws JspException {
}
/**
* Prints the lines to include any CSS files.
*/
public void printCssIncludes(HttpServletResponse resp, JspWriter out, String urlBase) throws JspException {
}
/**
* Prints the lines for any JavaScript sources.
*/
public void printJavaScriptSources(HttpServletResponse resp, JspWriter out, String urlBase) throws JspException {
}
/**
* Prints the line for the favicon.
*/
public void printFavIcon(HttpServletResponse resp, JspWriter out, String urlBase) throws JspException {
}
public static MessageResources getMessageResources(HttpServletRequest req) throws JspException {
MessageResources resources = (MessageResources)req.getAttribute("/ApplicationResources");
if(resources==null) throw new JspException("Unable to load resources: /ApplicationResources");
return resources;
}
@Override
public void startSkin(HttpServletRequest req, HttpServletResponse resp, JspWriter out, PageAttributes pageAttributes) throws JspException {
try {
String layout = pageAttributes.getLayout();
if(!layout.equals(PageAttributes.LAYOUT_NORMAL)) throw new JspException("TODO: Implement layout: "+layout);
HttpSession session = req.getSession();
Locale locale = (Locale)session.getAttribute(Globals.LOCALE_KEY);
MessageResources applicationResources = getMessageResources(req);
String urlBase = getUrlBase(req);
String path = pageAttributes.getPath();
if(path.startsWith("/")) path=path.substring(1);
final String fullPath = urlBase + path;
final String encodedFullPath = resp.encodeURL(UrlUtils.encodeUrlPath(fullPath, resp.getCharacterEncoding()));
ServletContext servletContext = session.getServletContext();
SiteSettings settings = SiteSettings.getInstance(servletContext);
List skins = settings.getSkins();
boolean isOkResponseStatus;
{
Integer responseStatus = (Integer)req.getAttribute(Constants.HTTP_SERVLET_RESPONSE_STATUS);
isOkResponseStatus = responseStatus==null || responseStatus==HttpServletResponse.SC_OK;
}
out.print(" \n");
// If this is not the default skin, then robots noindex
boolean robotsMetaUsed = false;
if(!isOkResponseStatus || !getName().equals(skins.get(0).getName())) {
out.print(" \n");
robotsMetaUsed = true;
}
// Default style language
out.print(" \n"
+ " \n");
// If this is an authenticated page, redirect to session timeout after one hour
AOServConnector aoConn = AuthenticatedAction.getAoConn(req, resp);
if(isOkResponseStatus && aoConn!=null) {
out.print(" \n");
}
for(Meta meta : pageAttributes.getMetas()) {
// Skip ROBOTS if not on default skin
boolean isRobots = meta.getName().equalsIgnoreCase("ROBOTS");
if(!robotsMetaUsed || !isRobots) {
out.print(" \n");
if(isRobots) robotsMetaUsed = true;
}
}
out.print(" ");
// No more page stack, just show current page only
/*
List parents = pageAttributes.getParents();
for(Parent parent : parents) {
encodeTextInXhtml(parent.getTitle(), out);
out.print(" - ");
}
*/
encodeTextInXhtml(pageAttributes.getTitle(), out);
out.print("\n"
+ " \n");
Brand brand = settings.getBrand();
if(isOkResponseStatus) {
String googleVerify = brand.getAowebStrutsGoogleVerifyContent();
if(googleVerify!=null) {
out.print(" \n");
}
}
String keywords = pageAttributes.getKeywords();
if(keywords!=null && keywords.length()>0) {
out.print(" \n");
}
String description = pageAttributes.getDescription();
if(description!=null && description.length()>0) {
out.print(" \n"
+ " \n");
}
String copyright = pageAttributes.getCopyright();
if(copyright!=null && copyright.length()>0) {
out.print(" \n");
}
String author = pageAttributes.getAuthor();
if(author!=null && author.length()>0) {
out.print(" \n");
}
List languages = settings.getLanguages(req);
printAlternativeLinks(resp, out, fullPath, languages);
out.print(" \n"
+ " \n");
printCssIncludes(resp, out, urlBase);
defaultPrintLinks(out, pageAttributes, resp.getCharacterEncoding());
printJavaScriptSources(resp, out, urlBase);
out.print(" \n");
String googleAnalyticsNewTrackingCode = brand.getAowebStrutsGoogleAnalyticsNewTrackingCode();
if(googleAnalyticsNewTrackingCode!=null) {
out.print(" \n");
}
printFavIcon(resp, out, urlBase);
out.print(" \n"
+ " 0) {
out.print(" onload=\""); out.print(onload); out.print('"');
}
out.print(">\n"
+ "