1
|
|
|
<?php |
2
|
|
|
// |
3
|
|
|
// ------------------------------------------------------------------------ // |
4
|
|
|
// XOOPS - PHP Content Management System // |
5
|
|
|
// Copyright (c) 2000-2016 XOOPS.org // |
6
|
|
|
// <http://xoops.org/> // |
7
|
|
|
// ------------------------------------------------------------------------ // |
8
|
|
|
// This program is free software; you can redistribute it and/or modify // |
9
|
|
|
// it under the terms of the GNU General Public License as published by // |
10
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
11
|
|
|
// (at your option) any later version. // |
12
|
|
|
// // |
13
|
|
|
// You may not change or alter any portion of this comment or credits // |
14
|
|
|
// of supporting developers from this source code or any supporting // |
15
|
|
|
// source code which is considered copyrighted (c) material of the // |
16
|
|
|
// original comment or credit authors. // |
17
|
|
|
// // |
18
|
|
|
// This program is distributed in the hope that it will be useful, // |
19
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
20
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
21
|
|
|
// GNU General Public License for more details. // |
22
|
|
|
// // |
23
|
|
|
// You should have received a copy of the GNU General Public License // |
24
|
|
|
// along with this program; if not, write to the Free Software // |
25
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
26
|
|
|
// ------------------------------------------------------------------------ // |
27
|
|
|
// Author: Kazumi Ono (AKA onokazu) // |
28
|
|
|
// URL: http://www.myweb.ne.jp/, http://xoops.org/, http://jp.xoops.org/ // |
29
|
|
|
// Project: XOOPS Project // |
30
|
|
|
// ------------------------------------------------------------------------- // |
31
|
|
|
|
32
|
|
|
include_once __DIR__ . '/header.php'; |
33
|
|
|
//error_reporting(0); |
34
|
|
|
//error_reporting(0); |
35
|
|
|
|
36
|
|
|
$myts = MyTextSanitizer::getInstance(); |
37
|
|
|
require_once SMARTPARTNER_ROOT_PATH . 'fpdf/fpdf.inc.php'; |
38
|
|
|
|
39
|
|
|
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
40
|
|
|
|
41
|
|
|
if ($id == 0) { |
42
|
|
|
redirect_header('javascript:history.go(-1)', 2, _MD_SPARTNER_NOPARTNERSELECTED); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
// Creating the Partner object for the selected FAQ |
46
|
|
|
$partnerObj = new SmartpartnerPartner($id); |
47
|
|
|
|
48
|
|
|
// If the selected partner was not found, exit |
49
|
|
|
if ($partnerObj->notLoaded()) { |
50
|
|
|
redirect_header('javascript:history.go(-1)', 2, _MD_SPARTNER_NOPARTNERSELECTED); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
// Chech the status |
54
|
|
|
if ($partnerObj->status() != _SPARTNER_STATUS_ACTIVE) { |
55
|
|
|
redirect_header('javascript:history.go(-1)', 2, _NOPERM); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$pdf_data['title'] = $partnerObj->title(); |
59
|
|
|
$pdf_data['subtitle'] = 'subtitle...'; |
60
|
|
|
$pdf_data['subsubtitle'] = 'subsubtitle...'; |
61
|
|
|
$pdf_data['date'] = 'date...'; |
62
|
|
|
$pdf_data['filename'] = 'filename...'; //preg_replace("/[^0-9a-z\-_\.]/i",'', $myts->htmlSpecialChars($article->topic_title()).' - '.$article->title()); |
63
|
|
|
$pdf_data['content'] = $partnerObj->description(); |
64
|
|
|
$pdf_data['author'] = 'author...'; |
65
|
|
|
|
66
|
|
|
echo 'test'; |
67
|
|
|
//Other stuff |
68
|
|
|
$puff = '<br>'; |
69
|
|
|
$puffer = '<br><br><br>'; |
70
|
|
|
|
71
|
|
|
//create the A4-PDF... |
72
|
|
|
$pdf_config['slogan'] = $xoopsConfig['sitename'] . ' - ' . $xoopsConfig['slogan']; |
73
|
|
|
|
74
|
|
|
$pdf = new PDF(); |
75
|
|
|
$pdf->SetCreator($pdf_config['creator']); |
76
|
|
|
$pdf->SetTitle($pdf_data['title']); |
77
|
|
|
$pdf->SetAuthor($pdf_config['url']); |
78
|
|
|
$pdf->SetSubject($pdf_data['author']); |
79
|
|
|
$out = $pdf_config['url'] . ', ' . $pdf_data['author'] . ', ' . $pdf_data['title'] . ', ' . $pdf_data['subtitle'] . ', ' . $pdf_data['subsubtitle']; |
80
|
|
|
$pdf->SetKeywords($out); |
81
|
|
|
$pdf->SetAutoPageBreak(true, 25); |
82
|
|
|
$pdf->SetMargins($pdf_config['margin']['left'], $pdf_config['margin']['top'], $pdf_config['margin']['right']); |
83
|
|
|
$pdf->Open(); |
84
|
|
|
|
85
|
|
|
//First page |
86
|
|
|
$pdf->AddPage(); |
87
|
|
|
$pdf->SetXY(24, 25); |
88
|
|
|
$pdf->SetTextColor(10, 60, 160); |
89
|
|
|
$pdf->SetFont($pdf_config['font']['slogan']['family'], $pdf_config['font']['slogan']['style'], $pdf_config['font']['slogan']['size']); |
90
|
|
|
$pdf->WriteHTML($pdf_config['slogan'], $pdf_config['scale']); |
91
|
|
|
//$pdf->Image($pdf_config['logo']['path'],$pdf_config['logo']['left'],$pdf_config['logo']['top'],$pdf_config['logo']['width'],$pdf_config['logo']['height'],'',$pdf_config['url']); |
92
|
|
|
$pdf->Line(25, 30, 190, 30); |
93
|
|
|
$pdf->SetXY(25, 35); |
94
|
|
|
$pdf->SetFont($pdf_config['font']['title']['family'], $pdf_config['font']['title']['style'], $pdf_config['font']['title']['size']); |
95
|
|
|
$pdf->WriteHTML($pdf_data['title'], $pdf_config['scale']); |
96
|
|
|
|
97
|
|
View Code Duplication |
if ($pdf_data['subtitle'] <> '') { |
|
|
|
|
98
|
|
|
$pdf->WriteHTML($puff, $pdf_config['scale']); |
99
|
|
|
$pdf->SetFont($pdf_config['font']['subtitle']['family'], $pdf_config['font']['subtitle']['style'], $pdf_config['font']['subtitle']['size']); |
100
|
|
|
$pdf->WriteHTML($pdf_data['subtitle'], $pdf_config['scale']); |
101
|
|
|
} |
102
|
|
View Code Duplication |
if ($pdf_data['subsubtitle'] <> '') { |
|
|
|
|
103
|
|
|
$pdf->WriteHTML($puff, $pdf_config['scale']); |
104
|
|
|
$pdf->SetFont($pdf_config['font']['subsubtitle']['family'], $pdf_config['font']['subsubtitle']['style'], $pdf_config['font']['subsubtitle']['size']); |
105
|
|
|
$pdf->WriteHTML($pdf_data['subsubtitle'], $pdf_config['scale']); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
$pdf->WriteHTML($puff, $pdf_config['scale']); |
109
|
|
|
$pdf->SetFont($pdf_config['font']['author']['family'], $pdf_config['font']['author']['style'], $pdf_config['font']['author']['size']); |
110
|
|
|
$out = NEWS_PDF_AUTHOR . ': '; |
111
|
|
|
$out .= $pdf_data['author']; |
112
|
|
|
$pdf->WriteHTML($out, $pdf_config['scale']); |
113
|
|
|
$pdf->WriteHTML($puff, $pdf_config['scale']); |
114
|
|
|
$out = NEWS_PDF_DATE; |
115
|
|
|
$out .= $pdf_data['date']; |
116
|
|
|
$pdf->WriteHTML($out, $pdf_config['scale']); |
117
|
|
|
$pdf->WriteHTML($puff, $pdf_config['scale']); |
118
|
|
|
|
119
|
|
|
$pdf->SetTextColor(0, 0, 0); |
120
|
|
|
$pdf->WriteHTML($puffer, $pdf_config['scale']); |
121
|
|
|
|
122
|
|
|
$pdf->SetFont($pdf_config['font']['content']['family'], $pdf_config['font']['content']['style'], $pdf_config['font']['content']['size']); |
123
|
|
|
$pdf->WriteHTML($pdf_data['content'], $pdf_config['scale']); |
124
|
|
|
|
125
|
|
|
//$pdf->Output($pdf_data['filename'],''); |
126
|
|
|
$pdf->Output(); |
127
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.