Inital commit

This commit is contained in:
2020-11-19 15:36:28 +01:00
parent 71f32f83d3
commit 66ce4ee218
18077 changed files with 2166122 additions and 35184 deletions

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns="http://thelia.net/schema/dic/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
</config>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="http://thelia.net/schema/dic/module"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/module http://thelia.net/schema/dic/module/module-2_2.xsd">
<fullnamespace>PdfGenerator\PdfGenerator</fullnamespace>
<descriptive locale="en_US">
<title>A PDF generator</title>
</descriptive>
<descriptive locale="fr_FR">
<title>Un générateur de PDF</title>
</descriptive>
<languages>
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>0.5.1</version>
<authors>
<author>
<name>Franck Allimant</name>
<company>CQFDev</company>
<email>thelia@cqfdev.fr</email>
<website>www.cqfdev.fr</website>
</author>
</authors>
<type>classic</type>
<thelia>2.3.4</thelia>
<stability>other</stability>
<mandatory>0</mandatory>
<hidden>0</hidden>
</module>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="pdf_generator.get_pdf" path="/getpdf/{template}/{outputFileName}">
<default key="_controller">PdfGenerator\Controller\GeneratorController::downloadPdf</default>
<requirement key="template">.*</requirement>
<requirement key="outputFileName">.*</requirement>
</route>
<route id="pdf_generator.view_pdf" path="/viewpdf/{template}/{outputFileName}">
<default key="_controller">PdfGenerator\Controller\GeneratorController::viewPdf</default>
<requirement key="template">.*</requirement>
<requirement key="outputFileName">.*</requirement>
</route>
</routes>

View File

@@ -0,0 +1,77 @@
<?php
/*************************************************************************************/
/* Copyright (c) Franck Allimant, CQFDev */
/* email : thelia@cqfdev.fr */
/* web : http://www.cqfdev.fr */
/* */
/* For the full copyright and license information, please view the LICENSE */
/* file that was distributed with this source code. */
/*************************************************************************************/
/**
* Created by Franck Allimant, CQFDev <franck@cqfdev.fr>
* Date: 24/01/2019 19:38
*/
namespace PdfGenerator\Controller;
use PdfGenerator\PdfGenerator;
use Thelia\Controller\Front\BaseFrontController;
use Thelia\Core\Event\PdfEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Exception\TheliaProcessException;
use Thelia\Log\Tlog;
class GeneratorController extends BaseFrontController
{
public function downloadPdf($template, $outputFileName)
{
return $this->renderPdfTemplate($template, $outputFileName, false);
}
public function viewPdf($template, $outputFileName)
{
return $this->renderPdfTemplate($template, $outputFileName, true);
}
/**
* @param $templateName
* @param $outputFileName
* @param $browser
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function renderPdfTemplate($templateName, $outputFileName, $browser)
{
$html = $this->renderRaw(
$templateName,
[],
$this->getTemplateHelper()->getActivePdfTemplate()
);
try {
$pdfEvent = new PdfEvent($html);
$this->dispatch(TheliaEvents::GENERATE_PDF, $pdfEvent);
if ($pdfEvent->hasPdf()) {
return $this->pdfResponse($pdfEvent->getPdf(), $outputFileName, 200, $browser);
}
} catch (\Exception $e) {
Tlog::getInstance()->error(
sprintf(
'error during generating PDF document %s.html with message "%s"',
$templateName,
$e->getMessage()
)
);
}
throw new TheliaProcessException(
$this->getTranslator()->trans(
"We're sorry, this PDF document %name is not available at the moment.",
[ '%name' => $outputFileName],
PdfGenerator::DOMAIN_NAME
)
);
}
}

View File

@@ -0,0 +1,5 @@
<?php
return array(
'We\'re sorry, this PDF document %name is not available at the moment.' => 'We\'re sorry, this PDF document %name is not available at the moment. ',
);

View File

@@ -0,0 +1,5 @@
<?php
return array(
'We\'re sorry, this PDF document %name is not available at the moment.' => 'Désoler, le PDF %name n\'est pas disponible pour le moment. ',
);

View File

@@ -0,0 +1,23 @@
<?php
/*************************************************************************************/
/* Copyright (c) Franck Allimant, CQFDev */
/* email : thelia@cqfdev.fr */
/* web : http://www.cqfdev.fr */
/* */
/* For the full copyright and license information, please view the LICENSE */
/* file that was distributed with this source code. */
/*************************************************************************************/
/**
* Created by Franck Allimant, CQFDev <franck@cqfdev.fr>
* Date: 24/01/2019 19:44
*/
namespace PdfGenerator;
use Thelia\Module\BaseModule;
class PdfGenerator extends BaseModule
{
/** @var string */
const DOMAIN_NAME = 'pdfgenerator';
}

View File

@@ -0,0 +1,78 @@
# PdfGenerator
## en_US
This modules allows to generate PDF files from a template who will be sought in
the current PDF template
## Uses
The URL to use to generate a PDF from a template is like :
https://yourshop.tld/getpdf/template_name_without_extension/output_file_name_without_extension
The URL to use to generate a PDF to visualise in the navigator is like :
https://yourshop.tld/viewpdf/template_name_without_extension/output_file_name_without_extension
For example, if you have in your PDF templates a file `category.html`, you are going to utilise:
https://yourshop.tld/viewpdf/category/category-list
## Installation
### Manually
* Copy the module into ```<thelia_root>/local/modules/``` directory and be sure that the name of the module is PdfGenerator.
* Activate it in your thelia administration panel
### Composer
Add it in your main thelia composer.json file
```
composer require cqfdev/pdf-generator-module:~0.5.1
```
## fr_Fr
Ce module permet de générer un PDF à parti d'un template qui sera cherché dans
le template PDF courant.
## Utilisation
L'URL à utiliser pour générer un PDF à télécharger est la suivante :
https://yourshop.tld/getpdf/template_name_without_extension/output_file_name_without_extension
L'URL à utiliser pour générer un PDF à visualiser dans le navigateur est la suivante :
https://yourshop.tld/viewpdf/template_name_without_extension/output_file_name_without_extension
Par exemple, si vous avez dans votre template pdf une fichier `category.html`, vous allez utiliser :
https://yourshop.tld/viewpdf/category/category-list
Vous obtinedrez un fichier category-list.pdf.
## Installation
### Manuellement
* Copier le module dans le dossier ```<thelia_root>/local/modules/``` et fait bien attention que le nom du module soit PdfGenerator.
* Activer le module dans votre espace d'administration
### Composer
Ajouter dans le fichier composer.json de thelia
```
composer require cqfdev/pdf-generator-module:~0.5.1
```

View File

@@ -0,0 +1,11 @@
{
"name": "cqfdev/pdf-generator-module",
"license": "LGPL-3.0-or-later",
"type": "thelia-module",
"require": {
"thelia/installer": "~1.1"
},
"extra": {
"installer-name": "PdfGenerator"
}
}