Added very basic forum functionality

This commit is contained in:
Polonkai Gergely 2012-07-03 14:56:28 +02:00
parent 0649408e60
commit 1af3a30c2a
10 changed files with 379 additions and 5 deletions

View File

@ -0,0 +1,216 @@
<?php
namespace KekRozsak\FrontBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* KekRozsak\FrontBundle\Entity\ForumPost
*/
class ForumPost
{
/**
* @var integer $id
*/
private $id;
/**
* @var datetime $created_at
*/
private $created_at;
/**
* @var datetime $updated_at
*/
private $updated_at;
/**
* @var string $update_reason
*/
private $update_reason;
/**
* @var text $text
*/
private $text;
/**
* @var KekRozsak\FrontBundle\Entity\User
*/
private $created_by;
/**
* @var KekRozsak\FrontBundle\Entity\User
*/
private $updated_by;
/**
* @var KekRozsak\FrontBundle\Entity\ForumTopic
*/
private $topic;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set created_at
*
* @param datetime $createdAt
* @return ForumPost
*/
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 ForumPost
*/
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 string $updateReason
* @return ForumPost
*/
public function setUpdateReason($updateReason)
{
$this->update_reason = $updateReason;
return $this;
}
/**
* Get update_reason
*
* @return string
*/
public function getUpdateReason()
{
return $this->update_reason;
}
/**
* Set text
*
* @param text $text
* @return ForumPost
*/
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 ForumPost
*/
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 ForumPost
*/
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;
}
/**
* Set topic
*
* @param KekRozsak\FrontBundle\Entity\ForumTopic $topic
* @return ForumPost
*/
public function setTopic(\KekRozsak\FrontBundle\Entity\ForumTopic $topic = null)
{
$this->topic = $topic;
return $this;
}
/**
* Get topic
*
* @return KekRozsak\FrontBundle\Entity\ForumTopic
*/
public function getTopic()
{
return $this->topic;
}
}

View File

@ -240,4 +240,35 @@ class ForumTopic
{ {
return $this->topic_group; return $this->topic_group;
} }
/**
* @var \Doctrine\Common\Collections\ArrayCollection
*/
private $posts;
public function __construct()
{
$this->posts = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add posts
*
* @param KekRozsak\FrontBundle\Entity\ForumPost $posts
* @return ForumTopic
*/
public function addForumPost(\KekRozsak\FrontBundle\Entity\ForumPost $posts)
{
$this->posts[] = $posts;
return $this;
}
/**
* Get posts
*
* @return Doctrine\Common\Collections\Collection
*/
public function getPosts()
{
return $this->posts;
}
} }

View File

@ -200,4 +200,58 @@ class User implements UserInterface
{ {
return $this->password; return $this->password;
} }
/**
* @var \Doctrine\Common\Collections\ArrayCollection
*/
private $articles;
/**
* @var \Doctrine\Common\Collections\ArrayCollection
*/
private $forum_posts;
/**
* Add articles
*
* @param KekRozsak\FrontBundle\Entity\Article $articles
* @return User
*/
public function addArticle(\KekRozsak\FrontBundle\Entity\Article $articles)
{
$this->articles[] = $articles;
return $this;
}
/**
* Get articles
*
* @return Doctrine\Common\Collections\Collection
*/
public function getArticles()
{
return $this->articles;
}
/**
* Add forum_posts
*
* @param KekRozsak\FrontBundle\Entity\ForumPost $forumPosts
* @return User
*/
public function addForumPost(\KekRozsak\FrontBundle\Entity\ForumPost $forumPosts)
{
$this->forum_posts[] = $forumPosts;
return $this;
}
/**
* Get forum_posts
*
* @return Doctrine\Common\Collections\Collection
*/
public function getForumPosts()
{
return $this->forum_posts;
}
} }

View File

@ -0,0 +1,33 @@
KekRozsak\FrontBundle\Entity\ForumPost:
type: entity
table: forum_posts
id:
id:
type: integer
generator:
strategy: AUTO
fields:
created_at:
type: datetime
nullable: false
updated_at:
type: datetime
nullable: true
update_reason:
type: string
nullable: true
text:
type: text
nullable: false
manyToOne:
created_by:
targetEntity: User
inversedBy: forum_posts
nullable: false
updated_by:
targetEntity: User
nullable: true
default: null
topic:
targetEntity: ForumTopic
inversedBy: posts

View File

