diff options
author | Wushin <pasekei@gmail.com> | 2016-03-13 23:40:54 -0500 |
---|---|---|
committer | Wushin <pasekei@gmail.com> | 2016-03-13 23:40:54 -0500 |
commit | 2c772426573df493c3d88c77417e5dc55935b946 (patch) | |
tree | 0afee89be43ef3fd2dbca7c2689a942a9fe94e74 /extensions/GoogleSiteSearch/GoogleSiteSearch.php | |
parent | 85292f0cb64bb3b39f70cbbb86718dafe2bf206a (diff) | |
parent | d197654c7ea92593f88ec0f4bd06d2441bf430f0 (diff) | |
download | website-2c772426573df493c3d88c77417e5dc55935b946.tar.gz website-2c772426573df493c3d88c77417e5dc55935b946.tar.bz2 website-2c772426573df493c3d88c77417e5dc55935b946.tar.xz website-2c772426573df493c3d88c77417e5dc55935b946.zip |
Merge pull request #19 from wushin/tmwa-1.26.2-wikimedia
Tmwa 1.26.2 wikimedia
Diffstat (limited to 'extensions/GoogleSiteSearch/GoogleSiteSearch.php')
-rw-r--r-- | extensions/GoogleSiteSearch/GoogleSiteSearch.php | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/extensions/GoogleSiteSearch/GoogleSiteSearch.php b/extensions/GoogleSiteSearch/GoogleSiteSearch.php deleted file mode 100644 index c2d70c5..0000000 --- a/extensions/GoogleSiteSearch/GoogleSiteSearch.php +++ /dev/null @@ -1,107 +0,0 @@ -<?php -/** \file -* \brief Contains setup code for the GoogleSiteSearch Extension. -*/ - -/** - * GoogleSiteSearch Extension for MediaWiki - * - * Copyright (C) Ryan Finnie - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - */ - -# Not a valid entry point, skip unless MEDIAWIKI is defined -if ( !defined( 'MEDIAWIKI' ) ) { - echo <<<EOT -To install my extension, put the following line in LocalSettings.php: -require_once( "$IP/extensions/GoogleSiteSearch/GoogleSiteSearch.php" ); -EOT; - exit( 1 ); -} - -$wgExtensionCredits['specialpage'][] = array( - 'path' => __FILE__, - 'name' => 'GoogleSiteSearch', - 'author' => 'Ryan Finnie', - 'url' => 'https://www.mediawiki.org/wiki/Extension:GoogleSiteSearch', - 'descriptionmsg' => 'googlesitesearch-desc', - 'version' => '2.2', -); - -# Default configuration globals -if ( !isset( $wgGoogleSiteSearchCSEID ) ) { - $wgGoogleSiteSearchCSEID = ''; -} -if ( !isset( $wgGoogleSiteSearchOnly ) ) { - $wgGoogleSiteSearchOnly = false; -} -if ( !isset( $wgGoogleSiteSearchCharset ) ) { - $wgGoogleSiteSearchCharset = 'UTF-8'; -} - -$dir = dirname( __FILE__ ) . '/'; - -# Define internationalizations -$wgMessagesDirs['GoogleSiteSearch'] = __DIR__ . '/i18n'; -$wgExtensionMessagesFiles['GoogleSiteSearch'] = $dir . 'GoogleSiteSearch.i18n.php'; - -# Hook into SpecialSearchResultsPrepend (MW 1.21+) -$wgHooks['SpecialSearchResultsPrepend'][] = 'GoogleSiteSearch'; - -function GoogleSiteSearch( $t, $out, $term ) { - global $wgGoogleSiteSearchCSEID; - global $wgGoogleSiteSearchOnly; - global $wgGoogleSiteSearchCharset; - - # Return immediately if the CSE ID is not configured - if ( !$wgGoogleSiteSearchCSEID ) { - return true; - } - - # Return immediately if no search term was supplied - if ( !$term ) { - return true; - } - - $dir = dirname( __FILE__ ) . '/'; - $lang = $t->getLang(); - - # Allow for local overrides of the base HTML - if ( file_exists( $dir . 'GoogleSiteSearch.content.html' ) ) { - $outhtml = file_get_contents ( $dir . 'GoogleSiteSearch.content.html' ); - } else { - $outhtml = file_get_contents ( $dir . 'GoogleSiteSearch.content.default.html' ); - } - - # Replace variable data in the HTML - $outhtml = str_replace( '_GSS_CSE_ID_', FormatJson::encode( $wgGoogleSiteSearchCSEID ), $outhtml ); - $outhtml = str_replace( '_GSS_TERM_ESCAPE_', FormatJson::encode( $term ), $outhtml ); - $outhtml = str_replace( '_GSS_LANG_', FormatJson::encode( $lang->getCode() ), $outhtml ); - $outhtml = str_replace( '_GSS_LOADING_', htmlentities( wfMessage( 'googlesitesearch-loading', $wgGoogleSiteSearchCharset ) ), $outhtml ); - - # Add it! - $out->addWikiText( '== ' . wfMessage( 'googlesitesearch-google-results' ) . ' ==' ); - $out->AddHTML( $outhtml ); - - # Do not return wiki results if configured that way - if ( $wgGoogleSiteSearchOnly ) { - return false; - } else { - $out->addWikiText( '== ' . wfMessage( 'googlesitesearch-wiki-results' ) . ' ==' ); - return true; - } -} |