##// END OF EJS Templates
Pluggable admin menu (patch #2031 by Yuki Sonoda with slight changes)....
Jean-Philippe Lang -
r2020:d7718470785c
parent child
Show More
@@ -34,6 +34,12
34 <%= link_to l(:label_settings), :controller => 'settings' %>
34 <%= link_to l(:label_settings), :controller => 'settings' %>
35 </p>
35 </p>
36
36
37 <% menu_items_for(:admin_menu) do |item, caption, url, selected| -%>
38 <%= content_tag 'p',
39 link_to(h(caption), item.url, item.html_options),
40 :class => ["icon22", "icon22-#{item.name}"].join(' ') %>
41 <% end -%>
42
37 <p class="icon22 icon22-info">
43 <p class="icon22 icon22-info">
38 <%= link_to l(:label_information_plural), :controller => 'admin', :action => 'info' %>
44 <%= link_to l(:label_information_plural), :controller => 'admin', :action => 'info' %>
39 </p>
45 </p>
@@ -124,6 +124,10 Redmine::MenuManager.map :application_menu do |menu|
124 # Empty
124 # Empty
125 end
125 end
126
126
127 Redmine::MenuManager.map :admin_menu do |menu|
128 # Empty
129 end
130
127 Redmine::MenuManager.map :project_menu do |menu|
131 Redmine::MenuManager.map :project_menu do |menu|
128 menu.push :overview, { :controller => 'projects', :action => 'show' }
132 menu.push :overview, { :controller => 'projects', :action => 'show' }
129 menu.push :activity, { :controller => 'projects', :action => 'activity' }
133 menu.push :activity, { :controller => 'projects', :action => 'activity' }
@@ -70,6 +70,15 module Redmine
70
70
71 def render_menu(menu, project=nil)
71 def render_menu(menu, project=nil)
72 links = []
72 links = []
73 menu_items_for(menu, project) do |item, caption, url, selected|
74 links << content_tag('li',
75 link_to(h(caption), url, (selected ? item.html_options.merge(:class => 'selected') : item.html_options)))
76 end
77 links.empty? ? nil : content_tag('ul', links.join("\n"))
78 end
79
80 def menu_items_for(menu, project=nil)
81 items = []
73 Redmine::MenuManager.allowed_items(menu, User.current, project).each do |item|
82 Redmine::MenuManager.allowed_items(menu, User.current, project).each do |item|
74 unless item.condition && !item.condition.call(project)
83 unless item.condition && !item.condition.call(project)
75 url = case item.url
84 url = case item.url
@@ -82,11 +91,14 module Redmine
82 end
91 end
83 caption = item.caption(project)
92 caption = item.caption(project)
84 caption = l(caption) if caption.is_a?(Symbol)
93 caption = l(caption) if caption.is_a?(Symbol)
85 links << content_tag('li',
94 if block_given?
86 link_to(h(caption), url, (current_menu_item == item.name ? item.html_options.merge(:class => 'selected') : item.html_options)))
95 yield item, caption, url, (current_menu_item == item.name)
96 else
97 items << [item, caption, url, (current_menu_item == item.name)]
98 end
87 end
99 end
88 end
100 end
89 links.empty? ? nil : content_tag('ul', links.join("\n"))
101 return block_given? ? nil : items
90 end
102 end
91 end
103 end
92
104
General Comments 0
You need to be logged in to leave comments. Login now