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