Add support for grouped items in media/link lists

These commits add support for specifying sublists of links, images and media items by adding them to <optgroup> tags.

It does not affect currently functionality - using lists in the form:
    list = [
        [ "Name", "URL" ],
        ...
    ];

which produces lists like
    - Name
    - ...

still works fine, but this patch makes it possible to use the following form as well:
    list = [ 
        ["Group of links", [
            ["Name", "URL"],
            ...
        ]],
        ...
    ];

which produces lists like:
    - Group of links
        - Name
        - ...

It also works just fine to mix both styles - ie some links in optgroups, others at top level.