Now fetching news from the database

This commit is contained in:
Polonkai Gergely 2012-07-03 18:05:09 +02:00
parent 8b0e8e1a29
commit 20fea814e4
6 changed files with 325 additions and 30 deletions

8
TODO
View File

@ -9,14 +9,6 @@ UserData
google talk address google talk address
google talk address public? google talk address public?
News
id
title
slug
timestamp
text
poster
BlogPost BlogPost
id id
title title

View File

@ -30,30 +30,14 @@
</div> </div>
<div id="hirek"> <div id="hirek">
<h3>Hírek</h3> <h3>Hírek</h3>
{% for news in recentNews %}
<div class="hir"> <div class="hir">
<p class="hir-cim">Rendszer átalakítás, regisztráció</p> <p class="hir-cim">{{ news.title }}</p>
<p class="hir-szoveg">Ki lett dolgozva az új rendszer ami hamarosan feltöltésre kerül. Aki szeretne tagja lenni a körnek regisztrálással a fórumon jelentkezhet tagnak. Hamarosan beindulnak a csoportok és megkezdődnek az első órák. hogy mindenki a megfelelő csoportba kerüljön vegyetek részt majd a bemutató órákon. Jelentkezés a kekrozsaokkutkor@freemail.hu e-mail címen is lehet, akár tagnak, akár a csoportok bemutató óráira.</p> <p class="hir-szoveg">{{ news.text|raw }}</p>
<p class="hir-szerzo">Lakshmí</p> <p class="hir-szerzo">{{ news.createdBy.displayName }}</p>
<p class="hir-datum">2012. április 1. 23:17</p> <p class="hir-datum">{{ news.createdAt|date('Y-m-d H:i') }}</p>
</div>
<div class="hir">
<p class="hir-cim">Rendszer átalakítás</p>
<p class="hir-szoveg">Kedves tagok és új jelentkezők! A kör jelenleg belső működési és tanrendi változásokon megy keresztül a zökkenőmentes működés érdekében. Így türelmeteket kérjük. Az átalakítás várhatólag 2012. március 31.éig fog tartani.</p>
<p class="hir-szerzo">Lakshmí</p>
<p class="hir-datum">2012. március 18. 16:26</p>
</div>
<div class="hir">
<p class="hir-cim">Tavaszi Napéjegyenlőség</p>
<p class="hir-szoveg"><img src="{{ asset('upload/images/napejegyenloseg.jpg') }}" alt="" /></p>
<p class="hir-szerzo">Lakshmí</p>
<p class="hir-datum">2012. február 28. 23:27</p>
</div>
<div class="hir">
<p class="hir-cim">Valentin...</p>
<p class="hir-szoveg">Boldog Valentin napot nem csak a pároknak...<br /><img src="{{ asset('upload/images/valentin_rozsa.jpg') }}" alt="" /></p>
<p class="hir-szerzo">Lakshmí</p>
<p class="hir-datum">2012. február 13. 20:41</p>
</div> </div>
{% endfor %}
</div> </div>
</div> </div>
</div> </div>

View File

@ -0,0 +1,243 @@
<?php
namespace KekRozsak\FrontBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* KekRozsak\FrontBundle\Entity\News
*/
class News
{
/**
* @var integer $id
*/
private $id;
/**
* @var datetime $created_at
*/
private $created_at;
/**
* @var datetime $updated_at
*/
private $updated_at;
/**
* @var text $update_reason
*/
private $update_reason;
/**
* @var string $title
*/
private $title;
/**
* @var string $slug
*/
private $slug;
/**
* @var text $text
*/
private $text;
/**
* @var KekRozsak\FrontBundle\Entity\User
*/
private $created_by;
/**
* @var KekRozsak\FrontBundle\Entity\User
*/
private $updated_by;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set created_at
*
* @param datetime $createdAt
* @return News
*/
public function setCreatedAt($createdAt)
{
$this->created_at = $createdAt;
return $this;
}
/**
* Get created_at
*
* @return datetime
*/
public function getCreatedAt()
{
return $this->created_at;
}
/**
* Set updated_at
*
* @param datetime $updatedAt
* @return News
*/
public function setUpdatedAt($updatedAt)
{
$this->updated_at = $updatedAt;
return $this;
}
/**
* Get updated_at
*
* @return datetime
*/
public function getUpdatedAt()
{
return $this->updated_at;
}
/**
* Set update_reason
*
* @param text $updateReason
* @return News
*/
public function setUpdateReason($updateReason)
{
$this->update_reason = $updateReason;
return $this;
}
/**
* Get update_reason
*
* @return text
*/
public function getUpdateReason()
{
return $this->update_reason;
}
/**
* Set title
*
* @param string $title
* @return News
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set slug
*
* @param string $slug
* @return News
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set text
*
* @param text $text
* @return News
*/
public function setText($text)
{
$this->text = $text;
return $this;
}
/**
* Get text
*
* @return text
*/
public function getText()
{
return $this->text;
}
/**
* Set created_by
*
* @param KekRozsak\FrontBundle\Entity\User $createdBy
* @return News
*/
public function setCreatedBy(\KekRozsak\FrontBundle\Entity\User $createdBy = null)
{
$this->created_by = $createdBy;
return $this;
}
/**
* Get created_by
*
* @return KekRozsak\FrontBundle\Entity\User
*/
public function getCreatedBy()
{
return $this->created_by;
}
/**
* Set updated_by
*
* @param KekRozsak\FrontBundle\Entity\User $updatedBy
* @return News
*/
public function setUpdatedBy(\KekRozsak\FrontBundle\Entity\User $updatedBy = null)
{
$this->updated_by = $updatedBy;
return $this;
}
/**
* Get updated_by
*
* @return KekRozsak\FrontBundle\Entity\User
*/
public function getUpdatedBy()
{
return $this->updated_by;
}
}

View File

@ -0,0 +1,39 @@
KekRozsak\FrontBundle\Entity\News:
type: entity
table: news
id:
id:
type: integer
generator:
strategy: AUTO
fields:
created_at:
type: datetime
nullable: false
updated_at:
type: datetime
nullable: true
default: null
update_reason:
type: text
nullable: true
default: null
title:
type: string(100)
nullable: false
slug:
type: string(100)
nullable: false
unique: true
text:
type: text
nullable: false
manyToOne:
created_by:
targetEntity: User
nullable: false
inversedBy: news
updated_by:
targetEntity: User
nullable: true
default: null

View File

@ -5,3 +5,9 @@ services:
# kek_rozsak_front.example: # kek_rozsak_front.example:
# class: %kek_rozsak_front.example.class% # class: %kek_rozsak_front.example.class%
# arguments: [@service_id, "plain_value", %parameter%] # arguments: [@service_id, "plain_value", %parameter%]
kek_rozsak_front.twig_extension.news:
class: KekRozsak\FrontBundle\Twig\NewsExtension
arguments:
doctrine: @doctrine
tags:
- { name: twig.extension }

View File

@ -0,0 +1,31 @@
<?php
namespace KekRozsak\FrontBundle\Twig;
use Symfony\Bridge\Doctrine\RegistryInterface;
class NewsExtension extends \Twig_Extension
{
protected $doctrine;
public function __construct(RegistryInterface $doctrine)
{
$this->doctrine = $doctrine;
}
public function getGlobals()
{
$newsRepo = $this->doctrine->getRepository('KekRozsakFrontBundle:News');
$news = $newsRepo->findBy(array(), array('created_at' => 'DESC'), 4);
return array(
'recentNews' => $news,
);
}
public function getName()
{
return 'News';
}
}