]> source.dussan.org Git - redmine.git/commitdiff
Pluggable admin menu (patch #2031 by Yuki Sonoda with slight changes).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 11 Nov 2008 18:10:21 +0000 (18:10 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 11 Nov 2008 18:10:21 +0000 (18:10 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2022 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/views/admin/index.rhtml
lib/redmine.rb
lib/redmine/menu_manager.rb

index 438f72a305366d4243507ce67bfd001d6b80266f..e2d1607307811c648d8d6db90fce64fae9d734f5 100644 (file)
 <%= link_to l(:label_settings), :controller => 'settings' %>
 </p>
 
+<% menu_items_for(:admin_menu) do |item, caption, url, selected| -%>
+  <%= content_tag 'p', 
+    link_to(h(caption), item.url, item.html_options),
+    :class => ["icon22", "icon22-#{item.name}"].join(' ') %>
+<% end -%>
+
 <p class="icon22 icon22-info">
 <%= link_to l(:label_information_plural), :controller => 'admin', :action => 'info' %>
 </p>
index 19f0854e2826f81d6c2b7fcaf42c62ea62b0b368..45cfcbddf4f8208815cc3a58a334efc5e48b041a 100644 (file)
@@ -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' }
index 730097d745692fe5ad7e451e4bb703d308de8f6c..b09e5150a13322d5830628fba5b2132c261cfc8c 100644 (file)
@@ -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