* Fix E_NOTICE
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 7 Feb 2009 15:16:51 +0000 (15:16 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 7 Feb 2009 15:16:51 +0000 (15:16 +0000)
* Add page title

includes/specials/SpecialExport.php

index f996cac..d729abf 100644 (file)
  */
 
 class SpecialExport extends SpecialPage {
-       
+
        private $curonly, $doExport, $pageLinkDepth, $templates;
        private $images;
-       
+
        public function __construct() {
                parent::__construct( 'Export' );
        }
@@ -33,7 +33,10 @@ class SpecialExport extends SpecialPage {
        public function execute( $par ) {
                global $wgOut, $wgRequest, $wgSitename, $wgExportAllowListContributors;
                global $wgExportAllowHistory, $wgExportMaxHistory;
-       
+
+               $this->setHeaders();
+               $this->outputHeader();
+
                // Set some variables
                $this->curonly = true;
                $this->doExport = false;
@@ -44,7 +47,7 @@ class SpecialExport extends SpecialPage {
                if ( $wgRequest->getCheck( 'addcat' ) ) {
                        $page = $wgRequest->getText( 'pages' );
                        $catname = $wgRequest->getText( 'catname' );
-       
+
                        if ( $catname !== '' && $catname !== NULL && $catname !== false ) {
                                $t = Title::makeTitleSafe( NS_MAIN, $catname );
                                if ( $t ) {
@@ -88,29 +91,29 @@ class SpecialExport extends SpecialPage {
                                        $history['dir'] = 'desc';
                                }
                        }
-       
+
                        if( $page != '' ) $this->doExport = true;
                } else {
                        // Default to current-only for GET requests
-                       $page = $wgRequest->getText( 'pages', $page );
+                       $page = $wgRequest->getText( 'pages' );
                        $historyCheck = $wgRequest->getCheck( 'history' );
                        if( $historyCheck ) {
                                $history = WikiExporter::FULL;
                        } else {
                                $history = WikiExporter::CURRENT;
                        }
-       
+
                        if( $page != '' ) $this->doExport = true;
                }
-       
+
                if( !$wgExportAllowHistory ) {
                        // Override
                        $history = WikiExporter::CURRENT;
                }
-       
+
                $list_authors = $wgRequest->getCheck( 'listauthors' );
                if ( !$this->curonly || !$wgExportAllowListContributors ) $list_authors = false ;
-       
+
                if ( $this->doExport ) {
                        $wgOut->disable();
                        // Cancel output buffering and gzipping if set
@@ -125,16 +128,16 @@ class SpecialExport extends SpecialPage {
                        $this->doExport( $page, $history );
                        return;
                }
-       
+
                $wgOut->addHTML( wfMsgExt( 'exporttext', 'parse' ) );
-       
+
                $form = Xml::openElement( 'form', array( 'method' => 'post',
                        'action' => $this->getTitle()->getLocalUrl( 'action=submit' ) ) );
                $form .= Xml::inputLabel( wfMsg( 'export-addcattext' )  , 'catname', 'catname', 40 ) . '&nbsp;';
                $form .= Xml::submitButton( wfMsg( 'export-addcat' ), array( 'name' => 'addcat' ) ) . '<br />';
                $form .= Xml::element( 'textarea', array( 'name' => 'pages', 'cols' => 40, 'rows' => 10 ), $page, false );
                $form .= '<br />';
-       
+
                if( $wgExportAllowHistory ) {
                        $form .= Xml::checkLabel( wfMsg( 'exportcuronly' ), 'curonly', 'curonly', true ) . '<br />';
                } else {
@@ -145,12 +148,12 @@ class SpecialExport extends SpecialPage {
                // Enable this when we can do something useful exporting/importing image information. :)
                //$form .= Xml::checkLabel( wfMsg( 'export-images' ), 'images', 'wpExportImages', false ) . '<br />';
                $form .= Xml::checkLabel( wfMsg( 'export-download' ), 'wpDownload', 'wpDownload', true ) . '<br />';
-       
+
                $form .= Xml::submitButton( wfMsg( 'export-submit' ), array( 'accesskey' => 's' ) );
                $form .= Xml::closeElement( 'form' );
                $wgOut->addHTML( $form );
        }
-       
+
        /**
         * Do the actual page exporting
         * @param string $page User input on what page(s) to export
@@ -158,28 +161,28 @@ class SpecialExport extends SpecialPage {
         */
        private function doExport( $page, $history ) {
                global $wgExportMaxHistory;
-               
+
                /* Split up the input and look up linked pages */
                $inputPages = array_filter( explode( "\n", $page ), array( $this, 'filterPage' ) );
                $pageSet = array_flip( $inputPages );
-               
+
                if( $this->templates ) {
                        $pageSet = $this->getTemplates( $inputPages, $pageSet );
                }
-               
+
                if( $linkDepth = $this->pageLinkDepth ) {
                        $pageSet = $this->getPageLinks( $inputPages, $pageSet, $linkDepth );
                }
-               
+
                /*
                // Enable this when we can do something useful exporting/importing image information. :)
                if( $this->images ) ) {
                        $pageSet = $this->getImages( $inputPages, $pageSet );
                }
                */
-               
+
                $pages = array_keys( $pageSet );
-               
+
                /* Ok, let's get to it... */
                if( $history == WikiExporter::CURRENT ) {
                        $lb = false;
@@ -190,7 +193,7 @@ class SpecialExport extends SpecialPage {
                        $lb = wfGetLBFactory()->newMainLB();
                        $db = $lb->getConnection( DB_SLAVE );
                        $buffer = WikiExporter::STREAM;
-                       
+
                        // This might take a while... :D
                        wfSuppressWarnings();
                        set_time_limit(0);
@@ -216,28 +219,28 @@ class SpecialExport extends SpecialPage {
                        $title = Title::newFromText( $page );
                        if( is_null( $title ) ) continue; #TODO: perhaps output an <error> tag or something.
                                if( !$title->userCanRead() ) continue; #TODO: perhaps output an <error> tag or something.
-       
+
                                $exporter->pageByTitle( $title );
                }
-       
+
                $exporter->closeStream();
                if( $lb ) {
                        $lb->closeAll();
                }
        }
-       
+
        private function getPagesFromCategory( $title ) {
                global $wgContLang;
 
                $name = $title->getDBkey();
-       
+
                $dbr = wfGetDB( DB_SLAVE );
-       
+
                list( $page, $categorylinks ) = $dbr->tableNamesN( 'page', 'categorylinks' );
                $sql = "SELECT page_namespace, page_title FROM $page " .
                        "JOIN $categorylinks ON cl_from = page_id " .
                        "WHERE cl_to = " . $dbr->addQuotes( $name );
-       
+
                $pages = array();
                $res = $dbr->query( $sql, __METHOD__ );
                while ( $row = $dbr->fetchObject( $res ) ) {
@@ -246,12 +249,12 @@ class SpecialExport extends SpecialPage {
                                $ns = $wgContLang->getNsText( $row->page_namespace );
                                $n = $ns . ':' . $n;
                        }
-       
+
                        $pages[] = $n;
                }
                $dbr->freeResult($res);
-       
-       return $pages;  
+
+       return $pages;
        }
 
        /**
@@ -276,7 +279,7 @@ class SpecialExport extends SpecialPage {
                }
                return $pageSet;
        }
-       
+
        /**
         * Expand a list of pages to include images used in those pages.
         * @param $inputPages array, list of titles to look up
@@ -289,7 +292,7 @@ class SpecialExport extends SpecialPage {
                                        array( NS_FILE . ' AS namespace', 'il_to AS title' ),
                                        array( 'page_id=il_from' ) );
        }
-       
+
        /**
         * Expand a list of pages to include items used in those pages.
         * @private