sub GetAdvertsForLink {
use strict;
use warnings;
use utf8;
binmode STDOUT, ':encoding(UTF-8)';
$_ = 'été';
my $desc = "test 123 un été à Tanger. élargir elargir ete";
$desc =~ s|\b\Q$_|$_|sg;
print "FOO" . $desc;
}
####
#<%Plugins::SponsorText::GetAdvertsForLink($Description,$category_id)%>
sub GetAdvertsForLink2 {
use locale;
my $desc = $_[0];
my $link_id = $_[1];
my $cat_tbl = $DB->table('CatLinks');
$cat_tbl->select_options('LIMIT 1');
my $cat_id = $cat_tbl->select( ['CategoryID'] , { LinkID => $link_id } )->fetchrow;
my $cond = new GT::SQL::Condition;
$cond->add('CatIDs','LIKE',"%,$cat_id,%");
$cond->add('CatIDs','LIKE',"%,$cat_id");
$cond->add('CatIDs','LIKE',"$cat_id,%");
$cond->add('CatIDs','LIKE',"$cat_id");
$cond->bool('OR');
my @words;
print $IN->header;
# print qq|GOT CAT ID: $cat_id|;
# use Unicode::MapUTF8 qw(to_utf8 from_utf8 utf8_supported_charset);
my $sth = $DB->table('SponsorLinkText')->select( $cond ) || die $GT::SQL::error;
while (my $hit = $sth->fetchrow_hashref) {
my (@words) = split /,/, $hit->{Words};
$hit->{Target} ||= '_blank';
foreach (@words) {
print qq|Looking for "$_" in "$desc"
\n|;
if ($hit->{TheText}) {
$desc =~ s|\b$_|$_|sg;
} else {
$desc =~ s|\b$_|$_|sg;
}
}
}
return $desc;
}
####
foreach (@words) {
print qq|Looking for "$_" in "$desc"
\n|;
if ($hit->{TheText}) {
$desc =~ s|\b$_|$_|sg;
} else {
$desc =~ s|\b$_|$_|sg;
}
}