Skip to content

Commit

Permalink
Add Event
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Caillau committed Dec 26, 2012
1 parent 766abe1 commit abd0a4f
Show file tree
Hide file tree
Showing 32 changed files with 824 additions and 97 deletions.
47 changes: 42 additions & 5 deletions app/Resources/views/layout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,54 @@
<a class="brand" href="#">My Website</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li {% if page is defined %} {% if page == 'home'%} class="active" {% endif %} {% endif %}><a href="{{ path('home') }}">Home</a></li>
<li {% if page is defined %} {% if page == 'gallery'%} class="active" {% endif %} {% endif %}><a href="{{ path('gallery') }}">Gallery</a></li>
<li {% if page is defined %} {% if page == 'about'%} class="active" {% endif %} {% endif %}><a href="{{ path('about') }}">About</a></li>
<li {% if page is defined %} {% if page == 'contact'%} class="active" {% endif %} {% endif %}><a href="{{ path('contact') }}">Contact</a></li>
<li{% if page is defined %} {% if page == 'home'%} class="active" {% endif %} {% endif %}><a href="{{ path('home') }}"><i class="icon-home icon-white"> </i></a></li>
<li{% if page is defined %} {% if page == 'gallery'%} class="active" {% endif %} {% endif %}><a href="{{ path('gallery') }}"><i class="icon-picture icon-white"> </i></a></li>
<li{% if page is defined %} {% if page == 'about'%} class="active" {% endif %} {% endif %}><a href="{{ path('about') }}"><i class="icon-question-sign icon-white"> </i></a></li>
<li><a href="#email" data-toggle="modal"><i class="icon-envelope icon-white"> </i></a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div id="email" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Send me an email</h3>
</div>
<div class="modal-body">
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" for="inputEmail">Your Email</label>
<div class="controls">
<input type="text" id="inputEmail" placeholder="[email protected]"><br />
</div>
</div>
<div class="control-group">
<label class="control-label" for="subject">Subject</label>
<div class="controls">
<select name="subject">
<option value="">1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</div>

</div>
<div class="control-group">
<label class="control-label" for="content">Content</label>
<div class="controls">
<textarea rows="8" name="content" id="content"></textarea>

