Index: trunk/phase3/maintenance/generateSitemap.php |
— | — | @@ -57,11 +57,11 @@ |
58 | 58 | var $fspath; |
59 | 59 | |
60 | 60 | /** |
61 | | - * The path to append to the domain name |
| 61 | + * The URL path to prepend to filenames in the index; should resolve to the same directory as $fspath |
62 | 62 | * |
63 | 63 | * @var string |
64 | 64 | */ |
65 | | - var $path; |
| 65 | + var $urlpath; |
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Whether or not to use compression |
— | — | @@ -126,8 +126,8 @@ |
127 | 127 | public function __construct() { |
128 | 128 | parent::__construct(); |
129 | 129 | $this->mDescription = "Creates a sitemap for the site"; |
130 | | - $this->addOption( 'fspath', 'The file system path to save to, e.g. /tmp/sitemap' . |
131 | | - "\n\t\tdefaults to current directory", false, true ); |
| 130 | + $this->addOption( 'fspath', 'The file system path to save to, e.g. /tmp/sitemap; defaults to current directory', false, true ); |
| 131 | + $this->addOption( 'urlpath', 'The URL path corresponding to --fspath, prepended to filenames in the index; defaults to an empty string', false, true ); |
132 | 132 | $this->addOption( 'compress', 'Compress the sitemap files, can take value yes|no, default yes', false, true ); |
133 | 133 | } |
134 | 134 | |
— | — | @@ -139,6 +139,8 @@ |
140 | 140 | $this->url_limit = 50000; |
141 | 141 | $this->size_limit = pow( 2, 20 ) * 10; |
142 | 142 | $this->fspath = self::init_path( $this->getOption( 'fspath', getcwd() ) ); |
| 143 | + $this->urlpath = $this->getOption( 'urlpath', "" ); |
| 144 | + if ( $this->urlpath !== "" && substr( $this->urlpath, -1 ) !== '/' ) $this->urlpath .= '/'; |
143 | 145 | $this->compress = $this->getOption( 'compress', 'yes' ) !== 'no'; |
144 | 146 | $this->dbr = wfGetDB( DB_SLAVE ); |
145 | 147 | $this->generateNamespaces(); |
— | — | @@ -384,7 +386,7 @@ |
385 | 387 | function indexEntry( $filename ) { |
386 | 388 | return |
387 | 389 | "\t<sitemap>\n" . |
388 | | - "\t\t<loc>$filename</loc>\n" . |
| 390 | + "\t\t<loc>{$this->urlpath}$filename</loc>\n" . |
389 | 391 | "\t\t<lastmod>{$this->timestamp}</lastmod>\n" . |
390 | 392 | "\t</sitemap>\n"; |
391 | 393 | } |