##// END OF EJS Templates
Email address should be lowercased for gravatar (#2145)....
Jean-Philippe Lang -
r1986:4581baa5c0b6
parent child
Show More
@@ -5,12 +5,12
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.
@@ -28,7 +28,7 module ApplicationHelper
28 def current_role
28 def current_role
29 @current_role ||= User.current.role_for_project(@project)
29 @current_role ||= User.current.role_for_project(@project)
30 end
30 end
31
31
32 # Return true if user is authorized for controller/action, otherwise false
32 # Return true if user is authorized for controller/action, otherwise false
33 def authorize_for(controller, action)
33 def authorize_for(controller, action)
34 User.current.allowed_to?({:controller => controller, :action => action}, @project)
34 User.current.allowed_to?({:controller => controller, :action => action}, @project)
@@ -38,7 +38,7 module ApplicationHelper
38 def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
38 def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
39 link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
39 link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
40 end
40 end
41
41
42 # Display a link to remote if user is authorized
42 # Display a link to remote if user is authorized
43 def link_to_remote_if_authorized(name, options = {}, html_options = nil)
43 def link_to_remote_if_authorized(name, options = {}, html_options = nil)
44 url = options[:url] || {}
44 url = options[:url] || {}
@@ -49,14 +49,14 module ApplicationHelper
49 def link_to_user(user)
49 def link_to_user(user)
50 user ? link_to(user, :controller => 'account', :action => 'show', :id => user) : 'Anonymous'
50 user ? link_to(user, :controller => 'account', :action => 'show', :id => user) : 'Anonymous'
51 end
51 end
52
52
53 def link_to_issue(issue, options={})
53 def link_to_issue(issue, options={})
54 options[:class] ||= ''
54 options[:class] ||= ''
55 options[:class] << ' issue'
55 options[:class] << ' issue'
56 options[:class] << ' closed' if issue.closed?
56 options[:class] << ' closed' if issue.closed?
57 link_to "#{issue.tracker.name} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue}, options
57 link_to "#{issue.tracker.name} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue}, options
58 end
58 end
59
59
60 # Generates a link to an attachment.
60 # Generates a link to an attachment.
61 # Options:
61 # Options:
62 # * :text - Link text (default to attachment filename)
62 # * :text - Link text (default to attachment filename)
@@ -64,37 +64,37 module ApplicationHelper
64 def link_to_attachment(attachment, options={})
64 def link_to_attachment(attachment, options={})
65 text = options.delete(:text) || attachment.filename
65 text = options.delete(:text) || attachment.filename
66 action = options.delete(:download) ? 'download' : 'show'
66 action = options.delete(:download) ? 'download' : 'show'
67
67
68 link_to(h(text), {:controller => 'attachments', :action => action, :id => attachment, :filename => attachment.filename }, options)
68 link_to(h(text), {:controller => 'attachments', :action => action, :id => attachment, :filename => attachment.filename }, options)
69 end
69 end
70
70
71 def toggle_link(name, id, options={})
71 def toggle_link(name, id, options={})
72 onclick = "Element.toggle('#{id}'); "
72 onclick = "Element.toggle('#{id}'); "
73 onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ")
73 onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ")
74 onclick << "return false;"
74 onclick << "return false;"
75 link_to(name, "#", :onclick => onclick)
75 link_to(name, "#", :onclick => onclick)
76 end
76 end
77
77
78 def image_to_function(name, function, html_options = {})
78 def image_to_function(name, function, html_options = {})
79 html_options.symbolize_keys!
79 html_options.symbolize_keys!
80 tag(:input, html_options.merge({
80 tag(:input, html_options.merge({
81 :type => "image", :src => image_path(name),
81 :type => "image", :src => image_path(name),
82 :onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};"
82 :onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};"
83 }))
83 }))
84 end
84 end
85
85
86 def prompt_to_remote(name, text, param, url, html_options = {})
86 def prompt_to_remote(name, text, param, url, html_options = {})
87 html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;"
87 html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;"
88 link_to name, {}, html_options
88 link_to name, {}, html_options
89 end
89 end
90
90
91 def format_date(date)
91 def format_date(date)
92 return nil unless date
92 return nil unless date
93 # "Setting.date_format.size < 2" is a temporary fix (content of date_format setting changed)
93 # "Setting.date_format.size < 2" is a temporary fix (content of date_format setting changed)
94 @date_format ||= (Setting.date_format.blank? || Setting.date_format.size < 2 ? l(:general_fmt_date) : Setting.date_format)
94 @date_format ||= (Setting.date_format.blank? || Setting.date_format.size < 2 ? l(:general_fmt_date) : Setting.date_format)
95 date.strftime(@date_format)
95 date.strftime(@date_format)
96 end
96 end
97
97
98 def format_time(time, include_date = true)
98 def format_time(time, include_date = true)
99 return nil unless time
99 return nil unless time
100 time = time.to_time if time.is_a?(String)
100 time = time.to_time if time.is_a?(String)
@@ -104,44 +104,44 module ApplicationHelper
104 @time_format ||= (Setting.time_format.blank? ? l(:general_fmt_time) : Setting.time_format)
104 @time_format ||= (Setting.time_format.blank? ? l(:general_fmt_time) : Setting.time_format)
105 include_date ? local.strftime("#{@date_format} #{@time_format}") : local.strftime(@time_format)
105 include_date ? local.strftime("#{@date_format} #{@time_format}") : local.strftime(@time_format)
106 end
106 end
107
107
108 def distance_of_date_in_words(from_date, to_date = 0)
108 def distance_of_date_in_words(from_date, to_date = 0)
109 from_date = from_date.to_date if from_date.respond_to?(:to_date)
109 from_date = from_date.to_date if from_date.respond_to?(:to_date)
110 to_date = to_date.to_date if to_date.respond_to?(:to_date)
110 to_date = to_date.to_date if to_date.respond_to?(:to_date)
111 distance_in_days = (to_date - from_date).abs
111 distance_in_days = (to_date - from_date).abs
112 lwr(:actionview_datehelper_time_in_words_day, distance_in_days)
112 lwr(:actionview_datehelper_time_in_words_day, distance_in_days)
113 end
113 end
114
114
115 def due_date_distance_in_words(date)
115 def due_date_distance_in_words(date)
116 if date
116 if date
117 l((date < Date.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(Date.today, date))
117 l((date < Date.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(Date.today, date))
118 end
118 end
119 end
119 end
120
120
121 # Truncates and returns the string as a single line
121 # Truncates and returns the string as a single line
122 def truncate_single_line(string, *args)
122 def truncate_single_line(string, *args)
123 truncate(string, *args).gsub(%r{[\r\n]+}m, ' ')
123 truncate(string, *args).gsub(%r{[\r\n]+}m, ' ')
124 end
124 end
125
125
126 def html_hours(text)
126 def html_hours(text)
127 text.gsub(%r{(\d+)\.(\d+)}, '<span class="hours hours-int">\1</span><span class="hours hours-dec">.\2</span>')
127 text.gsub(%r{(\d+)\.(\d+)}, '<span class="hours hours-int">\1</span><span class="hours hours-dec">.\2</span>')
128 end
128 end
129
129
130 def authoring(created, author)
130 def authoring(created, author)
131 time_tag = content_tag('acronym', distance_of_time_in_words(Time.now, created), :title => format_time(created))
131 time_tag = content_tag('acronym', distance_of_time_in_words(Time.now, created), :title => format_time(created))
132 author_tag = (author.is_a?(User) && !author.anonymous?) ? link_to(h(author), :controller => 'account', :action => 'show', :id => author) : h(author || 'Anonymous')
132 author_tag = (author.is_a?(User) && !author.anonymous?) ? link_to(h(author), :controller => 'account', :action => 'show', :id => author) : h(author || 'Anonymous')
133 l(:label_added_time_by, author_tag, time_tag)
133 l(:label_added_time_by, author_tag, time_tag)
134 end
134 end
135
135
136 def l_or_humanize(s, options={})
136 def l_or_humanize(s, options={})
137 k = "#{options[:prefix]}#{s}".to_sym
137 k = "#{options[:prefix]}#{s}".to_sym
138 l_has_string?(k) ? l(k) : s.to_s.humanize
138 l_has_string?(k) ? l(k) : s.to_s.humanize
139 end
139 end
140
140
141 def day_name(day)
141 def day_name(day)
142 l(:general_day_names).split(',')[day-1]
142 l(:general_day_names).split(',')[day-1]
143 end
143 end
144
144
145 def month_name(month)
145 def month_name(month)
146 l(:actionview_datehelper_select_month_names).split(',')[month-1]
146 l(:actionview_datehelper_select_month_names).split(',')[month-1]
147 end
147 end
@@ -150,7 +150,7 module ApplicationHelper
150 type = CodeRay::FileType[name]
150 type = CodeRay::FileType[name]
151 type ? CodeRay.scan(content, type).html : h(content)
151 type ? CodeRay.scan(content, type).html : h(content)
152 end
152 end
153
153
154 def to_path_param(path)
154 def to_path_param(path)
155 path.to_s.split(%r{[/\\]}).select {|p| !p.blank?}
155 path.to_s.split(%r{[/\\]}).select {|p| !p.blank?}
156 end
156 end
@@ -160,51 +160,51 module ApplicationHelper
160 url_param = params.dup
160 url_param = params.dup
161 # don't reuse params if filters are present
161 # don't reuse params if filters are present
162 url_param.clear if url_param.has_key?(:set_filter)
162 url_param.clear if url_param.has_key?(:set_filter)
163
163
164 html = ''
164 html = ''
165 html << link_to_remote(('&#171; ' + l(:label_previous)),
165 html << link_to_remote(('&#171; ' + l(:label_previous)),
166 {:update => 'content',
166 {:update => 'content',
167 :url => url_param.merge(page_param => paginator.current.previous),
167 :url => url_param.merge(page_param => paginator.current.previous),
168 :complete => 'window.scrollTo(0,0)'},
168 :complete => 'window.scrollTo(0,0)'},
169 {:href => url_for(:params => url_param.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous
169 {:href => url_for(:params => url_param.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous
170
170
171 html << (pagination_links_each(paginator, options) do |n|
171 html << (pagination_links_each(paginator, options) do |n|
172 link_to_remote(n.to_s,
172 link_to_remote(n.to_s,
173 {:url => {:params => url_param.merge(page_param => n)},
173 {:url => {:params => url_param.merge(page_param => n)},
174 :update => 'content',
174 :update => 'content',
175 :complete => 'window.scrollTo(0,0)'},
175 :complete => 'window.scrollTo(0,0)'},
176 {:href => url_for(:params => url_param.merge(page_param => n))})
176 {:href => url_for(:params => url_param.merge(page_param => n))})
177 end || '')
177 end || '')
178
178
179 html << ' ' + link_to_remote((l(:label_next) + ' &#187;'),
179 html << ' ' + link_to_remote((l(:label_next) + ' &#187;'),
180 {:update => 'content',
180 {:update => 'content',
181 :url => url_param.merge(page_param => paginator.current.next),
181 :url => url_param.merge(page_param => paginator.current.next),
182 :complete => 'window.scrollTo(0,0)'},
182 :complete => 'window.scrollTo(0,0)'},
183 {:href => url_for(:params => url_param.merge(page_param => paginator.current.next))}) if paginator.current.next
183 {:href => url_for(:params => url_param.merge(page_param => paginator.current.next))}) if paginator.current.next
184
184
185 unless count.nil?
185 unless count.nil?
186 html << [" (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})", per_page_links(paginator.items_per_page)].compact.join(' | ')
186 html << [" (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})", per_page_links(paginator.items_per_page)].compact.join(' | ')
187 end
187 end
188
188
189 html
189 html
190 end
190 end
191
191
192 def per_page_links(selected=nil)
192 def per_page_links(selected=nil)
193 url_param = params.dup
193 url_param = params.dup
194 url_param.clear if url_param.has_key?(:set_filter)
194 url_param.clear if url_param.has_key?(:set_filter)
195
195
196 links = Setting.per_page_options_array.collect do |n|
196 links = Setting.per_page_options_array.collect do |n|
197 n == selected ? n : link_to_remote(n, {:update => "content", :url => params.dup.merge(:per_page => n)},
197 n == selected ? n : link_to_remote(n, {:update => "content", :url => params.dup.merge(:per_page => n)},
198 {:href => url_for(url_param.merge(:per_page => n))})
198 {:href => url_for(url_param.merge(:per_page => n))})
199 end
199 end
200 links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil
200 links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil
201 end
201 end
202
202
203 def breadcrumb(*args)
203 def breadcrumb(*args)
204 elements = args.flatten
204 elements = args.flatten
205 elements.any? ? content_tag('p', args.join(' &#187; ') + ' &#187; ', :class => 'breadcrumb') : nil
205 elements.any? ? content_tag('p', args.join(' &#187; ') + ' &#187; ', :class => 'breadcrumb') : nil
206 end
206 end
207
207
208 def html_title(*args)
208 def html_title(*args)
209 if args.empty?
209 if args.empty?
210 title = []
210 title = []
@@ -239,12 +239,12 module ApplicationHelper
239 raise ArgumentError, 'invalid arguments to textilizable'
239 raise ArgumentError, 'invalid arguments to textilizable'
240 end
240 end
241 return '' if text.blank?
241 return '' if text.blank?
242
242
243 only_path = options.delete(:only_path) == false ? false : true
243 only_path = options.delete(:only_path) == false ? false : true
244
244
245 # when using an image link, try to use an attachment, if possible
245 # when using an image link, try to use an attachment, if possible
246 attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil)
246 attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil)
247
247
248 if attachments
248 if attachments
249 attachments = attachments.sort_by(&:created_on).reverse
249 attachments = attachments.sort_by(&:created_on).reverse
250 text = text.gsub(/!((\<|\=|\>)?(\([^\)]+\))?(\[[^\]]+\])?(\{[^\}]+\})?)(\S+\.(bmp|gif|jpg|jpeg|png))!/i) do |m|
250 text = text.gsub(/!((\<|\=|\>)?(\([^\)]+\))?(\[[^\]]+\])?(\{[^\}]+\})?)(\S+\.(bmp|gif|jpg|jpeg|png))!/i) do |m|
@@ -262,7 +262,7 module ApplicationHelper
262 end
262 end
263 end
263 end
264 end
264 end
265
265
266 text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text) { |macro, args| exec_macro(macro, obj, args) }
266 text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text) { |macro, args| exec_macro(macro, obj, args) }
267
267
268 # different methods for formatting wiki links
268 # different methods for formatting wiki links
@@ -276,11 +276,11 module ApplicationHelper
276 else
276 else
277 format_wiki_link = Proc.new {|project, title, anchor| url_for(:only_path => only_path, :controller => 'wiki', :action => 'index', :id => project, :page => title, :anchor => anchor) }
277 format_wiki_link = Proc.new {|project, title, anchor| url_for(:only_path => only_path, :controller => 'wiki', :action => 'index', :id => project, :page => title, :anchor => anchor) }
278 end
278 end
279
279
280 project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
280 project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
281
281
282 # Wiki links
282 # Wiki links
283 #
283 #
284 # Examples:
284 # Examples:
285 # [[mypage]]
285 # [[mypage]]
286 # [[mypage|mytext]]
286 # [[mypage|mytext]]
@@ -298,7 +298,7 module ApplicationHelper
298 page = $2
298 page = $2
299 title ||= $1 if page.blank?
299 title ||= $1 if page.blank?
300 end
300 end
301
301
302 if link_project && link_project.wiki
302 if link_project && link_project.wiki
303 # extract anchor
303 # extract anchor
304 anchor = nil
304 anchor = nil
@@ -319,7 +319,7 module ApplicationHelper
319 end
319 end
320
320
321 # Redmine links
321 # Redmine links
322 #
322 #
323 # Examples:
323 # Examples:
324 # Issues:
324 # Issues:
325 # #52 -> Link to issue #52
325 # #52 -> Link to issue #52
@@ -358,7 +358,7 module ApplicationHelper
358 oid = oid.to_i
358 oid = oid.to_i
359 case prefix
359 case prefix
360 when nil
360 when nil
361 if issue = Issue.find_by_id(oid, :include => [:project, :status], :conditions => Project.visible_by(User.current))
361 if issue = Issue.find_by_id(oid, :include => [:project, :status], :conditions => Project.visible_by(User.current))
362 link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid},
362 link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid},
363 :class => (issue.closed? ? 'issue closed' : 'issue'),
363 :class => (issue.closed? ? 'issue closed' : 'issue'),
364 :title => "#{truncate(issue.subject, 100)} (#{issue.status.name})")
364 :title => "#{truncate(issue.subject, 100)} (#{issue.status.name})")
@@ -426,10 +426,10 module ApplicationHelper
426 end
426 end
427 leading + (link || "#{prefix}#{sep}#{oid}")
427 leading + (link || "#{prefix}#{sep}#{oid}")
428 end
428 end
429
429
430 text
430 text
431 end
431 end
432
432
433 # Same as Rails' simple_format helper without using paragraphs
433 # Same as Rails' simple_format helper without using paragraphs
434 def simple_format_without_paragraph(text)
434 def simple_format_without_paragraph(text)
435 text.to_s.
435 text.to_s.
@@ -437,7 +437,7 module ApplicationHelper
437 gsub(/\n\n+/, "<br /><br />"). # 2+ newline -> 2 br
437 gsub(/\n\n+/, "<br /><br />"). # 2+ newline -> 2 br
438 gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
438 gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
439 end
439 end
440
440
441 def error_messages_for(object_name, options = {})
441 def error_messages_for(object_name, options = {})
442 options = options.symbolize_keys
442 options = options.symbolize_keys
443 object = instance_variable_get("@#{object_name}")
443 object = instance_variable_get("@#{object_name}")
@@ -455,14 +455,14 module ApplicationHelper
455 end
455 end
456 # retrieve custom values error messages
456 # retrieve custom values error messages
457 if object.errors[:custom_values]
457 if object.errors[:custom_values]
458 object.custom_values.each do |v|
458 object.custom_values.each do |v|
459 v.errors.each do |attr, msg|
459 v.errors.each do |attr, msg|
460 next if msg.nil?
460 next if msg.nil?
461 msg = msg.first if msg.is_a? Array
461 msg = msg.first if msg.is_a? Array
462 full_messages << "&#171; " + v.custom_field.name + " &#187; " + l(msg)
462 full_messages << "&#171; " + v.custom_field.name + " &#187; " + l(msg)
463 end
463 end
464 end
464 end
465 end
465 end
466 content_tag("div",
466 content_tag("div",
467 content_tag(
467 content_tag(
468 options[:header_tag] || "span", lwr(:gui_validation_error, full_messages.length) + ":"
468 options[:header_tag] || "span", lwr(:gui_validation_error, full_messages.length) + ":"
@@ -474,34 +474,34 module ApplicationHelper
474 ""
474 ""
475 end
475 end
476 end
476 end
477
477
478 def lang_options_for_select(blank=true)
478 def lang_options_for_select(blank=true)
479 (blank ? [["(auto)", ""]] : []) +
479 (blank ? [["(auto)", ""]] : []) +
480 GLoc.valid_languages.collect{|lang| [ ll(lang.to_s, :general_lang_name), lang.to_s]}.sort{|x,y| x.last <=> y.last }
480 GLoc.valid_languages.collect{|lang| [ ll(lang.to_s, :general_lang_name), lang.to_s]}.sort{|x,y| x.last <=> y.last }
481 end
481 end
482
482
483 def label_tag_for(name, option_tags = nil, options = {})
483 def label_tag_for(name, option_tags = nil, options = {})
484 label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
484 label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
485 content_tag("label", label_text)
485 content_tag("label", label_text)
486 end
486 end
487
487
488 def labelled_tabular_form_for(name, object, options, &proc)
488 def labelled_tabular_form_for(name, object, options, &proc)
489 options[:html] ||= {}
489 options[:html] ||= {}
490 options[:html][:class] = 'tabular' unless options[:html].has_key?(:class)
490 options[:html][:class] = 'tabular' unless options[:html].has_key?(:class)
491 form_for(name, object, options.merge({ :builder => TabularFormBuilder, :lang => current_language}), &proc)
491 form_for(name, object, options.merge({ :builder => TabularFormBuilder, :lang => current_language}), &proc)
492 end
492 end
493
493
494 def back_url_hidden_field_tag
494 def back_url_hidden_field_tag
495 back_url = params[:back_url] || request.env['HTTP_REFERER']
495 back_url = params[:back_url] || request.env['HTTP_REFERER']
496 hidden_field_tag('back_url', back_url) unless back_url.blank?
496 hidden_field_tag('back_url', back_url) unless back_url.blank?
497 end
497 end
498
498
499 def check_all_links(form_name)
499 def check_all_links(form_name)
500 link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") +
500 link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") +
501 " | " +
501 " | " +
502 link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
502 link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
503 end
503 end
504
504
505 def progress_bar(pcts, options={})
505 def progress_bar(pcts, options={})
506 pcts = [pcts, pcts] unless pcts.is_a?(Array)
506 pcts = [pcts, pcts] unless pcts.is_a?(Array)
507 pcts[1] = pcts[1] - pcts[0]
507 pcts[1] = pcts[1] - pcts[0]
@@ -516,7 +516,7 module ApplicationHelper
516 ), :class => 'progress', :style => "width: #{width};") +
516 ), :class => 'progress', :style => "width: #{width};") +
517 content_tag('p', legend, :class => 'pourcent')
517 content_tag('p', legend, :class => 'pourcent')
518 end
518 end
519
519
520 def context_menu_link(name, url, options={})
520 def context_menu_link(name, url, options={})
521 options[:class] ||= ''
521 options[:class] ||= ''
522 if options.delete(:selected)
522 if options.delete(:selected)
@@ -532,7 +532,7 module ApplicationHelper
532 end
532 end
533 link_to name, url, options
533 link_to name, url, options
534 end
534 end
535
535
536 def calendar_for(field_id)
536 def calendar_for(field_id)
537 include_calendar_headers_tags
537 include_calendar_headers_tags
538 image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
538 image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
@@ -550,25 +550,25 module ApplicationHelper
550 end
550 end
551 end
551 end
552 end
552 end
553
553
554 def content_for(name, content = nil, &block)
554 def content_for(name, content = nil, &block)
555 @has_content ||= {}
555 @has_content ||= {}
556 @has_content[name] = true
556 @has_content[name] = true
557 super(name, content, &block)
557 super(name, content, &block)
558 end
558 end
559
559
560 def has_content?(name)
560 def has_content?(name)
561 (@has_content && @has_content[name]) || false
561 (@has_content && @has_content[name]) || false
562 end
562 end
563
563
564 def gravatar_for_mail(mail, options = { })
564 def gravatar_for_mail(mail, options = { })
565 if Setting.gravatar_enabled?
565 if Setting.gravatar_enabled?
566 return gravatar(mail, options) rescue nil
566 return gravatar(mail.to_s.downcase, options) rescue nil
567 end
567 end
568 end
568 end
569
569
570 private
570 private
571
571
572 def wiki_helper
572 def wiki_helper
573 helper = Redmine::WikiFormatting.helper_for(Setting.text_formatting)
573 helper = Redmine::WikiFormatting.helper_for(Setting.text_formatting)
574 extend helper
574 extend helper
General Comments 0
You need to be logged in to leave comments. Login now