Defect #4787 » user-pref-r8745.patch
| app/controllers/gantts_controller.rb | ||
|---|---|---|
|
basename = (@project ? "#{@project.identifier}-" : '') + 'gantt'
|
||
|
@rmagick_font = params[:rmagick_font] || User.current.pref[:rmagick_font]
|
||
|
if User.current.logged? && !@rmagick_font.blank? &&
|
||
|
( @rmagick_font != User.current.pref[:rmagick_font] )
|
||
|
User.current.pref[:rmagick_font] = @rmagick_font
|
||
|
User.current.preference.save
|
||
|
end
|
||
|
respond_to do |format|
|
||
|
format.html { render :action => "show", :layout => !request.xhr? }
|
||
|
format.png { send_data(@gantt.to_image, :disposition => 'inline', :type => 'image/png', :filename => "#{basename}.png") } if @gantt.respond_to?('to_image')
|
||
|
if @gantt.respond_to?('to_image')
|
||
|
format.png do
|
||
|
send_data(@gantt.to_image('PNG', @rmagick_font), :disposition => 'inline',
|
||
|
:type => 'image/png', :filename => "#{basename}.png")
|
||
|
end
|
||
|
end
|
||
|
format.pdf { send_data(@gantt.to_pdf, :type => 'application/pdf', :filename => "#{basename}.pdf") }
|
||
|
end
|
||
|
end
|
||
| app/views/gantts/show.html.erb | ||
|---|---|---|
|
</tr>
|
||
|
</table>
|
||
|
<% if @gantt.respond_to?('to_image') %>
|
||
|
<% form_tag(params.merge({'format'=>'PNG'}).merge(@gantt.params), :method => 'get') do %>
|
||
|
<label>TODO: PNG font</label>
|
||
|
<%= select_tag 'rmagick_font',
|
||
|
options_for_select(
|
||
|
Magick.fonts.collect {|t| [t.name, CGI.escape(t.name)]},
|
||
|
@rmagick_font
|
||
|
) %>
|
||
|
<%= submit_tag 'OK' %>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
|
<% other_formats_links do |f| %>
|
||
|
<%= f.link_to 'PDF', :url => params.merge(@gantt.params) %>
|
||
|
<%= f.link_to('PNG', :url => params.merge(@gantt.params)) if @gantt.respond_to?('to_image') %>
|
||
|
<% end %>
|
||
|
<% end # query.valid? %>
|
||
| lib/redmine/helpers/gantt.rb | ||
|---|---|---|
|
# Generates a gantt image
|
||
|
# Only defined if RMagick is avalaible
|
||
|
def to_image(format='PNG')
|
||
|
def to_image(format='PNG', rmagick_font=nil)
|
||
|
date_to = (@date_from >> @months)-1
|
||
|
show_weeks = @zoom > 1
|
||
|
show_days = @zoom > 2
|
||
| ... | ... | |
|
imgl = Magick::ImageList.new
|
||
|
imgl.new_image(subject_width+g_width+1, height)
|
||
|
gc = Magick::Draw.new
|
||
|
gc.font = CGI.unescape(rmagick_font) unless rmagick_font.blank?
|
||
|
# Subjects
|
||
|
gc.stroke('transparent')
|
||