-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpmwiki2pdf.php
More file actions
55 lines (43 loc) · 1.65 KB
/
pmwiki2pdf.php
File metadata and controls
55 lines (43 loc) · 1.65 KB
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
<?php
/**
PmWiki module to generate a PDF file from the ?action=pdf page view.
with the HTML2PDF PHP Class ( http://html2pdf.fr/ )
Hacked by Stephane HUC for PmWiki !
Copyright (C) 2011 Stephane HUC <devs@stephane-huc.net>
This is GPL, only it seems odd to include a license in a program
that has twice the size of the license.
Modifications to work with PmWiki 2.2.x,
Copyright (c) 2005 by Patrick R. Michaud <pmichaud@pobox.com>
*/
if (!defined('PmWiki')) exit();
if($_SERVER['DOCUMENT_ROOT'] == 'pmwiki.dev.stephane-huc.net') error_reporting(E_ALL);
// to define file config name : config.php, config...
define('P2PDF_CFG_NAME', 'config.php');
/*** Don't touch below! ***/
define('P2PDF_OWNER', fileowner(dirname(__FILE__).'/pmwiki2pdf.php') );
$file = new SplFileInfo(dirname(__FILE__).'/class.pmwiki2pdf.php');
if($file->isFile() && $file->isReadable() && $file->getOwner() == P2PDF_OWNER ) require($file);
else die('<p style="color: red; font-weight: bold;">Failed to require the pmwiki2pdf class!</p>');
#
# add the $HandleActions PDF variable array ...
#
$HandleActions['pdf'] = 'HandlePDF';
function HandlePDF($pagename) {
global $WikiTitle;
try {
$pmwiki['name'] = $pagename;
$pmwiki['page'] = RetrieveAuthPage($pmwiki['name'], 'read', true, READPAGE_CURRENT);
$pmwiki['title'] = $WikiTitle;
// declare new instance
$pmwiki2pdf = new pmwiki2pdf();
$pmwiki2pdf->get_wiki_vars($pmwiki);
$pmwiki2pdf->build_variables_needed();
$pmwiki2pdf->transform_text();
$pmwiki2pdf->initialize_server();
$pmwiki2pdf->get_flux();
$pmwiki2pdf->get_pdf();
unset($pmwiki, $pmwiki2pdf);
}
catch(Exception $e) { echo $e; }
}
?>