diff --git a/app/AppKernel.php b/app/AppKernel.php index ca2290b..5763f88 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -22,6 +22,7 @@ public function registerBundles() new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(), new JMS\DiExtraBundle\JMSDiExtraBundle($this), new Vich\UploaderBundle\VichUploaderBundle(), + new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(), new AppBundle\AppBundle(), ); diff --git a/app/Resources/FOSUserBundle/views/layout.html.twig b/app/Resources/FOSUserBundle/views/layout.html.twig index 6ce65f7..03b79d1 100644 --- a/app/Resources/FOSUserBundle/views/layout.html.twig +++ b/app/Resources/FOSUserBundle/views/layout.html.twig @@ -25,8 +25,8 @@ -
- Responsive image +
+ Vintage Logo Responsive image
{% for type, messages in app.session.flashBag.all %} diff --git a/app/Resources/views/base.html.twig b/app/Resources/views/base.html.twig index 8167eed..d28bec0 100644 --- a/app/Resources/views/base.html.twig +++ b/app/Resources/views/base.html.twig @@ -45,9 +45,8 @@ {% if is_granted('ROLE_ADMIN') %}
  • Locations
  • {% endif %} -
  • Points
  • -
  • My Points
  • -
  • Upload
  • +
  • Points
  • +
  • My Points
  • {{ 'layout.logout'|trans({}, 'FOSUserBundle') }} diff --git a/app/config/config.yml b/app/config/config.yml index 4be25c9..d1e39c9 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -92,6 +92,14 @@ doctrine: auto_generate_proxy_classes: "%kernel.debug%" auto_mapping: true +# Doctrine extensions +stof_doctrine_extensions: + default_locale: en_US + orm: + default: + timestampable: true + + # Swiftmailer Configuration swiftmailer: transport: "%mailer_transport%" diff --git a/app/config/config_dev.yml b/app/config/config_dev.yml index efaf396..86447c2 100644 --- a/app/config/config_dev.yml +++ b/app/config/config_dev.yml @@ -44,5 +44,7 @@ monolog: assetic: use_controller: true -#swiftmailer: -# delivery_address: me@example.com +swiftmailer: + transport: "%mailer_transport%" + username: "%mailer_user%" + password: "%mailer_password%" diff --git a/composer.json b/composer.json index 5d2a808..ecb3b1e 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "sensio/distribution-bundle": "~3.0,>=3.0.12", "sensio/framework-extra-bundle": "~3.0,>=3.0.2", "incenteev/composer-parameter-handler": "~2.0", - "stof/doctrine-extensions-bundle": "dev-master", + "stof/doctrine-extensions-bundle": "~1.1@dev", "friendsofsymfony/user-bundle": "~2.0@dev", "jms/serializer-bundle": "0.13.*@dev", "jms/security-extra-bundle": "dev-master", diff --git a/composer.lock b/composer.lock index eb61e6e..0ddbe06 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "da2c7bc3dc7ecc94c411df350687d26b", + "hash": "bd16d23a8dc9c8dbc2ccff1bd28e3db1", "packages": [ { "name": "behat/transliterator", @@ -175,16 +175,16 @@ }, { "name": "doctrine/annotations", - "version": "v1.2.3", + "version": "v1.2.4", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "eeda578cbe24a170331a1cfdf78be723412df7a4" + "reference": "b5202eb9e83f8db52e0e58867e0a46e63be8332e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/eeda578cbe24a170331a1cfdf78be723412df7a4", - "reference": "eeda578cbe24a170331a1cfdf78be723412df7a4", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/b5202eb9e83f8db52e0e58867e0a46e63be8332e", + "reference": "b5202eb9e83f8db52e0e58867e0a46e63be8332e", "shasum": "" }, "require": { @@ -239,20 +239,20 @@ "docblock", "parser" ], - "time": "2014-12-20 20:49:38" + "time": "2014-12-23 22:40:37" }, { "name": "doctrine/cache", - "version": "v1.4.0", + "version": "v1.4.1", "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "2346085d2b027b233ae1d5de59b07440b9f288c8" + "reference": "c9eadeb743ac6199f7eec423cb9426bc518b7b03" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/2346085d2b027b233ae1d5de59b07440b9f288c8", - "reference": "2346085d2b027b233ae1d5de59b07440b9f288c8", + "url": "https://api.github.com/repos/doctrine/cache/zipball/c9eadeb743ac6199f7eec423cb9426bc518b7b03", + "reference": "c9eadeb743ac6199f7eec423cb9426bc518b7b03", "shasum": "" }, "require": { @@ -263,13 +263,13 @@ }, "require-dev": { "phpunit/phpunit": ">=3.7", - "predis/predis": "~0.8", + "predis/predis": "~1.0", "satooshi/php-coveralls": "~0.6" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4.x-dev" + "dev-master": "1.5.x-dev" } }, "autoload": { @@ -309,25 +309,28 @@ "cache", "caching" ], - "time": "2015-01-15 20:38:55" + "time": "2015-04-15 00:11:59" }, { "name": "doctrine/collections", - "version": "v1.2", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/doctrine/collections.git", - "reference": "b99c5c46c87126201899afe88ec490a25eedd6a2" + "reference": "6c1e4eef75f310ea1b3e30945e9f06e652128b8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/collections/zipball/b99c5c46c87126201899afe88ec490a25eedd6a2", - "reference": "b99c5c46c87126201899afe88ec490a25eedd6a2", + "url": "https://api.github.com/repos/doctrine/collections/zipball/6c1e4eef75f310ea1b3e30945e9f06e652128b8a", + "reference": "6c1e4eef75f310ea1b3e30945e9f06e652128b8a", "shasum": "" }, "require": { "php": ">=5.3.2" }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, "type": "library", "extra": { "branch-alias": { @@ -344,17 +347,6 @@ "MIT" ], "authors": [ - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com", - "homepage": "http://www.jwage.com/", - "role": "Creator" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com", - "homepage": "http://www.instaclick.com" - }, { "name": "Roman Borschel", "email": "roman@code-factory.org" @@ -363,11 +355,17 @@ "name": "Benjamin Eberlei", "email": "kontakt@beberlei.de" }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, { "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh", - "role": "Developer of wrapped JMSSerializerBundle" + "email": "schmittjoh@gmail.com" } ], "description": "Collections Abstraction library", @@ -377,7 +375,7 @@ "collections", "iterator" ], - "time": "2014-02-03 23:07:43" + "time": "2015-04-14 22:21:58" }, { "name": "doctrine/common", @@ -983,12 +981,12 @@ "source": { "type": "git", "url": "https://github.com/FriendsOfSymfony/FOSUserBundle.git", - "reference": "808672b01f6aa6777417551c72a0be2c3545eafe" + "reference": "192c53916942847aee687722af54f431aead0b70" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/zipball/808672b01f6aa6777417551c72a0be2c3545eafe", - "reference": "808672b01f6aa6777417551c72a0be2c3545eafe", + "url": "https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/zipball/192c53916942847aee687722af54f431aead0b70", + "reference": "192c53916942847aee687722af54f431aead0b70", "shasum": "" }, "require": { @@ -1042,7 +1040,7 @@ "keywords": [ "User management" ], - "time": "2015-03-12 11:42:34" + "time": "2015-04-16 23:14:14" }, { "name": "gedmo/doctrine-extensions", diff --git a/src/AppBundle/Controller/FileController.php b/src/AppBundle/Controller/FileController.php index 65d7c1f..727d691 100644 --- a/src/AppBundle/Controller/FileController.php +++ b/src/AppBundle/Controller/FileController.php @@ -7,6 +7,8 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; +use Symfony\Component\HttpFoundation\Response; +use JMS\SecurityExtraBundle\Annotation\Secure; use AppBundle\Entity\File; use AppBundle\Form\FileType; @@ -29,10 +31,12 @@ public function indexAction() { $em = $this->getDoctrine()->getManager(); - $entities = $em->getRepository('AppBundle:File')->findAll(); + $entities = $em->getRepository('AppBundle:File')->findReleased(); + $maps = $em->getRepository('AppBundle:Map')->findAll(); return array( 'entities' => $entities, + 'maps' => $maps, ); } /** @@ -45,6 +49,8 @@ public function indexAction() public function createAction(Request $request) { $entity = new File(); + $user = $this->getUser(); + $entity->setUser($user); $form = $this->createCreateForm($entity); $form->handleRequest($request); @@ -53,7 +59,7 @@ public function createAction(Request $request) $em->persist($entity); $em->flush(); - return $this->redirect($this->generateUrl('file_show', array('id' => $entity->getId()))); + return $this->redirect($this->generateUrl('myuploads')); } return array( @@ -69,9 +75,10 @@ public function createAction(Request $request) * * @return \Symfony\Component\Form\Form The form */ - private function createCreateForm(File $entity) + private function createCreateForm(File $entity, $map) { - $form = $this->createForm(new FileType(), $entity, array( + $options = array('mapid' => $map); + $form = $this->createForm(new FileType($options), $entity, array( 'action' => $this->generateUrl('file_create'), 'method' => 'POST', )); @@ -84,14 +91,14 @@ private function createCreateForm(File $entity) /** * Displays a form to create a new File entity. * - * @Route("/new", name="file_new") + * @Route("/{map}/new", name="file_new") * @Method("GET") * @Template() */ - public function newAction() + public function newAction($map) { $entity = new File(); - $form = $this->createCreateForm($entity); + $form = $this->createCreateForm($entity, $map); return array( 'entity' => $entity, @@ -102,7 +109,7 @@ public function newAction() /** * Finds and displays a File entity. * - * @Route("/{id}", name="file_show") + * @Route("/{id}/show", name="file_show") * @Method("GET") * @Template() */ @@ -128,7 +135,7 @@ public function showAction($id) /** * Finds and displays a File. * - * @Route("/{id}/get/{filename}", name="file_get", defaults={"filename" = "name.ext"}) + * @Route("/{id}/get", name="file_get") * */ public function getAction($id) @@ -137,13 +144,9 @@ public function getAction($id) $em = $this->getDoctrine()->getManager(); $file = $em->getRepository('AppBundle:File')->find($id); - $name = $file->getName(); - $helper = $this->container->get('vich_uploader.templating.helper.uploader_helper'); $path = $helper->asset($file, 'file'); $ext = strtolower($file->getExt()); - $filename = $name . '.' . $ext; - $response = new Response(); @@ -151,67 +154,15 @@ public function getAction($id) switch ($ext) { case "png": $response->headers->set('Content-Type', 'image/png'); - $response->headers->set('Content-Disposition', 'filename="' . $filename . '"'); break; case "gif": $response->headers->set('Content-Type', 'image/gif'); - $response->headers->set('Content-Disposition', 'filename="' . $filename . '"'); break; case "jpeg": $response->headers->set('Content-Type', 'image/jpeg'); - $response->headers->set('Content-Disposition', 'filename="' . $filename . '"'); break; case "jpg": $response->headers->set('Content-Type', 'image/jpeg'); - $response->headers->set('Content-Disposition', 'filename="' . $filename . '"'); - break; - case "mpeg": - $response->headers->set('Content-Type', 'audio/mpeg'); - $response->headers->set('Content-Disposition', 'filename="' . $filename . '"'); - break; - case "mp3": - $response->headers->set('Content-Type', 'audio/mp3'); - $response->headers->set('Content-Disposition', 'filename="' . $filename . '"'); - break; - case "odt": - $response->headers->set('Content-Type', 'application/vnd.oasis.opendocument.text'); - $response->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"'); - break; - case "ods": - $response->headers->set('Content-Type', 'application/vnd.oasis.opendocument.spreadsheet'); - $response->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"'); - break; - case "odp": - $response->headers->set('Content-Type', 'application/vnd.oasis.opendocument.presentation'); - $response->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"'); - break; - case "doc": - $response->headers->set('Content-Type', 'application/vnd.msword'); - $response->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"'); - break; - case "docx": - $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'); - $response->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"'); - break; - case "ppt": - $response->headers->set('Content-Type', 'application/vnd.mspowerpoint'); - $response->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"'); - break; - case "pptx": - $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'); - $response->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"'); - break; - case "xls": - $response->headers->set('Content-Type', 'application/vnd.ms-excel'); - $response->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"'); - break; - case "xlsx": - $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); - $response->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"'); - break; - case "pdf": - $response->headers->set('Content-Type', 'application/pdf'); - $response->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"'); break; default: $response->headers->set('Content-Type', 'application/octet-stream'); @@ -292,7 +243,7 @@ public function updateAction(Request $request, $id) if ($editForm->isValid()) { $em->flush(); - return $this->redirect($this->generateUrl('file_edit', array('id' => $id))); + return $this->redirect($this->generateUrl('file')); } return array( @@ -343,4 +294,72 @@ private function createDeleteForm($id) ->getForm() ; } + + /** + * Lists all Point entities. + * + * @Route("/myuploads", name="myuploads") + * @Method("GET") + * @Template("AppBundle:File:index.html.twig") + */ + public function myFilesAction() + { + $em = $this->getDoctrine()->getManager(); + $user = $this->getUser(); + + $entities = $em->getRepository('AppBundle:File')->findMine($user); + $maps = $em->getRepository('AppBundle:Map')->findAll(); + + return array( + 'entities' => $entities, + 'maps' => $maps, + ); + } + + /** + * Lists all unreleased Point entities. + * + * @Secure(roles="ROLE_ADMIN") + * @Route("/upload_pending", name="upload_pending") + * @Method("GET") + * @Template("AppBundle:File:index.html.twig") + */ + public function pendingAction() + { + $em = $this->getDoctrine()->getManager(); + + $entities = $em->getRepository('AppBundle:File')->findPending(); + $maps = $em->getRepository('AppBundle:Map')->findAll(); + + return array( + 'entities' => $entities, + 'maps' => $maps, + ); + } + + /** + * Releases an existing Point entity. + * + * @Secure(roles="ROLE_ADMIN") + * @Route("/{id}/release", name="file_release") + * @Method("GET") + * @Template("AppBundle:File:index.html.twig") + */ + public function releaseAction($id) + { + $em = $this->getDoctrine()->getManager(); + + $entity = $em->getRepository('AppBundle:File')->find($id); + $entity->setStatus(1); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find File entity.'); + } + + $em->flush(); + + return $this->redirect($this->generateUrl('file')); + } + + } diff --git a/src/AppBundle/Entity/File.php b/src/AppBundle/Entity/File.php index 228dc7c..448825f 100644 --- a/src/AppBundle/Entity/File.php +++ b/src/AppBundle/Entity/File.php @@ -12,6 +12,7 @@ * * @ORM\Table() * @ORM\Entity(repositoryClass="AppBundle\Entity\FileRepository") + * @Vich\Uploadable */ class File { @@ -28,12 +29,7 @@ class File /** * @Assert\File( * maxSize="10M", - * mimeTypes={"audio/mpeg", "application/vnd.ms-office", "image/gif", "image/png", "image/jpeg", "image/pjpeg", "application/pdf", - * "application/vnd.oasis.opendocument.text", "application/vnd.oasis.opendocument.presentation", - * "application/vnd.oasis.opendocument.spreadsheet", "application/msword", "application/mspowerpoint", - * "application/excel", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", - * "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", - * "application/zip"} + * mimeTypes={"image/gif", "image/png", "image/jpeg", "image/pjpeg"} * ) * @Vich\UploadableField(mapping="property_file", fileNameProperty="path") * @@ -41,27 +37,48 @@ class File */ protected $file; + /** + * @var string + * + * @ORM\Column(name="path", type="string", length=255, nullable=true) + */ + private $path; + + /** + * @var integer + * + * @ORM\Column(name="access", type="integer") + */ + private $access = 0 ; + /** * @var string * - * @ORM\Column(name="name", type="string", length=255) + * @ORM\Column(name="title", type="string", length=255) */ - private $name; + private $title; /** * @var string * - * @ORM\Column(name="path", type="string", length=255, nullable=true) + * @ORM\Column(name="body", type="text", nullable=true) */ - private $path; + private $body; /** * @var integer * - * @ORM\Column(name="access", type="integer") + * @ORM\Column(name="status", type="integer") */ - private $access = 0 ; + private $status = 0 ; + + + /** + * @ORM\ManyToOne(targetEntity="Location", inversedBy="files") + */ + protected $location; + /** * @ORM\Column(type="datetime") @@ -260,4 +277,96 @@ public function getFile() { return $this->file; } + + /** + * Set title + * + * @param string $title + * @return File + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Get title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Set body + * + * @param string $body + * @return File + */ + public function setBody($body) + { + $this->body = $body; + + return $this; + } + + /** + * Get body + * + * @return string + */ + public function getBody() + { + return $this->body; + } + + /** + * Set status + * + * @param integer $status + * @return File + */ + public function setStatus($status) + { + $this->status = $status; + + return $this; + } + + /** + * Get status + * + * @return integer + */ + public function getStatus() + { + return $this->status; + } + + /** + * Set location + * + * @param \AppBundle\Entity\Location $location + * @return File + */ + public function setLocation(\AppBundle\Entity\Location $location = null) + { + $this->location = $location; + + return $this; + } + + /** + * Get location + * + * @return \AppBundle\Entity\Location + */ + public function getLocation() + { + return $this->location; + } } diff --git a/src/AppBundle/Entity/FileRepository.php b/src/AppBundle/Entity/FileRepository.php index 25982ee..2da4443 100644 --- a/src/AppBundle/Entity/FileRepository.php +++ b/src/AppBundle/Entity/FileRepository.php @@ -12,4 +12,23 @@ */ class FileRepository extends EntityRepository { + public function findMine($user) + { + return $this->getEntityManager() + ->createQuery('SELECT f from AppBundle:File f WHERE f.user = ?1 ORDER BY f.created DESC')->setParameter('1',$user)->getResult(); + } + + public function findReleased() + { + $pending = 1; + return $this->getEntityManager() + ->createQuery('SELECT f from AppBundle:File f WHERE f.status = ?1 ORDER BY f.created DESC')->setParameter('1',$pending)->getResult(); + } + + public function findPending() + { + $pending = 1; + return $this->getEntityManager() + ->createQuery('SELECT f from AppBundle:File f WHERE f.status != ?1 ORDER BY f.created DESC')->setParameter('1',$pending)->getResult(); + } } diff --git a/src/AppBundle/Entity/Location.php b/src/AppBundle/Entity/Location.php index dabb5ad..30c1068 100644 --- a/src/AppBundle/Entity/Location.php +++ b/src/AppBundle/Entity/Location.php @@ -49,12 +49,24 @@ class Location */ private $description; + + /** + * @ORM\ManyToOne(targetEntity="Map", inversedBy="locations") + */ + protected $map; + /** * @ORM\OneToMany(targetEntity="Point", mappedBy="location") */ protected $points; + /** + * @ORM\OneToMany(targetEntity="File", mappedBy="location") + */ + protected $files; + + /** * Get id * @@ -196,4 +208,62 @@ public function getPoints() { return $this->points; } + + + + /** + * Add files + * + * @param \AppBundle\Entity\File $files + * @return Location + */ + public function addFile(\AppBundle\Entity\File $files) + { + $this->files[] = $files; + + return $this; + } + + /** + * Remove files + * + * @param \AppBundle\Entity\File $files + */ + public function removeFile(\AppBundle\Entity\File $files) + { + $this->files->removeElement($files); + } + + /** + * Get files + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getFiles() + { + return $this->files; + } + + /** + * Set map + * + * @param \AppBundle\Entity\Map $map + * @return Location + */ + public function setMap(\AppBundle\Entity\Map $map = null) + { + $this->map = $map; + + return $this; + } + + /** + * Get map + * + * @return \AppBundle\Entity\Map + */ + public function getMap() + { + return $this->map; + } } diff --git a/src/AppBundle/Entity/Map.php b/src/AppBundle/Entity/Map.php index 1305084..7aa9c6d 100644 --- a/src/AppBundle/Entity/Map.php +++ b/src/AppBundle/Entity/Map.php @@ -43,9 +43,9 @@ class Map private $background; /** - * @ORM\OneToMany(targetEntity="Point", mappedBy="map") + * @ORM\OneToMany(targetEntity="Location", mappedBy="map") */ - protected $points; + protected $locations; /** @@ -166,4 +166,37 @@ public function getPoints() { return $this->points; } + + /** + * Add locations + * + * @param \AppBundle\Entity\Location $locations + * @return Map + */ + public function addLocation(\AppBundle\Entity\Location $locations) + { + $this->locations[] = $locations; + + return $this; + } + + /** + * Remove locations + * + * @param \AppBundle\Entity\Location $locations + */ + public function removeLocation(\AppBundle\Entity\Location $locations) + { + $this->locations->removeElement($locations); + } + + /** + * Get locations + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getLocations() + { + return $this->locations; + } } diff --git a/src/AppBundle/Entity/MapRepository.php b/src/AppBundle/Entity/MapRepository.php index 944165e..a5118c6 100644 --- a/src/AppBundle/Entity/MapRepository.php +++ b/src/AppBundle/Entity/MapRepository.php @@ -15,6 +15,6 @@ class MapRepository extends EntityRepository public function map_json($map) { return $this->getEntityManager() - ->createQuery('SELECT l.lat as latitude, l.lng as longitude, p.title, p.body as content FROM AppBundle:Point p JOIN p.location l WHERE p.map = ?1 ')->setParameter('1', $map)->getResult(); + ->createQuery('SELECT l.lat as latitude, l.lng as longitude, f.title, f.id, f.body as content FROM AppBundle:File f JOIN f.location l WHERE l.map = ?1 and f.status = 1')->setParameter('1', $map)->getResult(); } } diff --git a/src/AppBundle/Entity/Point.php b/src/AppBundle/Entity/Point.php index a10208b..fc19314 100644 --- a/src/AppBundle/Entity/Point.php +++ b/src/AppBundle/Entity/Point.php @@ -44,12 +44,6 @@ class Point private $status = 0 ; - /** - * @ORM\ManyToOne(targetEntity="Map", inversedBy="points") - */ - protected $map; - - /** * @ORM\ManyToOne(targetEntity="Location", inversedBy="points") */ diff --git a/src/AppBundle/Form/FileType.php b/src/AppBundle/Form/FileType.php index f09aaa7..edae1c9 100644 --- a/src/AppBundle/Form/FileType.php +++ b/src/AppBundle/Form/FileType.php @@ -8,15 +8,33 @@ class FileType extends AbstractType { + protected $options; + + public function __construct (array $options) + { + $this->options = $options; + } + /** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { + $options = $this->options; $builder - ->add('file','file', array('label' => 'File to Upload', 'attr' => array('class' => ''))) - ->add('name','text', array('attr' => array('class' => 'text form-control', 'placeholder' => 'Name of your file'),)) + ->add('file','file', array('label' => 'Image to Upload', 'attr' => array('class' => ''))) + ->add('title', 'text', array('label'=> 'Title','required' => false,'attr' => array('class' => 'form-control'))) + ->add('body', 'textarea', array('label'=> 'Text for point','required' => false,'attr' => array('class' => 'form-control'))) + ->add('location', 'entity', array('class' => 'AppBundle:Location','property'=>'title','query_builder' => + function(\AppBundle\Entity\LocationRepository $er) use ($options) { + $mapid = $options['mapid'] ; + return $er->createQueryBuilder('l') + ->join("l.map", 'm') + ->where('m.id = :id') + ->setParameter('id', $mapid); + }, 'expanded'=>false,'multiple'=>false, 'label' => 'Select Location', 'attr' => array('class' => 'form-control'), + )) ; } diff --git a/src/AppBundle/Form/LocationType.php b/src/AppBundle/Form/LocationType.php index 89b497c..630d304 100644 --- a/src/AppBundle/Form/LocationType.php +++ b/src/AppBundle/Form/LocationType.php @@ -19,6 +19,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) ->add('lng', 'text', array('label'=> 'Longitude','required' => false,'attr' => array('class' => 'form-control'))) ->add('title', 'text', array('label'=> 'Title','required' => false,'attr' => array('class' => 'form-control'))) ->add('description', 'textarea', array('label'=> 'Description','required' => false,'attr' => array('class' => 'form-control'))) + ->add('map', 'entity', array('class' => 'AppBundle:Map','property'=>'title','expanded'=>false,'multiple'=>false, 'label' => 'Select Map', + 'attr' => array('class' => 'form-control'))) ; } diff --git a/src/AppBundle/Resources/views/File/index.html.twig b/src/AppBundle/Resources/views/File/index.html.twig index 64dbe3e..d986f1c 100644 --- a/src/AppBundle/Resources/views/File/index.html.twig +++ b/src/AppBundle/Resources/views/File/index.html.twig @@ -1,49 +1,49 @@ {% extends '::base.html.twig' %} {% block body -%} -

    File list

    - - - - - - - - - - - - - - - {% for entity in entities %} - - - - - - - - - - {% endfor %} - -
    IdNamePathAccessCreatedUpdatedActions
    {{ entity.id }}{{ entity.name }}{{ entity.path }}{{ entity.access }}{% if entity.created %}{{ entity.created|date('Y-m-d H:i:s') }}{% endif %}{% if entity.updated %}{{ entity.updated|date('Y-m-d H:i:s') }}{% endif %} - -
    - -
    - {% endblock %} + {% if entity.user.username == app.user.username %} + Edit + {% endif %} + {% if is_granted('ROLE_ADMIN') and entity.status==0 %} + Release + {% endif %} +
  • + {% endfor %} + {% if is_granted('ROLE_USER') %} + + + + + {% endif %} + +{% endblock %} diff --git a/src/AppBundle/Resources/views/File/new.html.twig b/src/AppBundle/Resources/views/File/new.html.twig index 530d4f5..4b1f451 100644 --- a/src/AppBundle/Resources/views/File/new.html.twig +++ b/src/AppBundle/Resources/views/File/new.html.twig @@ -1,15 +1,8 @@ {% extends '::base.html.twig' %} {% block body -%} -

    File creation

    +

    Point creation

    {{ form(form) }} - {% endblock %} diff --git a/src/AppBundle/Resources/views/Map/edit.html.twig b/src/AppBundle/Resources/views/Map/edit.html.twig index 7b0ebe6..0932b8d 100644 --- a/src/AppBundle/Resources/views/Map/edit.html.twig +++ b/src/AppBundle/Resources/views/Map/edit.html.twig @@ -5,12 +5,4 @@ {{ form(edit_form) }} - {% endblock %} diff --git a/src/AppBundle/Resources/views/Map/show.html.twig b/src/AppBundle/Resources/views/Map/show.html.twig index a40a1f7..f3f666d 100644 --- a/src/AppBundle/Resources/views/Map/show.html.twig +++ b/src/AppBundle/Resources/views/Map/show.html.twig @@ -13,11 +13,18 @@ var max = 1.000001; var lat = marker.latitude * (Math.random() * (max - min) + min); var long = marker.longitude * (Math.random() * (max - min) + min); + var imageid = marker.id; + var imagetemp = '{{ path('file_get', { 'id': 'imageid' }) }}'; + var imagepath = imagetemp.replace('imageid', imageid) + + var content = '

    ' + marker.title + '

    ' + marker.title + '' + + '

    ' + + marker.content + '

    '; $('#map_canvas').gmap('addMarker', { 'position': new google.maps.LatLng(lat,long), 'bounds': true }).click(function () { - $('#map_canvas').gmap('openInfoWindow', {'content': marker.content}, this); + $('#map_canvas').gmap('openInfoWindow', {'content': content}, this); }); }); }); diff --git a/uploads/BaldHead.jpg b/uploads/BaldHead.jpg new file mode 100644 index 0000000..8c60450 Binary files /dev/null and b/uploads/BaldHead.jpg differ diff --git a/uploads/eveningsky.jpg b/uploads/eveningsky.jpg new file mode 100644 index 0000000..64e1710 Binary files /dev/null and b/uploads/eveningsky.jpg differ diff --git a/uploads/list.png b/uploads/list.png new file mode 100644 index 0000000..5f71ad8 Binary files /dev/null and b/uploads/list.png differ diff --git a/uploads/recycledwisdom.jpg b/uploads/recycledwisdom.jpg new file mode 100644 index 0000000..4a9ff49 Binary files /dev/null and b/uploads/recycledwisdom.jpg differ diff --git a/uploads/worms.pdf b/uploads/worms.pdf new file mode 100644 index 0000000..206b816 Binary files /dev/null and b/uploads/worms.pdf differ