-
Notifications
You must be signed in to change notification settings - Fork 3
/
pdf.php
128 lines (114 loc) · 3.56 KB
/
pdf.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Plugin - PDF Generator
*
* $URL$
* $Id$
*/
/**
* e107 pdf generation plugin
*
* @package e107_plugins
* @subpackage pdf
* @version $Id$;
*/
require_once('../../class2.php');
if(!e107::isInstalled('pdf') || !e_QUERY)
{
header('Location: '.e_BASE.'index.php');
}
$qs = explode('.', e_QUERY,2);
$source = $qs[0];
$parms = varset($qs[1],'');
//include_lan(e_PLUGIN.'pdf/languages/'.e_LANGUAGE.'_admin_pdf.php');
require_once(e_PLUGIN.'pdf/e107pdf.php'); //require the e107pdf class
$pdf = new e107PDF();
if(strpos($source,'plugin:') !== FALSE)
{
$plugin = substr($source,7);
if(file_exists(e_PLUGIN.$plugin.'/e_emailprint.php'))
{
include_once(e_PLUGIN.$plugin.'/e_emailprint.php');
if (function_exists('print_item_pdf'))
{
$text = print_item_pdf($parms);
$pdf->makePDF($text);
}
else
{
echo 'PDF generation not supported in this section';
}
}
else
{
echo 'file missing: '.e_PLUGIN.$plugin.'/e_emailprint.php';
exit;
}
}
else
{
if($source == 'news')
{
$con = new convert;
$sql->db_Select('news', '*', 'news_id='.intval($parms));
$row = $sql->db_Fetch();
$news_body = $tp->toHTML($row['news_body'], TRUE);
$news_extended = $tp->toHTML($row['news_extended'], TRUE);
if ($row['news_author'] == 0)
{
$a_name = 'e107';
$category_name = 'e107 welcome message';
}
else
{
$sql->db_Select('news_category', 'category_id, category_name', 'category_id='.intval($row['news_category']));
list($category_id, $category_name) = $sql->db_Fetch();
$sql->db_Select('user', 'user_id, user_name', 'user_id='.intval($row['news_author']));
list($a_id, $a_name) = $sql->db_Fetch(MYSQL_NUM);
}
$row['news_datestamp'] = $con->convert_date($row['news_datestamp'], "long");
$row['news_title'] = $tp -> toHTML($row['news_title'], TRUE, 'parse_sc');
//remove existing links from news title
$search = array();
$replace = array();
$search[0] = "/\<a href=\"(.*?)\">(.*?)<\/a>/si";
$replace[0] = '\\2';
$search[1] = "/\<a href='(.*?)'>(.*?)<\/a>/si";
$replace[1] = '\\2';
$search[2] = "/\<a href='(.*?)'>(.*?)<\/a>/si";
$replace[2] = '\\2';
$search[3] = "/\<a href="(.*?)">(.*?)<\/a>/si";
$replace[3] = '\\2';
$search[4] = "/\<a href='(.*?)'>(.*?)<\/a>/si";
$replace[4] = '\\2';
$row['news_title'] = preg_replace($search, $replace, $row['news_title']);
$text = "
<b>".$row['news_title']."</b><br />
".$row['category_name']."<br />
".$a_name.", ".$row['news_datestamp']."<br />
<br />
".$row['news_body']."<br />
";
if ($row['news_extended'] != ""){ $text .= "<br /><br />".$row['news_extended']; }
if ($row['news_source'] != ""){ $text .= "<br /><br />".$row['news_source']; }
if ($row['news_url'] != ""){ $text .= "<br />".$row['news_url']; }
$text = $text; //define text
$creator = SITENAME; //define creator
$author = $a_name; //define author
$title = $row['news_title']; //define title
$subject = $category_name; //define subject
$keywords = ''; //define keywords
//define url and logo to use in the header of the pdf file
$url = SITEURL.'news.php?item.'.$row['news_id'];
//always return an array with the following data:
$text = array($text, $creator, $author, $title, $subject, $keywords, $url);
$pdf->makePDF($text);
}
}
?>