liquid_feedback_frontend
diff env/util/help.lua @ 4:80c215dbf076
Version alpha5
Many optical changes and improved usability
Support for different wiki-formatting-engines
Help system
Many optical changes and improved usability
Support for different wiki-formatting-engines
Help system
author | bsw/jbe |
---|---|
date | Thu Dec 10 12:00:00 2009 +0100 (2009-12-10) |
parents | |
children | 00d1004545f1 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/env/util/help.lua Thu Dec 10 12:00:00 2009 +0100 1.3 @@ -0,0 +1,65 @@ 1.4 +function util.help(id, title) 1.5 + local setting_key = "liquidfeedback_frontend_hidden_help_" .. id 1.6 + local setting = Setting:by_pk(app.session.member.id, setting_key) 1.7 + if not setting then 1.8 + ui.container{ 1.9 + attr = { class = "help help_visible" }, 1.10 + content = function() 1.11 + ui.image{ 1.12 + attr = { class = "help_icon" }, 1.13 + static = "icons/16/help.png" 1.14 + } 1.15 + ui.container{ 1.16 + attr = { class = "help_actions" }, 1.17 + content = function() 1.18 + ui.link{ 1.19 + content = _"Hide this help message", 1.20 + module = "help", 1.21 + action = "update", 1.22 + params = { 1.23 + help_ident = id, 1.24 + hide = true 1.25 + }, 1.26 + routing = { 1.27 + default = { 1.28 + mode = "redirect", 1.29 + module = request.get_module(), 1.30 + view = request.get_view(), 1.31 + id = param.get_id_cgi(), 1.32 + params = param.get_all_cgi() 1.33 + } 1.34 + } 1.35 + } 1.36 + end 1.37 + } 1.38 + local lang = locale.get("lang") 1.39 + local basepath = request.get_app_basepath() 1.40 + local file_name = basepath .. "/locale/help/" .. id .. "." .. lang .. ".txt" 1.41 + local file = io.open(file_name) 1.42 + if file ~= nil then 1.43 + local help_text = file:read("*a") 1.44 + if #help_text > 0 then 1.45 + ui.container{ 1.46 + attr = { class = "wiki" }, 1.47 + content = function() 1.48 + slot.put(format.wiki_text(help_text)) 1.49 + end 1.50 + } 1.51 + else 1.52 + ui.field.text{ value = _("Empty help text: #{id}.#{lang}.txt", { id = id, lang = lang }) } 1.53 + end 1.54 + else 1.55 + ui.field.text{ value = _("Missing help text: #{id}.#{lang}.txt", { id = id, lang = lang }) } 1.56 + end 1.57 + end 1.58 + } 1.59 + else 1.60 + if util._hidden_helps == nil then 1.61 + util._hidden_helps = {} 1.62 + end 1.63 + util._hidden_helps[#util._hidden_helps+1] = { 1.64 + id = id, 1.65 + title = title 1.66 + } 1.67 + end 1.68 +end 1.69 \ No newline at end of file