Index: DrupalGoogleMini.php =================================================================== RCS file: /cvs/drupal/contributions/modules/google_appliance/DrupalGoogleMini.php,v retrieving revision 1.1.4.2 diff -u -p -r1.1.4.2 DrupalGoogleMini.php --- DrupalGoogleMini.php 22 Jul 2009 09:11:49 -0000 1.1.4.2 +++ DrupalGoogleMini.php 20 Aug 2009 15:37:11 -0000 @@ -6,7 +6,6 @@ define('GOOGLE_MINI_MAX_RESULTS', variab include_once 'GoogleMini.php'; class DrupalGoogleMini extends GoogleMini { - var $cache = FALSE; function __construct($debug = FALSE, $debug_callback = NULL) { @@ -17,10 +16,14 @@ class DrupalGoogleMini extends GoogleMin if ($this->debug_callback) { $callback = $this->debug_callback; call_user_func($callback, $message); - } + } watchdog("google_appliance", $message); } + function getQueryParts() { + return $this->_queryParts; + } + function query($iteratorClass = 'GoogleMiniResultIterator') { if (!db_table_exists('cache_google_appliance')) { $this->cache = FALSE; Index: GoogleMini.php =================================================================== RCS file: /cvs/drupal/contributions/modules/google_appliance/GoogleMini.php,v retrieving revision 1.2.2.2 diff -u -p -r1.2.2.2 GoogleMini.php --- GoogleMini.php 22 Jul 2009 09:11:49 -0000 1.2.2.2 +++ GoogleMini.php 20 Aug 2009 15:37:11 -0000 @@ -12,7 +12,7 @@ class GoogleMini { public $baseUrl = ''; // REQUIRED public $frontEnd = ''; // IF SET WILL DISABLE parsing of results. public $collection = ''; // REQUIRED - private $_queryParts; + protected $_queryParts; public function __construct($debug = FALSE, $debug_callback = NULL) { @@ -83,7 +83,6 @@ class GoogleMini { } } - /** * Sets the languages to be used in the search, if none specified, searches all languages * @@ -161,7 +160,7 @@ class GoogleMini { * * @param string $keys */ - public function setKeywords($keys) { + public function setKeywords($keys) { if ($this->_queryParts['q']) { $this->_queryParts['q'] .= "%20". urlencode($keys); } else { @@ -249,8 +248,8 @@ class GoogleMini { * IMPORTANT! The new Version of the Mini uses parenthesis. * This will not work for older versions pre August 2008 (I believe). * - * If you are using one of these versions see the patch at: - * which will use the old + * If you are using one of these versions see the patch at: ? + * which will use the old ? * */ @@ -285,7 +284,6 @@ class GoogleMini { foreach ($this->_queryParts as $label => $value) { $query .= "&$label=$value"; } - $this->_query = $query; if ($this->debug) { $this->log($query); @@ -317,7 +315,6 @@ class GoogleMini { function resultFactory($resultXML, $className = 'GoogleMiniResultIterator') { $results = array(); - $payload = simplexml_load_string($resultXML); $totalResults = $payload->RES->M; Index: google_appliance.info =================================================================== RCS file: /cvs/drupal/contributions/modules/google_appliance/google_appliance.info,v retrieving revision 1.1.4.2 diff -u -p -r1.1.4.2 google_appliance.info --- google_appliance.info 22 Jul 2009 09:11:49 -0000 1.1.4.2 +++ google_appliance.info 20 Aug 2009 15:37:11 -0000 @@ -1,5 +1,5 @@ ; $Id: google_appliance.info,v 1.1.4.2 2009/07/22 09:11:49 larskleiner Exp $ name = "Google Search Appliance Integration" description = "Provides a search interface to a Google Mini or GSA, meta-data generators to allow for advanced search, and a class for talking to the appliance." -package = "Other" +package = "Google Search Appliance" core = 6.x \ No newline at end of file Index: google_appliance.module =================================================================== RCS file: /cvs/drupal/contributions/modules/google_appliance/google_appliance.module,v retrieving revision 1.1.4.2 diff -u -p -r1.1.4.2 google_appliance.module --- google_appliance.module 22 Jul 2009 09:11:49 -0000 1.1.4.2 +++ google_appliance.module 20 Aug 2009 15:37:12 -0000 @@ -37,7 +37,7 @@ function google_appliance_perm() { /** * Get selected config settings. */ -function _google_appliance_get_settings($reset = FALSE) { +function google_appliance_get_settings($reset = FALSE) { static $settings; if ($reset or empty($settings)) { $google_appliance_name = trim(variable_get('google_appliance_name', GOOGLE_APPLIANCE_NAME_DEFAULT)); @@ -86,7 +86,7 @@ function _google_appliance_get_settings( */ function google_appliance_menu() { // Get settings. - $settings = _google_appliance_get_settings(); + $settings = google_appliance_get_settings(); $google_appliance_name = $settings['google_appliance_name']; $default_client = $settings['default_client']; $default_collection = $settings['default_collection']; @@ -191,7 +191,7 @@ function google_appliance_local_task(&$i * Implementation of hook_menu_alter(). */ function google_appliance_menu_alter(&$items) { - $settings = _google_appliance_get_settings(); + $settings = google_appliance_get_settings(); $google_appliance_path = $settings['google_appliance_path']; // We have provided a replacement for the search.module's @@ -279,7 +279,7 @@ function google_appliance_catch_all_task if (!$client || !$collection) { return FALSE; } - $settings = _google_appliance_get_settings(); + $settings = google_appliance_get_settings(); foreach ($settings['tabs_array'] as $this_tab) { $tab = _google_appliance_explode_tab($this_tab); if ($tab['client'] == $client && $tab['collection'] == $collection) { @@ -539,7 +539,7 @@ function google_appliance_block($op = 'l */ function google_appliance_admin_settings() { // Get settings. - $settings = _google_appliance_get_settings(); + $settings = google_appliance_get_settings(); $google_appliance_name = $settings['google_appliance_name']; $google_appliance_path = $settings['google_appliance_path']; $default_client = $settings['default_client']; @@ -789,7 +789,7 @@ function google_appliance_admin_settings foreach ($fields as $field) { if ($form_state['values'][$field] != $form["config_init"][$field]['#default_value']) { drupal_set_message(t("Rebuilding menus.")); - _google_appliance_get_settings(TRUE); //reset + google_appliance_get_settings(TRUE); //reset menu_rebuild(); break; } @@ -815,9 +815,6 @@ function google_appliance_admin_settings */ function google_appliance_search($op = 'search', $keys = NULL, $options = array(), $collection = '', $client = '') { switch ($op) { - // case 'reset': - // case 'status': - // break; case 'name': return t(variable_get('google_appliance_name', GOOGLE_APPLIANCE_NAME_DEFAULT)); case 'search': @@ -835,7 +832,7 @@ function google_appliance_search($op = ' else { $gm = new DrupalGoogleMini(FALSE); } - + // Initialise the search object. $init = _google_appliance_search_initialise($gm, $client, $collection, $keys, $options); if ($init !== NULL) { @@ -847,11 +844,10 @@ function google_appliance_search($op = ' } } - /** * Initialise the search object */ -function _google_appliance_search_initialise(&$gm, $client, $collection, $keys, $options) { +function _google_appliance_search_initialise(&$gm, $client = NULL, $collection = NULL, $keys = NULL, $options = array()) { try { $gm->setOutputEncoding('utf8'); $gm->setInputEncoding('utf8'); @@ -935,7 +931,7 @@ function _google_appliance_search(&$gm) $gm->cache = TRUE; // Check the cache when calling $gm->query(). See DrupalGoogleMini.php } - $result_iterator = $gm->query(); + $result_iterator = $gm->query(); google_appliance_static_response_cache($result_iterator); // Store keymatches @@ -957,12 +953,13 @@ function _google_appliance_search(&$gm) and $total_results > GOOGLE_APPLIANCE_MAX_RESULTS_FOR_MINI) { $total_results = GOOGLE_APPLIANCE_MAX_RESULTS_FOR_MINI; } + $limit = $gm->getQueryPart('num'); $page = $gm->getQueryPart('start') / $limit; google_appliance_configure_pager($total_results, $page, $limit); // Process search results - foreach ($result_iterator as $key => $result) { + foreach ($result_iterator as $key => $result) { if (is_numeric($key)) { $result_array = theme('google_appliance_search_result_array', $result); $results[] = $result_array; @@ -975,8 +972,7 @@ function _google_appliance_search(&$gm) } drupal_set_message($e->getMessage()); return FALSE; - } - + } return $results; } @@ -1031,7 +1027,7 @@ function google_appliance_configure_page } if (is_null($limit)) { $limit = variable_get('google_appliance_limit_per_page', GOOGLE_APPLIANCE_RESULTS_PER_PAGE_DEFAULT); -} + } // Convert comma-separated $page to an array, used by other functions. $pager_page_array = explode(',', $page); @@ -1056,9 +1052,8 @@ function google_appliance_configure_page * @return * Themed search results. */ -function google_appliance_search_view($search_base, $client, $collection, $keys = NULL) { +function google_appliance_search_view($search_base, $client, $collection, $keys = NULL, $title = NULL) { $form = drupal_get_form('google_appliance_search_form', NULL, $search_base, $client, $collection, $keys); - // When POSTing back to an existing search-results page, the original // URL is accessed (which re-runs that search) and then the redirect for // the new search takes place and a second (correct) search is executed. @@ -1075,7 +1070,7 @@ function google_appliance_search_view($s 'keymatches' => google_appliance_cache_data('keymatches'), 'synonyms' => google_appliance_cache_data('synonyms'), ); - return theme('google_appliance_search_view', $search_view); + return theme('google_appliance_search_view', $search_view, $title); } else { return $form; @@ -1091,7 +1086,7 @@ function google_appliance_search_view($s * @return * Themed search results. */ -function theme_google_appliance_search_view($search_view) { +function theme_google_appliance_search_view($search_view, $title = 'Search results') { $output = ""; if (!empty($search_view['keys'])) { @@ -1103,7 +1098,7 @@ function theme_google_appliance_search_v // search.module is enabled. See google_appliance_theme() // and google_appliance_preprocess_search_results() $search_results = theme('search_results', $search_view['results'], 'google-appliance'); - $results = theme('box', t('Search results'), $search_results); + $results = theme('box', t($title), $search_results); } // Show any keymatches and/or synonyms found by the search. @@ -1178,7 +1173,7 @@ function theme_google_appliance_add_meta $meta_data[] = array('type', $node->type); // Author - $node->uid = empty($node->uid) ? 0: $node->uid; + $node->uid = empty($node->uid) ? 0 : $node->uid; $user = user_load(array('uid' => 0)); $meta_data[] = array('author', empty($user->name) ? 'anonymous' : $user->name); @@ -1224,7 +1219,7 @@ function theme_google_appliance_search_r // Meta data (from tags) $meta_data = array(); - if (isset($result->MT)) { + if (isset($result->MT)) { foreach ($result->MT as $meta) { $value = (string) $meta['V']; $name = (string) $meta['N']; @@ -1359,7 +1354,7 @@ function google_appliance_block_nogoogle * Define the search form. */ function google_appliance_search_form(&$form_state, $prompt = NULL, $search_base = NULL, $client = NULL, $collection = NULL, $keys = '') { - $settings = _google_appliance_get_settings(); + $settings = google_appliance_get_settings(); if (is_null($prompt)) { $prompt = t('Enter your keywords'); } @@ -1461,7 +1456,6 @@ function google_appliance_simpletest() { return array_keys($tests); } - /** * Common MIME types */