mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 13:03:20 +00:00

Conflicts: CHANGELOG.md bin/console bin/developer bin/setup bower.json composer.json composer.lock features/bootstrap/FeatureContext.php features/bootstrap/GuiContext.php lib/Alchemy/Phrasea/Authentication/Token/TokenValidator.php lib/Alchemy/Phrasea/Command/BuildMissingSubdefs.php lib/Alchemy/Phrasea/Command/CreateCollection.php lib/Alchemy/Phrasea/Command/Developer/JavascriptBuilder.php lib/Alchemy/Phrasea/Controller/Admin/Collection.php lib/Alchemy/Phrasea/Controller/Admin/Databoxes.php lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php lib/Alchemy/Phrasea/Controller/Api/V1.php lib/Alchemy/Phrasea/Controller/Client/Baskets.php lib/Alchemy/Phrasea/Controller/Client/Root.php lib/Alchemy/Phrasea/Controller/Prod/Basket.php lib/Alchemy/Phrasea/Controller/Prod/Export.php lib/Alchemy/Phrasea/Controller/Prod/Property.php lib/Alchemy/Phrasea/Controller/Prod/Records.php lib/Alchemy/Phrasea/Controller/Prod/Tools.php lib/Alchemy/Phrasea/Controller/Prod/Upload.php lib/Alchemy/Phrasea/Controller/Root/Login.php lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php lib/Alchemy/Phrasea/Core/Event/ApiLoadEndEvent.php lib/Alchemy/Phrasea/Core/Event/ApiLoadStartEvent.php lib/Alchemy/Phrasea/Core/Provider/TaskManagerServiceProvider.php lib/Alchemy/Phrasea/Core/Version.php lib/Alchemy/Phrasea/Exception/XMLParseErrorException.php lib/Alchemy/Phrasea/Helper/DatabaseHelper.php lib/Alchemy/Phrasea/Helper/User/Edit.php lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php lib/Alchemy/Phrasea/SearchEngine/SearchEngineOptions.php lib/Doctrine/Entities/AuthFailure.php lib/Doctrine/Entities/Basket.php lib/Doctrine/Entities/BasketElement.php lib/Doctrine/Entities/LazaretAttribute.php lib/Doctrine/Entities/LazaretCheck.php lib/Doctrine/Entities/LazaretFile.php lib/Doctrine/Entities/LazaretSession.php lib/Doctrine/Entities/Session.php lib/Doctrine/Entities/SessionModule.php lib/Doctrine/Entities/StoryWZ.php lib/Doctrine/Entities/UsrList.php lib/Doctrine/Entities/UsrListEntry.php lib/Doctrine/Entities/UsrListOwner.php lib/Doctrine/Entities/ValidationData.php lib/Doctrine/Entities/ValidationParticipant.php lib/Doctrine/Entities/ValidationSession.php lib/Doctrine/Logger/MonologSQLLogger.php lib/Doctrine/Repositories/BasketRepository.php lib/Doctrine/Repositories/ValidationParticipantRepository.php lib/Doctrine/Types/Binary.php lib/Doctrine/Types/Blob.php lib/Doctrine/Types/Enum.php lib/Doctrine/Types/LongBlob.php lib/Doctrine/Types/VarBinary.php lib/classes/API/OAuth2/Account.php lib/classes/API/OAuth2/Application.php lib/classes/API/OAuth2/Application/OfficePlugin.php lib/classes/API/OAuth2/AuthCode.php lib/classes/API/OAuth2/RefreshToken.php lib/classes/API/OAuth2/Token.php lib/classes/API/V1/Abstract.php lib/classes/API/V1/Interface.php lib/classes/API/V1/adapter.php lib/classes/API/V1/exception/abstract.php lib/classes/API/V1/exception/badrequest.php lib/classes/API/V1/exception/forbidden.php lib/classes/API/V1/exception/internalservererror.php lib/classes/API/V1/exception/maintenance.php lib/classes/API/V1/exception/methodnotallowed.php lib/classes/API/V1/exception/notfound.php lib/classes/API/V1/exception/unauthorized.php lib/classes/API/V1/result.php lib/classes/Exception/Feed/EntryNotFound.php lib/classes/Exception/Feed/ItemNotFound.php lib/classes/Exception/Feed/PublisherNotFound.php lib/classes/Feed/Abstract.php lib/classes/Feed/Adapter.php lib/classes/Feed/Aggregate.php lib/classes/Feed/Collection.php lib/classes/Feed/CollectionInterface.php lib/classes/Feed/Entry/Adapter.php lib/classes/Feed/Entry/Collection.php lib/classes/Feed/Entry/CollectionInterface.php lib/classes/Feed/Entry/Interface.php lib/classes/Feed/Entry/Item.php lib/classes/Feed/Entry/ItemInterface.php lib/classes/Feed/Interface.php lib/classes/Feed/Link.php lib/classes/Feed/LinkInterface.php lib/classes/Feed/Publisher/Adapter.php lib/classes/Feed/Publisher/Interface.php lib/classes/Feed/Token.php lib/classes/Feed/TokenAggregate.php lib/classes/Feed/XML/Abstract.php lib/classes/Feed/XML/Atom.php lib/classes/Feed/XML/Cooliris.php lib/classes/Feed/XML/Interface.php lib/classes/Feed/XML/RSS.php lib/classes/Feed/XML/RSS/Image.php lib/classes/Feed/XML/RSS/ImageInterface.php lib/classes/User/Adapter.php lib/classes/User/Interface.php lib/classes/appbox/register.php lib/classes/connection.php lib/classes/connection/abstract.php lib/classes/connection/interface.php lib/classes/connection/pdo.php lib/classes/connection/pdoStatementDebugger.php lib/classes/deprecated/countries.php lib/classes/deprecated/inscript.api.php lib/classes/eventsmanager/event/test.php lib/classes/ftpclient.php lib/classes/http/request.php lib/classes/media/subdef.php lib/classes/module/console/schedulerStart.php lib/classes/module/console/schedulerState.php lib/classes/module/console/schedulerStop.php lib/classes/module/console/taskState.php lib/classes/module/console/tasklist.php lib/classes/module/console/taskrun.php lib/classes/patch/320alpha4b.php lib/classes/patch/3715alpha1a.php lib/classes/patch/379alpha1a.php lib/classes/patch/380alpha10a.php lib/classes/patch/380alpha11a.php lib/classes/patch/380alpha13a.php lib/classes/patch/380alpha14a.php lib/classes/patch/380alpha15a.php lib/classes/patch/380alpha16a.php lib/classes/patch/380alpha17a.php lib/classes/patch/380alpha18a.php lib/classes/patch/380alpha3a.php lib/classes/patch/380alpha4a.php lib/classes/patch/380alpha6a.php lib/classes/patch/380alpha8a.php lib/classes/patch/380alpha9a.php lib/classes/patch/381alpha1b.php lib/classes/patch/381alpha2a.php lib/classes/patch/381alpha3a.php lib/classes/patch/381alpha4a.php lib/classes/patch/383alpha1a.php lib/classes/patch/383alpha2a.php lib/classes/patch/383alpha3a.php lib/classes/patch/383alpha4a.php lib/classes/record/adapter.php lib/classes/record/preview.php lib/classes/recordutils.php lib/classes/recordutils/audio.php lib/classes/recordutils/document.php lib/classes/recordutils/map.php lib/classes/recordutils/video.php lib/classes/registry.php lib/classes/registryInterface.php lib/classes/set/order.php lib/classes/system/url.php lib/classes/task/Scheduler.php lib/classes/task/appboxAbstract.php lib/classes/task/databoxAbstract.php lib/classes/task/manager.php lib/classes/task/period/RecordMover.php lib/classes/task/period/apibridge.php lib/classes/task/period/apiwebhooks.php lib/classes/task/period/archive.php lib/classes/task/period/cindexer.php lib/classes/task/period/emptyColl.php lib/classes/task/period/ftp.php lib/classes/task/period/ftpPull.php lib/classes/task/period/subdef.php lib/classes/task/period/test.php lib/classes/task/period/writemeta.php lib/conf.d/PhraseaFixture/AbstractWZ.php lib/conf.d/PhraseaFixture/Basket/LoadFiveBaskets.php lib/conf.d/PhraseaFixture/Basket/LoadOneBasket.php lib/conf.d/PhraseaFixture/Basket/LoadOneBasketEnv.php lib/conf.d/PhraseaFixture/Lazaret/LoadOneFile.php lib/conf.d/PhraseaFixture/Story/LoadOneStory.php lib/conf.d/PhraseaFixture/UsrLists/ListAbstract.php lib/conf.d/PhraseaFixture/UsrLists/UsrList.php lib/conf.d/PhraseaFixture/UsrLists/UsrListEntry.php lib/conf.d/PhraseaFixture/UsrLists/UsrListOwner.php lib/conf.d/PhraseaFixture/ValidationParticipant/LoadOneParticipant.php lib/conf.d/PhraseaFixture/ValidationParticipant/LoadParticipantWithSession.php lib/conf.d/PhraseaFixture/ValidationSession/LoadOneValidationSession.php templates/web/admin/collection/collection.html.twig templates/web/common/dialog_export.html.twig templates/web/common/menubar.html.twig templates/web/prod/actions/Tools/index.html.twig templates/web/prod/index.html.twig templates/web/prod/upload/upload-flash.html.twig templates/web/prod/upload/upload.html.twig templates/web/report/report_layout_child.html.twig templates/web/setup/step2.html.twig templates/web/thesaurus/new-synonym-dialog.html.twig templates/web/thesaurus/properties.html.twig templates/web/thesaurus/search.html.twig tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php tests/Alchemy/Tests/Phrasea/Cache/FactoryTest.php tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminCollectionTest.php tests/Alchemy/Tests/Phrasea/Controller/Client/RootTest.php
503 lines
18 KiB
PHP
503 lines
18 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Phraseanet
|
|
*
|
|
* (c) 2005-2015 Alchemy
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Alchemy\Phrasea\Out\Module;
|
|
|
|
use Alchemy\Phrasea\Application;
|
|
use Alchemy\Phrasea\Out\Tool\PhraseaPDF;
|
|
|
|
class PDF
|
|
{
|
|
protected $app;
|
|
protected $records;
|
|
protected $pdf;
|
|
|
|
const LAYOUT_PREVIEW = 'preview';
|
|
const LAYOUT_PREVIEWCAPTION = 'previewCaption';
|
|
const LAYOUT_PREVIEWCAPTIONTDM = 'previewCaptionTdm';
|
|
const LAYOUT_THUMBNAILLIST = 'thumbnailList';
|
|
const LAYOUT_THUMBNAILGRID = 'thumbnailGrid';
|
|
|
|
public function __construct(Application $app, array $records, $layout)
|
|
{
|
|
$this->app = $app;
|
|
|
|
$list = [];
|
|
|
|
foreach ($records as $record) {
|
|
switch ($layout) {
|
|
default:
|
|
throw new \Exception('Unknown layout');
|
|
break;
|
|
case self::LAYOUT_PREVIEW:
|
|
case self::LAYOUT_PREVIEWCAPTION:
|
|
case self::LAYOUT_PREVIEWCAPTIONTDM:
|
|
try {
|
|
$subdef = $record->get_subdef('preview');
|
|
// fallback to thumbnail ( video, sound, doc ) ..
|
|
if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE) {
|
|
$subdef = $record->get_thumbnail();
|
|
}
|
|
|
|
if (!$subdef->is_physically_present()) {
|
|
continue 2;
|
|
}
|
|
|
|
if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE) {
|
|
continue 2;
|
|
}
|
|
} catch (\Exception $e) {
|
|
continue 2;
|
|
}
|
|
break;
|
|
case self::LAYOUT_THUMBNAILLIST:
|
|
case self::LAYOUT_THUMBNAILGRID:
|
|
try {
|
|
$subdef = $record->get_thumbnail();
|
|
if (!$subdef->is_physically_present()) {
|
|
continue 2;
|
|
}
|
|
|
|
if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE) {
|
|
continue 2;
|
|
}
|
|
} catch (\Exception $e) {
|
|
continue 2;
|
|
}
|
|
break;
|
|
}
|
|
|
|
$record->set_number(count($list) + 1);
|
|
|
|
$list[] = $record;
|
|
}
|
|
|
|
$this->records = $list;
|
|
|
|
$pdf = new PhraseaPDF("P", "mm", "A4", true, 'UTF-8', false);
|
|
|
|
$pdf->SetAuthor("Phraseanet");
|
|
$pdf->SetTitle("Phraseanet Print");
|
|
$pdf->SetDisplayMode("fullpage", "single");
|
|
|
|
$this->pdf = $pdf;
|
|
|
|
switch ($layout) {
|
|
case self::LAYOUT_PREVIEW:
|
|
$this->print_preview(false, false);
|
|
break;
|
|
case self::LAYOUT_PREVIEWCAPTION:
|
|
$this->print_preview(false, true);
|
|
break;
|
|
case self::LAYOUT_PREVIEWCAPTIONTDM:
|
|
$this->print_preview(true, true);
|
|
break;
|
|
case self::LAYOUT_THUMBNAILLIST:
|
|
$this->print_thumbnailList();
|
|
break;
|
|
case self::LAYOUT_THUMBNAILGRID:
|
|
$this->print_thumbnailGrid();
|
|
break;
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
$this->pdf->Close();
|
|
|
|
return $this->pdf->Output('', 'S');
|
|
}
|
|
|
|
protected function print_thumbnailGrid($links = false)
|
|
{
|
|
$NDiapoW = 3;
|
|
$NDiapoH = 4;
|
|
|
|
$this->pdf->AddPage();
|
|
|
|
$oldMargins = $this->pdf->getMargins();
|
|
$tmargin = $oldMargins['top'];
|
|
$lmargin = $oldMargins['left'];
|
|
$bmargin = $oldMargins['bottom'];
|
|
$rmargin = $oldMargins['right'];
|
|
|
|
$this->pdf->SetLeftMargin($lmargin + 55);
|
|
|
|
$clientW = $this->pdf->getPageWidth() - $lmargin - $rmargin;
|
|
$clientH = $this->pdf->getPageHeight() - $tmargin - $bmargin;
|
|
|
|
$DiapoW = floor($clientW / $NDiapoW);
|
|
$DiapoH = floor($clientH / $NDiapoH);
|
|
$TitleH = 5;
|
|
$ImgSize = min($DiapoW, ($DiapoH - $TitleH)) - 5;
|
|
|
|
$npages = ceil(count($this->records) / ($NDiapoW * $NDiapoH));
|
|
|
|
$irow = $ipage = 0;
|
|
$icol = -1;
|
|
foreach ($this->records as $rec) {
|
|
/* @var $rec record_adapter */
|
|
if (++$icol >= $NDiapoW) {
|
|
$icol = 0;
|
|
if (++$irow >= $NDiapoH) {
|
|
$irow = 0;
|
|
$ipage++;
|
|
$this->pdf->AddPage();
|
|
}
|
|
}
|
|
$fimg = null;
|
|
$himg = 0;
|
|
|
|
$subdef = $rec->get_subdef('preview');
|
|
|
|
if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE) {
|
|
$subdef = $rec->get_thumbnail();
|
|
}
|
|
|
|
$fimg = $subdef->get_pathfile();
|
|
|
|
if (!$this->app['acl']->get($this->app['authentication']->getUser())->has_right_on_base($rec->get_base_id(), "nowatermark")
|
|
&& $subdef->get_type() == \media_subdef::TYPE_IMAGE) {
|
|
$fimg = \recordutils_image::watermark($this->app, $subdef);
|
|
}
|
|
|
|
$wimg = $himg = $ImgSize;
|
|
if ($subdef->get_height() > 0 && $subdef->get_width() > 0) {
|
|
if ($subdef->get_width() > $subdef->get_height())
|
|
$himg = $wimg * $subdef->get_height() / $subdef->get_width();
|
|
else
|
|
$wimg = $himg * $subdef->get_width() / $subdef->get_height();
|
|
}
|
|
|
|
if ($fimg) {
|
|
$x = $lmargin + ($icol * $DiapoW);
|
|
$y = $tmargin + ($irow * $DiapoH);
|
|
$this->pdf->SetDrawColor(0);
|
|
$this->pdf->Rect($x, $y, $DiapoW, $DiapoH, "D");
|
|
|
|
$this->pdf->SetXY($x, $y + 1);
|
|
$this->pdf->SetFont(PhraseaPDF::FONT, '', 10);
|
|
$t = $irow . '-' . $x;
|
|
$t = $rec->get_title();
|
|
|
|
$this->pdf->MultiCell($DiapoW, $TitleH, $t, '0', 'C', false);
|
|
|
|
if ($links) {
|
|
$lk = $this->pdf->AddLink();
|
|
$this->pdf->SetLink($lk, 0, $npages + $rec->get_number());
|
|
$this->pdf->Image(
|
|
$fimg
|
|
, $x + (($DiapoW - $wimg) / 2)
|
|
, $TitleH + $y + (($DiapoH - $TitleH - $himg) / 2)
|
|
, $wimg, $himg
|
|
, null, $lk
|
|
);
|
|
} else {
|
|
$this->pdf->Image($fimg
|
|
, $x + (($DiapoW - $wimg) / 2)
|
|
, $TitleH + $y + (($DiapoH - $TitleH - $himg) / 2)
|
|
, $wimg, $himg
|
|
);
|
|
}
|
|
}
|
|
}
|
|
$this->pdf->SetLeftMargin($oldMargins['left']);
|
|
}
|
|
|
|
protected function print_thumbnailList()
|
|
{
|
|
$this->pdf->AddPage();
|
|
$oldMargins = $this->pdf->getMargins();
|
|
|
|
$lmargin = $oldMargins['left'];
|
|
$rmargin = $oldMargins['right'];
|
|
|
|
$this->pdf->SetLeftMargin($lmargin + 55);
|
|
|
|
$ndoc = 0;
|
|
foreach ($this->records as $rec) {
|
|
/* @var $rec record_adapter */
|
|
$subdef = $rec->get_subdef('thumbnail');
|
|
|
|
$fimg = $subdef->get_pathfile();
|
|
|
|
$wimg = $himg = 50;
|
|
// 1px = 3.77952 mm
|
|
$finalWidth = round($subdef->get_width() / 3.779528, 2);
|
|
$finalHeight = round($subdef->get_height() / 3.779528, 2);
|
|
$aspectH = $finalWidth/$finalHeight;
|
|
$aspectW = $finalHeight/$finalWidth;
|
|
|
|
if ($finalWidth > 0 && $finalHeight > 0) {
|
|
if ($finalWidth > $finalHeight && $finalWidth > $wimg) {
|
|
$finalWidth = $wimg;
|
|
$finalHeight = $wimg * $aspectW;
|
|
} else if ($finalHeight > $finalWidth && $finalHeight > $himg) {
|
|
$finalHeight = $himg;
|
|
$finalWidth = $himg * $aspectH;
|
|
} else if ($finalHeight == $finalWidth & $finalWidth > $wimg) {
|
|
$finalHeight = $wimg;
|
|
$finalWidth = $himg;
|
|
}
|
|
}
|
|
|
|
if ($this->pdf->GetY() > $this->pdf->getPageHeight() - (6 + $finalHeight + 20))
|
|
$this->pdf->AddPage();
|
|
|
|
$title = "record : " . $rec->get_title();
|
|
|
|
$y = $this->pdf->GetY();
|
|
|
|
$t = \phrasea::bas_labels($rec->get_base_id(), $this->app);
|
|
$this->pdf->SetFont(PhraseaPDF::FONT, '', 10);
|
|
$this->pdf->SetFillColor(220, 220, 220);
|
|
$this->pdf->SetLeftMargin($lmargin);
|
|
$this->pdf->SetRightMargin($rmargin);
|
|
$this->pdf->SetX($lmargin);
|
|
$this->pdf->SetY($y);
|
|
|
|
$this->pdf->out = false;
|
|
$this->pdf->MultiCell(140, 4, $title, "LTR", "L", 1);
|
|
$y2 = $this->pdf->GetY();
|
|
$h = $y2 - $y;
|
|
$this->pdf->out = true;
|
|
$this->pdf->SetX($lmargin);
|
|
$this->pdf->SetY($y);
|
|
$this->pdf->Cell(0, $h, "", "LTR", 1, "R", 1);
|
|
$this->pdf->SetX($lmargin);
|
|
$this->pdf->SetY($y);
|
|
$this->pdf->Cell(0, 4, $t, "", 1, "R");
|
|
$this->pdf->SetX($lmargin);
|
|
$this->pdf->SetY($y);
|
|
$this->pdf->MultiCell(140, 4, $title, "", "L");
|
|
$this->pdf->SetX($lmargin);
|
|
$this->pdf->SetY($y = $y2);
|
|
|
|
$this->pdf->SetLeftMargin($lmargin + 55);
|
|
$this->pdf->SetY($y + 2);
|
|
|
|
if ($fimg) {
|
|
$y = $this->pdf->GetY();
|
|
$this->pdf->Image($fimg, $lmargin, $y, $finalWidth, $finalHeight);
|
|
$this->pdf->SetY($y + 3);
|
|
}
|
|
|
|
$nf = 0;
|
|
$this->pdf->SetX($lmargin + 55);
|
|
$p0 = $this->pdf->PageNo();
|
|
$y0 = $this->pdf->GetY();
|
|
foreach ($rec->get_caption()->get_fields() as $field) {
|
|
/* @var $field caption_field */
|
|
|
|
$this->pdf->SetFont(PhraseaPDF::FONT, 'B', 12);
|
|
$this->pdf->Write(5, $field->get_name() . " : ");
|
|
|
|
$this->pdf->SetFont(PhraseaPDF::FONT, '', 12);
|
|
$this->pdf->Write(5, $field->get_serialized_values());
|
|
|
|
$this->pdf->Write(6, "\n");
|
|
$nf++;
|
|
}
|
|
if ($this->pdf->PageNo() == $p0 && ($this->pdf->GetY() - $y0) < $finalHeight)
|
|
$this->pdf->SetY($y0 + $finalHeight);
|
|
$ndoc++;
|
|
}
|
|
$this->pdf->SetLeftMargin($lmargin);
|
|
}
|
|
|
|
protected function print_preview($withtdm, $write_caption)
|
|
{
|
|
if ($withtdm === true) {
|
|
$this->print_thumbnailGrid($this->pdf, $this->records, true);
|
|
}
|
|
|
|
foreach ($this->records as $krec => $rec) {
|
|
/* @var $rec record_adapter */
|
|
|
|
$this->pdf->AddPage();
|
|
|
|
if ($withtdm === "CALCPAGES") {
|
|
$rec->set_number($this->pdf->PageNo());
|
|
}
|
|
$lmargin = $this->pdf->GetX();
|
|
$himg = 0;
|
|
$y = 0;
|
|
$miniConv = NULL;
|
|
|
|
$LEFT__TEXT = "";
|
|
$LEFT__IMG = NULL;
|
|
$RIGHT_TEXT = "";
|
|
$RIGHT_IMG = NULL;
|
|
|
|
$LEFT__IMG = $this->app['root.path'] . "/config/minilogos/logopdf_" . $rec->get_sbas_id();
|
|
|
|
if (!is_file($LEFT__IMG)) {
|
|
$databox = $rec->get_databox();
|
|
$str = $databox->get_sxml_structure();
|
|
$vn = (string) ($str->pdfPrintLogo);
|
|
if (($vn * 1) == 1) {
|
|
$LEFT__TEXT = $databox->get_label($this->app['locale']);
|
|
}
|
|
}
|
|
|
|
$collection = \collection::get_from_base_id($this->app, $rec->get_base_id());
|
|
|
|
$vn = "";
|
|
if (false !== $str = simplexml_load_string($collection->get_prefs())) {
|
|
$vn = (string) ($str->pdfPrintappear);
|
|
}
|
|
|
|
if ($vn == "" || $vn == "1") {
|
|
$RIGHT_TEXT = \phrasea::bas_labels($rec->get_base_id(), $this->app);
|
|
} elseif ($vn == "2") {
|
|
$RIGHT_IMG = $this->app['root.path'] . "/config/minilogos/" . $rec->get_base_id();
|
|
}
|
|
|
|
$xtmp = $this->pdf->GetX();
|
|
$ytmp = $this->pdf->GetY();
|
|
|
|
$this->pdf->SetFont(PhraseaPDF::FONT, '', 12);
|
|
$this->pdf->SetFillColor(220, 220, 220);
|
|
$y = $this->pdf->GetY();
|
|
$this->pdf->MultiCell(95, 7, $LEFT__TEXT, "LTB", "L", 1);
|
|
$y2 = $this->pdf->GetY();
|
|
$h = $y2 - $y;
|
|
$this->pdf->SetY($y);
|
|
$this->pdf->SetX(105);
|
|
$this->pdf->Cell(95, $h, $RIGHT_TEXT, "TBR", 1, "R", 1);
|
|
|
|
if ($LEFT__TEXT == "" && is_file($LEFT__IMG)) {
|
|
if ($size = @getimagesize($LEFT__IMG)) {
|
|
$wmm = (int) $size[0] * 25.4 / 72;
|
|
$hmm = (int) $size[1] * 25.4 / 72;
|
|
if ($hmm > 6) {
|
|
$coeff = $hmm / 6;
|
|
$wmm = (int) $wmm / $coeff;
|
|
$hmm = (int) $hmm / $coeff;
|
|
}
|
|
$this->pdf->Image($LEFT__IMG, $xtmp + 0.5, $ytmp + 0.5, $wmm, $hmm);
|
|
}
|
|
}
|
|
|
|
if ($RIGHT_IMG != NULL && is_file($RIGHT_IMG)) {
|
|
if ($size = @getimagesize($RIGHT_IMG)) {
|
|
|
|
if ($size[2] == '1') {
|
|
if (!isset($miniConv[$RIGHT_IMG])) {
|
|
$tmp_filename = tempnam('minilogos/', 'gif4fpdf');
|
|
$img = imagecreatefromgif($RIGHT_IMG);
|
|
imageinterlace($img, 0);
|
|
imagepng($img, $tmp_filename);
|
|
rename($tmp_filename, $tmp_filename . '.png');
|
|
$miniConv[$RIGHT_IMG] = $tmp_filename . '.png';
|
|
$RIGHT_IMG = $tmp_filename . '.png';
|
|
} else
|
|
$RIGHT_IMG = $miniConv[$RIGHT_IMG];
|
|
|
|
$wmm = (int) $size[0] * 25.4 / 72;
|
|
$hmm = (int) $size[1] * 25.4 / 72;
|
|
if ($hmm > 6) {
|
|
$coeff = $hmm / 6;
|
|
$wmm = (int) $wmm / $coeff;
|
|
$hmm = (int) $hmm / $coeff;
|
|
}
|
|
$tt = 0;
|
|
if ($hmm < 6)
|
|
$tt = (6 - $hmm) / 2;
|
|
$this->pdf->Image($RIGHT_IMG, 200 - 0.5 - $wmm, $ytmp + 0.5 + $tt);
|
|
} else {
|
|
$wmm = (int) $size[0] * 25.4 / 72;
|
|
$hmm = (int) $size[1] * 25.4 / 72;
|
|
if ($hmm > 6) {
|
|
$coeff = $hmm / 6;
|
|
$wmm = (int) $wmm / $coeff;
|
|
$hmm = (int) $hmm / $coeff;
|
|
}
|
|
$this->pdf->Image($RIGHT_IMG, 200 - 0.5 - $wmm, $ytmp + 0.5);
|
|
}
|
|
}
|
|
}
|
|
|
|
$y = $this->pdf->GetY() + 5;
|
|
|
|
$subdef = $rec->get_subdef('preview');
|
|
|
|
if ($subdef->get_type() !== \media_subdef::TYPE_IMAGE) {
|
|
$subdef = $rec->get_thumbnail();
|
|
}
|
|
|
|
$f = $subdef->get_pathfile();
|
|
|
|
if (!$this->app['acl']->get($this->app['authentication']->getUser())->has_right_on_base($rec->get_base_id(), "nowatermark")
|
|
&& $subdef->get_type() == \media_subdef::TYPE_IMAGE)
|
|
$f = \recordutils_image::watermark($this->app, $subdef);
|
|
|
|
// original height / original width x new width = new height
|
|
$wimg = $himg = 150; // preview dans un carre de 150 mm
|
|
// 1px = 3.77952 mm
|
|
$finalWidth = round($subdef->get_width() / 3.779528, 2);
|
|
$finalHeight = round($subdef->get_height() / 3.779528, 2);
|
|
$aspectH = $finalWidth/$finalHeight;
|
|
$aspectW = $finalHeight/$finalWidth;
|
|
|
|
if ($finalWidth > 0 && $finalHeight > 0) {
|
|
if ($finalWidth > $finalHeight && $finalWidth > $wimg) {
|
|
$finalWidth = $wimg;
|
|
$finalHeight = $wimg * $aspectW;
|
|
} else if ($finalHeight > $finalWidth && $finalHeight > $himg) {
|
|
$finalHeight = $himg;
|
|
$finalWidth = $himg * $aspectH;
|
|
} else if ($finalHeight == $finalWidth & $finalWidth > $wimg) {
|
|
$finalHeight = $wimg;
|
|
$finalWidth = $himg;
|
|
}
|
|
}
|
|
|
|
$this->pdf->Image($f, (210 - $finalWidth) / 2, $y, $finalWidth, $finalHeight);
|
|
|
|
if ($miniConv != NULL) {
|
|
foreach ($miniConv as $oneF)
|
|
unlink($oneF);
|
|
}
|
|
$this->pdf->SetXY($lmargin, $y += ( $finalHeight + 5));
|
|
|
|
$nf = 0;
|
|
if ($write_caption) {
|
|
foreach ($rec->get_caption()->get_fields() as $field) {
|
|
/* @var $field caption_field */
|
|
if ($nf > 0) {
|
|
$this->pdf->Write(6, "\n");
|
|
}
|
|
|
|
$this->pdf->SetFont(PhraseaPDF::FONT, 'B', 12);
|
|
$this->pdf->Write(5, $field->get_name() . " : ");
|
|
|
|
$this->pdf->SetFont(PhraseaPDF::FONT, '', 12);
|
|
|
|
$t = str_replace(
|
|
["<", ">", "&"]
|
|
, ["<", ">", "&"]
|
|
, strip_tags($field->get_serialized_values())
|
|
);
|
|
|
|
$this->pdf->Write(5, $t);
|
|
|
|
$nf++;
|
|
}
|
|
}
|
|
}
|
|
|
|
return;
|
|
}
|
|
}
|