use of web.Accordion in project common by zenlunatics.
the class MailLists method writeArchiveViewer.
// --------------------------------------------------------------------------
private void writeArchiveViewer(int list_id, Request request) throws IOException {
MailList mail_list = new MailList(list_id, request.site, request.db);
if (mail_list.getId() == 0)
request.abort("writeArchiveViewer: list " + list_id + " not found");
HTMLWriter writer = request.writer;
writer.write("<h3>").write(mail_list.getName()).write(" mail list archive</h3>");
writer.write("<table><tr><td style=\"padding:0 10px;vertical-align:top;width:200px;\">");
ResultSet rs = request.db.select("SELECT DISTINCT extract(month from arrived) m,extract(year from arrived) y FROM ml_" + list_id + " ORDER BY y DESC,m");
try {
if (rs.next()) {
writer.write("<div class=\"list_border_outer\"><div class=\"list_border_inner\">");
Accordion accordion = new Accordion(writer).setActiveGroup(0).open();
NavList nav_list = new NavList(writer);
String[] months = new String[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
int year = 0;
int most_recent_month = -1;
int most_recent_year = rs.getInt(2);
int month = 0;
do {
if (year != rs.getInt(2)) {
if (most_recent_month == -1)
most_recent_month = 0;
else if (most_recent_month == 0)
most_recent_month = month;
nav_list.close();
year = rs.getInt(2);
accordion.heading(Integer.toString(year));
nav_list.open();
}
month = rs.getInt(1);
nav_list.aOnClick(months[rs.getInt(1) - 1], "$('ml_headers').replace(context+'/MailLists/" + mail_list.getId() + "/headers/" + year + "/" + month + "');");
} while (rs.next());
if (most_recent_month <= 0)
most_recent_month = month;
nav_list.close();
accordion.close();
writer.write("</div></div>");
writer.write("<div class=\"well\" style=\"margin:10px 0;\"><form id=\"search\">");
writer.write("Search for:");
writer.setAttribute("onfocus", "$('options').style.display='block'");
writer.setAttribute("onkeypress", "if(event.keyCode==13){$('go_btn').click();return false;}");
writer.textInput("search", null, null);
writer.write("<div id=\"options\" style=\"display:none;\">show emails containing:");
writer.setAttribute("id", "all");
writer.radioButton("words", "all search words", "all", true, null);
writer.radioButton("words", "any search word", "any", false, null);
writer.setAttribute("id", "subject");
writer.checkbox("subject", "search subject", null, true, false);
writer.setAttribute("id", "message");
writer.checkbox("message", "search message (slow)", null, false, false);
writer.write("</div>");
writer.setAttribute("id", "go_btn");
writer.aButtonOnClick("go", "var m=$('ml_headers');m.set('html','searching...');m.replace(context+'/MailLists/" + list_id + "/search?'+$('search').toQueryString());");
writer.write("</form></div>");
writer.scriptOpen().write("window.addEvent('load',function(){$('ml_headers').replace(context+'/MailLists/").write(list_id).write("/headers/").write(most_recent_year).write("/").write(most_recent_month).write("');});").scriptClose();
} else
writer.write("empty archives");
rs.getStatement().close();
} catch (SQLException e) {
request.abort(e);
}
writer.write("<div id=\"subscribers\"><div class=\"list_border_outer\"><div class=\"list_border_inner\">");
NavList nav_list = new NavList(writer).addStyle("font-size", "12px").addStyle("white-space", "nowrap");
nav_list.open();
MailHandler mail_handler = getMailHandler(mail_list.getName(), request.db);
if (mail_handler != null)
mail_handler.writeSubscribers(nav_list, request.site, request.db);
else
mail_list.writeSubscribers(nav_list, request.site, request.db);
nav_list.close();
writer.write("</div></div>");
writer.write("</div></td><td valign=\"top\" style=\"height:200px;padding:0 10px 10px 0;\"><div id=\"ml_headers\" class=\"mail_archive_headers\"></td></tr></table>");
}
use of web.Accordion in project common by zenlunatics.
the class Admin method writeAccordion.
// --------------------------------------------------------------------------
private void writeAccordion(Request request) throws IOException {
Accordion accordion = new Accordion(request.writer);
accordion.open();
Collection<Module> modules_list = request.site.getModules();
accordion.heading("modules");
// accordion.aOnClick("- add module -", "new_tab('Add Module','get_add_module_form')");
for (Module module : modules_list) if (module.showOnAdminPage())
accordion.aOnClick(module.getName(), "new_tab('" + HTMLWriter.escapeJSString(module.getName()) + "','get_module&module=" + HTMLWriter.escapeJSString(module.getName()) + "')");
Collection<DBObjects<?>> objects_list = request.site.getAllObjects();
if (objects_list.size() > 0) {
accordion.heading("objects");
for (DBObjects<?> objects : objects_list) accordion.aOnClick(objects.getName(), "new_tab('" + HTMLWriter.escapeJSString(objects.getName()) + "','get_object&object=" + HTMLWriter.escapeJSString(objects.getName()) + "')");
}
accordion.heading("tables");
accordion.aOnClick("- create table -", "new_tab('Create Table','get_table_create_form')");
accordion.aOnClick("- create many to many link table -", "new_tab('Create Many To Many Link Table','get_many_to_many_link_table_create_form')");
String[] tables = request.db.getTableNames(false);
if (tables != null)
for (String table : tables) accordion.aOnClick(table, "new_tab('" + table + "','get_table&table=" + table + "')");
accordion.heading("table defs");
accordion.aOnClick("- create table def -", "create_table_def()");
View table_defs = request.site.newView("_tables_", request);
table_defs.select();
if (table_defs.data().isBeforeFirst()) {
table_defs.setColumn(new Column("name").setValueRenderer(new LinkValueRenderer().setHrefColumn("id").setTextColumn("name").setOnClick("new_tab('<%name%>','get_table_def&db_key_value=", "')"), false));
writeRows(accordion, table_defs, new String[] { "name" }, request.writer);
}
accordion.heading("views");
accordion.aOnClick("- create view -", "create_view()");
View views = request.site.newView("_views_", request);
views.select();
if (views.data().isBeforeFirst()) {
views.setColumn(new Column("name").setValueRenderer(new LinkValueRenderer().setHrefColumn("id").setTextColumn("name").setOnClick("new_tab('<%name%>','get_view&db_key_value=", "')"), false));
writeRows(accordion, views, new String[] { "name" }, request.writer);
}
writeAccordionItems(accordion, request.site.getDisplayName(), request.site.getClass());
Class<?>[] classes = request.site.getClasses();
if (classes != null)
for (Class<?> c : classes) writeAccordionItems(accordion, c.getSimpleName() + " tasks", c);
String display = request.getParameter("display");
if (display != null)
if (Character.isDigit(display.charAt(0)))
accordion.setActiveGroup(Integer.parseInt(display));
else
accordion.setActiveGroup(display);
accordion.close();
}
Aggregations