You are here

asin.module in Amazon Product Advertisement API 6

Same filename and directory in other branches
  1. 7.2 asin/asin.module
  2. 7 asin/asin.module

Defines a field type for referencing an Amazon product.

File

asin/asin.module
View source
<?php

/**
 * @file
 * Defines a field type for referencing an Amazon product.
 */

/**
 * Implementation of hook_menu().
 */
function asin_menu() {
  $items = array();
  $items['asin/autocomplete'] = array(
    'page callback' => 'asin_autocomplete_callback',
    'access arguments' => array(
      'access content',
    ),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Implementation of hook_theme().
 */
function asin_theme() {
  return array(
    'asin_text' => array(
      'arguments' => array(
        'element',
      ),
    ),
    'asin_autocomplete' => array(
      'arguments' => array(
        'element',
      ),
    ),
    'asin_formatter_default' => array(
      'arguments' => array(
        'element',
      ),
    ),
    'asin_formatter_thumbnail' => array(
      'arguments' => array(
        'element',
      ),
    ),
    'asin_formatter_details' => array(
      'arguments' => array(
        'element',
      ),
    ),
    'asin_formatter_inline' => array(
      'arguments' => array(
        'element',
      ),
    ),
  );
}

/**
 * Implementation of hook_field_info().
 *
 * Here we indicate that the content module will use its default
 * handling for the view of this field.
 *
 * Callbacks can be omitted if default handing is used.
 * They're included here just so this module can be used
 * as an example for custom modules that might do things
 * differently.
 */
function asin_field_info() {
  return array(
    'asin' => array(
      'label' => t('Amazon item'),
      'description' => t('Store the id of a product listed on Amazon.com.'),
    ),
  );
}

/**
 * Implementation of hook_field_settings().
 */
function asin_field_settings($op, $field) {
  switch ($op) {
    case 'database columns':
      $columns['asin'] = array(
        'type' => 'varchar',
        'length' => 32,
        'not null' => FALSE,
      );
      return $columns;
    case 'views data':
      $data = content_views_field_views_data($field);
      $db_info = content_database_info($field);
      $table_alias = content_views_tablename($field);

      // Filter: Add a 'many to one' filter.
      $copy = $data[$table_alias][$field['field_name'] . '_asin'];
      $copy['title'] = t('@label (!name) - Allowed values', array(
        '@label' => $field['widget']['label'],
        '!name' => $field['field_name'],
      ));
      $copy['filter']['handler'] = 'views_handler_filter_many_to_one';
      unset($copy['field'], $copy['argument'], $copy['sort']);
      $data[$table_alias][$field['field_name'] . '_value_many_to_one'] = $copy;

      // Argument : swap the handler to the 'many to one' operator.
      $data[$table_alias][$field['field_name'] . '_value']['argument']['handler'] = 'views_handler_argument_many_to_one';

      // Add a relationship for related node.
      $data[$table_alias][$field['field_name'] . '_asin']['relationship'] = array(
        'base' => 'amazon_item',
        'field' => $db_info['columns']['asin']['column'],
        'handler' => 'views_handler_relationship',
      );
      return $data;
  }
}

/**
 * Implementation of hook_field().
 */
function asin_field($op, &$node, $field, &$items, $teaser, $page) {
  switch ($op) {
    case 'insert':
    case 'update':
      $results = _asin_load_items($items);
      return;
      break;
    case 'validate':

      // Trim ASINs to help the user out.
      _asin_trim_items($items);
      $results = _asin_load_items($items);
      foreach ($items as $delta => $item) {
        if (is_array($item)) {
          if (!empty($item['asin']) && empty($results[$item['asin']])) {
            form_set_error($field['field_name'] . '][' . $delta . '][asin', t('%name : No Amazon product with the ASIN "%id" could be located.', array(
              '%name' => $field['widget']['label'],
              '%id' => $item['asin'],
            )));
          }
        }
      }
      return;
      break;
    case 'load':
      _asin_trim_items($items);
      $results = _asin_load_items($items);
      foreach ($items as $delta => $item) {
        if (!empty($item['asin'])) {
          $items[$delta] = $results[$item['asin']];
        }
      }
      return $items;
      break;
    case 'delete':
      $results = _asin_load_items($items);
      foreach ($items as $delta => $item) {
        if (!empty($item['asin'])) {
          amazon_item_delete($item['asin']);
        }
      }
      return;
      break;
  }
}
function _asin_trim_items(&$items) {
  foreach ($items as $delta => $item) {
    $items[$delta]['asin'] = trim($items[$delta]['asin']);
  }
}

/**
 * Get an array of items from Amazon.com.
 * @param $items
 * @return unknown_type
 */
function _asin_load_items(&$items) {
  $asins = array();
  foreach ($items as $delta => $item) {
    if (!empty($item['asin'])) {
      $asin = trim($item['asin']);
      $asin = amazon_convert_to_asin($asin);
      $asins[] = $asin;
      $items[$delta]['asin'] = $asin;

      // Adjust in case we've changed it.
    }
  }
  return amazon_item_lookup($asins);
}

/**
 * Implementation of hook_content_is_empty().
 */
function asin_content_is_empty($item, $field) {
  if (empty($item['asin'])) {
    return TRUE;
  }
  return FALSE;
}

/**
 * Implementation of hook_field_formatter_info().
 */
function asin_field_formatter_info() {
  return array(
    'default' => array(
      'label' => t('Small image and basic info'),
      'field types' => array(
        'asin',
      ),
      'multiple values' => CONTENT_HANDLE_CORE,
    ),
    'details' => array(
      'label' => t('Small image and full info'),
      'field types' => array(
        'asin',
      ),
      'multiple values' => CONTENT_HANDLE_CORE,
    ),
    'thumbnail' => array(
      'label' => t('Large image'),
      'field types' => array(
        'asin',
      ),
      'multiple values' => CONTENT_HANDLE_CORE,
    ),
    'inline' => array(
      'label' => t('Title as link'),
      'field types' => array(
        'asin',
      ),
      'multiple values' => CONTENT_HANDLE_CORE,
    ),
  );
}

/**
 * Theme function for 'default' asin field formatter, appropriate for
 * general use and product listings.
 */
function theme_asin_formatter_default($element) {
  $asin = trim($element['#item']['asin']);
  $asins = array();
  if (!empty($asin)) {
    $asins = amazon_item_lookup("{$asin}");
    return theme('amazon_item', $asins["{$asin}"]);
  }
}

/**
 * Theme function for 'thumbnail' asin field formatter, appropriate for
 * product highlighting and display.
 */
function theme_asin_formatter_thumbnail($element) {
  $asin = trim($element['#item']['asin']);
  if (!empty($asin)) {
    $asins = amazon_item_lookup("{$asin}");
    return theme('amazon_item', $asins["{$asin}"], 'thumbnail');
  }
}

/**
 * Theme function for 'full' asin field formatter, appropriate for
 * product highlighting and display.
 */
function theme_asin_formatter_details($element) {
  $asin = trim($element['#item']['asin']);
  if (!empty($asin)) {
    $asins = amazon_item_lookup(array(
      $asin,
    ));
    return theme('amazon_item', $asins["{$asin}"], 'details');
  }
}

/**
 * Theme function for 'inline' asin field formatter, appropriate for
 * quick title lists, etc.
 */
function theme_asin_formatter_inline($element) {
  if ($asin = trim($element['#item']['asin'])) {
    $asins = amazon_item_lookup("{$asin}");
    return theme('amazon_inline_item', $asins[$asin]);
  }
}

/**
 * Implementation of hook_widget_info().
 *
 * We need custom handling of multiple values for the asin_text
 * widget because we need to combine them into a options list rather
 * than display multiple elements.
 *
 * We will use the content module's default handling for default value.
 *
 * Callbacks can be omitted if default handing is used.
 * They're included here just so this module can be used
 * as an example for custom modules that might do things
 * differently.
 */
function asin_widget_info() {
  return array(
    'asin_autocomplete' => array(
      'label' => t('Product name autocomplete'),
      'field types' => array(
        'asin',
      ),
      'multiple values' => CONTENT_HANDLE_CORE,
      'callbacks' => array(
        'default value' => CONTENT_CALLBACK_DEFAULT,
      ),
    ),
    'asin_text' => array(
      'label' => t('ASIN or ISBN Text field'),
      'field types' => array(
        'asin',
      ),
      'multiple values' => CONTENT_HANDLE_CORE,
      'callbacks' => array(
        'default value' => CONTENT_CALLBACK_DEFAULT,
      ),
    ),
  );
}

/**
 * Implementation of FAPI hook_elements().
 *
 * Any FAPI callbacks needed for individual widgets can be declared here,
 * and the element will be passed to those callbacks for processing.
 *
 * Drupal will automatically theme the element using a theme with
 * the same name as the hook_elements key.
 */
function asin_elements() {
  return array(
    'asin_text' => array(
      '#input' => TRUE,
      '#process' => array(
        'asin_text_process',
      ),
    ),
    'asin_autocomplete' => array(
      '#input' => TRUE,
      '#process' => array(
        'asin_autocomplete_process',
      ),
      '#autocomplete_path' => FALSE,
      '#value_callback' => 'asin_autocomplete_value',
    ),
  );
}

/**
 * Implementation of hook_widget().
 *
 * Attach a single form element to the form. It will be built out and
 * validated in the callback(s) listed in hook_elements. We build it
 * out in the callbacks rather than here in hook_widget so it can be
 * plugged into any module that can provide it with valid
 * $field information.
 *
 * Content module will set the weight, field name and delta values
 * for each form element. This is a change from earlier CCK versions
 * where the widget managed its own multiple values.
 *
 * If there are multiple values for this field, the content module will
 * call this function as many times as needed.
 *
 * @param $form
 *   the entire form array, $form['#node'] holds node information
 * @param $form_state
 *   the form_state, $form_state['values'][$field['field_name']]
 *   holds the field's form values.
 * @param $field
 *   the field array
 * @param $items
 *   array of default values for this field
 * @param $delta
 *   the order of this item in the array of subelements (0, 1, 2, etc)
 *
 * @return
 *   the form item for a single element for this field
 */
function asin_widget(&$form, &$form_state, $field, $items, $delta = 0) {
  $element = array(
    '#type' => $field['widget']['type'],
    '#default_value' => isset($items[$delta]) ? $items[$delta] : '',
  );
  return $element;
}

/**
 * Process an individual element.
 *
 * Build the form element. When creating a form using FAPI #process,
 * note that $element['#value'] is already set.
 *
 * The $fields array is in $form['#field_info'][$element['#field_name']].
 */
function asin_text_process($element, $edit, $form_state, $form) {
  $field = $form['#field_info'][$element['#field_name']];
  $delta = $element['#delta'];
  $asin_key = $element['#columns'][0];
  if (!empty($element['#value'][$asin_key])) {
    $element['#value'][$asin_key] = trim($element['#value'][$asin_key]);
    $element['#value'][$asin_key] = amazon_convert_to_asin($element['#value'][$asin_key]);
  }
  $element[$asin_key] = array(
    '#type' => 'textfield',
    '#title' => $element['#title'],
    '#description' => $element['#description'],
    '#required' => $element['#required'],
    '#default_value' => isset($element['#value'][$asin_key]) ? $element['#value'][$asin_key] : NULL,
  );
  return $element;
}

/**
 * Process an autocomplete widget.
 */
function asin_autocomplete_process($element, $edit, $form_state, $form) {
  $element = asin_text_process($element, $edit, $form_state, $form);
  $asin_key = $element['#columns'][0];
  $element[$asin_key]['#autocomplete_path'] = 'asin/autocomplete';
  $element[$asin_key]['#element_validate'][] = 'asin_autocomplete_validate';
  $element[$asin_key]['#maxlength'] = 256;
  return $element;
}

/**
 * Autocomplete callback for the asin_autocomplete widget.
 */
function asin_autocomplete_callback($string = '') {
  $items = $matches = array();
  $cleanstring = trim(preg_replace('#[^\\p{L}\\p{N}]+#u', ' ', $string));

  // Search Amazon.
  $parameters = array(
    'ResponseGroup' => 'Small',
    'SearchIndex' => 'All',
    'Keywords' => urlencode($cleanstring),
  );
  $results = amazon_http_request('ItemSearch', $parameters);

  // Process the results.
  foreach ($results->Items->Item as $xml) {
    $items[(string) $xml->ASIN] = (string) $xml->ItemAttributes->Title . ' (' . $xml->ItemAttributes->ProductGroup . ')';
  }

  // Create our response.
  foreach ($items as $asin => $title) {

    // Add a class wrapper for a few required CSS overrides.
    $matches[$title . ' [asin:' . $asin . ']'] = '<div class="reference-autocomplete">' . $title . '</div>';
  }
  drupal_json($matches);
}

/**
 * Validate an select element.
 *
 * Remove the wrapper layer and set the right element's value.
 */
function asin_text_validate($element, &$form_state) {
  array_pop($element['#parents']);
  form_set_value($element, $form_state['values'][$element['#field_name']], $form_state);
}

/**
 * Validate the autocomplete widget.
 *
 * This corrects the value (we want just the ASIN, not the whole title).
 */
function asin_autocomplete_validate($element, &$form_state) {
  $value = $element['#value'];
  $asin = NULL;
  if (preg_match('!.*\\[asin\\:([a-zA-Z0-9]*)\\]!', $value, $matches)) {
    $asin = $matches[1];
  }
  else {
    $asin = $value;
  }
  form_set_value($element, $asin, $form_state);
}
function theme_asin_text($element) {
  drupal_add_css(drupal_get_path('module', 'asin') . '/asin.css', 'module', 'all', FALSE);
  $output = $element['#children'];
  if (!empty($element['#value']) && !empty($element['#value']['asin'])) {
    $asin = $element['#value']['asin'];
    if ($data = amazon_item_lookup(array(
      $asin,
    ))) {
      $output .= '<p class="asin-edit-title">' . check_plain($data[$asin]['title']) . '</p>';
    }
  }
  return $output;
}

/**
 * Implementation of hook_feeds_node_processor_targets_alter().
 *
 * @see FeedsNodeProcessor::getMappingTargets().
 */
function asin_feeds_node_processor_targets_alter(&$targets, $content_type) {
  $info = content_types($content_type);
  $fields = array();
  if (isset($info['fields']) && count($info['fields'])) {
    foreach ($info['fields'] as $field_name => $field) {
      if ($field['type'] == 'asin') {
        $fields[$field_name] = isset($field['widget']['label']) ? $field['widget']['label'] : $field_name;
      }
    }
  }
  foreach ($fields as $k => $name) {
    $targets[$k] = array(
      'name' => $name,
      'callback' => 'asin_feeds_set_target',
      'description' => t('The CCK !name field of the node.', array(
        '!name' => $name,
      )),
    );
  }
}

/**
 * Callback for mapping. Here is where the actual mapping happens.
 *
 * When the callback is invoked, $target contains the name of the field the
 * user has decided to map to and $value contains the value of the feed item
 * element the user has picked as a source.
 */
function asin_feeds_set_target($node, $target, $value) {
  $field = isset($node->{$target}) ? $node->{$target} : array();

  // Handle multiple value fields.
  if (is_array($value)) {
    $i = 0;
    foreach ($value as $v) {
      if (!is_array($v) && !is_object($v)) {
        $field[$i]['asin'] = $v;
      }
      $i++;
    }
  }
  else {
    $field[0]['asin'] = $value;
  }
  $node->{$target} = $field;
}
function theme_asin_autocomplete($element) {
  return theme_asin_text($element);
}
function asin_content_generate($node, $field) {
  if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
    return content_devel_multiple('_asin_content_generate', $node, $field);
  }
  else {
    return _asin_devel_generate($node, $field);
  }
}

/**
 * Utility function that actually provides the values for asin_devel_generate().
 *
 * You can change the SearchIndex and Keywords used for the search by changing
 * the variables amazon_devel_generate_search_index and
 * asin_devel_generate_keywords.
 */
function _asin_devel_generate($node, $field) {
  $search_index = variable_get('asin_devel_generate_search_index', 'Books');
  $keywords_picker = explode(',', variable_get('asin_devel_generate_keywords', 'computers'));
  $keywords_picker = array_flip($keywords_picker);
  $asins = variable_get('amazon_devel_generate_asins', array());
  $amazon_item_page = variable_get('amazon_devel_generate_item_page', 1);
  if (empty($asins)) {
    $parameters = array(
      'ResponseGroup' => 'ItemAttributes,EditorialReview,Images',
      'SearchIndex' => $search_index,
      'Keywords' => urlencode(array_rand($keywords_picker, 1)),
      'ItemPage' => $amazon_item_page % 400,
    );
    $amazon_item_page++;
    $results = amazon_http_request('ItemSearch', $parameters);
    foreach ($results->Items->Item as $xml) {
      $item = amazon_item_clean_xml($xml);
      amazon_item_insert($item);
      $asins[] = $item['asin'];
    }
  }
  $field = array();
  $asin = array_shift($asins);
  $field['asin'] = $asin;
  variable_set('amazon_devel_generate_asins', $asins);
  variable_set('amazon_devel_generate_item_page', $amazon_item_page);
  return $field;
}

/**
 * Allow selection of the SearchIndex and Keywords to be used
 */
function asin_form_devel_generate_content_form_alter(&$form, $form_state) {
  $form['asin_options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Amazon ASIN Field Configuration'),
    '#expanded' => FALSE,
  );
  $form['asin_options']['asin_devel_generate_search_index'] = array(
    '#type' => 'select',
    '#title' => t('Amazon SearchIndex'),
    '#options' => drupal_map_assoc(array(
      'All',
      'Books',
      'DVD',
      'Electronics',
      'Kitchen',
      'Software',
    )),
    '#default_value' => variable_get('asin_devel_generate_search_index', 'All'),
  );
  $form['asin_options']['asin_devel_generate_keywords'] = array(
    '#type' => 'textfield',
    '#title' => t('Amazon.com search keywords for ASIN fields'),
    '#description' => t('Comma-separated list of keywords to be used in search to populate Amazon module asin fields'),
    '#default_value' => variable_get('asin_devel_generate_keywords', 'computers'),
  );
  $form['submit']['#weight'] = 99;
  array_unshift($form['#submit'], 'asin_devel_generate_set_values');
}
function asin_devel_generate_set_values($form, &$form_state) {
  variable_set('asin_devel_generate_keywords', $form_state['values']['asin_devel_generate_keywords']);
  variable_set('asin_devel_generate_search_index', $form_state['values']['asin_devel_generate_search_index']);
}

