You are here

function amazon_search_search in Amazon Product Advertisement API 6

Implementation of hook_search(). Implements remote Amazon searching.

File

amazon_search/amazon_search.module, line 11

Code

function amazon_search_search($op = 'search', $keys = NULL, $skip_access_check = FALSE) {
  switch ($op) {
    case 'name':
      if ($skip_access_check || user_access('access amazon search')) {
        return t('Amazon.com');
      }
    case 'search':
      if (user_access('access amazon search')) {
        $products = array();
        $items = amazon_search_simple_search($keys);
        foreach ($items as $item) {
          $products[] = array(
            'title' => check_plain($item['title']),
            'link' => check_url($item['detailpageurl']),
            'type' => check_plain($item['productgroup']),
            'user' => isset($item['participants']) ? implode(', ', $item['participants']) : '',
            'snippet' => isset($item['editorialreviews']) ? check_markup($item['editorialreviews'][0]['content']) : '',
          );
        }
        return $products;
      }
  }
}