You are here

function pmpapi_query_tools_admin_config in Public Media Platform API Integration 7

Form constructor for the PMPAPI query admin form.

See also

pmpapi_query_tools_admin_config_validate()

pmpapi_query_tools_admin_config_submit()

1 string reference to 'pmpapi_query_tools_admin_config'
pmpapi_query_tools_menu in pmpapi_query_tools/pmpapi_query_tools.module
Implements hook_menu().

File

pmpapi_query_tools/pmpapi_query_tools.admin.inc, line 16
Basic admin forms, validators, and submit handlers.

Code

function pmpapi_query_tools_admin_config($form, &$form_state, $query = '') {
  $form['query_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Query name'),
    '#size' => 12,
    '#maxlength' => 12,
    '#required' => TRUE,
    '#disabled' => $query,
    '#default_value' => $query ? $query : '',
    '#description' => t('Only numbers, letters and spaces allowed. Maximum 12 characters.'),
  );
  $options = pmpapi_query_tools_get_query($query);
  $saved = $options ? $options : array();
  $form['query_parameters'] = array(
    '#type' => 'fieldset',
    '#title' => t('Query parameters'),
  );
  $form['query_parameters']['creator'] = array(
    '#type' => 'select',
    '#title' => t('Creator'),
    '#description' => t('Limit query to the chosen creator(s).'),
    '#options' => array(
      0 => t('All'),
    ) + array_flip(pmpapi_get_creators()),
    '#multiple' => TRUE,
    '#default_value' => !empty($saved['creator']) ? $saved['creator'] : array(),
  );
  $form['query_parameters']['limit'] = array(
    '#type' => 'select',
    '#title' => t('Limit'),
    '#description' => t('Maximum number of docs pulled per query run.'),
    '#options' => drupal_map_assoc(array(
      1,
      5,
      10,
      15,
      20,
    )),
    '#default_value' => !empty($saved['limit']) ? $saved['limit'] : 5,
  );
  $form['query_parameters']['profile'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Profiles'),
    '#multiple' => TRUE,
    '#description' => t('Limit query to the checked profiles.'),
    '#options' => drupal_map_assoc(pmpapi_get_profile_list()),
    '#default_value' => !empty($saved['profile']) ? $saved['profile'] : array(),
  );
  $text_t_args = array(
    '@syntax' => url('http://www.lucenetutorial.com/lucene-query-syntax.html'),
  );
  $form['query_parameters']['text'] = array(
    '#type' => 'textfield',
    '#title' => t('Search text'),
    '#size' => 60,
    '#description' => t("Limit query to search snippet (using the <a href='@syntax'>Lucene query syntax</a>).", $text_t_args),
    '#default_value' => !empty($saved['text']) ? $saved['text'] : '',
  );
  $form['query_parameters']['tag'] = array(
    '#type' => 'textfield',
    '#title' => t('Tags'),
    '#size' => 60,
    '#description' => t('Limit query to the listed tags (space-separated).'),
    '#default_value' => !empty($saved['tag']) ? $saved['tag'] : '',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save settings'),
  );
  return $form;
}