Rails3: helper: use html_safe in SettingsHelper

Contributed by Sylvain Utard.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7544 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-09-29 22:55:18 +00:00
parent 33d41583bb
commit 5d297091fe
1 changed files with 16 additions and 16 deletions

View File

@ -32,18 +32,18 @@ module SettingsHelper
if blank_text = options.delete(:blank) if blank_text = options.delete(:blank)
choices = [[blank_text.is_a?(Symbol) ? l(blank_text) : blank_text, '']] + choices choices = [[blank_text.is_a?(Symbol) ? l(blank_text) : blank_text, '']] + choices
end end
setting_label(setting, options) + setting_label(setting, options).html_safe +
select_tag("settings[#{setting}]", select_tag("settings[#{setting}]",
options_for_select(choices, Setting.send(setting).to_s), options_for_select(choices, Setting.send(setting).to_s),
options) options).html_safe
end end
def setting_multiselect(setting, choices, options={}) def setting_multiselect(setting, choices, options={})
setting_values = Setting.send(setting) setting_values = Setting.send(setting)
setting_values = [] unless setting_values.is_a?(Array) setting_values = [] unless setting_values.is_a?(Array)
setting_label(setting, options) + setting_label(setting, options).html_safe +
hidden_field_tag("settings[#{setting}][]", '') + hidden_field_tag("settings[#{setting}][]", '').html_safe +
choices.collect do |choice| choices.collect do |choice|
text, value = (choice.is_a?(Array) ? choice : [choice, choice]) text, value = (choice.is_a?(Array) ? choice : [choice, choice])
content_tag( content_tag(
@ -55,28 +55,28 @@ module SettingsHelper
) + text.to_s, ) + text.to_s,
:class => 'block' :class => 'block'
) )
end.join end.join.html_safe
end end
def setting_text_field(setting, options={}) def setting_text_field(setting, options={})
setting_label(setting, options) + setting_label(setting, options).html_safe +
text_field_tag("settings[#{setting}]", Setting.send(setting), options) text_field_tag("settings[#{setting}]", Setting.send(setting), options).html_safe
end end
def setting_text_area(setting, options={}) def setting_text_area(setting, options={})
setting_label(setting, options) + setting_label(setting, options).html_safe +
text_area_tag("settings[#{setting}]", Setting.send(setting), options) text_area_tag("settings[#{setting}]", Setting.send(setting), options).html_safe
end end
def setting_check_box(setting, options={}) def setting_check_box(setting, options={})
setting_label(setting, options) + setting_label(setting, options).html_safe +
hidden_field_tag("settings[#{setting}]", 0) + hidden_field_tag("settings[#{setting}]", 0).html_safe +
check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options) check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options).html_safe
end end
def setting_label(setting, options={}) def setting_label(setting, options={})
label = options.delete(:label) label = options.delete(:label)
label != false ? content_tag("label", l(label || "setting_#{setting}")) : '' label != false ? content_tag("label", l(label || "setting_#{setting}")).html_safe : ''
end end
# Renders a notification field for a Redmine::Notifiable option # Renders a notification field for a Redmine::Notifiable option
@ -84,8 +84,8 @@ module SettingsHelper
return content_tag(:label, return content_tag(:label,
check_box_tag('settings[notified_events][]', check_box_tag('settings[notified_events][]',
notifiable.name, notifiable.name,
Setting.notified_events.include?(notifiable.name)) + Setting.notified_events.include?(notifiable.name)).html_safe +
l_or_humanize(notifiable.name, :prefix => 'label_'), l_or_humanize(notifiable.name, :prefix => 'label_').html_safe,
:class => notifiable.parent.present? ? "parent" : '') :class => notifiable.parent.present? ? "parent" : '').html_safe
end end
end end