Commit fe28193e authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

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
parent 9a986ac0
...@@ -19,6 +19,13 @@ require 'uri' ...@@ -19,6 +19,13 @@ require 'uri'
require 'cgi' require 'cgi'
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
include Redmine::I18n
# In case the cookie store secret changes
rescue_from CGI::Session::CookieStore::TamperedWithCookie do |exception|
render :text => 'Your session was invalid and has been reset. Please, reload this page.', :status => 500
end
layout 'base' layout 'base'
before_filter :user_setup, :check_if_login_required, :set_localization before_filter :user_setup, :check_if_login_required, :set_localization
...@@ -64,20 +71,18 @@ class ApplicationController < ActionController::Base ...@@ -64,20 +71,18 @@ class ApplicationController < ActionController::Base
end end
def set_localization def set_localization
User.current.language = nil unless User.current.logged? lang = nil
lang = begin if User.current.logged?
if !User.current.language.blank? && GLoc.valid_language?(User.current.language) lang = find_language(User.current.language)
User.current.language end
elsif request.env['HTTP_ACCEPT_LANGUAGE'] if lang.nil? && request.env['HTTP_ACCEPT_LANGUAGE']
accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first.downcase accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first.downcase
if !accept_lang.blank? && (GLoc.valid_language?(accept_lang) || GLoc.valid_language?(accept_lang = accept_lang.split('-').first)) if !accept_lang.blank?
User.current.language = accept_lang lang = find_language(accept_lang) || find_language(accept_lang.split('-').first)
end
end end
rescue end
nil lang ||= Setting.default_language
end || Setting.default_language set_language_if_valid(lang)
set_language_if_valid(lang)
end end
def require_login def require_login
...@@ -152,7 +157,7 @@ class ApplicationController < ActionController::Base ...@@ -152,7 +157,7 @@ class ApplicationController < ActionController::Base
def render_error(msg) def render_error(msg)
flash.now[:error] = msg flash.now[:error] = msg
render :nothing => true, :layout => !request.xhr?, :status => 500 render :text => '', :layout => !request.xhr?, :status => 500
end end
def render_feed(items, options={}) def render_feed(items, options={})
...@@ -225,6 +230,8 @@ class ApplicationController < ActionController::Base ...@@ -225,6 +230,8 @@ class ApplicationController < ActionController::Base
tmp.collect!{|val, q| val} tmp.collect!{|val, q| val}
end end
return tmp return tmp
rescue
nil
end end
# Returns a string that can be used as filename value in Content-Disposition header # Returns a string that can be used as filename value in Content-Disposition header
......
...@@ -258,7 +258,9 @@ class IssuesController < ApplicationController ...@@ -258,7 +258,9 @@ class IssuesController < ApplicationController
if unsaved_issue_ids.empty? if unsaved_issue_ids.empty?
flash[:notice] = l(:notice_successful_update) unless @issues.empty? flash[:notice] = l(:notice_successful_update) unless @issues.empty?
else else
flash[:error] = l(:notice_failed_to_save_issues, unsaved_issue_ids.size, @issues.size, '#' + unsaved_issue_ids.join(', #')) flash[:error] = l(:notice_failed_to_save_issues, :count => unsaved_issue_ids.size,
:total => @issues.size,
:ids => '#' + unsaved_issue_ids.join(', #'))
end end
redirect_to(params[:back_to] || {:controller => 'issues', :action => 'index', :project_id => @project}) redirect_to(params[:back_to] || {:controller => 'issues', :action => 'index', :project_id => @project})
return return
...@@ -291,7 +293,9 @@ class IssuesController < ApplicationController ...@@ -291,7 +293,9 @@ class IssuesController < ApplicationController
if unsaved_issue_ids.empty? if unsaved_issue_ids.empty?
flash[:notice] = l(:notice_successful_update) unless @issues.empty? flash[:notice] = l(:notice_successful_update) unless @issues.empty?
else else
flash[:error] = l(:notice_failed_to_save_issues, unsaved_issue_ids.size, @issues.size, '#' + unsaved_issue_ids.join(', #')) flash[:error] = l(:notice_failed_to_save_issues, :count => unsaved_issue_ids.size,
:total => @issues.size,
:ids => '#' + unsaved_issue_ids.join(', #'))
end end
redirect_to :controller => 'issues', :action => 'index', :project_id => @project redirect_to :controller => 'issues', :action => 'index', :project_id => @project
return return
......
...@@ -238,8 +238,7 @@ private ...@@ -238,8 +238,7 @@ private
changes_by_day.each {|c| changes_by_month[c.first.to_date.months_ago] += c.last } changes_by_day.each {|c| changes_by_month[c.first.to_date.months_ago] += c.last }
fields = [] fields = []
month_names = l(:actionview_datehelper_select_month_names_abbr).split(',') 12.times {|m| fields << month_name(((Date.today.month - 1 - m) % 12) + 1)}
12.times {|m| fields << month_names[((Date.today.month - 1 - m) % 12)]}
graph = SVG::Graph::Bar.new( graph = SVG::Graph::Bar.new(
:height => 300, :height => 300,
......
...@@ -22,6 +22,7 @@ require 'cgi' ...@@ -22,6 +22,7 @@ require 'cgi'
module ApplicationHelper module ApplicationHelper
include Redmine::WikiFormatting::Macros::Definitions include Redmine::WikiFormatting::Macros::Definitions
include Redmine::I18n
include GravatarHelper::PublicMethods include GravatarHelper::PublicMethods
extend Forwardable extend Forwardable
...@@ -89,26 +90,9 @@ module ApplicationHelper ...@@ -89,26 +90,9 @@ module ApplicationHelper
html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;" html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;"
link_to name, {}, html_options link_to name, {}, html_options
end 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) def format_activity_title(text)
h(truncate_single_line(text, 100)) h(truncate_single_line(text, :length => 100))
end end
def format_activity_day(date) def format_activity_day(date)
...@@ -116,14 +100,7 @@ module ApplicationHelper ...@@ -116,14 +100,7 @@ module ApplicationHelper
end end
def format_activity_description(text) def format_activity_description(text)
h(truncate(text.to_s, 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, "<br />") h(truncate(text.to_s, :length => 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)
end end
def due_date_distance_in_words(date) def due_date_distance_in_words(date)
...@@ -235,20 +212,7 @@ module ApplicationHelper ...@@ -235,20 +212,7 @@ module ApplicationHelper
{:controller => 'projects', :action => 'activity', :id => @project, :from => created.to_date}, {:controller => 'projects', :action => 'activity', :id => @project, :from => created.to_date},
:title => format_time(created)) :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') 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) l(options[:label] || :label_added_time_by, :author => author_tag, :age => 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]
end end
def syntax_highlight(name, content) def syntax_highlight(name, content)
...@@ -308,9 +272,9 @@ module ApplicationHelper ...@@ -308,9 +272,9 @@ module ApplicationHelper
end end
def other_formats_links(&block) 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) yield Redmine::Views::OtherFormatsBuilder.new(self)
concat('</p>', block.binding) concat('</p>')
end end
def page_header_title def page_header_title
...@@ -479,7 +443,7 @@ module ApplicationHelper ...@@ -479,7 +443,7 @@ module ApplicationHelper
if project && (changeset = project.changesets.find_by_revision(oid)) 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}, link = link_to("r#{oid}", {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => oid},
:class => 'changeset', :class => 'changeset',
:title => truncate_single_line(changeset.comments, 100)) :title => truncate_single_line(changeset.comments, :length => 100))
end end
elsif sep == '#' elsif sep == '#'
oid = oid.to_i oid = oid.to_i
...@@ -488,7 +452,7 @@ module ApplicationHelper ...@@ -488,7 +452,7 @@ module ApplicationHelper
if issue = Issue.find_by_id(oid, :include => [:project, :status], :conditions => Project.visible_by(User.current)) 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}, link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid},
:class => (issue.closed? ? 'issue closed' : 'issue'), :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? link = content_tag('del', link) if issue.closed?
end end
when 'document' when 'document'
...@@ -503,7 +467,7 @@ module ApplicationHelper ...@@ -503,7 +467,7 @@ module ApplicationHelper
end end
when 'message' when 'message'
if message = Message.find_by_id(oid, :include => [:parent, {:board => :project}], :conditions => Project.visible_by(User.current)) 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', :controller => 'messages',
:action => 'show', :action => 'show',
:board_id => message.board, :board_id => message.board,
...@@ -530,7 +494,7 @@ module ApplicationHelper ...@@ -530,7 +494,7 @@ module ApplicationHelper
if project && (changeset = project.changesets.find(:first, :conditions => ["scmid LIKE ?", "#{name}%"])) 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}, link = link_to h("#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.revision},
:class => 'changeset', :class => 'changeset',
:title => truncate_single_line(changeset.comments, 100) :title => truncate_single_line(changeset.comments, :length => 100)
end end
when 'source', 'export' when 'source', 'export'
if project && project.repository if project && project.repository
...@@ -565,46 +529,9 @@ module ApplicationHelper ...@@ -565,46 +529,9 @@ module ApplicationHelper
gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br gsub(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
end 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) def lang_options_for_select(blank=true)
(blank ? [["(auto)", ""]] : []) + (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 end
def label_tag_for(name, option_tags = nil, options = {}) def label_tag_for(name, option_tags = nil, options = {})
......
...@@ -119,7 +119,7 @@ module IssuesHelper ...@@ -119,7 +119,7 @@ module IssuesHelper
case detail.property case detail.property
when 'attr', 'cf' when 'attr', 'cf'
if !detail.old_value.blank? if !detail.old_value.blank?
label + " " + l(:text_journal_changed, old_value, value) label + " " + l(:text_journal_changed, :old => old_value, :new => value)
else else
label + " " + l(:text_journal_set_to, value) label + " " + l(:text_journal_set_to, value)
end end
......
...@@ -19,7 +19,7 @@ module MessagesHelper ...@@ -19,7 +19,7 @@ module MessagesHelper
def link_to_message(message) def link_to_message(message)
return '' unless 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', :action => 'show',
:board_id => message.board_id, :board_id => message.board_id,
:id => message.root, :id => message.root,
......
...@@ -22,8 +22,8 @@ module SettingsHelper ...@@ -22,8 +22,8 @@ module SettingsHelper
{:name => 'authentication', :partial => 'settings/authentication', :label => :label_authentication}, {:name => 'authentication', :partial => 'settings/authentication', :label => :label_authentication},
{:name => 'projects', :partial => 'settings/projects', :label => :label_project_plural}, {:name => 'projects', :partial => 'settings/projects', :label => :label_project_plural},
{:name => 'issues', :partial => 'settings/issues', :label => :label_issue_tracking}, {:name => 'issues', :partial => 'settings/issues', :label => :label_issue_tracking},
{:name => 'notifications', :partial => 'settings/notifications', :label => l(:field_mail_notification)}, {:name => 'notifications', :partial => 'settings/notifications', :label => :field_mail_notification},
{:name => 'mail_handler', :partial => 'settings/mail_handler', :label => l(:label_incoming_emails)}, {:name => 'mail_handler', :partial => 'settings/mail_handler', :label => :label_incoming_emails},
{:name => 'repositories', :partial => 'settings/repositories', :label => :label_repository_plural} {:name => 'repositories', :partial => 'settings/repositories', :label => :label_repository_plural}
] ]
end end
......
...@@ -109,7 +109,7 @@ class Changeset < ActiveRecord::Base ...@@ -109,7 +109,7 @@ class Changeset < ActiveRecord::Base
if self.scmid && (! (csettext =~ /^r[0-9]+$/)) if self.scmid && (! (csettext =~ /^r[0-9]+$/))
csettext = "commit:\"#{self.scmid}\"" csettext = "commit:\"#{self.scmid}\""
end end
journal = issue.init_journal(user || User.anonymous, l(:text_status_changed_by_changeset, csettext)) journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, csettext))
issue.status = fix_status issue.status = fix_status
issue.done_ratio = done_ratio if done_ratio issue.done_ratio = done_ratio if done_ratio
issue.save issue.save
......
...@@ -48,14 +48,14 @@ class CustomField < ActiveRecord::Base ...@@ -48,14 +48,14 @@ class CustomField < ActiveRecord::Base
def validate def validate
if self.field_format == "list" if self.field_format == "list"
errors.add(:possible_values, :activerecord_error_blank) if self.possible_values.nil? || self.possible_values.empty? errors.add(:possible_values, :blank) if self.possible_values.nil? || self.possible_values.empty?
errors.add(:possible_values, :activerecord_error_invalid) unless self.possible_values.is_a? Array errors.add(:possible_values, :invalid) unless self.possible_values.is_a? Array
end end
# validate default value # validate default value
v = CustomValue.new(:custom_field => self.clone, :value => default_value, :customized => nil) v = CustomValue.new(:custom_field => self.clone, :value => default_value, :customized => nil)
v.custom_field.is_required = false v.custom_field.is_required = false
errors.add(:default_value, :activerecord_error_invalid) unless v.valid? errors.add(:default_value, :invalid) unless v.valid?
end end
# Makes possible_values accept a multiline string # Makes possible_values accept a multiline string
......
...@@ -45,22 +45,22 @@ class CustomValue < ActiveRecord::Base ...@@ -45,22 +45,22 @@ class CustomValue < ActiveRecord::Base
protected protected
def validate def validate
if value.blank? if value.blank?
errors.add(:value, :activerecord_error_blank) if custom_field.is_required? and value.blank? errors.add(:value, :blank) if custom_field.is_required? and value.blank?
else else
errors.add(:value, :activerecord_error_invalid) unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp) errors.add(:value, :invalid) unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp)
errors.add(:value, :activerecord_error_too_short) if custom_field.min_length > 0 and value.length < custom_field.min_length errors.add(:value, :too_short) if custom_field.min_length > 0 and value.length < custom_field.min_length
errors.add(:value, :activerecord_error_too_long) if custom_field.max_length > 0 and value.length > custom_field.max_length errors.add(:value, :too_long) if custom_field.max_length > 0 and value.length > custom_field.max_length
# Format specific validations # Format specific validations
case custom_field.field_format case custom_field.field_format
when 'int' when 'int'
errors.add(:value, :activerecord_error_not_a_number) unless value =~ /^[+-]?\d+$/ errors.add(:value, :not_a_number) unless value =~ /^[+-]?\d+$/
when 'float' when 'float'
begin; Kernel.Float(value); rescue; errors.add(:value, :activerecord_error_invalid) end begin; Kernel.Float(value); rescue; errors.add(:value, :invalid) end
when 'date' when 'date'
errors.add(:value, :activerecord_error_not_a_date) unless value =~ /^\d{4}-\d{2}-\d{2}$/ errors.add(:value, :not_a_date) unless value =~ /^\d{4}-\d{2}-\d{2}$/
when 'list' when 'list'
errors.add(:value, :activerecord_error_inclusion) unless custom_field.possible_values.include?(value) errors.add(:value, :inclusion) unless custom_field.possible_values.include?(value)
end end
end end
end end
......
...@@ -129,20 +129,20 @@ class Issue < ActiveRecord::Base ...@@ -129,20 +129,20 @@ class Issue < ActiveRecord::Base
def validate def validate
if self.due_date.nil? && @attributes['due_date'] && !@attributes['due_date'].empty? if self.due_date.nil? && @attributes['due_date'] && !@attributes['due_date'].empty?
errors.add :due_date, :activerecord_error_not_a_date errors.add :due_date, :not_a_date
end end
if self.due_date and self.start_date and self.due_date < self.start_date if self.due_date and self.start_date and self.due_date < self.start_date
errors.add :due_date, :activerecord_error_greater_than_start_date errors.add :due_date, :greater_than_start_date
end end
if start_date && soonest_start && start_date < soonest_start if start_date && soonest_start && start_date < soonest_start
errors.add :start_date, :activerecord_error_invalid errors.add :start_date, :invalid
end end
end end
def validate_on_create def validate_on_create
errors.add :tracker_id, :activerecord_error_invalid unless project.trackers.include?(tracker) errors.add :tracker_id, :invalid unless project.trackers.include?(tracker)
end end
def before_create def before_create
......
...@@ -39,9 +39,9 @@ class IssueRelation < ActiveRecord::Base ...@@ -39,9 +39,9 @@ class IssueRelation < ActiveRecord::Base
def validate def validate
if issue_from && issue_to if issue_from && issue_to
errors.add :issue_to_id, :activerecord_error_invalid if issue_from_id == issue_to_id errors.add :issue_to_id, :invalid if issue_from_id == issue_to_id
errors.add :issue_to_id, :activerecord_error_not_same_project unless issue_from.project_id == issue_to.project_id || Setting.cross_project_issue_relations? errors.add :issue_to_id, :not_same_project unless issue_from.project_id == issue_to.project_id || Setting.cross_project_issue_relations?
errors.add_to_base :activerecord_error_circular_dependency if issue_to.all_dependent_issues.include? issue_from errors.add_to_base :circular_dependency if issue_to.all_dependent_issues.include? issue_from
end end
end end
......
...@@ -236,4 +236,9 @@ class MailHandler < ActionMailer::Base ...@@ -236,4 +236,9 @@ class MailHandler < ActionMailer::Base
end end
@plain_text_body.strip! @plain_text_body.strip!
end end
def self.full_sanitizer
@full_sanitizer ||= HTML::FullSanitizer.new
end
end end
...@@ -21,6 +21,7 @@ class Mailer < ActionMailer::Base ...@@ -21,6 +21,7 @@ class Mailer < ActionMailer::Base
helper :custom_fields helper :custom_fields
include ActionController::UrlWriter include ActionController::UrlWriter
include Redmine::I18n
def issue_add(issue) def issue_add(issue)
redmine_headers 'Project' => issue.project.identifier, redmine_headers 'Project' => issue.project.identifier,
......
...@@ -24,7 +24,7 @@ class Member < ActiveRecord::Base ...@@ -24,7 +24,7 @@ class Member < ActiveRecord::Base
validates_uniqueness_of :user_id, :scope => :project_id validates_uniqueness_of :user_id, :scope => :project_id
def validate def validate
errors.add :role_id, :activerecord_error_invalid if role && !role.member? errors.add :role_id, :invalid if role && !role.member?
end end
def name def name
......
...@@ -306,7 +306,7 @@ class Project < ActiveRecord::Base ...@@ -306,7 +306,7 @@ class Project < ActiveRecord::Base
protected protected
def validate def validate
errors.add(:identifier, :activerecord_error_invalid) if !identifier.blank? && identifier.match(/^\d*$/) errors.add(:identifier, :invalid) if !identifier.blank? && identifier.match(/^\d*$/)
end end
private private
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
class QueryColumn class QueryColumn
attr_accessor :name, :sortable, :default_order attr_accessor :name, :sortable, :default_order
include GLoc include Redmine::I18n
def initialize(name, options={}) def initialize(name, options={})
self.name = name self.name = name
...@@ -26,7 +26,6 @@ class QueryColumn ...@@ -26,7 +26,6 @@ class QueryColumn
end end
def caption def caption
set_language_if_valid(User.current.language)
l("field_#{name}") l("field_#{name}")
end end
end end
...@@ -113,7 +112,6 @@ class Query < ActiveRecord::Base ...@@ -113,7 +112,6 @@ class Query < ActiveRecord::Base
def initialize(attributes = nil) def initialize(attributes = nil)
super attributes super attributes
self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} } self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} }
set_language_if_valid(User.current.language)
end end
def after_initialize def after_initialize
...@@ -123,7 +121,7 @@ class Query < ActiveRecord::Base ...@@ -123,7 +121,7 @@ class Query < ActiveRecord::Base
def validate def validate
filters.each_key do |field| filters.each_key do |field|
errors.add label_for(field), :activerecord_error_blank unless errors.add label_for(field), :blank unless
# filter requires one or more values # filter requires one or more values
(values_for(field) and !values_for(field).first.blank?) or (values_for(field) and !values_for(field).first.blank?) or
# filter doesn't require any value # filter doesn't require any value
......
...@@ -25,7 +25,7 @@ class Repository < ActiveRecord::Base ...@@ -25,7 +25,7 @@ class Repository < ActiveRecord::Base
before_destroy :clear_changesets before_destroy :clear_changesets
# Checks if the SCM is enabled when creating a repository # Checks if the SCM is enabled when creating a repository
validate_on_create { |r| r.errors.add(:type, :activerecord_error_invalid) unless Setting.enabled_scm.include?(r.class.name.demodulize) } validate_on_create { |r| r.errors.add(:type, :invalid) unless Setting.enabled_scm.include?(r.class.name.demodulize) }
# Removes leading and trailing whitespace # Removes leading and trailing whitespace
def url=(arg) def url=(arg)
......
...@@ -26,13 +26,13 @@ class TimeEntry < ActiveRecord::Base ...@@ -26,13 +26,13 @@ class TimeEntry < ActiveRecord::Base
attr_protected :project_id, :user_id, :tyear, :tmonth, :tweek attr_protected :project_id, :user_id, :tyear, :tmonth, :tweek
acts_as_customizable acts_as_customizable
acts_as_event :title => Proc.new {|o| "#{o.user}: #{lwr(:label_f_hour, o.hours)} (#{(o.issue || o.project).event_title})"}, acts_as_event :title => Proc.new {|o| "#{o.user}: #{l_hours(o.hours)} (#{(o.issue || o.project).event_title})"},
:url => Proc.new {|o| {:controller => 'timelog', :action => 'details', :project_id => o.project}}, :url => Proc.new {|o| {:controller => 'timelog', :action => 'details', :project_id => o.project}},
:author => :user, :author => :user,
:description => :comments :description => :comments
validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on
validates_numericality_of :hours, :allow_nil => true, :message => :activerecord_error_invalid validates_numericality_of :hours, :allow_nil => true, :message => :invalid
validates_length_of :comments, :maximum => 255, :allow_nil => true validates_length_of :comments, :maximum => 255, :allow_nil => true
def after_initialize def after_initialize
...@@ -48,9 +48,9 @@ class TimeEntry < ActiveRecord::Base ...@@ -48,9 +48,9 @@ class TimeEntry < ActiveRecord::Base
end end
def validate def validate
errors.add :hours, :activerecord_error_invalid if hours && (hours < 0 || hours >= 1000) errors.add :hours, :invalid if hours && (hours < 0 || hours >= 1000)
errors.add :project_id, :activerecord_error_invalid if project.nil? errors.add :project_id, :invalid if project.nil?
errors.add :issue_id, :activerecord_error_invalid if (issue_id && !issue) || (issue && project!=issue.project) errors.add :issue_id, :invalid if (issue_id && !issue) || (issue && project!=issue.project)
end end
def hours=(h) def hours=(h)
......
...@@ -25,7 +25,7 @@ class Version < ActiveRecord::Base ...@@ -25,7 +25,7 @@ class Version < ActiveRecord::Base
validates_presence_of :name validates_presence_of :name
validates_uniqueness_of :name, :scope => [:project_id] validates_uniqueness_of :name, :scope => [:project_id]
validates_length_of :name, :maximum => 60 validates_length_of :name, :maximum => 60
validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => 'activerecord_error_not_a_date', :allow_nil => true validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :not_a_date, :allow_nil => true
def start_date def start_date
effective_date effective_date
......
...@@ -25,6 +25,6 @@ class Watcher < ActiveRecord::Base ...@@ -25,6 +25,6 @@ class Watcher < ActiveRecord::Base
protected protected
def validate def validate
errors.add :user_id, :activerecord_error_invalid unless user.nil? || user.active? errors.add :user_id, :invalid unless user.nil? || user.active?
end end
end end
...@@ -129,9 +129,9 @@ class WikiPage < ActiveRecord::Base ...@@ -129,9 +129,9 @@ class WikiPage < ActiveRecord::Base
protected protected
def validate def validate
errors.add(:parent_title, :activerecord_error_invalid) if !@parent_title.blank? && parent.nil? errors.add(:parent_title, :invalid) if !@parent_title.blank? && parent.nil?
errors.add(:parent_title, :activerecord_error_circular_dependency) if parent && (parent == self || parent.ancestors.include?(self)) errors.add(:parent_title, :circular_dependency) if parent && (parent == self || parent.ancestors.include?(self))
errors.add(:parent_title, :activerecord_error_not_same_project) if parent && (parent.wiki_id != wiki_id) errors.add(:parent_title, :not_same_project) if parent && (parent.wiki_id != wiki_id)
end end
end end
......
...@@ -20,7 +20,7 @@ while day <= calendar.enddt %> ...@@ -20,7 +20,7 @@ while day <= calendar.enddt %>
image_tag('arrow_to.png') image_tag('arrow_to.png')
end %> end %>
<%= h("#{i.project} -") unless @project && @project == i.project %> <%= h("#{i.project} -") unless @project && @project == i.project %>
<%= link_to_issue i %>: <%= h(truncate(i.subject, 30)) %> <%= link_to_issue i %>: <%= h(truncate(i.subject, :length => 30)) %>
<span class="tip"><%= render_issue_tooltip i %></span> <span class="tip"><%= render_issue_tooltip i %></span>
</div> </div>
<% else %> <% else %>
......
xml.instruct! xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
xml.title truncate_single_line(@title, 100) xml.title truncate_single_line(@title, :length => 100)
xml.link "rel" => "self", "href" => url_for(params.merge({:format => nil, :only_path => false})) xml.link "rel" => "self", "href" => url_for(params.merge({:format => nil, :only_path => false}))
xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false) xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false)
xml.id url_for(:controller => 'welcome', :only_path => false) xml.id url_for(:controller => 'welcome', :only_path => false)
...@@ -11,9 +11,9 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do ...@@ -11,9 +11,9 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
xml.entry do xml.entry do
url = url_for(item.event_url(:only_path => false)) url = url_for(item.event_url(:only_path => false))
if @project if @project
xml.title truncate_single_line(item.event_title, 100) xml.title truncate_single_line(item.event_title, :length => 100)
else else
xml.title truncate_single_line("#{item.project} - #{item.event_title}", 100) xml.title truncate_single_line("#{item.project} - #{item.event_title}", :length => 100)
end end
xml.link "rel" => "alternate", "href" => url xml.link "rel" => "alternate", "href" => url
xml.id url xml.id url
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<td align="center"><%= image_tag 'true.png' if custom_field.is_required? %></td> <td align="center"><%= image_tag 'true.png' if custom_field.is_required? %></td>
<% if tab[:name] == 'IssueCustomField' %> <% if tab[:name] == 'IssueCustomField' %>
<td align="center"><%= image_tag 'true.png' if custom_field.is_for_all? %></td> <td align="center"><%= image_tag 'true.png' if custom_field.is_for_all? %></td>
<td align="center"><%= custom_field.projects.count.to_s + ' ' + lwr(:label_project, custom_field.projects.count) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %></td> <td align="center"><%= l(:label_x_projects, :count => custom_field.projects.count) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %></td>
<% end %> <% end %>
<td align="center" style="width:15%;"> <td align="center" style="width:15%;">
<%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => custom_field, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %> <%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => custom_field, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
......
<p><%= link_to h(document.title), :controller => 'documents', :action => 'show', :id => document %><br /> <p><%= link_to h(document.title), :controller => 'documents', :action => 'show', :id => document %><br />
<% unless document.description.blank? %><%=h(truncate(document.description, 250)) %><br /><% end %> <% unless document.description.blank? %><%=h(truncate(document.description, :length => 250)) %><br /><% end %>
<em><%= format_time(document.created_on) %></em></p> <em><%= format_time(document.created_on) %></em></p>
\ No newline at end of file
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<table style="width:100%"> <table style="width:100%">
<% @issue.relations.select {|r| r.other_issue(@issue).visible? }.each do |relation| %> <% @issue.relations.select {|r| r.other_issue(@issue).visible? }.each do |relation| %>
<tr> <tr>
<td><%= l(relation.label_for(@issue)) %> <%= "(#{lwr(:actionview_datehelper_time_in_words_day, relation.delay)})" if relation.delay && relation.delay != 0 %> <td><%= l(relation.label_for(@issue)) %> <%= "(#{l('datetime.distance_in_words.x_days', :count => relation.delay)})" if relation.delay && relation.delay != 0 %>
<%= h(relation.other_issue(@issue).project) + ' - ' if Setting.cross_project_issue_relations? %> <%= link_to_issue relation.other_issue(@issue) %></td> <%= h(relation.other_issue(@issue).project) + ' - ' if Setting.cross_project_issue_relations? %> <%= link_to_issue relation.other_issue(@issue) %></td>
<td><%=h relation.other_issue(@issue).subject %></td> <td><%=h relation.other_issue(@issue).subject %></td>
<td><%= relation.other_issue(@issue).status.name %></td> <td><%= relation.other_issue(@issue).status.name %></td>
......
...@@ -34,13 +34,13 @@ ...@@ -34,13 +34,13 @@
<td class="category"><b><%=l(:field_category)%>:</b></td><td><%=h @issue.category ? @issue.category.name : "-" %></td> <td class="category"><b><%=l(:field_category)%>:</b></td><td><%=h @issue.category ? @issue.category.name : "-" %></td>
<% if User.current.allowed_to?(:view_time_entries, @project) %> <% if User.current.allowed_to?(:view_time_entries, @project) %>
<td class="spent-time"><b><%=l(:label_spent_time)%>:</b></td> <td class="spent-time"><b><%=l(:label_spent_time)%>:</b></td>
<td class="spent-hours"><%= @issue.spent_hours > 0 ? (link_to lwr(:label_f_hour, @issue.spent_hours), {:controller => 'timelog', :action => 'details', :project_id => @project, :issue_id => @issue}) : "-" %></td> <td class="spent-hours"><%= @issue.spent_hours > 0 ? (link_to l_hours(@issue.spent_hours), {:controller => 'timelog', :action => 'details', :project_id => @project, :issue_id => @issue}) : "-" %></td>
<% end %> <% end %>
</tr> </tr>
<tr> <tr>
<td class="fixed-version"><b><%=l(:field_fixed_version)%>:</b></td><td><%= @issue.fixed_version ? link_to_version(@issue.fixed_version) : "-" %></td> <td class="fixed-version"><b><%=l(:field_fixed_version)%>:</b></td><td><%= @issue.fixed_version ? link_to_version(@issue.fixed_version) : "-" %></td>
<% if @issue.estimated_hours %> <% if @issue.estimated_hours %>
<td class="estimated-hours"><b><%=l(:field_estimated_hours)%>:</b></td><td><%= lwr(:label_f_hour, @issue.estimated_hours) %></td> <td class="estimated-hours"><b><%=l(:field_estimated_hours)%>:</b></td><td><%= l_hours(@issue.estimated_hours) %></td>
<% end %> <% end %>
</tr> </tr>
<tr> <tr>
......
<%= l(:text_issue_added, "##{@issue.id}", @issue.author) %> <%= l(:text_issue_added, :id => "##{@issue.id}", :author => @issue.author) %>
<hr /> <hr />
<%= render :partial => "issue_text_html", :locals => { :issue => @issue, :issue_url => @issue_url } %> <%= render :partial => "issue_text_html", :locals => { :issue => @issue, :issue_url => @issue_url } %>
<%= l(:text_issue_added, "##{@issue.id}", @issue.author) %> <%= l(:text_issue_added, :id => "##{@issue.id}", :author => @issue.author) %>
---------------------------------------- ----------------------------------------
<%= render :partial => "issue_text_plain", :locals => { :issue => @issue, :issue_url => @issue_url } %> <%= render :partial => "issue_text_plain", :locals => { :issue => @issue, :issue_url => @issue_url } %>
<%= l(:text_issue_updated, "##{@issue.id}", @journal.user) %> <%= l(:text_issue_updated, :id => "##{@issue.id}", :author => @journal.user) %>
<ul> <ul>
<% for detail in @journal.details %> <% for detail in @journal.details %>
......
<%= l(:text_issue_updated, "##{@issue.id}", @journal.user) %> <%= l(:text_issue_updated, :id => "##{@issue.id}", :author => @journal.user) %>
<% for detail in @journal.details -%> <% for detail in @journal.details -%>
<%= show_detail(detail, true) %> <%= show_detail(detail, true) %>
......
<p><%= l(:mail_body_reminder, @issues.size, @days) %></p> <p><%= l(:mail_body_reminder, :count => @issues.size, :days => @days) %></p>
<ul> <ul>
<% @issues.each do |issue| -%> <% @issues.each do |issue| -%>
......
<%= l(:mail_body_reminder, @issues.size, @days) %>: <%= l(:mail_body_reminder, :count => @issues.size, :days => @days) %>:
<% @issues.each do |issue| -%> <% @issues.each do |issue| -%>
* <%= "#{issue.project} - #{issue.tracker} ##{issue.id}: #{issue.subject}" %> * <%= "#{issue.project} - #{issue.tracker} ##{issue.id}: #{issue.subject}" %>
......
<h3><%=l(:label_watched_issues)%></h3> <h3><%=l(:label_watched_issues)%> (<%= Issue.visible.count(:include => :watchers,
:conditions => ["#{Watcher.table_name}.user_id = ?", user.id]) %>)</h3>
<% watched_issues = Issue.visible.find(:all, <% watched_issues = Issue.visible.find(:all,
:include => [:status, :project, :tracker, :watchers], :include => [:status, :project, :tracker, :watchers],
:limit => 10, :limit => 10,
......
<p><%= link_to(h(news.project.name), :controller => 'projects', :action => 'show', :id => news.project) + ': ' unless @project %> <p><%= link_to(h(news.project.name), :controller => 'projects', :action => 'show', :id => news.project) + ': ' unless @project %>
<%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %> <%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %>
<%= "(#{news.comments_count} #{lwr(:label_comment, news.comments_count).downcase})" if news.comments_count > 0 %> <%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>
<br /> <br />
<% unless news.summary.blank? %><span class="summary"><%=h news.summary %></span><br /><% end %> <% unless news.summary.blank? %><span class="summary"><%=h news.summary %></span><br /><% end %>
<span class="author"><%= authoring news.created_on, news.author %></span></p> <span class="author"><%= authoring news.created_on, news.author %></span></p>
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
<% @newss.each do |news| %> <% @newss.each do |news| %>
<h3><%= link_to(h(news.project.name), :controller => 'projects', :action => 'show', :id => news.project) + ': ' unless news.project == @project %> <h3><%= link_to(h(news.project.name), :controller => 'projects', :action => 'show', :id => news.project) + ': ' unless news.project == @project %>
<%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %> <%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %>
<%= "(#{news.comments_count} #{lwr(:label_comment, news.comments_count).downcase})" if news.comments_count > 0 %></h3> <%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %></h3>
<p class="author"><%= authoring news.created_on, news.author %></p> <p class="author"><%= authoring news.created_on, news.author %></p>
<div class="wiki"> <div class="wiki">
<%= textilizable(news.description) %> <%= textilizable(news.description) %>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<p><%= f.text_area :description, :rows => 5, :class => 'wiki-edit' %></p> <p><%= f.text_area :description, :rows => 5, :class => 'wiki-edit' %></p>
<p><%= f.text_field :identifier, :required => true, :disabled => @project.identifier_frozen? %> <p><%= f.text_field :identifier, :required => true, :disabled => @project.identifier_frozen? %>
<% unless @project.identifier_frozen? %> <% unless @project.identifier_frozen? %>
<br /><em><%= l(:text_length_between, 2, 20) %> <%= l(:text_project_identifier_info) %></em> <br /><em><%= l(:text_length_between, :min => 2, :max => 20) %> <%= l(:text_project_identifier_info) %></em>
<% end %></p> <% end %></p>
<p><%= f.text_field :homepage, :size => 60 %></p> <p><%= f.text_field :homepage, :size => 60 %></p>
<p><%= f.check_box :is_public %></p> <p><%= f.check_box :is_public %></p>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<% Redmine::AccessControl.available_project_modules.each do |m| %> <% Redmine::AccessControl.available_project_modules.each do |m| %>
<label class="floating"> <label class="floating">
<%= check_box_tag 'enabled_modules[]', m, @project.module_enabled?(m) %> <%= check_box_tag 'enabled_modules[]', m, @project.module_enabled?(m) %>
<%= (l_has_string?("project_module_#{m}".to_sym) ? l("project_module_#{m}".to_sym) : m.to_s.humanize) %> <%= l_or_humanize(m, :prefix => "project_module_") %>
</label> </label>
<% end %> <% end %>
</fieldset> </fieldset>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<% Redmine::AccessControl.available_project_modules.each do |m| %> <% Redmine::AccessControl.available_project_modules.each do |m| %>
<p><label><%= check_box_tag 'enabled_modules[]', m, @project.module_enabled?(m) -%> <p><label><%= check_box_tag 'enabled_modules[]', m, @project.module_enabled?(m) -%>
<%= (l_has_string?("project_module_#{m}".to_sym) ? l("project_module_#{m}".to_sym) : m.to_s.humanize) %></label></p> <%= l_or_humanize(m, :prefix => "project_module_") %></label></p>
<% end %> <% end %>
</div> </div>
......
...@@ -23,8 +23,9 @@ ...@@ -23,8 +23,9 @@
<li><%= link_to tracker.name, :controller => 'issues', :action => 'index', :project_id => @project, <li><%= link_to tracker.name, :controller => 'issues', :action => 'index', :project_id => @project,
:set_filter => 1, :set_filter => 1,
"tracker_id" => tracker.id %>: "tracker_id" => tracker.id %>:
<%= @open_issues_by_tracker[tracker] || 0 %> <%= lwr(:label_open_issues, @open_issues_by_tracker[tracker] || 0) %> <%= l(:label_x_open_issues_abbr_on_total, :count => @open_issues_by_tracker[tracker].to_i,
<%= l(:label_on) %> <%= @total_issues_by_tracker[tracker] || 0 %></li> :total => @total_issues_by_tracker[tracker].to_i) %>
</li>
<% end %> <% end %>
</ul> </ul>
<p><%= link_to l(:label_issue_view_all), :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1 %></p> <p><%= link_to l(:label_issue_view_all), :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1 %></p>
...@@ -65,7 +66,7 @@ ...@@ -65,7 +66,7 @@
<% if @total_hours && User.current.allowed_to?(:view_time_entries, @project) %> <% if @total_hours && User.current.allowed_to?(:view_time_entries, @project) %>
<h3><%= l(:label_spent_time) %></h3> <h3><%= l(:label_spent_time) %></h3>
<p><span class="icon icon-time"><%= lwr(:label_f_hour, @total_hours) %></span></p> <p><span class="icon icon-time"><%= l_hours(@total_hours) %></span></p>
<p><%= link_to(l(:label_details), {:controller => 'timelog', :action => 'details', :project_id => @project}) %> | <p><%= link_to(l(:label_details), {:controller => 'timelog', :action => 'details', :project_id => @project}) %> |
<%= link_to(l(:label_report), {:controller => 'timelog', :action => 'report', :project_id => @project}) %></p> <%= link_to(l(:label_report), {:controller => 'timelog', :action => 'report', :project_id => @project}) %></p>
<% end %> <% end %>
......
...@@ -19,6 +19,6 @@ ...@@ -19,6 +19,6 @@
<td class="revision"><%= link_to(format_revision(entry.lastrev.name), :action => 'revision', :id => @project, :rev => entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %></td> <td class="revision"><%= link_to(format_revision(entry.lastrev.name), :action => 'revision', :id => @project, :rev => entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %></td>
<td class="age"><%= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %></td> <td class="age"><%= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %></td>
<td class="author"><%= changeset.nil? ? h(entry.lastrev.author.to_s.split('<').first) : changeset.author if entry.lastrev %></td> <td class="author"><%= changeset.nil? ? h(entry.lastrev.author.to_s.split('<').first) : changeset.author if entry.lastrev %></td>
<td class="comments"><%=h truncate(changeset.comments, 50) unless changeset.nil? %></td> <td class="comments"><%=h truncate(changeset.comments, :length => 50) unless changeset.nil? %></td>
</tr> </tr>
<% end %> <% end %>
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<h3><%= l(:label_result_plural) %> (<%= @results_by_type.values.sum %>)</h3> <h3><%= l(:label_result_plural) %> (<%= @results_by_type.values.sum %>)</h3>
<dl id="search-results"> <dl id="search-results">
<% @results.each do |e| %> <% @results.each do |e| %>
<dt class="<%= e.event_type %>"><%= content_tag('span', h(e.project), :class => 'project') unless @project == e.project %> <%= link_to highlight_tokens(truncate(e.event_title, 255), @tokens), e.event_url %></dt> <dt class="<%= e.event_type %>"><%= content_tag('span', h(e.project), :class => 'project') unless @project == e.project %> <%= link_to highlight_tokens(truncate(e.event_title, :length => 255), @tokens), e.event_url %></dt>
<dd><span class="description"><%= highlight_tokens(e.event_description, @tokens) %></span> <dd><span class="description"><%= highlight_tokens(e.event_description, @tokens) %></span>
<span class="author"><%= format_time(e.event_datetime) %></span></dd> <span class="author"><%= format_time(e.event_datetime) %></span></dd>
<% end %> <% end %>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<%= check_box_tag 'settings[login_required]', 1, Setting.login_required? %><%= hidden_field_tag 'settings[login_required]', 0 %></p> <%= check_box_tag 'settings[login_required]', 1, Setting.login_required? %><%= hidden_field_tag 'settings[login_required]', 0 %></p>
<p><label><%= l(:setting_autologin) %></label> <p><label><%= l(:setting_autologin) %></label>
<%= 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> <%= select_tag 'settings[autologin]', options_for_select( [[l(:label_disabled), "0"]] + [1, 7, 30, 365].collect{|days| [l('datetime.distance_in_words.x_days', :count => days), days.to_s]}, Setting.autologin) %></p>
<p><label><%= l(:setting_self_registration) %></label> <p><label><%= l(:setting_self_registration) %></label>
<%= select_tag 'settings[self_registration]', <%= select_tag 'settings[self_registration]',
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<td class="project"><%=h entry.project %></td> <td class="project"><%=h entry.project %></td>
<td class="subject"> <td class="subject">
<% if entry.issue -%> <% if entry.issue -%>
<%= link_to_issue entry.issue %>: <%= h(truncate(entry.issue.subject, 50)) -%> <%= link_to_issue entry.issue %>: <%= h(truncate(entry.issue.subject, :length => 50)) -%>
<% end -%> <% end -%>
</td> </td>
<td class="comments"><%=h entry.comments %></td> <td class="comments"><%=h entry.comments %></td>
......
...@@ -15,7 +15,7 @@ already in the URI %> ...@@ -15,7 +15,7 @@ already in the URI %>
<% end %> <% end %>
<div class="total-hours"> <div class="total-hours">
<p><%= l(:label_total) %>: <%= html_hours(lwr(:label_f_hour, @total_hours)) %></p> <p><%= l(:label_total) %>: <%= html_hours(l_hours(@total_hours)) %></p>
</div> </div>
<% unless @entries.empty? %> <% unless @entries.empty? %>
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
[l(:label_day_plural).titleize, 'day']], @columns), [l(:label_day_plural).titleize, 'day']], @columns),
:onchange => "this.form.onsubmit();" %> :onchange => "this.form.onsubmit();" %>
<%= l(:button_add) %>: <%= select_tag('criterias[]', options_for_select([[]] + (@available_criterias.keys - @criterias).collect{|k| [l(@available_criterias[k][:label]), k]}), <%= l(:button_add) %>: <%= select_tag('criterias[]', options_for_select([[]] + (@available_criterias.keys - @criterias).collect{|k| [l_or_humanize(@available_criterias[k][:label]), k]}),
:onchange => "this.form.onsubmit();", :onchange => "this.form.onsubmit();",
:style => 'width: 200px', :style => 'width: 200px',
:id => nil, :id => nil,
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<% unless @criterias.empty? %> <% unless @criterias.empty? %>
<div class="total-hours"> <div class="total-hours">
<p><%= l(:label_total) %>: <%= html_hours(lwr(:label_f_hour, @total_hours)) %></p> <p><%= l(:label_total) %>: <%= html_hours(l_hours(@total_hours)) %></p>
</div> </div>
<% unless @hours.empty? %> <% unless @hours.empty? %>
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<thead> <thead>
<tr> <tr>
<% @criterias.each do |criteria| %> <% @criterias.each do |criteria| %>
<th><%= l(@available_criterias[criteria][:label]) %></th> <th><%= l_or_humanize(@available_criterias[criteria][:label]) %></th>
<% end %> <% end %>
<% columns_width = (40 / (@periods.length+1)).to_i %> <% columns_width = (40 / (@periods.length+1)).to_i %>
<% @periods.each do |period| %> <% @periods.each do |period| %>
......
...@@ -9,12 +9,10 @@ ...@@ -9,12 +9,10 @@
<% if version.fixed_issues.count > 0 %> <% if version.fixed_issues.count > 0 %>
<%= progress_bar([version.closed_pourcent, version.completed_pourcent], :width => '40em', :legend => ('%0.0f%' % version.completed_pourcent)) %> <%= progress_bar([version.closed_pourcent, version.completed_pourcent], :width => '40em', :legend => ('%0.0f%' % version.completed_pourcent)) %>
<p class="progress-info"> <p class="progress-info">
<%= link_to(version.closed_issues_count, :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'c', :fixed_version_id => version, :set_filter => 1) %> <%= link_to_if(version.closed_issues_count > 0, l(:label_x_closed_issues_abbr, :count => version.closed_issues_count), :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'c', :fixed_version_id => version, :set_filter => 1) %>
<%= lwr(:label_closed_issues, version.closed_issues_count) %>
(<%= '%0.0f' % (version.closed_issues_count.to_f / version.fixed_issues.count * 100) %>%) (<%= '%0.0f' % (version.closed_issues_count.to_f / version.fixed_issues.count * 100) %>%)
&#160; &#160;
<%= link_to(version.open_issues_count, :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'o', :fixed_version_id => version, :set_filter => 1) %> <%= link_to_if(version.open_issues_count > 0, l(:label_x_open_issues_abbr, :count => version.open_issues_count), :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'o', :fixed_version_id => version, :set_filter => 1) %>
<%= lwr(:label_open_issues, version.open_issues_count)%>
(<%= '%0.0f' % (version.open_issues_count.to_f / version.fixed_issues.count * 100) %>%) (<%= '%0.0f' % (version.open_issues_count.to_f / version.fixed_issues.count * 100) %>%)
</p> </p>
<% else %> <% else %>
......
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
<table> <table>
<tr> <tr>
<td width="130px" align="right"><%= l(:field_estimated_hours) %></td> <td width="130px" align="right"><%= l(:field_estimated_hours) %></td>
<td width="240px" class="total-hours"width="130px" align="right"><%= html_hours(lwr(:label_f_hour, @version.estimated_hours)) %></td> <td width="240px" class="total-hours"width="130px" align="right"><%= html_hours(l_hours(@version.estimated_hours)) %></td>
</tr> </tr>
<% if User.current.allowed_to?(:view_time_entries, @project) %> <% if User.current.allowed_to?(:view_time_entries, @project) %>
<tr> <tr>
<td width="130px" align="right"><%= l(:label_spent_time) %></td> <td width="130px" align="right"><%= l(:label_spent_time) %></td>
<td width="240px" class="total-hours"><%= html_hours(lwr(:label_f_hour, @version.spent_hours)) %></td> <td width="240px" class="total-hours"><%= html_hours(l_hours(@version.spent_hours)) %></td>
</tr> </tr>
<% end %> <% end %>
</table> </table>
......
...@@ -67,7 +67,7 @@ module Rails ...@@ -67,7 +67,7 @@ module Rails
class << self class << self
def rubygems_version def rubygems_version
Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion Gem::RubyGemsVersion rescue nil
end end
def gem_version def gem_version
...@@ -82,14 +82,14 @@ module Rails ...@@ -82,14 +82,14 @@ module Rails
def load_rubygems def load_rubygems
require 'rubygems' require 'rubygems'
min_version = '1.3.1'
unless rubygems_version >= '0.9.4' unless rubygems_version >= min_version
$stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.) $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
exit 1 exit 1
end end
rescue LoadError rescue LoadError
$stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org) $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
exit 1 exit 1
end end
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# ENV['RAILS_ENV'] ||= 'production' # ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present # Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.1.2' unless defined? RAILS_GEM_VERSION RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration # Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot') require File.join(File.dirname(__FILE__), 'boot')
...@@ -30,11 +30,6 @@ Rails::Initializer.run do |config| ...@@ -30,11 +30,6 @@ Rails::Initializer.run do |config|
# (by default production uses :info, the others :debug) # (by default production uses :info, the others :debug)
# config.log_level = :debug # config.log_level = :debug
# Use the database for sessions instead of the file system
# (create the session table with 'rake db:sessions:create')
# config.action_controller.session_store = :active_record_store
config.action_controller.session_store = :PStore
# Enable page/fragment caching by setting a file-based store # Enable page/fragment caching by setting a file-based store
# (remember to create the caching directory and make it readable to the application) # (remember to create the caching directory and make it readable to the application)
# config.action_controller.fragment_cache_store = :file_store, "#{RAILS_ROOT}/cache" # config.action_controller.fragment_cache_store = :file_store, "#{RAILS_ROOT}/cache"
......
...@@ -15,3 +15,8 @@ config.action_controller.perform_caching = false ...@@ -15,3 +15,8 @@ config.action_controller.perform_caching = false
config.action_mailer.perform_deliveries = true config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :test config.action_mailer.delivery_method = :test
config.action_controller.session = {
:session_key => "_test_session",
:secret => "some secret phrase for the tests."
}
...@@ -15,3 +15,8 @@ config.action_controller.perform_caching = false ...@@ -15,3 +15,8 @@ config.action_controller.perform_caching = false
config.action_mailer.perform_deliveries = true config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :test config.action_mailer.delivery_method = :test
config.action_controller.session = {
:session_key => "_test_session",
:secret => "some secret phrase for the tests."
}
...@@ -15,3 +15,8 @@ config.action_controller.perform_caching = false ...@@ -15,3 +15,8 @@ config.action_controller.perform_caching = false
config.action_mailer.perform_deliveries = true config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :test config.action_mailer.delivery_method = :test
config.action_controller.session = {
:session_key => "_test_session",
:secret => "some secret phrase for the tests."
}
ActiveRecord::Errors.default_error_messages = { require 'activerecord'
:inclusion => "activerecord_error_inclusion",
:exclusion => "activerecord_error_exclusion", module ActiveRecord
:invalid => "activerecord_error_invalid", class Base
:confirmation => "activerecord_error_confirmation", include Redmine::I18n
:accepted => "activerecord_error_accepted",
:empty => "activerecord_error_empty", # Translate attribute names for validation errors display
:blank => "activerecord_error_blank", def self.human_attribute_name(attr)
:too_long => "activerecord_error_too_long", l("field_#{attr.to_s.gsub(/_id$/, '')}")
:too_short => "activerecord_error_too_short", end
:wrong_length => "activerecord_error_wrong_length", end
:taken => "activerecord_error_taken", end
:not_a_number => "activerecord_error_not_a_number"
} if ActiveRecord::Errors.respond_to?('default_error_messages=') module ActionView
module Helpers
module DateHelper
# distance_of_time_in_words breaks when difference is greater than 30 years
def distance_of_date_in_words(from_date, to_date = 0, options = {})
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
I18n.with_options :locale => options[:locale], :scope => :'datetime.distance_in_words' do |locale|
case distance_in_days
when 0..60 then locale.t :x_days, :count => distance_in_days
when 61..720 then locale.t :about_x_months, :count => (distance_in_days / 30).round
else locale.t :over_x_years, :count => (distance_in_days / 365).round
end
end
end
end
end
end
ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" } ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| "#{html_tag}" }
......
GLoc.set_config :default_language => :en I18n.default_locale = 'en'
GLoc.clear_strings
GLoc.set_kcode
GLoc.load_localized_strings
GLoc.set_config(:raise_string_not_found_errors => false)
require 'redmine' require 'redmine'
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -4,6 +4,7 @@ class ExampleController < ApplicationController ...@@ -4,6 +4,7 @@ class ExampleController < ApplicationController
layout 'base' layout 'base'
before_filter :find_project, :authorize before_filter :find_project, :authorize
menu_item :sample_plugin
def say_hello def say_hello
@value = Setting.plugin_sample_plugin['sample_setting'] @value = Setting.plugin_sample_plugin['sample_setting']
......
# Sample plugin
en:
label_plugin_example: Sample Plugin
label_meeting_plural: Meetings
text_say_hello: Plugin say 'Hello'
text_say_goodbye: Plugin say 'Good bye'
# Sample plugin
fr:
label_plugin_example: Plugin exemple
label_meeting_plural: Meetings
text_say_hello: Plugin dit 'Bonjour'
text_say_goodbye: Plugin dit 'Au revoir'
# Sample plugin
label_plugin_example: Sample Plugin
label_meeting_plural: Meetings
text_say_hello: Plugin say 'Hello'
text_say_goodbye: Plugin say 'Good bye'
# Sample plugin
label_plugin_example: Plugin exemple
label_meeting_plural: Meetings
text_say_hello: Plugin dit 'Bonjour'
text_say_goodbye: Plugin dit 'Au revoir'
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment