Added Event listing and Event box
Signed-off-by: Gergely Polonkai <polesz@w00d5t0ck.info>
This commit is contained in:
		
							
								
								
									
										75
									
								
								app/Resources/views/Box/Events.html.twig
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								app/Resources/views/Box/Events.html.twig
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,75 @@ | ||||
| {# vim: ft=htmljinja | ||||
| #} | ||||
| 				<div id="esemenyek-gomb"> | ||||
| 					<span id="esemeny-mutato">[események gomb]</span> | ||||
| 					<div id="esemeny-box"> | ||||
| 						<div id="esemeny-belso"> | ||||
| 							<p class="honap">{{ firstDay|date('Y-m') }}</p> | ||||
| 							<table> | ||||
| 								<thead> | ||||
| 									<tr> | ||||
| 										<td></td> | ||||
| 										<td>H</td> | ||||
| 										<td>K</td> | ||||
| 										<td>Sze</td> | ||||
| 										<td>Cs</td> | ||||
| 										<td>P</td> | ||||
| 										<td>Szo</td> | ||||
| 										<td>V</td> | ||||
| 									</tr> | ||||
| 								</thead> | ||||
| 								<tbody> | ||||
| 									<tr> | ||||
| 										<td class="woy">{{ firstDay|date('W') }}</td> | ||||
| {% set curDow = 0 %} | ||||
| {% if firstDayWeekday != 1 %} | ||||
| {% for i in 1..(firstDayWeekday - 1) %} | ||||
| {% set curDow = curDow + 1 %}{% if curDow == 8 %}{% set curDow = 1 %}{% endif %} | ||||
| 										<td></td> | ||||
| {% endfor %} | ||||
| {% endif %} | ||||
| {% set cur = firstDayWeekday - 1 %} | ||||
| {% for i in 1..numDays %} | ||||
| {% set cur = cur + 1 %} | ||||
| {% set curDow = curDow + 1 %}{% if curDow == 8 %}{% set curDow = 1 %}{% endif %} | ||||
| {% set eventCount = 0 %} | ||||
| {# TODO Check if an event occurs on this date: | ||||
| (event.startDate = this day AND event.endDate is NULL) | ||||
| OR (event.startDate <= this day AND evend.endDate >= this day) | ||||
| #} | ||||
| 										<td id="event-calendar-{{ i }}"{% if eventList[i].events|length > 0 %} class="program"{% endif %}> | ||||
| 											<a href="{{ path('KekRozsakFrontBundle_eventList', { date: eventList[i].date|date('Y-m-d')}) }}">{{ eventList[i].date|date('d') }}</a> | ||||
| {% if eventList[i].events|length > 0 %} | ||||
| 											<script type="text/javascript"> | ||||
| 												$('#event-calendar-{{ i }}').tooltip({ | ||||
| 													bodyHandler: function() { | ||||
| 														eventList = ''; | ||||
| {% for event in eventList[i].events %} | ||||
| 														eventList += '{{ event.title }}<br />'; | ||||
| {% endfor %} | ||||
| 														return ((eventList == '') ? false : eventList); | ||||
| 													} | ||||
| 												}); | ||||
| 											</script> | ||||
| {% endif %} | ||||
| 										</td> | ||||
| {% if cur is divisibleby(7) %} | ||||
| 									</tr> | ||||
| {% if cur != numDays %} | ||||
| 									<tr> | ||||
| 										<td class="woy">{{ eventList[i + 1].date|date('W') }}</td> | ||||
| {% endif %} | ||||
| {% endif %} | ||||
| {% endfor %} | ||||
| {% if curDow != 7 %} | ||||
| {% for i in (curDow + 1)..7 %} | ||||
| 										<td></td> | ||||
| {% endfor %} | ||||
| {% endif %} | ||||
| 									</tr> | ||||
| 								</tbody> | ||||
| 							</table> | ||||
| 							<a href="">További események</a> | ||||
| 						</div> | ||||
| 					</div> | ||||
| 				</div> | ||||
| @@ -19,6 +19,7 @@ | ||||
| 			<div id="top-line"> | ||||
| {% if app.user %} | ||||
| {% include ':Box:UserProfile.html.twig' %} | ||||
| {% include ':Box:Events.html.twig' %} | ||||
| {% else %} | ||||
| {% include ':Box:Login.html.twig' %} | ||||
| {% endif %} | ||||
| @@ -91,6 +92,16 @@ | ||||
| 				delay: 0, | ||||
| 				fade: 250 | ||||
| 			}); | ||||
| 			$('#esemeny-mutato').click(function() { | ||||
| 				if ($('#esemeny-box').is(':visible')) | ||||
| 				{ | ||||
| 					$('#esemeny-box').hide(); | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					$('#esemeny-box').show(); | ||||
| 				} | ||||
| 			}); | ||||
| {% else %} | ||||
| 			$('#login-mutato').click(function() { | ||||
| 				if ($('#login-box').is(':visible')) | ||||
|   | ||||
							
								
								
									
										75
									
								
								src/KekRozsak/FrontBundle/Controller/EventController.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								src/KekRozsak/FrontBundle/Controller/EventController.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,75 @@ | ||||
| <?php | ||||
|  | ||||
| namespace KekRozsak\FrontBundle\Controller; | ||||
|  | ||||
| use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||||
| use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||||
| use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; | ||||
| use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; | ||||
|  | ||||
| use KekRozsak\FrontBundle\Entity\Event; | ||||
|  | ||||
| class EventController extends Controller | ||||
| { | ||||
| 	/** | ||||
| 	 * @Route("/esesmeny/{startDate}/{eventSlug}", name="KekRozsakFrontBundle_eventView") | ||||
| 	 * @Template() | ||||
| 	 * @ParamConverter("event", class="KekRozsakFrontBundle:Event", options={"mapping"={"eventSlug" = "slug", "startDate"="startDate"}}) | ||||
| 	 * @ParamConverter("startDate", class="DateTime", options={"format"="Y-m-d"}) | ||||
| 	 */ | ||||
| 	public function viewAction(\DateTime $startDate, Event $event) | ||||
| 	{ | ||||
| 		if ($event->getGroup() !== null) | ||||
| 		{ | ||||
| 			if (!$event->getGroup()->isMember($this->get('security.context')->getToken()->getUser())) | ||||
| 				throw new AccessDeniedException('Ehhez az eseményhez nem csatlakozhatsz, mivel a csoportjának nem vagy tagja.'); | ||||
| 		} | ||||
|  | ||||
| 		return array( | ||||
| 			'event' => $event, | ||||
| 		); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @Route("/esemeny/{startDate}/{eventSlug}/csatlakozas", name="KekRozsakFrontBundle_eventJoin") | ||||
| 	 * @Template() | ||||
| 	 * @ParamConverter("event", class="KekRozsakFrontBundle:Event", options={"mapping"={"eventSlug"="slug", "startDate"="startDate"}}) | ||||
| 	 * @ParamConverter("startDate", class="DateTime", options={"format"="Y-m-d"}) | ||||
| 	 */ | ||||
| 	public function joinAction(\DateTime $startDate, Event $event) | ||||
| 	{ | ||||
| 		if ($event->getGroup() !== null) | ||||
| 		{ | ||||
| 			if (!$event->getGroup()->isMember($this->get('security.context')->getToken()->getUser())) | ||||
| 				throw new AccessDeniedException('Ehhez az eseményhez nem csatlakozhatsz, mivel a csoportjának nem vagy tagja.'); | ||||
| 		} | ||||
|  | ||||
| 		$event->addAttendee($this->get('security.context')->getToken()->getUser()); | ||||
|  | ||||
| 		$em = $this->getDoctrine()->getEntityManager(); | ||||
| 		$em->persist($event); | ||||
| 		$em->flush(); | ||||
|  | ||||
| 		return $this->redirect($this->generateUrl('KekRozsakFrontBundle_eventView', array( | ||||
| 			'eventDate' => $eventDate, | ||||
| 			'eventSlug' => $eventSlug, | ||||
| 		))); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @Route("/esemenyek/{date}", name="KekRozsakFrontBundle_eventList") | ||||
| 	 * @Template() | ||||
| 	 * @ParamConverter("date", class="DateTime", options={"format": "Y-m-d"}) | ||||
| 	 */ | ||||
| 	public function listAction(\DateTime $date) | ||||
| 	{ | ||||
| 		$query = $this->getDoctrine()->getEntityManager()->createQuery('SELECT e FROM KekRozsakFrontBundle:Event e WHERE e.cancelled = FALSE AND ((e.startDate < :day AND e.endDate >= :day) OR e.startDate = :day)'); | ||||
| 		$query->setParameter('day', $date, \Doctrine\DBAL\Types\Type::DATE); | ||||
| 		$events = $query->getResult(); | ||||
|  | ||||
| 		return array( | ||||
| 			'day'    => $date, | ||||
| 			'events' => $events, | ||||
| 		); | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										402
									
								
								src/KekRozsak/FrontBundle/Entity/Event.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										402
									
								
								src/KekRozsak/FrontBundle/Entity/Event.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,402 @@ | ||||
| <?php | ||||
|  | ||||
| namespace KekRozsak\FrontBundle\Entity; | ||||
|  | ||||
| use Doctrine\ORM\Mapping as ORM; | ||||
| use Doctrine\Common\Collections\ArrayCollection; | ||||
| use Symfony\Component\Validator\Constraints as Assert; | ||||
| use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert; | ||||
|  | ||||
| /** | ||||
|  * @ORM\Entity | ||||
|  * @ORM\Table(name="events") | ||||
|  * | ||||
|  * @DoctrineAssert\UniqueEntity(fields={"startDate", "slug"}) | ||||
|  * @DoctrineAssert\UniqueEntity(fields={"startDate", "title"}) | ||||
|  */ | ||||
| class Event | ||||
| { | ||||
| 	/** | ||||
| 	 * @var integer $id | ||||
| 	 * | ||||
| 	 * @ORM\Id | ||||
| 	 * @ORM\GeneratedValue(strategy="AUTO") | ||||
| 	 * @ORM\Column(type="integer") | ||||
| 	 */ | ||||
| 	protected $id; | ||||
| 	 | ||||
| 	/** | ||||
| 	 * Get id | ||||
| 	 * | ||||
| 	 * @return integer | ||||
| 	 */ | ||||
| 	public function getId() | ||||
| 	{ | ||||
| 		return $this->id; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| 	 * @var KekRozsak\SecurityBundle\Entity\User $createdBy | ||||
| 	 * | ||||
| 	 * @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User") | ||||
| 	 * @ORM\JoinColumn(name="created_by_id") | ||||
| 	 */ | ||||
| 	protected $createdBy; | ||||
| 	 | ||||
| 	/** | ||||
| 	 * Set createdBy | ||||
| 	 * | ||||
| 	 * @param KekRozsak\SecurityBundle\Entity\User $createdBy | ||||
| 	 * @return Event | ||||
| 	 */ | ||||
| 	public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy) | ||||
| 	{ | ||||
| 		$this->createdBy = $createdBy; | ||||
| 		return $this; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| 	 * Get createdBy | ||||
| 	 * | ||||
| 	 * @return KekRozsak\SecurityBundle\Entity\User | ||||
| 	 */ | ||||
| 	public function getCreatedBy() | ||||
| 	{ | ||||
| 		return $this->createdBy; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| 	 * @var DateTime $startDate | ||||
| 	 * | ||||
| 	 * @ORM\Column(type="date", nullable=true, name="start_date", nullable=false) | ||||
| 	 */ | ||||
| 	protected $startDate; | ||||
| 	 | ||||
| 	/** | ||||
| 	 * Set startDate | ||||
| 	 * | ||||
| 	 * @param DateTime $startDate | ||||
| 	 * @return Event | ||||
| 	 */ | ||||
| 	public function setStartDate(\DateTime $startDate = null) | ||||
| 	{ | ||||
| 		$this->startDate = $startDate; | ||||
| 		return $this; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| 	 * Get startDate | ||||
| 	 * | ||||
| 	 * @return DateTime | ||||
| 	 */ | ||||
| 	public function getStartDate() | ||||
| 	{ | ||||
| 		return $this->startDate; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| 	 * @var DateTime $endDate | ||||
| 	 * | ||||
| 	 * @ORM\Column(type="date", nullable=true, name="end_date") | ||||
| 	 */ | ||||
| 	protected $endDate; | ||||
|  | ||||
| 	/** | ||||
| 	 * Set endDate | ||||
| 	 * | ||||
| 	 * @param DateTime $endDate | ||||
| 	 * @return Event | ||||
| 	 */ | ||||
| 	public function setEndDate(\DateTime $endDate) | ||||
| 	{ | ||||
| 		$this->endDate = $endDate; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get endDate | ||||
| 	 * | ||||
| 	 * @return DateTime | ||||
| 	 */ | ||||
| 	public function getEndDate() | ||||
| 	{ | ||||
| 		return $this->endDate; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @var Doctrine\Common\Collections\ArrayCollection $attendees | ||||
| 	 * | ||||
| 	 * @ORM\ManyToMany(targetEntity="KekRozsak\SecurityBundle\Entity\User") | ||||
| 	 * @ORM\JoinTable(name="event_attendees") | ||||
| 	 */ | ||||
| 	protected $attendees; | ||||
|  | ||||
| 	/** | ||||
| 	 * Add attendee | ||||
| 	 * | ||||
| 	 * @param KekRozsak\SecurityBundle\Entity\User $attendee | ||||
| 	 * @return Event | ||||
| 	 */ | ||||
| 	public function addAttendee(\KekRozsak\SecurityBundle\Entity\User $attendee) | ||||
| 	{ | ||||
| 		$this->attendees[] = $attendee; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get all attendees | ||||
| 	 * | ||||
| 	 * @return Doctrine\Common\Collections\ArrayCollection | ||||
| 	 */ | ||||
| 	public function getAttendees() | ||||
| 	{ | ||||
| 		return $this->attendees; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Check if a user is attending | ||||
| 	 * | ||||
| 	 * @param KekRozsak\SecurityBundle\Entity\User $user | ||||
| 	 * @return boolean | ||||
| 	 */ | ||||
| 	public function isAttending(\KekRozsak\SecurityBundle\Entity\User $user) | ||||
| 	{ | ||||
| 		$users = $this->attendees->filter(function ($attendee) use ($user) { | ||||
| 			if ($attendee == $user) | ||||
| 				return true; | ||||
| 		}); | ||||
|  | ||||
| 		return ($users->count() != 0); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @var string $title | ||||
| 	 * | ||||
| 	 * @ORM\Column(type="string", length=150) | ||||
| 	 * | ||||
| 	 * @Assert\NotBlank() | ||||
| 	 */ | ||||
| 	protected $title; | ||||
|  | ||||
| 	/** | ||||
| 	 * Set title | ||||
| 	 * | ||||
| 	 * @param string $title | ||||
| 	 * @return Event | ||||
| 	 */ | ||||
| 	public function setTitle($title) | ||||
| 	{ | ||||
| 		$this->title = $title; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get title | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function getTitle() | ||||
| 	{ | ||||
| 		return $this->title; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @var string $slug | ||||
| 	 * | ||||
| 	 * @ORM\Column(type="string", length=150) | ||||
| 	 * | ||||
| 	 * @Assert\NotBlank() | ||||
| 	 */ | ||||
| 	protected $slug; | ||||
|  | ||||
| 	/** | ||||
| 	 * Set slug | ||||
| 	 * | ||||
| 	 * @param string $slug | ||||
| 	 * @return Event | ||||
| 	 */ | ||||
| 	public function setSlug($slug) | ||||
| 	{ | ||||
| 		$this->slug = $slug; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get slug | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function getSlug() | ||||
| 	{ | ||||
| 		return $this->slug; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @var string $description | ||||
| 	 * | ||||
| 	 * @ORM\Column(type="text") | ||||
| 	 * | ||||
| 	 * @Assert\NotBlank() | ||||
| 	 */ | ||||
| 	protected $description; | ||||
|  | ||||
| 	/** | ||||
| 	 * Set description | ||||
| 	 * | ||||
| 	 * @param string $description | ||||
| 	 * @return Event | ||||
| 	 */ | ||||
| 	public function setDescription($description) | ||||
| 	{ | ||||
| 		$this->description = $description; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get description | ||||
| 	 * | ||||
| 	 * @return string | ||||
| 	 */ | ||||
| 	public function getDescription() | ||||
| 	{ | ||||
| 		return $this->description; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @var KekRozsak\FrontBundle\Entity\Group $group | ||||
| 	 * | ||||
| 	 * @ORM\ManyToOne(targetEntity="KekRozsak\FrontBundle\Entity\Group") | ||||
| 	 */ | ||||
| 	protected $group; | ||||
|  | ||||
| 	/** | ||||
| 	 * Set group | ||||
| 	 * | ||||
| 	 * @param KekRozsak\FrontBundle\Entity\Group $group | ||||
| 	 * @return Event | ||||
| 	 */ | ||||
| 	public function setGroup(\KekRozsak\FrontBundle\Entity\Group $group = null) | ||||
| 	{ | ||||
| 		$this->group = $group; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get group | ||||
| 	 * | ||||
| 	 * @return KekRozsak\FrontBundle\Entity\Group | ||||
| 	 */ | ||||
| 	public function getGroup() | ||||
| 	{ | ||||
| 		return $this->group; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @var boolean $cancelled | ||||
| 	 * | ||||
| 	 * @ORM\Column(type="boolean", nullable=false) | ||||
| 	 */ | ||||
| 	protected $cancelled; | ||||
|  | ||||
| 	/** | ||||
| 	 * Set cancelled | ||||
| 	 * | ||||
| 	 * @param boolean $cancelled | ||||
| 	 * @return Event | ||||
| 	 */ | ||||
| 	public function setCancelled($cancelled = false) | ||||
| 	{ | ||||
| 		$this->cancelled = $cancelled; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get cancelled | ||||
| 	 * | ||||
| 	 * @return boolean | ||||
| 	 */ | ||||
| 	public function getCancelled() | ||||
| 	{ | ||||
| 		return $this->cancelled; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @var DateTime $startTime | ||||
| 	 * | ||||
| 	 * @ORM\Column(type="time", nullable=false, name="start_time") | ||||
| 	 */ | ||||
| 	protected $startTime; | ||||
|  | ||||
| 	/** | ||||
| 	 * Set startTime | ||||
| 	 * | ||||
| 	 * @param DateTime $startTime | ||||
| 	 * @return Event | ||||
| 	 */ | ||||
| 	public function setStartTime(\DateTime $startTime) | ||||
| 	{ | ||||
| 		$this->startTime = $startTime; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get startTime | ||||
| 	 * | ||||
| 	 * @return DateTime | ||||
| 	 */ | ||||
| 	public function getStartTime() | ||||
| 	{ | ||||
| 		return $this->startTime; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * @var DateTime $endTime | ||||
| 	 * | ||||
| 	 * @ORM\Column(type="time", nullable=true, name="end_time") | ||||
| 	 */ | ||||
| 	protected $endTime; | ||||
|  | ||||
| 	/** | ||||
| 	 * Set endTime | ||||
| 	 * | ||||
| 	 * @param DateTime $endTime | ||||
| 	 * @return Event | ||||
| 	 */ | ||||
| 	public function setEndTime(\DateTime $endTime) | ||||
| 	{ | ||||
| 		$this->endTime = $endTime; | ||||
| 		return $this; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Get endTime | ||||
| 	 * | ||||
| 	 * @return DateTime | ||||
| 	 */ | ||||
| 	public function getEndTime() | ||||
| 	{ | ||||
| 		return $this->endTime; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Check if an event will go on a specific date | ||||
| 	 * | ||||
| 	 * @param DateTime $date | ||||
| 	 * @return boolean | ||||
| 	 */ | ||||
| 	public function isOnDate(\DateTime $date) | ||||
| 	{ | ||||
| 		$date->setTime(0, 0, 0); | ||||
|  | ||||
| 		return ( | ||||
| 			( | ||||
| 				($this->startDate == $date) | ||||
| 				&& ($this->endDate === null) | ||||
| 			) | ||||
| 			|| ( | ||||
| 				($this->startDate <= $date) | ||||
| 				&& ($this->endDate >= $date) | ||||
| 			) | ||||
| 		); | ||||
| 	} | ||||
| } | ||||
| @@ -7,6 +7,11 @@ | ||||
| 			<argument type="service" id="security.context" /> | ||||
| 			<tag name="twig.extension" /> | ||||
| 		</service> | ||||
| 		<service id="kek_rozsak_front.twig_extension.events" class="KekRozsak\FrontBundle\Twig\EventsExtension"> | ||||
| 			<argument type="service" id="doctrine" /> | ||||
| 			<argument type="service" id="security.context" /> | ||||
| 			<tag name="twig.extension" /> | ||||
| 		</service> | ||||
| 		<service id="form.type_extension.help_message" class="KekRozsak\FrontBundle\Form\Extension\HelpMessageTypeExtension"> | ||||
| 			<tag name="form.type_extension" alias="field" /> | ||||
| 		</service> | ||||
|   | ||||
| @@ -0,0 +1,16 @@ | ||||
| {# vim: ft=htmljinja | ||||
| #} | ||||
| {% extends '::main_template.html.twig' %} | ||||
| {% block title %} - Események - {{ day|date('Y-m-d') }}{% endblock %} | ||||
| {% block content %} | ||||
| <h3>Események - {{ day|date('Y-m-d') }}</h3> | ||||
| {% if events %} | ||||
| <ul> | ||||
| {% for event in events %} | ||||
| 	<li><a href="{{ path('KekRozsakFrontBundle_eventView', {startDate: event.startDate|date('Y-m-d'), eventSlug: event.slug}) }}">{{ event.title }}</a></li> | ||||
| {% endfor %} | ||||
| </ul> | ||||
| {% else %} | ||||
| <p>Erre a napra nincsenek kiírva események.</p> | ||||
| {% endif %} | ||||
| {% endblock content %} | ||||
| @@ -0,0 +1,21 @@ | ||||
| {# vim: ft=htmljinja | ||||
| #} | ||||
| {% extends '::main_template.html.twig' %} | ||||
| {% block title %} - Esemény - {{ event.title }}{% endblock %} | ||||
| {% block content %} | ||||
| <h3>Esemény - {{ event.title }}</h3> | ||||
| <p class="esemeny-idopont">{{ event.startDate|date('Y-m-d') }} {{ event.startTime|date('H:i') }}{% if event.endDate or event.endTime %} - {% endif %}{% if event.endDate is not null %} {{ event.endDate|date('Y-m-d') }}{% endif %}{% if event.endTime is not null %} {{ event.endTime|date('H:i') }}{% endif %}</p> | ||||
| <p class="esemeny-szervezo">Az eseményt szervezi: {{ event.createdBy.displayName }}</p> | ||||
| <p> | ||||
| 	{{ event.description }} | ||||
| </p> | ||||
| <h4>Eddigi résztvevők</h4> | ||||
| <ul> | ||||
| {% for attendee in event.attendees %} | ||||
| 	<li>{{ attendee.displayName }}</li> | ||||
| {% endfor %} | ||||
| </ul> | ||||
| {% if not event.isAttending(app.user) %} | ||||
| <a href="{{ path('KekRozsakFrontBundle_eventJoin', { eventDate: event.startDate|date('Y-m-d'), eventSlug: event.slug }) }}">Megyek</a> | ||||
| {% endif %} | ||||
| {% endblock content %} | ||||
							
								
								
									
										67
									
								
								src/KekRozsak/FrontBundle/Twig/EventsExtension.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								src/KekRozsak/FrontBundle/Twig/EventsExtension.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,67 @@ | ||||
| <?php | ||||
|  | ||||
| namespace KekRozsak\FrontBundle\Twig; | ||||
|  | ||||
| use Symfony\Bridge\Doctrine\RegistryInterface; | ||||
| use Symfony\Component\Security\Core\SecurityContextInterface; | ||||
|  | ||||
| class EventsExtension extends \Twig_Extension | ||||
| { | ||||
| 	protected $_doctrine; | ||||
| 	protected $_securityContext; | ||||
|  | ||||
| 	public function __construct(RegistryInterface $doctrine, SecurityContextInterface $securityContext) | ||||
| 	{ | ||||
| 		$this->_doctrine = $doctrine; | ||||
| 		$this->_securityContext = $securityContext; | ||||
| 	} | ||||
|  | ||||
| 	public function getGlobals() | ||||
| 	{ | ||||
| 		$today = new \DateTime('now'); | ||||
| 		$firstDay = \DateTime::createFromFormat('Y-m-d', $today->format('Y-m-01')); | ||||
| 		$firstDayWeekday = $firstDay->format('N'); | ||||
| 		$numDays = $firstDay->format('t'); | ||||
| 		$lastDay = \DateTime::createFromFormat('Y-m-d', $today->format('Y-m-' . sprintf("%02d", $numDays))); | ||||
|  | ||||
| 		/* | ||||
| 		 * Get all events in today's month. Iterate through this | ||||
| 		 * collection, adding each element to $monthEvents array's | ||||
| 		 * 'day'th element array. | ||||
| 		 */ | ||||
| 		$query = $this->_doctrine->getEntityManager()->createQuery('SELECT e FROM KekRozsakFrontBundle:Event e WHERE e.cancelled = FALSE AND ((e.startDate < :firstDay AND e.endDate >= :firstDay) OR e.startDate BETWEEN :firstDay AND :lastDay)'); | ||||
| 		$query->setParameter('firstDay', $firstDay, \Doctrine\DBAL\Types\Type::DATE); | ||||
| 		$query->setParameter('lastDay', $lastDay, \Doctrine\DBAL\Types\Type::DATE); | ||||
| 		$events = $query->getResult(); | ||||
|  | ||||
| 		$eventList = array(); | ||||
| 		for ($i = 1; $i <= $numDays; $i++) | ||||
| 		{ | ||||
| 			$date = \DateTime::createFromFormat('Y-m-d', $today->format('Y-m-' . sprintf('%02d', $i))); | ||||
| 			$eventList[$i]['date'] = $date; | ||||
| 			$eventList[$i]['events'] = array(); | ||||
| 			foreach ($events as $event) | ||||
| 			{ | ||||
| 				if ($event->isOnDate($date)) | ||||
| 				{ | ||||
| 					$eventList[$i]['events'][] = $event; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return array( | ||||
| 			'events'          => $events, | ||||
| 			'eventList'       => $eventList, | ||||
| 			'today'           => $today, | ||||
| 			'firstDay'        => $firstDay, | ||||
| 			'lastDay'         => $lastDay, | ||||
| 			'firstDayWeekday' => $firstDayWeekday, | ||||
| 			'numDays'         => $numDays, | ||||
| 		); | ||||
| 	} | ||||
|  | ||||
| 	public function getName() | ||||
| 	{ | ||||
| 		return 'Events'; | ||||
| 	} | ||||
| } | ||||
| @@ -86,11 +86,57 @@ body { | ||||
| 	display: none; | ||||
| } | ||||
|  | ||||
| #esemeny-box { | ||||
| 	position: fixed; | ||||
| 	left: 5px; | ||||
| 	top: 32px; | ||||
| 	width: 250px; | ||||
| 	height: 200px; | ||||
| 	background-color: #c4d3ff; | ||||
| 	border: 2px solid #152967; | ||||
| 	color: #152967; | ||||
| 	display: none; | ||||
| } | ||||
|  | ||||
| #esemeny-box td { | ||||
| 	text-align: center; | ||||
| 	vertical-align: middle; | ||||
| } | ||||
|  | ||||
| #esemeny-box td.woy { | ||||
| 	font-size: 60%; | ||||
| } | ||||
|  | ||||
| #esemeny-box td.program { | ||||
| 	background-color: green; | ||||
| } | ||||
|  | ||||
| #esemeny-belso p.honap { | ||||
| 	text-align: center; | ||||
| 	margin: 0 5px; | ||||
| 	font-weight: bold; | ||||
| } | ||||
|  | ||||
| #esemeny-belso table { | ||||
| 	margin-left: auto; | ||||
| 	margin-right: auto; | ||||
| } | ||||
|  | ||||
| #login-belso { | ||||
| 	position: relative; | ||||
| 	padding: 5px; | ||||
| } | ||||
|  | ||||
| #esemeny-belso { | ||||
| 	position: relative; | ||||
| 	padding: 5px; | ||||
| } | ||||
|  | ||||
| #esemenyek-gomb { | ||||
| 	float: left; | ||||
| 	padding: 5px; | ||||
| } | ||||
|  | ||||
| #bottom-line { | ||||
| 	position: fixed; | ||||
| 	left: 0; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user