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,21 +24,38 @@ |
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> |
| 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 | + $text = "<fieldset>\n" . |
| 52 | + "<legend>" . wfMsg('interwikilist-filter') . "</legend>\n" . |
| 53 | + "<form action=\"". $wgScript . "\" method=\"get\" id=\"interwikilist-search\">\n" . |
| 54 | + "<input type=\"hidden\" name=\"title\" value=\"" . $this->mTitle->getPrefixedText() . "\">\n" . |
| 55 | + wfMsg('interwikilist-prefix') . " <input type=\"text\" name=\"iwsearch\" id=\"interwikilist-prefix\"><br />\n" . |
| 56 | + "<input type=\"submit\" value=\"" . wfMsg('search') . "\">\n" . |
| 57 | + "</form>\n</fieldset>"; |
| 58 | + |
| 59 | + $text .= "<table id=\"sv-software\"<tr> |
40 | 60 | <th>" . wfMsg( 'interwikilist-linkname' ) . "</th> |
41 | 61 | <th>" . wfMsg( 'interwikilist-target' ) . "</th> |
42 | 62 | </tr>\n"; |
— | — | @@ -48,7 +68,7 @@ |
49 | 69 | } |
50 | 70 | $text .= "</table>\n"; |
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 | /** Arabic (العربية) |
Index: trunk/extensions/InterwikiList/InterwikiList.php |
— | — | @@ -11,10 +11,10 @@ |
12 | 12 | * @author Chad Horohoe <innocentkiller@gmail.com> |
13 | 13 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
14 | 14 | */ |
15 | | - |
| 15 | + |
16 | 16 | $wgExtensionCredits['specialpage'][] = array( |
17 | 17 | 'name' => 'Interwiki List', |
18 | | - 'version' => '0.2', |
| 18 | + 'version' => '0.3', |
19 | 19 | 'url' => 'http://mediawiki.org/wiki/Extension:InterwikiList', |
20 | 20 | 'description' => 'Adds a [[Special:Interwikilist|special page]] to view available interwiki links', |
21 | 21 | 'author' => '[mailto:innocentkiller@gmail.com Chad Horohoe]', |
— | — | @@ -25,5 +25,4 @@ |
26 | 26 | $wgSpecialPages['InterwikiList'] = 'InterwikiList'; |
27 | 27 | $wgAutoloadClasses['InterwikiList'] = $dir . 'InterwikiList_body.php'; |
28 | 28 | $wgExtensionMessagesFiles['InterwikiList'] = $dir . 'InterwikiList.i18n.php'; |
29 | | -$wgExtensionAliasesFiles['InterwikiList'] = $dir . 'InterwikiList.alias.php'; |
30 | 29 | $wgSpecialPageGroups['InterwikiList'] = 'wiki'; |