Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -1741,6 +1741,11 @@ |
1742 | 1742 | &$query_options: array of options for the database request |
1743 | 1743 | &$select: Array of columns to select |
1744 | 1744 | |
| 1745 | +'SpecialSearchCreateLink': called when making the message to create a page or |
| 1746 | +go to the existing page |
| 1747 | +$t: title object searched for |
| 1748 | +&$params: an array of the default message name and page title (as parameter) |
| 1749 | + |
1745 | 1750 | 'SpecialSearchGo': called when user clicked the "Go" |
1746 | 1751 | &$title: title object generated from the text entered by the user |
1747 | 1752 | &$term: the search term entered by the user |
— | — | @@ -1749,6 +1754,12 @@ |
1750 | 1755 | target doesn't exist |
1751 | 1756 | &$title: title object generated from the text entered by the user |
1752 | 1757 | |
| 1758 | +'SpecialSearchPowerBox': the equivalent of SpecialSearchProfileForm for |
| 1759 | +the advanced form, a.k.a. power search box |
| 1760 | +&$showSections: an array to add values with more options to |
| 1761 | +$term: the search term (not a title object) |
| 1762 | +$opts: an array of hidden options (containing 'redirs' and 'profile') |
| 1763 | + |
1753 | 1764 | 'SpecialSearchProfiles': allows modification of search profiles |
1754 | 1765 | &$profiles: profiles, which can be modified. |
1755 | 1766 | |
Index: trunk/phase3/includes/specials/SpecialSearch.php |
— | — | @@ -411,8 +411,11 @@ |
412 | 412 | $messageName = 'searchmenu-new-nocreate'; |
413 | 413 | } |
414 | 414 | } |
| 415 | + $params = array( $messageName, wfEscapeWikiText( $t->getPrefixedText() ) ); |
| 416 | + wfRunHooks( 'SpecialSearchCreateLink', array( $t, &$params ) ); |
| 417 | + |
415 | 418 | if( $messageName ) { |
416 | | - $this->getOutput()->wrapWikiMsg( "<p class=\"mw-search-createlink\">\n$1</p>", array( $messageName, wfEscapeWikiText( $t->getPrefixedText() ) ) ); |
| 419 | + $this->getOutput()->wrapWikiMsg( "<p class=\"mw-search-createlink\">\n$1</p>", $params ); |
417 | 420 | } else { |
418 | 421 | // preserve the paragraph for margins etc... |
419 | 422 | $this->getOutput()->addHtml( '<p></p>' ); |
— | — | @@ -871,13 +874,17 @@ |
872 | 875 | } |
873 | 876 | $namespaceTables .= Xml::closeElement( 'table' ); |
874 | 877 | } |
| 878 | + |
| 879 | + $showSections = array( 'namespaceTables' => $namespaceTables ); |
| 880 | + |
875 | 881 | // Show redirects check only if backend supports it |
876 | | - $redirects = ''; |
877 | 882 | if( $this->getSearchEngine()->supports( 'list-redirects' ) ) { |
878 | | - $redirects = |
| 883 | + $showSections['redirects'] = |
879 | 884 | Xml::checkLabel( wfMsg( 'powersearch-redir' ), 'redirs', 'redirs', $this->searchRedirects ); |
880 | 885 | } |
881 | 886 | |
| 887 | + wfRunHooks( 'SpecialSearchPowerBox', array( &$showSections, $term, $opts ) ); |
| 888 | + |
882 | 889 | $hidden = ''; |
883 | 890 | unset( $opts['redirs'] ); |
884 | 891 | foreach( $opts as $key => $value ) { |
— | — | @@ -913,9 +920,8 @@ |
914 | 921 | ) |
915 | 922 | ) . |
916 | 923 | Xml::element( 'div', array( 'class' => 'divider' ), '', false ) . |
917 | | - $namespaceTables . |
918 | | - Xml::element( 'div', array( 'class' => 'divider' ), '', false ) . |
919 | | - $redirects . $hidden . |
| 924 | + implode( Xml::element( 'div', array( 'class' => 'divider' ), '', false ), $showSections ) . |
| 925 | + $hidden . |
920 | 926 | Xml::closeElement( 'fieldset' ); |
921 | 927 | } |
922 | 928 | |
Index: trunk/extensions/WikimediaIncubator/WikimediaIncubator.php |
— | — | @@ -16,7 +16,7 @@ |
17 | 17 | 'path' => __FILE__, |
18 | 18 | 'name' => 'Wikimedia Incubator', |
19 | 19 | 'author' => 'SPQRobin', |
20 | | - 'version' => '4.4', |
| 20 | + 'version' => '4.5', |
21 | 21 | 'url' => 'http://www.mediawiki.org/wiki/Extension:WikimediaIncubator', |
22 | 22 | 'descriptionmsg' => 'wminc-desc', |
23 | 23 | ); |
— | — | @@ -149,3 +149,8 @@ |
150 | 150 | $wgHooks['SpecialListusersHeaderForm'][] = 'ListUsersTestWiki::onSpecialListusersHeaderForm'; |
151 | 151 | $wgHooks['SpecialListusersQueryInfo'][] = 'ListUsersTestWiki::onSpecialListusersQueryInfo'; |
152 | 152 | $wgHooks['SpecialListusersHeader'][] = 'ListUsersTestWiki::onSpecialListusersHeader'; |
| 153 | + |
| 154 | +/* Search in test wiki */ |
| 155 | +$wgHooks['SpecialSearchCreateLink'][] = 'IncubatorTest::onSpecialSearchCreateLink'; |
| 156 | +$wgHooks['SpecialSearchPowerBox'][] = 'IncubatorTest::onSpecialSearchPowerBox'; |
| 157 | +$wgHooks['SpecialSearchSetupEngine'][] = 'IncubatorTest::onSpecialSearchSetupEngine'; |
Index: trunk/extensions/WikimediaIncubator/IncubatorTest.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | $prefinsert[$wmincPref . '-code'] = array( |
37 | 37 | 'type' => 'text', |
38 | 38 | 'section' => 'personal/i18n', |
39 | | - 'label-message' => 'wminc-testwiki', |
| 39 | + 'label-message' => 'wminc-testwiki-code', |
40 | 40 | 'id' => $wmincPref . '-code', |
41 | 41 | 'maxlength' => (int)$wmincLangCodeLength, |
42 | 42 | 'size' => (int)$wmincLangCodeLength, |
— | — | @@ -695,6 +695,62 @@ |
696 | 696 | return true; |
697 | 697 | } |
698 | 698 | |
| 699 | + /** |
| 700 | + * Search: Adapt the default message to show a more descriptive one, |
| 701 | + * along with an adapted link. |
| 702 | + * @return true |
| 703 | + */ |
| 704 | + public static function onSpecialSearchCreateLink( $title, &$params ) { |
| 705 | + if( $title->isKnown() ) { |
| 706 | + return true; |
| 707 | + } |
| 708 | + global $wmincProjectSite, $wmincTestWikiNamespaces; |
| 709 | + $prefix = self::displayPrefix(); |
| 710 | + |
| 711 | + $newNs = $title->getNamespace(); |
| 712 | + $newTitle = $title->getText(); |
| 713 | + if( $prefix == $wmincProjectSite['short'] ) { |
| 714 | + $newNs = NS_PROJECT; |
| 715 | + } else { |
| 716 | + if( !in_array( $title->getNamespace(), $wmincTestWikiNamespaces ) ) { |
| 717 | + $newNs = $wmincTestWikiNamespaces[0]; # no "valid" NS, should be main NS |
| 718 | + } |
| 719 | + $newTitle = $prefix . '/' . $newTitle; |
| 720 | + } |
| 721 | + |
| 722 | + $t = Title::newFromText( $newTitle, $newNs ); |
| 723 | + if( $t->isKnown() ) { |
| 724 | + # use the default message if the suggested title exists |
| 725 | + $params[0] = 'searchmenu-exists'; |
| 726 | + $params[1] = wfEscapeWikiText( $t->getPrefixedText() ); |
| 727 | + return true; |
| 728 | + } |
| 729 | + $params[] = wfEscapeWikiText( $t->getPrefixedText() ); |
| 730 | + $params[0] = $prefix ? 'wminc-search-nocreate-suggest' :'wminc-search-nocreate-nopref'; |
| 731 | + return true; |
| 732 | + } |
| 733 | + |
| 734 | + /** |
| 735 | + * Search: Add an input form to enter a test wiki prefix. |
| 736 | + * @return true |
| 737 | + */ |
| 738 | + public static function onSpecialSearchPowerBox( &$showSections, $term, $opts ) { |
| 739 | + $showSections['testwiki'] = Xml::label( wfMsg( 'wminc-testwiki' ), 'testwiki' ) . ' ' . |
| 740 | + Xml::input( 'testwiki', 20, self::displayPrefix(), array( 'id' => 'testwiki' ) ); |
| 741 | + return true; |
| 742 | + } |
| 743 | + |
| 744 | + /** |
| 745 | + * Search: Search by default in the test wiki of the user's preference (or url &testwiki). |
| 746 | + * @return true |
| 747 | + */ |
| 748 | + public static function onSpecialSearchSetupEngine( $search, $profile, $engine ) { |
| 749 | + if( !isset( $search->prefix ) || !$search->prefix ) { |
| 750 | + $search->prefix = self::displayPrefix(); |
| 751 | + } |
| 752 | + return true; |
| 753 | + } |
| 754 | + |
699 | 755 | private static function preg_quote_slash( $str ) { |
700 | 756 | return preg_quote( $str, '/' ); |
701 | 757 | } |
Index: trunk/extensions/WikimediaIncubator/WikimediaIncubator.i18n.php |
— | — | @@ -16,6 +16,7 @@ |
17 | 17 | 'wminc-manual' => 'Manual', |
18 | 18 | 'wminc-listwikis' => 'List of wikis', |
19 | 19 | 'wminc-testwiki' => 'Test wiki:', |
| 20 | + 'wminc-testwiki-code' => 'Test wiki language:', |
20 | 21 | 'wminc-testwiki-none' => 'None/All', |
21 | 22 | 'wminc-recentchanges-all' => 'All recent changes', |
22 | 23 | |
— | — | @@ -57,6 +58,10 @@ |
58 | 59 | |
59 | 60 | # Special:ListUsers |
60 | 61 | 'wminc-listusers-testwiki' => 'You are viewing users who have set their test wiki preference to $1.', |
| 62 | + |
| 63 | + # Search |
| 64 | + 'wminc-search-nocreate-nopref' => 'You searched for "$1". Please set your [[Special:Preferences|test wiki preference]] so we can tell you which page you can create!', |
| 65 | + 'wminc-search-nocreate-suggest' => 'You searched for "$1". You can create a page in your wiki at <b>[[$2]]</b>!', |
61 | 66 | ); |
62 | 67 | |
63 | 68 | /** Message documentation (Message documentation) |