Update PDF output

This commit is contained in:
Romain Neutron
2012-09-21 15:52:03 +02:00
parent 86eadb1e9b
commit 4809cd30bc

View File

@@ -11,6 +11,8 @@
namespace Alchemy\Phrasea\Out\Module; namespace Alchemy\Phrasea\Out\Module;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Configuration;
use Alchemy\Phrasea\Out\Tool\PhraseaPDF; use Alchemy\Phrasea\Out\Tool\PhraseaPDF;
/** /**
@@ -21,6 +23,7 @@ use Alchemy\Phrasea\Out\Tool\PhraseaPDF;
*/ */
class PDF class PDF
{ {
protected $app;
protected $records; protected $records;
protected $pdf; protected $pdf;
@@ -30,8 +33,10 @@ class PDF
const LAYOUT_THUMBNAILLIST = 'thumbnailList'; const LAYOUT_THUMBNAILLIST = 'thumbnailList';
const LAYOUT_THUMBNAILGRID = 'thumbnailGrid'; const LAYOUT_THUMBNAILGRID = 'thumbnailGrid';
public function __construct(array $records, $layout) public function __construct(Application $app, array $records, $layout)
{ {
$this->app = $app;
$list = array(); $list = array();
foreach ($records as $record) { foreach ($records as $record) {
@@ -120,8 +125,7 @@ class PDF
protected function print_thumbnailGrid($links = false) protected function print_thumbnailGrid($links = false)
{ {
$core = \bootstrap::getCore(); $user = $this->app['phraseanet.user'];
$user = $core->getAuthenticatedUser();
$NDiapoW = 3; $NDiapoW = 3;
$NDiapoH = 4; $NDiapoH = 4;
@@ -167,7 +171,7 @@ class PDF
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($this->app, $subdef);
} }
$wimg = $himg = $ImgSize; $wimg = $himg = $ImgSize;
@@ -248,7 +252,7 @@ class PDF
$y = $this->pdf->GetY(); $y = $this->pdf->GetY();
$t = \phrasea::bas_names($rec->get_base_id()); $t = \phrasea::bas_names($rec->get_base_id(), $this->app);
$this->pdf->SetFont(PhraseaPDF::FONT, '', 10); $this->pdf->SetFont(PhraseaPDF::FONT, '', 10);
$this->pdf->SetFillColor(220, 220, 220); $this->pdf->SetFillColor(220, 220, 220);
$this->pdf->SetLeftMargin($lmargin); $this->pdf->SetLeftMargin($lmargin);
@@ -307,10 +311,8 @@ class PDF
protected function print_preview($withtdm, $write_caption) protected function print_preview($withtdm, $write_caption)
{ {
$core = \bootstrap::getCore(); $registry = $this->app['phraseanet.registry'];
$appbox = \appbox::get_instance($core); $user = $this->app['phraseanet.user'];
$registry = \registry::get_instance();
$user = \User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
if ($withtdm === true) { if ($withtdm === true) {
$this->print_thumbnailGrid($this->pdf, $this->records, true); $this->print_thumbnailGrid($this->pdf, $this->records, true);
@@ -350,14 +352,14 @@ class PDF
} }
} }
$collection = \collection::get_from_base_id($rec->get_base_id()); $collection = \collection::get_from_base_id($this->app, $rec->get_base_id());
$vn = ""; $vn = "";
if ($str = simplexml_load_string($collection->get_prefs())) if ($str = simplexml_load_string($collection->get_prefs()))
$vn = (string) ($str->pdfPrintappear); $vn = (string) ($str->pdfPrintappear);
if ($vn == "" || $vn == "1") { if ($vn == "" || $vn == "1") {
$RIGHT_TEXT = \phrasea::bas_names($rec->get_base_id()); $RIGHT_TEXT = \phrasea::bas_names($rec->get_base_id(), $this->app);
} elseif ($vn == "2") { } elseif ($vn == "2") {
$RIGHT_IMG = $registry->get('GV_RootPath') . "config/minilogos/" . $rec->get_base_id(); $RIGHT_IMG = $registry->get('GV_RootPath') . "config/minilogos/" . $rec->get_base_id();
} }
@@ -435,7 +437,7 @@ class PDF
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($this->app, $subdef);
$wimg = $himg = 150; // preview dans un carre de 150 mm $wimg = $himg = 150; // preview dans un carre de 150 mm
if ($subdef->get_width() > 0 && $subdef->get_height() > 0) { if ($subdef->get_width() > 0 && $subdef->get_height() > 0) {