<commit_before>module Extensions::MenuHelper
  def menu_item_link_to (item,current_branch,options={})
    picture=item.pictures.main_or_first if options[:image]
    title=options[:image] && picture ? image_tag(picture.picture.url) : item.name
    hsh={:class=>"active"} if current_branch.include?(item)
    link_to(h(title),item.link,hsh)
  end

  def get_current_menu_branch (menu_name)
    cur_in_menu = get_current_menu_item(menu_name)
    if cur_in_menu
      cur_in_menu.self_and_ancestors
    else
      []
    end
  end

  def get_current_menu_item(menu_name)
    id = get_id
 
    type = params[:controller].camelize
    if id
      menu=Admin::Menu.find_by_menu_name(menu_name)
      menu=Admin::MenuItem.find_by_branch_name(menu_name) unless menu
      menu_items = menu.menu_items.find(:all, :conditions=>['menuable_type=? AND menuable_id=? AND is_published=1',type,id])
    else
      return nil
    end
    menu_item=menu_items.empty? ? nil : Admin::MenuItem.get_deepest_item(menu_items)
    unless menu_item
      menu_item=get_menu_item_with_action(menu_name)
    end
    unless menu_item
      object=type.constantize
      menu_item=object.find_related_menu_item(menu_name,id) if object.respond_to?(:find_related_menu_item)
      unless menu_item
        menu_item = session["last_selected_#{menu_name.downcase}_item"] unless session["last_selected_#{menu_name.downcase}_item"].nil? 
      end
    else
      session["last_selected_#{menu_name.downcase}_item"] = menu_item
    end
    menu_item
  end

  def get_menu_item_with_action(menu_name)
    menu=Admin::Menu.find_by_menu_name(menu_name)
    menu_items=menu ? menu.action_item(params) : []
    menu_items.empty? ? nil : Admin::MenuItem.get_deepest_item(menu_items)
  end
  
  def get_menu_editors(id,namespace,object,menu_id)
    if Admin::Menu.exists?(menu_id)<commit_msg>change in menu_helper to recognize Admin::Action-s<commit_after>module Extensions::MenuHelper
  def menu_item_link_to (item,current_branch,options={})
    picture=item.pictures.main_or_first if options[:image]
    title=options[:image] && picture ? image_tag(picture.picture.url) : item.name
    hsh={:class=>"active"} if current_branch.include?(item)
    link_to(h(title),item.link,hsh)
  end

  def get_current_menu_branch (menu_name)
    cur_in_menu = get_current_menu_item(menu_name)
    if cur_in_menu
      cur_in_menu.self_and_ancestors
    else
      []
    end
  end

  def get_current_menu_item(menu_name)
    id = get_id
 
    type = params[:controller].camelize
    if id
      menu=Admin::Menu.find_by_menu_name(menu_name)
      menu=Admin::MenuItem.find_by_branch_name(menu_name) unless menu
      menu_items = menu.menu_items.find(:all, :conditions=>['menuable_type=? AND menuable_id=? AND is_published=1',type,id])
    end
    menu_item=menu_items.nil? || menu_items.empty? ? nil : Admin::MenuItem.get_deepest_item(menu_items)
    unless menu_item
      menu_item=get_menu_item_with_action(menu_name)
    end
    unless menu_item
      begin
        object=type.constantize
        menu_item=object.find_related_menu_item(menu_name,id) if object.respond_to?(:find_related_menu_item)
      rescue #table-less objects, e.g. start page
        menu=Admin::Menu.find_by_menu_name(menu_name)
        item=menu.menu_items.first
        if !item.nil?
          return item.root
        else
          return nil
        end
      end
      unless menu_item
        menu_item = session["last_selected_#{menu_name.downcase}_item"] unless session["last_selected_#{menu_name.downcase}_item"].nil? 
      end
    else
      session["last_selected_#{menu_name.downcase}_item"] = menu_item
    end
    menu_item
  end

  def get_menu_item_with_action(menu_name)
    menu=Admin::Menu.find_by_menu_name(menu_name)
    menu_items=menu ? menu.action_item(params) : []
    menu_items.empty? ? nil : Admin::MenuItem.get_deepest_item(menu_items)
  end
  
  def get_menu_editors(id,namespace,object,menu_id)
    if Admin::Menu.exists?(menu_id)
{'fraction_non_alphanumeric': 0.10065261044176707, 'fraction_numerical': 0.000502008032128514, 'mean_word_length': 4.128700128700129, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3936621', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1371, 'n_words': 200}