{# render "SdzBlogBundle:Blog:menu" with {'nombre': 3} #}
</div>
</div>
</form>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">Close</a>
<a href="#" class="btn btn-primary">Send email</a>
</div>
</div>

<header id="header1">
<div class="container">
Expand Down
45 changes: 43 additions & 2 deletions src/Chouffe/MagicBundle/Controller/AlbumController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,27 @@
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Chouffe\MagicBundle\Entity\Album;
use Chouffe\MagicBundle\Entity\Photo;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use JMS\SecurityExtraBundle\Annotation\Secure;
use Chouffe\MagicBundle\Form\AlbumType;
use Chouffe\MagicBundle\Form\PhotoType;

class AlbumController extends Controller
{

public function seeAction(Album $album)
{
$em = $this->getDoctrine()->getManager();

$photo = new Photo();
$form = $this->createForm(new PhotoType, $photo);

return $this->render('ChouffeMagicBundle:Default:album.html.twig', array('action' => 'add', 'page' => 'gallery', 'form' => $form->createView(), 'album' => $album));

}


// TODO
public function fetchAllAction()
{
Expand All @@ -22,7 +36,7 @@ public function fetchAllAction()
$album = new Album();
$form = $this->createForm(new AlbumType, $album);

return $this->render('ChouffeMagicBundle:Default:gallery.html.twig', array('page' => 'gallery', 'form' => $form->createView(), 'albumList' => $albumList));
return $this->render('ChouffeMagicBundle:Default:gallery.html.twig', array('action' => 'add', 'page' => 'gallery', 'form' => $form->createView(), 'albumList' => $albumList));


}
Expand All @@ -36,7 +50,7 @@ public function fetchAction(Album $album)
$news = new News();
$form = $this->createForm(new NewsType, $news);

return $this->render('ChouffeMagicBundle:Default:news.html.twig', array('page' => 'home', 'form' => $form->createView(), 'newsList' => $newsList));
return $this->render('ChouffeMagicBundle:Default:news.html.twig', array('action' => 'add', 'page' => 'home', 'form' => $form->createView(), 'newsList' => $newsList));
}

/**
Expand Down Expand Up @@ -66,11 +80,38 @@ public function addAction()
return new Response('0');
}

/**
* @Secure(roles="ROLE_ADMIN")
*/
public function updateAddAction(Album $album)
{
$form = $this->createForm(new AlbumType, $album);

// La gestion d'un formulaire est particulière, mais l'idée est la suivante
if( $this->get('request')->getMethod() == 'POST' )
{
// Ici, on s'occupera de la création et de la gestion du formulaire
$request = $this->get('request');
$form->bind($request);

$em = $this->getDoctrine()->getManager();
$em->persist($album);
$em->flush();

$this->get('session')->getFlashBag()->add('notice', 'News Updated');
return new Response('1');
}

return new Response('0');
}

/**
* @Secure(roles="ROLE_ADMIN")
*/
public function updateAction(Album $album)
{
$form = $this->createForm(new AlbumType, $album);
return $this->render('ChouffeMagicBundle:forms:album.html.twig', array('action' => 'update', 'form' => $form->createView()));
}

/**
Expand Down
13 changes: 8 additions & 5 deletions src/Chouffe/MagicBundle/Controller/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,34 @@
use Chouffe\MagicBundle\Form\NewsType;
use Chouffe\MagicBundle\Entity\Photo;
use Chouffe\MagicBundle\Form\PhotoType;
use Chouffe\MagicBundle\Entity\Event;
use Chouffe\MagicBundle\Form\EventType;

class DefaultController extends Controller
{
public function indexAction($name)
{
$em = $this->getDoctrine()->getManager();
$repo = $em->getRepository('ChouffeMagicBundle:News');
$lastNews = $repo->find(1);
$lastNews->setContent('test new content');
// $newNews = new News();
// $newNews->setContent('test');
// $newNews->setTitle('title');
// $em->persist($newNews);
$em->persist($lastNews);
$em->flush();
// $em->persist($lastNews);
// $em->flush();
// print_r($lastNews);
$news = new News();
$album = new Album();
$photo = new Photo();
$event = new Event();
$form = $this->createForm(new NewsType(), $news);
$form2 = $this->createForm(new AlbumType, $album);
$form3 = $this->createForm(new PhotoType, $photo);
$form4 = $this->createForm(new EventType, $event);
// return $this->render('ChouffeMagicBundle:forms:news.html.twig', array('form' => $form->createView()));
// return $this->render('ChouffeMagicBundle:forms:photo.html.twig', array('form' => $form3->createView()));
return $this->render('ChouffeMagicBundle:forms:album.html.twig', array('form' => $form2->createView()));
// return $this->render('ChouffeMagicBundle:forms:album.html.twig', array('form' => $form2->createView()));
return $this->render('ChouffeMagicBundle:forms:event.html.twig', array('form' => $form4->createView()));
// return $this->render('ChouffeMagicBundle:Default:index.html.twig', array('name' => $name, 'form' => $form->createView()));
}

Expand Down
72 changes: 72 additions & 0 deletions src/Chouffe/MagicBundle/Controller/EventController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace Chouffe\MagicBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Chouffe\MagicBundle\Entity\Event;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use JMS\SecurityExtraBundle\Annotation\Secure;
use Chouffe\MagicBundle\Form\EventType;


class EventController extends Controller
{

/**
* @Secure(roles="ROLE_ADMIN")
*/
public function addAction()
{
$event = new Event();
$form = $this->createForm(new EventType, $event);

// La gestion d'un formulaire est particulière, mais l'idée est la suivante
if( $this->get('request')->getMethod() == 'POST' )
{
// Ici, on s'occupera de la création et de la gestion du formulaire
$request = $this->get('request');
$form->bind($request);

$em = $this->getDoctrine()->getManager();
$em->persist($event);
$em->flush();

$this->get('session')->getFlashBag()->add('notice', 'Event saved');
return new Response('1');
}


return new Response('0');
}
/**
* @Secure(roles="ROLE_ADMIN")
*/
public function deleteAction(Event $event)
{
$em = $this->getDoctrine()->getManager();
$em->remove($event);

$response = new Response('1');
$em->flush();
return $response;
}

public function agendaAction()
{
$em = $this->getDoctrine()->getManager();
$repo = $em->getRepository('ChouffeMagicBundle:Event');
$eventList = $repo->findAll();

$event = new Event();
$formEvent = $this->createForm(new EventType, $event);

return $this->render('ChouffeMagicBundle:Default:event.html.twig', array('formEvent' => $formEvent->createView(), 'eventList' => $eventList));

}

public function seeAction(Event $event)
{
return $this->render('ChouffeMagicBundle:Default:event-zoom.html.twig', array('event' => $event));
}
}
29 changes: 28 additions & 1 deletion src/Chouffe/MagicBundle/Controller/NewsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function fetchAllAction()
$news = new News();
$form = $this->createForm(new NewsType, $news);

