liquid_feedback_frontend
view env/util/help.lua @ 34:a851cc1d9903
Beautified report view for closed issues
author | bsw |
---|---|
date | Wed Feb 24 12:37:28 2010 +0100 (2010-02-24) |
parents | 00d1004545f1 |
children | 0849be391140 |
line source
1 function util.help(id, title)
2 local setting_key = "liquidfeedback_frontend_hidden_help_" .. id
3 local setting = Setting:by_pk(app.session.member.id, setting_key)
4 if not setting then
5 ui.container{
6 attr = { class = "help help_visible" },
7 content = function()
8 ui.image{
9 attr = { class = "help_icon" },
10 static = "icons/16/help.png"
11 }
12 ui.container{
13 attr = { class = "help_actions" },
14 content = function()
15 ui.link{
16 text = _"Hide this help message",
17 module = "help",
18 action = "update",
19 params = {
20 help_ident = id,
21 hide = true
22 },
23 routing = {
24 default = {
25 mode = "redirect",
26 module = request.get_module(),
27 view = request.get_view(),
28 id = param.get_id_cgi(),
29 params = param.get_all_cgi()
30 }
31 }
32 }
33 end
34 }
35 local lang = locale.get("lang")
36 local basepath = request.get_app_basepath()
37 local file_name = basepath .. "/locale/help/" .. id .. "." .. lang .. ".txt"
38 local file = io.open(file_name)
39 if file ~= nil then
40 local help_text = file:read("*a")
41 if #help_text > 0 then
42 ui.container{
43 attr = { class = "wiki" },
44 content = function()
45 slot.put(format.wiki_text(help_text))
46 end
47 }
48 else
49 ui.field.text{ value = _("Empty help text: #{id}.#{lang}.txt", { id = id, lang = lang }) }
50 end
51 else
52 ui.field.text{ value = _("Missing help text: #{id}.#{lang}.txt", { id = id, lang = lang }) }
53 end
54 end
55 }
56 else
57 if util._hidden_helps == nil then
58 util._hidden_helps = {}
59 end
60 util._hidden_helps[#util._hidden_helps+1] = {
61 id = id,
62 title = title
63 }
64 end
65 end