Completed
Push — master ( 10bab4...a0a78b )
by Michael
02:06
created

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * FPDF creator framework for XOOPS
4
 *
5
 * Supporting multi-byte languages as well as utf-8 charset
6
 *
7
 * @copyright   XOOPS Project (https://xoops.org)
8
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
9
 * @author      Taiwen Jiang (phppp or D.J.) <[email protected]>
10
 * @since       1.00
11
 * @package     frameworks
12
 */
13
14
//TODO needs to be refactored for TCPDF
15
16
//ob_start();
17
18
/**
19
 * If no pdf_data is set, build it from the module
20
 *
21
 * <ul>The data fields to be built:
22
 *      <li>title</li>
23
 *      <li>subtitle (optional)</li>
24
 *      <li>subsubtitle (optional)</li>
25
 *      <li>date</li>
26
 *      <li>author</li>
27
 *      <li>content</li>
28
 *      <li>filename</li>
29
 * </ul>
30
 */
31
32
use Xmf\Request;
33
34
include __DIR__ . '/header.php';
35
global $pdf_data;
36
if (!empty($_POST['pdf_data'])) {
37
    $pdf_data = unserialize(base64_decode(Request::getText('pdf_data', '', 'POST')));
38
} elseif (!empty($pdf_data)) {
39
} else {
40
    error_reporting(0);
41
    include __DIR__ . '/header.php';
42
    error_reporting(0);
43
44
    if (PlanetUtility::planetParseArguments($args_num, $args, $args_str)) {
45
        $args['article'] = @$args_num[0];
46
    }
47
48
    $article_id = (int)(empty($_GET['article']) ? @$args['article'] : $_GET['article']);
49
50
    $articleHandler = xoops_getModuleHandler('article', $GLOBALS['moddirname']);
51
    $article_obj    = $articleHandler->get($article_id);
52
53
    $article_data = [];
54
55
    // title
56
    $article_data['title'] = $article_obj->getVar('art_title');
57
58
    $article_data['author'] = $article_obj->getVar('art_author');
59
60
    // source
61
    $article_data['source'] = $article_obj->getVar('art_link');
62
63
    // publish time
64
    $article_data['time'] = $article_obj->getTime();
65
66
    // summary
67
    $article_data['summary'] = $article_obj->getSummary();
68
69
    // text of page
70
    $article_data['text'] = $article_obj->getVar('art_content');
71
72
    // Build the pdf_data array
73
    $pdf_data['title']   = $article_data['title'];
74
    $pdf_data['author']  = $article_data['author'];
75
    $pdf_data['date']    = $article_data['time'];
76
    $pdf_data['content'] = '';
77
    if ($article_data['summary']) {
78
        $pdf_data['content'] .= planet_constant('MD_SUMMARY') . ': ' . $article_data['summary'] . '<br><br>';
79
    }
80
    $pdf_data['content'] .= $article_data['text'] . '<br>';
81
    $pdf_data['url']     = XOOPS_URL . '/modules/' . $GLOBALS['artdirname'] . '/view.article.php' . URL_DELIMITER . $article_obj->getVar('art_id');
82
}
83
$pdf_data['filename'] = preg_replace("/[^0-9a-z\-_\.]/i", '', $pdf_data['title']);
84
85
require_once XOOPS_ROOT_PATH . '/class/libraries/vendor/tecnickcom/tcpdf/tcpdf.php';
86
87
error_reporting(0);
88
ob_end_clean();
89
90
//$pdf = new xoopsPDF($xoopsConfig['language']);
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
91
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, _CHARSET, false);
92
$pdf->initialize();
93
$pdf->output($pdf_data, _CHARSET);
94