return $this->render('ChouffeMagicBundle:Default:news.html.twig', array('page' => 'home', 'form' => $form->createView(), 'newsList' => $newsList));
return $this->render('ChouffeMagicBundle:Default:news.html.twig', array('action' => 'add','page' => 'home', 'form' => $form->createView(), 'newsList' => $newsList));
}

public function fetchAction(News $news)
Expand Down Expand Up @@ -85,11 +85,38 @@ public function addAction()
return new Response('0');
}

/**
* @Secure(roles="ROLE_ADMIN")
*/
public function updateAddAction(News $news)
{
$form = $this->createForm(new NewsType, $news);

// La gestion d'un formulaire est particulière, mais l'idée est la suivante
if( $this->get('request')->getMethod() == 'POST' )
{
// Ici, on s'occupera de la création et de la gestion du formulaire
$request = $this->get('request');
$form->bind($request);

$em = $this->getDoctrine()->getManager();
$em->persist($news);
$em->flush();

$this->get('session')->getFlashBag()->add('notice', 'News added');
return new Response('1');
}

return new Response('0');
}

/**
* @Secure(roles="ROLE_ADMIN")
*/
public function updateAction(News $news)
{
$form = $this->createForm(new NewsType, $news);
return $this->render('ChouffeMagicBundle:forms:news.html.twig', array('action' => 'update','form' => $form->createView()));
}

/**
Expand Down
33 changes: 30 additions & 3 deletions src/Chouffe/MagicBundle/Controller/PhotoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Chouffe\MagicBundle\Entity\Photo;
use Chouffe\MagicBundle\Entity\Album;
use Chouffe\MagicBundle\Entity\Photo;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use JMS\SecurityExtraBundle\Annotation\Secure;
use Chouffe\MagicBundle\Form\PhotoType;;
Expand Down Expand Up @@ -50,7 +50,7 @@ public function fetchAction(Photo $photo)
/**
* @Secure(roles="ROLE_ADMIN")
*/
public function addAction(Album $album)
public function addAction(Photo $photo)
{
$photo = new Photo();
$form = $this->createForm(new PhotoType, $photo);
Expand All @@ -61,9 +61,11 @@ public function addAction(Album $album)
// Ici, on s'occupera de la création et de la gestion du formulaire
$request = $this->get('request');
$form->bind($request);
$photo->setAlbum($album);
$photo->setPhoto($photo);

$em = $this->getDoctrine()->getManager();
$photo->addPhoto($photo);
$em->persist($photo);
$em->persist($photo);
$em->flush();

Expand All @@ -75,6 +77,31 @@ public function addAction(Album $album)
return new Response('0');
}

/**
* @Secure(roles="ROLE_ADMIN")
*/
public function updateAddAction(Photo $photo)
{
$form = $this->createForm(new PhotoType, $photo);

// La gestion d'un formulaire est particulière, mais l'idée est la suivante
if( $this->get('request')->getMethod() == 'POST' )
{
// Ici, on s'occupera de la création et de la gestion du formulaire
$request = $this->get('request');
$form->bind($request);

$em = $this->getDoctrine()->getManager();
$em->persist($photo);
$em->flush();

$this->get('session')->getFlashBag()->add('notice', 'Photo Updated');
return new Response('1');
}

return new Response('0');
}

/**
* @Secure(roles="ROLE_ADMIN")
*/
Expand Down
Loading

0 comments on commit abd0a4f

Please sign in to comment.