r38749 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38748‎ | r38749 | r38750 >
Date:04:19, 7 August 2008
Author:demon
Status:old
Tags:
Comment:
Now with search.
Modified paths:
  • /trunk/extensions/InterwikiList/InterwikiList.i18n.php (modified) (history)
  • /trunk/extensions/InterwikiList/InterwikiList.php (modified) (history)
  • /trunk/extensions/InterwikiList/InterwikiList_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/InterwikiList/InterwikiList_body.php
@@ -9,6 +9,9 @@
1010
1111 class InterwikiList extends SpecialPage {
1212
 13+ // Privates
 14+ private $mTitle; // The title for this specialpage
 15+
1316 /**
1417 * Constructor
1518 */
@@ -21,21 +24,38 @@
2225 * Execute
2326 */
2427 public function execute( $par ) {
25 - global $wgOut;
 28+ global $wgOut, $wgRequest;
2629 $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 ) );
2933 }
3034
3135 /**
3236 * Get all Interwiki Links - the heart of the function
 37+ * @param $prefix string Prefix to search for in list
 38+ * @return string HTML
3339 */
34 - private function getInterwikis() {
 40+ private function getInterwikis( $prefix = null ) {
 41+ global $wgScript;
3542 $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>
4060 <th>" . wfMsg( 'interwikilist-linkname' ) . "</th>
4161 <th>" . wfMsg( 'interwikilist-target' ) . "</th>
4262 </tr>\n";
@@ -48,7 +68,7 @@
4969 }
5070 $text .= "</table>\n";
5171 $dbr->freeResult( $results );
52 -
 72+
5373 return $text;
5474 }
55 -}
\ No newline at end of file
 75+}
Index: trunk/extensions/InterwikiList/InterwikiList.i18n.php
@@ -9,6 +9,8 @@
1010 'interwikilist-desc' => 'Adds a [[Special:Interwikilist|special page]] to view available interwiki links',
1111 'interwikilist-linkname' => 'Interwiki link',
1212 'interwikilist-target' => 'Target URL',
 13+ 'interwikilist-filter' => 'Filter list',
 14+ 'interwikilist-prefix' => 'Interwiki prefix:',
1315 );
1416
1517 /** Arabic (العربية)
Index: trunk/extensions/InterwikiList/InterwikiList.php
@@ -11,10 +11,10 @@
1212 * @author Chad Horohoe <innocentkiller@gmail.com>
1313 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1414 */
15 -
 15+
1616 $wgExtensionCredits['specialpage'][] = array(
1717 'name' => 'Interwiki List',
18 - 'version' => '0.2',
 18+ 'version' => '0.3',
1919 'url' => 'http://mediawiki.org/wiki/Extension:InterwikiList',
2020 'description' => 'Adds a [[Special:Interwikilist|special page]] to view available interwiki links',
2121 'author' => '[mailto:innocentkiller@gmail.com Chad Horohoe]',
@@ -25,5 +25,4 @@
2626 $wgSpecialPages['InterwikiList'] = 'InterwikiList';
2727 $wgAutoloadClasses['InterwikiList'] = $dir . 'InterwikiList_body.php';
2828 $wgExtensionMessagesFiles['InterwikiList'] = $dir . 'InterwikiList.i18n.php';
29 -$wgExtensionAliasesFiles['InterwikiList'] = $dir . 'InterwikiList.alias.php';
3029 $wgSpecialPageGroups['InterwikiList'] = 'wiki';

Follow-up revisions

RevisionCommit summaryAuthorDate
r38944Revert r38749, 38750 - prefix search on InterwikiList extension...brion20:34, 8 August 2008

Status & tagging log