|
|
|
|
|
|
|
|
my $q = sqlquery($dbh, "SELECT * FROM documents WHERE id = ?", $id); |
|
|
my $q = sqlquery($dbh, "SELECT * FROM documents WHERE id = ?", $id); |
|
|
while(my $hash = $q->fetchrow_hashref()) { $document = $hash; } |
|
|
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, " |
|
|
$q = sqlquery($dbh, " |
|
|
SELECT tags.tag AS tag |
|
|
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); |
|
|
WHERE documentId = ? ORDER BY tag", $id); |
|
|
while(my ($tag) = $q->fetchrow_array()) { push @tags, $tag; } |
|
|
while(my ($tag) = $q->fetchrow_array()) { push @tags, $tag; } |
|
|
|
|
|
|
|
|
my %lang; |
|
|
my %lang; |
|
|
|
|
|
|
|
|
foreach my $page ( @pages ) { |
|
|
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}; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|