implemented very simple ad rotation support, good enough for our rotating
quote banners - also included quote banners (20 from Webb, 4 new)
This commit is contained in:
@@ -608,7 +608,7 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
Variables.flushCookies(request,response);
|
||||
if (content!=null)
|
||||
{ // display the content!
|
||||
BaseJSPData base = new BaseJSPData(getMyLocation(request,engine,user,rdat),content);
|
||||
BaseJSPData base = new BaseJSPData(engine,user,getMyLocation(request,engine,user,rdat),content);
|
||||
base.transfer(ctxt,rdat);
|
||||
|
||||
} // end if
|
||||
@@ -663,7 +663,7 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
catch (ServletMultipartException e)
|
||||
{ // this is an error message we need to generate and just bail out on
|
||||
logger.error("ServletMultipartException caught in doVenicePost!",e);
|
||||
BaseJSPData base = new BaseJSPData(getMyLocation(request,engine,user,rdat),
|
||||
BaseJSPData base = new BaseJSPData(engine,user,getMyLocation(request,engine,user,rdat),
|
||||
new ErrorBox(null,"Internal Error: " + e.getMessage(),null));
|
||||
base.transfer(ctxt,rdat);
|
||||
return;
|
||||
@@ -712,7 +712,7 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
Variables.flushCookies(request,response);
|
||||
if (content!=null)
|
||||
{ // display the content!
|
||||
BaseJSPData base = new BaseJSPData(getMyLocation(request,engine,user,rdat),content);
|
||||
BaseJSPData base = new BaseJSPData(engine,user,getMyLocation(request,engine,user,rdat),content);
|
||||
base.transfer(ctxt,rdat);
|
||||
|
||||
} // end if
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.io.IOException;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.servlets.Variables;
|
||||
import com.silverwrist.venice.servlets.format.menus.LeftMenu;
|
||||
|
||||
@@ -40,6 +41,8 @@ public class BaseJSPData
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private VeniceEngine engine; // the Venice engine
|
||||
private UserContext user; // user context
|
||||
private String location; // location string to use for this page
|
||||
private VeniceContent content; // the actual content
|
||||
private boolean login_links = true; // show login links up top?
|
||||
@@ -49,8 +52,10 @@ public class BaseJSPData
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public BaseJSPData(String location, VeniceContent content)
|
||||
public BaseJSPData(VeniceEngine engine, UserContext user, String location, VeniceContent content)
|
||||
{
|
||||
this.engine = engine;
|
||||
this.user = user;
|
||||
this.location = location;
|
||||
this.content = content;
|
||||
|
||||
@@ -116,6 +121,47 @@ public class BaseJSPData
|
||||
|
||||
} // end transfer
|
||||
|
||||
public void renderBannerAd(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
Advertisement advert;
|
||||
if (user.isLoggedIn())
|
||||
advert = user.selectAd();
|
||||
else
|
||||
advert = engine.selectAd();
|
||||
if (advert==null)
|
||||
{ // no advert found - bail out now!
|
||||
out.write(" ");
|
||||
return;
|
||||
|
||||
} // end if
|
||||
|
||||
String full_image_path;
|
||||
if (advert.getImagePathStyle()==Advertisement.CONTEXT_RELATIVE)
|
||||
{ // return the full image path
|
||||
full_image_path = rdat.getContextRelativePath(advert.getImagePath());
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // can't render the ad - just punt
|
||||
out.write(" ");
|
||||
return;
|
||||
|
||||
} // end else
|
||||
|
||||
// Write the banner ad.
|
||||
String url = advert.getLinkURL();
|
||||
String capt = advert.getCaption();
|
||||
if (url!=null)
|
||||
out.write("<A HREF=\"" + url + "\">");
|
||||
out.write("<IMG SRC=\"" + full_image_path + "\" ALT=\"");
|
||||
if (capt!=null)
|
||||
out.write(capt);
|
||||
out.write("\" ALIGN=RIGHT WIDTH=468 HEIGHT=60 HSPACE=2 VSPACE=2 BORDER=0>");
|
||||
if (url!=null)
|
||||
out.write("</A>");
|
||||
|
||||
} // end renderBannerAd
|
||||
|
||||
public void renderMenu(HttpSession session, Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
ComponentRender menu = Variables.getMenu(session);
|
||||
|
||||
@@ -190,6 +190,15 @@ public class RenderData
|
||||
|
||||
} // end getStaticIncludePath
|
||||
|
||||
public String getContextRelativePath(String name)
|
||||
{
|
||||
StringBuffer buf = new StringBuffer(request.getContextPath());
|
||||
if (name.charAt(0)!='/')
|
||||
buf.append('/');
|
||||
return buf.append(name).toString();
|
||||
|
||||
} // end getContextRelativePath
|
||||
|
||||
public String getStdFontTag(String color, int size)
|
||||
{
|
||||
return rconf.getStdFontTag(color,size);
|
||||
|
||||
Reference in New Issue
Block a user