Index: branches/querypage-work/phase3/includes/specials/SpecialDisambiguations.php |
— | — | @@ -13,11 +13,11 @@ |
14 | 14 | return 'Disambiguations'; |
15 | 15 | } |
16 | 16 | |
17 | | - function isExpensive( ) { return true; } |
| 17 | + function isExpensive() { return true; } |
18 | 18 | function isSyndicated() { return false; } |
19 | 19 | |
20 | 20 | |
21 | | - function getPageHeader( ) { |
| 21 | + function getPageHeader() { |
22 | 22 | return wfMsgExt( 'disambiguations-text', array( 'parse' ) ); |
23 | 23 | } |
24 | 24 | |
— | — | @@ -77,11 +77,70 @@ |
78 | 78 | |
79 | 79 | return $sql; |
80 | 80 | } |
| 81 | + |
| 82 | + function getQueryInfo() { |
| 83 | + $dbr = wfGetDB( DB_SLAVE ); |
| 84 | + $dMsgText = wfMsgForContent('disambiguationspage'); |
| 85 | + $linkBatch = new LinkBatch; |
81 | 86 | |
82 | | - function getOrder() { |
83 | | - return ''; |
| 87 | + # If the text can be treated as a title, use it verbatim. |
| 88 | + # Otherwise, pull the titles from the links table |
| 89 | + $dp = Title::newFromText($dMsgText); |
| 90 | + if( $dp ) { |
| 91 | + if($dp->getNamespace() != NS_TEMPLATE) { |
| 92 | + # FIXME we assume the disambiguation message is a template but |
| 93 | + # the page can potentially be from another namespace :/ |
| 94 | + wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n"); |
| 95 | + } |
| 96 | + $linkBatch->addObj( $dp ); |
| 97 | + } else { |
| 98 | + # Get all the templates linked from the Mediawiki:Disambiguationspage |
| 99 | + $disPageObj = Title::makeTitleSafe( NS_MEDIAWIKI, 'disambiguationspage' ); |
| 100 | + $res = $dbr->select( |
| 101 | + array('pagelinks', 'page'), |
| 102 | + 'pl_title', |
| 103 | + array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE, |
| 104 | + 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()), |
| 105 | + __METHOD__ ); |
| 106 | + |
| 107 | + while ( $row = $dbr->fetchObject( $res ) ) { |
| 108 | + $linkBatch->addObj( Title::makeTitle( NS_TEMPLATE, $row->pl_title )); |
| 109 | + } |
| 110 | + |
| 111 | + $dbr->freeResult( $res ); |
| 112 | + } |
| 113 | + $set = $linkBatch->constructSet( 'tl', $dbr ); |
| 114 | + if( $set === false ) { |
| 115 | + # We must always return a valid SQL query, but this way |
| 116 | + # the DB will always quickly return an empty result |
| 117 | + $set = 'FALSE'; |
| 118 | + wfDebug("Mediawiki:disambiguationspage message does not link to any templates!\n"); |
| 119 | + } |
| 120 | + |
| 121 | + // FIXME: What are pagelinks and p2 doing here? |
| 122 | + return array ( |
| 123 | + 'tables' => array( 'templatelinks', 'page AS p1', 'pagelinks', 'page AS p2' ), |
| 124 | + 'fields' => array( "'{$this->getName()}' AS type", |
| 125 | + 'p1.page_namespace AS namespace', |
| 126 | + 'p1.page_title AS title', |
| 127 | + 'pl_from AS value' ), |
| 128 | + 'conds' => array( $set, |
| 129 | + 'p1.page_id = tl_from', |
| 130 | + 'pl_namespace = p1.page_namespace', |
| 131 | + 'pl_title = p1.page_title', |
| 132 | + 'p2.page_id = pl_from', |
| 133 | + 'p2.page_namespace' => NS_MAIN ) |
| 134 | + ); |
84 | 135 | } |
85 | 136 | |
| 137 | + function getOrderFields() { |
| 138 | + return array('tl_namespace', 'tl_title', 'value'); |
| 139 | + } |
| 140 | + |
| 141 | + function sortDescending() { |
| 142 | + return false; |
| 143 | + } |
| 144 | + |
86 | 145 | function formatResult( $skin, $result ) { |
87 | 146 | global $wgContLang; |
88 | 147 | $title = Title::newFromID( $result->value ); |
Index: branches/querypage-work/phase3/includes/specials/SpecialBrokenRedirects.php |
— | — | @@ -16,30 +16,13 @@ |
17 | 17 | return 'BrokenRedirects'; |
18 | 18 | } |
19 | 19 | |
20 | | - function isExpensive( ) { return true; } |
| 20 | + function isExpensive() { return true; } |
21 | 21 | function isSyndicated() { return false; } |
22 | 22 | |
23 | | - function getPageHeader( ) { |
| 23 | + function getPageHeader() { |
24 | 24 | return wfMsgExt( 'brokenredirectstext', array( 'parse' ) ); |
25 | 25 | } |
26 | 26 | |
27 | | - function getSQL() { |
28 | | - $dbr = wfGetDB( DB_SLAVE ); |
29 | | - list( $page, $redirect ) = $dbr->tableNamesN( 'page', 'redirect' ); |
30 | | - |
31 | | - $sql = "SELECT 'BrokenRedirects' AS type, |
32 | | - p1.page_namespace AS namespace, |
33 | | - p1.page_title AS title, |
34 | | - rd_namespace, |
35 | | - rd_title |
36 | | - FROM $redirect AS rd |
37 | | - JOIN $page p1 ON (rd.rd_from=p1.page_id) |
38 | | - LEFT JOIN $page AS p2 ON (rd_namespace=p2.page_namespace AND rd_title=p2.page_title ) |
39 | | - WHERE rd_namespace >= 0 |
40 | | - AND p2.page_namespace IS NULL"; |
41 | | - return $sql; |
42 | | - } |
43 | | - |
44 | 27 | function getQueryInfo() { |
45 | 28 | return array( |
46 | 29 | 'tables' => array( 'redirect', 'page AS p1', 'page AS p2' ), |
— | — | @@ -64,7 +47,8 @@ |
65 | 48 | ); |
66 | 49 | } |
67 | 50 | |
68 | | - function getOrder() { |
| 51 | + function getOrderFields() { |
| 52 | + // FIXME: really? |
69 | 53 | return array (); |
70 | 54 | } |
71 | 55 | |
Index: branches/querypage-work/phase3/includes/specials/SpecialDeadendpages.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | */ |
11 | 11 | class DeadendPagesPage extends PageQueryPage { |
12 | 12 | |
13 | | - function getName( ) { |
| 13 | + function getName() { |
14 | 14 | return "Deadendpages"; |
15 | 15 | } |
16 | 16 | |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | * |
24 | 24 | * @return true |
25 | 25 | */ |
26 | | - function isExpensive( ) { |
| 26 | + function isExpensive() { |
27 | 27 | return 1; |
28 | 28 | } |
29 | 29 | |
— | — | @@ -35,19 +35,6 @@ |
36 | 36 | return false; |
37 | 37 | } |
38 | 38 | |
39 | | - /** |
40 | | - * @return string an sqlquery |
41 | | - */ |
42 | | - function getSQL() { |
43 | | - $dbr = wfGetDB( DB_SLAVE ); |
44 | | - list( $page, $pagelinks ) = $dbr->tableNamesN( 'page', 'pagelinks' ); |
45 | | - return "SELECT 'Deadendpages' as type, page_namespace AS namespace, page_title as title, page_title AS value " . |
46 | | - "FROM $page LEFT JOIN $pagelinks ON page_id = pl_from " . |
47 | | - "WHERE pl_from IS NULL " . |
48 | | - "AND page_namespace = 0 " . |
49 | | - "AND page_is_redirect = 0"; |
50 | | - } |
51 | | - |
52 | 39 | function getQueryInfo() { |
53 | 40 | return array( |
54 | 41 | 'tables' => array( 'page', 'pagelinks' ), |