@ -23,6 +23,10 @@ KekRozsak\FrontBundle\Entity\ForumTopic:
update_reason: update_reason:
type: text type: text
nullable: true nullable: true
oneToMany:
posts:
targetEntity: ForumPost
mappedBy: topic
manyToOne: manyToOne:
created_by: created_by:
targetEntity: User targetEntity: User

View File

@ -21,6 +21,15 @@ KekRozsak\FrontBundle\Entity\User:
display_name: display_name:
type: string(50) type: string(50)
nullable: false nullable: false
oneToMany:
articles:
targetEntity: Article
mappedBy: created_by
fetch: EXTRA_LAZY
forum_posts:
targetEntity: ForumPost
mappedBy: created_by
fetch: EXTRA_LAZY
manyToMany: manyToMany:
roles: roles:
targetEntity: Role targetEntity: Role

View File

@ -1,5 +1,26 @@
{% extends '::main_template.html.twig' %} {% extends '::main_template.html.twig' %}
{% block title %} - Fórum - {{ topicGroup.title }} - {{ topic.title }}{% endblock %} {% block title %} - Fórum - {{ topicGroup.title }} - {{ topic.title }}{% endblock %}
{% block content %} {% block content %}
<h3>Fórum - {{ topicGroup.title }} - {{ topic.title }}</h3> <h3><a href="{{ path('KekRozsakFrontBundle_forum_main') }}">Fórum</a> - <a href="{{ path('KekRozsakFrontBundle_forum_topic_list', { topicGroupSlug: topicGroup.slug }) }}">{{ topicGroup.title }}</a> - {{ topic.title }}</h3>
{% if topic.posts|length > 0 %}
<table>
<thead>
</thead>
<tbody>
{% for post in topic.posts %}
<tr>
<td>
{{ post.createdBy.displayName }}<br />
{{ post.createdAt|date('Y-m-d H:i') }}<br />
Admin<br />
Tagság kezdete: {{ post.createdBy.RegisteredAt|date('Y-m-d') }}
</td>
<td>{{ post.text }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
A témában még nincsenek hozzászólások.
{% endif %}
{% endblock %} {% endblock %}

View File

@ -6,21 +6,26 @@
<table id="temakor-lista"> <table id="temakor-lista">
<thead> <thead>
<tr> <tr>
<td><a href="{{ path('KekRozsakFrontBundle_forum_topic_list', {topicGroupSlug: topicGroup.slug}) }}">{{ topicGroup.title }}</a></td> <td colspan="2"><a href="{{ path('KekRozsakFrontBundle_forum_topic_list', {topicGroupSlug: topicGroup.slug}) }}">{{ topicGroup.title }}</a></td>
<td></td> <td>Témák száma</td>
<td>Hozzászólások száma</td>
<td>Utolsó hozzászólás</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% if topicGroup.topics|length > 0 %} {% if topicGroup.topics|length > 0 %}
{% for topic in topicGroup.topics %} {% for topic in topicGroup.topics %}
<tr> <tr>
<td>[]</td>
<td><a href="{{ path('KekRozsakFrontBundle_forum_post_list', {topicGroupSlug: topicGroup.slug, topicSlug: topic.slug}) }}">{{ topic.title }}</a></td> <td><a href="{{ path('KekRozsakFrontBundle_forum_post_list', {topicGroupSlug: topicGroup.slug, topicSlug: topic.slug}) }}">{{ topic.title }}</a></td>
<td></td> <td></td>
<td></td>
<td></td>
</tr> </tr>
{% endfor %} {% endfor %}
{% else %} {% else %}
<tr> <tr>
<td colspan="2">Ebben a kategóriában nincsenek témák</td> <td colspan="4">Ebben a kategóriában nincsenek témák</td>
</tr> </tr>
{% endif %} {% endif %}
</tbody> </tbody>

View File

@ -1,7 +1,7 @@
{% extends '::main_template.html.twig' %} {% extends '::main_template.html.twig' %}
{% block title %} - Fórum - {{ topicGroup.title }}{% endblock %} {% block title %} - Fórum - {{ topicGroup.title }}{% endblock %}
{% block content %} {% block content %}
<h3>Fórum - {{ topicGroup.title }}</h3> <h3><a href="{{ path('KekRozsakFrontBundle_forum_main') }}">Fórum</a> - {{ topicGroup.title }}</h3>
{% if topicGroup.topics|length > 0 %} {% if topicGroup.topics|length > 0 %}
<table> <table>
<thead> <thead>

View File

@ -1,5 +1,6 @@
* { * {
font-family: sans-serif; font-family: sans-serif;
font-size: 14px;
} }
body { body {