Project

General

Profile

Patch #2031 ยป pluggable-admin-menu.patch

Yuki Sonoda, 2008-10-14 14:46

View differences:

app/views/admin/index.rhtml
38 38
<%= link_to l(:label_information_plural), :controller => 'admin', :action => 'info' %>
39 39
</p>
40 40

  
41
<% menu_items_for(:admin) do |item, caption, url, selected| -%>
42
  <%= content_tag 'p', 
43
    link_to(h(caption), item.url, item.html_options),
44
    :class => ["icon22", "icon22-#{item.name}"].join(' ') %>
45
<% end -%>
46

  
41 47
<% html_title(l(:label_administration)) -%>
lib/redmine/menu_manager.rb
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
    
    (1-1/1)