You are here

function amazon_test_form in Amazon Product Advertisement API 7

Same name and namespace in other branches
  1. 6 amazon.admin.inc \amazon_test_form()
  2. 7.2 amazon.admin.inc \amazon_test_form()

Form for testing a single ASIN.

1 string reference to 'amazon_test_form'
amazon_menu in ./amazon.module
Implementation of hook_menu. Adds the url path for the Amazon settings page.

File

./amazon.admin.inc, line 116
Amazon Admin pages.

Code

function amazon_test_form($form, &$form_state) {
  $form = array();
  $cache = amazon_data_cache();
  $options = array();
  foreach ($cache['locales'] as $locale => $data) {
    if (variable_get('amazon_locale_' . $locale . '_associate_id', '')) {
      $options[$locale] = $data['name'];
    }
  }
  $form['asin'] = array(
    '#type' => 'textfield',
    '#title' => t('Amazon Product ID'),
    '#description' => t('The ASIN (ISBN-10) or EAN (ISBN-13) of a product listed on Amazon.'),
    '#required' => TRUE,
  );
  $form['locale'] = array(
    '#type' => 'select',
    '#title' => t('Locale'),
    '#options' => $options,
    '#default_value' => variable_get('amazon_default_locale', 'US'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Look Up Product'),
  );
  if (isset($form_state['amazon_item'])) {
    $form['item'] = array(
      '#type' => 'fieldset',
      '#title' => t('Result'),
      '#collapsible' => FALSE,
    );
    $form['item']['display'] = array(
      '#markup' => theme('amazon_item', array(
        'item' => $form_state['amazon_item'],
        'style' => 'details',
      )),
      '#weight' => 9,
    );
    $form['item']['details'] = array(
      '#type' => 'fieldset',
      '#title' => t('Details'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#weight' => 10,
    );
    $form['item']['details']['data'] = array(
      '#markup' => '<pre><small>' . print_r($form_state['amazon_item'], TRUE) . '</small></pre>',
    );
  }
  return $form;
}