Search in sources :

Example 1 with NavList

use of web.NavList 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>");
}
Also used : HTMLWriter(web.HTMLWriter) Accordion(web.Accordion) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) NavList(web.NavList)

Aggregations

ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Accordion (web.Accordion)1 HTMLWriter (web.HTMLWriter)1 NavList (web.NavList)1