Loading Dockerfile +2 −1 Changes for Dockerfile: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -14,7 +14,8 @@ LABEL maintainer="Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>" RUN apt-get update -qq && \ apt-get install -y \ ghostscript-x \ php${PHP_VERSION}-imagick php${PHP_VERSION}-imagick \ imagemagick # Nettoyage RUN apt-get autoremove -y && apt-get clean && rm -rf /tmp/* /var/tmp/* Loading module/Application/src/Application/Command/ConvertCommand.php 0 → 100644 +42 −0 Changes for module/Application/src/Application/Command/ConvertCommand.php: 42 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Application\Command; use Assert\Assertion; use Assert\AssertionFailedException; use UnicaenApp\Exception\LogicException; class ConvertCommand extends AbstractCommand { protected $executable = 'convert'; /** * @return string */ public function getName() { return 'convert'; } /** * @param string $outputFilePath * @param array $inputFilePath * @param string $errorFilePath * @return string */ public function generate($outputFilePath, $inputFilePath, &$errorFilePath = null) { try { Assertion::keyIsset($inputFilePath, 'logo'); } catch (AssertionFailedException $e) { throw new LogicException("Argument invalide"); } $logo = $inputFilePath['logo']; $command = $this->executable . ' \'' . $logo . '\' \''. $outputFilePath . '\''; $this->commandLine = $command; return $this->commandLine; } } No newline at end of file module/Application/src/Application/Form/EcoleDoctoraleForm.php +14 −0 Changes for module/Application/src/Application/Form/EcoleDoctoraleForm.php: 14 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ use Zend\Form\Element\Submit; use Zend\Form\Element\Text; use Zend\Form\Form; use Zend\InputFilter\Factory; use Zend\Validator\File\Extension; class EcoleDoctoraleForm extends Form { Loading Loading @@ -71,6 +72,19 @@ class EcoleDoctoraleForm extends Form 'name' => 'code', 'required' => true, ], 'cheminLogo' => [ 'required' => false, // 'validators' => [ // [ // 'name' => Extension::class, // 'options' => [ // 'extension' => ['bmp', 'png', 'jpg', 'jpeg'], // 'case' => false, // ], // 'break_chain_on_failure' => true, // ], // ], ], ])); } } No newline at end of file module/Application/src/Application/Service/Structure/StructureService.php +35 −4 Changes for module/Application/src/Application/Service/Structure/StructureService.php: 35 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Application\Service\Structure; use Application\Command\ConvertCommand; use Application\Entity\Db\EcoleDoctorale; use Application\Entity\Db\Etablissement; use Application\Entity\Db\Source; Loading @@ -24,6 +25,7 @@ use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\OptimisticLockException; use DoctrineModule\Stdlib\Hydrator\DoctrineObject; use Import\Service\Traits\SynchroServiceAwareTrait; use Retraitement\Exception\TimedOutCommandException; use UnicaenApp\Exception\RuntimeException; use UnicaenApp\Util; use Webmozart\Assert\Assert; Loading Loading @@ -861,13 +863,42 @@ class StructureService extends BaseService } // création du fichier logo sur le disque. $logoFilepath = $this->fileService->computeLogoFilePathForStructure($structure); $logoDir = $this->fileService->computeLogoDirectoryPathForStructure($structure); $this->fileService->createWritableDirectory($logoDir); $ok = rename($uploadedFilePath, $logoFilepath); if (! $ok) { throw new RuntimeException("Impossible de renommer le fichier logo sur le disque."); $logoFilepath = $this->fileService->computeLogoFilePathForStructure($structure); /** ANCIENNE METHODE */ // $ok = rename($uploadedFilePath, $logoFilepath); // if (! $ok) { // throw new RuntimeException("Impossible de renommer le fichier logo sur le disque."); // } $command = new ConvertCommand(); $errorFilePath = null; $command->generate($logoFilepath, ['logo' => $uploadedFilePath], $errorFilePath); try { $command->checkResources(); $command->execute(); $success = ($command->getReturnCode() === 0); if (!$success) { throw new RuntimeException(sprintf( "La commande %s a échoué (code retour = %s), voici le résultat d'exécution : %s", $command->getName(), $command->getReturnCode(), implode(PHP_EOL, $command->getResult()) )); } } catch (TimedOutCommandException $toce) { throw $toce; } catch (RuntimeException $rte) { throw new RuntimeException( "Une erreur est survenue lors de l'exécution de la commande " . $command->getName(), 0, $rte); } //!todo remplacer par 'convert $uploadedFilePath $logoFilepath' } /** Loading module/Application/view/application/ecole-doctorale/modifier.phtml +15 −0 Changes for module/Application/view/application/ecole-doctorale/modifier.phtml: 15 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ $form->get('code')->setAttribute('readonly', !$editable); </div> <div id="logo-div" class="col-md-6"> <?php /** @var \Zend\Form\Element\File $logoFile */ $logoFile = $form->get('cheminLogo'); Loading @@ -60,6 +61,8 @@ $form->get('code')->setAttribute('readonly', !$editable); $ecole->setCheminLogo(null); } ?> <table> <tr> <td> Loading @@ -84,6 +87,18 @@ $form->get('code')->setAttribute('readonly', !$editable); </td> </tr> </table> <div class="alert alert-warning"> <small> <span class="glyphicon glyphicon-exclamation-sign"></span> Le logo de la structure doit être donné dans un des formats suivant : <ul> <li>.bmp</li> <li>.jpg, .jpeg</li> <li>.png</li> </ul> </small> </div> </div> </div> Loading Loading
Dockerfile +2 −1 Changes for Dockerfile: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -14,7 +14,8 @@ LABEL maintainer="Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>" RUN apt-get update -qq && \ apt-get install -y \ ghostscript-x \ php${PHP_VERSION}-imagick php${PHP_VERSION}-imagick \ imagemagick # Nettoyage RUN apt-get autoremove -y && apt-get clean && rm -rf /tmp/* /var/tmp/* Loading
module/Application/src/Application/Command/ConvertCommand.php 0 → 100644 +42 −0 Changes for module/Application/src/Application/Command/ConvertCommand.php: 42 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Application\Command; use Assert\Assertion; use Assert\AssertionFailedException; use UnicaenApp\Exception\LogicException; class ConvertCommand extends AbstractCommand { protected $executable = 'convert'; /** * @return string */ public function getName() { return 'convert'; } /** * @param string $outputFilePath * @param array $inputFilePath * @param string $errorFilePath * @return string */ public function generate($outputFilePath, $inputFilePath, &$errorFilePath = null) { try { Assertion::keyIsset($inputFilePath, 'logo'); } catch (AssertionFailedException $e) { throw new LogicException("Argument invalide"); } $logo = $inputFilePath['logo']; $command = $this->executable . ' \'' . $logo . '\' \''. $outputFilePath . '\''; $this->commandLine = $command; return $this->commandLine; } } No newline at end of file
module/Application/src/Application/Form/EcoleDoctoraleForm.php +14 −0 Changes for module/Application/src/Application/Form/EcoleDoctoraleForm.php: 14 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ use Zend\Form\Element\Submit; use Zend\Form\Element\Text; use Zend\Form\Form; use Zend\InputFilter\Factory; use Zend\Validator\File\Extension; class EcoleDoctoraleForm extends Form { Loading Loading @@ -71,6 +72,19 @@ class EcoleDoctoraleForm extends Form 'name' => 'code', 'required' => true, ], 'cheminLogo' => [ 'required' => false, // 'validators' => [ // [ // 'name' => Extension::class, // 'options' => [ // 'extension' => ['bmp', 'png', 'jpg', 'jpeg'], // 'case' => false, // ], // 'break_chain_on_failure' => true, // ], // ], ], ])); } } No newline at end of file
module/Application/src/Application/Service/Structure/StructureService.php +35 −4 Changes for module/Application/src/Application/Service/Structure/StructureService.php: 35 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Application\Service\Structure; use Application\Command\ConvertCommand; use Application\Entity\Db\EcoleDoctorale; use Application\Entity\Db\Etablissement; use Application\Entity\Db\Source; Loading @@ -24,6 +25,7 @@ use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\OptimisticLockException; use DoctrineModule\Stdlib\Hydrator\DoctrineObject; use Import\Service\Traits\SynchroServiceAwareTrait; use Retraitement\Exception\TimedOutCommandException; use UnicaenApp\Exception\RuntimeException; use UnicaenApp\Util; use Webmozart\Assert\Assert; Loading Loading @@ -861,13 +863,42 @@ class StructureService extends BaseService } // création du fichier logo sur le disque. $logoFilepath = $this->fileService->computeLogoFilePathForStructure($structure); $logoDir = $this->fileService->computeLogoDirectoryPathForStructure($structure); $this->fileService->createWritableDirectory($logoDir); $ok = rename($uploadedFilePath, $logoFilepath); if (! $ok) { throw new RuntimeException("Impossible de renommer le fichier logo sur le disque."); $logoFilepath = $this->fileService->computeLogoFilePathForStructure($structure); /** ANCIENNE METHODE */ // $ok = rename($uploadedFilePath, $logoFilepath); // if (! $ok) { // throw new RuntimeException("Impossible de renommer le fichier logo sur le disque."); // } $command = new ConvertCommand(); $errorFilePath = null; $command->generate($logoFilepath, ['logo' => $uploadedFilePath], $errorFilePath); try { $command->checkResources(); $command->execute(); $success = ($command->getReturnCode() === 0); if (!$success) { throw new RuntimeException(sprintf( "La commande %s a échoué (code retour = %s), voici le résultat d'exécution : %s", $command->getName(), $command->getReturnCode(), implode(PHP_EOL, $command->getResult()) )); } } catch (TimedOutCommandException $toce) { throw $toce; } catch (RuntimeException $rte) { throw new RuntimeException( "Une erreur est survenue lors de l'exécution de la commande " . $command->getName(), 0, $rte); } //!todo remplacer par 'convert $uploadedFilePath $logoFilepath' } /** Loading
module/Application/view/application/ecole-doctorale/modifier.phtml +15 −0 Changes for module/Application/view/application/ecole-doctorale/modifier.phtml: 15 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ $form->get('code')->setAttribute('readonly', !$editable); </div> <div id="logo-div" class="col-md-6"> <?php /** @var \Zend\Form\Element\File $logoFile */ $logoFile = $form->get('cheminLogo'); Loading @@ -60,6 +61,8 @@ $form->get('code')->setAttribute('readonly', !$editable); $ecole->setCheminLogo(null); } ?> <table> <tr> <td> Loading @@ -84,6 +87,18 @@ $form->get('code')->setAttribute('readonly', !$editable); </td> </tr> </table> <div class="alert alert-warning"> <small> <span class="glyphicon glyphicon-exclamation-sign"></span> Le logo de la structure doit être donné dans un des formats suivant : <ul> <li>.bmp</li> <li>.jpg, .jpeg</li> <li>.png</li> </ul> </small> </div> </div> </div> Loading