Fix caption inclusion

This commit is contained in:
Romain Neutron
2012-09-14 11:53:04 +02:00
parent a8209d8c1c
commit b2f0c701ea

View File

@@ -44,14 +44,14 @@ class PDF
case self::LAYOUT_PREVIEWCAPTIONTDM: case self::LAYOUT_PREVIEWCAPTIONTDM:
try { try {
$subdef = $record->get_subdef('preview'); $subdef = $record->get_subdef('preview');
if ( ! $subdef->is_physically_present()) { if (!$subdef->is_physically_present()) {
continue 2; continue 2;
} }
if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE) if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE)
continue 2; continue 2;
$subdef = $record->get_subdef('thumbnail'); $subdef = $record->get_subdef('thumbnail');
if ( ! $subdef->is_physically_present()) if (!$subdef->is_physically_present())
continue 2; continue 2;
if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE) if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE)
@@ -64,7 +64,7 @@ class PDF
case self::LAYOUT_THUMBNAILGRID: case self::LAYOUT_THUMBNAILGRID:
try { try {
$subdef = $record->get_subdef('thumbnail'); $subdef = $record->get_subdef('thumbnail');
if ( ! $subdef->is_physically_present()) if (!$subdef->is_physically_present())
continue 2; continue 2;
if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE) if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE)
@@ -91,19 +91,19 @@ class PDF
$this->pdf = $pdf; $this->pdf = $pdf;
switch ($layout) { switch ($layout) {
case "preview": case self::LAYOUT_PREVIEW:
$this->print_preview(false); $this->print_preview(false, false);
break; break;
case "previewCaption": case self::LAYOUT_PREVIEWCAPTION:
$this->print_preview(false); $this->print_preview(false, true);
break; break;
case "previewCaptionTdm": case self::LAYOUT_PREVIEWCAPTIONTDM:
$this->print_preview(true); $this->print_preview(true, true);
break; break;
case "thumbnailList": case self::LAYOUT_THUMBNAILLIST:
$this->print_thumbnailList(); $this->print_thumbnailList();
break; break;
case "thumbnailGrid": case self::LAYOUT_THUMBNAILGRID:
$this->print_thumbnailGrid(); $this->print_thumbnailGrid();
break; break;
} }
@@ -151,11 +151,11 @@ class PDF
$icol = -1; $icol = -1;
foreach ($this->records as $rec) { foreach ($this->records as $rec) {
/* @var $rec record_adapter */ /* @var $rec record_adapter */
if ( ++ $icol >= $NDiapoW) { if (++$icol >= $NDiapoW) {
$icol = 0; $icol = 0;
if ( ++ $irow >= $NDiapoH) { if (++$irow >= $NDiapoH) {
$irow = 0; $irow = 0;
$ipage ++; $ipage++;
$this->pdf->AddPage(); $this->pdf->AddPage();
} }
} }
@@ -166,7 +166,7 @@ class PDF
$fimg = $subdef->get_pathfile(); $fimg = $subdef->get_pathfile();
if ( ! $user->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark") if (!$user->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark")
&& $subdef->get_type() == \media_subdef::TYPE_IMAGE) { && $subdef->get_type() == \media_subdef::TYPE_IMAGE) {
$fimg = \recordutils_image::watermark($subdef); $fimg = \recordutils_image::watermark($subdef);
} }
@@ -297,16 +297,16 @@ class PDF
$this->pdf->Write(5, $field->get_serialized_values()); $this->pdf->Write(5, $field->get_serialized_values());
$this->pdf->Write(6, "\n"); $this->pdf->Write(6, "\n");
$nf ++; $nf++;
} }
if ($this->pdf->PageNo() == $p0 && ($this->pdf->GetY() - $y0) < $himg) if ($this->pdf->PageNo() == $p0 && ($this->pdf->GetY() - $y0) < $himg)
$this->pdf->SetY($y0 + $himg); $this->pdf->SetY($y0 + $himg);
$ndoc ++; $ndoc++;
} }
$this->pdf->SetLeftMargin($lmargin); $this->pdf->SetLeftMargin($lmargin);
} }
protected function print_preview($withtdm) protected function print_preview($withtdm, $write_caption)
{ {
$core = \bootstrap::getCore(); $core = \bootstrap::getCore();
$appbox = \appbox::get_instance($core); $appbox = \appbox::get_instance($core);
@@ -342,7 +342,7 @@ class PDF
$LEFT__IMG = $registry->get('GV_RootPath') . "config/minilogos/logopdf_" $LEFT__IMG = $registry->get('GV_RootPath') . "config/minilogos/logopdf_"
. $rec->get_sbas_id() . ""; . $rec->get_sbas_id() . "";
if ( ! is_file($LEFT__IMG)) { if (!is_file($LEFT__IMG)) {
$databox = $rec->get_databox(); $databox = $rec->get_databox();
$str = $databox->get_sxml_structure(); $str = $databox->get_sxml_structure();
$vn = (string) ($str->pdfPrintLogo); $vn = (string) ($str->pdfPrintLogo);
@@ -393,7 +393,7 @@ class PDF
if ($size = @getimagesize($RIGHT_IMG)) { if ($size = @getimagesize($RIGHT_IMG)) {
if ($size[2] == '1') { if ($size[2] == '1') {
if ( ! isset($miniConv[$RIGHT_IMG])) { if (!isset($miniConv[$RIGHT_IMG])) {
$tmp_filename = tempnam('minilogos/', 'gif4fpdf'); $tmp_filename = tempnam('minilogos/', 'gif4fpdf');
$img = imagecreatefromgif($RIGHT_IMG); $img = imagecreatefromgif($RIGHT_IMG);
imageinterlace($img, 0); imageinterlace($img, 0);
@@ -434,7 +434,7 @@ class PDF
$f = $subdef->get_pathfile(); $f = $subdef->get_pathfile();
if ( ! $user->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark") if (!$user->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark")
&& $subdef->get_type() == \media_subdef::TYPE_IMAGE) && $subdef->get_type() == \media_subdef::TYPE_IMAGE)
$f = \recordutils_image::watermark($subdef); $f = \recordutils_image::watermark($subdef);
@@ -454,10 +454,12 @@ class PDF
$this->pdf->SetXY($lmargin, $y += ( $himg + 5)); $this->pdf->SetXY($lmargin, $y += ( $himg + 5));
$nf = 0; $nf = 0;
if ($write_caption) {
foreach ($rec->get_caption()->get_fields() as $field) { foreach ($rec->get_caption()->get_fields() as $field) {
/* @var $field caption_field */ /* @var $field caption_field */
if ($nf > 0) if ($nf > 0) {
$this->pdf->Write(6, "\n"); $this->pdf->Write(6, "\n");
}
$this->pdf->SetFont(PhraseaPDF::FONT, 'B', 12); $this->pdf->SetFont(PhraseaPDF::FONT, 'B', 12);
$this->pdf->Write(5, $field->get_name() . " : "); $this->pdf->Write(5, $field->get_name() . " : ");
@@ -472,7 +474,8 @@ class PDF
$this->pdf->Write(5, $t); $this->pdf->Write(5, $t);
$nf ++; $nf++;
}
} }
} }