/* * The contents of this file are subject to the Mozilla Public License Version 1.1 * (the "License"); you may not use this file except in compliance with the License. * You may obtain a copy of the License at . * * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT * WARRANTY OF ANY KIND, either express or implied. See the License for the specific * language governing rights and limitations under the License. * * The Original Code is the Venice Web Communities System. * * The Initial Developer of the Original Code is Eric J. Bowersox , * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ package com.silverwrist.venice.ui.view; import java.io.IOException; import java.util.*; import javax.servlet.*; import com.silverwrist.util.StringUtil; import com.silverwrist.venice.core.*; import com.silverwrist.venice.ui.*; import com.silverwrist.venice.ui.helpers.HTMLRendering; import com.silverwrist.venice.ui.servlet.RequestImpl; public class AuditView implements ContentDirect { /*-------------------------------------------------------------------------------- * Static data members *-------------------------------------------------------------------------------- */ private static final String REPLACE_TOKEN = "${offset}"; /*-------------------------------------------------------------------------------- * Attributes *-------------------------------------------------------------------------------- */ private int menu_sel = MENU_SELECTOR_NOCHANGE; private List audit_list; private int offset; private int total_count; private int last_index; private String title; private String next_url; private String prev_url; private String return_url; private String return_text; /*-------------------------------------------------------------------------------- * Constructor *-------------------------------------------------------------------------------- */ public AuditView(VeniceEngine engine, List audit_list, int offset, int total_count, String title, String template_url, String return_url, String return_text) { this.audit_list = audit_list; this.offset = offset; this.total_count = total_count; int npage = engine.getNumAuditRecordsPerPage(); this.last_index = Math.min(offset + npage,total_count); this.title = title; if (this.last_index0) this.prev_url = StringUtil.replaceAllInstances(template_url,REPLACE_TOKEN, String.valueOf(Math.max(offset-npage,0))); else this.prev_url = null; this.return_url = return_url; this.return_text = return_text; } // end constructor /*-------------------------------------------------------------------------------- * Implementations from interface Content *-------------------------------------------------------------------------------- */ public boolean needFrame() { return true; } // end needFrame public int getMenuSelector() { return menu_sel; } // end getMenuSelector public String getPageTitle(RequestOutput ro) { return title; } // end getPageTitle public String getPageQID() { return null; } // end getPageQID /*-------------------------------------------------------------------------------- * Implementations from interface ContentDirect *-------------------------------------------------------------------------------- */ public void render(RequestOutput out) throws IOException { HTMLRendering html = (HTMLRendering)(out.queryService(HTMLRendering.class)); out.writeContentHeader(title,null); // Write the return URL out.write("
" + html.getFontTag(html.CONTENT_FOREGROUND,"content") + "" + StringUtil.encodeHTML(return_text) + "
\n"); // Write the informational and navigational table out.write("
" + html.getFontTag(html.CONTENT_FOREGROUND,"content") + "\nDisplaying records " + (offset+1) + " to " + last_index + " of " + total_count + "\n" + "\n"); if (prev_url==null) out.write(html.getButtonVisual("_null_")); else out.write("" + html.getButtonVisual("previous") + ""); out.write(" "); if (next_url==null) out.write(html.getButtonVisual("_null_")); else out.write("" + html.getButtonVisual("next") + ""); out.write("\n
\n"); // Start writing the table containing the actual audit records. String tb_font = html.getFontTag(html.CONTENT_FOREGROUND,"content"); out.write("\n\n\n\n\n\n\n\n\n"); Iterator it = audit_list.iterator(); while (it.hasNext()) { // display each record in turn AuditData dat = (AuditData)(it.next()); out.write("\n\n\n\n\n\n"); for (int i=0; i" + tb_font); if (dat.getData(i)!=null) out.write(StringUtil.encodeHTML(dat.getData(i))); else out.write(" "); out.write("\n"); } // end for out.write("\n"); } // end while out.write("
" + tb_font + "Date/Time" + tb_font + "Description" + tb_font + "User" + tb_font + "Community" + tb_font + "IP Address" + tb_font + "Additional Data
" + tb_font + html.formatDate(dat.getDateTime()) + "" + tb_font + StringUtil.encodeHTML(dat.getDescription()) + "" + tb_font + StringUtil.encodeHTML(dat.getUserName()) + "" + tb_font + StringUtil.encodeHTML(dat.getCommunityName()) + "" + tb_font + StringUtil.encodeHTML(dat.getIPAddress()) + "
\n"); } // end render /*-------------------------------------------------------------------------------- * External operations *-------------------------------------------------------------------------------- */ public final void setMenuSelector(int sel) { menu_sel = sel; } // end setMenuSelector } // end class AuditView