tosfos has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/155616

Change subject: Require IContextSource
......................................................................

Require IContextSource

Change-Id: I5011952ae7acfc2bd25ab0096490000456623803
---
M GoogleCustomWikiSearch.class.php
M GoogleCustomWikiSearch.hooks.php
M GoogleCustomWikiSearch.php
M SpecialGoogleCustomWikiSearch.php
4 files changed, 9 insertions(+), 63 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GoogleCustomWikiSearch 
refs/changes/16/155616/1

diff --git a/GoogleCustomWikiSearch.class.php b/GoogleCustomWikiSearch.class.php
index c37d070..cba93f1 100644
--- a/GoogleCustomWikiSearch.class.php
+++ b/GoogleCustomWikiSearch.class.php
@@ -123,80 +123,26 @@
        }
 
        /**
-        * Set up all the inclusions needed for the search
-        * Inspired by ParserOptions
-        *
-        * @global OutputPage $wgOut
-        * @param OutputPage $out
-        * @param Language $lang
-        */
-       public function __construct( OutputPage $out = null, Language $lang = 
null ) {
-               if ( $out === null ) {
-                       global $wgOut;
-                       if ( $wgOut === null ) {
-                               $out = new OutputPage;
-                       } else {
-                               $out = $wgOut;
-                       }
-               }
-               if ( $lang === null ) {
-                       $lang = $out->getLanguage();
-               }
-
-               $this->initializeFromOutputPageAndLanguage( $out, $lang );
-       }
-
-       /**
-        * Get a GoogleCustomWikiSearch object from a IContextSource object
-        *
-        * @param IContextSource $context
-        * @return GoogleCustomWikiSearch
-        */
-       public static function newFromContext( IContextSource $context ) {
-               return new GoogleCustomWikiSearch( $context->getOutput(), 
$context->getLanguage() );
-       }
-
-       /**
-        * Get a GoogleCustomWikiSearch object from a given OutputPage
-        *
-        * @param OutputPage $out
-        * @return GoogleCustomWikiSearch
-        */
-       public static function newFromOutputPage( OutputPage $out ) {
-               return new GoogleCustomWikiSearch( $out, $out->getLanguage() );
-       }
-
-       /**
-        * Get a GoogleCustomWikiSearch object from a given OutputPage and 
Language
-        *
-        * @param OutputPage $out
-        * @param Language $lang
-        * @return GoogleCustomWikiSearch
-        */
-       public static function newFromOutputPageAndLanguage( OutputPage $out, 
Language $lang ) {
-               return new GoogleCustomWikiSearch( $out, $lang );
-       }
-
-       /**
-        * Set up the parameters to be inserted into the js
+        * Set up all the parameters needed for the search
         *
         * @global string $wgGoogleCustomWikiSearchId
         * @global string $wgGoogleCustomWikiSearchTheme
         * @global string $wgGoogleCustomWikiSearchOptions
         * @global int $wgGoogleCustomWikiSearchCodeVersion
+        * @param IContextSource $context
         */
-       private function initializeFromOutputPageAndLanguage( OutputPage $out, 
Language $lang ) {
+       public function __construct( IContextSource $context ) {
                global $wgGoogleCustomWikiSearchId, 
$wgGoogleCustomWikiSearchTheme,
                $wgGoogleCustomWikiSearchOptions, 
$wgGoogleCustomWikiSearchCodeVersion;
 
-               $this->out = $out;
-               $this->lang = $lang;
+               $this->out = $context->getOutput();
+               $this->lang = $context->getLanguage();
                $this->id = $wgGoogleCustomWikiSearchId;
                $this->theme = $wgGoogleCustomWikiSearchTheme;
                $this->options = $wgGoogleCustomWikiSearchOptions == '' ? 
$this->getDefaultOptions() :
                        $wgGoogleCustomWikiSearchOptions;
                $this->codeVersion = $wgGoogleCustomWikiSearchCodeVersion;
-               if ( $out->getTitle()->equals( SpecialPage::getTitleFor( 
'Search' ) ) ) {
+               if ( $context->getOutput()->getTitle()->equals( 
SpecialPage::getTitleFor( 'Search' ) ) ) {
                        $this->isOnSpecialSearch = true;
                }
        }
diff --git a/GoogleCustomWikiSearch.hooks.php b/GoogleCustomWikiSearch.hooks.php
index 7250c97..35bab05 100644
--- a/GoogleCustomWikiSearch.hooks.php
+++ b/GoogleCustomWikiSearch.hooks.php
@@ -47,7 +47,7 @@
                                $special->msg( 'googlecustomwikisearch' ) ) );
 
                // Set up the Google search
-               $googleCustomWikiSearch = 
GoogleCustomWikiSearch::newFromContext( $special->getContext() );
+               $googleCustomWikiSearch = new GoogleCustomWikiSearch( 
$special->getContext() );
 
                $request = $special->getRequest();
                $term = GoogleCustomWikiSearch::getSearchTerm( 
$request->getText( 'search' ), $par );
diff --git a/GoogleCustomWikiSearch.php b/GoogleCustomWikiSearch.php
index 66b6fb3..06369ac 100644
--- a/GoogleCustomWikiSearch.php
+++ b/GoogleCustomWikiSearch.php
@@ -10,7 +10,7 @@
        'author' => 'Ike Hecht for [http://wikiworks.com/ WikiWorks]',
        'url' => 
'https://www.mediawiki.org/wiki/Extension:GoogleCustomWikiSearch',
        'descriptionmsg' => 'gcws-desc',
-       'version' => '0.3.0 beta',
+       'version' => '0.4.0 beta',
 );
 
 $dir = __DIR__ . '/';
diff --git a/SpecialGoogleCustomWikiSearch.php 
b/SpecialGoogleCustomWikiSearch.php
index 40a5e7f..f177a89 100644
--- a/SpecialGoogleCustomWikiSearch.php
+++ b/SpecialGoogleCustomWikiSearch.php
@@ -33,7 +33,7 @@
 
                $this->setupPage( $term );
 
-               $googleCustomWikiSearch = 
GoogleCustomWikiSearch::newFromContext( $this->getContext() );
+               $googleCustomWikiSearch = new GoogleCustomWikiSearch( 
$this->getContext() );
                $googleCustomWikiSearch->doSearch( $term );
 
                $this->getOutput()->parserOptions()->setEditSection( false );

-- 
To view, visit https://gerrit.wikimedia.org/r/155616
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5011952ae7acfc2bd25ab0096490000456623803
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GoogleCustomWikiSearch
Gerrit-Branch: master
Gerrit-Owner: tosfos <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to