From 7a580c18ca3411bcad54cfb813d0ae70b76ba35a Mon Sep 17 00:00:00 2001 From: tgalopin Date: Mon, 26 May 2014 18:36:17 +0200 Subject: [PATCH 1/5] Update argentique module to limit images size (auto resize) --- .../Controller/AdminController.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Etu/Module/ArgentiqueBundle/Controller/AdminController.php b/src/Etu/Module/ArgentiqueBundle/Controller/AdminController.php index cad798a1e..1ac8c68f3 100644 --- a/src/Etu/Module/ArgentiqueBundle/Controller/AdminController.php +++ b/src/Etu/Module/ArgentiqueBundle/Controller/AdminController.php @@ -394,6 +394,9 @@ public function synchronizePhotoAction($photoId) // Flickr $flickr = $this->createFlickrAccess(); + // Imagine + $imagine = new \Imagine\Gd\Imagine(); + // Get database photo /** @var Photo $photo */ $photo = $em->getRepository('EtuModuleArgentiqueBundle:Photo')->find($photoId); @@ -409,7 +412,20 @@ public function synchronizePhotoAction($photoId) file_put_contents($uploadDir.'/'.$photo->getId().'_t.jpg', file_get_contents($sizes['sizes']['size'][2]['source'])); // Original - file_put_contents($uploadDir.'/'.$photo->getId().'_o.jpg', file_get_contents($sizes['sizes']['size'][9]['source'])); + $image = $imagine->open($sizes['sizes']['size'][9]['source']); + + $width = $image->getSize()->getWidth(); + $height = $image->getSize()->getHeight(); + + if ($width > $height) { + $box = new \Imagine\Image\Box(1500, 1500 * ($height / $width)); + } elseif ($width < $height) { + $box = new \Imagine\Image\Box(1500 * ($width / $height), 1500); + } else { + $box = new \Imagine\Image\Box(1500, 1500); + } + + $image->resize($box)->save($uploadDir.'/'.$photo->getId().'_o.jpg'); $photo->setFile($photo->getId().'_o.jpg'); $photo->setIcon($photo->getId().'_t.jpg'); From 118f0c0474488617e7a864bec22d1ab03625fa04 Mon Sep 17 00:00:00 2001 From: tgalopin Date: Mon, 26 May 2014 19:37:38 +0200 Subject: [PATCH 2/5] Update covoit --- app/AppKernel.php | 3 ++ composer.json | 3 +- .../Controller/PrivateController.php | 47 +++++++++++++++++++ .../Notification/Helper/CanceledHelper.php | 44 +++++++++++++++++ .../Resources/translations/messages.fr.yml | 4 +- .../Resources/views/Private/cancel.html.twig | 28 +++++++++++ .../Resources/views/Private/edit.html.twig | 4 ++ .../Resources/views/Private/index.html.twig | 43 ++++++++--------- .../Resources/views/Public/index.html.twig | 31 ++++++------ .../Resources/views/Public/search.html.twig | 34 +++++++------- web/css/bundles/covoit.less | 38 +++++++++------ 11 files changed, 206 insertions(+), 73 deletions(-) create mode 100644 src/Etu/Module/CovoitBundle/Notification/Helper/CanceledHelper.php create mode 100644 src/Etu/Module/CovoitBundle/Resources/views/Private/cancel.html.twig diff --git a/app/AppKernel.php b/app/AppKernel.php index 8691faa06..209464581 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -55,6 +55,9 @@ public function registerBundles() // BBCode new FM\BbcodeBundle\FMBbcodeBundle(), + // Date and times translations + new Sonata\IntlBundle\SonataIntlBundle(), + // API documentation new Nelmio\ApiDocBundle\NelmioApiDocBundle(), diff --git a/composer.json b/composer.json index fc14b914c..ca0f9765c 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,8 @@ "fzaninotto/faker": "~1.3", "nelmio/api-doc-bundle": "2.5.*", "dopiaza/dpzflickr": "1.2.*", - "jasig/phpcas": "dev-master" + "jasig/phpcas": "dev-master", + "sonata-project/intl-bundle": "2.2.*" }, "scripts": { "post-install-cmd": [ diff --git a/src/Etu/Module/CovoitBundle/Controller/PrivateController.php b/src/Etu/Module/CovoitBundle/Controller/PrivateController.php index 3a7fd70bb..698681e01 100644 --- a/src/Etu/Module/CovoitBundle/Controller/PrivateController.php +++ b/src/Etu/Module/CovoitBundle/Controller/PrivateController.php @@ -255,6 +255,53 @@ public function editMessageAction(Request $request, CovoitMessage $message) ]; } + /** + * @Route("/{id}/cancel/{confirm}", defaults={"confirm" = false}, name="covoiturage_my_cancel") + * @Template() + */ + public function cancelAction(Covoit $covoit, $confirm) + { + if (! $this->getUserLayer()->isUser()) { + return $this->createAccessDeniedResponse(); + } + + /** @var EntityManager $em */ + $em = $this->getDoctrine()->getManager(); + + if ($covoit->getAuthor()->getId() != $this->getUser()->getId()) { + throw new AccessDeniedHttpException(); + } + + if ($confirm) { + $em->remove($covoit); + $em->flush(); + + $notif = new Notification(); + + $notif + ->setModule($this->getCurrentBundle()->getIdentifier()) + ->setHelper('covoit_canceled') + ->setAuthorId($this->getUser()->getId()) + ->setEntityType('covoit') + ->setEntityId($covoit->getId()) + ->addEntity($covoit); + + $this->getNotificationsSender()->send($notif); + + // Flash message + $this->get('session')->getFlashBag()->set('message', array( + 'type' => 'success', + 'message' => 'covoit.messages.canceled' + )); + + return $this->redirect($this->generateUrl('covoiturage_my_index')); + } + + return [ + 'covoit' => $covoit, + ]; + } + /** * @Route("/{id}/subscribe", name="covoiturage_my_subscribe") */ diff --git a/src/Etu/Module/CovoitBundle/Notification/Helper/CanceledHelper.php b/src/Etu/Module/CovoitBundle/Notification/Helper/CanceledHelper.php new file mode 100644 index 000000000..3542358e2 --- /dev/null +++ b/src/Etu/Module/CovoitBundle/Notification/Helper/CanceledHelper.php @@ -0,0 +1,44 @@ +twig = $twig; + } + + /** + * @return string + */ + public function getName() + { + return 'covoit_canceled'; + } + + /** + * @param Notification $notification + * @return string + */ + public function render(Notification $notification) + { + return $this->twig->render('EtuModuleCovoitBundle:Notification:canceled.html.twig', array( + 'notif' => $notification + )); + } +} \ No newline at end of file diff --git a/src/Etu/Module/CovoitBundle/Resources/translations/messages.fr.yml b/src/Etu/Module/CovoitBundle/Resources/translations/messages.fr.yml index 5621f04bb..9acf5a80a 100644 --- a/src/Etu/Module/CovoitBundle/Resources/translations/messages.fr.yml +++ b/src/Etu/Module/CovoitBundle/Resources/translations/messages.fr.yml @@ -14,6 +14,7 @@ covoit: messages: created: Votre proposition a bien été créée edited: Votre covoiturage a bien été modifié + canceled: Votre covoiturage a bien été annulé message_sent: Votre message a bien été envoyé message_edited: Votre message a bien été modifié already_subscribed: Vous êtes déjà inscrit à ce covoiturage @@ -68,8 +69,6 @@ covoit: private_index: title: Mes covoiturages - from_to: De %startCity% à %endCity% - date: Le %date% à %hour% subscriptions_left: none_or_one: place
restante|some: places
restantes per_place: par place creator: Créateur @@ -121,6 +120,7 @@ covoit: private_edit: title: Modifier un covoiturage + delete: Annuler ce covoiturage submit: Modifier cancel: Annuler diff --git a/src/Etu/Module/CovoitBundle/Resources/views/Private/cancel.html.twig b/src/Etu/Module/CovoitBundle/Resources/views/Private/cancel.html.twig new file mode 100644 index 000000000..c970bf604 --- /dev/null +++ b/src/Etu/Module/CovoitBundle/Resources/views/Private/cancel.html.twig @@ -0,0 +1,28 @@ +{% extends '::page-2cols.html.twig' %} + +{% block title %}{{ 'covoit.private_edit.title'|trans }}{% endblock %} + +{% block titleIcon %} + {{ 'base.logo.alt'|trans }} +{% endblock %} + +{% block content %} + {% include 'EtuModuleCovoitBundle::menu.html.twig' with {'active': 'none'} %} + +
+

