2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
*
|
2004-09-03 23:00:01 +00:00
|
|
|
* @package MediaWiki
|
|
|
|
|
* @subpackage SpecialPage
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2003-05-16 11:19:06 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
require_once ( 'QueryPage.php' ) ;
|
I was adding a special page (dead-end pages), and I realized that almost all
the special query pages were pretty much identical. I copy-and-pasted one to
make the one I was working on, and I realized that that was Wrong.
So, I took the common elements and made them into a class, QueryPage.php.
Then, I derived each of the existing special pages from QueryPage, and
overrode places where they differed. This is a Recipe pattern, btw, for
those of you following along at home.
Anyways, the upshot is that the query pages are a lot shorter, with just the
essentials that make them different from other query pages, and there's one
place to make big UI changes for all queries.
2003-12-01 16:04:35 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
*
|
2004-09-03 23:00:01 +00:00
|
|
|
* @package MediaWiki
|
|
|
|
|
* @subpackage SpecialPage
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
I was adding a special page (dead-end pages), and I realized that almost all
the special query pages were pretty much identical. I copy-and-pasted one to
make the one I was working on, and I realized that that was Wrong.
So, I took the common elements and made them into a class, QueryPage.php.
Then, I derived each of the existing special pages from QueryPage, and
overrode places where they differed. This is a Recipe pattern, btw, for
those of you following along at home.
Anyways, the upshot is that the query pages are a lot shorter, with just the
essentials that make them different from other query pages, and there's one
place to make big UI changes for all queries.
2003-12-01 16:04:35 +00:00
|
|
|
class WantedPagesPage extends QueryPage {
|
2004-01-25 02:27:49 +00:00
|
|
|
|
|
|
|
|
function getName() {
|
2004-09-02 23:28:24 +00:00
|
|
|
return 'Wantedpages';
|
2004-01-25 02:27:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isExpensive() {
|
2004-05-09 01:30:34 +00:00
|
|
|
return true;
|
2004-01-25 02:27:49 +00:00
|
|
|
}
|
2004-11-13 20:40:28 +00:00
|
|
|
function isSyndicated() { return false; }
|
2004-01-25 02:27:49 +00:00
|
|
|
|
2004-05-09 01:30:34 +00:00
|
|
|
function getSQL() {
|
2004-07-18 08:48:43 +00:00
|
|
|
$dbr =& wfGetDB( DB_SLAVE );
|
2005-05-26 10:23:36 +00:00
|
|
|
$pagelinks = $dbr->tableName( 'pagelinks' );
|
|
|
|
|
$page = $dbr->tableName( 'page' );
|
2004-05-09 01:30:34 +00:00
|
|
|
return
|
2005-05-26 10:23:36 +00:00
|
|
|
"SELECT 'Wantedpages' AS type,
|
|
|
|
|
pl_namespace AS namespace,
|
|
|
|
|
pl_title AS title,
|
|
|
|
|
COUNT(*) AS value
|
|
|
|
|
FROM $pagelinks
|
|
|
|
|
LEFT JOIN $page
|
|
|
|
|
ON pl_namespace=page_namespace AND pl_title=page_title
|
|
|
|
|
WHERE page_namespace IS NULL
|
|
|
|
|
GROUP BY pl_namespace,pl_title
|
|
|
|
|
HAVING COUNT(*) > 1";
|
2004-10-14 04:55:06 +00:00
|
|
|
}
|
2004-09-09 12:10:58 +00:00
|
|
|
|
2004-01-25 02:27:49 +00:00
|
|
|
function formatResult( $skin, $result ) {
|
2004-09-24 16:45:31 +00:00
|
|
|
global $wgContLang;
|
2004-01-25 02:27:49 +00:00
|
|
|
|
2005-05-26 10:23:36 +00:00
|
|
|
$nt = Title::makeTitle( $result->namespace, $result->title );
|
|
|
|
|
$text = $wgContLang->convert( $nt->getPrefixedText() );
|
2005-05-02 03:18:31 +00:00
|
|
|
$plink = $skin->makeBrokenLink( $nt->getPrefixedText(), $text );
|
2005-05-26 10:23:36 +00:00
|
|
|
|
2004-05-09 01:30:34 +00:00
|
|
|
$nl = wfMsg( "nlinks", $result->value );
|
2004-09-24 16:45:31 +00:00
|
|
|
$nlink = $skin->makeKnownLink( $wgContLang->specialPage( "Whatlinkshere" ), $nl,
|
2004-01-25 02:27:49 +00:00
|
|
|
"target=" . $nt->getPrefixedURL() );
|
|
|
|
|
|
|
|
|
|
return "{$plink} ({$nlink})";
|
|
|
|
|
}
|
I was adding a special page (dead-end pages), and I realized that almost all
the special query pages were pretty much identical. I copy-and-pasted one to
make the one I was working on, and I realized that that was Wrong.
So, I took the common elements and made them into a class, QueryPage.php.
Then, I derived each of the existing special pages from QueryPage, and
overrode places where they differed. This is a Recipe pattern, btw, for
those of you following along at home.
Anyways, the upshot is that the query pages are a lot shorter, with just the
essentials that make them different from other query pages, and there's one
place to make big UI changes for all queries.
2003-12-01 16:04:35 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* constructor
|
|
|
|
|
*/
|
|
|
|
|
function wfSpecialWantedpages() {
|
2004-01-25 02:27:49 +00:00
|
|
|
list( $limit, $offset ) = wfCheckLimits();
|
|
|
|
|
|
|
|
|
|
$wpp = new WantedPagesPage();
|
|
|
|
|
|
|
|
|
|
$wpp->doQuery( $offset, $limit );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|