Index: branches/querypage-work2/extensions/ProofreadPage/ProofreadPage.php |
— | — | @@ -28,9 +28,10 @@ |
29 | 29 | |
30 | 30 | |
31 | 31 | # special page |
32 | | -$wgAutoloadClasses['ProofreadPages'] = $dir . 'SpecialProofreadPages.php'; |
33 | | -$wgSpecialPages['IndexPages'] = 'ProofreadPages'; |
| 32 | +$wgAutoloadClasses['IndexPagesPage'] = $dir . 'SpecialProofreadPages.php'; |
| 33 | +$wgSpecialPages['IndexPages'] = 'IndexPagesPage'; |
34 | 34 | $wgSpecialPageGroups['IndexPages'] = 'pages'; |
| 35 | +$wgQueryPages['IndexPagesPage'] = 'IndexPages'; |
35 | 36 | |
36 | 37 | # Bump the version number every time you change proofread.js |
37 | 38 | $wgProofreadPageVersion = 26; |
Index: branches/querypage-work2/extensions/ProofreadPage/SpecialProofreadPages.php |
— | — | @@ -4,21 +4,15 @@ |
5 | 5 | * @ingroup SpecialPage |
6 | 6 | */ |
7 | 7 | |
8 | | - |
9 | | -if ( !defined( 'MEDIAWIKI' ) ) die( 1 ); |
10 | | -global $wgHooks, $IP; |
11 | | -require_once "$IP/includes/QueryPage.php"; |
12 | | - |
13 | | - |
14 | | -class ProofreadPages extends SpecialPage { |
15 | | - |
16 | | - function ProofreadPages() { |
17 | | - SpecialPage::SpecialPage( 'IndexPages' ); |
| 8 | +class IndexPagesPage extends QueryPage { |
| 9 | + public function __construct() { |
| 10 | + SpecialPage::__construct( 'IndexPages' ); |
18 | 11 | } |
19 | 12 | |
20 | | - function execute( $parameters ) { |
| 13 | + public function execute( $parameters ) { |
21 | 14 | global $wgOut, $wgRequest, $wgDisableTextSearch; |
22 | 15 | |
| 16 | + wfLoadExtensionMessages( 'ProofreadPage' ); |
23 | 17 | $this->setHeaders(); |
24 | 18 | list( $limit, $offset ) = wfCheckLimits(); |
25 | 19 | $wgOut->addWikiText( wfMsgForContentNoTrans( 'proofreadpage_specialpage_text' ) ); |
— | — | @@ -49,22 +43,40 @@ |
50 | 44 | } |
51 | 45 | } |
52 | 46 | } |
53 | | - $cnl = new ProofreadPagesQuery( $searchList, $searchTerm ); |
54 | | - $cnl->doQuery( $offset, $limit ); |
| 47 | + parent::execute( $parameters ); |
55 | 48 | } |
56 | | -} |
57 | 49 | |
58 | | -class ProofreadPagesQuery extends QueryPage { |
59 | | - function ProofreadPagesQuery( $searchList, $searchTerm ) { |
60 | | - $this->searchList = $searchList; |
61 | | - $this->searchTerm = $searchTerm; |
| 50 | + public function getQueryInfo() { |
| 51 | + $conds = array(); |
| 52 | + if ( $this->searchTerm ) { |
| 53 | + if ( $this->searchList ) { |
| 54 | + $index_namespace = pr_index_ns(); |
| 55 | + $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( $index_namespace ) ); |
| 56 | + $conds = array( 'page_namespace' => $index_ns_index, 'page_title' => $this->searchList ); |
| 57 | + } else { |
| 58 | + $conds = array( 'false' ); // FIXME: This is ugly |
| 59 | + } |
| 60 | + } |
| 61 | + return array( |
| 62 | + 'tables' => array( 'pr_index', 'page' ), |
| 63 | + 'fields' => array( 'page_title AS title', 'pr_count', |
| 64 | + 'pr_q0', 'pr_q1', 'pr_q2' ,'pr_q3', 'pr_q4' ), |
| 65 | + 'conds' => $conds, |
| 66 | + 'options' => array(), |
| 67 | + 'join_conds' => array( 'page' => array( 'LEFT JOIN', 'page_id=pr_page_id' ) ) |
| 68 | + ); |
62 | 69 | } |
63 | 70 | |
64 | | - function getName() { |
65 | | - return 'IndexPages'; |
| 71 | + public function getOrderFields() { |
| 72 | + return array( '2*pr_q4+pr_q3' ); // FIXME: This causes a filesort |
66 | 73 | } |
67 | 74 | |
| 75 | + public function sortDescending() { |
| 76 | + return true; |
| 77 | + } |
| 78 | + |
68 | 79 | function isExpensive() { |
| 80 | + // FIXME: the query does filesort, so we're kinda lying here right now |
69 | 81 | return false; |
70 | 82 | } |
71 | 83 | |
— | — | @@ -72,45 +84,6 @@ |
73 | 85 | return false; |
74 | 86 | } |
75 | 87 | |
76 | | - function linkParameters() { |
77 | | - return array( 'key'=> $this->searchTerm ); |
78 | | - } |
79 | | - |
80 | | - function getSQL() { |
81 | | - $dbr = wfGetDB( DB_SLAVE ); |
82 | | - $page = $dbr->tableName( 'page' ); |
83 | | - $pr_index = $dbr->tableName( 'pr_index' ); |
84 | | - |
85 | | - $query = "SELECT page_title as title, |
86 | | - pr_count,pr_q0,pr_q1,pr_q2,pr_q3,pr_q4 |
87 | | - FROM $pr_index LEFT JOIN $page ON page_id = pr_page_id"; |
88 | | - |
89 | | - if( $this->searchTerm ) { |
90 | | - if( $this->searchList ) { |
91 | | - $index_namespace = pr_index_ns() ; |
92 | | - $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( $index_namespace ) ); |
93 | | - $querylist = ''; |
94 | | - foreach( $this->searchList as $item ) { |
95 | | - if( $querylist ) $querylist .= ', '; |
96 | | - $querylist .= "'" . $dbr->strencode( $item ). "'"; |
97 | | - } |
98 | | - $query .= " WHERE page_namespace=$index_ns_index AND page_title IN ($querylist)"; |
99 | | - } else { |
100 | | - $query .= " WHERE false"; |
101 | | - } |
102 | | - } |
103 | | - return $query; |
104 | | - } |
105 | | - |
106 | | - function getOrder() { |
107 | | - return ' ORDER BY 2*pr_q4+pr_q3 ' . |
108 | | - ($this->sortDescending() ? 'DESC' : ''); |
109 | | - } |
110 | | - |
111 | | - function sortDescending() { |
112 | | - return true; |
113 | | - } |
114 | | - |
115 | 88 | function formatResult( $skin, $result ) { |
116 | 89 | global $wgLang; |
117 | 90 | |