getSettings();
$local_info = $this->get_local_info($Settings);
// If using local tags then just process the ones on this page otherwise search categories.
if (strcasecmp($categories, "local") != 0) {
// First process all post content for the selected categories
$content = '';
if (preg_match('!^[0-9,]*$!', $categories)) {
$lastposts = get_posts("numberposts=$last&cat=$categories");
} else {
$lastposts = get_posts("numberposts=$last&cat_name=$categories");
}
foreach ($lastposts as $id => $post) {
$content .= $post->post_content;
}
$saved_tags = $this->tags;
$this->tags = array();
$this->content_filter($content, FALSE);
$this->Settings = $Settings; // Reset settings as content filter will overwrite them
}
$output = '';
if ((count($this->tags) != 0) && is_array($this->tags))
{
$output .= '
';
if (strcasecmp($Settings['wishlist_type'],'similar') == 0) {
$request = array("Operation" => "CartCreate",
"MergeCart" => "True",
"ResponseGroup" => "CartSimilarities",
"IdType"=>"ASIN",
"MerchantId"=>"Amazon");
// Get the Cart Similarities for the items found
$counter=1;
$unique_asins = array();
foreach ($this->tags as $asins)
{
$asin = isset($asins[$local_info['cc']]) ? $asins[$local_info['cc']] : (isset($asins[$Settings['default_cc']]) ? $asins[$Settings['default_cc']] : '');
if ((strlen($asin) > 8) && !in_array($asin,$unique_asins)) {
$request["Item." . $counter . ".ASIN"] = $asin;
$request["Item." . $counter . ".Quantity"] = 1;
$counter++;
$unique_asins[] = $asin;
}
}
$pxml = $this->doQuery($request);
if (!empty($pxml['Cart']['SimilarProducts']['SimilarProduct']))
{
$Items=$pxml['Cart']['SimilarProducts']['SimilarProduct'];
if (!array_key_exists('0', $Items)) {
$Items = array('0'=>$Items);
}
} else {
$output .= '';
$output .= '';
$Items=array();
}
$ASINs = array();
foreach ($Items as $Item => $Details)
$ASINs[] = $Details['ASIN'];
} else {
if (strcasecmp($Settings['wishlist_type'],'random') == 0) {
shuffle($this->tags);
$ASINs = $this->tags;
} else if (strcasecmp($Settings['wishlist_type'],'multi') == 0) {
$ASINs = $this->tags;
}
$unique_asins = array();
for ($index=0; $index < count($ASINs); $index++) {
$asin = isset($ASINs[$index][$local_info['cc']]) ? $ASINs[$index][$local_info['cc']] : (isset($ASINs[$index][$Settings['default_cc']]) ? $ASINs[$index][$Settings['default_cc']] : '');
if (in_array($asin, $unique_asins)) {
unset($ASINs[$index]);
} else {
$unique_asins[] = $asin;
}
}
}
if ( is_array($ASINs) && !empty($ASINs)) {
$Settings['live'] = 1;
$Settings['asin'] = array_slice($ASINs,0,$Settings['wishlist_items']);
if (!isset($Settings['template'])) $Settings['template'] = $Settings['wishlist_template'];
$output .= $this->make_links($Settings);
}
$output .= "
";
} else {
$output .= "";
}
if (isset($saved_tags)) {
$this->tags = $saved_tags;
}
return $output;
?>