Index: trunk/extensions/IndexFunction/IndexFunction.i18n.php |
— | — | @@ -19,4 +19,5 @@ |
20 | 20 | 'index-disambig-start' => "'''$1''' may refer to several pages:", |
21 | 21 | 'index-exclude-categories' => '', # List of categories to exclude from the auto-disambig pages |
22 | 22 | 'index-missing-param' => 'This page cannot be used with no parameters', |
| 23 | + 'index-emptylist' => 'There are no pages associated with "$1"', |
23 | 24 | ); |
Index: trunk/extensions/IndexFunction/SpecialIndex.php |
— | — | @@ -38,7 +38,6 @@ |
39 | 39 | global $wgOut, $wgUser; |
40 | 40 | $sk = $wgUser->getSkin(); |
41 | 41 | $wgOut->setPagetitle( $t1->getPrefixedText() ); |
42 | | - $wgOut->addWikiMsg( 'index-disambig-start', $t1->getPrefixedText() ); |
43 | 42 | $dbr = wfGetDB( DB_SLAVE ); |
44 | 43 | $pages = $dbr->select( array('page', 'indexes'), |
45 | 44 | array( 'page_id', 'page_namespace', 'page_title' ), |
— | — | @@ -53,6 +52,14 @@ |
54 | 53 | $t = Title::newFromRow( $row ); |
55 | 54 | $list[strval($row->page_id)] = array( 'title' => $t, 'cats' => array() ); |
56 | 55 | } |
| 56 | + if (count($list) == 0) { |
| 57 | + $wgOut->addWikiMsg( 'index-emptylist', $t1->getPrefixedText() ); |
| 58 | + return; |
| 59 | + } elseif (count($list) == 1) { |
| 60 | + $target = reset( $list ); |
| 61 | + $wgOut->redirect( $target['title']->getLocalURL() ); |
| 62 | + } |
| 63 | + $wgOut->addWikiMsg( 'index-disambig-start', $t1->getPrefixedText() ); |
57 | 64 | $keys = array_keys( $list ); |
58 | 65 | $set = '(' . implode(',', $keys) . ')'; |
59 | 66 | |