summaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-02-21 11:04:50 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-02-21 11:04:50 +0000
commitfe28193e4eb9af2dc5262535a29ffde5249568fc (patch)
treebd4cf3a9fbada98e58e510ca0e25c42bf00676a7 /app/helpers
parent9a986ac0a51fe844eee816325e6a6d4122136d9a (diff)
downloadredmine-fe28193e4eb9af2dc5262535a29ffde5249568fc.tar.gz
redmine-fe28193e4eb9af2dc5262535a29ffde5249568fc.zip
Merged Rails 2.2 branch. Redmine now requires Rails 2.2.2.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2493 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb95
-rw-r--r--app/helpers/issues_helper.rb2
-rw-r--r--app/helpers/messages_helper.rb2
-rw-r--r--app/helpers/settings_helper.rb4
4 files changed, 15 insertions, 88 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 5b63ecd5a..2e95ca5ff 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -22,6 +22,7 @@ require 'cgi'
module ApplicationHelper
include Redmine::WikiFormatting::Macros::Definitions
+ include Redmine::I18n
include GravatarHelper::PublicMethods
extend Forwardable
@@ -89,26 +90,9 @@ module ApplicationHelper
html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;"
link_to name, {}, html_options
end
-
- def format_date(date)
- return nil unless date
- # "Setting.date_format.size < 2" is a temporary fix (content of date_format setting changed)
- @date_format ||= (Setting.date_format.blank? || Setting.date_format.size < 2 ? l(:general_fmt_date) : Setting.date_format)
- date.strftime(@date_format)
- end
-
- def format_time(time, include_date = true)
- return nil unless time
- time = time.to_time if time.is_a?(String)
- zone = User.current.time_zone
- local = zone ? time.in_time_zone(zone) : (time.utc? ? time.localtime : time)
- @date_format ||= (Setting.date_format.blank? || Setting.date_format.size < 2 ? l(:general_fmt_date) : Setting.date_format)
- @time_format ||= (Setting.time_format.blank? ? l(:general_fmt_time) : Setting.time_format)
- include_date ? local.strftime("#{@date_format} #{@time_format}") : local.strftime(@time_format)
- end
def format_activity_title(text)
- h(truncate_single_line(text, 100))
+ h(truncate_single_line(text, :length => 100))
end
def format_activity_day(date)
@@ -116,14 +100,7 @@ module ApplicationHelper
end
def format_activity_description(text)
- h(truncate(text.to_s, 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, "<br />")
- end
-
- def distance_of_date_in_words(from_date, to_date = 0)
- from_date = from_date.to_date if from_date.respond_to?(:to_date)
- to_date = to_date.to_date if to_date.respond_to?(:to_date)
- distance_in_days = (to_date - from_date).abs
- lwr(:actionview_datehelper_time_in_words_day, distance_in_days)
+ h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, "<br />")
end
def due_date_distance_in_words(date)
@@ -235,20 +212,7 @@ module ApplicationHelper
{:controller => 'projects', :action => 'activity', :id => @project, :from => created.to_date},
:title => format_time(created))
author_tag = (author.is_a?(User) && !author.anonymous?) ? link_to(h(author), :controller => 'account', :action => 'show', :id => author) : h(author || 'Anonymous')
- l(options[:label] || :label_added_time_by, author_tag, time_tag)
- end
-
- def l_or_humanize(s, options={})
- k = "#{options[:prefix]}#{s}".to_sym
- l_has_string?(k) ? l(k) : s.to_s.humanize
- end
-
- def day_name(day)
- l(:general_day_names).split(',')[day-1]
- end
-
- def month_name(month)
- l(:actionview_datehelper_select_month_names).split(',')[month-1]
+ l(options[:label] || :label_added_time_by, :author => author_tag, :age => time_tag)
end
def syntax_highlight(name, content)
@@ -308,9 +272,9 @@ module ApplicationHelper
end
def other_formats_links(&block)
- concat('<p class="other-formats">' + l(:label_export_to), block.binding)
+ concat('<p class="other-formats">' + l(:label_export_to))
yield Redmine::Views::OtherFormatsBuilder.new(self)
- concat('</p>', block.binding)
+ concat('</p>')
end
def page_header_title
@@ -479,7 +443,7 @@ module ApplicationHelper
if project && (changeset = project.changesets.find_by_revision(oid))
link = link_to("r#{oid}", {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => oid},
:class => 'changeset',
- :title => truncate_single_line(changeset.comments, 100))
+ :title => truncate_single_line(changeset.comments, :length => 100))
end
elsif sep == '#'
oid = oid.to_i
@@ -488,7 +452,7 @@ module ApplicationHelper
if issue = Issue.find_by_id(oid, :include => [:project, :status], :conditions => Project.visible_by(User.current))
link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid},
:class => (issue.closed? ? 'issue closed' : 'issue'),
- :title => "#{truncate(issue.subject, 100)} (#{issue.status.name})")
+ :title => "#{truncate(issue.subject, :length => 100)} (#{issue.status.name})")
link = content_tag('del', link) if issue.closed?
end
when 'document'
@@ -503,7 +467,7 @@ module ApplicationHelper
end
when 'message'
if message = Message.find_by_id(oid, :include => [:parent, {:board => :project}], :conditions => Project.visible_by(User.current))
- link = link_to h(truncate(message.subject, 60)), {:only_path => only_path,
+ link = link_to h(truncate(message.subject, :length => 60)), {:only_path => only_path,
:controller => 'messages',
:action => 'show',
:board_id => message.board,
@@ -530,7 +494,7 @@ module ApplicationHelper
if project && (changeset = project.changesets.find(:first, :conditions => ["scmid LIKE ?", "#{name}%"]))
link = link_to h("#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.revision},
:class => 'changeset',
- :title => truncate_single_line(changeset.comments, 100)
+ :title => truncate_single_line(changeset.comments, :length => 100)
end
when 'source', 'export'
if project && project.repository
@@ -565,46 +529,9 @@ module ApplicationHelper
gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
end
- def error_messages_for(object_name, options = {})
- options = options.symbolize_keys
- object = instance_variable_get("@#{object_name}")
- if object && !object.errors.empty?
- # build full_messages here with controller current language
- full_messages = []
- object.errors.each do |attr, msg|
- next if msg.nil?
- msg = [msg] unless msg.is_a?(Array)
- if attr == "base"
- full_messages << l(*msg)
- else
- full_messages << "&#171; " + (l_has_string?("field_" + attr) ? l("field_" + attr) : object.class.human_attribute_name(attr)) + " &#187; " + l(*msg) unless attr == "custom_values"
- end
- end
- # retrieve custom values error messages
- if object.errors[:custom_values]
- object.custom_values.each do |v|
- v.errors.each do |attr, msg|
- next if msg.nil?
- msg = [msg] unless msg.is_a?(Array)
- full_messages << "&#171; " + v.custom_field.name + " &#187; " + l(*msg)
- end
- end
- end
- content_tag("div",
- content_tag(
- options[:header_tag] || "span", lwr(:gui_validation_error, full_messages.length) + ":"
- ) +
- content_tag("ul", full_messages.collect { |msg| content_tag("li", msg) }),
- "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation"
- )
- else
- ""
- end
- end
-
def lang_options_for_select(blank=true)
(blank ? [["(auto)", ""]] : []) +
- GLoc.valid_languages.collect{|lang| [ ll(lang.to_s, :general_lang_name), lang.to_s]}.sort{|x,y| x.last <=> y.last }
+ valid_languages.collect{|lang| [ ll(lang.to_s, :general_lang_name), lang.to_s]}.sort{|x,y| x.last <=> y.last }
end
def label_tag_for(name, option_tags = nil, options = {})
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index b2b85ee4c..16678df7d 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -119,7 +119,7 @@ module IssuesHelper
case detail.property
when 'attr', 'cf'
if !detail.old_value.blank?
- label + " " + l(:text_journal_changed, old_value, value)
+ label + " " + l(:text_journal_changed, :old => old_value, :new => value)
else
label + " " + l(:text_journal_set_to, value)
end
diff --git a/app/helpers/messages_helper.rb b/app/helpers/messages_helper.rb
index bf23275c3..034d1ad31 100644
--- a/app/helpers/messages_helper.rb
+++ b/app/helpers/messages_helper.rb
@@ -19,7 +19,7 @@ module MessagesHelper
def link_to_message(message)
return '' unless message
- link_to h(truncate(message.subject, 60)), :controller => 'messages',
+ link_to h(truncate(message.subject, :length => 60)), :controller => 'messages',
:action => 'show',
:board_id => message.board_id,
:id => message.root,
diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb
index 35442f615..7d130331d 100644
--- a/app/helpers/settings_helper.rb
+++ b/app/helpers/settings_helper.rb
@@ -22,8 +22,8 @@ module SettingsHelper
{:name => 'authentication', :partial => 'settings/authentication', :label => :label_authentication},
{:name => 'projects', :partial => 'settings/projects', :label => :label_project_plural},
{:name => 'issues', :partial => 'settings/issues', :label => :label_issue_tracking},
- {:name => 'notifications', :partial => 'settings/notifications', :label => l(:field_mail_notification)},
- {:name => 'mail_handler', :partial => 'settings/mail_handler', :label => l(:label_incoming_emails)},
+ {:name => 'notifications', :partial => 'settings/notifications', :label => :field_mail_notification},
+ {:name => 'mail_handler', :partial => 'settings/mail_handler', :label => :label_incoming_emails},
{:name => 'repositories', :partial => 'settings/repositories', :label => :label_repository_plural}
]
end