Index: trunk/extensions/InterwikiList/InterwikiList_body.php |
— | — | @@ -9,6 +9,9 @@ |
10 | 10 | |
11 | 11 | class InterwikiList extends SpecialPage { |
12 | 12 | |
| 13 | + // Privates |
| 14 | + private $mTitle; // The title for this specialpage |
| 15 | + |
13 | 16 | /** |
14 | 17 | * Constructor |
15 | 18 | */ |
— | — | @@ -21,34 +24,51 @@ |
22 | 25 | * Execute |
23 | 26 | */ |
24 | 27 | public function execute( $par ) { |
25 | | - global $wgOut; |
| 28 | + global $wgOut, $wgRequest; |
26 | 29 | $wgOut->setPagetitle( wfMsg( 'interwikilist' ) ); |
27 | | - $selfTitle = Title::makeTitle( NS_SPECIAL, 'InterwikiList' ); |
28 | | - $wgOut->addHTML( $this->getInterwikis() ); |
| 30 | + $this->mTitle = SpecialPage::getTitleFor( 'InterwikiList' ); |
| 31 | + $prefix = $wgRequest->getText( 'iwsearch', $par ); |
| 32 | + $wgOut->addHTML( $this->getInterwikis( $prefix ) ); |
29 | 33 | } |
30 | 34 | |
31 | 35 | /** |
32 | 36 | * Get all Interwiki Links - the heart of the function |
| 37 | + * @param $prefix string Prefix to search for in list |
| 38 | + * @return string HTML |
33 | 39 | */ |
34 | | - private function getInterwikis() { |
| 40 | + private function getInterwikis( $prefix = null ) { |
| 41 | + global $wgScript; |
35 | 42 | $dbr = wfGetDB( DB_SLAVE ); |
36 | | - |
37 | | - $results = $dbr->select( 'interwiki', array( 'iw_prefix', 'iw_url' ) ); |
38 | | - |
39 | | - $text = Xml::openElement( 'table', array( 'id' => 'sv-software' ) ) . "<tr> |
40 | | - <th>" . wfMsg( 'interwikilist-linkname' ) . "</th> |
41 | | - <th>" . wfMsg( 'interwikilist-target' ) . "</th> |
42 | | - </tr>\n"; |
43 | | - |
| 43 | + |
| 44 | + $conds = array(); |
| 45 | + if ( !is_null( $prefix ) ) { |
| 46 | + $conds[] = "iw_prefix LIKE " . $dbr->addQuotes( $dbr->escapeLike( $prefix ) . "%" ); |
| 47 | + } |
| 48 | + |
| 49 | + $results = $dbr->select( 'interwiki', array( 'iw_prefix', 'iw_url' ), $conds ); |
| 50 | + |
| 51 | + $form = Xml::openElement( 'form', array( 'action' => $wgScript, 'method' => 'get', 'id' => 'interwikilist-search' ) ) . |
| 52 | + Xml::hidden( 'title', $this->mTitle->getPrefixedText() ) . |
| 53 | + Xml::inputLabel( wfMsg('interwikilist-prefix'), 'iwsearch', 'interwikilist-prefix', false, $prefix ) . |
| 54 | + Xml::submitButton( wfMsg('search') ) . |
| 55 | + Xml::closeElement( 'form' ); |
| 56 | + $text = Xml::fieldSet( wfMsg('interwikilist-filter'), $form ); |
| 57 | + |
| 58 | + $text .= Xml::openElement( 'table', array( 'id' => 'sv-software' ) ) . |
| 59 | + Xml::openElement( 'tr' ) . |
| 60 | + Xml::element( 'th', null, wfMsg( 'interwikilist-linkname' ) ) . |
| 61 | + Xml::element( 'th', null, wfMsg( 'interwikilist-target' ) ) . |
| 62 | + Xml::closeElement( 'tr' );; |
| 63 | + |
44 | 64 | while ( $row = $dbr->fetchObject( $results ) ) { |
45 | | - $text .= " <tr> |
46 | | - <td>" . htmlspecialchars( $row->iw_prefix ) . "</td> |
47 | | - <td>" . htmlspecialchars( $row->iw_url ) . "</td> |
48 | | - </tr>\n"; |
| 65 | + $text .= Xml::openElement( 'tr' ) . |
| 66 | + Xml::element( 'td', null, $row->iw_prefix ) . |
| 67 | + Xml::element( 'td', null, $row->iw_url ) . |
| 68 | + Xml::closeElement( 'tr' ); |
49 | 69 | } |
50 | | - $text .= "</table>\n"; |
| 70 | + $text .= Xml::closeElement( 'table' ); |
51 | 71 | $dbr->freeResult( $results ); |
52 | | - |
| 72 | + |
53 | 73 | return $text; |
54 | 74 | } |
55 | | -} |
\ No newline at end of file |
| 75 | +} |
Index: trunk/extensions/InterwikiList/InterwikiList.i18n.php |
— | — | @@ -9,6 +9,8 @@ |
10 | 10 | 'interwikilist-desc' => 'Adds a [[Special:Interwikilist|special page]] to view available interwiki links', |
11 | 11 | 'interwikilist-linkname' => 'Interwiki link', |
12 | 12 | 'interwikilist-target' => 'Target URL', |
| 13 | + 'interwikilist-filter' => 'Filter list', |
| 14 | + 'interwikilist-prefix' => 'Interwiki prefix:', |
13 | 15 | ); |
14 | 16 | |
15 | 17 | /** Message documentation (Message documentation) |
Index: trunk/extensions/InterwikiList/InterwikiList.php |
— | — | @@ -13,11 +13,11 @@ |
14 | 14 | */ |
15 | 15 | |
16 | 16 | $wgExtensionCredits['specialpage'][] = array( |
17 | | - 'name' => 'Interwiki List', |
18 | | - 'version' => '0.2', |
19 | | - 'url' => 'http://mediawiki.org/wiki/Extension:InterwikiList', |
| 17 | + 'name' => 'Interwiki List', |
| 18 | + 'version' => '0.3', |
| 19 | + 'url' => 'http://mediawiki.org/wiki/Extension:InterwikiList', |
20 | 20 | 'description' => 'Adds a [[Special:Interwikilist|special page]] to view available interwiki links', |
21 | | - 'author' => '[mailto:innocentkiller@gmail.com Chad Horohoe]', |
| 21 | + 'author' => '[mailto:innocentkiller@gmail.com Chad Horohoe]', |
22 | 22 | 'descriptionmsg' => 'interwikilist-desc', |
23 | 23 | ); |
24 | 24 | |