function wp_one_post_widget($args, $vars = array()) { extract($args); $widget_number = (int) str_replace('wp-one-post-widget-', '', @$widget_id); $options = get_option('wp_one_post_widget'); if (!empty($options[$widget_number])) { $vars = $options[$widget_number]; } // ------ data used by several parts ---------- $title = translate_title(get_the_title()); $s = explode("(", $title); $short_title = trim($s[0]); global $post; global $wpdb; global $lhg_price_db; global $lang; global $txt_summary; global $txt_supplier; global $txt_cheapest_supplier; global $txt_rating; global $txt_select; global $txt_ratings; global $txt_sim_tags; global $txt_combine_tags; global $txt_wpop_register; global $txt_register_long; global $txt_send; global $txt_manage_subscr; global $txt_not_avail; global $txt_rate_yourself; global $txt_wpop_register; global $txt_button_string; //defined by amazon-product-in-a-post.php //echo "ID: $post->ID"; if (is_single($post->ID)) { $querystr = "\r\n SELECT {$wpdb->posts}.* \r\n FROM {$wpdb->posts}\r\n WHERE {$wpdb->posts}.post_title = '" . $vars['title'] . "'\r\n AND {$wpdb->posts}.post_status = 'publish' \r\n AND {$wpdb->posts}.post_type = 'post'\r\n "; $pageposts = $wpdb->get_results($querystr, OBJECT); foreach ($pageposts as $post) { setup_postdata($post); $title = $post->post_title; $excerpt = $post->post_excerpt; if (!$excerpt) { $excerpt = substr($post->post_content, 0, 100); } if (!$vars['thumbnail_position']) { $vars['thumbnail_position'] = 'left'; } $thumb = get_the_post_thumbnail($post->ID, 'thumbnail', array('class' => $vars['thumbnail_position'])); $link = get_permalink($post->ID); } echo "\n{$before_widget}"; echo ' <div class="topright" style="border: 1px solid #2b8fc3; padding-left: 3px; padding-right:3px; padding-top: 1px; margin-bottom: 10px; background-color: #fff; padding-bottom: 17px;">'; echo ' <div class="wp-one-summary">' . $txt_summary . "</div>"; // if(empty($vars['custom_title'])): echo $before_title . "A".$vars['title'] . $after_title; else: echo "<h2>".$vars['custom_title'] . "</h2>"; endif; if ($vars['use_thumbnail'] == 'yes') { $content_widget = $thumb . '<p>' . $excerpt . ' <a href="' . $link . '">' . $vars['readmore'] . '</a></p>'; } else { $content_widget = '<p>' . $excerpt . ' <a href="' . $link . '">' . $vars['readmore'] . '</a></p>'; } //$thumb = get_the_post_thumbnail($post->ID); //echo "$thumb"; //Rating Overview $post_id = $post->ID; // Check IP From IP Logging Database #$get_rates = $wpdb->get_results("SELECT rating_rating FROM $wpdb->ratings WHERE rating_postid = $post_id"); //echo "Nr: ".sizeof($get_rates); $rating1 = 0; $rating2 = 0; $rating3 = 0; $rating4 = 0; $rating5 = 0; $rating_total = 0; #foreach($get_rates as $get_rate){ # $rating_total++; # # if ($get_rate->rating_rating == 1 ) $rating1++; # if ($get_rate->rating_rating == 2 ) $rating2++; # if ($get_rate->rating_rating == 3 ) $rating3++; # if ($get_rate->rating_rating == 4 ) $rating4++; # if ($get_rate->rating_rating == 5 ) $rating5++; # #} if ($lang != "de") { $ratings = $lhg_price_db->get_results("SELECT * FROM `lhgtransverse_posts` WHERE postid_com = {$post_id}"); } if ($lang == "de") { $ratings = $lhg_price_db->get_results("SELECT * FROM `lhgtransverse_posts` WHERE postid_de = {$post_id}"); } #var_dump($ratings); $rating1 = $ratings[0]->post_ratings_1_com + $ratings[0]->post_ratings_1_de; $rating2 = $ratings[0]->post_ratings_2_com + $ratings[0]->post_ratings_2_de; $rating3 = $ratings[0]->post_ratings_3_com + $ratings[0]->post_ratings_3_de; $rating4 = $ratings[0]->post_ratings_4_com + $ratings[0]->post_ratings_4_de; $rating5 = $ratings[0]->post_ratings_5_com + $ratings[0]->post_ratings_5_de; $rating_total = $ratings[0]->post_ratings_users_com + $ratings[0]->post_ratings_users_de; #$rating1 + $rating2 + $rating3 + $rating4 + $rating5; //echo "<table cellspacing=0 cellpadding=0 border=1> // <tr> // <td width=90%>"; //echo "</td></tr></table> "; global $vspacer; $vspacer = '<div class="spacer" style="border-top: 1px solid #2b8fc3; height: 0px; margin-top: 9px; margin-bottom: 9px;"></div>'; // ---- Overview - cheapest supplier // get cheapest supplier $cheapest_supplier_id = lhg_db_get_cheapest_supplier_id($post->ID); #echo "CID: $cheapest_supplier_id <br>"; if ($cheapest_supplier_id != "") { lhg_show_supplier_square($cheapest_supplier_id, $post->ID); } if ($cheapest_supplier_id == "") { lhg_show_supplier_square_default($post->ID); } //get price & url from DB $region = get_region(); # $meta="price-amazon.".$region; # $aprice = get_post_meta($post->ID,$meta,true); # $meta="url-amazon.".$region; # $aurl=get_post_meta($post->ID,$meta,true); //amaz_url($post->ID); //still undefined? # if ($aurl == ""){ # $aid=get_id(); # $aurl = 'http://www.amazon.'.$region.'/?_encoding=UTF8&camp=15121&creative=390961&linkCode=ur2&tag='.$aid; # } /* if ( ($region == "de") or ($region == "fr") or ($region == "it") or ($region == "es")) { $aprice=str_replace(".","",$aprice); }else{ $aprice=str_replace(",","",$aprice); //$aprice=str_replace(",",".",$aprice); } */ //echo "AP0: $aprice"; # $aprice = lhg_amazon_price_to_float ( $aprice , $region ); //echo "AP1: $aprice"; // // affilinet prices // if ($lang == "de debug") { //echo "A"; $meta = "affilinet_PID"; $aff_PID = get_post_meta($post->ID, $meta, true); //amaz_url($post->ID); if ($aff_PID == "") { //check for wrong entered PID $meta = "PID_affilinet"; $aff_PID = get_post_meta($post->ID, $meta, true); //amaz_url($post->ID); //echo "affPID: $aff_PID"; } if ($aff_PID != "") { // check for multiple PIDs $PIDlist = str_getcsv($aff_PID, ";"); $num = count($PIDlist); //echo "Num: $num <br>PIDlist0: $PIDlist[0]<br>"; //echo "PIDlist1: $PIDlist[1]<br>"; if ($num == 1) { list($aff_date, $aff_shop_id, $aff_price, $aff_shipping, $aff_url) = get_price_aff($aff_PID); $cheapestURL = str_replace("+++++", ";", $aff_url); //echo "Cheap: $cheapestURL<br>"; $tprice = $aff_price + $aff_shipping; //echo "TP: $tprice <br>"; if ($aff_shop_id == 1739) { $pcount++; $pricetable[$pcount] = $tprice . '### EUR ' . str_replace(".", ",", number_format($tprice, 2)) . ' > <a href="' . $aff_url . '" rel="nofollow">Redcoon.de</a>'; $pricetable_data[$pcount] = $tprice . '###' . str_replace(".", ",", number_format($tprice, 2)) . '###' . $aff_url . '###Redcoon.de' . '###' . str_replace(".", ",", number_format($aff_shipping, 2)); } if ($aff_shop_id == 1752) { $pcount++; $pricetable[$pcount] = $tprice . '### EUR ' . str_replace(".", ",", number_format($tprice, 2)) . ' > <a href="' . $aff_url . '" rel="nofollow">Reichelt.de</a>'; $pricetable_data[$pcount] = $tprice . '###' . str_replace(".", ",", number_format($tprice, 2)) . '###' . $aff_url . '###Reichelt.de' . '###' . str_replace(".", ",", number_format($aff_shipping, 2)); } } if ($num > 1) { //cycle through IDs //$ProductIDList = str_getcsv($ProductID,";"); //echo "multiple ids<br>"; list($aff_date, $aff_shop_id, $aff_price, $aff_shipping, $aff_url) = get_price_aff($aff_PID, $num); //echo "ShopID: $aff_shop_id"; $ShopIDList = str_getcsv($aff_shop_id, ";"); $PriceList = str_getcsv($aff_price, ";"); $ShippingList = str_getcsv($aff_shipping, ";"); $URLList = str_getcsv($aff_url, ";"); $tpriceListCheapest = 9999999999; for ($i = 0; $i < $num; $i++) { $tpriceList[$i] = $PriceList[$i] + $ShippingList[$i]; //url of cheapest partner if ($tpriceList[$i] < $tpriceListCheapest) { $tpriceListCheapest = $tpriceList[$i]; $cheapestURL = str_replace("+++++", ";", $URLList[$i]); //echo "Cheap: $cheapestURL<br>"; } if ($ShopIDList[$i] == 1739) { $pcount++; $pricetable[$pcount] = $tpriceList[$i] . '### EUR ' . str_replace(".", ",", number_format($tpriceList[$i], 2)) . ' > <a href="' . $URLList[$i] . '" rel="nofollow">Redcoon.de</a>'; $pricetable_data[$pcount] = $tpriceList[$i] . '###' . str_replace(".", ",", number_format($tpriceList[$i], 2)) . '###' . $URLList[$i] . '###Redcoon.de' . '###' . str_replace(".", ",", number_format($ShippingList[$i], 2)); } if ($ShopIDList[$i] == 1752) { $pcount++; $pricetable[$pcount] = $tpriceList[$i] . '### EUR ' . str_replace(".", ",", number_format($tpriceList[$i], 2)) . ' > <a href="' . $URLList[$i] . '" rel="nofollow">Reichelt.de</a>'; $pricetable_data[$pcount] = $tpriceList[$i] . '###' . str_replace(".", ",", number_format($tpriceList[$i], 2)) . '###' . $URLList[$i] . '###Reichelt.de' . '###' . str_replace(".", ",", number_format($ShippingList[$i], 2)); } } } } //echo "ID: $aff_shop_id <br>Price: $aff_price + $aff_shipping"; } //$nbprice=str_replace(",",".",NB_price($post->ID)); //$nburl=NB_url($post->ID); //$region=get_region(); //$aid=get_id(); //print $aprice; //print "AURL: $aurl<br>"; //if ($aurl == "") $aurl="http://www.amazon.$region/?_encoding=UTF8&camp=15121&creative=390961&linkCode=ur2&tag=$aid"; //default: Euro //print "2: ".number_format($aprice,2); //$pricestring = number_format( str_replace("EUR","",str_replace(",",".",$aprice)),2,',','.'); //pure price without currency //$pureprice = str_replace("EUR","",$aprice); //$pureprice = str_replace("CND","",$aprice); //$pureprice = str_replace("$","",$aprice); # $pricestring = $aprice; # # if ( ($region == "de") or # ($region == "es") or # ($region == "fr") or # ($region == "it") ){ # //$pricetable[0] = str_replace(",",".",$pricestring).'### EUR <span itemprop="price">'.$pricestring.'</span> > <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>'; # //$pricetable[0] = str_replace(",",".",$pricestring).'### EUR <span itemprop="price">'.$pricestring.'</span> > <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>'; # $pricetable_data[0] = $pricestring.'###'.$pricestring.'###'.$aurl.'###Amazon.'.$region; # } //float price to string # $aprice_str = lhg_float_to_currency_string( $aprice , $region ); # $cs = lhg_get_currency_symbol( $region ); //echo "REG: $region"; /* if ($region == "com") $pricetable[0] = ' $ <span itemprop="price">'.str_replace(".",".",number_format(str_replace("$","",$aprice),2)).'</span> > <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>'; if ($region == "in") $pricetable[0] = ' '.str_replace("INR",'₹ <span itemprop="price">',$aprice).'</span> > <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>'; if ($region == "ca") $pricetable[0] = ' CDN$ <span itemprop="price">'.str_replace(".",".",number_format(str_replace("CDN\$","",$aprice),2)).'</span> > <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>'; if ($region == "co.uk") $pricetable[0] = ' '.$cs.' <span itemprop="price">'.$aprice_str.'</span> > <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>'; if ($region == "co.jp") $pricetable[0] = ' ¥ <span itemprop="price">'.$aprice_str.'</span> > <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>'; */ # $pricetable[0] = ' '.$cs.' <span itemprop="price">'.$aprice_str.'</span> > <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>'; //echo "PT: $pricetable[0]"; //print "APrice: $aprice<br>"; # if ($aprice=='out of stock') # $pricetable[0] = ' '.$txt_not_avail.' > <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>'; //print "AP: >$aprice< <br>"; # if ( (strpos($aprice,'nicht vorr') !== false) or (strpos($aprice,'nicht liefer') !== false) or ($aprice=="") ) # $pricetable[0] = ' '.$txt_not_avail.' > <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>'; # if ($lang == "de"){ # if ($nbprice != ""){ # $pcount++; # $pricetable[$pcount] = ' EUR <span itemprop="price">'.str_replace(".",",",number_format(str_replace("EUR","",$nbprice),2)).'</span> > <a href="'.$nburl.'" rel="nofollow">Notebooksbilliger.de</a>'; # } # //sort($pricetable); # array_multisort( $pricetable , SORT_NUMERIC, $pricetable_data ); # } //echo "PT0 ".$pricetable[0]; //echo "POS: ".strpos($pricetable[0],"###"); //get rid of sorting string, works only for "de" # if ( strpos($pricetable[0],"###") >0 ) # foreach ($pricetable as &$value) { # list( $null, $value) = explode("###",$value); # } //echo "PT0 ".$pricetable[0]; //echo "<br>PT1 ".$pricetable[1]; //echo "PR: $aprice"; // echo "\n".'<div itemscope itemtype="http://data-vocabulary.org/Product">'; // echo "\n".'<span itemprop="category" content="Hardware" ></span>'; // echo "\n".'<span itemprop="name" content="'.translate_title(get_the_title()).'" ></span>'; //echo "PC: $pcount"; # if ($pcount > 0) # echo "\n".'<div style="text-align: center;"><b>'.$txt_cheapest_supplier.':</b></div>'; //echo "aprice: $aprice<br>"; //echo "PC: ",$pcount; # if ($pcount == 0) # if ($aprice!='out of stock') # echo "\n".'<div style="text-align: center;"><b>'.$txt_supplier.'</b></div>'; # echo "\n".'<div class="rating" style="border: 0px solid #222; width: 70%; text-align: center; margin: 0 auto;">'; # echo $cheap_txt; /* single offer. to be changed for group of offers! */ //echo "\n".'<span itemprop="offerDetails" itemscope itemtype="http://data-vocabulary.org/Offer">'; # $price_meta = "USD"; # if ($region == "de") $price_meta = "EUR"; # if ($region == "it") $price_meta = "EUR"; # if ($region == "fr") $price_meta = "EUR"; # if ($region == "es") $price_meta = "EUR"; # if ($region == "com") $price_meta = "USD"; # if ($region == "co.uk") $price_meta = "GBP"; # if ($region == "co.jp") $price_meta = "JPY"; # if ($region == "cn") $price_meta = "CNY"; # if ($region == "ca") $price_meta = "CAD"; # if ($region == "in") $price_meta = "INR"; # # echo "\n".'<meta itemprop="currency" content="'.$price_meta.'" />'; //echo '<meta itemprop="price" content="'.str_replace(".",",",number_format(str_replace("EUR","",$nbprice),2)).'" />'; //echo "Amazon.$region"; //echo "PT: $pricetable[0]"; # if ( (strpos($pricetable[0],"Amazon.$region")) or ($pricetable[0] == "") ){ # //if ($aprice!='out of stock') # echo "\n".'<div class="amazonbutton"><a href="'.$aurl.'" rel="nofollow"><img src="/wp-uploads/2012/10/Amazon_Logo1.png" border=0 width=125 height=125 alt="'.$txt_button_string.': '.$short_title.'" title="'.$txt_button_string.': '.$short_title.'"></a></div>'; # }elseif (strpos($pricetable[0],"Notebooksbilliger.de")){ # echo "\n".'<div class="amazonbutton"><a href="'.$nburl.'" rel="nofollow"><img src="wp-uploads/2012/10/Logo_125-x-125_5_H.gif" border=0></a></div>'; # }elseif (strpos($pricetable[0],"Redcoon.de")){ # echo "\n".'<div class="amazonbutton" style="border: 1px solid #2B8FC3; width: 140px; margin: 0 auto;"><a href="'.$cheapestURL.'" rel="nofollow"><img src="/wp-uploads/2014/03/redcoon-logo-125x125.jpg" border=0 width=140 height=140></a></div>'; # }elseif (strpos($pricetable[0],"Reichelt.de")){ # echo "\n".'<div class="amazonbutton" style="border: 1px solid #2B8FC3; width: 140px; margin: 0 auto;"><a href="'.$cheapestURL.'" rel="nofollow"><img src="/wp-uploads/2014/03/reichelt_logo_125x125.gif" border=0 width=140 height=140></a></div>'; # } # # $pricetable[0] = str_replace("+++++",";",$pricetable[0]); # echo str_replace(" > ", "<br>",$pricetable[0]); # echo "\n"."</div>"; # if ($pcount == 0){ # //echo "<b>Preis:</b>"; # }else{ # //echo "<b>Amazon-Preis:</b><br>"; # //echo ' '.$aprice.' > <a href="'.$aurl.'">Amazon.de</a>'; # echo $vspacer; # echo "<b>Übersicht der Anbieter:</b>"; # # } //echo "<br>PT1 ".$pricetable[1]; # if ($pcount == 0){ # //echo $line; # }else{ # echo "<br> # <table>"; # //<tr><td><b>Preis</b></td><td><b>Anbieter</b></td><td></td></tr> # //"; # $i=0; # foreach($pricetable as $line){ # list ($price1, $price2, $url , $shop, $shipping) = explode("###",$pricetable_data[$i]); # # //echo "$price2 .. $url .. $shop"; # # if (strpos($pricetable[$i],"Redcoon.de")){ # echo '<tr><td>EUR '.$price2.'<br><div class="portoline">inkl. Porto: '.$shipping.' EUR</div></td><td valign="middle"><a href="'.$url.'" rel="nofollow"><img src="wp-uploads/2014/03/redcoon-logo-110x033.jpg" style="border: 1px solid #2B8FC3;"></a></td><td><a href="'.$url.'" rel="nofollow">Redcoon.de</a></td></tr>'; # # }elseif (strpos($pricetable[$i],"Amazon.de")){ # echo '<tr><td>EUR '.$price2.'<br><div class="portoline">exkl. Porto</div></td><td valign="middle"><a href="'.$url.'" rel="nofollow"><img src="wp-uploads/2014/03/amazon_de_logo_110_33.jpg" style="border: 1px solid #2B8FC3;"></a></td><td><a href="'.$url.'" rel="nofollow">Amazon.de</a></td></tr>'; # //echo '<img src="wp-uploads/2014/03/amazon_de_logo_110_33.jpg">'.$pricetable[$i]."<br>"; # }elseif (strpos($pricetable[$i],"Reichelt.de")){ # $url = str_replace("+++++",";",$url); # echo '<tr><td>EUR '.$price2.'<br><div class="portoline">inkl. Porto: '.$shipping.' EUR</div></td><td valign="middle"><a href="'.$cheapestURL.'" rel="nofollow"><img src="wp-uploads/2014/03/reichelt_logo_110x33.jpeg" style="border: 1px solid #2B8FC3;"></a></td><td><a href="'.$url.'" rel="nofollow">Reichelt.de</a></td></tr>'; # //echo '<img src="wp-uploads/2014/03/amazon_de_logo_110_33.jpg">'.$pricetable[$i]."<br>"; # } # else{ # echo $pricetable[$i]."<br>"; # } # # //if ($i == 0) echo '<div class="priceline" style="border: 0px solid #000; "><div class="pricetop" style="border: 1px solid #2b8fc3; background-color: #eee; margin: 3px 3px;">'.$line.'</div></div>'; # //if ($i > 0) echo '<div class="priceline" style="border: 0px solid #000; "><div class="price" style="border: 0px solid #333; background-color: #fff; margin: 3px 3px;">'.$line.'</div></div>'; # $i++; # } # echo"</table>"; # } // echo get_affiliate_prices($post->ID); // // ---- New Supplier Overview // #if ($lang == "de") lhg_supplier_comparison($post->ID); // // ---- Rating Overview ============================================================== // global $txt_opw_num_ratings; // = "Number of ratings"; global $txt_opw_average_rating; // = "Average ratings"; global $txt_opw_rating_overview; global $txt_out_of; global $txt_opw_hardware; global $txt_average; global $no_supplier_square; #$rating_avg = get_post_meta($post->ID,'ratings_average',true); $num_rates = $ratings[0]->post_ratings_users_com + $ratings[0]->post_ratings_users_de; if ($num_rates == 0) { $rating_avg = 0; } if ($num_rates != 0) { $rating_avg = ($ratings[0]->post_ratings_score_com + $ratings[0]->post_ratings_score_de) / $num_rates; } if ($no_supplier_square != 1) { echo $vspacer; } #echo '<div itemscope itemtype="http://schema.org/Product">'; #echo '<div itemscope itemtype="http://data-vocabulary.org/Review-aggregate">'; #echo '<div property="itemReviewed" typeof="Product">'; #echo ' <div itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating">'; //echo '<div class="rating" style="border: 0px solid #222; width: 90%; margin: 0 auto;">'; echo ' <table class="ratingtable" border="0"> <tr> <td><b>' . $txt_opw_hardware . ':</b></td> <td><span itemprop="name">' . $short_title . '</span></td> </tr> <tr> <td> '; //if ($rating_total>1) echo "<b>$txt_wpone_num_ratings:</b></td><td> <b>".'<span itemprop="votes">'."$rating_total</span></b><br>"; //if ($rating_total<2) echo " <b>{$txt_opw_num_ratings}:</b>\n </td>\n\n\n\n <td>\n {$rating_total} <br />\n </td>\n </tr>\n\n\n <tr>\n <td><b>{$txt_opw_average_rating}: </b></td>\n\n <td>"; echo '<span itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">'; echo the_ratings_results($post->ID, 0, 0, 0, 10) . ' (<span itemprop="ratingValue">' . round($rating_avg, 1) . '</span> ' . $txt_out_of . ' <span itemprop="bestRating">5</span>) <span itemprop="ratingCount" content="' . $rating_total . '" /> <span itemprop="worstRating" content="0" /> </span> </td> </tr> '; echo ' <tr> <td class="td-ratingoverview">' . "<b>{$txt_opw_rating_overview}:</b></td>\n\n <td>"; if ($rating_total == 0) { $ra5 = 0; $ra4 = 0; $ra3 = 0; $ra2 = 0; $ra1 = 0; } else { $ra5 = 100 * $rating5 / $rating_total; $ra4 = 100 * $rating4 / $rating_total; $ra3 = 100 * $rating3 / $rating_total; $ra2 = 100 * $rating2 / $rating_total; $ra1 = 100 * $rating1 / $rating_total; } echo ' <div class="rateline" style="border: 0px solid #000;"> <div style="float: left;">5: </div> <div class="outerbox" style="background-color: #eee; width: 80px; float: left; margin: 4px 0px;"> <div class="box" style="border: 0px solid #088; background-color: #2b8fc3; height: 8px; width: ' . $ra5 . '%;" ></div> </div> (' . $rating5 . ') </div><br clear="all" />'; echo ' <div class="rateline" style="border: 0px solid #000; margin-top: -17px; "> <div style="float: left;">4: </div> <div class="outerbox" style="background-color: #eee; width: 80px; float: left; margin: 4px 0px;"> <div class="box" style="border: 0px solid #088; background-color: #2b8fc3; height: 8px; width: ' . $ra4 . '%;" ></div> </div> (' . $rating4 . ') </div><br clear="all" />'; echo ' <div class="rateline" style="border: 0px solid #000; margin-top: -17px; "> <div style="float: left;">3: </div> <div class="outerbox" style="background-color: #eee; width: 80px; float: left; margin: 4px 0px;"> <div class="box" style="border: 0px solid #088; background-color: #2b8fc3; height: 8px; width: ' . $ra3 . '%;" ></div> </div> (' . $rating3 . ') </div><br clear="all" />'; echo ' <div class="rateline" style="border: 0px solid #000; margin-top: -17px; "> <div style="float: left;">2: </div> <div class="outerbox" style="background-color: #eee; width: 80px; float: left; margin: 4px 0px;"> <div class="box" style="border: 0px solid #088; background-color: #2b8fc3; height: 8px; width: ' . $ra2 . '%;" ></div> </div> (' . $rating2 . ') </div><br clear="all" />'; echo ' <div class="rateline" style="border: 0px solid #000; margin-top: -17px; "> <div style="float: left;">1: </div> <div class="outerbox" style="background-color: #eee; width: 80px; float: left; margin: 4px 0px;"> <div class="box" style="border: 0px solid #2b8fc3; background-color: #2b8fc3; height: 8px; width: ' . $ra1 . '%;" ></div> </div> (' . $rating1 . ') </div>'; # echo ' # </div>'; echo ' <a href="#comments">' . $txt_rate_yourself . '</a>'; //echo "</td></tr><tr><td></td><td>"; echo "\n </td>\n </tr>\n\n </table>\n\n "; #echo '</div>'; // itemreviewed # echo " </div>"; //Rating #echo '</div>'; //Review-aggregate //echo $vspacer; // // -------- Subscriber ============================================================= // //if ($lang == "de"){ echo $vspacer; print "<b>" . '<i class="icon-user icon-add-hw-user"></i><i class="icon-plus icon-add-hw-plus"></i>' . "{$txt_wpop_register}</b><br />"; print "{$txt_register_long}"; if (is_user_logged_in()) { $current_user = wp_get_current_user(); print '<form action="/hardware-profile?srp=' . $post->ID . '&sra=s" method="post" onsubmit="if(this.sre.value==\'\' || this.sre.indexOf(\'@\')==0) return false"> <fieldset style="border:0"> <input type="hidden" class="subscribe-form-field" name="sre" value="' . $current_user->user_email . '" size="18"> <button type="submit" value="' . $txt_send . '" >' . $txt_send . ' <i class="icon-arrow-right icon-button"></i></button> </fieldset> </form>'; } else { print '<form action="/hardware-profile?srp=' . $post->ID . '&sra=s" method="post" onsubmit="if(this.sre.value==\'\' || this.sre.indexOf(\'@\')==0) return false"> <fieldset style="border:0"> <input type="text" class="subscribe-form-field" name="sre" value="email" size="18" onfocus="if(this.value==this.defaultValue)this.value=\'\'" onblur="if(this.value==\'\')this.value=this.defaultValue"/> <button type="submit" value="' . $txt_send . '" >' . $txt_send . ' <i class="icon-arrow-right icon-button"></i></button> </fieldset> </form>'; } $usernum = 0; //get number of registered users global $txt_opw_registered; global $wpdb; global $txt_not_avail; $usernum = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE meta_key LIKE '\\_stcr@\\_%' AND post_id = " . $post->ID); if ($usernum > 0) { print "(" . $txt_opw_registered . ": " . $usernum . ")"; } //print do_shortcode('<a href="/manage-subscriptions">'.$txt_manage_subscr."</a>"); //} // // ----------- Language Selector ============================================ // #$selected ='<div class="pricetop" style="border: 1px solid #2b8fc3; background-color: #eee; margin: 3px 3px 3px 3px; padding-top: 3px;">'; #$selectedEnd ='</div>'; # Debug: #lhg_store_comment_numbers_by_post_id( $post_id ); echo $vspacer; echo "<b>{$txt_select}:</b><br />"; //echo "PL:".get_permalink(); //echo "<br>QPL:".qtrans_convertURL(get_permalink()); list($null1, $null2, $null3, $posturl) = explode("/", get_permalink()); list($null1, $null2, $null3, $null4, $posturl2) = explode("/", get_permalink()); //echo "pu:".$posturl ."<br>"; //echo "pu2".$posturl2."<br>"; if ($posturl2 != "") { $posturl = $posturl2; } //we are in a qtranslate subfolder! $posturlde = $posturl; $posturlcom = $posturl; if (!is_search() and !($postID == "1821") and !is_archive()) { $comURL = get_post_meta($post->ID, 'COM_URL', true); $deURL = get_post_meta($post->ID, 'DE_URL', true); if ($comURL != "") { $posturlcom = $comURL; } if ($deURL != "") { $posturlde = $deURL; } if (substr($comURL, 0, 1) == "/") { $comURL = substr($comURL, 1); } if (substr($deURL, 0, 1) == "/") { $deURL = substr($deURL, 1); } //echo "LANG: $lang, PID: $postID, "; //translation still missing -> redirect to main page if ($comURL == "" and $post->ID > 2599 and $lang == "de") { $posturlcom = ""; } if ($deURL == "" and $post->ID > 2599 and $lang == "en") { $posturlde = ""; } # on de server get com link from priceDB if ($lang == "de") { $com = lhg_get_com_post_URL($postID); $comURL == $com; } } //remove language selection for .de $posturlde = str_replace("?lang=jp", "", $posturlde); $posturlde = str_replace("?lang=it", "", $posturlde); $posturlde = str_replace("?lang=es", "", $posturlde); $posturlde = str_replace("?lang=uk", "", $posturlde); $posturlde = str_replace("?lang=ca", "", $posturlde); $posturlde = str_replace("?lang=in", "", $posturlde); $posturlde = str_replace("?lang=fr", "", $posturlde); $posturlde = str_replace("?lang=cn", "", $posturlde); $posturlde = str_replace("?lang=en", "", $posturlde); $posturlcom = str_replace("?lang=jp", "", $posturlcom); $posturlcom = str_replace("?lang=it", "", $posturlcom); $posturlcom = str_replace("?lang=es", "", $posturlcom); $posturlcom = str_replace("?lang=uk", "", $posturlcom); $posturlcom = str_replace("?lang=ca", "", $posturlcom); $posturlcom = str_replace("?lang=in", "", $posturlcom); $posturlcom = str_replace("?lang=fr", "", $posturlcom); $posturlcom = str_replace("?lang=cn", "", $posturlcom); $posturlcom = str_replace("?lang=en", "", $posturlcom); if ($lang == "de") { $URLC = "http://www.linux-hardware-guide.com"; $URLD = ""; } if ($lang != "de") { $URLC = ""; $URLD = "http://www.linux-hardware-guide.de"; } //$URLC="http://192.168.3.113"; //Debug if (1 == 1) { echo '<div class="countrytable"><table border="0"> <tr class="countrytable_header"> <td class="cth_country">Country</td> <td class="cth_price">Price</td> <td class="cth_currency"></td> <td class="cth_comment">Comments</td> </tr>'; print lhg_country_row("de", $URLC, $URLD, $posturlcom, $posturlde); print lhg_country_row("com", $URLC, $URLD, $posturlcom, $posturlde); print lhg_country_row("ca", $URLC, $URLD, $posturlcom, $posturlde); print lhg_country_row("co.uk", $URLC, $URLD, $posturlcom, $posturlde); print lhg_country_row("fr", $URLC, $URLD, $posturlcom, $posturlde); print lhg_country_row("es", $URLC, $URLD, $posturlcom, $posturlde); print lhg_country_row("it", $URLC, $URLD, $posturlcom, $posturlde); print lhg_country_row("nl", $URLC, $URLD, $posturlcom, $posturlde); print lhg_country_row("in", $URLC, $URLD, $posturlcom, $posturlde); print lhg_country_row("co.jp", $URLC, $URLD, $posturlcom, $posturlde); print lhg_country_row("cn", $URLC, $URLD, $posturlcom, $posturlde); echo "</table></div>"; } else { //if ($region == "de") print $selected; //echo ' <a href="'.$URLD.'/'.$posturlde.'"><img src="/wp-content/plugins/qtranslate/flags/de.png" alt="Germany" /> Germany (€)</a><br />'; //if ($region == "de") print $selectedEnd; if ($region == "de") { print $selected; } echo ' <a href="' . $URLC . '/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/us.png" alt="USA" /> USA (€)</a><br />'; if ($region == "de") { print $selectedEnd; } if ($region == "ca") { print $selected; } echo ' <a href="' . $URLC . '/ca/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/ca.png" alt="Canada" /> Canada (CDN $)</a><br />'; if ($region == "ca") { print $selectedEnd; } if ($region == "co.uk") { print $selected; } echo ' <a href="' . $URLC . '/uk/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/uk.png" alt="UK" /> United Kingdom (£)</a><br />'; if ($region == "co.uk") { print $selectedEnd; } if ($region == "fr") { print $selected; } echo ' <a href="' . $URLC . '/fr/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/fr.png" alt="France" /> France (€)</a><br />'; if ($region == "fr") { print $selectedEnd; } if ($region == "es") { print $selected; } echo ' <a href="' . $URLC . '/es/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/es.png" alt="Espana" /> Espana (€)</a><br />'; if ($region == "es") { print $selectedEnd; } if ($region == "it") { print $selected; } echo ' <a href="' . $URLC . '/it/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/it.png" alt="Italia" /> Italia (€)</a><br />'; if ($region == "it") { print $selectedEnd; } if ($region == "nl") { print $selected; } echo ' <a href="' . $URLC . '/nl/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/nl.png" alt="Netherlands" /> Netherlands (€)</a><br />'; if ($region == "nl") { print $selectedEnd; } if ($region == "in") { print $selected; } echo ' <a href="' . $URLC . '/in/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/in.png" alt="India" /> India (₹)</a><br />'; if ($region == "in") { print $selectedEnd; } if ($region == "co.jp") { print $selected; } echo ' <a href="' . $URLC . '/ja/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/jp.png" alt="Japan" /> Japan (¥)</a><br />'; if ($region == "co.jp") { print $selectedEnd; } if ($region == "cn") { print $selected; } echo ' <a href="' . $URLC . '/zh/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/cn.png" alt="China" /> China (RMB)</a><br />'; if ($region == "cn") { print $selectedEnd; } } // // Tag List Start // echo $vspacer; echo "\n\n" . " <b>{$txt_sim_tags}:</b>\n <br />"; echo "\n" . ' <div style="margin-left: 18px;">'; echo "\n\n" . ' <form method="get" action="/tagsearch/" class="combine_tags">' . "\n"; foreach (get_the_category() as $category) { $counter++; $CID = $category->cat_ID; break; //stop at main category! } $args = array('category' => $CID); $catposts = get_posts($args); foreach ($catposts as $post) { setup_postdata($post); $posttags = get_the_tags(get_the_ID()); if (is_array($posttags)) { foreach ($posttags as $tag) { if ($tag->count > 1) { // combination not useful in case of one result if ($tag->term_id != 981) { $count++; $tagstrings[$count] = $tag->term_id . '; <a href="' . get_tag_link($tag->term_id) . '">' . $tag->name . '</a> (' . $tag->count . ')<br /> '; if ($count > 15) { break; } } } } } } if (is_array($tagstrings)) { $unique_tagstrings = array_unique($tagstrings); } if (is_array($unique_tagstrings)) { sort($unique_tagstrings); } $countU = 0; if (is_array($unique_tagstrings)) { foreach ($unique_tagstrings as $tagstring) { $part = explode(";", $tagstring); $out .= "\n" . ' <input type="checkbox" name="tagid[' . $countU . ']" value="' . $part[0] . '" />' . $part[1]; $countU++; } } echo $out; // // Tag List End // echo $content_widget; echo "\n" . ' <div class="tagbutton"> <button type="submit" value="' . $txt_combine_tags . '" >' . $txt_combine_tags . ' <i class="icon-arrow-right icon-button"></i> </button> </div> </form>'; echo "\n" . "\n </div>\n "; echo "\n" . "</div>"; echo $after_widget; //close the blue widget } }
function lhg_get_shop_button($postid) { global $region; global $txt_on_stock; global $txt_out_of_stock; global $txt_shipping; global $txt_tooltip2; global $txt_button; global $txt_not_avail_at; global $txt_price; global $txt_search_at; global $txt_preorder; global $txt_buy_from; global $txt_shipping_costs; $tooltip = $txt_tooltip2; //"Die von Amazon zur Verfügung gestellten Preise sind exklusive möglicherweise zusätzlich anfallender Versandkosten (abhängig vom jeweiligen Anbieter des Amazon-Marketplace)."; //$button .= "PID: $postid<br>"; $shopid = lhg_db_get_cheapest_supplier_id($postid); $products = lhg_get_sorted_products($shopid, $postid, false); $url = $products[0]["url"]; $price = $products[0]["price"]; #+$products[0]["shipping"]; #$price_total = $products[0]["price"]+$products[0]["shipping"]; $shipping = $products[0]["shipping"]; $shipping = lhg_float_to_currency_string($shipping, $region); $price = lhg_float_to_currency_string($price, $region); $name = lhg_get_shop_long_name($shopid); $txt_currency = lhg_get_currency_symbol($region); //format button depending on availability if ($shopid != "") { //product available at a shop $price_meta = "USD"; if ($region == "de") { $price_meta = "EUR"; } if ($region == "it") { $price_meta = "EUR"; } if ($region == "fr") { $price_meta = "EUR"; } if ($region == "nl") { $price_meta = "EUR"; } if ($region == "es") { $price_meta = "EUR"; } if ($region == "com") { $price_meta = "USD"; } if ($region == "co.uk") { $price_meta = "GBP"; } if ($region == "co.jp") { $price_meta = "JPY"; } if ($region == "cn") { $price_meta = "CNY"; } if ($region == "ca") { $price_meta = "CAD"; } if ($region == "in") { $price_meta = "INR"; } $schema_start = '<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">'; $schema_end = '</div>'; $button_string = '<i class="icon-shopping-cart icon-large3"></i> ' . $txt_buy_from . ' ' . $name; $price_string = $txt_price . ': ' . $txt_currency . ' <span itemprop="price">' . $price . '</span> <meta itemprop="priceCurrency" content="' . $price_meta . '" /> <span itemprop="availability" itemtype="http://schema.org/InStock" class="instock"> (' . $txt_on_stock . ') </span>'; $shipping_string = '<span class="shippingcosts"> (+ ' . $txt_shipping_costs . ': ' . $txt_currency . ' ' . $shipping . ') </span>'; //unknown shipping costs for Amazon, add warning if (strpos($name, "mazon") > 0) { $shipping_string = '<font size="1"> (' . $txt_shipping . ')</font> <span class="tooltip">' . tooltip($tooltip) . '</span> '; } //no shipping costs in DB if (strpos($products[0]["shipping"], "ULL") > 0) { $shipping_string = '<font size="1"> (' . $txt_shipping . ') </font>'; } } elseif ($region == "nl") { //currently no Amazon.de shown } else { // see if we have "Check Amazon for pricing" $meta = "price-amazon." . $region; $aprice = get_post_meta($postid, $meta, true); #print "AP: $aprice"; if ($aprice != "Check Amazon For Pricing") { $aid = get_id(); //nowhere available! not even in Amazon catalog // $region_tmp = $region; if ($region == "nl") { $region_tmp = "de"; } $price_string = '<span class="outofstock">(' . $txt_out_of_stock . ')</span> <br /><div class="amazon-cr"></div>' . $txt_never_avail_at . ' <a target="_blank" href="http://www.amazon.' . $region_tmp . '/?_encoding=UTF8&camp=15121&creative=390961&linkCode=ur2&tag=' . $aid . '" rel="nofollow"> Amazon.' . $region_tmp . ' </a> <div class="amazon-cr"></div>'; $button_string = '<i class="icon-search icon-large3"></i> ' . $txt_search_at . ' Amazon.' . $region_tmp; $url = 'http://www.amazon.' . $region_tmp . '/?_encoding=UTF8&camp=15121&creative=390961&linkCode=ur2&tag=' . $aid; $shipping_string = ""; #'<font size="1">('.$txt_shipping.') #<span class="tooltip">'.tooltip($tooltip).'<span> #</font>'; // Check if at least a Amazon URL exists?! // $meta = "url-amazon." . $region; $pageurl = get_post_meta($postid, $meta, true); if ($pageurl != "") { // not possible because we have no price ... //$schema_start = '<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">'; //$schema_end = '</div>'; $region_tmp = $region; if ($region == "nl") { $region_tmp = "de"; } //$price_string = '<span itemprop="availability" itemtype="http://schema.org/OutOfStock" class="outofstock">('.$txt_out_of_stock.')</span> $price_string = '<span class="outofstock">(' . $txt_out_of_stock . ')</span> <br /><div class="amazon-cr"></div>' . $txt_not_avail_at . ' <a target="_blank" href="http://www.amazon.' . $region_tmp . '/?_encoding=UTF8&camp=15121&creative=390961&linkCode=ur2&tag=' . $aid . '" rel="nofollow"> Amazon.' . $region_tmp . ' </a> <div class="amazon-cr"></div>'; $button_string = '<i class="icon-search icon-large3"></i> ' . $txt_preorder . ' Amazon.' . $region_tmp; $url = $pageurl; } $do_not_show = 1; } else { //echo "AAA"; $schema_start = '<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">'; $schema_end = '</div>'; //Check Amazon for pricing returned $meta = "url-amazon." . $region; $pageurl = get_post_meta($postid, $meta, true); $price_string = ' <span itemprop="availability" itemtype="http://schema.org/InStock" class="instock"> ' . $txt_on_stock . ' at <a href="' . $pageurl . '">Amazon.com</a> </span>'; $region_tmp = $region; if ($region == "nl") { $region_tmp = "de"; } $button_string = '<i class="icon-search icon-large3"></i> Check Price at Amazon.' . $region_tmp; $url = $pageurl; } } $button .= ' <div class="amaz-grey-box" style="border: 0px solid #eee; background-color: #eee;"> ' . $schema_start . $price_string . ' <br />'; if ($shipping_string != "") { $button .= ' <div class="shipping">' . $shipping_string . ' </div> <br />'; } $button .= ' <a href="' . $url . '" class="css_btn_class" rel="nofollow">' . $button_string . ' </a> ' . $schema_end . ' </div> <br /> '; if ($region == "nl" and $shopid == "") { $button = ""; } if ($do_not_show == 1) { $button = ""; } return $button; }