<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>db/migrate/002_add_pdf_title.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,21 +1,18 @@
-== ezFAQ plugin 0.1.0
+== ezFAQ plugin 0.1.9
 
 This is a FAQ management plugin for Redmine
 
 == Upgrade Note
 
-1. WARNING: ezFAQ 0.0.4 ONLY compitable with redmine after devel.r2429.
-   It's not compitable with stable versions(0.8.0 or 0.7.4)(for redmine has changed
-   it's attachment mechanism after 0.8.0)
+1. WARNING: ezFAQ 0.1.x ONLY compitable with redmine after devel.r2429.
    If you use redmine 0.8.0, please use ezfaq 0.0.2 at redmine's plugin wiki page.
 
-== Installation
+2. 0.1.9 has mailer errors!!!
 
-=== Adding plugin support to Redmine
+== Installation
 
 To add plugin support to Redmine, install engines plugin:
-   See: http://rails-engines.org/
-   Also: http://www.redmine.org/wiki/redmine/Plugins
+   See: http://www.redmine.org/wiki/redmine/Plugins
 
 === Plugin installation
 
@@ -30,6 +27,9 @@ Installed plugins are listed on 'Admin -&gt; Plugins' screen.
 
 === Changelog
 
+0.1.9 -&gt; Add export to PDF function to FAQ and FAQ-list.
+         This version has a mailer error, the mail function is disabled and will be corrected in 0.2.0.
+
 0.1.0 -&gt; Compitable with redmine devel after r2493 and rails 2.2.2
          Add cs.yml language.
 
@@ -43,7 +43,6 @@ Installed plugins are listed on 'Admin -&gt; Plugins' screen.
          attatchment manage mechanism.
          Change permission and menu into gloc strings and now they can be localized.
 
-
 === Feature
 
 1. Ask question and request a user to answer it.
@@ -51,6 +50,7 @@ Installed plugins are listed on 'Admin -&gt; Plugins' screen.
 3. FAQ's modification has history logs.
 4. Send notify email to the author and the assigned user who should answer the question.
 5. FAQ creation or edit is added to redmine's activity.
+6. FAQ and FAQ-list can be exported to PDF document.
 
 === Credits
 
@@ -62,12 +62,6 @@ Thanks for edavis10 at http://github.com/edavis10/ for his redmine core patch.
 cs.yml - Marek Hul&#225;n
 de.yml - Mathias K&#252;hn
 
-=== Roadmap
-
-0.2.0 -&gt; Generate pdf version FAQ document including all valid FAQ.
-         (note: maybe delayed, if you need this feature, please let know)
-
-
 === Contact info
 
 Homepage -&gt; http://218.107.133.32:5000/projects/show/ezwork powered by redmine</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -28,11 +28,17 @@ class EzfaqController &lt; ApplicationController
   include MessagesHelper
   helper :sort
   include SortHelper
