Index: trunk/extensions/PdfBook/PdfBook.hooks.php |
— | — | @@ -14,12 +14,12 @@ |
15 | 15 | $title = $article->getTitle(); |
16 | 16 | $opt = ParserOptions::newFromUser( $wgUser ); |
17 | 17 | |
18 | | - # Log the export |
| 18 | + // Log the export |
19 | 19 | $msg = wfMsg( 'pdfbook-log', $wgUser->getUserPage()->getPrefixedText() ); |
20 | 20 | $log = new LogPage( 'pdf', false ); |
21 | 21 | $log->addEntry( 'book', $article->getTitle(), $msg ); |
22 | 22 | |
23 | | - # Initialise PDF variables |
| 23 | + // Initialise PDF variables |
24 | 24 | $format = $wgRequest->getText( 'format' ); |
25 | 25 | $notitle = $wgRequest->getText( 'notitle' ); |
26 | 26 | $layout = $format == 'single' ? '--webpage' : '--firstpage toc'; |
— | — | @@ -38,7 +38,7 @@ |
39 | 39 | $width = $width ? "--browserwidth $width" : ''; |
40 | 40 | if( !is_array( $exclude ) ) $exclude = split( '\\s*,\\s*', $exclude ); |
41 | 41 | |
42 | | - # Select articles from members if a category or links in content if not |
| 42 | + // Select articles from members if a category or links in content if not |
43 | 43 | if( $format == 'single' ) $articles = array( $title ); |
44 | 44 | else { |
45 | 45 | $articles = array(); |
— | — | @@ -63,7 +63,7 @@ |
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | | - # Format the article(s) as a single HTML document with absolute URL's |
| 67 | + // Format the article(s) as a single HTML document with absolute URL's |
68 | 68 | $book = $title->getText(); |
69 | 69 | $html = ''; |
70 | 70 | $wgArticlePath = $wgServer.$wgArticlePath; |
— | — | @@ -90,7 +90,7 @@ |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | | - # $wgPdfBookTab = false; If format=html in query-string, return html content directly |
| 94 | + // $wgPdfBookTab = false; If format=html in query-string, return html content directly |
95 | 95 | if( $format == 'html' ) { |
96 | 96 | $wgOut->disable(); |
97 | 97 | header( "Content-Type: text/html" ); |
— | — | @@ -98,14 +98,15 @@ |
99 | 99 | print $html; |
100 | 100 | } |
101 | 101 | else { |
102 | | - # Write the HTML to a tmp file |
| 102 | + // Write the HTML to a tmp file |
| 103 | + if( !is_dir( $wgUploadDirectory ) ) mkdir( $wgUploadDirectory ); |
103 | 104 | $file = "$wgUploadDirectory/" . uniqid( 'pdf-book' ); |
104 | 105 | file_put_contents( $file, $html ); |
105 | 106 | |
106 | 107 | $footer = $format == 'single' ? "..." : ".1."; |
107 | 108 | $toc = $format == 'single' ? "" : " --toclevels $levels"; |
108 | 109 | |
109 | | - # Send the file to the client via htmldoc converter |
| 110 | + // Send the file to the client via htmldoc converter |
110 | 111 | $wgOut->disable(); |
111 | 112 | header( "Content-Type: application/pdf" ); |
112 | 113 | header( "Content-Disposition: attachment; filename=\"$book.pdf\"" ); |
— | — | @@ -130,8 +131,8 @@ |
131 | 132 | */ |
132 | 133 | private static function setProperty( $name, $default ) { |
133 | 134 | global $wgRequest; |
134 | | - if ( $wgRequest->getText( "pdf$name" ) ) return $wgRequest->getText( "pdf$name" ); |
135 | | - if ( $wgRequest->getText( "amp;pdf$name" ) ) return $wgRequest->getText( "amp;pdf$name" ); // hack to handle ampersand entities in URL |
| 135 | + if ( $wgRequest->getText( "pdf$name" ) ) return $wgRequest->getText( "pdf$name" ); |
| 136 | + if ( $wgRequest->getText( "amp;pdf$name" ) ) return $wgRequest->getText( "amp;pdf$name" ); // hack to handle ampersand entities in URL |
136 | 137 | if ( isset( $GLOBALS["wgPdfBook$name"] ) ) return $GLOBALS["wgPdfBook$name"]; |
137 | 138 | return $default; |
138 | 139 | } |