MediaWiki
REL1_19
|
00001 <?php 00032 require_once( dirname( __FILE__ ) . '/Maintenance.php' ); 00033 00034 class DumpLinks extends Maintenance { 00035 public function __construct() { 00036 parent::__construct(); 00037 $this->mDescription = "Quick demo hack to generate a plaintext link dump"; 00038 } 00039 00040 public function execute() { 00041 $dbr = wfGetDB( DB_SLAVE ); 00042 $result = $dbr->select( array( 'pagelinks', 'page' ), 00043 array( 00044 'page_id', 00045 'page_namespace', 00046 'page_title', 00047 'pl_namespace', 00048 'pl_title' ), 00049 array( 'page_id=pl_from' ), 00050 __METHOD__, 00051 array( 'ORDER BY' => 'page_id' ) ); 00052 00053 $lastPage = null; 00054 foreach ( $result as $row ) { 00055 if ( $lastPage != $row->page_id ) { 00056 if ( isset( $lastPage ) ) { 00057 $this->output( "\n" ); 00058 } 00059 $page = Title::makeTitle( $row->page_namespace, $row->page_title ); 00060 $this->output( $page->getPrefixedUrl() ); 00061 $lastPage = $row->page_id; 00062 } 00063 $link = Title::makeTitle( $row->pl_namespace, $row->pl_title ); 00064 $this->output( " " . $link->getPrefixedUrl() ); 00065 } 00066 if ( isset( $lastPage ) ) 00067 $this->output( "\n" ); 00068 } 00069 } 00070 00071 $maintClass = "DumpLinks"; 00072 require_once( RUN_MAINTENANCE_IF_MAIN ); 00073