Revision 1297:0a574315af3e app/helpers

View differences:

app/helpers/application_helper.rb
610 610

  
611 611
  def parse_inline_attachments(text, project, obj, attr, only_path, options)
612 612
    # when using an image link, try to use an attachment, if possible
613
    if options[:attachments] || (obj && obj.respond_to?(:attachments))
614
      attachments = options[:attachments] || obj.attachments
613
    attachments = options[:attachments] || []
614
    attachments += obj.attachments if obj.respond_to?(:attachments)
615
    if attachments.present?
615 616
      text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
616 617
        filename, ext, alt, alttext = $1.downcase, $2, $3, $4
617 618
        # search for the picture in attachments
......
716 717
  #     identifier:document:"Some document"
717 718
  #     identifier:version:1.0.0
718 719
  #     identifier:source:some/file
719
  def parse_redmine_links(text, project, obj, attr, only_path, options)
720
    text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(attachment|document|version|forum|news|message|project|commit|source|export)?(((#)|((([a-z0-9\-]+)\|)?(r)))((\d+)((#note)?-(\d+))?)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]][^A-Za-z0-9_/])|,|\s|\]|<|$)}) do |m|
720
  def parse_redmine_links(text, default_project, obj, attr, only_path, options)
721
    text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(attachment|document|version|forum|news|message|project|commit|source|export)?(((#)|((([a-z0-9\-_]+)\|)?(r)))((\d+)((#note)?-(\d+))?)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]][^A-Za-z0-9_/])|,|\s|\]|<|$)}) do |m|
721 722
      leading, esc, project_prefix, project_identifier, prefix, repo_prefix, repo_identifier, sep, identifier, comment_suffix, comment_id = $1, $2, $3, $4, $5, $10, $11, $8 || $12 || $18, $14 || $19, $15, $17
722 723
      link = nil
724
      project = default_project
723 725
      if project_identifier
724 726
        project = Project.visible.find_by_identifier(project_identifier)
725 727
      end
......
805 807
          when 'commit', 'source', 'export'
806 808
            if project
807 809
              repository = nil
808
              if name =~ %r{^(([a-z0-9\-]+)\|)(.+)$}
810
              if name =~ %r{^(([a-z0-9\-_]+)\|)(.+)$}
809 811
                repo_prefix, repo_identifier, name = $1, $2, $3
810 812
                repository = project.repositories.detect {|repo| repo.identifier == repo_identifier}
811 813
              else
......
832 834
            end
833 835
          when 'attachment'
834 836
            attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil)
835
            if attachments && attachment = attachments.detect {|a| a.filename == name }
837
            if attachments && attachment = Attachment.latest_attach(attachments, name)
836 838
              link = link_to h(attachment.filename), {:only_path => only_path, :controller => 'attachments', :action => 'download', :id => attachment},
837 839
                                                     :class => 'attachment'
838 840
            end
app/helpers/issues_helper.rb
350 350
    association = Issue.reflect_on_association(field.to_sym)
351 351
    if association
352 352
      record = association.class_name.constantize.find_by_id(id)
353
      return record.name if record
353
      if record
354
        record.name.force_encoding('UTF-8') if record.name.respond_to?(:force_encoding)
355
        return record.name
356
      end
354 357
    end
355 358
  end
356 359

  
app/helpers/queries_helper.rb
87 87
      format_time(value)
88 88
    when 'Date'
89 89
      format_date(value)
90
    when 'Fixnum', 'Float'
90
    when 'Fixnum'
91 91
      if column.name == :done_ratio
92 92
        progress_bar(value, :width => '80px')
93
      elsif  column.name == :spent_hours
94
        sprintf "%.2f", value
95 93
      else
96
        h(value.to_s)
94
        value.to_s
97 95
      end
96
    when 'Float'
97
      sprintf "%.2f", value
98 98
    when 'User'
99 99
      link_to_user value
100 100
    when 'Project'

Also available in: Unified diff