http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73891
Revision: 73891
Author: thomasv
Date: 2010-09-28 14:43:24 +0000 (Tue, 28 Sep 2010)
Log Message:
-----------
instead of defining a custom category, use disambiguation pages.
Modified Paths:
--------------
trunk/extensions/ProofreadPage/SpecialPagesWithoutScans.php
Modified: trunk/extensions/ProofreadPage/SpecialPagesWithoutScans.php
===================================================================
--- trunk/extensions/ProofreadPage/SpecialPagesWithoutScans.php 2010-09-28
14:27:02 UTC (rev 73890)
+++ trunk/extensions/ProofreadPage/SpecialPagesWithoutScans.php 2010-09-28
14:43:24 UTC (rev 73891)
@@ -42,7 +42,6 @@
function __construct() {
wfLoadExtensionMessages( 'ProofreadPage' );
$this->page_namespace = preg_quote( wfMsgForContent(
'proofreadpage_namespace' ), '/' );
- $this->cat = wfMsgForContent( 'proofreadpage_notnaked_category'
);
}
function getName() {
@@ -57,24 +56,69 @@
return false;
}
+ /*
+ * return a clause with the list of disambiguation templates.
+ * this function was copied verbatim from
specials/SpecialDisambiguations.php
+ */
+ function disambiguation_templates( $dbr ) {
+ $dMsgText = wfMsgForContent('disambiguationspage');
+
+ $linkBatch = new LinkBatch;
+
+ # If the text can be treated as a title, use it verbatim.
+ # Otherwise, pull the titles from the links table
+ $dp = Title::newFromText($dMsgText);
+ if( $dp ) {
+ if($dp->getNamespace() != NS_TEMPLATE) {
+ # FIXME we assume the disambiguation message is
a template but
+ # the page can potentially be from another
namespace :/
+ wfDebug("Mediawiki:disambiguationspage message
does not refer to a template!\n");
+ }
+ $linkBatch->addObj( $dp );
+ } else {
+ # Get all the templates linked from the
Mediawiki:Disambiguationspage
+ $disPageObj = Title::makeTitleSafe(
NS_MEDIAWIKI, 'disambiguationspage' );
+ $res = $dbr->select(
+ array('pagelinks', 'page'),
+ 'pl_title',
+ array('page_id = pl_from',
'pl_namespace' => NS_TEMPLATE,
+ 'page_namespace' =>
$disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()),
+ __METHOD__ );
+
+ while ( $row = $dbr->fetchObject( $res ) ) {
+ $linkBatch->addObj( Title::makeTitle(
NS_TEMPLATE, $row->pl_title ));
+ }
+
+ $dbr->freeResult( $res );
+ }
+ return $linkBatch->constructSet( 'tl', $dbr );
+ }
+
function getSQL() {
global $wgContentNamespaces;
$dbr = wfGetDB( DB_SLAVE );
$page = $dbr->tableName( 'page' );
$templatelinks = $dbr->tableName( 'templatelinks' );
- $categorylinks = $dbr->tableName( 'categorylinks' );
$forceindex = $dbr->useIndexClause( 'page_len' );
$page_ns_index = MWNamespace::getCanonicalIndex( strtolower(
$this->page_namespace ) );
- $cat = $dbr->strencode( str_replace( ' ' , '_' , $this->cat ) );
- $clause = "page_namespace=" . NS_MAIN . " AND
page_is_redirect=0 AND page_id NOT IN ( SELECT DISTINCT tl_from FROM
$templatelinks LEFT JOIN $page ON page_id=tl_from WHERE
tl_namespace=$page_ns_index AND page_namespace=" . NS_MAIN . " ) AND page_id
NOT IN ( SELECT DISTINCT cl_from FROM $categorylinks WHERE cl_to='$cat' )";
- return
- "SELECT page_namespace as namespace,
- page_title as title,
- page_len AS value
+ /* SQL clause to exclude pages with scans */
+ $pages_with_scans = "( SELECT DISTINCT tl_from FROM
$templatelinks LEFT JOIN $page ON page_id=tl_from WHERE
tl_namespace=$page_ns_index AND page_namespace=" . NS_MAIN . " ) ";
+
+ /* Exclude disambiguation pages too */
+ $dt = $this->disambiguation_templates( $dbr );
+ $disambiguation_pages = "( SELECT page_id FROM $page LEFT JOIN
$templatelinks ON page_id=tl_from WHERE page_namespace=" . NS_MAIN . " AND " .
$dt . " )";
+
+ $sql = "SELECT page_namespace as namespace,
+ page_title as title,
+ page_len AS value
FROM $page $forceindex
- WHERE $clause";
+ WHERE page_namespace=" . NS_MAIN . " AND
page_is_redirect=0
+ AND page_id NOT IN $pages_with_scans
+ AND page_id NOT IN $disambiguation_pages";
+
+ return $sql;
}
function sortDescending() {
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs