MediaWiki REL1_30
dumpLinks.php
Go to the documentation of this file.
1<?php
33require_once __DIR__ . '/Maintenance.php';
34
40class DumpLinks extends Maintenance {
41 public function __construct() {
42 parent::__construct();
43 $this->addDescription( 'Quick demo hack to generate a plaintext link dump' );
44 }
45
46 public function execute() {
47 $dbr = $this->getDB( DB_REPLICA );
48 $result = $dbr->select( [ 'pagelinks', 'page' ],
49 [
50 'page_id',
51 'page_namespace',
52 'page_title',
53 'pl_namespace',
54 'pl_title' ],
55 [ 'page_id=pl_from' ],
56 __METHOD__,
57 [ 'ORDER BY' => 'page_id' ] );
58
59 $lastPage = null;
60 foreach ( $result as $row ) {
61 if ( $lastPage != $row->page_id ) {
62 if ( $lastPage !== null ) {
63 $this->output( "\n" );
64 }
65 $page = Title::makeTitle( $row->page_namespace, $row->page_title );
66 $this->output( $page->getPrefixedURL() );
67 $lastPage = $row->page_id;
68 }
69 $link = Title::makeTitle( $row->pl_namespace, $row->pl_title );
70 $this->output( " " . $link->getPrefixedURL() );
71 }
72 if ( $lastPage !== null ) {
73 $this->output( "\n" );
74 }
75 }
76}
77
78$maintClass = "DumpLinks";
79require_once RUN_MAINTENANCE_IF_MAIN;
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
addDescription( $text)
Set the description text.
if(! $regexes) $dbr
Definition cleanup.php:94
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:2989
require_once RUN_MAINTENANCE_IF_MAIN
const DB_REPLICA
Definition defines.php:25