2005-10-31 09:57:38 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Copyright (C) 2005 Brion Vibber <brion@pobox.com>
|
|
|
|
|
* http://www.mediawiki.org/
|
2006-01-07 13:09:30 +00:00
|
|
|
*
|
2005-10-31 09:57:38 +00:00
|
|
|
* Quick demo hack to generate a plaintext link dump,
|
|
|
|
|
* per the proposed wiki link database standard:
|
|
|
|
|
* http://www.usemod.com/cgi-bin/mb.pl?LinkDatabase
|
|
|
|
|
*
|
|
|
|
|
* Includes all (live and broken) intra-wiki links.
|
|
|
|
|
* Does not include interwiki or URL links.
|
|
|
|
|
* Dumps ASCII text to stdout; command-line.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2006-01-07 13:09:30 +00:00
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
2005-10-31 09:57:38 +00:00
|
|
|
* (at your option) any later version.
|
2006-01-07 13:09:30 +00:00
|
|
|
*
|
2005-10-31 09:57:38 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
2006-01-07 13:09:30 +00:00
|
|
|
*
|
2005-10-31 09:57:38 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
2006-04-05 07:43:17 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-10-31 09:57:38 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Mainatenance
|
2005-10-31 09:57:38 +00:00
|
|
|
*/
|
|
|
|
|
|
2010-05-22 16:50:39 +00:00
|
|
|
require_once( dirname( __FILE__ ) . '/Maintenance.php' );
|
2005-10-31 09:57:38 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
class DumpLinks extends Maintenance {
|
|
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct();
|
|
|
|
|
$this->mDescription = "Quick demo hack to generate a plaintext link dump";
|
|
|
|
|
}
|
2005-10-31 09:57:38 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
public function execute() {
|
|
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
$result = $dbr->select( array( 'pagelinks', 'page' ),
|
|
|
|
|
array(
|
|
|
|
|
'page_id',
|
|
|
|
|
'page_namespace',
|
|
|
|
|
'page_title',
|
|
|
|
|
'pl_namespace',
|
|
|
|
|
'pl_title' ),
|
|
|
|
|
array( 'page_id=pl_from' ),
|
|
|
|
|
__METHOD__,
|
|
|
|
|
array( 'ORDER BY' => 'page_id' ) );
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
$lastPage = null;
|
2010-05-22 16:50:39 +00:00
|
|
|
foreach ( $result as $row ) {
|
|
|
|
|
if ( $lastPage != $row->page_id ) {
|
|
|
|
|
if ( isset( $lastPage ) ) {
|
2009-08-02 19:35:17 +00:00
|
|
|
$this->output( "\n" );
|
|
|
|
|
}
|
|
|
|
|
$page = Title::makeTitle( $row->page_namespace, $row->page_title );
|
|
|
|
|
$this->output( $page->getPrefixedUrl() );
|
|
|
|
|
$lastPage = $row->page_id;
|
|
|
|
|
}
|
|
|
|
|
$link = Title::makeTitle( $row->pl_namespace, $row->pl_title );
|
2009-08-02 21:31:23 +00:00
|
|
|
$this->output( " " . $link->getPrefixedUrl() );
|
2005-10-31 09:57:38 +00:00
|
|
|
}
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( isset( $lastPage ) )
|
2009-08-02 19:35:17 +00:00
|
|
|
$this->output( "\n" );
|
2005-10-31 09:57:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
$maintClass = "DumpLinks";
|
2011-01-13 22:58:55 +00:00
|
|
|
require_once( RUN_MAINTENANCE_IF_MAIN );
|
2007-06-29 01:19:14 +00:00
|
|
|
|