/**
 * Implementation of hook_token_list()
 */
function asin_token_list($type = 'all') {
  if ($type == 'field' || $type == 'all') {
    $tokens = array();
    $tokens['asin']['asin'] = t("Product ID");
    $tokens['asin']['title'] = t("Product title");
    $tokens['asin']['title-dec'] = t("Product title (HTML entities like '&amp;mp;' are decoded. Best for use in node titles.)");

    //isbn and ean removed, because they're not available in the database. can be readded later if those fields are made available

    //$tokens['asin']['isbn'] = t("The 10-digit ISBN (INternational Standard Book Number)");

    //$tokens['asin']['ean'] = t("The EAN or 13-digit ISBN");
    $tokens['asin']['detailpageurl'] = t("The detail page URL for the item");
    $tokens['asin']['salesrank'] = t("The product's sales rank");
    $tokens['asin']['brand'] = t("The product's brand");
    $tokens['asin']['brand-dec'] = t("The product's brand (HTML entities like '&amp;mp;' are decoded.)");
    $tokens['asin']['publisher'] = t("The product's publisher");
    $tokens['asin']['publisher-dec'] = t("The product's publisher (HTML entities like '&amp;mp;' are decoded.)");
    $tokens['asin']['manufacturer'] = t("The product's manufacturer");
    $tokens['asin']['manufacturer-dec'] = t("The product's manufacturer (HTML entities like '&amp;mp;' are decoded.)");
    $tokens['asin']['studio'] = t("The product's studio");
    $tokens['asin']['studio-dec'] = t("The product's studio (HTML entities like '&amp;mp;' are decoded.)");
    $tokens['asin']['label'] = t("The product's label");
    $tokens['asin']['label-dec'] = t("The product's label (HTML entities like '&amp;mp;' are decoded.)");
    $tokens['asin']['binding'] = t("The product's binding type");
    $tokens['asin']['binding-dec'] = t("The product's binding type (HTML entities like '&amp;mp;' are decoded.)");
    $tokens['asin']['release'] = t("The product's release date");
    $tokens['asin']['release-Y'] = t("The product's release date. 4 digit year only.");
    $tokens['asin']['release-y'] = t("The product's release date. 2 digit year only.");
    $tokens['asin']['release-m'] = t("The product's release date. 2 digit month only");
    $tokens['asin']['release-n'] = t("The product's release date. 2 digit month only (no leading 0)");
    $tokens['asin']['release-M'] = t("The product's release date. Abbreviated month only. (Example: 'Jan', 'Feb'");
    $tokens['asin']['release-d'] = t("The product's release date. 2 digit day only");
    $tokens['asin']['release-j'] = t("The product's release date. 2 digit day only (no leading 0)");
    $tokens['asin']['list'] = t("The product's list price");
    $tokens['asin']['list-amount'] = t("The product's list price (Unformatted)");
    $tokens['asin']['list-currency'] = t("Currency code for the product's list price");
    $tokens['asin']['lowest'] = t("The lowest price currently offered by any merchant at Amazon");
    $tokens['asin']['lowest-amount'] = t("The lowest price currently offered by any merchant at Amazon (Unformatted)");
    $tokens['asin']['lowest-currency'] = t("Currency code for the lowest price currently offered by any merchant at Amazon");
    $tokens['asin']['amazon'] = t("Current price offered by Amazon");
    $tokens['asin']['amazon-amount'] = t("Current price offered by Amazon (Unformatted)");
    $tokens['asin']['amazon-currency'] = t("Currency code for the current price offered by Amazon");
    $tokens['asin']['group'] = t("The product's product group or categorization of the product");
    $tokens['asin']['group-dec'] = t("The product's product group (HTML entities like '&amp;mp;' are decoded.)");
    $tokens['asin']['type'] = t("The product's Amazon product type");
    $tokens['asin']['type-dec'] = t("The product's Amazon product type (HTML entities like '&amp;mp;' are decoded.)");
    $tokens['asin']['author'] = t("The product's author(s)");
    $tokens['asin']['author-dec'] = t("The product's author (HTML entities like '&amp;mp;' are decoded.)");
    $tokens['asin']['participants'] = t("The product's participants. All names listed on the product");
    $tokens['asin']['participants-dec'] = t("The product's participants. (HTML entities like '&amp;mp;' are decoded.)");
    return $tokens;
  }
}

