##// END OF EJS Templates
Rails3: helper: use html_safe in SettingsHelper...
Toshi MARUYAMA -
r7424:5d297091fe04
parent child
Show More
@@ -32,18 +32,18 module SettingsHelper
32 if blank_text = options.delete(:blank)
32 if blank_text = options.delete(:blank)
33 choices = [[blank_text.is_a?(Symbol) ? l(blank_text) : blank_text, '']] + choices
33 choices = [[blank_text.is_a?(Symbol) ? l(blank_text) : blank_text, '']] + choices
34 end
34 end
35 setting_label(setting, options) +
35 setting_label(setting, options).html_safe +
36 select_tag("settings[#{setting}]",
36 select_tag("settings[#{setting}]",
37 options_for_select(choices, Setting.send(setting).to_s),
37 options_for_select(choices, Setting.send(setting).to_s),
38 options)
38 options).html_safe
39 end
39 end
40
40
41 def setting_multiselect(setting, choices, options={})
41 def setting_multiselect(setting, choices, options={})
42 setting_values = Setting.send(setting)
42 setting_values = Setting.send(setting)
43 setting_values = [] unless setting_values.is_a?(Array)
43 setting_values = [] unless setting_values.is_a?(Array)
44
44
45 setting_label(setting, options) +
45 setting_label(setting, options).html_safe +
46 hidden_field_tag("settings[#{setting}][]", '') +
46 hidden_field_tag("settings[#{setting}][]", '').html_safe +
47 choices.collect do |choice|
47 choices.collect do |choice|
48 text, value = (choice.is_a?(Array) ? choice : [choice, choice])
48 text, value = (choice.is_a?(Array) ? choice : [choice, choice])
49 content_tag(
49 content_tag(
@@ -55,28 +55,28 module SettingsHelper
55 ) + text.to_s,
55 ) + text.to_s,
56 :class => 'block'
56 :class => 'block'
57 )
57 )
58 end.join
58 end.join.html_safe
59 end
59 end
60
60
61 def setting_text_field(setting, options={})
61 def setting_text_field(setting, options={})
62 setting_label(setting, options) +
62 setting_label(setting, options).html_safe +
63 text_field_tag("settings[#{setting}]", Setting.send(setting), options)
63 text_field_tag("settings[#{setting}]", Setting.send(setting), options).html_safe
64 end
64 end
65
65
66 def setting_text_area(setting, options={})
66 def setting_text_area(setting, options={})
67 setting_label(setting, options) +
67 setting_label(setting, options).html_safe +
68 text_area_tag("settings[#{setting}]", Setting.send(setting), options)
68 text_area_tag("settings[#{setting}]", Setting.send(setting), options).html_safe
69 end
69 end
70
70
71 def setting_check_box(setting, options={})
71 def setting_check_box(setting, options={})
72 setting_label(setting, options) +
72 setting_label(setting, options).html_safe +
73 hidden_field_tag("settings[#{setting}]", 0) +
73 hidden_field_tag("settings[#{setting}]", 0).html_safe +
74 check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options)
74 check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options).html_safe
75 end
75 end
76
76
77 def setting_label(setting, options={})
77 def setting_label(setting, options={})
78 label = options.delete(:label)
78 label = options.delete(:label)
79 label != false ? content_tag("label", l(label || "setting_#{setting}")) : ''
79 label != false ? content_tag("label", l(label || "setting_#{setting}")).html_safe : ''
80 end
80 end
81
81
82 # Renders a notification field for a Redmine::Notifiable option
82 # Renders a notification field for a Redmine::Notifiable option
@@ -84,8 +84,8 module SettingsHelper
84 return content_tag(:label,
84 return content_tag(:label,
85 check_box_tag('settings[notified_events][]',
85 check_box_tag('settings[notified_events][]',
86 notifiable.name,
86 notifiable.name,
87 Setting.notified_events.include?(notifiable.name)) +
87 Setting.notified_events.include?(notifiable.name)).html_safe +
88 l_or_humanize(notifiable.name, :prefix => 'label_'),
88 l_or_humanize(notifiable.name, :prefix => 'label_').html_safe,
89 :class => notifiable.parent.present? ? "parent" : '')
89 :class => notifiable.parent.present? ? "parent" : '').html_safe
90 end
90 end
91 end
91 end
General Comments 0
You need to be logged in to leave comments. Login now