Adds plugin id attribute.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2038 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2008-11-16 15:22:48 +00:00
parent 94b5bbcb5d
commit 97252c26ee
3 changed files with 20 additions and 11 deletions

View File

@ -50,7 +50,7 @@ class AdminController < ApplicationController
end end
def plugins def plugins
@plugins = Redmine::Plugin.registered_plugins @plugins = Redmine::Plugin.registered_plugins.values.sort
end end
# Loads the default configuration # Loads the default configuration

View File

@ -2,13 +2,13 @@
<% if @plugins.any? %> <% if @plugins.any? %>
<table class="list"> <table class="list">
<% @plugins.keys.sort {|x,y| x.to_s <=> y.to_s}.each do |plugin| %> <% @plugins.each do |plugin| %>
<tr class="<%= cycle('odd', 'even') %>"> <tr class="<%= cycle('odd', 'even') %>">
<td><%=h @plugins[plugin].name %></td> <td><%=h plugin.name %></td>
<td><%=h @plugins[plugin].description %></td> <td><%=h plugin.description %></td>
<td><%=h @plugins[plugin].author %></td> <td><%=h plugin.author %></td>
<td><%=h @plugins[plugin].version %></td> <td><%=h plugin.version %></td>
<td><%= link_to(l(:button_configure), :controller => 'settings', :action => 'plugin', :id => plugin.to_s) if @plugins[plugin].configurable? %></td> <td><%= link_to(l(:button_configure), :controller => 'settings', :action => 'plugin', :id => plugin.id) if plugin.configurable? %></td>
</tr> </tr>
<% end %> <% end %>
</table> </table>

View File

@ -56,12 +56,21 @@ module Redmine #:nodoc:
end end
end end
def_field :name, :description, :author, :version, :settings def_field :name, :description, :author, :version, :settings
attr_reader :id
# Plugin constructor # Plugin constructor
def self.register(name, &block) def self.register(id, &block)
p = new p = new(id)
p.instance_eval(&block) p.instance_eval(&block)
Plugin.registered_plugins[name] = p Plugin.registered_plugins[id] = p
end
def initialize(id)
@id = id.to_sym
end
def <=>(plugin)
self.id.to_s <=> plugin.id.to_s
end end
# Adds an item to the given +menu+. # Adds an item to the given +menu+.