Specialpage, how to output some text to a file ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Specialpage, how to output some text to a file ?

Peter Flindt (Lastwebpage)
Hello,
i start to write my own special pages and have the code snippet below,
unfortunately the mediawiki add some code, a complete website, to the
outputfile. Some hints to stop this additional text?

regards
Peter

==============================================
$fname = "Sprachdatei::DownloadLanguagepack";
$sql="SELECT old_text FROM page,text, revision WHERE page.page_title IN
(".implode(",",$TitelArray).") AND revision.rev_id=page.page_latest AND
revision.rev_text_id=text.old_id AND page.page_namespace=100";
$res=$dbr->query($sql,$fname);
while ($row=$dbr->fetchObject($res))
{
        $curText=$row->old_text;
        $this->FormatText($curText);
        $outText.=$curText;
}
$dbr->freeResult($res);
$filename="../wiki/extensions/langpack_german.txt";
if($file=fopen($filename,"w"))
        fwrite($file,$outText);
fclose($file);
header('Content-Description: File Transfer');
header("Content-Type: application/octet-stream");
header("Content-length: ".filesize($filename));
header( "Content-disposition: attachment;
filename=langpack_german.txt")
readfile($filename);
unlink($filename);

--
Newsreader: http://mesnews.net/index-gb.php
Deutsche Hilfedatei: http://www.lastwebpage.de/download/mesnews-de.zip



_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Reply | Threaded
Open this post in threaded view
|

Re: Specialpage, how to output some text to a file ?

Markus Krötzsch
On Friday 07 April 2006 14:26, Peter Flindt wrote:
> Hello,
> i start to write my own special pages and have the code snippet below,
> unfortunately the mediawiki add some code, a complete website, to the
> outputfile. Some hints to stop this additional text?

If you want to make your own page from scratch, use

global $wgOut;
$wgOut->disable();

and issue "print"-calls for all your HTML. You then also should include
something like

header( "Content-type: text/html; charset=UTF-8" );

or whatever your output is (if you can, avoid the rather useless
"application/octet-stream" and say what you really transmit).

Best regards,

Markus

>
> regards
> Peter
>
> ==============================================
> $fname = "Sprachdatei::DownloadLanguagepack";
> $sql="SELECT old_text FROM page,text, revision WHERE page.page_title IN
> (".implode(",",$TitelArray).") AND revision.rev_id=page.page_latest AND
> revision.rev_text_id=text.old_id AND page.page_namespace=100";
> $res=$dbr->query($sql,$fname);
> while ($row=$dbr->fetchObject($res))
> {
> $curText=$row->old_text;
> $this->FormatText($curText);
> $outText.=$curText;
> }
> $dbr->freeResult($res);
> $filename="../wiki/extensions/langpack_german.txt";
> if($file=fopen($filename,"w"))
> fwrite($file,$outText);
> fclose($file);
> header('Content-Description: File Transfer');
> header("Content-Type: application/octet-stream");
> header("Content-length: ".filesize($filename));
> header( "Content-disposition: attachment;
> filename=langpack_german.txt")
> readfile($filename);
> unlink($filename);
--
Markus Krötzsch
Institute AIFB, University of Karlsruhe, D-76128 Karlsruhe
[hidden email]        phone +49 (0)721 608 7362
www.aifb.uni-karlsruhe.de/WBS/     fax +49 (0)721 693  717

_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l

attachment0 (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Specialpage, how to output some text to a file ?

Peter Flindt (Lastwebpage)
Markus Krötzsch wrote at 07.04.2006 :
> ...
> If you want to make your own page from scratch, use

> global $wgOut;
> $wgOut->disable();
> ...

Excelent, many thanks, this disable() was the solution. :-)
And thanks for the tip about this charset.

best regards
Peter

--
Newsreader: http://mesnews.net/index-gb.php
Deutsche Hilfedatei: http://www.lastwebpage.de/download/mesnews-de.zip



_______________________________________________
MediaWiki-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l