'search/google', 'access' => user_access('search Google CSE'), 'title' => t('Google'), 'callback' => 'google_cse_results', 'type' => MENU_LOCAL_TASK, ); } } return $items; } /** * Admin settings page for the CSE. */ function google_cse_settings() { // http://drupal.org/node/64279#hook-settings $form = array(); $form['google_cse_cx'] = array( '#title' => t('Google Co-op Custom Search Engine ID'), '#type' => 'textfield', '#default_value' => variable_get('google_cse_cx', ''), '#description' => t('Enter your Google Co-op Custom Search Engine ID.'), ); $form['google_cse_results_display'] = array( '#title' => t('Display search results'), '#type' => 'radios', '#default_value' => variable_get('google_cse_results_display', 'here'), '#options' => array( 'here' => t('On this site (requires JavaScript)'), 'google' => t("On Google"), ), '#description' => t('Search results can be displayed on this site, using JavaScript, or on Google, which does not require JavaScript. Note: You can also configure your CSE at Google to have the iGoogle widget point to your site, but that will not work (see below). This setting only affects your own searchbox.'), ); $form['google_cse_results_title'] = array( '#title' => t('Search results page title'), '#type' => 'textfield', '#maxlength' => 50, '#size' => 60, '#description' => t('Enter the desired title of the page where the search results will be displayed. This has no effect if you do not display results on your own site.'), '#default_value' => variable_get('google_cse_results_title', t('Search')), ); $form['google_cse_searchbox_width'] = array( '#title' => t('Searchbox width'), '#type' => 'textfield', '#maxlength' => 4, '#size' => 6, '#description' => t('Enter the desired width, in characters, of the searchbox when displayed in a block.'), '#default_value' => variable_get('google_cse_searchbox_width', 15), ); /* $form['google_cse_results_searchbox_width'] = array( '#title' => t('Search results searchbox width'), '#type' => 'textfield', '#maxlength' => 4, '#size' => 6, '#description' => t('Enter the desired width, in characters, of the searchbox when displayed on the results page.'), '#default_value' => variable_get('google_cse_results_searchbox_width', 40), ); */ $form['google_cse_results_width'] = array( '#title' => t('Search results frame width'), '#type' => 'textfield', '#maxlength' => 4, '#size' => 6, '#description' => t('Enter the desired width, in pixels, of the search frame.'), '#default_value' => variable_get('google_cse_results_width', 600), ); $form['google_cse_results_gadget'] = array( '#title' => t('Search results "Add to Google" Google Gadget'), '#type' => 'radios', '#options' => array(t('Disabled'), t('Enabled')), '#default_value' => variable_get('google_cse_results_gadget', 1), '#description' => t('If enabled, an "Add to Google" button will be displayed above the search results. For this to function, you must not have configured your CSE results to appear on this site, because Drupal sites are not compatible with the "q" parameter. Search results will still appear on this site for searches originating here.'), ); $form['google_cse_domain'] = array( '#title' => t('Search domain'), '#type' => 'textfield', '#maxlength' => 64, '#description' => t('Enter the Google domain to use for search results, e.g. google.com.'), '#default_value' => variable_get('google_cse_domain', 'google.com'), ); return $form; //system_settings_form('google_cse_settings', $form); } function google_cse_block($op = 'list', $delta = 0, $edit = array()) { if ($op == 'list') { $blocks = array(); $blocks[0]['info'] = t('Google Co-op CSE'); return $blocks; } else if ($op == 'view' && user_access('search Google CSE')) { $block['content'] = theme('box', t('Search'), theme('google_cse_search_form')); return $block; } } function theme_google_cse_search_form() { $output = ''; $output .= '
'; return $output; } function google_cse_footer() { return ''; } /** * Display an Add-to-Google button. */ function google_cse_results_gadget() { if (variable_get('google_cse_results_gadget', 1) && $id = explode(':', variable_get('google_cse_cx', ''))) { $output = '
'; $output .= ''; $output .= 'Add to Google'; $output .= '
'; return $output; } else { return ''; } } /** * Render the search page and custom title. */ function google_cse_results() { drupal_set_title(variable_get('google_cse_results_title', t('Search'))); print theme('page', theme('google_cse_results')); } /** * The search results page can be themed/customized. */ function theme_google_cse_results() { $query = array( 'q' => $_GET['query'], 'cx' => variable_get('google_cse_cx', ''), 'cof' => 'FORID:0', ); //$output = drupal_get_form('searchbox', google_cse_searchbox_formbuilder('searchbox')); $output .= ''; $output .= '
'; $output .= '
'; return $output; } /** * Implementation of hook_perm(). */ function google_cse_perm() { return array('search Google CSE'); }