/**
 * Implementation of hook_token_values()
 */
function asin_token_values($type, $object = NULL, $options = array()) {
  if ($type == 'field') {
    $item = $object[0];
    $amazonAsin = amazon_convert_to_asin($item['asin']);
    $amazonArr = amazon_item_lookup($amazonAsin);
    $item = $amazonArr[$amazonAsin];
    if (is_array($item)) {
      foreach ($item as $k => $v) {
        if ($k == 'detailpageurl') {
          $v = check_url($v);
        }
        else {
          if ($k == 'author' || $k == 'participants') {
            $v = array_map('check_plain', $v);
            $v = implode(', ', $v);
          }
          else {
            if (is_string($v)) {
              $v = check_plain($v);
            }
          }
        }
        ${$k} = $v;
      }
    }
    $values['asin'] = $asin;
    $values['title'] = $title;
    $values['title-dec'] = decode_entities($title);
    $values['detailpageurl'] = $detailpageurl;
    $values['salesrank'] = $salesrank;
    $values['brand'] = $brand;
    $values['brand-dec'] = decode_entities($brand);
    $values['publisher'] = $publisher;
    $values['publisher-dec'] = decode_entities($publisher);
    $values['manufacturer'] = $manufacturer;
    $values['manufacturer-dec'] = decode_entities($manufacturer);
    $values['studio'] = $studio;
    $values['studio-dec'] = decode_entities($studio);
    $values['label'] = $label;
    $values['label-dec'] = decode_entities($label);
    $values['binding'] = $binding;
    $values['binding-dec'] = decode_entities($binding);
    $values['release'] = $releasedate;
    $values['release-Y'] = substr($releasedate, 0, 4);
    $values['release-y'] = substr($releasedate, 2, 2);
    $month = substr($releasedate, 5, 2);
    $values['release-m'] = $month;
    $values['release-n'] = ltrim($month, '0');
    $values['release-M'] = $month ? date('M', mktime(0, 0, 0, $month)) : '';
    $day = substr($releasedate, 8, 2);
    $values['release-d'] = $day;
    $values['release-j'] = ltrim($day, '0');
    $values['list'] = $listpriceformattedprice;
    $values['list-amount'] = $listpriceamount;
    $values['list-currency'] = $listpricecurrencycode;
    $values['lowest'] = $lowestpriceformattedprice;
    $values['lowest-amount'] = $lowestpriceamount;
    $values['lowest-currency'] = $lowestpricecurrencycode;
    $values['amazon'] = $amazonpriceformattedprice;
    $values['amazon-amount'] = $amazonpriceamount;
    $values['amazon-currency'] = $amazonpricecurrencycode;
    $values['group'] = $productgroup;
    $values['group-dec'] = decode_entities($productgroup);
    $values['type'] = $producttypename;
    $values['type-dec'] = decode_entities($producttypename);
    $values['author'] = $author;
    $values['author-dec'] = decode_entities($author);
    $values['participants'] = $participants;
    $values['participants-dec'] = decode_entities($participants);
    return $values;
  }
}

