From 97252c26eefe3dfa5e0c3cb059fe66cb21b2e34d Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 16 Nov 2008 15:22:48 +0000 Subject: [PATCH] Adds plugin id attribute. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2038 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/admin_controller.rb | 2 +- app/views/admin/plugins.rhtml | 12 ++++++------ lib/redmine/plugin.rb | 17 +++++++++++++---- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 90ec59098..119e2b922 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -50,7 +50,7 @@ class AdminController < ApplicationController end def plugins - @plugins = Redmine::Plugin.registered_plugins + @plugins = Redmine::Plugin.registered_plugins.values.sort end # Loads the default configuration diff --git a/app/views/admin/plugins.rhtml b/app/views/admin/plugins.rhtml index 5a208fe02..9cabd42ae 100644 --- a/app/views/admin/plugins.rhtml +++ b/app/views/admin/plugins.rhtml @@ -2,13 +2,13 @@ <% if @plugins.any? %> - <% @plugins.keys.sort {|x,y| x.to_s <=> y.to_s}.each do |plugin| %> + <% @plugins.each do |plugin| %> - - - - - + + + + + <% end %>
<%=h @plugins[plugin].name %><%=h @plugins[plugin].description %><%=h @plugins[plugin].author %><%=h @plugins[plugin].version %><%= link_to(l(:button_configure), :controller => 'settings', :action => 'plugin', :id => plugin.to_s) if @plugins[plugin].configurable? %><%=h plugin.name %><%=h plugin.description %><%=h plugin.author %><%=h plugin.version %><%= link_to(l(:button_configure), :controller => 'settings', :action => 'plugin', :id => plugin.id) if plugin.configurable? %>
diff --git a/lib/redmine/plugin.rb b/lib/redmine/plugin.rb index 87a6ce4d3..17953ef8c 100644 --- a/lib/redmine/plugin.rb +++ b/lib/redmine/plugin.rb @@ -56,12 +56,21 @@ module Redmine #:nodoc: end end def_field :name, :description, :author, :version, :settings - + attr_reader :id + # Plugin constructor - def self.register(name, &block) - p = new + def self.register(id, &block) + p = new(id) 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 # Adds an item to the given +menu+.