Merge "Move list generation out of TablePager::getLimitSelect()"
[lhc/web/wiklou.git] / maintenance / generateSitemap.php
index a81e3d9..44867d0 100644 (file)
@@ -26,7 +26,7 @@
  * @see http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd
  */
 
-require_once( dirname( __FILE__ ) . '/Maintenance.php' );
+require_once( __DIR__ . '/Maintenance.php' );
 
 /**
  * Maintenance script that generates a sitemap for the site.
@@ -44,7 +44,7 @@ class GenerateSitemap extends Maintenance {
         *
         * @var int
         */
-       var $url_limit;
+       public $url_limit;
 
        /**
         * The maximum size of a sitemap file
@@ -53,77 +53,77 @@ class GenerateSitemap extends Maintenance {
         *
         * @var int
         */
-       var $size_limit;
+       public $size_limit;
 
        /**
         * The path to prepend to the filename
         *
         * @var string
         */
-       var $fspath;
+       public $fspath;
 
        /**
         * The URL path to prepend to filenames in the index; should resolve to the same directory as $fspath
         *
         * @var string
         */
-       var $urlpath;
+       public $urlpath;
 
        /**
         * Whether or not to use compression
         *
         * @var bool
         */
-       var $compress;
+       public $compress;
 
        /**
         * Whether or not to include redirection pages
         *
         * @var bool
         */
-       var $skipRedirects;
+       public $skipRedirects;
 
        /**
         * The number of entries to save in each sitemap file
         *
         * @var array
         */
-       var $limit = array();
+       public $limit = array();
 
        /**
         * Key => value entries of namespaces and their priorities
         *
         * @var array
         */
-       var $priorities = array();
+       public $priorities = array();
 
        /**
         * A one-dimensional array of namespaces in the wiki
         *
         * @var array
         */
-       var $namespaces = array();
+       public $namespaces = array();
 
        /**
         * When this sitemap batch was generated
         *
         * @var string
         */
-       var $timestamp;
+       public $timestamp;
 
        /**
         * A database slave object
         *
         * @var object
         */
-       var $dbr;
+       public $dbr;
 
        /**
         * A resource pointing to the sitemap index file
         *
         * @var resource
         */
-       var $findex;
+       public $findex;
 
 
        /**
@@ -131,7 +131,7 @@ class GenerateSitemap extends Maintenance {
         *
         * @var resource
         */
-       var $file;
+       public $file;
 
        /**
         * Identifier to use in filenames, default $wgDBname
@@ -167,7 +167,7 @@ class GenerateSitemap extends Maintenance {
                }
                $this->identifier = $this->getOption( 'identifier', wfWikiID() );
                $this->compress = $this->getOption( 'compress', 'yes' ) !== 'no';
-               $this->skipRedirects = $this->getOption( 'skip-redirects', false ) !== false ;
+               $this->skipRedirects = $this->getOption( 'skip-redirects', false ) !== false;
                $this->dbr = wfGetDB( DB_SLAVE );
                $this->generateNamespaces();
                $this->timestamp = wfTimestamp( TS_ISO_8601, wfTimestampNow() );
@@ -231,7 +231,7 @@ class GenerateSitemap extends Maintenance {
                        wfMkdirParents( $fspath, null, __METHOD__ ) or die( "Can not create directory $fspath.\n" );
                }
 
-               return realpath( $fspath ) . DIRECTORY_SEPARATOR ;
+               return realpath( $fspath ) . DIRECTORY_SEPARATOR;
        }
 
        /**
@@ -255,8 +255,9 @@ class GenerateSitemap extends Maintenance {
                        )
                );
 
-               foreach ( $res as $row )
+               foreach ( $res as $row ) {
                        $this->namespaces[] = $row->page_namespace;
+               }
        }
 
        /**
@@ -346,7 +347,9 @@ class GenerateSitemap extends Maintenance {
                                if ( $wgContLang->hasVariants() ) {
                                        $variants = $wgContLang->getVariants();
                                        foreach ( $variants as $vCode ) {
-                                               if ( $vCode == $wgContLang->getCode() ) continue; // we don't want default variant
+                                               if ( $vCode == $wgContLang->getCode() ) {
+                                                       continue; // we don't want default variant
+                                               }
                                                $entry = $this->fileEntry( $title->getCanonicalURL( '', $vCode ), $date, $this->priority( $namespace ) );
                                                $length += strlen( $entry );
                                                $this->write( $this->file, $entry );
@@ -374,7 +377,7 @@ class GenerateSitemap extends Maintenance {
         */
        function open( $file, $flags ) {
                $resource = $this->compress ? gzopen( $file, $flags ) : fopen( $file, $flags );
-               if( $resource === false ) {
+               if ( $resource === false ) {
                        wfDebugDieBacktrace( __METHOD__ . " error opening file $file with flags $flags. Check permissions?" );
                }
                return $resource;
@@ -384,23 +387,25 @@ class GenerateSitemap extends Maintenance {
         * gzwrite() / fwrite() wrapper
         */
        function write( &$handle, $str ) {
-               if( $handle === true || $handle === false ) {
+               if ( $handle === true || $handle === false ) {
                        wfDebugDieBacktrace( __METHOD__ . " was passed a boolean as a file handle.\n" );
                }
-               if ( $this->compress )
+               if ( $this->compress ) {
                        gzwrite( $handle, $str );
-               else
+               } else {
                        fwrite( $handle, $str );
+               }
        }
 
        /**
         * gzclose() / fclose() wrapper
         */
        function close( &$handle ) {
-               if ( $this->compress )
+               if ( $this->compress ) {
                        gzclose( $handle );
-               else
+               } else {
                        fclose( $handle );
+               }
        }
 
        /**