%@ include file="init.jsp" %>
<%@ page import="org.crosswire.swordweb.*" %>
<%
String addModule = (String)request.getParameter("add");
if (addModule != null) {
SWModule mod = mgr.getModuleByName(addModule);
if (mod != null) {
if (mod.getCategory().equals(SwordOrb.BIBLES)) {
prefBibles.remove(mod.getName());
prefBibles.add(0, mod.getName());
}
if (mod.getCategory().equals(SwordOrb.COMMENTARIES)) {
prefCommentaries.remove(mod.getName());
prefCommentaries.add(0, mod.getName());
}
}
}
String delModule = (String)request.getParameter("del");
if (delModule != null) {
SWModule mod = mgr.getModuleByName(delModule);
if (mod != null) {
if (mod.getCategory().equals(SwordOrb.BIBLES)) {
prefBibles.remove(mod.getName());
}
if (mod.getCategory().equals(SwordOrb.COMMENTARIES)) {
prefCommentaries.remove(mod.getName());
}
}
}
session.setAttribute("PrefBibles", prefBibles);
session.setAttribute("PrefCommentaries", prefCommentaries);
saveModPrefsCookie(response, "PrefBibles", prefBibles);
saveModPrefsCookie(response, "PrefCommentaries", prefCommentaries);
SidebarModuleView sidebarView = new SimpleModuleView(mgr);
SidebarItemRenderer selectModRenderer = new SidebarItemRenderer() { //an anonymous class which renders a list of modules with links to read each of them
public String renderModuleItem(SWModule module) {
StringBuffer ret = new StringBuffer();
ret.append("
")
.append(module.getDescription().replaceAll("&", "&"))
.append("");
return ret.toString();
}
};
SidebarItemRenderer removeModRenderer = new SidebarItemRenderer() { //an anonymous class which renders a list of modules with links to read each of them
public String renderModuleItem(SWModule module) {
StringBuffer ret = new StringBuffer();
ret.append("")
.append(module.getDescription().replaceAll("&", "&"))
.append("");
return ret.toString();
}
};
%>
Translations:
Preferred Translations
<%
out.print( sidebarView.renderView(prefBibles, selectModRenderer) ); //render the preferred Bibles section
%>
All Translations
<%
Vector modules = new Vector();
for (int i = 0; i < modInfo.length; i++) {
if (modInfo[i].category.equals(SwordOrb.BIBLES)) {
modules.add(modInfo[i].name);
}
}
modules.removeAll(prefBibles); //don't insert the pref mods again
out.print( sidebarView.renderView(modules, selectModRenderer) ); //render the preferred Bibles section
%>
Preferred Translations
Click to remove. Reselect on the side to move to the top.
<%
out.print( sidebarView.renderView(prefBibles, removeModRenderer) ); //render the preferred Bibles section
%>
Preferred Commentaries
Click to remove. Reselect on the side to move to the top.
<%
out.print( sidebarView.renderView(prefCommentaries, removeModRenderer) ); //render the preferred Bibles section
%>
Preferred Style
Tabs
Misc Options
<%!
private void saveModPrefsCookie(HttpServletResponse response, String name, Vector modPrefs) {
StringBuffer fullText = new StringBuffer("GodLuvsU");
for (int i = 0; i < modPrefs.size(); i++) {
fullText.append("+");
fullText.append((String)modPrefs.get(i));
}
/*
// serialize out to cookie
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
Base64.OutputStream bos = new Base64.OutputStream(bytes);
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(prefBibles);
oos.writeObject(prefCommentaries);
Cookie c = new Cookie("prefMods", new String(bytes.toByteArray()));
*/
Cookie c = new Cookie(name, fullText.toString());
c.setMaxAge(java.lang.Integer.MAX_VALUE);
c.setPath("/");
//out.println("Cookie being set is ("+c.getName()+"):" + c.getValue());
response.addCookie(c);
}
%>