Beispiel #1
0
 function handler_pdf($page, $arg0 = null, $arg1 = null)
 {
     $this->load('contacts.pdf.inc.php');
     $user = S::user();
     Platal::session()->close();
     $order = array(new UFO_Name());
     if ($arg0 == 'promo') {
         $order = array_unshift($order, new UFO_Promo());
     } else {
         $order[] = new UFO_Promo();
     }
     $filter = new UserFilter(new UFC_Contact($user), $order);
     $pdf = new ContactsPDF();
     $it = $filter->iterProfiles();
     while ($p = $it->next()) {
         $pdf = ContactsPDF::addContact($pdf, $p, $arg0 == 'photos' || $arg1 == 'photos');
     }
     $pdf->Output();
     exit;
 }
Beispiel #2
0
 public static function AddContact(ContactsPDF $self, Profile $profile, $wp = true)
 {
     /* infamous hack :
           1- we store the current state.
           2- at the end, we find out if we triggered the page break,
              -> no ? ok
              -> yes ? then we have to create a col, and add the contact again.
        */
     $old = clone $self;
     $self->SetFont('Vera Sans', '', 10);
     $self->SetDrawColor(0);
     $self->SetFillColor(245, 248, 252);
     $self->SetLineWidth(0.4);
     $nom = utf8_decode($profile->full_name);
     $ok = false;
     if ($wp) {
         $photo = $profile->getPhoto(false, true);
         if ($photo) {
             list(, $type) = explode('/', $photo->mimeType());
             $type = $type == 'jpeg' ? 'jpg' : $type;
             if (method_exists($self, '_parse' . $type)) {
                 $old2 = clone $self;
                 $width = $photo->width() * 20 / $photo->height();
                 $_x = $self->getX();
                 $_y = $self->getY();
                 $self->Cell(0, 20, '', '', 0, '', 1);
                 error_reporting(0);
                 $self->Image($photo->path(), $_x, $_y, $width, 20, $type);
                 error_reporting($self->report);
                 if ($self->error) {
                     $self = clone $old2;
                 } else {
                     $self->setX($_x);
                     $self->Cell($width, 20, '', "T");
                     $h = 20 / $self->wordwrap($nom, 90 - $width);
                     $self->MultiCell(0, $h, $nom, 'T', 'C');
                     $ok = true;
                 }
             }
         }
     }
     if (!$ok) {
         $self->MultiCell(0, 6, $nom, "T", 'C', 1);
     }
     if ($profile->mobile) {
         $self->Space();
         $self->TableRow('mobile', utf8_decode($profile->mobile), 'Mono');
     }
     $it = $profile->iterAddresses(Profile::ADDRESS_ALL);
     while ($a = $it->next()) {
         $self->Space();
         $self->Address($a);
     }
     $it = $profile->getJobs(Profile::JOBS_CURRENT);
     foreach ($it as $a) {
         $self->Space();
         $self->AddressPro($a);
     }
     $self->Space(0.4, 5);
     if ($self->broken) {
         $old->NextCol();
         $self = ContactsPDF::AddContact($old, $profile, $wp);
     }
     return $self;
 }