You are here

function google_appliance_admin_settings in Google Search Appliance 6.2

Same name and namespace in other branches
  1. 5 google_appliance.module \google_appliance_admin_settings()
  2. 7 google_appliance.admin.inc \google_appliance_admin_settings()

google_appliance module configuration form.

1 string reference to 'google_appliance_admin_settings'
google_appliance_menu in ./google_appliance.module
Implementation of hook_menu().

File

./google_appliance.module, line 551
Google Search Appliance (GSA) / Google Mini integration

Code

function google_appliance_admin_settings() {

  // 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'];
  $default_collection = $settings['default_collection'];
  $search_tabs = $settings['search_tabs'];
  $default_tab_enabled = $settings['default_tab_enabled'];
  $default_search_path = $settings['default_search_path'];
  $form = array();
  $introduction = <<<END_INTRO
    <p>This module provides two ways of accessing search results
    from your Google Appliance:</p>
    <ol>
      <li>search/<i>tab path</i>/<i>search terms...</i></li>
      <li>google-appliance/<i>client</i>/<i>collection</i>/<i>search terms...</i></li>
    </ol>
    <p>The former integrates with the standard search module
    if it is enabled, and replaces it otherwise. It provides a
    search tab for the default client and collection, and also
    for any additional 'Search tabs' defined.</p>
    <p>The latter provides the same set of tabs, but will also
    work with any valid client and collection combination, even
    if a search tab has not been defined (provided that permission
    to do this has been assigned).</p>
    <p>All search result themeing is done via the standard search
    module themes (even when the search module is disabled).</p>
    <p>See the README.txt file for more information.</p>
END_INTRO;

  // Introduction
  $form["introduction"] = array(
    "#type" => "markup",
    "#value" => t($introduction),
    "#weight" => -2,
  );

  // initial required config fields
  $form["config_init"] = array(
    "#title" => t("Initial Configuration"),
    "#type" => "fieldset",
    "#weight" => -1,
  );
  $form["config_init"]["google_appliance_name"] = array(
    "#type" => "textfield",
    "#size" => 30,
    "#title" => t("Search Name"),
    "#description" => t('The name of this search, used as the default tab name, and the title of the "google-appliance/*" search pages.'),
    "#default_value" => $google_appliance_name,
    "#required" => TRUE,
    "#weight" => -10,
  );
  $form["config_init"]["google_appliance_host_name"] = array(
    "#type" => "textfield",
    "#size" => 50,
    "#title" => t("Host Name"),
    "#description" => t('Your Google Search Appliance host name or IP address (with http:// or https://), which were assigned when the appliance was set up.<br />You do <b>not</b> need to include "/search" at the end, or a trailing slash, but you should include a port number if needed.<br/> Example: http://mygooglebox.com'),
    "#default_value" => variable_get('google_appliance_host_name', ''),
    "#required" => TRUE,
    "#weight" => -9,
  );
  $form["config_init"]["google_appliance_default_collection"] = array(
    "#type" => "textfield",
    "#size" => 20,
    "#title" => t("Default collection"),
    "#description" => t('The name of the collection of indexed content to search.'),
    "#default_value" => $default_collection,
    "#required" => TRUE,
    "#weight" => -8,
  );
  $form["config_init"]["google_appliance_default_client"] = array(
    "#type" => "textfield",
    "#size" => 20,
    "#title" => t("Default client (front end)"),
    "#description" => t('The name of a valid front-end, defined when you set up the appliance.'),
    "#default_value" => $default_client,
    "#required" => TRUE,
    "#weight" => -7,
  );
  $form["config_init"]["google_appliance_default_tab_enabled"] = array(
    "#type" => "checkbox",
    "#title" => t("Enable the default search tab"),
    "#description" => t('Provide a default search tab for the default client and collection.'),
    "#default_value" => $default_tab_enabled,
    "#weight" => -6,
  );
  $form["config_init"]["google_appliance_default_search_path"] = array(
    "#type" => "textfield",
    "#size" => 30,
    "#title" => t("Default search path"),
    "#description" => t('The default search address will be <strong>search/<em>default_search_path</em></strong><br/>Note that optional search.module tabs supply their own <em>path</em>.'),
    "#default_value" => $default_search_path,
    "#required" => TRUE,
    "#weight" => -5,
  );
  $form["config_init"]["google_appliance_search_tabs"] = array(
    "#type" => "textarea",
    "#rows" => 4,
    "#title" => t("Search tabs"),
    "#description" => t('Optional search tabs. These will appear on both search.module and "google-appliance/*" search pages.<br/>Format: title|path_arg|client|collection<br/>The search.module will use <b>search/<em>path_arg</em></b> for the tab\'s search path.'),
    "#default_value" => $search_tabs,
    "#weight" => -4,
  );
  $form["config_init"]["google_appliance_path"] = array(
    "#type" => "textfield",
    "#size" => 30,
    "#title" => t("Base path"),
    "#description" => t('The base ("google-appliance") component of search paths of the form: <strong><i>google-appliance/client/collection/search terms</i></strong>'),
    "#default_value" => $google_appliance_path,
    "#required" => TRUE,
    "#weight" => -3,
  );
  $form["config_init"]["google_appliance_collection_underscores_hyphens"] = array(
    "#type" => "checkbox",
    "#title" => t("Use hyphens in the URLs, but underscores in the Client/Collection names?"),
    "#description" => t('e.g. Search default_client + default_collection when visiting <strong>google-appliance/default-client/default-collection</strong><br/>n.b. Client and Collection names may contain both hyphens and underscores, so you can still achieve the same effect without using this option.'),
    "#default_value" => variable_get('google_appliance_collection_underscores_hyphens', FALSE),
    "#weight" => -2,
  );
  $form["config_init"]["google_appliance_cache_timeout"] = array(
    "#type" => "textfield",
    "#size" => 20,
    "#title" => t("Cache Timeout"),
    "#description" => t('If you wish to cache the search results to reduce the load on the Google Appliance, enter a timeout value here (in seconds).'),
    "#default_value" => variable_get('google_appliance_cache_timeout', ''),
    "#weight" => -1,
  );
  $form["config_init"]["google_appliance_debug"] = array(
    "#type" => "textfield",
    "#size" => 20,
    "#title" => t("Debug Level"),
    "#description" => t('1 = watchdog, 2 = dpr(needs devel module), 3 = more dpr\'s'),
    "#default_value" => variable_get('google_appliance_debug', 0),
    "#weight" => 0,
  );
  $form["config_init"]["google_appliance_limit_per_page"] = array(
    "#type" => "textfield",
    "#size" => 5,
    "#title" => t("Number of results per page"),
    "#description" => t('If you enter 0, it will return the max allowed by the appliance (100)'),
    "#default_value" => variable_get('google_appliance_limit_per_page', GOOGLE_APPLIANCE_RESULTS_PER_PAGE_DEFAULT),
    "#weight" => 1,
  );
  $form["config_init"]["google_appliance_type"] = array(
    "#type" => "select",
    "#title" => t("Type of Appliance"),
    "#options" => array(
      GOOGLE_APPLIANCE_TYPE_MINI => t('Google Mini'),
      GOOGLE_APPLIANCE_TYPE_GSA => t('Google Search Appliance'),
    ),
    "#default_value" => variable_get('google_appliance_type', GOOGLE_APPLIANCE_TYPE_MINI),
    "#weight" => 2,
  );

  // error message config
  $form["config_messages"] = array(
    "#title" => t("Error Messages"),
    "#type" => "fieldset",
    "#collapsible" => TRUE,
    "#weight" => 0,
  );
  $form["config_messages"]["google_appliance_errorcode_1"] = array(
    "#title" => t("No results found"),
    "#type" => "textfield",
    "#size" => 100,
    "#maxlength" => 255,
    "#required" => TRUE,
    "#description" => t('If there are no results for the search criteria.'),
    "#default_value" => variable_get('google_appliance_errorcode_1', 'No results were found that matched your criteria. Please try broadening your search.'),
    "#weight" => -1,
  );
  $form["config_messages"]["google_appliance_errorcode_2"] = array(
    "#title" => t("More than @max results", array(
      "@max" => number_format(GOOGLE_APPLIANCE_MAX_RESULTS_FOR_MINI),
    )),
    "#type" => "textfield",
    "#size" => 100,
    "#maxlength" => 255,
    "#required" => TRUE,
    "#description" => t('If there are more than @max results for the search criteria.', array(
      "@max" => number_format(GOOGLE_APPLIANCE_MAX_RESULTS_FOR_MINI),
    )),
    "#default_value" => variable_get('google_appliance_errorcode_2', t('Sorry, our search does not return more than @max records. Please refine your criteria.', array(
      "@max" => number_format(GOOGLE_APPLIANCE_MAX_RESULTS_FOR_MINI),
    ))),
    "#weight" => 0,
  );
  $form["config_messages"]["google_appliance_errorcode_neg_99"] = array(
    "#title" => t("Cannot perform search"),
    "#type" => "textfield",
    "#size" => 100,
    "#maxlength" => 255,
    "#required" => TRUE,
    "#description" => t('If the search cannot perform due to a query error.'),
    "#default_value" => variable_get('google_appliance_errorcode_neg_99', 'Sorry, your search cannot be completed at this time. Please try again later.'),
    "#weight" => 1,
  );
  $form["config_messages"]["google_appliance_errorcode_neg_100"] = array(
    "#title" => t("Cannot connect to @name", array(
      '@name' => $google_appliance_name,
    )),
    "#type" => "textfield",
    "#size" => 100,
    "#maxlength" => 255,
    "#required" => TRUE,
    "#description" => t('If the search cannot connect to the @name server.', array(
      '@name' => $google_appliance_name,
    )),
    "#default_value" => variable_get('google_appliance_errorcode_neg_100', 'Sorry, the connection to our search engine appears to be down at the moment. Please try again later.'),
    "#weight" => 2,
  );
  $form = system_settings_form($form);
  $form['#submit'][] = 'google_appliance_admin_settings_submit';
  return $form;
}