Index: trunk/extensions/ProofreadPage/SpecialPagesWithoutScans.php |
— | — | @@ -42,7 +42,6 @@ |
43 | 43 | function __construct() { |
44 | 44 | wfLoadExtensionMessages( 'ProofreadPage' ); |
45 | 45 | $this->page_namespace = preg_quote( wfMsgForContent( 'proofreadpage_namespace' ), '/' ); |
46 | | - $this->cat = wfMsgForContent( 'proofreadpage_notnaked_category' ); |
47 | 46 | } |
48 | 47 | |
49 | 48 | function getName() { |
— | — | @@ -57,24 +56,69 @@ |
58 | 57 | return false; |
59 | 58 | } |
60 | 59 | |
| 60 | + /* |
| 61 | + * return a clause with the list of disambiguation templates. |
| 62 | + * this function was copied verbatim from specials/SpecialDisambiguations.php |
| 63 | + */ |
| 64 | + function disambiguation_templates( $dbr ) { |
| 65 | + $dMsgText = wfMsgForContent('disambiguationspage'); |
| 66 | + |
| 67 | + $linkBatch = new LinkBatch; |
| 68 | + |
| 69 | + # If the text can be treated as a title, use it verbatim. |
| 70 | + # Otherwise, pull the titles from the links table |
| 71 | + $dp = Title::newFromText($dMsgText); |
| 72 | + if( $dp ) { |
| 73 | + if($dp->getNamespace() != NS_TEMPLATE) { |
| 74 | + # FIXME we assume the disambiguation message is a template but |
| 75 | + # the page can potentially be from another namespace :/ |
| 76 | + wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n"); |
| 77 | + } |
| 78 | + $linkBatch->addObj( $dp ); |
| 79 | + } else { |
| 80 | + # Get all the templates linked from the Mediawiki:Disambiguationspage |
| 81 | + $disPageObj = Title::makeTitleSafe( NS_MEDIAWIKI, 'disambiguationspage' ); |
| 82 | + $res = $dbr->select( |
| 83 | + array('pagelinks', 'page'), |
| 84 | + 'pl_title', |
| 85 | + array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE, |
| 86 | + 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()), |
| 87 | + __METHOD__ ); |
| 88 | + |
| 89 | + while ( $row = $dbr->fetchObject( $res ) ) { |
| 90 | + $linkBatch->addObj( Title::makeTitle( NS_TEMPLATE, $row->pl_title )); |
| 91 | + } |
| 92 | + |
| 93 | + $dbr->freeResult( $res ); |
| 94 | + } |
| 95 | + return $linkBatch->constructSet( 'tl', $dbr ); |
| 96 | + } |
| 97 | + |
61 | 98 | function getSQL() { |
62 | 99 | global $wgContentNamespaces; |
63 | 100 | |
64 | 101 | $dbr = wfGetDB( DB_SLAVE ); |
65 | 102 | $page = $dbr->tableName( 'page' ); |
66 | 103 | $templatelinks = $dbr->tableName( 'templatelinks' ); |
67 | | - $categorylinks = $dbr->tableName( 'categorylinks' ); |
68 | 104 | $forceindex = $dbr->useIndexClause( 'page_len' ); |
69 | 105 | $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( $this->page_namespace ) ); |
70 | | - $cat = $dbr->strencode( str_replace( ' ' , '_' , $this->cat ) ); |
71 | | - $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' )"; |
72 | 106 | |
73 | | - return |
74 | | - "SELECT page_namespace as namespace, |
75 | | - page_title as title, |
76 | | - page_len AS value |
| 107 | + /* SQL clause to exclude pages with scans */ |
| 108 | + $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 . " ) "; |
| 109 | + |
| 110 | + /* Exclude disambiguation pages too */ |
| 111 | + $dt = $this->disambiguation_templates( $dbr ); |
| 112 | + $disambiguation_pages = "( SELECT page_id FROM $page LEFT JOIN $templatelinks ON page_id=tl_from WHERE page_namespace=" . NS_MAIN . " AND " . $dt . " )"; |
| 113 | + |
| 114 | + $sql = "SELECT page_namespace as namespace, |
| 115 | + page_title as title, |
| 116 | + page_len AS value |
77 | 117 | FROM $page $forceindex |
78 | | - WHERE $clause"; |
| 118 | + WHERE page_namespace=" . NS_MAIN . " AND page_is_redirect=0 |
| 119 | + AND page_id NOT IN $pages_with_scans |
| 120 | + AND page_id NOT IN $disambiguation_pages"; |
| 121 | + |
| 122 | + return $sql; |
79 | 123 | } |
80 | 124 | |
81 | 125 | function sortDescending() { |