search results now contain the publisher

git-svn-id: http://yolanda.mister-muffin.de/svn@55 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
josch 2007-10-12 11:30:55 +00:00
parent 646c217e42
commit cdcbf45b18
3 changed files with 35 additions and 6 deletions

View file

@ -55,6 +55,34 @@ sub get_username_from_sid
return $username;
}
#return a username from passed id
sub get_username_from_id
{
#get parameters
my ($id) = @_;
#connect to db
my $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass) or die $dbh->errstr;
#prepare query
my $sth = $dbh->prepare(qq{select username from users where id = ?}) or die $dbh->errstr;
#execute it
$sth->execute($id) or die $dbh->errstr;
#save the resulting username
my ($username) = $sth->fetchrow_array();
#finish query
$sth->finish() or die $dbh->errstr;
#close db
$dbh->disconnect() or die $dbh->errstr;
#return
return $username;
}
#return a username from passed session id
sub get_userid_from_sid
{

View file

@ -25,13 +25,13 @@ if($query->param('query'))
my $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass) or die $dbh->errstr;
#prepare query
my $sth = $dbh->prepare(qq{select title, caption, timestamp from videos where match(title, caption) against( ? ) }) or die $dbh->errstr;
my $sth = $dbh->prepare(qq{select title, caption, userid, timestamp from videos where match(title, caption) against( ? ) }) or die $dbh->errstr;
#execute it
$sth->execute($query->param('query')) or die $dbh->errstr;
#get every returned value
while (my ($title, $caption, $timestamp) = $sth->fetchrow_array())
while (my ($title, $caption, $userid, $timestamp) = $sth->fetchrow_array())
{
#really obfuscated array/hash creation
push @{ $page->{'results'}->{'result'} },
@ -43,7 +43,8 @@ if($query->param('query'))
{
'rdf:about' => './videos/1050x700/4chan_city_mashup.ogg',
'dc:title' => [$title],
'dc:date' => [$timestamp]
'dc:date' => [$timestamp],
'dc:publisher' => [get_username_from_id($userid)]
},
'cc:License' =>
{

View file

@ -224,8 +224,8 @@
</td>
<td>
<xsl:value-of select="$locale_strings/str[@id='DC.title']" />: <xsl:value-of select="rdf:RDF/cc:Work/dc:title" /><br />
<xsl:value-of select="$locale_strings/str[@id='DC.creator']" /><xsl:value-of select="rdf:RDF/cc:Work/dc:creator" /><br />
<xsl:value-of select="$locale_strings/str[@id='DC.publisher']" /><xsl:value-of select="rdf:RDF/cc:Work/dc:publisher" />
<xsl:value-of select="$locale_strings/str[@id='DC.creator']" />: <xsl:value-of select="rdf:RDF/cc:Work/dc:creator" /><br />
<xsl:value-of select="$locale_strings/str[@id='DC.publisher']" />: <xsl:value-of select="rdf:RDF/cc:Work/dc:publisher" />
</td>
</tr>
</xsl:for-each>