+  include Redmine::Export::PDF
   
   def index
     @categorized_faqs = Faq.find(:all, :conditions =&gt; &quot;project_id = #{@project.id} and category_id is not null and is_valid = true&quot;)
     @not_categorized_faqs = Faq.find(:all, :conditions =&gt; &quot;project_id = #{@project.id} and category_id is null and is_valid = true&quot;, :order =&gt; &quot;question&quot;)
     @faq_setting = FaqSetting.find(:first, :conditions =&gt; &quot;project_id = #{@project.id}&quot;)
+
+    respond_to do |format|
+      format.html { render :template =&gt; 'ezfaq/index.html.erb', :layout =&gt; !request.xhr? }
+      format.pdf  { send_data(faqs_to_pdf, :type =&gt; 'application/pdf', :filename =&gt; &quot;#{@project}-faq.pdf&quot;) }
+    end
   end
   
   def list_invalid_faqs
@@ -46,8 +52,12 @@ class EzfaqController &lt; ApplicationController
   def show
     @faq.viewed_count += 1
     Faq.update_all(&quot;viewed_count = #{@faq.viewed_count}&quot;, &quot;id = #{@faq.id}&quot;)
-
     @faq_categories = FaqCategory.find(:all, :conditions =&gt; &quot;project_id = #{@project.id}&quot;, :order =&gt; &quot;position&quot;)
+
+    respond_to do |format|
+      format.html { render :template =&gt; 'ezfaq/show.html.erb', :layout =&gt; !request.xhr? }
+      format.pdf  { send_data(faq_to_pdf, :type =&gt; 'application/pdf', :filename =&gt; &quot;#{@project}-faq-#{@faq.id}.pdf&quot;) }
+    end
   end
   
   def new
@@ -66,7 +76,7 @@ class EzfaqController &lt; ApplicationController
       if @faq.save
         attach_files(@faq, params[:attachments])
         flash[:notice] = l(:notice_successful_create)
-        FaqMailer.deliver_faq_add(@project, @faq)
+        #FaqMailer.deliver_faq_add(@project, @faq)
         redirect_to :controller =&gt; 'ezfaq', :action =&gt; 'show', :id =&gt; @project, :faq_id =&gt; @faq
         return
       end		
@@ -88,7 +98,7 @@ class EzfaqController &lt; ApplicationController
       if @faq.save
         attach_files(@faq, params[:attachments])
         flash[:notice] = l(:notice_successful_update)
-        FaqMailer.deliver_faq_update(@project, @faq)
+        #FaqMailer.deliver_faq_update(@project, @faq)
         redirect_to :controller =&gt; 'ezfaq', :action =&gt; 'show', :id =&gt; @project, :faq_id =&gt; @faq
         return
       end
@@ -188,5 +198,95 @@ private
   rescue ActiveRecord::RecordNotFound
     render_404
   end
-  
+
+  def faq_to_pdf
+    faq_setting = FaqSetting.find(:first, :conditions =&gt; &quot;project_id = #{@project.id}&quot;)
+
+    pdf = IFPDF.new(current_language)
+    pdf.SetTitle(&quot;FAQ-#{@faq.question}&quot;)
+    pdf.SetAuthor('ezFAQ for Redmine')
+    pdf.AliasNbPages
+    pdf.footer_date = format_date(Date.today)
+    pdf.AddPage
+    
+    pdf.SetFontStyle('B',16)
+    pdf.Cell(200,5, faq_setting.pdf_title)
+    pdf.Ln(15)
+
+    pdf.SetFontStyle('B',11)
+    pdf.Cell(200,5, &quot;#{l(:field_question)}: #{@faq.question}&quot;)
+    pdf.Ln
+    pdf.Line(pdf.GetX, pdf.GetY, 180, pdf.GetY)
+    pdf.Ln
+    pdf.SetFontStyle('',11)
+    pdf.MultiCell(200,5, @faq.answer)
+    pdf.Ln
+
+    pdf.Line(pdf.GetX, pdf.GetY, 100, pdf.GetY)
+    pdf.SetFontStyle('I',8)
+    pdf.Cell(200,5, 'Auto generated faq-document by ezFAQ. Powered by ezWORK &amp; Redmine.')
+
+    pdf.Output
+  end
+
+  def faqs_to_pdf
+    pdf = IFPDF.new(current_language)
+    pdf.SetTitle(@faq_setting.pdf_title)
+    pdf.SetAuthor('ezFAQ for Redmine')
+    pdf.AliasNbPages
+    pdf.footer_date = format_date(Date.today)
+    pdf.AddPage
+
+    pdf.SetFontStyle('B',16)
+    pdf.Cell(200,5, @faq_setting.pdf_title)
+    pdf.Ln(10)
+    pdf.SetFontStyle('',11)
+    pdf.MultiCell(180,5, @faq_setting.note)
+    pdf.Ln
+    pdf.Line(pdf.GetX, pdf.GetY, 180, pdf.GetY)
+    pdf.Ln
+
+    list_number = 1
+    if @categorized_faqs.any?
+      @categorized_faqs.group_by(&amp;:category).sort.each do |category, faqs|
+        pdf.SetFontStyle('BI', 13)
+        pdf.Cell(200,5, &quot;#{list_number}. #{category.name}&quot;)
+        pdf.Ln
+        faq_number = 1
+        for faq in faqs.sort
+          pdf.SetFontStyle('B',11)
+          pdf.Cell(200,5, &quot;#{list_number}.#{faq_number} #{faq.question}&quot;)
+          pdf.Ln
+          pdf.SetFontStyle('',11)
+          pdf.MultiCell(200,5, faq.answer)
+          pdf.Ln
+          faq_number += 1
+        end
+        pdf.Ln
+        list_number += 1
+      end
+    end
+    
+    if @not_categorized_faqs.any?
+      pdf.SetFontStyle('BI', 13)
+      pdf.Cell(200,5, &quot;#{list_number}. #{l(:label_not_categorized)}&quot;)
+      pdf.Ln
+      faq_number = 1
+      for faq in @not_categorized_faqs.sort
+        pdf.SetFontStyle('B',11)
+        pdf.Cell(200,5, &quot;#{list_number}.#{faq_number} #{faq.question}&quot;)
+        pdf.Ln
+        pdf.SetFontStyle('',11)
+        pdf.MultiCell(200,5, faq.answer)
+        pdf.Ln(10)
+        faq_number += 1
+      end      
+    end
+
+    pdf.Line(pdf.GetX, pdf.GetY, 100, pdf.GetY)
+    pdf.SetFontStyle('I',8)
+    pdf.Cell(200,5, 'Auto generated faq-list by ezFAQ. Powered by ezWORK &amp; Redmine.')
+
+    pdf.Output
+  end
 end</diff>
      <filename>app/controllers/ezfaq_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,4 @@
 class FaqSetting &lt; ActiveRecord::Base
-  
-  
-  
+  validates_presence_of :pdf_title, :note
+  validates_length_of :pdf_title, :maximum =&gt; 200
 end</diff>
      <filename>app/models/faq_setting.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,11 @@
 &lt;h2&gt;&lt;%= l(:label_settings) %&gt;&lt;/h2&gt;
 
 &lt;div id=&quot;settings&quot;&gt;
-&lt;% form_for :faq_setting do |f| %&gt;
-&lt;div class=&quot;box tabular&quot;&gt;
-  &lt;p&gt;&lt;label&gt;&lt;%=l(:label_faq_note)%&gt;&lt;/label&gt;
-  &lt;%= f.text_area :note, :cols =&gt; 60, :rows =&gt; 4 %&gt;&lt;/p&gt;
+&lt;% labelled_tabular_form_for :faq_setting, @faq_setting, :url =&gt; {:id =&gt; @project}, :html =&gt; {:id =&gt; 'faq_setting-form'} do |f| %&gt;
+&lt;%= error_messages_for 'faq_setting' %&gt;
+&lt;div class=&quot;box&quot;&gt;
+  &lt;p&gt;&lt;%= f.text_field :pdf_title, :size =&gt;80, :required =&gt; true %&gt;&lt;/p&gt;
+  &lt;p&gt;&lt;%= f.text_area :note, :label =&gt; :field_faq_note,:cols =&gt; 80, :rows =&gt; 4, :required =&gt; true %&gt;&lt;/p&gt;
 &lt;/div&gt;
 &lt;%= submit_tag l(:button_save) %&gt;
 &lt;% end %&gt;</diff>
      <filename>app/views/ezfaq/faq_setting.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -24,6 +24,10 @@
   &lt;p class=&quot;nodata&quot;&gt;&lt;%= l(:label_no_data) %&gt;&lt;/p&gt;
 &lt;% end %&gt;
 
+&lt;% other_formats_links do |f| %&gt;
+    &lt;%= f.link_to 'PDF' %&gt;
+&lt;% end %&gt;
+
 &lt;% content_for :sidebar do %&gt;
     &lt;%= render :partial =&gt; 'ezfaq/sidebar' %&gt;
 &lt;% end %&gt;</diff>
      <filename>app/views/ezfaq/index.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -53,6 +53,10 @@
 
 &lt;/div&gt;
 
+&lt;% other_formats_links do |f| %&gt;
+    &lt;%= f.link_to 'PDF', :url =&gt; {:faq_id =&gt; @faq} %&gt;
+&lt;% end %&gt;
+
 &lt;% content_for :sidebar do %&gt;
     &lt;%= render :partial =&gt; 'ezfaq/sidebar' %&gt;
 &lt;% end %&gt;</diff>
      <filename>app/views/ezfaq/show.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -16,7 +16,6 @@ cs:
   label_info_for_input_id: (Pros&#237;m vypl&#328;te id)
   label_manage: Spravovat
   label_faq_setting: Nastaven&#237; FAQ
-  label_faq_note: FAQ pozn&#225;mka(Zobrazeno p&#345;ed seznamem FAQ)
   label_updated_time_by: Upraveno u&#382;ivatelem {{author}} p&#345;ed {{age}}
 
   field_question: Ot&#225;zka
@@ -28,6 +27,8 @@ cs:
   field_related_message: Souvisej&#237;c&#237; zpr&#225;va
   field_is_valid: Validn&#237;
   field_faq_counts_under_category: Po&#269;et FAQ
+  field_pdf_title: Title of PDF document
+  field_faq_note: FAQ pozn&#225;mka(Zobrazeno p&#345;ed seznamem FAQ)
 
   text_faq_category_destroy_question: N&#283;jak&#233; FAQ ({{value}}) je ji&#382; p&#345;i&#345;azeno do t&#233;to kategorie. Co chcete ud&#283;lat?
   text_faq_category_destroy_assignments: Odstranit p&#345;i&#345;azen&#237; kategorie</diff>
      <filename>config/locales/cs.yml</filename>
    </modified>
    <modified>
      <diff>@@ -16,7 +16,6 @@ de:
   label_info_for_input_id: (Bitte id eingeben)
   label_manage: Verwalten
   label_faq_setting: FAQ Einstellungen
-  label_faq_note: FAQ note(Displayed before the FAQ list)
   label_updated_time_by: Updated by {{author}} {{age}} ago
 
   field_question: Frage
@@ -28,7 +27,9 @@ de:
   field_related_message: Verwandte Nachricht
   field_is_valid: G&#252;ltig
   field_faq_counts_under_category: FAQ Anzahl
-
+  field_pdf_title: Title of PDF document
+  field_faq_note: FAQ note(Displayed before the FAQ list)
+  
   text_faq_category_destroy_question: Manche FAQs ({{value}}) sind dieser Kategorie zugeordnet. Was m&#246;chten Sie tun?
   text_faq_category_destroy_assignments: Entferne die Zuordnungen
   text_faq_category_reassign_to: FAQ wieder dieser Kategorie zuordnen</diff>
      <filename>config/locales/de.yml</filename>
    </modified>
    <modified>
      <diff>@@ -16,7 +16,6 @@ en:
   label_info_for_input_id: (Please input id)
   label_manage: Manage
   label_faq_setting: FAQ setting
-  label_faq_note: FAQ note(Displayed before the FAQ list)
   label_updated_time_by: Updated by {{author}} {{age}} ago
 
   field_question: Question
@@ -28,6 +27,8 @@ en:
   field_related_message: Related Message
   field_is_valid: Valid
   field_faq_counts_under_category: FAQ count
+  field_pdf_title: Title of PDF document
+  field_faq_note: FAQ note(Displayed before the FAQ list)
 
   text_faq_category_destroy_question: Some FAQ ({{value}}) is assigned to this category. What do you want to do ?
   text_faq_category_destroy_assignments: Remove category assignments</diff>
      <filename>config/locales/en.yml</filename>
    </modified>
    <modified>
      <diff>@@ -16,7 +16,6 @@ zh:
   label_info_for_input_id: (&#35831;&#36755;&#20837;&#32534;&#21495;)
   label_manage: &#31649;&#29702;
   label_faq_setting: FAQ&#37197;&#32622;
-  label_faq_note: FAQ&#35828;&#26126;(&#26174;&#31034;&#22312;FAQ&#21015;&#34920;&#21069;)
   label_updated_time_by: &#30001; {{author}} &#22312; {{age}} &#20043;&#21069;&#26356;&#26032;
 
   field_question: &#38382;&#39064;
@@ -28,6 +27,8 @@ zh:
   field_related_message: &#30456;&#20851;&#35752;&#35770;&#21306;&#24086;&#23376;
   field_is_valid: &#26159;&#21542;&#26377;&#25928;
   field_faq_counts_under_category: FAQ&#25968;&#37327;
+  field_pdf_title: PDF&#25991;&#26723;&#30340;&#26631;&#39064;
+  field_faq_note: FAQ&#35828;&#26126;(&#26174;&#31034;&#22312;FAQ&#21015;&#34920;&#21069;)
 
   text_faq_category_destroy_question: &#26377;&#19968;&#20123;FAQ&#65288;{{value}} &#20010;&#65289;&#23646;&#20110;&#27492;&#31867;&#21035;&#12290;&#24744;&#24819;&#36827;&#34892;&#21738;&#31181;&#25805;&#20316;&#65311;
   text_faq_category_destroy_assignments: &#21024;&#38500;FAQ&#30340;&#25152;&#23646;&#31867;&#21035;&#65288;FAQ&#21464;&#20026;&#26080;&#31867;&#21035;&#65289;</diff>
      <filename>config/locales/zh.yml</filename>
    </modified>
    <modified>
      <diff>@@ -26,7 +26,7 @@ Redmine::Plugin.register :ezfaq_plugin do
   name 'ezFAQ plugin'
   author 'Zou Chaoqun'
   description 'This is a FAQ management plugin for Redmine'
-  version '0.1.0'
+  version '0.1.9'
 
   project_module :ezfaq do
     permission :view_faqs, {:ezfaq =&gt; [:index, :show, :history, :diff, :show_history_version]}, :public =&gt; true</diff>
      <filename>init.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>81bc65ec62fffcbabb9d24958bd875e04ea06b52</id>
    </parent>
  </parents>
  <author>
    <name>zouchaoqun</name>
    <email>zouchaoqun@gmail.com</email>
  </author>
  <url>http://github.com/zouchaoqun/ezfaq/commit/a08d476dd98f4599e6b76e265f69a419d164ade0</url>
  <id>a08d476dd98f4599e6b76e265f69a419d164ade0</id>
  <committed-date>2009-02-28T22:11:12-08:00</committed-date>
  <authored-date>2009-02-28T22:11:12-08:00</authored-date>
  <message>add export to pdf function;still waiting for mailer correction</message>
  <tree>a49fc451ab70e0feb989307d3365df36f48cae7f</tree>
  <committer>
    <name>zouchaoqun</name>
    <email>zouchaoqun@gmail.com</email>
  </committer>
</commit>
