webmcp

diff framework/env/ui_deprecated/link.lua @ 0:9fdfb27f8e67

Version 1.0.0
author jbe/bsw
date Sun Oct 25 12:00:00 2009 +0100 (2009-10-25)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/framework/env/ui_deprecated/link.lua	Sun Oct 25 12:00:00 2009 +0100
     1.3 @@ -0,0 +1,69 @@
     1.4 +function ui_deprecated.link(args)
     1.5 +  if args.action then
     1.6 +    local params = {}
     1.7 +    if args.params then
     1.8 +      for key, value in pairs(args.params) do
     1.9 +        params[key] = value
    1.10 +      end
    1.11 +    end
    1.12 +    ui_deprecated._prepare_redirect_params(params, args.redirect_to)
    1.13 +
    1.14 +    local attr_action = args.url or encode.url{
    1.15 +      module = args.module or request.get_module(),
    1.16 +      action = args.action,
    1.17 +      id     = args.id,
    1.18 +      params = params
    1.19 +    }
    1.20 +    local attr_class = table.concat({ 'ui_link', args.class }, ' ')
    1.21 +    local attr_target = args.target or ''
    1.22 +    local redirect_to = args.redirect_to
    1.23 +    local unique_id = "unique_" .. multirand.string(32, "abcdefghijklmnopqrstuvwxyz0123456789")
    1.24 +    slot.put(
    1.25 +      '<form',
    1.26 +      ' id="', unique_id , '"',
    1.27 +      ' action="', attr_action,  '"',
    1.28 +      ' class="', attr_class, '"',
    1.29 +      ' target="', attr_target, '"',
    1.30 +      ' method="post"',
    1.31 +      '>\n',
    1.32 +      '<input type="submit" value="', args.label or '', '" />',
    1.33 +      '</form>',
    1.34 +      '<script>document.getElementById(\'', unique_id, '\').style.display=\'none\';document.write(\'<a href="#" class="', attr_class , '" onclick="document.getElementById(\\\'', unique_id, '\\\').submit();">'
    1.35 +    )
    1.36 +    if args.icon then
    1.37 +      ui_deprecated.image{ image = 'ui/icon/' .. args.icon }
    1.38 +    end
    1.39 +    if args.image then
    1.40 +      ui_deprecated.image{ image = args.image }
    1.41 +    end
    1.42 +    if args.label then
    1.43 +      slot.put(args.label)
    1.44 +    end
    1.45 +    slot.put("</a>');</script>")
    1.46 +  else
    1.47 +    local attr_class = table.concat({ 'ui_link', args.class }, ' ')
    1.48 +    slot.put(
    1.49 +      '<a href="',
    1.50 +      args.url or encode.url{
    1.51 +        module    = args.module or request.get_module(),
    1.52 +        view      = args.view,
    1.53 +        id        = args.id,
    1.54 +        params    = args.params,
    1.55 +      },
    1.56 +      '" ',
    1.57 +      ui_deprecated._stringify_table({ class = attr_class }),
    1.58 +      ui_deprecated._stringify_table( args.html_options or {} ),
    1.59 +      '>'
    1.60 +    )
    1.61 +    if args.icon then
    1.62 +      ui_deprecated.image{ image = 'ui/icon/' .. args.icon }
    1.63 +    end
    1.64 +    if args.image then
    1.65 +      ui_deprecated.image{ image = args.image }
    1.66 +    end
    1.67 +    if args.label then
    1.68 +      slot.put(args.label)
    1.69 +    end
    1.70 +    slot.put('</a>')
    1.71 +  end
    1.72 +end

Impressum / About Us