From d7718470785c67aaede689a3651dfe2b2fd53bfb Mon Sep 17 00:00:00 2001
From: Jean-Philippe Lang
<%= link_to l(:label_information_plural), :controller => 'admin', :action => 'info' %>
diff --git a/lib/redmine.rb b/lib/redmine.rb index 19f0854e2..45cfcbddf 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -124,6 +124,10 @@ Redmine::MenuManager.map :application_menu do |menu| # Empty end +Redmine::MenuManager.map :admin_menu do |menu| + # Empty +end + Redmine::MenuManager.map :project_menu do |menu| menu.push :overview, { :controller => 'projects', :action => 'show' } menu.push :activity, { :controller => 'projects', :action => 'activity' } diff --git a/lib/redmine/menu_manager.rb b/lib/redmine/menu_manager.rb index 730097d74..b09e5150a 100644 --- a/lib/redmine/menu_manager.rb +++ b/lib/redmine/menu_manager.rb @@ -70,6 +70,15 @@ module Redmine def render_menu(menu, project=nil) links = [] + menu_items_for(menu, project) do |item, caption, url, selected| + links << content_tag('li', + link_to(h(caption), url, (selected ? item.html_options.merge(:class => 'selected') : item.html_options))) + end + links.empty? ? nil : content_tag('ul', links.join("\n")) + end + + def menu_items_for(menu, project=nil) + items = [] Redmine::MenuManager.allowed_items(menu, User.current, project).each do |item| unless item.condition && !item.condition.call(project) url = case item.url @@ -82,11 +91,14 @@ module Redmine end caption = item.caption(project) caption = l(caption) if caption.is_a?(Symbol) - links << content_tag('li', - link_to(h(caption), url, (current_menu_item == item.name ? item.html_options.merge(:class => 'selected') : item.html_options))) + if block_given? + yield item, caption, url, (current_menu_item == item.name) + else + items << [item, caption, url, (current_menu_item == item.name)] + end end end - links.empty? ? nil : content_tag('ul', links.join("\n")) + return block_given? ? nil : items end end -- 2.39.5