Quellcode durchsuchen

fixed language extract

master
Pascal Gloor vor 5 Jahren
Ursprung
Commit
819d7d035a
1 geänderte Dateien mit 27 neuen und 6 gelöschten Zeilen
  1. 27
    6
      cgi/autodoc.fcgi

+ 27
- 6
cgi/autodoc.fcgi Datei anzeigen

@@ -141,21 +141,42 @@ sub db_get_document_object {
my $q = sqlquery($dbh, "SELECT * FROM documents WHERE id = ?", $id);
while(my $hash = $q->fetchrow_hashref()) { $document = $hash; }

#$q = sqlquery($dbh, "SELECT * FROM pages WHERE documentId = ?", $id);
#while(my $hash = $q->fetchrow_hashref()) { push @pages, $hash; push @pageids, $hash->{id}; }
$q = sqlquery($dbh, "
SELECT p.*
FROM pages p
JOIN documents_pages dp
ON p.id = dp.pageId
WHERE dp.documentId = ?", $id);
while(my $hash = $q->fetchrow_hashref()) {
my $clean = { };
foreach my $name ( keys %{$hash} ) {
if ( $name =~ /^pages\.(.*)/ ) {
my $newname = $1;
$clean->{$newname} = $hash->{$name};
}
}
push @pages, $clean; push @pageids, $clean->{id};
}

$q = sqlquery($dbh, "
SELECT tags.tag AS tag
FROM documents_tags LEFT JOIN tags ON documents_tags.tagId = tags.id
FROM documents_tags JOIN tags ON documents_tags.tagId = tags.id
WHERE documentId = ? ORDER BY tag", $id);
while(my ($tag) = $q->fetchrow_array()) { push @tags, $tag; }

my %lang;

foreach my $page ( @pages ) {
$q = sqlquery($dbh, "SELECT * FROM pages_lang WHERE pageId = ?", $page->{id});
while(my $hash = $q->fetchrow_hashref()) {
$lang{$hash->{language}}++;
$q = sqlquery($dbh, "
SELECT
SUM(pw.count) AS count
l.short AS lang
FROM pages_words pw
JOIN words w ON pw.wordID = w.id
JOIN lang l ON w.langId = l.id
WHERE pw.pageId = ?", $page->{id});
while(my $h = $q->fetchrow_hashref()) {
$lang{$h->{lang}}=$h->{count};
}
}


Laden…
Abbrechen
Speichern