Location: PHPKode > projects > Aukyla Platform > plugins/SearchGatewayInterfaces/Google.php
     Google.php, Google Search Gateway
     Copyright (C) 2005 Arend van Beelen, Auton Rijnsburg

     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.,
     59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

     For any questions, comments or whatever, you may mail me at: hide@address.com


class Google_SearchGatewayInterface implements SearchGatewayInterface
	public function __construct()

		$config = new Config('google');
		$this->webKey      = $config->variable('webKey');
		$this->topic       = $config->variable('topic');
		$this->adultFilter = $config->variable('enableAdultFilter', 'false');

		if($this->webKey == '' ||
		   $this->webKey == 'your_google_webkey')
			trigger_error('No Google Web Key set in config/google.conf');

		$this->client = new SoapClient(AUKYLA_DIR.'/data/plugins/SearchGatewayInterfaces/Google/GoogleSearch.wsdl');

	public function name()
		return i18n('Google Search');

	public function search($keywords, $maxResults, $offset)
		if($this->webKey == '' ||
		   $this->webKey == 'your_google_webkey')
			return array();

		$results = $this->client->doGoogleSearch($this->webKey,
		                                         implode(' ', $keywords),

		$searchResults = array();
		foreach($results->resultElements as $result)
			$searchResult = new SearchResult();
			$searchResult->application = 'Google';
			$searchResult->uri = $result->URL;
			$searchResult->fromGateway = true;
			$searchResult->title = $result->title;
			$searchResult->summary = $result->snippet;
			$searchResult->mimeType = 'text/html';
			$searchResult->metaData = array();
			$searchResult->score = 1;
			$searchResult->flags = 0;
			$searchResults[] = $searchResult;

		return $searchResults;

	private $client;
	private $webKey;
	private $topic;
	private $adultFilter;

Return current item: Aukyla Platform