r102902 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102901‎ | r102902 | r102903 >
Date:17:34, 13 November 2011
Author:nad
Status:deferred
Tags:
Comment:
attempt to create the upload dir if it doesnt exist
Modified paths:
  • /trunk/extensions/PdfBook/PdfBook.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PdfBook/PdfBook.hooks.php
@@ -14,12 +14,12 @@
1515 $title = $article->getTitle();
1616 $opt = ParserOptions::newFromUser( $wgUser );
1717
18 - # Log the export
 18+ // Log the export
1919 $msg = wfMsg( 'pdfbook-log', $wgUser->getUserPage()->getPrefixedText() );
2020 $log = new LogPage( 'pdf', false );
2121 $log->addEntry( 'book', $article->getTitle(), $msg );
2222
23 - # Initialise PDF variables
 23+ // Initialise PDF variables
2424 $format = $wgRequest->getText( 'format' );
2525 $notitle = $wgRequest->getText( 'notitle' );
2626 $layout = $format == 'single' ? '--webpage' : '--firstpage toc';
@@ -38,7 +38,7 @@
3939 $width = $width ? "--browserwidth $width" : '';
4040 if( !is_array( $exclude ) ) $exclude = split( '\\s*,\\s*', $exclude );
4141
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
4343 if( $format == 'single' ) $articles = array( $title );
4444 else {
4545 $articles = array();
@@ -63,7 +63,7 @@
6464 }
6565 }
6666
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
6868 $book = $title->getText();
6969 $html = '';
7070 $wgArticlePath = $wgServer.$wgArticlePath;
@@ -90,7 +90,7 @@
9191 }
9292 }
9393
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
9595 if( $format == 'html' ) {
9696 $wgOut->disable();
9797 header( "Content-Type: text/html" );
@@ -98,14 +98,15 @@
9999 print $html;
100100 }
101101 else {
102 - # Write the HTML to a tmp file
 102+ // Write the HTML to a tmp file
 103+ if( !is_dir( $wgUploadDirectory ) ) mkdir( $wgUploadDirectory );
103104 $file = "$wgUploadDirectory/" . uniqid( 'pdf-book' );
104105 file_put_contents( $file, $html );
105106
106107 $footer = $format == 'single' ? "..." : ".1.";
107108 $toc = $format == 'single' ? "" : " --toclevels $levels";
108109
109 - # Send the file to the client via htmldoc converter
 110+ // Send the file to the client via htmldoc converter
110111 $wgOut->disable();
111112 header( "Content-Type: application/pdf" );
112113 header( "Content-Disposition: attachment; filename=\"$book.pdf\"" );
@@ -130,8 +131,8 @@
131132 */
132133 private static function setProperty( $name, $default ) {
133134 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
136137 if ( isset( $GLOBALS["wgPdfBook$name"] ) ) return $GLOBALS["wgPdfBook$name"];
137138 return $default;
138139 }

Status & tagging log