? amazontools.txt Index: amazon.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/amazontools/amazon.module,v retrieving revision 1.63 diff -u -p -r1.63 amazon.module --- amazon.module 25 Jan 2007 00:13:16 -0000 1.63 +++ amazon.module 25 Jun 2007 20:21:00 -0000 @@ -710,6 +710,12 @@ function amazon_settings() { '#width' => 60, '#height' => 5, ); + $form['amazon_link_functionality'] = array( + '#title' => t('Link Functionality'), + '#type' => 'radios', + '#options' => array(t('Images link back to Amazon'),t('Disable image links'),t('Images link to product node')), + '#default_value' => variable_get('amazon_link_functionality', 0), + ); return system_settings_form($form); } @@ -1375,7 +1381,7 @@ function theme_amazon_block($selected_bo $book_image = $selected_book->mediumimageurl ? $selected_book->mediumimageurl : "$module_dir/images/missingm.gif"; $blockcontent = '
'; if ($is_review) { - $blockcontent .= ""; + $blockcontent .= "review"; $blockcontent .= "mediumimageheight\" width=\"$selected_book->mediumimagewidth\" alt=\"cover of $selected_book->title\" />
"; $blockcontent .= '
'; $blockcontent .= " detailpageurl\" target=\"_blank\">"; @@ -1386,12 +1392,8 @@ function theme_amazon_block($selected_bo $blockcontent .= ''; } else { - $blockcontent .= "detailpageurl\" target=\"_blank\">"; - $blockcontent .= "mediumimageheight\" width=\"$selected_book->mediumimagewidth\" alt=\"cover of $selected_book->title\" />
"; - $blockcontent .= '
'; - $blockcontent .= "detailpageurl\" target=\"_blank\">"; - $blockcontent .= $selected_book->title; - $blockcontent .= ''; + $blockcontent .= amazon_paint_image($node,$book_image,$selected_book); + $blockcontent .= amazon_paint_link($selected_book); } if ($selected_book->rating) { @@ -1400,20 +1402,14 @@ function theme_amazon_block($selected_bo $blockcontent .= '
'; return $blockcontent; } - function theme_amazon_node($node) { $module_dir = drupal_get_path('module', 'amazon'); $output = ''; $output .= ''; $output .= ''; - $output .= "
detailpageurl\" target=\"_blank\">"; - if ($node->mediumimageurl) { - $output .= "mediumimageurl\" height=\"$node->mediumimageheight\" width=\"$node->mediumimagewidth\" alt=\"cover of $node->title\" />"; - } - else { - $output .= "\"no"; - } - $output .= ""; + $output .= ""; + $output .= amazon_paint_image($node); + $output .= ""; if ($node->type == 'amazon') { if ($node->detailpageurl) { $output .= "detailpageurl\" target=\"_blank\">"; @@ -1477,3 +1473,51 @@ function theme_amazon_related_link($node $output .= '
'; return $output; } +function amazon_paint_image($node,$book_image=null,$selected_book=null) { + $src = $book_image; + $height = $selected_book->mediumimageheight; + $width = $selected_book->mediumimagewidth; + if(!$src) { + $src = $node->mediumimageurl; + $height = $node->mediumimageheight; + $width = $node->width; + } + if ($src) { + $image .= "\"covertitle\" />"; + } + else { + $image .= "\"no"; + } + switch(variable_get('amazon_link_functionality',0)) { + case 0: + $output .= l($image,$node->detailpageurl,array('target'=>'_blank'),null,null,false,true); + break; + case 1: + $output .= $image; + break; + case 2: + if(!$node->nid) { + $node = db_fetch_object(db_query("SELECT nid,asin from {amazonnode} where asin = '%s'",$selected_book->asin)); + } + $output .= l($image,'node/'.$node->nid,null,null,null,false,true); + break; + } + return $output; +} +function amazon_paint_link($selected_book) { + $href = $selected_book->detailpageurl; + $title = $selected_book->title; + switch(variable_get('amazon_link_functionality',0)) { + case 0: + $output .= "

".l($title,$href,array('target'=>'_blank'),null,null,false,false)."

"; + break; + case 1: + $output .= "

$title

"; + break; + case 2: + $node = db_fetch_object(db_query("SELECT nid,asin from {amazonnode} where asin = '%s'",$selected_book->asin)); + $output .= "

".l($title,'node/'.$node->nid,null,null,null,false,false)."

"; + break; + } + return $output; +} \ No newline at end of file