##// END OF EJS Templates
Removed RedCloth checks since it's now supplied with the application....
Jean-Philippe Lang -
r697:22ad806a439e
parent child
Show More
@@ -1,72 +1,71
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 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 class AdminController < ApplicationController
18 class AdminController < ApplicationController
19 layout 'base'
19 layout 'base'
20 before_filter :require_admin
20 before_filter :require_admin
21
21
22 helper :sort
22 helper :sort
23 include SortHelper
23 include SortHelper
24
24
25 def index
25 def index
26 end
26 end
27
27
28 def projects
28 def projects
29 sort_init 'name', 'asc'
29 sort_init 'name', 'asc'
30 sort_update
30 sort_update
31
31
32 @status = params[:status] ? params[:status].to_i : 0
32 @status = params[:status] ? params[:status].to_i : 0
33 conditions = nil
33 conditions = nil
34 conditions = ["status=?", @status] unless @status == 0
34 conditions = ["status=?", @status] unless @status == 0
35
35
36 @project_count = Project.count(:conditions => conditions)
36 @project_count = Project.count(:conditions => conditions)
37 @project_pages = Paginator.new self, @project_count,
37 @project_pages = Paginator.new self, @project_count,
38 25,
38 25,
39 params['page']
39 params['page']
40 @projects = Project.find :all, :order => sort_clause,
40 @projects = Project.find :all, :order => sort_clause,
41 :conditions => conditions,
41 :conditions => conditions,
42 :limit => @project_pages.items_per_page,
42 :limit => @project_pages.items_per_page,
43 :offset => @project_pages.current.offset
43 :offset => @project_pages.current.offset
44
44
45 render :action => "projects", :layout => false if request.xhr?
45 render :action => "projects", :layout => false if request.xhr?
46 end
46 end
47
47
48 def mail_options
48 def mail_options
49 end
49 end
50
50
51 def test_email
51 def test_email
52 raise_delivery_errors = ActionMailer::Base.raise_delivery_errors
52 raise_delivery_errors = ActionMailer::Base.raise_delivery_errors
53 # Force ActionMailer to raise delivery errors so we can catch it
53 # Force ActionMailer to raise delivery errors so we can catch it
54 ActionMailer::Base.raise_delivery_errors = true
54 ActionMailer::Base.raise_delivery_errors = true
55 begin
55 begin
56 @test = Mailer.deliver_test(User.current)
56 @test = Mailer.deliver_test(User.current)
57 flash[:notice] = l(:notice_email_sent, User.current.mail)
57 flash[:notice] = l(:notice_email_sent, User.current.mail)
58 rescue Exception => e
58 rescue Exception => e
59 flash[:error] = l(:notice_email_error, e.message)
59 flash[:error] = l(:notice_email_error, e.message)
60 end
60 end
61 ActionMailer::Base.raise_delivery_errors = raise_delivery_errors
61 ActionMailer::Base.raise_delivery_errors = raise_delivery_errors
62 redirect_to :action => 'mail_options'
62 redirect_to :action => 'mail_options'
63 end
63 end
64
64
65 def info
65 def info
66 @db_adapter_name = ActiveRecord::Base.connection.adapter_name
66 @db_adapter_name = ActiveRecord::Base.connection.adapter_name
67 @flags = Hash.new
67 @flags = Hash.new
68 @flags[:default_admin_changed] = User.find(:first, :conditions => ["login=? and hashed_password=?", 'admin', User.hash_password('admin')]).nil?
68 @flags[:default_admin_changed] = User.find(:first, :conditions => ["login=? and hashed_password=?", 'admin', User.hash_password('admin')]).nil?
69 @flags[:file_repository_writable] = File.writable?(Attachment.storage_path)
69 @flags[:file_repository_writable] = File.writable?(Attachment.storage_path)
70 @flags[:textile_available] = ActionView::Helpers::TextHelper.method_defined? "textilize"
71 end
70 end
72 end
71 end
@@ -1,34 +1,33
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 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 class SettingsController < ApplicationController
18 class SettingsController < ApplicationController
19 layout 'base'
19 layout 'base'
20 before_filter :require_admin
20 before_filter :require_admin
21
21
22 def index
22 def index
23 edit
23 edit
24 render :action => 'edit'
24 render :action => 'edit'
25 end
25 end
26
26
27 def edit
27 def edit
28 if request.post? and params[:settings] and params[:settings].is_a? Hash
28 if request.post? and params[:settings] and params[:settings].is_a? Hash
29 params[:settings].each { |name, value| Setting[name] = value }
29 params[:settings].each { |name, value| Setting[name] = value }
30 redirect_to :action => 'edit' and return
30 redirect_to :action => 'edit' and return
31 end
31 end
32 @textile_available = ActionView::Helpers::TextHelper.method_defined?("textilize")
33 end
32 end
34 end
33 end
@@ -1,292 +1,292
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 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 ApplicationHelper
18 module ApplicationHelper
19
19
20 def current_role
20 def current_role
21 @current_role ||= User.current.role_for_project(@project)
21 @current_role ||= User.current.role_for_project(@project)
22 end
22 end
23
23
24 # Return true if user is authorized for controller/action, otherwise false
24 # Return true if user is authorized for controller/action, otherwise false
25 def authorize_for(controller, action)
25 def authorize_for(controller, action)
26 User.current.allowed_to?({:controller => controller, :action => action}, @project)
26 User.current.allowed_to?({:controller => controller, :action => action}, @project)
27 end
27 end
28
28
29 # Display a link if user is authorized
29 # Display a link if user is authorized
30 def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
30 def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
31 link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
31 link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
32 end
32 end
33
33
34 # Display a link to user's account page
34 # Display a link to user's account page
35 def link_to_user(user)
35 def link_to_user(user)
36 link_to user.name, :controller => 'account', :action => 'show', :id => user
36 link_to user.name, :controller => 'account', :action => 'show', :id => user
37 end
37 end
38
38
39 def link_to_issue(issue)
39 def link_to_issue(issue)
40 link_to "#{issue.tracker.name} ##{issue.id}", :controller => "issues", :action => "show", :id => issue
40 link_to "#{issue.tracker.name} ##{issue.id}", :controller => "issues", :action => "show", :id => issue
41 end
41 end
42
42
43 def toggle_link(name, id, options={})
43 def toggle_link(name, id, options={})
44 onclick = "Element.toggle('#{id}'); "
44 onclick = "Element.toggle('#{id}'); "
45 onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ")
45 onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ")
46 onclick << "return false;"
46 onclick << "return false;"
47 link_to(name, "#", :onclick => onclick)
47 link_to(name, "#", :onclick => onclick)
48 end
48 end
49
49
50 def image_to_function(name, function, html_options = {})
50 def image_to_function(name, function, html_options = {})
51 html_options.symbolize_keys!
51 html_options.symbolize_keys!
52 tag(:input, html_options.merge({
52 tag(:input, html_options.merge({
53 :type => "image", :src => image_path(name),
53 :type => "image", :src => image_path(name),
54 :onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};"
54 :onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};"
55 }))
55 }))
56 end
56 end
57
57
58 def prompt_to_remote(name, text, param, url, html_options = {})
58 def prompt_to_remote(name, text, param, url, html_options = {})
59 html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;"
59 html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;"
60 link_to name, {}, html_options
60 link_to name, {}, html_options
61 end
61 end
62
62
63 def format_date(date)
63 def format_date(date)
64 return nil unless date
64 return nil unless date
65 @date_format_setting ||= Setting.date_format.to_i
65 @date_format_setting ||= Setting.date_format.to_i
66 @date_format_setting == 0 ? l_date(date) : date.strftime("%Y-%m-%d")
66 @date_format_setting == 0 ? l_date(date) : date.strftime("%Y-%m-%d")
67 end
67 end
68
68
69 def format_time(time)
69 def format_time(time)
70 return nil unless time
70 return nil unless time
71 @date_format_setting ||= Setting.date_format.to_i
71 @date_format_setting ||= Setting.date_format.to_i
72 time = time.to_time if time.is_a?(String)
72 time = time.to_time if time.is_a?(String)
73 @date_format_setting == 0 ? l_datetime(time) : (time.strftime("%Y-%m-%d") + ' ' + l_time(time))
73 @date_format_setting == 0 ? l_datetime(time) : (time.strftime("%Y-%m-%d") + ' ' + l_time(time))
74 end
74 end
75
75
76 def day_name(day)
76 def day_name(day)
77 l(:general_day_names).split(',')[day-1]
77 l(:general_day_names).split(',')[day-1]
78 end
78 end
79
79
80 def month_name(month)
80 def month_name(month)
81 l(:actionview_datehelper_select_month_names).split(',')[month-1]
81 l(:actionview_datehelper_select_month_names).split(',')[month-1]
82 end
82 end
83
83
84 def pagination_links_full(paginator, options={}, html_options={})
84 def pagination_links_full(paginator, options={}, html_options={})
85 page_param = options.delete(:page_param) || :page
85 page_param = options.delete(:page_param) || :page
86
86
87 html = ''
87 html = ''
88 html << link_to_remote(('&#171; ' + l(:label_previous)),
88 html << link_to_remote(('&#171; ' + l(:label_previous)),
89 {:update => "content", :url => options.merge(page_param => paginator.current.previous)},
89 {:update => "content", :url => options.merge(page_param => paginator.current.previous)},
90 {:href => url_for(:params => options.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous
90 {:href => url_for(:params => options.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous
91
91
92 html << (pagination_links_each(paginator, options) do |n|
92 html << (pagination_links_each(paginator, options) do |n|
93 link_to_remote(n.to_s,
93 link_to_remote(n.to_s,
94 {:url => {:params => options.merge(page_param => n)}, :update => 'content'},
94 {:url => {:params => options.merge(page_param => n)}, :update => 'content'},
95 {:href => url_for(:params => options.merge(page_param => n))})
95 {:href => url_for(:params => options.merge(page_param => n))})
96 end || '')
96 end || '')
97
97
98 html << ' ' + link_to_remote((l(:label_next) + ' &#187;'),
98 html << ' ' + link_to_remote((l(:label_next) + ' &#187;'),
99 {:update => "content", :url => options.merge(page_param => paginator.current.next)},
99 {:update => "content", :url => options.merge(page_param => paginator.current.next)},
100 {:href => url_for(:params => options.merge(page_param => paginator.current.next))}) if paginator.current.next
100 {:href => url_for(:params => options.merge(page_param => paginator.current.next))}) if paginator.current.next
101 html
101 html
102 end
102 end
103
103
104 # textilize text according to system settings and RedCloth availability
104 # format text according to system settings
105 def textilizable(text, options = {})
105 def textilizable(text, options = {})
106 return "" if text.blank?
106 return "" if text.blank?
107
107
108 # when using an image link, try to use an attachment, if possible
108 # when using an image link, try to use an attachment, if possible
109 attachments = options[:attachments]
109 attachments = options[:attachments]
110 if attachments
110 if attachments
111 text = text.gsub(/!([<>=]*)(\S+\.(gif|jpg|jpeg|png))!/) do |m|
111 text = text.gsub(/!([<>=]*)(\S+\.(gif|jpg|jpeg|png))!/) do |m|
112 align = $1
112 align = $1
113 filename = $2
113 filename = $2
114 rf = Regexp.new(filename, Regexp::IGNORECASE)
114 rf = Regexp.new(filename, Regexp::IGNORECASE)
115 # search for the picture in attachments
115 # search for the picture in attachments
116 if found = attachments.detect { |att| att.filename =~ rf }
116 if found = attachments.detect { |att| att.filename =~ rf }
117 image_url = url_for :controller => 'attachments', :action => 'download', :id => found.id
117 image_url = url_for :controller => 'attachments', :action => 'download', :id => found.id
118 "!#{align}#{image_url}!"
118 "!#{align}#{image_url}!"
119 else
119 else
120 "!#{align}#{filename}!"
120 "!#{align}#{filename}!"
121 end
121 end
122 end
122 end
123 end
123 end
124
124
125 text = (Setting.text_formatting == 'textile') ?
125 text = (Setting.text_formatting == 'textile') ?
126 Redmine::WikiFormatting.to_html(text) : simple_format(auto_link(h(text)))
126 Redmine::WikiFormatting.to_html(text) : simple_format(auto_link(h(text)))
127
127
128 # different methods for formatting wiki links
128 # different methods for formatting wiki links
129 case options[:wiki_links]
129 case options[:wiki_links]
130 when :local
130 when :local
131 # used for local links to html files
131 # used for local links to html files
132 format_wiki_link = Proc.new {|project, title| "#{title}.html" }
132 format_wiki_link = Proc.new {|project, title| "#{title}.html" }
133 when :anchor
133 when :anchor
134 # used for single-file wiki export
134 # used for single-file wiki export
135 format_wiki_link = Proc.new {|project, title| "##{title}" }
135 format_wiki_link = Proc.new {|project, title| "##{title}" }
136 else
136 else
137 format_wiki_link = Proc.new {|project, title| url_for :controller => 'wiki', :action => 'index', :id => project, :page => title }
137 format_wiki_link = Proc.new {|project, title| url_for :controller => 'wiki', :action => 'index', :id => project, :page => title }
138 end
138 end
139
139
140 project = options[:project] || @project
140 project = options[:project] || @project
141
141
142 # turn wiki links into html links
142 # turn wiki links into html links
143 # example:
143 # example:
144 # [[mypage]]
144 # [[mypage]]
145 # [[mypage|mytext]]
145 # [[mypage|mytext]]
146 # wiki links can refer other project wikis, using project name or identifier:
146 # wiki links can refer other project wikis, using project name or identifier:
147 # [[project:]] -> wiki starting page
147 # [[project:]] -> wiki starting page
148 # [[project:|mytext]]
148 # [[project:|mytext]]
149 # [[project:mypage]]
149 # [[project:mypage]]
150 # [[project:mypage|mytext]]
150 # [[project:mypage|mytext]]
151 text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) do |m|
151 text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) do |m|
152 link_project = project
152 link_project = project
153 page = $1
153 page = $1
154 title = $3
154 title = $3
155 if page =~ /^([^\:]+)\:(.*)$/
155 if page =~ /^([^\:]+)\:(.*)$/
156 link_project = Project.find_by_name($1) || Project.find_by_identifier($1)
156 link_project = Project.find_by_name($1) || Project.find_by_identifier($1)
157 page = title || $2
157 page = title || $2
158 title = $1 if page.blank?
158 title = $1 if page.blank?
159 end
159 end
160 link_to((title || page), format_wiki_link.call(link_project, Wiki.titleize(page)), :class => 'wiki-page')
160 link_to((title || page), format_wiki_link.call(link_project, Wiki.titleize(page)), :class => 'wiki-page')
161 end
161 end
162
162
163 # turn issue and revision ids into links
163 # turn issue and revision ids into links
164 # example:
164 # example:
165 # #52 -> <a href="/issues/show/52">#52</a>
165 # #52 -> <a href="/issues/show/52">#52</a>
166 # r52 -> <a href="/repositories/revision/6?rev=52">r52</a> (project.id is 6)
166 # r52 -> <a href="/repositories/revision/6?rev=52">r52</a> (project.id is 6)
167 text = text.gsub(%r{([\s,-^])(#|r)(\d+)(?=[[:punct:]]|\s|<|$)}) do |m|
167 text = text.gsub(%r{([\s,-^])(#|r)(\d+)(?=[[:punct:]]|\s|<|$)}) do |m|
168 leading, otype, oid = $1, $2, $3
168 leading, otype, oid = $1, $2, $3
169 link = nil
169 link = nil
170 if otype == 'r'
170 if otype == 'r'
171 link = link_to("r#{oid}", {:controller => 'repositories', :action => 'revision', :id => project.id, :rev => oid}, :class => 'changeset') if project
171 link = link_to("r#{oid}", {:controller => 'repositories', :action => 'revision', :id => project.id, :rev => oid}, :class => 'changeset') if project
172 else
172 else
173 link = link_to("##{oid}", {:controller => 'issues', :action => 'show', :id => oid}, :class => 'issue')
173 link = link_to("##{oid}", {:controller => 'issues', :action => 'show', :id => oid}, :class => 'issue')
174 end
174 end
175 leading + (link || "#{otype}#{oid}")
175 leading + (link || "#{otype}#{oid}")
176 end
176 end
177
177
178 text
178 text
179 end
179 end
180
180
181 # Same as Rails' simple_format helper without using paragraphs
181 # Same as Rails' simple_format helper without using paragraphs
182 def simple_format_without_paragraph(text)
182 def simple_format_without_paragraph(text)
183 text.to_s.
183 text.to_s.
184 gsub(/\r\n?/, "\n"). # \r\n and \r -> \n
184 gsub(/\r\n?/, "\n"). # \r\n and \r -> \n
185 gsub(/\n\n+/, "<br /><br />"). # 2+ newline -> 2 br
185 gsub(/\n\n+/, "<br /><br />"). # 2+ newline -> 2 br
186 gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
186 gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
187 end
187 end
188
188
189 def error_messages_for(object_name, options = {})
189 def error_messages_for(object_name, options = {})
190 options = options.symbolize_keys
190 options = options.symbolize_keys
191 object = instance_variable_get("@#{object_name}")
191 object = instance_variable_get("@#{object_name}")
192 if object && !object.errors.empty?
192 if object && !object.errors.empty?
193 # build full_messages here with controller current language
193 # build full_messages here with controller current language
194 full_messages = []
194 full_messages = []
195 object.errors.each do |attr, msg|
195 object.errors.each do |attr, msg|
196 next if msg.nil?
196 next if msg.nil?
197 msg = msg.first if msg.is_a? Array
197 msg = msg.first if msg.is_a? Array
198 if attr == "base"
198 if attr == "base"
199 full_messages << l(msg)
199 full_messages << l(msg)
200 else
200 else
201 full_messages << "&#171; " + (l_has_string?("field_" + attr) ? l("field_" + attr) : object.class.human_attribute_name(attr)) + " &#187; " + l(msg) unless attr == "custom_values"
201 full_messages << "&#171; " + (l_has_string?("field_" + attr) ? l("field_" + attr) : object.class.human_attribute_name(attr)) + " &#187; " + l(msg) unless attr == "custom_values"
202 end
202 end
203 end
203 end
204 # retrieve custom values error messages
204 # retrieve custom values error messages
205 if object.errors[:custom_values]
205 if object.errors[:custom_values]
206 object.custom_values.each do |v|
206 object.custom_values.each do |v|
207 v.errors.each do |attr, msg|
207 v.errors.each do |attr, msg|
208 next if msg.nil?
208 next if msg.nil?
209 msg = msg.first if msg.is_a? Array
209 msg = msg.first if msg.is_a? Array
210 full_messages << "&#171; " + v.custom_field.name + " &#187; " + l(msg)
210 full_messages << "&#171; " + v.custom_field.name + " &#187; " + l(msg)
211 end
211 end
212 end
212 end
213 end
213 end
214 content_tag("div",
214 content_tag("div",
215 content_tag(
215 content_tag(
216 options[:header_tag] || "span", lwr(:gui_validation_error, full_messages.length) + ":"
216 options[:header_tag] || "span", lwr(:gui_validation_error, full_messages.length) + ":"
217 ) +
217 ) +
218 content_tag("ul", full_messages.collect { |msg| content_tag("li", msg) }),
218 content_tag("ul", full_messages.collect { |msg| content_tag("li", msg) }),
219 "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation"
219 "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation"
220 )
220 )
221 else
221 else
222 ""
222 ""
223 end
223 end
224 end
224 end
225
225
226 def lang_options_for_select(blank=true)
226 def lang_options_for_select(blank=true)
227 (blank ? [["(auto)", ""]] : []) +
227 (blank ? [["(auto)", ""]] : []) +
228 GLoc.valid_languages.collect{|lang| [ ll(lang.to_s, :general_lang_name), lang.to_s]}.sort{|x,y| x.first <=> y.first }
228 GLoc.valid_languages.collect{|lang| [ ll(lang.to_s, :general_lang_name), lang.to_s]}.sort{|x,y| x.first <=> y.first }
229 end
229 end
230
230
231 def label_tag_for(name, option_tags = nil, options = {})
231 def label_tag_for(name, option_tags = nil, options = {})
232 label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
232 label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
233 content_tag("label", label_text)
233 content_tag("label", label_text)
234 end
234 end
235
235
236 def labelled_tabular_form_for(name, object, options, &proc)
236 def labelled_tabular_form_for(name, object, options, &proc)
237 options[:html] ||= {}
237 options[:html] ||= {}
238 options[:html].store :class, "tabular"
238 options[:html].store :class, "tabular"
239 form_for(name, object, options.merge({ :builder => TabularFormBuilder, :lang => current_language}), &proc)
239 form_for(name, object, options.merge({ :builder => TabularFormBuilder, :lang => current_language}), &proc)
240 end
240 end
241
241
242 def check_all_links(form_name)
242 def check_all_links(form_name)
243 link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") +
243 link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") +
244 " | " +
244 " | " +
245 link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
245 link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
246 end
246 end
247
247
248 def calendar_for(field_id)
248 def calendar_for(field_id)
249 image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
249 image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
250 javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });")
250 javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });")
251 end
251 end
252
252
253 def wikitoolbar_for(field_id)
253 def wikitoolbar_for(field_id)
254 return '' unless Setting.text_formatting == 'textile'
254 return '' unless Setting.text_formatting == 'textile'
255 javascript_include_tag('jstoolbar') + javascript_tag("var toolbar = new jsToolBar($('#{field_id}')); toolbar.draw();")
255 javascript_include_tag('jstoolbar') + javascript_tag("var toolbar = new jsToolBar($('#{field_id}')); toolbar.draw();")
256 end
256 end
257 end
257 end
258
258
259 class TabularFormBuilder < ActionView::Helpers::FormBuilder
259 class TabularFormBuilder < ActionView::Helpers::FormBuilder
260 include GLoc
260 include GLoc
261
261
262 def initialize(object_name, object, template, options, proc)
262 def initialize(object_name, object, template, options, proc)
263 set_language_if_valid options.delete(:lang)
263 set_language_if_valid options.delete(:lang)
264 @object_name, @object, @template, @options, @proc = object_name, object, template, options, proc
264 @object_name, @object, @template, @options, @proc = object_name, object, template, options, proc
265 end
265 end
266
266
267 (field_helpers - %w(radio_button hidden_field) + %w(date_select)).each do |selector|
267 (field_helpers - %w(radio_button hidden_field) + %w(date_select)).each do |selector|
268 src = <<-END_SRC
268 src = <<-END_SRC
269 def #{selector}(field, options = {})
269 def #{selector}(field, options = {})
270 return super if options.delete :no_label
270 return super if options.delete :no_label
271 label_text = l(options[:label]) if options[:label]
271 label_text = l(options[:label]) if options[:label]
272 label_text ||= l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym)
272 label_text ||= l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym)
273 label_text << @template.content_tag("span", " *", :class => "required") if options.delete(:required)
273 label_text << @template.content_tag("span", " *", :class => "required") if options.delete(:required)
274 label = @template.content_tag("label", label_text,
274 label = @template.content_tag("label", label_text,
275 :class => (@object && @object.errors[field] ? "error" : nil),
275 :class => (@object && @object.errors[field] ? "error" : nil),
276 :for => (@object_name.to_s + "_" + field.to_s))
276 :for => (@object_name.to_s + "_" + field.to_s))
277 label + super
277 label + super
278 end
278 end
279 END_SRC
279 END_SRC
280 class_eval src, __FILE__, __LINE__
280 class_eval src, __FILE__, __LINE__
281 end
281 end
282
282
283 def select(field, choices, options = {}, html_options = {})
283 def select(field, choices, options = {}, html_options = {})
284 label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
284 label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
285 label = @template.content_tag("label", label_text,
285 label = @template.content_tag("label", label_text,
286 :class => (@object && @object.errors[field] ? "error" : nil),
286 :class => (@object && @object.errors[field] ? "error" : nil),
287 :for => (@object_name.to_s + "_" + field.to_s))
287 :for => (@object_name.to_s + "_" + field.to_s))
288 label + super
288 label + super
289 end
289 end
290
290
291 end
291 end
292
292
@@ -1,9 +1,8
1 <h2><%=l(:label_information_plural)%></h2>
1 <h2><%=l(:label_information_plural)%></h2>
2
2
3 <p><%=l(:field_version)%>: <strong><%= Redmine::Info.versioned_name %></strong> (<%= @db_adapter_name %>)</p>
3 <p><%=l(:field_version)%>: <strong><%= Redmine::Info.versioned_name %></strong> (<%= @db_adapter_name %>)</p>
4
4
5 <table class="list">
5 <table class="list">
6 <tr class="odd"><td>File repository writable</td><td><%= image_tag (@flags[:file_repository_writable] ? 'true.png' : 'false.png'), :style => "vertical-align:bottom;" %></td></tr>
6 <tr class="odd"><td>File repository writable</td><td><%= image_tag (@flags[:file_repository_writable] ? 'true.png' : 'false.png'), :style => "vertical-align:bottom;" %></td></tr>
7 <tr class="even"><td>Default administrator account changed</td><td><%= image_tag (@flags[:default_admin_changed] ? 'true.png' : 'false.png'), :style => "vertical-align:bottom;" %></td></tr>
7 <tr class="even"><td>Default administrator account changed</td><td><%= image_tag (@flags[:default_admin_changed] ? 'true.png' : 'false.png'), :style => "vertical-align:bottom;" %></td></tr>
8 <tr class="odd"><td>Textile available</td><td><%= image_tag (@flags[:textile_available] ? 'true.png' : 'false.png'), :style => "vertical-align:bottom;" %></td></tr>
9 </table>
8 </table>
@@ -1,79 +1,79
1 <h2><%= l(:label_settings) %></h2>
1 <h2><%= l(:label_settings) %></h2>
2
2
3 <div id="settings">
3 <div id="settings">
4 <% form_tag({:action => 'edit'}, :class => "tabular") do %>
4 <% form_tag({:action => 'edit'}, :class => "tabular") do %>
5 <div class="box">
5 <div class="box">
6 <p><label><%= l(:setting_app_title) %></label>
6 <p><label><%= l(:setting_app_title) %></label>
7 <%= text_field_tag 'settings[app_title]', Setting.app_title, :size => 30 %></p>
7 <%= text_field_tag 'settings[app_title]', Setting.app_title, :size => 30 %></p>
8
8
9 <p><label><%= l(:setting_app_subtitle) %></label>
9 <p><label><%= l(:setting_app_subtitle) %></label>
10 <%= text_field_tag 'settings[app_subtitle]', Setting.app_subtitle, :size => 60 %></p>
10 <%= text_field_tag 'settings[app_subtitle]', Setting.app_subtitle, :size => 60 %></p>
11
11
12 <p><label><%= l(:setting_welcome_text) %></label>
12 <p><label><%= l(:setting_welcome_text) %></label>
13 <%= text_area_tag 'settings[welcome_text]', Setting.welcome_text, :cols => 60, :rows => 5, :class => 'wiki-edit' %></p>
13 <%= text_area_tag 'settings[welcome_text]', Setting.welcome_text, :cols => 60, :rows => 5, :class => 'wiki-edit' %></p>
14 <%= wikitoolbar_for 'settings[welcome_text]' %>
14 <%= wikitoolbar_for 'settings[welcome_text]' %>
15
15
16 <p><label><%= l(:setting_default_language) %></label>
16 <p><label><%= l(:setting_default_language) %></label>
17 <%= select_tag 'settings[default_language]', options_for_select( lang_options_for_select(false), Setting.default_language) %></p>
17 <%= select_tag 'settings[default_language]', options_for_select( lang_options_for_select(false), Setting.default_language) %></p>
18
18
19 <p><label><%= l(:setting_date_format) %></label>
19 <p><label><%= l(:setting_date_format) %></label>
20 <%= select_tag 'settings[date_format]', options_for_select( [[l(:label_language_based), '0'], ['ISO 8601 (YYYY-MM-DD)', '1']], Setting.date_format) %></p>
20 <%= select_tag 'settings[date_format]', options_for_select( [[l(:label_language_based), '0'], ['ISO 8601 (YYYY-MM-DD)', '1']], Setting.date_format) %></p>
21
21
22 <p><label><%= l(:setting_attachment_max_size) %></label>
22 <p><label><%= l(:setting_attachment_max_size) %></label>
23 <%= text_field_tag 'settings[attachment_max_size]', Setting.attachment_max_size, :size => 6 %> KB</p>
23 <%= text_field_tag 'settings[attachment_max_size]', Setting.attachment_max_size, :size => 6 %> KB</p>
24
24
25 <p><label><%= l(:setting_issues_export_limit) %></label>
25 <p><label><%= l(:setting_issues_export_limit) %></label>
26 <%= text_field_tag 'settings[issues_export_limit]', Setting.issues_export_limit, :size => 6 %></p>
26 <%= text_field_tag 'settings[issues_export_limit]', Setting.issues_export_limit, :size => 6 %></p>
27
27
28 <p><label><%= l(:setting_cross_project_issue_relations) %></label>
28 <p><label><%= l(:setting_cross_project_issue_relations) %></label>
29 <%= check_box_tag 'settings[cross_project_issue_relations]', 1, Setting.cross_project_issue_relations? %><%= hidden_field_tag 'settings[cross_project_issue_relations]', 0 %></p>
29 <%= check_box_tag 'settings[cross_project_issue_relations]', 1, Setting.cross_project_issue_relations? %><%= hidden_field_tag 'settings[cross_project_issue_relations]', 0 %></p>
30
30
31 <p><label><%= l(:setting_mail_from) %></label>
31 <p><label><%= l(:setting_mail_from) %></label>
32 <%= text_field_tag 'settings[mail_from]', Setting.mail_from, :size => 60 %></p>
32 <%= text_field_tag 'settings[mail_from]', Setting.mail_from, :size => 60 %></p>
33
33
34 <p><label><%= l(:setting_host_name) %></label>
34 <p><label><%= l(:setting_host_name) %></label>
35 <%= text_field_tag 'settings[host_name]', Setting.host_name, :size => 60 %></p>
35 <%= text_field_tag 'settings[host_name]', Setting.host_name, :size => 60 %></p>
36
36
37 <p><label><%= l(:setting_text_formatting) %></label>
37 <p><label><%= l(:setting_text_formatting) %></label>
38 <%= select_tag 'settings[text_formatting]', options_for_select([[l(:label_none), 0], ["textile", "textile"]], (@textile_available ? Setting.text_formatting : 0)), :disabled => !@textile_available %></p>
38 <%= select_tag 'settings[text_formatting]', options_for_select([[l(:label_none), "0"], ["textile", "textile"]], Setting.text_formatting) %></p>
39
39
40 <p><label><%= l(:setting_wiki_compression) %></label>
40 <p><label><%= l(:setting_wiki_compression) %></label>
41 <%= select_tag 'settings[wiki_compression]', options_for_select( [[l(:label_none), 0], ["gzip", "gzip"]], Setting.wiki_compression) %></p>
41 <%= select_tag 'settings[wiki_compression]', options_for_select( [[l(:label_none), 0], ["gzip", "gzip"]], Setting.wiki_compression) %></p>
42
42
43 <p><label><%= l(:setting_feeds_limit) %></label>
43 <p><label><%= l(:setting_feeds_limit) %></label>
44 <%= text_field_tag 'settings[feeds_limit]', Setting.feeds_limit, :size => 6 %></p>
44 <%= text_field_tag 'settings[feeds_limit]', Setting.feeds_limit, :size => 6 %></p>
45
45
46 <p><label><%= l(:setting_autofetch_changesets) %></label>
46 <p><label><%= l(:setting_autofetch_changesets) %></label>
47 <%= check_box_tag 'settings[autofetch_changesets]', 1, Setting.autofetch_changesets? %><%= hidden_field_tag 'settings[autofetch_changesets]', 0 %></p>
47 <%= check_box_tag 'settings[autofetch_changesets]', 1, Setting.autofetch_changesets? %><%= hidden_field_tag 'settings[autofetch_changesets]', 0 %></p>
48
48
49 <p><label><%= l(:setting_sys_api_enabled) %></label>
49 <p><label><%= l(:setting_sys_api_enabled) %></label>
50 <%= check_box_tag 'settings[sys_api_enabled]', 1, Setting.sys_api_enabled? %><%= hidden_field_tag 'settings[sys_api_enabled]', 0 %></p>
50 <%= check_box_tag 'settings[sys_api_enabled]', 1, Setting.sys_api_enabled? %><%= hidden_field_tag 'settings[sys_api_enabled]', 0 %></p>
51 </div>
51 </div>
52
52
53 <fieldset class="box"><legend><%= l(:label_authentication) %></legend>
53 <fieldset class="box"><legend><%= l(:label_authentication) %></legend>
54 <p><label><%= l(:setting_login_required) %></label>
54 <p><label><%= l(:setting_login_required) %></label>
55 <%= check_box_tag 'settings[login_required]', 1, Setting.login_required? %><%= hidden_field_tag 'settings[login_required]', 0 %></p>
55 <%= check_box_tag 'settings[login_required]', 1, Setting.login_required? %><%= hidden_field_tag 'settings[login_required]', 0 %></p>
56
56
57 <p><label><%= l(:setting_autologin) %></label>
57 <p><label><%= l(:setting_autologin) %></label>
58 <%= select_tag 'settings[autologin]', options_for_select( [[l(:label_disabled), "0"]] + [1, 7, 30, 365].collect{|days| [lwr(:actionview_datehelper_time_in_words_day, days), days.to_s]}, Setting.autologin) %></p>
58 <%= select_tag 'settings[autologin]', options_for_select( [[l(:label_disabled), "0"]] + [1, 7, 30, 365].collect{|days| [lwr(:actionview_datehelper_time_in_words_day, days), days.to_s]}, Setting.autologin) %></p>
59
59
60 <p><label><%= l(:setting_self_registration) %></label>
60 <p><label><%= l(:setting_self_registration) %></label>
61 <%= check_box_tag 'settings[self_registration]', 1, Setting.self_registration? %><%= hidden_field_tag 'settings[self_registration]', 0 %></p>
61 <%= check_box_tag 'settings[self_registration]', 1, Setting.self_registration? %><%= hidden_field_tag 'settings[self_registration]', 0 %></p>
62
62
63 <p><label><%= l(:label_password_lost) %></label>
63 <p><label><%= l(:label_password_lost) %></label>
64 <%= check_box_tag 'settings[lost_password]', 1, Setting.lost_password? %><%= hidden_field_tag 'settings[lost_password]', 0 %></p>
64 <%= check_box_tag 'settings[lost_password]', 1, Setting.lost_password? %><%= hidden_field_tag 'settings[lost_password]', 0 %></p>
65 </fieldset>
65 </fieldset>
66
66
67 <fieldset class="box"><legend><%= l(:text_issues_ref_in_commit_messages) %></legend>
67 <fieldset class="box"><legend><%= l(:text_issues_ref_in_commit_messages) %></legend>
68 <p><label><%= l(:setting_commit_ref_keywords) %></label>
68 <p><label><%= l(:setting_commit_ref_keywords) %></label>
69 <%= text_field_tag 'settings[commit_ref_keywords]', Setting.commit_ref_keywords, :size => 30 %><br /><em><%= l(:text_comma_separated) %></em></p>
69 <%= text_field_tag 'settings[commit_ref_keywords]', Setting.commit_ref_keywords, :size => 30 %><br /><em><%= l(:text_comma_separated) %></em></p>
70
70
71 <p><label><%= l(:setting_commit_fix_keywords) %></label>
71 <p><label><%= l(:setting_commit_fix_keywords) %></label>
72 <%= text_field_tag 'settings[commit_fix_keywords]', Setting.commit_fix_keywords, :size => 30 %>
72 <%= text_field_tag 'settings[commit_fix_keywords]', Setting.commit_fix_keywords, :size => 30 %>
73 &nbsp;<%= l(:label_applied_status) %>: <%= select_tag 'settings[commit_fix_status_id]', options_for_select( [["", 0]] + IssueStatus.find(:all).collect{|status| [status.name, status.id.to_s]}, Setting.commit_fix_status_id) %>
73 &nbsp;<%= l(:label_applied_status) %>: <%= select_tag 'settings[commit_fix_status_id]', options_for_select( [["", 0]] + IssueStatus.find(:all).collect{|status| [status.name, status.id.to_s]}, Setting.commit_fix_status_id) %>
74 <br /><em><%= l(:text_comma_separated) %></em></p>
74 <br /><em><%= l(:text_comma_separated) %></em></p>
75 </fieldset>
75 </fieldset>
76
76
77 <%= submit_tag l(:button_save) %>
77 <%= submit_tag l(:button_save) %>
78 </div>
78 </div>
79 <% end %> No newline at end of file
79 <% end %>
General Comments 0
You need to be logged in to leave comments. Login now