- rfe: Not being limited to single-worded Tags

- Exposed keywords API to all assets through edit screen. Now keywords are
   searchable and add metatags for all assets.
This commit is contained in:
JT Smith 2008-04-26 19:46:13 +00:00
parent 17d6151832
commit d744551c31
4 changed files with 69 additions and 4 deletions

View file

@ -157,7 +157,7 @@ sub getKeywordsForAsset {
return \@keywords;
}
else {
return join(" ", @keywords);
return wantarray ? @keywords : join(" ", map({ m/\s/ ? '"' . $_ . '"' : $_ } @keywords));
}
}
@ -266,7 +266,7 @@ sub setKeywordsForAsset {
$keywords = $options->{keywords};
}
else {
@{$keywords} = split(" ", $options->{keywords});
$keywords = string2list($options->{keywords});
}
$self->deleteKeywordsForAsset($options->{asset});
@ -284,6 +284,45 @@ sub setKeywordsForAsset {
}
}
#------------------------------------------------------------------------------
=head2 string2list ( string )
Returns an array reference of phrases.
=head3 string
A scalar containing space separated phrases.
=cut
sub string2list {
my $text = shift;
return if (ref $text);
my @words = ();
my $word = '';
my $errorFlag = 0;
while ( defined $text and length $text and not $errorFlag) {
if ($text =~ s/\A(?: ([^\"\s\\]+) | \\(.) )//mx) {
$word .= $1;
}
elsif ($text =~ s/\A"((?:[^\"\\]|\\.)*)"//mx) {
$word .= $1;
}
elsif ($text =~ s/\A\s+//m){
push(@words, $word);
$word = '';
}
elsif ($text =~ s/\A"//) {
$errorFlag = 1;
}
else {
$errorFlag = 1;
}
}
push(@words, $word);
return \@words;
}
1;