Index: API.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/google_cse_adv/API.txt,v
retrieving revision 1.1
diff -u -p -r1.1 API.txt
--- API.txt	21 Aug 2010 16:30:45 -0000	1.1
+++ API.txt	30 Sep 2010 02:03:59 -0000
@@ -20,3 +20,24 @@ function hook_google_cse_adv_execute($re
  *   - response (string)
  */
 function hook_google_cse_adv_filters($data)
+
+/**
+ * Allows modules to alter the search query parameters.
+ *
+ * Each key/value pair of the $options array will make up a separate
+ * query string parameter in the URL submitted to Google.
+ *
+ * The 'more' option (for labels) is a special case which is merged
+ * into the 'q' parameter in the query URL.
+ * e.g.: q=search+terms+more:label+name
+ *
+ * @param array &$options
+ *   The options which will constitute the query. Can be directly modified.
+ * @param array $initial
+ *   Any query options which were passed directly to google_cse_adv_execute().
+ *   These take precedence over the defaults.
+ * @param array $defaults
+ *   The default options used by the module in the absence of
+ *   an over-ride.
+ */
+function hook_google_cse_adv_options_alter(&$options, $initial, $defaults)
Index: google_cse_adv.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/google_cse_adv/google_cse_adv.module,v
retrieving revision 1.1.2.3
diff -u -p -r1.1.2.3 google_cse_adv.module
--- google_cse_adv.module	29 Sep 2010 06:16:54 -0000	1.1.2.3
+++ google_cse_adv.module	30 Sep 2010 02:03:59 -0000
@@ -222,9 +222,10 @@ function google_cse_adv_search($op = 'se
  * @param string $keys
  * @param int $page
  * @param bool $reset
+ * @param array $options
  * @return string
  */
-function google_cse_adv_execute($keys, $page, $reset = FALSE) {
+function google_cse_adv_execute($keys, $page, $reset = FALSE, $options = array()) {
   static $response = array(); // Cache
   if (isset($response[$keys]) && FALSE === $reset) {
     return $response[$keys];
@@ -232,21 +233,47 @@ function google_cse_adv_execute($keys, $
 
   // Number of results per page. 10 is the default for Google CSE.
   $rows = (int) variable_get('google_cse_adv_results_per_page', 10);
-  // Language interface.
-  $hl = google_cse_adv_param_hl();
-  // Language filtering.
-  $lr = google_cse_adv_param_lr();
-  $url = 'http://www.google.com/cse'
-		   . '?cx=' . urlencode(variable_get('google_cse_adv_cx', ''))
-		   . '&client=google-csbe'
-		   . '&output=xml_no_dtd'
-       . ($hl ? '&hl=' . urlencode($hl) : '')
-       . ($lr ? '&lr=' . urlencode($lr) : '')
-       . '&q=' . urlencode($keys)
-       .   (isset($_GET['more']) ? '+more:' . urlencode($_GET['more']) : '')
-       . '&num=' . urlencode($rows)
-       . '&start=' . urlencode($page * $rows);
 
+  // Default query options
+  $defaults = array(
+    'cx' => variable_get('google_cse_adv_cx', ''),
+    'client' => 'google-csbe',
+    'output' => 'xml_no_dtd',
+    'hl' => google_cse_adv_param_hl(), // Language interface
+    'lr' => google_cse_adv_param_lr(), // Language filtering
+    'q' => $keys,
+    'more' => isset($_GET['more']) ? $_GET['more'] : '', // Labels
+    'num' => $rows,
+    'start' => $page * $rows,
+  );
+  // Use defaults for any values unspecified by the $options argument
+  // Defaults which are false are omitted (e.g. hl, lr, more, start).
+  $initial = $options;
+  $options += array_filter($defaults);
+
+  // Allow other modules to make changes.
+  drupal_alter('google_cse_adv_options', $options, $initial, $defaults);
+
+  // Build the search URL
+  $options = array_map('urlencode', $options);
+
+  if (array_key_exists('more', $options)) {
+    if (!empty($options['q'])) {
+      $options['q'] .= '+more:' . $options['more'];
+    }
+    else {
+      $options['q'] = 'more:' . $options['more'];
+    }
+    unset($options['more']);
+  }
+
+  $query_parts = array();
+  foreach ($options as $option => $value) {
+    $query_parts[] = $option . '=' . $value;
+  }
+  $url = 'http://www.google.com/cse?' . join('&', $query_parts);
+
+  // Issue the search request
   $request = new stdClass();
   $request->url = $url;
 
