Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

settings_helper.rb 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. # encoding: utf-8
  2. #
  3. # Redmine - project management software
  4. # Copyright (C) 2006-2012 Jean-Philippe Lang
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License
  8. # as published by the Free Software Foundation; either version 2
  9. # of the License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. module SettingsHelper
  20. def administration_settings_tabs
  21. tabs = [{:name => 'general', :partial => 'settings/general', :label => :label_general},
  22. {:name => 'display', :partial => 'settings/display', :label => :label_display},
  23. {:name => 'authentication', :partial => 'settings/authentication', :label => :label_authentication},
  24. {:name => 'projects', :partial => 'settings/projects', :label => :label_project_plural},
  25. {:name => 'issues', :partial => 'settings/issues', :label => :label_issue_tracking},
  26. {:name => 'notifications', :partial => 'settings/notifications', :label => :field_mail_notification},
  27. {:name => 'mail_handler', :partial => 'settings/mail_handler', :label => :label_incoming_emails},
  28. {:name => 'repositories', :partial => 'settings/repositories', :label => :label_repository_plural}
  29. ]
  30. end
  31. def setting_select(setting, choices, options={})
  32. if blank_text = options.delete(:blank)
  33. choices = [[blank_text.is_a?(Symbol) ? l(blank_text) : blank_text, '']] + choices
  34. end
  35. setting_label(setting, options).html_safe +
  36. select_tag("settings[#{setting}]",
  37. options_for_select(choices, Setting.send(setting).to_s),
  38. options).html_safe
  39. end
  40. def setting_multiselect(setting, choices, options={})
  41. setting_values = Setting.send(setting)
  42. setting_values = [] unless setting_values.is_a?(Array)
  43. content_tag("label", l(options[:label] || "setting_#{setting}")) +
  44. hidden_field_tag("settings[#{setting}][]", '').html_safe +
  45. choices.collect do |choice|
  46. text, value = (choice.is_a?(Array) ? choice : [choice, choice])
  47. content_tag(
  48. 'label',
  49. check_box_tag(
  50. "settings[#{setting}][]",
  51. value,
  52. Setting.send(setting).include?(value),
  53. :id => nil
  54. ) + text.to_s,
  55. :class => 'block'
  56. )
  57. end.join.html_safe
  58. end
  59. def setting_text_field(setting, options={})
  60. setting_label(setting, options).html_safe +
  61. text_field_tag("settings[#{setting}]", Setting.send(setting), options).html_safe
  62. end
  63. def setting_text_area(setting, options={})
  64. setting_label(setting, options).html_safe +
  65. text_area_tag("settings[#{setting}]", Setting.send(setting), options).html_safe
  66. end
  67. def setting_check_box(setting, options={})
  68. setting_label(setting, options).html_safe +
  69. hidden_field_tag("settings[#{setting}]", 0, :id => nil).html_safe +
  70. check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options).html_safe
  71. end
  72. def setting_label(setting, options={})
  73. label = options.delete(:label)
  74. label != false ? label_tag("settings_#{setting}", l(label || "setting_#{setting}")).html_safe : ''
  75. end
  76. # Renders a notification field for a Redmine::Notifiable option
  77. def notification_field(notifiable)
  78. return content_tag(:label,
  79. check_box_tag('settings[notified_events][]',
  80. notifiable.name,
  81. Setting.notified_events.include?(notifiable.name), :id => nil).html_safe +
  82. l_or_humanize(notifiable.name, :prefix => 'label_').html_safe,
  83. :class => notifiable.parent.present? ? "parent" : '').html_safe
  84. end
  85. def cross_project_subtasks_options
  86. options = [
  87. [:label_disabled, ''],
  88. [:label_cross_project_system, 'system'],
  89. [:label_cross_project_tree, 'tree'],
  90. [:label_cross_project_hierarchy, 'hierarchy'],
  91. [:label_cross_project_descendants, 'descendants']
  92. ]
  93. options.map {|label, value| [l(label), value.to_s]}
  94. end
  95. end