ui/ui.d [ Modules ]

[ Top ] [ Modules ]

NAME

    ui.d

FUNCTION

    Helper functions for html views.

ui/errors_for [ Functions ]

[ Top ] [ Functions ]

FUNCTION

    Returns the validation errors for a model in html.

SOURCE

// FIXME: This should not need the named passed in.
// FIXME: This should say updated for already saved models
public static string errors_for(ModelBase model, string name) {
    // Just return a blank if there were no errors
    if(model.errors.length == 0)
        return "";

    // Return an error box if there are errors
    string retval = "";
    retval ~= "<div id=\"error_explanation\">\n";
    retval ~= "<h2>" ~ to_s(model.errors.length) ~ " errors prohibited this " ~ name ~ " from being saved</h2>\n";
    retval ~= "<p>There were problems with the following fields:</p>\n";
    retval ~= " <ul>\n";

    foreach(string error; model.errors) {
        retval ~= "     <li>" ~ error ~ "</li>\n";
    }

    retval ~= " </ul>\n";
    retval ~= "</div>\n";
    return retval;
}

ui/form_end [ Functions ]

[ Top ] [ Functions ]

FUNCTION

    Returns a html </form> tag.

SOURCE

public static string form_end() {
    return "</form>";
}

ui/form_start [ Functions ]

[ Top ] [ Functions ]

FUNCTION

    Returns a html <form> tag.

SOURCE

public static string form_start(string action, string id, string css_class, string method) {
    string real_url = get_real_url(action);
    return "<form action=\"/" ~ real_url ~ "\" class=\"" ~ css_class ~ "\" id=\"" ~ id ~ "\" method=\"" ~ method ~ "\">";
}

ui/get_real_url [ Functions ]

[ Top ] [ Functions ]

FUNCTION

    Returns base_get_real_url with the controller supplied by set_controller.

SOURCE

private static string get_real_url(string url) {
    return base_get_real_url(controller, url);
}

ui/h( bool ) [ Functions ]

[ Top ] [ Functions ]

FUNCTION

    Returns the bool converted into a string and filtered by escape_html.

SOURCE

public static string h(bool value) { return h(to_s(value)); }

ui/h( char ) [ Functions ]

[ Top ] [ Functions ]

FUNCTION

    Returns the char converted into a string and filtered by escape_html.

SOURCE

public static string h(char value) { return h(to_s(value)); }

ui/h( double ) [ Functions ]

[ Top ] [ Functions ]

FUNCTION

    Returns the double converted into a string and filtered by escape_html.

SOURCE

public static string h(double value) { return h(to_s(value)); }

ui/h( FixedPoint ) [ Functions ]

[ Top ] [ Functions ]

FUNCTION

    Returns the FixedPoint converted into a string and filtered by escape_html.

SOURCE

public static string h(FixedPoint value) { return h(to_s(value)); }

ui/h( float ) [ Functions ]

[ Top ] [ Functions ]

FUNCTION

    Returns the float converted into a string and filtered by escape_html.

SOURCE

public static string h(float value) { return h(to_s(value)); }

ui/h( int ) [ Functions ]

[ Top ] [ Functions ]

FUNCTION

    Returns the int converted into a string and filtered by escape_html.

SOURCE

public static string h(int value) { return h(to_s(value)); }

ui/h( long ) [ Functions ]

[ Top ] [ Functions ]

FUNCTION

    Returns the long converted into a string and filtered by escape_html.

SOURCE

public static string h(long value) { return h(to_s(value)); }

ui/h( string ) [ Functions ]

[ Top ] [ Functions ]

FUNCTION

    Returns the string filtered by escape_html.

SOURCE

public static string h(string value) { return escape_html(value);}

ui/h( uint ) [ Functions ]

[ Top ] [ Functions ]

FUNCTION

    Returns the uint converted into a string and filtered by escape_html.

SOURCE

public static string h(uint value) { return h(to_s(value)); }

ui/h( ulong ) [ Functions ]

[ Top ] [ Functions ]

FUNCTION

    Returns the ulong converted into a string and filtered by escape_html.

SOURCE

public static string h(ulong value) { return h(to_s(value)); }

ui/link_to [ Functions ]

[ Top ] [ Functions ]

FUNCTION

    Returns a html <a href></a> tag.

SOURCE

public static string link_to(string name, string url, string opt="") {
    string real_url = get_real_url(url);
    return "<a href=\"" ~ real_url ~ "\"" ~ opt ~ ">" ~ name ~ "</a>";
}

ui/set_controller [ Functions ]

[ Top ] [ Functions ]

FUNCTION

    Set the controller that is used by other functions.

SOURCE

public static ControllerBase controller = null;
public static void set_controller(ControllerBase value) {
    controller = value;
}