@@ -1,85 +1,85 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require 'iconv' |
|
19 | 19 | require 'rfpdf/chinese' |
|
20 | 20 | |
|
21 | 21 | module IfpdfHelper |
|
22 | 22 | |
|
23 | 23 | class IFPDF < FPDF |
|
24 | 24 | include GLoc |
|
25 | 25 | attr_accessor :footer_date |
|
26 | 26 | |
|
27 | 27 | def initialize(lang) |
|
28 | 28 | super() |
|
29 | 29 | set_language_if_valid lang |
|
30 | 30 | case current_language.to_s |
|
31 | 31 | when 'ja' |
|
32 | 32 | extend(PDF_Japanese) |
|
33 | 33 | AddSJISFont() |
|
34 | 34 | @font_for_content = 'SJIS' |
|
35 | 35 | @font_for_footer = 'SJIS' |
|
36 | 36 | when 'zh' |
|
37 | 37 | extend(PDF_Chinese) |
|
38 | 38 | AddGBFont() |
|
39 | 39 | @font_for_content = 'GB' |
|
40 | 40 | @font_for_footer = 'GB' |
|
41 | 41 | when 'zh-tw' |
|
42 | 42 | extend(PDF_Chinese) |
|
43 | 43 | AddBig5Font() |
|
44 | 44 | @font_for_content = 'Big5' |
|
45 | 45 | @font_for_footer = 'Big5' |
|
46 | 46 | else |
|
47 | 47 | @font_for_content = 'Arial' |
|
48 | 48 | @font_for_footer = 'Helvetica' |
|
49 | 49 | end |
|
50 |
SetCreator( |
|
|
50 | SetCreator(Redmine::Info.app_name) | |
|
51 | 51 | SetFont(@font_for_content) |
|
52 | 52 | end |
|
53 | 53 | |
|
54 | 54 | def SetFontStyle(style, size) |
|
55 | 55 | SetFont(@font_for_content, style, size) |
|
56 | 56 | end |
|
57 | 57 | |
|
58 | 58 | def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='') |
|
59 | 59 | @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8') |
|
60 | 60 | # these quotation marks are not correctly rendered in the pdf |
|
61 | 61 | txt = txt.gsub(/[“”]/, '"') if txt |
|
62 | 62 | txt = begin |
|
63 | 63 | # 0x5c char handling |
|
64 | 64 | txtar = txt.split('\\') |
|
65 | 65 | txtar << '' if txt[-1] == ?\\ |
|
66 | 66 | txtar.collect {|x| @ic.iconv(x)}.join('\\').gsub(/\\/, "\\\\\\\\") |
|
67 | 67 | rescue |
|
68 | 68 | txt |
|
69 | 69 | end || '' |
|
70 | 70 | super w,h,txt,border,ln,align,fill,link |
|
71 | 71 | end |
|
72 | 72 | |
|
73 | 73 | def Footer |
|
74 | 74 | SetFont(@font_for_footer, 'I', 8) |
|
75 | 75 | SetY(-15) |
|
76 | 76 | SetX(15) |
|
77 | 77 | Cell(0, 5, @footer_date, 0, 0, 'L') |
|
78 | 78 | SetY(-15) |
|
79 | 79 | SetX(-30) |
|
80 | 80 | Cell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C') |
|
81 | 81 | end |
|
82 | 82 | |
|
83 | 83 | end |
|
84 | 84 | |
|
85 | 85 | end |
@@ -1,31 +1,31 | |||
|
1 | 1 | xml.instruct! |
|
2 | 2 | xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do |
|
3 | 3 | xml.title truncate_single_line(@title, 100) |
|
4 | 4 | xml.link "rel" => "self", "href" => url_for(params.merge({:format => nil, :only_path => false})) |
|
5 | 5 | xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false) |
|
6 | 6 | xml.id url_for(:controller => 'welcome', :only_path => false) |
|
7 | 7 | xml.updated((@items.first ? @items.first.event_datetime : Time.now).xmlschema) |
|
8 | 8 | xml.author { xml.name "#{Setting.app_title}" } |
|
9 |
xml.generator(:uri => Redmine::Info.url |
|
|
9 | xml.generator(:uri => Redmine::Info.url) { xml.text! Redmine::Info.app_name; } | |
|
10 | 10 | @items.each do |item| |
|
11 | 11 | xml.entry do |
|
12 | 12 | url = url_for(item.event_url(:only_path => false)) |
|
13 | 13 | if @project |
|
14 | 14 | xml.title truncate_single_line(item.event_title, 100) |
|
15 | 15 | else |
|
16 | 16 | xml.title truncate_single_line("#{item.project} - #{item.event_title}", 100) |
|
17 | 17 | end |
|
18 | 18 | xml.link "rel" => "alternate", "href" => url |
|
19 | 19 | xml.id url |
|
20 | 20 | xml.updated item.event_datetime.xmlschema |
|
21 | 21 | author = item.event_author if item.respond_to?(:event_author) |
|
22 | 22 | xml.author do |
|
23 | 23 | xml.name(author) |
|
24 | 24 | xml.email(author.mail) if author.respond_to?(:mail) && !author.mail.blank? |
|
25 | 25 | end if author |
|
26 | 26 | xml.content "type" => "html" do |
|
27 | 27 | xml.text! textilizable(item.event_description) |
|
28 | 28 | end |
|
29 | 29 | end |
|
30 | 30 | end |
|
31 | 31 | end |
General Comments 0
You need to be logged in to leave comments.
Login now