mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Merge branch 'master' into PHRAS-3631-read-all-notifications
This commit is contained in:
@@ -11,10 +11,12 @@ namespace Alchemy\Phrasea\Controller\Prod;
|
|||||||
|
|
||||||
use Alchemy\Phrasea\Application\Helper\DataboxLoggerAware;
|
use Alchemy\Phrasea\Application\Helper\DataboxLoggerAware;
|
||||||
use Alchemy\Phrasea\Controller\Controller;
|
use Alchemy\Phrasea\Controller\Controller;
|
||||||
|
use Alchemy\Phrasea\Controller\RecordsRequest;
|
||||||
use Alchemy\Phrasea\Helper\Record as RecordHelper;
|
use Alchemy\Phrasea\Helper\Record as RecordHelper;
|
||||||
use Alchemy\Phrasea\Out\Module\PDFRecords;
|
use Alchemy\Phrasea\Out\Module\PDFRecords;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
|
||||||
|
|
||||||
class PrinterController extends Controller
|
class PrinterController extends Controller
|
||||||
{
|
{
|
||||||
@@ -31,9 +33,25 @@ class PrinterController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pdfTitle = '';
|
||||||
|
$storyId = null;
|
||||||
|
|
||||||
|
if ($printer->is_basket()) {
|
||||||
|
$pdfTitle = $printer->get_original_basket()->getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
$r = RecordsRequest::fromRequest($this->app, $request, false);
|
||||||
|
|
||||||
|
if ($r->isSingleStory()) {
|
||||||
|
$pdfTitle = $r->singleStory()->get_title();
|
||||||
|
$storyId = $r->singleStory()->getId();
|
||||||
|
}
|
||||||
|
|
||||||
return $this->render('prod/actions/printer_default.html.twig', [
|
return $this->render('prod/actions/printer_default.html.twig', [
|
||||||
'printer' => $printer,
|
'printer' => $printer,
|
||||||
'message' => '',
|
'message' => '',
|
||||||
|
'storyId' => $storyId,
|
||||||
|
'pdfTitle'=> $pdfTitle,
|
||||||
'basketFeedbackId' => $basketFeedbackId,
|
'basketFeedbackId' => $basketFeedbackId,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -66,10 +84,23 @@ class PrinterController extends Controller
|
|||||||
|
|
||||||
$PDF = new PDFRecords($this->app, $printer, $layout, $title, $description, $userPassword, $canDownload, $downloadSubdef);
|
$PDF = new PDFRecords($this->app, $printer, $layout, $title, $description, $userPassword, $canDownload, $downloadSubdef);
|
||||||
|
|
||||||
|
$pdfName = '';
|
||||||
|
|
||||||
|
if (!empty($title)) {
|
||||||
|
$pdfName = $printer->normalizeString($title);
|
||||||
|
$pdfName .= '.pdf';
|
||||||
|
}
|
||||||
|
|
||||||
$response = new Response($PDF->render(), 200, array('Content-Type' => 'application/pdf'));
|
$response = new Response($PDF->render(), 200, array('Content-Type' => 'application/pdf'));
|
||||||
$response->headers->set('Pragma', 'public', true);
|
$response->headers->set('Pragma', 'public', true);
|
||||||
$response->setMaxAge(0);
|
$response->setMaxAge(0);
|
||||||
|
|
||||||
|
$disposition = $response->headers->makeDisposition(
|
||||||
|
ResponseHeaderBag::DISPOSITION_INLINE,
|
||||||
|
$pdfName
|
||||||
|
);
|
||||||
|
$response->headers->set('Content-Disposition', $disposition);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,6 +14,8 @@ namespace Alchemy\Phrasea\Helper\Record;
|
|||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Alchemy\Phrasea\Helper\Record\Helper as RecordHelper;
|
use Alchemy\Phrasea\Helper\Record\Helper as RecordHelper;
|
||||||
use Alchemy\Phrasea\Media\Subdef\Subdef;
|
use Alchemy\Phrasea\Media\Subdef\Subdef;
|
||||||
|
use Alchemy\Phrasea\Out\Module\PDFRecords;
|
||||||
|
use Cocur\Slugify\Slugify;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
class Printer extends RecordHelper
|
class Printer extends RecordHelper
|
||||||
@@ -23,6 +25,7 @@ class Printer extends RecordHelper
|
|||||||
private $previewName = 'preview';
|
private $previewName = 'preview';
|
||||||
private $urlTtl = null;
|
private $urlTtl = null;
|
||||||
private $titleAsDownloadName = true;
|
private $titleAsDownloadName = true;
|
||||||
|
private $slugify;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \ACL
|
* @var \ACL
|
||||||
@@ -211,4 +214,20 @@ class Printer extends RecordHelper
|
|||||||
return $this->titleAsDownloadName;
|
return $this->titleAsDownloadName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function sanitizeString($string)
|
||||||
|
{
|
||||||
|
return str_replace(['/', '\\'], '', $string);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function normalizeString($string)
|
||||||
|
{
|
||||||
|
if (!isset($this->slugify)) {
|
||||||
|
$this->slugify = new Slugify();
|
||||||
|
}
|
||||||
|
|
||||||
|
$string = $this->sanitizeString($string);
|
||||||
|
|
||||||
|
return mb_substr($this->slugify->slugify($string, '-'), 0, PDFRecords::$maxFilenameLength);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,7 @@ use \IntlDateFormatter as DateFormatter;
|
|||||||
|
|
||||||
class PDFRecords extends PDF
|
class PDFRecords extends PDF
|
||||||
{
|
{
|
||||||
private static $maxFilenameLength = 256;
|
public static $maxFilenameLength = 256;
|
||||||
|
|
||||||
/** @var Printer */
|
/** @var Printer */
|
||||||
private $printer;
|
private $printer;
|
||||||
@@ -992,7 +992,7 @@ class PDFRecords extends PDF
|
|||||||
$this->pdfTitle,
|
$this->pdfTitle,
|
||||||
'', 1, 'C', false);
|
'', 1, 'C', false);
|
||||||
|
|
||||||
$this->pdf->Write(20, "\n");
|
$this->pdf->SetY($this->pdf->GetY() + 15);
|
||||||
|
|
||||||
$this->pdf->SetFont(PhraseaPDF::FONT, '', 12);
|
$this->pdf->SetFont(PhraseaPDF::FONT, '', 12);
|
||||||
$this->pdf->writeHTML($this->pdfDescription);
|
$this->pdf->writeHTML($this->pdfDescription);
|
||||||
|
@@ -2,6 +2,14 @@
|
|||||||
<form target="_blank" name="formprintpage" method="POST" action="{{ path('prod_printer_print') }}">
|
<form target="_blank" name="formprintpage" method="POST" action="{{ path('prod_printer_print') }}">
|
||||||
<div id="printBox">
|
<div id="printBox">
|
||||||
<div style="padding:10px;">
|
<div style="padding:10px;">
|
||||||
|
<div style="margin: 20px 5px;">
|
||||||
|
<h4 style="margin-left: 0px;">{{ 'print:: pdf title' | trans }}</h4>
|
||||||
|
<input type="text" value="{{ pdfTitle }}" name="print-pdf-title" class="print-pdf-title" style="margin-left: 0px;width: 530px;padding-left: 0px;padding-right: 0px;margin-right: 0px;"/>
|
||||||
|
</div>
|
||||||
|
<div style="margin: 20px 5px;">
|
||||||
|
<h4 style="margin-left: 0px;">{{ 'print:: pdf description' | trans }}</h4>
|
||||||
|
<textarea name="print-pdf-description" class="print-pdf-description" id="print-pdf-description" cols="0" rows="5" style="margin-left: 20px;width:660px;"></textarea>
|
||||||
|
</div>
|
||||||
<h3 style="margin-left: 5px;">{{ 'print:: choose model' | trans }}</h3>
|
<h3 style="margin-left: 5px;">{{ 'print:: choose model' | trans }}</h3>
|
||||||
|
|
||||||
{% set total_count = printer.get_count_actionable() %}
|
{% set total_count = printer.get_count_actionable() %}
|
||||||
@@ -57,14 +65,6 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<h3 style="margin-left: 5px;">{{ 'print:: some options' | trans }}</h3>
|
<h3 style="margin-left: 5px;">{{ 'print:: some options' | trans }}</h3>
|
||||||
<div style="margin: 20px 5px;">
|
|
||||||
<h4 style="margin-left: 0px;">{{ 'print:: pdf title' | trans }}</h4>
|
|
||||||
<input type="text" value="" name="print-pdf-title" class="print-pdf-title" style="margin-left: 0px;width: 530px;padding-left: 0px;padding-right: 0px;margin-right: 0px;"/>
|
|
||||||
</div>
|
|
||||||
<div style="margin: 20px 5px;">
|
|
||||||
<h4 style="margin-left: 0px;">{{ 'print:: pdf description' | trans }}</h4>
|
|
||||||
<textarea name="print-pdf-description" class="print-pdf-description" id="" cols="0" rows="5" style="margin-left: 20px;width:530px;"></textarea>
|
|
||||||
</div>
|
|
||||||
<div style="margin: 20px 5px;">
|
<div style="margin: 20px 5px;">
|
||||||
<h4 style="margin-left: 0px;">{{ 'print:: add and remember password to protect the pdf' | trans }}</h4>
|
<h4 style="margin-left: 0px;">{{ 'print:: add and remember password to protect the pdf' | trans }}</h4>
|
||||||
<input type="text" value="" name="print-pdf-password" style="margin-left: 0px;width: 530px;padding-left: 0px;padding-right: 0px;margin-right: 0px;"/>
|
<input type="text" value="" name="print-pdf-password" style="margin-left: 0px;width: 530px;padding-left: 0px;padding-right: 0px;margin-right: 0px;"/>
|
||||||
@@ -158,6 +158,7 @@
|
|||||||
{% if printer.get_count_thumbnail() > 0 or printer.get_count_preview() > 0 %}
|
{% if printer.get_count_thumbnail() > 0 or printer.get_count_preview() > 0 %}
|
||||||
<div style="margin-bottom: 10px; text-align: center;">
|
<div style="margin-bottom: 10px; text-align: center;">
|
||||||
<input type="hidden" name="lst" value="{{ printer.get_serialize_list }}" />
|
<input type="hidden" name="lst" value="{{ printer.get_serialize_list }}" />
|
||||||
|
<input type="hidden" name="storyId" value="{{ storyId }}" />
|
||||||
<button type="submit" class="btn btn-inverse">{{ 'boutton::imprimer' | trans }}</button>
|
<button type="submit" class="btn btn-inverse">{{ 'boutton::imprimer' | trans }}</button>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Reference in New Issue
Block a user