+ Voulez-vous vraiment annuler le covoiturage + {{ covoit.startCity.name }} {{ covoit.endCity.name }} + du {{ covoit.ate|format_date }} ? +

+ +

+ + Oui, le supprimer + + + Non, annuler + +

+
+{% endblock %} diff --git a/src/Etu/Module/CovoitBundle/Resources/views/Private/edit.html.twig b/src/Etu/Module/CovoitBundle/Resources/views/Private/edit.html.twig index 34dd2411b..4fd025e03 100644 --- a/src/Etu/Module/CovoitBundle/Resources/views/Private/edit.html.twig +++ b/src/Etu/Module/CovoitBundle/Resources/views/Private/edit.html.twig @@ -11,6 +11,10 @@
+ + {{ 'covoit.alerts.edit.delete'|trans }} + +

{{ 'covoit.proposal.titles.details'|trans }}

diff --git a/src/Etu/Module/CovoitBundle/Resources/views/Private/index.html.twig b/src/Etu/Module/CovoitBundle/Resources/views/Private/index.html.twig index 9ac92cc87..d97fa07d1 100644 --- a/src/Etu/Module/CovoitBundle/Resources/views/Private/index.html.twig +++ b/src/Etu/Module/CovoitBundle/Resources/views/Private/index.html.twig @@ -67,48 +67,43 @@ class="covoit-list-item{% if today > covoit.date %} covoit-list-item-done{% endif %}">
-
- {{ covoit.capacity - (covoit.subscriptions|length) }} +
+ {{ covoit.capacity - (covoit.subscriptions|length) }}
{{ 'covoit.private_index.subscriptions_left'|transchoice(covoit.capacity - (covoit.subscriptions|length))|raw }}
-
- {{ covoit.price }} € +
+ + {{ covoit.price }} € +
{{ 'covoit.private_index.per_place'|trans }}
-
- {% if covoit.author.id == app.user.id %} - {{ 'covoit.private_index.creator'|trans }} - {% else %} - {{ 'covoit.private_index.subscribed'|trans }} - {% endif %} +
+ + {{ covoit.date|format_date }} + +
+ {{ covoit.startHour|format_time(null, null, null, constant('IntlDateFormatter::SHORT')) }}
- {{ 'covoit.private_index.from_to'|trans({ - '%startCity%': covoit.startCity.name, - '%endCity%': covoit.endCity.name - }) }} + {{ covoit.startCity.name }} + {{ covoit.endCity.name }}
- - {{ 'covoit.private_index.date'|trans({ - '%date%': covoit.date|date('d/m/Y'), - '%hour%': covoit.startHour|date('H:i') - }) }} - + {{ covoit.author.fullName }}
{% else %}

{{ 'covoit.private_index.no_covoit.text'|trans }} - - {{ 'covoit.private_index.no_covoit.link'|trans }} - -

+ + {{ 'covoit.private_index.no_covoit.link'|trans }} + +

{% endfor %}