Пример #1
0
 /**
  * Builds the PDF delivery for the given faq.
  *
  * @param array  $faqData
  * @param string $filename
  *
  * @return string
  */
 public function generateFile(array $faqData, $filename = null)
 {
     global $PMF_LANG;
     // Default filename: FAQ-<id>-<language>.pdf
     if (empty($filename)) {
         $filename = 'FAQ-' . $faqData['id'] . '-' . $faqData['lang'] . '.pdf';
     }
     $this->pdf->setFaq($faqData);
     $this->pdf->setCategory($faqData['category_id']);
     $this->pdf->setQuestion($faqData['title']);
     $this->pdf->setCategories($this->category->categoryName);
     // Set any item
     $this->pdf->SetTitle($faqData['title']);
     $this->pdf->SetCreator($this->_config->get('main.titleFAQ') . ' - powered by phpMyFAQ ' . $this->_config->get('main.currentVersion'));
     $this->pdf->AddPage();
     $this->pdf->SetFont($this->pdf->getCurrentFont(), '', 12);
     $this->pdf->SetDisplayMode('real');
     $this->pdf->Ln();
     $this->pdf->WriteHTML('<h1 align="center">' . $faqData['title'] . '</h1>', true);
     $this->pdf->Ln();
     $this->pdf->Ln();
     $this->pdf->WriteHTML(str_replace('../', '', $faqData['content']), true);
     $this->pdf->Ln();
     $this->pdf->Ln();
     $this->pdf->SetFont($this->pdf->getCurrentFont(), '', 11);
     $this->pdf->Write(5, $PMF_LANG['ad_entry_solution_id'] . ': #' . $faqData['solution_id']);
     $this->pdf->SetAuthor($faqData['author']);
     $this->pdf->Ln();
     $this->pdf->Write(5, $PMF_LANG['msgAuthor'] . ': ' . $faqData['author']);
     $this->pdf->Ln();
     $this->pdf->Write(5, $PMF_LANG['msgLastUpdateArticle'] . $faqData['date']);
     return $this->pdf->Output($filename);
 }
Пример #2
0
 /**
  * Generates the export
  * 
  * @param integer $categoryId Category Id
  * @param boolean $downwards  If true, downwards, otherwise upward ordering
  * @param string  $language   Language
  * 
  * @return string
  */
 public function generate($categoryId = 0, $downwards = true, $language = '')
 {
     // Initialize categories
     $this->category->transform($categoryId);
     $faqdata = $this->faq->get(FAQ_QUERY_TYPE_EXPORT_XML, $categoryId, $downwards, $language);
     if (count($faqdata)) {
         $categories = $questions = $answers = $authors = $dates = array();
         $i = 0;
         foreach ($faqdata as $data) {
             $categories[$i] = $data['category_id'];
             $questions[$i] = $data['topic'];
             $answers[$i] = $data['content'];
             $authors[$i] = $data['author_name'];
             $dates[$i] = $data['lastmodified'];
             $i++;
         }
         // Create the PDF
         foreach ($answers as $key => $value) {
             $this->pdf->setCategory($categories[$key]);
             $this->pdf->setQuestion($questions[$key]);
             $this->pdf->setCategories($this->category->categoryName);
             $this->pdf->AddPage();
             $this->pdf->SetFont('arialunicid0', '', 12);
             $this->pdf->WriteHTML($value);
         }
     }
     return $this->pdf->Output('', 'S');
 }
Пример #3
0
 /**
  * Builds the PDF delivery for the given faq.
  * 
  * @param  integer $currentCategory The category under which we want the PDF to be created.
  * @param  string  $pdfFile         The path to the PDF file. Optional, default: pdf/<faq_id>.pdf.
  * @return mixed
  */
 public function buildPDFFile($currentCategory, $pdfFile = null)
 {
     global $PMF_LANG;
     // Sanity check: stop here if getRecord() has not been called yet
     if (empty($this->faqRecord)) {
         return false;
     }
     // Default filename: pdf/<faq_id>.pdf
     if (empty($pdfFile)) {
         $pdfFile = 'pdf' . $this->faqRecord['id'] . '.pdf';
     }
     $faqconfig = PMF_Configuration::getInstance();
     $categoryNode = new PMF_Category_Node();
     $categoryData = $categoryNode->fetch($currentCategory);
     $pdf = new PMF_Export_Pdf_Wrapper();
     $pdf->faq = $this->faqRecord;
     $pdf->setCategory($categoryData);
     $pdf->setQuestion($this->faqRecord['title']);
     // Start building PDF...
     $pdf->Open();
     // Set any item
     $pdf->SetTitle($this->faqRecord['title']);
     $pdf->SetCreator($faqconfig->get('main.titleFAQ') . ' - powered by phpMyFAQ ' . $faqconfig->get('main.currentVersion'));
     $pdf->AliasNbPages();
     $pdf->AddPage();
     $pdf->SetFont('arialunicid0', '', 12);
     $pdf->SetDisplayMode('real');
     $pdf->Ln();
     $pdf->WriteHTML(str_replace('../', '', $this->faqRecord['content']), true);
     $pdf->Ln();
     $pdf->Ln();
     $pdf->SetFont('arialunicid0', '', 11);
     $pdf->Write(5, $PMF_LANG['ad_entry_solution_id'] . ': #' . $this->faqRecord['solution_id']);
     $pdf->SetAuthor($this->faqRecord['author']);
     $pdf->Ln();
     $pdf->Write(5, $PMF_LANG['msgAuthor'] . ': ' . $this->faqRecord['author']);
     $pdf->Ln();
     $pdf->Write(5, $PMF_LANG['msgLastUpdateArticle'] . $this->faqRecord['date']);
     // Build it
     return $pdf->Output($pdfFile);
 }