|
|
@@ -108,6 +108,7 @@ sub db_get_document_object { |
|
|
|
my $document; |
|
|
|
my @pages; |
|
|
|
my @pageids; |
|
|
|
my @tags; |
|
|
|
|
|
|
|
my $q = sqlquery($dbh, "SELECT * FROM documents WHERE id = ?", $id); |
|
|
|
while(my $hash = $q->fetchrow_hashref()) { $document = $hash; } |
|
|
@@ -115,6 +116,12 @@ sub db_get_document_object { |
|
|
|
$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 tags.tag AS tag |
|
|
|
FROM documents_tags LEFT JOIN tags ON documents_tags.tagId = tags.id |
|
|
|
WHERE documentId = ?i SORT BY tag", $id); |
|
|
|
while(my ($tag) = $q->fetchrow_array()) { push @tags, $tag; } |
|
|
|
|
|
|
|
my %lang; |
|
|
|
|
|
|
|
foreach my $page ( @pages ) { |
|
|
@@ -134,8 +141,9 @@ sub db_get_document_object { |
|
|
|
owner => $document->{owner}, |
|
|
|
status => $document->{status}, |
|
|
|
languages => [ keys %lang ], |
|
|
|
tags => [ @tags ], |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return (200, "application/json", $out); |
|
|
|
} |
|
|
|
|
|
|
@@ -147,18 +155,13 @@ sub db_get_page_object { |
|
|
|
|
|
|
|
my $out; |
|
|
|
my %lang; |
|
|
|
my @tags; |
|
|
|
|
|
|
|
my $q = sqlquery($dbh, "SELECT * FROM pages_lang WHERE pageId = ?", $id); |
|
|
|
while(my $hash = $q->fetchrow_hashref()) { |
|
|
|
$lang{$hash->{language}}++; |
|
|
|
} |
|
|
|
|
|
|
|
$q = sqlquery($dbh, " |
|
|
|
SELECT tags.tag AS tag |
|
|
|
FROM pages_tags LEFT JOIN tags ON pages_tags.tagId = tags.id |
|
|
|
WHERE pageId = ?i SORT BY tag", $id); |
|
|
|
while(my ($tag) = $q->fetchrow_array()) { push @tags, $tag; } |
|
|
|
|
|
|
|
|
|
|
|
$q = sqlquery($dbh, "SELECT * FROM pages WHERE documentId = ?", $id); |
|
|
|
while(my $hash = $q->fetchrow_hashref()) { |
|
|
@@ -170,7 +173,6 @@ sub db_get_page_object { |
|
|
|
owner => $hash->{owner}, |
|
|
|
status => $hash->{status}, |
|
|
|
language => [ keys %lang ], |
|
|
|
tags => [ @tags ], |
|
|
|
}; |
|
|
|
} |
|
|
|
|