aboutsummaryrefslogtreecommitdiff
path: root/lib/models/Courseware/StructuralElement.php
diff options
context:
space:
mode:
authorRon Lucke <lucke@elan-ev.de>2022-08-04 09:47:14 +0000
committerTill Glöggler <tgloeggl@uos.de>2022-08-04 09:47:14 +0000
commit9bc8e30f18694a838142594d767b4cce574ec2e9 (patch)
tree74ea6b44d04dc6e89e522d3b2fe593772d9d9b0c /lib/models/Courseware/StructuralElement.php
parentfca7f5cf475db33a970a52417421337752b54bc4 (diff)
BIEST #723
Merge request studip/studip!853
Diffstat (limited to 'lib/models/Courseware/StructuralElement.php')
-rw-r--r--lib/models/Courseware/StructuralElement.php39
1 files changed, 23 insertions, 16 deletions
diff --git a/lib/models/Courseware/StructuralElement.php b/lib/models/Courseware/StructuralElement.php
index 7a127db..f518cc1 100644
--- a/lib/models/Courseware/StructuralElement.php
+++ b/lib/models/Courseware/StructuralElement.php
@@ -830,45 +830,52 @@ SQL;
$doc->setHeaderTitle(sprintf(_('Courseware von %s'), $this->user->getFullname()));
}
- $doc->addPage();
-
if (!self::canRead($user)) {
+ $doc->addPage();
$doc->addContent(_('Diese Seite steht Ihnen nicht zur Verfügung!'));
return $doc;
}
- $doc->writeHTML($this->getElementPdfExport('', $with_children, $user));
+ $this->getElementPdfExport(0, $with_children, $user, $doc);
+
+ if ($with_children) {
+ $doc->addTOCPage();
+ $doc->SetFont('helvetica', 'B', 16);
+ $doc->MultiCell(0, 0, _('Inhaltsverzeichnis'), 0, 'C', 0, 1, '', '', true, 0);
+ $doc->Ln();
+ $doc->SetFont('helvetica', '', 12);
+ $doc->addTOC(1, 'helvetica', '.', _('Inhaltsverzeichnis'), 'B', array(0,0,0));
+ $doc->endTOCPage();
+ }
+
return $doc;
}
- private function getElementPdfExport(string $parent_name, bool $with_children, $user)
+ private function getElementPdfExport(int $depth, bool $with_children, $user, $doc)
{
if (!$this->canRead($user)) {
return '';
}
- if ($parent_name !== '') {
- $parent_name .= ' / ';
- }
- $html = '<h1>' . $parent_name . $this->title . '</h1>';
+ $doc->addPage();
+ $doc->Bookmark(htmlReady($this->title), $depth, 0, '', '', array(128,0,0));
+ $html = "<h1>" . htmlReady($this->title) . "</h1>";
$html .= $this->getContainerPdfExport();
+ $doc->writeHTML($html);
+
if ($with_children) {
- $html .= $this->getChildrenPdfExport($parent_name, $with_children, $user);
+ $this->getChildrenPdfExport($depth, $with_children, $user, $doc);
}
-
- return $html;
}
- private function getChildrenPdfExport(string $parent_name, bool $with_children, $user)
+ private function getChildrenPdfExport(int $depth, bool $with_children, $user, $doc)
{
$children = self::findBySQL('parent_id = ?', [$this->id]);
- $html = '';
+ $depth++;
foreach ($children as $child) {
- $html .= $child->getElementPdfExport($parent_name . $this->title, $with_children, $user);
+ $child->getElementPdfExport($depth, $with_children, $user, $doc);
}
-
- return $html;
}
private function getContainerPdfExport()