fix the projects controller

pull/1186/head
Martin Linkhorst 12 years ago
parent 2342055ee2
commit abac91335c
  1. 34
      app/views/projects/show.html.erb
  2. 39
      lib/redmine/hook.rb

@ -8,21 +8,25 @@
<% breadcrumb_paths(l(:label_overview)) %>
<div class="splitcontentleft">
<div class="wiki">
<%= textilizable @project.description %>
</div>
<ul>
<% unless @project.homepage.blank? %><li><%=l(:field_homepage)%>: <%= auto_link(h(@project.homepage)) %></li><% end %>
<% if @subprojects.any? %>
<li><%=l(:label_subproject_plural)%>:
<%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join(", ") %></li>
<% end %>
<% @project.visible_custom_field_values.each do |custom_value| %>
<% if !custom_value.value.blank? %>
<li><%= h(custom_value.custom_field.name) %>: <%=h show_value(custom_value) %></li>
<% end %>
<% end %>
</ul>
<div class="wiki">
<%= textilizable @project.description %>
</div>
<ul>
<% if @project.homepage.present? %>
<li><%= l(:field_homepage) %>: <%=raw auto_link(@project.homepage) %></li>
<% end %>
<% if @subprojects.any? %>
<li>
<%= l(:label_subproject_plural) %>:
<%=raw @subprojects.map { |project| link_to(project.name, project) }.to_sentence %>
</li>
<% end %>
<% @project.visible_custom_field_values.each do |custom_value| %>
<% if custom_value.value.present? %>
<li><%= custom_value.custom_field.name %>: <%= show_value(custom_value) %></li>
<% end %>
<% end %>
</ul>
<% if User.current.allowed_to?(:view_issues, @project) %>
<div class="issues box">

@ -3,6 +3,7 @@
# ChiliProject is a project management system.
#
# Copyright (C) 2010-2011 the ChiliProject Team
# Copyright (C) 2006-2012 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -14,8 +15,6 @@
module Redmine
module Hook
include ActionController::UrlWriter
@@listener_classes = []
@@listeners = nil
@@hook_listeners = {}
@ -85,12 +84,11 @@ module Redmine
include ActionView::Helpers::FormTagHelper
include ActionView::Helpers::FormOptionsHelper
include ActionView::Helpers::JavaScriptHelper
include ActionView::Helpers::PrototypeHelper
include ActionView::Helpers::NumberHelper
include ActionView::Helpers::UrlHelper
include ActionView::Helpers::AssetTagHelper
include ActionView::Helpers::TextHelper
include ActionController::UrlWriter
include Rails.application.routes.url_helpers
include ApplicationHelper
# Default to creating links using only the path. Subclasses can
@ -107,22 +105,36 @@ module Redmine
#
def self.render_on(hook, options={})
define_method hook do |context|
context[:controller].send(:render_to_string, {:locals => context}.merge(options))
if context[:hook_caller].respond_to?(:render)
context[:hook_caller].send(:render, {:locals => context}.merge(options))
elsif context[:controller].is_a?(ActionController::Base)
context[:controller].send(:render_to_string, {:locals => context}.merge(options))
else
raise "Cannot render #{self.name} hook from #{context[:hook_caller].class.name}"
end
end
end
def controller
nil
end
def config
ActionController::Base.config
end
end
# Helper module included in ApplicationHelper and ActionControllerso that
# Helper module included in ApplicationHelper and ActionController so that
# hooks can be called in views like this:
#
# <%= call_hook(:some_hook) %>
# <%= call_hook(:another_hook, :foo => 'bar' %>
# <%= call_hook(:another_hook, :foo => 'bar') %>
#
# Or in controllers like:
# call_hook(:some_hook)
# call_hook(:another_hook, :foo => 'bar'
# call_hook(:another_hook, :foo => 'bar')
#
# Hooks added to views will be concatenated into a string. Hooks added to
# Hooks added to views will be concatenated into a string. Hooks added to
# controllers will return an array of results.
#
# Several objects are automatically added to the call context:
@ -130,15 +142,18 @@ module Redmine
# * project => current project
# * request => Request instance
# * controller => current Controller instance
# * hook_caller => object that called the hook
#
module Helper
def call_hook(hook, context={})
if is_a?(ActionController::Base)
default_context = {:controller => self, :project => @project, :request => request}
default_context = {:controller => self, :project => @project, :request => request, :hook_caller => self}
Redmine::Hook.call_hook(hook, default_context.merge(context))
else
default_context = {:controller => controller, :project => @project, :request => request}
Redmine::Hook.call_hook(hook, default_context.merge(context)).join(' ')
default_context = { :project => @project, :hook_caller => self }
default_context[:controller] = controller if respond_to?(:controller)
default_context[:request] = request if respond_to?(:request)
Redmine::Hook.call_hook(hook, default_context.merge(context)).join(' ').html_safe
end
end
end

Loading…
Cancel
Save