Search in sources :

Example 1 with Page

use of app.Page in project common by zenlunatics.

the class MailLists method init.

// --------------------------------------------------------------------------
@Override
public void init(DBConnection db) {
    JDBCTable table_def = new JDBCTable().add(new JDBCColumn("active", Types.BOOLEAN).setDefaultValue(true)).add(new JDBCColumn("allow_from_outside", Types.BOOLEAN).setDefaultValue(false)).add(new JDBCColumn("allow_from_outside_subscribers", Types.BOOLEAN).setDefaultValue(false)).add(new JDBCColumn("announce_only", Types.BOOLEAN)).add(new JDBCColumn("archive", Types.BOOLEAN).setDefaultValue(true)).add(new JDBCColumn("archives_public", Types.BOOLEAN).setDefaultValue(true)).add(new JDBCColumn("footer", Types.VARCHAR)).add(new JDBCColumn("host", Types.VARCHAR)).add(new JDBCColumn("name", Types.VARCHAR)).add(new JDBCColumn("password", Types.VARCHAR)).add(new JDBCColumn("send_to", Types.VARCHAR)).add(new JDBCColumn("store_on_disk", Types.BOOLEAN)).add(new JDBCColumn("username", Types.VARCHAR));
    db.getTable("mail_lists", true).createMissingColumns(table_def, db).dropExtraColumns(table_def, db);
    db.createManyToManyLinkTable("mail_lists", "people");
    db.createTable("mail_lists_digest", false, "mail_lists_id INTEGER REFERENCES mail_lists ON DELETE CASCADE,people_id INTEGER REFERENCES people ON DELETE CASCADE", null, false);
    db.createManyTable("mail_lists", "subscribers", "email VARCHAR(60)");
    table_def = new JDBCTable().add(new JDBCColumn("people")).add(new JDBCColumn("email", Types.VARCHAR, 60));
    db.getTable("additional_emails", true).createMissingColumns(table_def, db).dropExtraColumns(table_def, db);
    Roles.add("mail", m_site, db);
    m_site.addUserDropdownItem(new Page("Edit Mail Lists", m_site) {

        @Override
        public void write(Request request) throws IOException {
            request.site.writePageOpen("Edit Mail Lists", request);
            request.site.newView("mail_lists", request).writeComponent();
            request.close();
        }
    }.setRole("mail"), db);
}
Also used : JDBCTable(db.JDBCTable) Request(app.Request) JDBCColumn(db.JDBCColumn) Page(app.Page)

Example 2 with Page

use of app.Page in project common by zenlunatics.

the class SiteMenu method init.

// --------------------------------------------------------------------------
@Override
public void init(DBConnection db) {
    JDBCTable jdbc_table = new JDBCTable().add(new JDBCColumn("name", Types.VARCHAR, 30)).add(new JDBCColumn("_order_", Types.INTEGER));
    db.getTable("menu").dropExtraColumns(jdbc_table, db).createMissingColumns(jdbc_table, db);
    jdbc_table = new JDBCTable().add(new JDBCColumn("people")).add(new JDBCColumn("name", Types.VARCHAR, 30)).add(new JDBCColumn("_order_", Types.INTEGER));
    db.getTable("menu_items").dropExtraColumns(jdbc_table, db).createMissingColumns(jdbc_table, db);
    m_menu = new DBObjects<MenuItem>(new Select("*").from("menu").orderBy("_order_"), MenuItem.class, m_site);
    // so that the UpdateHook calls get called on reorder
    m_site.addObjects(m_menu);
    Pages pages = (Pages) m_site.getModule("Pages");
    pages.add(new Page("Other", "Other"), db);
    ViewDef view_def = m_site.getViewDef("pages", db);
    view_def.addDeleteHook(this).addUpdateHook(this);
}
Also used : Pages(app.Pages) JDBCTable(db.JDBCTable) Select(db.Select) JDBCColumn(db.JDBCColumn) Page(app.Page) ViewDef(db.ViewDef)

Example 3 with Page

use of app.Page in project common by zenlunatics.

the class MenuItemsInputRenderer method writeInput.

// --------------------------------------------------------------------------
@Override
public boolean writeInput(View view, Form form, ColumnBase<?> column, View.Mode mode, String default_value, Request request) throws IOException {
    HTMLWriter writer = request.writer;
    if (mode == View.Mode.ADD_FORM) {
        writer.jsFunction("handle_menu_choice", "s", "if(s.selectedIndex==s.options.length-1){" + "s.style.display='none';" + "$('hidden_name').setProperty('name','');" + "$('name_input').setProperty('name','name');" + "$('hidden_name').style.display='none';" + "$('hidden_url').setProperty('name','');" + "$('url_input').setProperty('name','url');" + "$('hidden_url').style.display='none';" + "$('miir').style.display='';" + "}else{" + "$('hidden_name').value=s.options[s.selectedIndex].text;" + "$('hidden_url').value=s.options[s.selectedIndex].value;" + "}");
        writer.write("<table id=\"miir\" border=\"0\" style=\"display:none\"><tr><td class=\"form_label\">name</td><td>");
        writer.setAttribute("id", "name_input");
        writer.textInput(null, "30", null);
        writer.write("</td></tr><tr><td class=\"form_label\">url</td><td>");
        writer.setAttribute("id", "url_input");
        writer.textInput(null, null, null);
        writer.write("</tr></table>");
        writer.setAttribute("id", "hidden_name");
        Page page = m_all_pages.iterator().next();
        writer.hiddenInput("name", page.getName());
        writer.setAttribute("id", "hidden_url");
        writer.hiddenInput("url", page.getURL());
        new Select(null, m_all_pages).setOnChange("handle_menu_choice(this)").write(request);
    } else {
        writer.write("<table border=\"0\"><tr><td class=\"form_label\">name</td><td>");
        writer.textInput("name", "30", view.data().getString("name"));
        writer.write("</td></tr><tr><td class=\"form_label\">url</td><td>");
        writer.textInput("url", null, view.data().getString("url"));
        writer.write("</tr></table>");
    }
    return true;
}
Also used : HTMLWriter(web.HTMLWriter) Select(web.Select) Page(app.Page)

