From da4dc2a9f320aa9fe1c2df76087a1d7ec5812eb3 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Thu, 3 Jun 2010 18:49:19 +0200 Subject: [PATCH] Fix contact pdf (images and addresses). Close #1060 Signed-off-by: Florent Bruneau --- include/profilefields.inc.php | 3 +++ modules/carnet/contacts.pdf.inc.php | 13 ++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/profilefields.inc.php b/include/profilefields.inc.php index 6d7a90c..e44a639 100644 --- a/include/profilefields.inc.php +++ b/include/profilefields.inc.php @@ -295,6 +295,9 @@ class Address public function hasFlag($flag) { + if (!$this->flags instanceof PlFlagSet) { + $this->flags = new PlFlagSet($this->flags); + } return $this->flags->hasFlag($flag); } } diff --git a/modules/carnet/contacts.pdf.inc.php b/modules/carnet/contacts.pdf.inc.php index 175cbc7..09ed3b4 100644 --- a/modules/carnet/contacts.pdf.inc.php +++ b/modules/carnet/contacts.pdf.inc.php @@ -175,19 +175,19 @@ class ContactsPDF extends FPDF private function Address($a) { - if (!$a['text']) { + if (!$a->text) { return; } $l = "adresse\n"; - if ($a['current']) { + if ($a->hasFlag('current')) { $l .= 'actuelle'; - } elseif ($a['secondary']) { + } elseif ($a->hasFlag('secondary')) { $l .= 'secondaire'; } else { $l .= 'principale'; } - $r = utf8_decode($a['text']); + $r = utf8_decode($a->text); /* $r = trim("$r\n".$a['adr1']); $r = trim("$r\n".$a['adr2']); $r = trim("$r\n".$a['adr3']); @@ -283,7 +283,7 @@ class ContactsPDF extends FPDF $ok = false; if ($wp) { - $photo = $profile->getPhoto(false); + $photo = $profile->getPhoto(false, true); if ($photo) { $old2 = clone $self; $width = $photo->width() * 20 / $photo->height(); @@ -291,8 +291,7 @@ class ContactsPDF extends FPDF $_y = $self->getY(); $self->Cell(0, 20, '', '', 0, '', 1); error_reporting(0); - $mime = explode('/', $photo->mimeType()); - $self->Image($photo->path(), $_x, $_y, $width, 20, $mime[1]); + $self->Image($photo->path(), $_x, $_y, $width, 20, $photo->mimeType()); error_reporting($self->report); if ($self->error) { -- 2.1.4