Index: trunk/extensions/ProofreadPage/ProofreadPage.i18n.php |
— | — | @@ -68,6 +68,8 @@ |
69 | 69 | <td ><span id=pr_index style=\"visibility:hidden;\">$7</span></td> |
70 | 70 | </tr></table>", |
71 | 71 | 'proofreadpage_pages' => "{{PLURAL:$1|page|pages}}", |
| 72 | + 'proofreadpage_specialpage_text' => '', |
| 73 | + 'proofreadpage_specialpage_legend' => 'Search index pages', |
72 | 74 | ); |
73 | 75 | |
74 | 76 | /** Message documentation (Message documentation) |
Index: trunk/extensions/ProofreadPage/SpecialProofreadPages.php |
— | — | @@ -17,10 +17,39 @@ |
18 | 18 | } |
19 | 19 | |
20 | 20 | function execute( $parameters ) { |
| 21 | + global $wgOut, $wgRequest, $wgDisableTextSearch; |
| 22 | + |
21 | 23 | $this->setHeaders(); |
22 | 24 | list( $limit, $offset ) = wfCheckLimits(); |
23 | | - |
24 | | - $cnl = new ProofreadPagesQuery(); |
| 25 | + $wgOut->addWikiText( wfMsgForContentNoTrans( 'proofreadpage_specialpage_text' ) ); |
| 26 | + $searchList = array(); |
| 27 | + if( ! $wgDisableTextSearch ) { |
| 28 | + $searchTerm = $wgRequest->getText( 'key' ); |
| 29 | + $wgOut->addHTML( |
| 30 | + Xml::openElement( 'form' ) . |
| 31 | + Xml::openElement( 'fieldset' ) . |
| 32 | + Xml::element( 'legend', null, wfMsg( 'proofreadpage_specialpage_legend' ) ) . |
| 33 | + Xml::input( 'key', 20, $searchTerm ) . ' ' . |
| 34 | + Xml::submitButton( wfMsg( 'ilsubmit' ) ) . |
| 35 | + Xml::closeElement( 'fieldset' ) . |
| 36 | + Xml::closeElement( 'form' ) |
| 37 | + ); |
| 38 | + if( $searchTerm ) { |
| 39 | + $index_namespace = pr_index_ns() ; |
| 40 | + $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( $index_namespace ) ); |
| 41 | + $searchEngine = SearchEngine::create(); |
| 42 | + $searchEngine->setLimitOffset( $limit, $offset ); |
| 43 | + $searchEngine->setNamespaces( array( $index_ns_index ) ); |
| 44 | + $searchEngine->showRedirects = false; |
| 45 | + $textMatches = $searchEngine->searchText( $searchTerm ); |
| 46 | + while( $result = $textMatches->next() ) { |
| 47 | + if ( preg_match( "/^$index_namespace:(.*)$/", $result->getTitle(), $m ) ) { |
| 48 | + array_push( $searchList, str_replace( ' ' , '_' , $m[1] ) ); |
| 49 | + } |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | + $cnl = new ProofreadPagesQuery( $searchList ); |
25 | 54 | $cnl->doQuery( $offset, $limit ); |
26 | 55 | } |
27 | 56 | } |
— | — | @@ -29,6 +58,10 @@ |
30 | 59 | |
31 | 60 | class ProofreadPagesQuery extends QueryPage { |
32 | 61 | |
| 62 | + function ProofreadPagesQuery( $searchList ) { |
| 63 | + $this->searchList = $searchList; |
| 64 | + } |
| 65 | + |
33 | 66 | function getName() { |
34 | 67 | return 'IndexPages'; |
35 | 68 | } |
— | — | @@ -46,17 +79,24 @@ |
47 | 80 | $page = $dbr->tableName( 'page' ); |
48 | 81 | $pr_index = $dbr->tableName( 'pr_index' ); |
49 | 82 | |
50 | | - return |
51 | | - "SELECT pr_page_id as title, |
52 | | - page_title as title, |
53 | | - pr_count, |
54 | | - pr_q0, |
55 | | - pr_q1, |
56 | | - pr_q2, |
57 | | - pr_q3, |
58 | | - pr_q4 |
59 | | - FROM $pr_index |
60 | | - LEFT JOIN $page ON page_id = pr_page_id"; |
| 83 | + if( $this->searchList ) { |
| 84 | + $index_namespace = pr_index_ns() ; |
| 85 | + $index_ns_index = MWNamespace::getCanonicalIndex( strtolower( $index_namespace ) ); |
| 86 | + $querylist = ''; |
| 87 | + foreach( $this->searchList as $item ) { |
| 88 | + if( $querylist ) $querylist .= ', '; |
| 89 | + $querylist .= "'" . $dbr->strencode( $item ). "'"; |
| 90 | + } |
| 91 | + $query = "SELECT page_title as title, |
| 92 | + pr_count,pr_q0,pr_q1,pr_q2,pr_q3,pr_q4 |
| 93 | + FROM $pr_index LEFT JOIN $page ON page_id = pr_page_id |
| 94 | + WHERE page_namespace=$index_ns_index AND page_title IN ($querylist)"; |
| 95 | + } else { |
| 96 | + $query = "SELECT page_title as title, |
| 97 | + pr_count,pr_q0,pr_q1,pr_q2,pr_q3,pr_q4 |
| 98 | + FROM $pr_index LEFT JOIN $page ON page_id = pr_page_id"; |
| 99 | + } |
| 100 | + return $query; |
61 | 101 | } |
62 | 102 | |
63 | 103 | function getOrder() { |