Mercurial > hg > soundsoftware-site
comparison app/helpers/.svn/text-base/settings_helper.rb.svn-base @ 441:cbce1fd3b1b7 redmine-1.2
Update to Redmine 1.2-stable branch (Redmine SVN rev 6000)
author | Chris Cannam |
---|---|
date | Mon, 06 Jun 2011 14:24:13 +0100 |
parents | 94944d00e43c |
children |
comparison
equal
deleted
inserted
replaced
245:051f544170fe | 441:cbce1fd3b1b7 |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2009 Jean-Philippe Lang | 2 # Copyright (C) 2006-2011 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
8 # | 8 # |
9 # This program is distributed in the hope that it will be useful, | 9 # This program is distributed in the hope that it will be useful, |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 # GNU General Public License for more details. | 12 # GNU General Public License for more details. |
13 # | 13 # |
14 # You should have received a copy of the GNU General Public License | 14 # You should have received a copy of the GNU General Public License |
15 # along with this program; if not, write to the Free Software | 15 # along with this program; if not, write to the Free Software |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 module SettingsHelper | 18 module SettingsHelper |
25 {:name => 'notifications', :partial => 'settings/notifications', :label => :field_mail_notification}, | 25 {:name => 'notifications', :partial => 'settings/notifications', :label => :field_mail_notification}, |
26 {:name => 'mail_handler', :partial => 'settings/mail_handler', :label => :label_incoming_emails}, | 26 {:name => 'mail_handler', :partial => 'settings/mail_handler', :label => :label_incoming_emails}, |
27 {:name => 'repositories', :partial => 'settings/repositories', :label => :label_repository_plural} | 27 {:name => 'repositories', :partial => 'settings/repositories', :label => :label_repository_plural} |
28 ] | 28 ] |
29 end | 29 end |
30 | 30 |
31 def setting_select(setting, choices, options={}) | 31 def setting_select(setting, choices, options={}) |
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) + |
36 select_tag("settings[#{setting}]", options_for_select(choices, Setting.send(setting).to_s), options) | 36 select_tag("settings[#{setting}]", |
37 options_for_select(choices, Setting.send(setting).to_s), | |
38 options) | |
37 end | 39 end |
38 | 40 |
39 def setting_multiselect(setting, choices, options={}) | 41 def setting_multiselect(setting, choices, options={}) |
40 setting_values = Setting.send(setting) | 42 setting_values = Setting.send(setting) |
41 setting_values = [] unless setting_values.is_a?(Array) | 43 setting_values = [] unless setting_values.is_a?(Array) |
42 | 44 |
43 setting_label(setting, options) + | 45 setting_label(setting, options) + |
44 hidden_field_tag("settings[#{setting}][]", '') + | 46 hidden_field_tag("settings[#{setting}][]", '') + |
45 choices.collect do |choice| | 47 choices.collect do |choice| |
46 text, value = (choice.is_a?(Array) ? choice : [choice, choice]) | 48 text, value = (choice.is_a?(Array) ? choice : [choice, choice]) |
47 content_tag('label', | 49 content_tag( |
48 check_box_tag("settings[#{setting}][]", value, Setting.send(setting).include?(value)) + text.to_s, | 50 'label', |
51 check_box_tag( | |
52 "settings[#{setting}][]", | |
53 value, | |
54 Setting.send(setting).include?(value) | |
55 ) + text.to_s, | |
49 :class => 'block' | 56 :class => 'block' |
50 ) | 57 ) |
51 end.join | 58 end.join |
52 end | 59 end |
53 | 60 |
54 def setting_text_field(setting, options={}) | 61 def setting_text_field(setting, options={}) |
55 setting_label(setting, options) + | 62 setting_label(setting, options) + |
56 text_field_tag("settings[#{setting}]", Setting.send(setting), options) | 63 text_field_tag("settings[#{setting}]", Setting.send(setting), options) |
57 end | 64 end |
58 | 65 |
59 def setting_text_area(setting, options={}) | 66 def setting_text_area(setting, options={}) |
60 setting_label(setting, options) + | 67 setting_label(setting, options) + |
61 text_area_tag("settings[#{setting}]", Setting.send(setting), options) | 68 text_area_tag("settings[#{setting}]", Setting.send(setting), options) |
62 end | 69 end |
63 | 70 |
64 def setting_check_box(setting, options={}) | 71 def setting_check_box(setting, options={}) |
65 setting_label(setting, options) + | 72 setting_label(setting, options) + |
66 hidden_field_tag("settings[#{setting}]", 0) + | 73 hidden_field_tag("settings[#{setting}]", 0) + |
67 check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options) | 74 check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options) |
68 end | 75 end |
69 | 76 |
70 def setting_label(setting, options={}) | 77 def setting_label(setting, options={}) |
71 label = options.delete(:label) | 78 label = options.delete(:label) |
72 label != false ? content_tag("label", l(label || "setting_#{setting}")) : '' | 79 label != false ? content_tag("label", l(label || "setting_#{setting}")) : '' |
73 end | 80 end |
74 | 81 |