Example 4 with Page

use of app.Page in project common by zenlunatics.

the class SiteMenu method write.

// --------------------------------------------------------------------------
public void write(String current_page, Request request) throws IOException {
    String context = request.getContext();
    NavBar nav_bar = new NavBar(request.writer).setActiveItem(current_page).setStaticTop(true);
    @SuppressWarnings("unchecked") DBObjects<MenuItem> user_pages = (DBObjects<MenuItem>) request.getSessionAttribute("menu_items");
    if (user_pages == null && request.getUser() != null) {
        user_pages = new DBObjects<MenuItem>(new Select("name").from("menu_items").where("people_id=" + request.getUser().getId()).orderBy("_order_"), MenuItem.class, request.site);
        request.setSessionAttribute("menu_items", user_pages);
    }
    List<MenuItem> menu_items = null;
    if (user_pages != null)
        menu_items = user_pages.getObjects();
    if (menu_items == null || menu_items.size() == 0)
        menu_items = m_menu.getObjects();
    if (m_home_page != null && request.userHasRole("coho")) {
        String label = request.site.getSettings().getString("home");
        if (label == null)
            label = "Home";
        nav_bar.setBrand(label, context + "/" + m_home_page);
    }
    nav_bar.open();
    Pages pages = request.site.getPages();
    for (MenuItem menu_item : menu_items) {
        Page page = pages.getPageByName(menu_item.name);
        if (page != null)
            if ("Other".equals(page.getURL())) {
                boolean first = true;
                for (Page p : pages.getPages()) if (p.onMainMenu() && !menu_items.contains(p) && p.canView(request)) {
                    if (first) {
                        nav_bar.dropdownOpen(page.getName());
                        first = false;
                    }
                    p.a(nav_bar, request);
                }
                if (!first)
                    nav_bar.dropdownClose();
            } else if (page.canView(request))
                page.a(nav_bar, request);
    }
    nav_bar.ulOpen(true);
    if (request.userHasRole("coho")) {
        String label = request.site.getSettings().getString("help");
        if (label == null)
            label = "Help";
        nav_bar.a(label, context + "/Help");
    }
    request.site.writeUserDropdown(nav_bar, request);
    nav_bar.close();
    Person user = request.getUser();
    if (user != null)
        request.setSessionAttribute("current page", current_page);
}
Also used : Pages(app.Pages) DBObjects(db.DBObjects) NavBar(web.NavBar) Select(db.Select) Page(app.Page) Person(app.Person)

Example 5 with Page

use of app.Page in project common by zenlunatics.

the class Documents method init.

// --------------------------------------------------------------------------
@Override
public void init(DBConnection db) {
    JDBCTable table_def = new JDBCTable().add(new JDBCColumn("filename", Types.VARCHAR, 60)).add(new JDBCColumn("title", Types.VARCHAR, 60)).add(new JDBCColumn("type", Types.VARCHAR)).add(new JDBCColumn("url", Types.BOOLEAN)).add(new JDBCColumn("_timestamp_", Types.TIMESTAMP));
    if (m_extra_columns != null)
        for (JDBCColumn column : m_extra_columns) table_def.add(column);
    addColumns(table_def);
    db.getTable("documents", true).createMissingColumns(table_def, db).dropExtraColumns(table_def, db);
    db.createTable("documents_types", "text VARCHAR");
    m_site.addObjects(new Options(new Select("text").from("documents_types").orderBy("text"), true, m_site).setAllowEditing(true));
    Roles.add("docs", m_site, db);
    m_site.addUserDropdownItem(new Page("Edit Documents", m_site) {

        @Override
        public void write(Request request) throws IOException {
            request.site.writePageOpen("Edit Documents", request);
            request.site.newView("edit documents", request).writeComponent();
            request.writer.br();
            request.close();
        }
    }.setRole("docs"), db);
}
Also used : Options(db.Options) JDBCTable(db.JDBCTable) Select(db.Select) Request(app.Request) JDBCColumn(db.JDBCColumn) Page(app.Page)

Aggregations

Page (app.Page)5 JDBCColumn (db.JDBCColumn)3 JDBCTable (db.JDBCTable)3 Select (db.Select)3 Pages (app.Pages)2 Request (app.Request)2 Person (app.Person)1 DBObjects (db.DBObjects)1 Options (db.Options)1 ViewDef (db.ViewDef)1 HTMLWriter (web.HTMLWriter)1 NavBar (web.NavBar)1 Select (web.Select)1