* Fix missing search box contents in MonoBook skin
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 7 Jan 2005 03:25:49 +0000 (03:25 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 7 Jan 2005 03:25:49 +0000 (03:25 +0000)
* Add option to forward search directly to an external URL (eg google)
* Add parser test for bug 1219 URL next to image

includes/DefaultSettings.php
includes/SkinTemplate.php
includes/SpecialSearch.php
maintenance/parserTests.txt
skins/MonoBook.php

index 231a875..1457612 100644 (file)
@@ -994,6 +994,19 @@ $wgLivePreview = false;
  */
 $wgDisableInternalSearch = false;
 
+/**
+ * Set this to a URL to forward search requests to some external location.
+ * If the URL includes '$1', this will be replaced with the URL-encoded
+ * search term.
+ * 
+ * For example, to forward to Google you'd have something like:
+ * $wgSearchForwardUrl = 'http://www.google.com/search?q=$1' .
+ *                       '&domains=http://example.com' .
+ *                       '&sitesearch=http://example.com' .
+ *                       '&ie=utf-8&oe=utf-8';
+ */
+$wgSearchForwardUrl = null;
+
 } else {
        die();
 }
index 6eedc08..0c2f812 100644 (file)
@@ -229,6 +229,7 @@ class SkinTemplate extends Skin {
                $tpl->set( "helppage", wfMsg('helppage'));
                */
                $tpl->set( 'searchaction', $this->escapeSearchLink() );
+               $tpl->set( 'search', trim( $wgRequest->getVal( 'search' ) ) );
                $tpl->setRef( 'stylepath', $wgStylePath );
                $tpl->setRef( 'logopath', $wgLogo );
                $tpl->setRef( "lang", $wgContLanguageCode );
index bebbfd2..948b789 100644 (file)
@@ -133,6 +133,12 @@ class SpecialSearch {
                
                global $wgDisableTextSearch;
                if ( $wgDisableTextSearch ) {
+                       global $wgForwardSearchUrl;
+                       if( $wgForwardSearchUrl ) {
+                               $url = str_replace( '$1', urlencode( $term ), $wgForwardSearchUrl );
+                               $wgOut->redirect( $url );
+                               return;
+                       }
                        global $wgInputEncoding;
                        $wgOut->addHTML( wfMsg( 'searchdisabled' ) );
                        $wgOut->addHTML( wfMsg( 'googlesearch',
index 23bf77b..47abe9b 100644 (file)
@@ -1767,6 +1767,25 @@ title=[[Parser test script]]
 
 !! end
 
+
+!! test
+Bug 1219 URL next to image (good)
+!! input
+http://example.com [[Image:foobar.jpg]]
+!! result
+<p><a href="http://example.com" class='external'>http://example.com</a> <a href="/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img src="/images/3/3a/Foobar.jpg" alt="Image:foobar.jpg" longdesc="/wiki/Image:Foobar.jpg" /></a>
+</p>
+!!end
+
+!! test
+Bug 1219 URL next to image (broken)
+!! input
+http://example.com[[Image:foobar.jpg]]
+!! result
+<p><a href="http://example.com" class='external'>http://example.com</a><a href="/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img src="/images/3/3a/Foobar.jpg" alt="Image:foobar.jpg" longdesc="/wiki/Image:Foobar.jpg" /></a>
+</p>
+!!end
+
 TODO:
 more images
 more tables
index ba1d50f..88c29aa 100644 (file)
@@ -128,7 +128,9 @@ class MonoBookTemplate extends QuickTemplate {
            <form name="searchform" action="<?php $this->text('searchaction') ?>" id="searchform">
              <input id="searchInput" name="search" type="text"
                <?php if($this->haveMsg('accesskey-search')) {
-                 ?>accesskey="<?php $this->msg('accesskey-search') ?>"<?php } ?> />
+                 ?>accesskey="<?php $this->msg('accesskey-search') ?>"<?php }
+               if( isset( $this->data['search'] ) ) {
+                 ?>value="<?php $this->text('search') ?>"<?php } ?> />
              <input type='submit' name="go" class="searchButton"
                value="<?php $this->msg('go') ?>"
                />&nbsp;<input type='submit' name="fulltext"