<commit_before># coding: utf-8
module ActiveScaffold
  module Helpers
    # Helpers that assist with the rendering of a List Column
    module ListColumnHelpers
      def get_column_value(record, column)
        begin
          # check for an override helper
          value = if column_override? column
            # we only pass the record as the argument. we previously also passed the formatted_value,
            # but <NAME> pointed out that prohibited the usage of overrides to improve on the
            # performance of our default formatting. see issue #138.
            send(column_override(column), record)
          # second, check if the dev has specified a valid list_ui for this column
          elsif column.list_ui and override_column_ui?(column.list_ui)
            send(override_column_ui(column.list_ui), column, record)

          elsif inplace_edit?(record, column)
            active_scaffold_inplace_edit(record, column)
          elsif column.column and override_column_ui?(column.column.type)
            send(override_column_ui(column.column.type), column, record)
          else
            format_column_value(record, column)
          end

          value = '&nbsp;'.html_safe if value.nil? or (value.respond_to?(:empty?) and value.empty?) # fix for IE 6
          return value
        rescue Exception => e
          logger.error Time.now.to_s + "#{e.inspect} -- on the ActiveScaffold column = :#{column.name} in #{controller.class}"
          raise e
        end
      end
      
      # TODO: move empty_field_text and &nbsp; logic in here?
      # TODO: move active_scaffold_inplace_edit in here?
      # TODO: we need to distinguish between the automatic links *we* create and the ones that the dev specified. some logic may not apply if the dev specified the link.
      def render_list_column(text, column, record)
        if column.link
          link = column.link
          associated = record.send(column.association.name) if column.association
          url_options = params_for(:action => nil, :id => record.id, :link => text)
          if column.association and link.controller.to_s != params[:controller]
            url_options[record.class.name.foreign_key.to_sym] = url_options.delete(:id)
            url_options[:id] = associated.id if associated and column.singular_association?
          end

          # setup automatic link
          if column.autolink? && column.singular_association? # link to inline form
            link = action_link_to_inline_form(column, associated)
            return text if link.crud_type.nil?
            url_options[:link] = as_(:create_new) if link.crud_type == :create
          end

          # check authorization
          if column.association
            associated_for_authorized = if associated.nil? || (associated.respond_to?(:empty?) && associated.empty?)<commit_msg>Bugfix: set parent_controller param for nested action_links with a different controller<commit_after># coding: utf-8
module ActiveScaffold
  module Helpers
    # Helpers that assist with the rendering of a List Column
    module ListColumnHelpers
      def get_column_value(record, column)
        begin
          # check for an override helper
          value = if column_override? column
            # we only pass the record as the argument. we previously also passed the formatted_value,
            # but <NAME> pointed out that prohibited the usage of overrides to improve on the
            # performance of our default formatting. see issue #138.
            send(column_override(column), record)
          # second, check if the dev has specified a valid list_ui for this column
          elsif column.list_ui and override_column_ui?(column.list_ui)
            send(override_column_ui(column.list_ui), column, record)

          elsif inplace_edit?(record, column)
            active_scaffold_inplace_edit(record, column)
          elsif column.column and override_column_ui?(column.column.type)
            send(override_column_ui(column.column.type), column, record)
          else
            format_column_value(record, column)
          end

          value = '&nbsp;'.html_safe if value.nil? or (value.respond_to?(:empty?) and value.empty?) # fix for IE 6
          return value
        rescue Exception => e
          logger.error Time.now.to_s + "#{e.inspect} -- on the ActiveScaffold column = :#{column.name} in #{controller.class}"
          raise e
        end
      end
      
      # TODO: move empty_field_text and &nbsp; logic in here?
      # TODO: move active_scaffold_inplace_edit in here?
      # TODO: we need to distinguish between the automatic links *we* create and the ones that the dev specified. some logic may not apply if the dev specified the link.
      def render_list_column(text, column, record)
        if column.link
          link = column.link
          associated = record.send(column.association.name) if column.association
          url_options = params_for(:action => nil, :id => record.id, :link => text)
          
          if column.association and link.controller.to_s != params[:controller]
            url_options[record.class.name.foreign_key.to_sym] = url_options.delete(:id)
            url_options[:id] = associated.id if associated and column.singular_association?
            url_options[:parent_controller] = params[:controller] 
          end

          # setup automatic link
          if column.autolink? && column.singular_association? # link to inline form
            link = action_link_to_inline_form(column, associated)
            return text if link.crud_type.nil?
            url_options[:link] = as_(:create_new) if link.crud_type == :create
          end

          # check authorization
          if column.association
            associated_for_authorized = if associated.nil? || (associated.respond_to?(:empty?) && associated.empty?)
{'fraction_non_alphanumeric': 0.07726344452008169, 'fraction_numerical': 0.0017018379850238256, 'mean_word_length': 2.557506053268765, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '670085', 'n_tokens_mistral': 1564, 'n_tokens_neox': 1543, 'n_words': 499}