Exemplo n.º 1
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;
     }
     $faqconfig = PMF_Configuration::getInstance();
     $category = new PMF_Category();
     // Default filename: pdf/<faq_id>.pdf
     if (empty($pdfFile)) {
         $pdfFile = 'pdf/' . $this->faqRecord['id'] . '.pdf';
     }
     // Cleanup any file
     if (file_exists($pdfFile)) {
         @unlink($pdfFile);
     }
     $pdf = new PMF_Export_Pdf($currentCategory, $this->faqRecord['title'], $category->categoryName);
     $pdf->faq = $this->faqRecord;
     // 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('dejavusans', '', 12);
     $pdf->SetDisplayMode('real');
     $pdf->Ln();
     $pdf->WriteHTML(str_replace('../', '', $this->faqRecord['content']), true);
     $pdf->Ln();
     $pdf->Ln();
     $pdf->SetFont('dejavusans', '', 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
     $pdf->Output($pdfFile);
     // Done?
     if (!file_exists($pdfFile)) {
         return false;
     }
     return $pdfFile;
 }
Exemplo n.º 2
0
    if (0 == count($current_groups)) {
        $current_groups = array(-1);
    }
} else {
    $current_user = -1;
    $current_groups = array(-1);
}
$currentCategory = PMF_Filter::filterInput(INPUT_GET, 'cat', FILTER_VALIDATE_INT);
$id = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
$getAll = PMF_Filter::filterInput(INPUT_GET, 'getAll', FILTER_VALIDATE_BOOLEAN, false);
$faq = new PMF_Faq($faqConfig);
$faq->setUser($current_user);
$faq->setGroups($current_groups);
$category = new PMF_Category($faqConfig, $current_groups, true);
$category->setUser($current_user);
$pdf = new PMF_Export_Pdf($faq, $category, $faqConfig);
if (true === $getAll) {
    $category->buildTree();
}
$tags = new PMF_Tags($faqConfig);
session_cache_limiter('private');
if (true === $getAll && $user->perm->checkRight($user->getUserId(), 'export')) {
    $filename = 'FAQs.pdf';
    $pdfFile = $pdf->generate(0, true, $lang);
} elseif (is_null($currentCategory) || is_null($id)) {
    Response::create('Wrong HTTP GET parameters values.', 403)->send();
    exit;
} else {
    if (is_null($currentCategory) || is_null($id)) {
        $http->redirect($faqConfig->get('main.referenceURL'));
        exit;
Exemplo n.º 3
0
 /**
  * Returns the PDF export
  * 
  * @param integer $nCatid     Number of categories
  * @param boolean $bDownwards Downwards
  * @param string  $lang       Language
  * 
  * @return string
  */
 public static function getPDFExport($nCatid = 0, $bDownwards = true, $lang = "")
 {
     $tree = new PMF_Category();
     $arrRubrik = array();
     $arrThema = array();
     $arrContent = array();
     $arrAuthor = array();
     $arrDatum = array();
     // Get Faq Data
     $oFaq = new PMF_Faq();
     $faqs = $oFaq->get(FAQ_QUERY_TYPE_EXPORT_PDF, $nCatid, $bDownwards, $lang);
     if (count($faqs) > 0) {
         $i = 0;
         // Get the data
         foreach ($faqs as $faq) {
             $arrRubrik[$i] = $faq['category_id'];
             $arrThema[$i] = $faq['topic'];
             $arrContent[$i] = $faq['content'];
             $arrAuthor[$i] = $faq['author_name'];
             $arrDatum[$i] = $faq['lastmodified'];
             $i++;
         }
         // Start composing PDF
         $pdf = new PMF_Export_Pdf();
         $pdf->enableBookmarks = true;
         $pdf->isFullExport = true;
         $pdf->Open();
         $pdf->AliasNbPages();
         $pdf->SetDisplayMode('real');
         // Create the PDF
         foreach ($arrContent as $key => $value) {
             $pdf->category = $arrRubrik[$key];
             $pdf->thema = $arrThema[$key];
             $pdf->categories = $tree->categoryName;
             $date = $arrDatum[$key];
             $author = $arrAuthor[$key];
             $pdf->AddPage();
             $pdf->SetFont("Arial", "", 12);
             $pdf->WriteHTML($value);
         }
         return $pdf->Output('', 'S');
     }
 }