Functions

Namesort descending Description
asin_autocomplete_callback Autocomplete callback for the asin_autocomplete widget.
asin_autocomplete_process Process an autocomplete widget.
asin_autocomplete_validate Validate the autocomplete widget.
asin_content_generate
asin_content_is_empty Implementation of hook_content_is_empty().
asin_devel_generate_set_values
asin_elements Implementation of FAPI hook_elements().
asin_feeds_node_processor_targets_alter Implementation of hook_feeds_node_processor_targets_alter().
asin_feeds_set_target Callback for mapping. Here is where the actual mapping happens.
asin_field Implementation of hook_field().
asin_field_formatter_info Implementation of hook_field_formatter_info().
asin_field_info Implementation of hook_field_info().
asin_field_settings Implementation of hook_field_settings().
asin_form_devel_generate_content_form_alter Allow selection of the SearchIndex and Keywords to be used
asin_menu Implementation of hook_menu().
asin_text_process Process an individual element.
asin_text_validate Validate an select element.
asin_theme Implementation of hook_theme().
asin_token_list Implementation of hook_token_list()
asin_token_values Implementation of hook_token_values()
asin_widget Implementation of hook_widget().
asin_widget_info Implementation of hook_widget_info().
theme_asin_autocomplete
theme_asin_formatter_default Theme function for 'default' asin field formatter, appropriate for general use and product listings.
theme_asin_formatter_details Theme function for 'full' asin field formatter, appropriate for product highlighting and display.
theme_asin_formatter_inline Theme function for 'inline' asin field formatter, appropriate for quick title lists, etc.
theme_asin_formatter_thumbnail Theme function for 'thumbnail' asin field formatter, appropriate for product highlighting and display.
theme_asin_text
_asin_devel_generate Utility function that actually provides the values for asin_devel_generate().
_asin_load_items Get an array of items from Amazon.com.
_asin_trim_items