70 |
70 |
|
71 |
71 |
def render_menu(menu, project=nil)
|
72 |
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 |
82 |
Redmine::MenuManager.allowed_items(menu, User.current, project).each do |item|
|
74 |
83 |
unless item.condition && !item.condition.call(project)
|
75 |
84 |
url = case item.url
|
... | ... | |
82 |
91 |
end
|
83 |
92 |
caption = item.caption(project)
|
84 |
93 |
caption = l(caption) if caption.is_a?(Symbol)
|
85 |
|
links << content_tag('li',
|
86 |
|
link_to(h(caption), url, (current_menu_item == item.name ? item.html_options.merge(:class => 'selected') : item.html_options)))
|
|
94 |
if block_given?
|
|
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 |
99 |
end
|
88 |
100 |
end
|
89 |
|
links.empty? ? nil : content_tag('ul', links.join("\n"))
|
|
101 |
return block_given? ? nil : items
|
90 |
102 |
end
|
91 |
103 |
end
|
92 |
104 |
|