Added very-very basic forum functionality

This commit is contained in:
Polonkai Gergely 2012-07-03 14:11:18 +02:00
parent ffda918ee5
commit 0649408e60
14 changed files with 727 additions and 31 deletions

24
TODO
View File

@ -9,17 +9,7 @@ UserData
google talk address
google talk address public?
Permissions
id
name
description
Roles
id
name
permission list
Hírek
News
id
title
slug
@ -36,20 +26,8 @@ BlogPost
text
poster
ForumTopicGroup
id
title
slug
creator
timestamp
ForumTopic
id
title
slug
creator
roles who can access it
topic group
ForumPost
id

View File

@ -26,9 +26,4 @@ class DefaultController extends Controller
'article' => $article
));
}
public function forumMainAction()
{
return $this->forward('KekRozsakFrontBundle:Default:homepage');
}
}

View File

@ -0,0 +1,46 @@
<?php
namespace KekRozsak\FrontBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class ForumController extends Controller
{
public function mainAction()
{
// TODO: Protect this controller with roles? It is also defined in security.yml
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumTopicGroup');
$topicGroups = $groupRepo->findAll();
return $this->render('KekRozsakFrontBundle:Forum:topic_group_list.html.twig', array(
'topicGroups' => $topicGroups,
));
}
public function topicListAction($topicGroupSlug)
{
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumTopicGroup');
if (!($topicGroup = $groupRepo->findOneBySlug($topicGroupSlug)))
throw $this->createNotFoundException('A kért témakör nem létezik!');
return $this->render('KekRozsakFrontBundle:Forum:topic_list.html.twig', array(
'topicGroup' => $topicGroup,
));
}
public function postListAction($topicGroupSlug, $topicSlug)
{
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumTopicGroup');
if (!($topicGroup = $groupRepo->findOneBySlug($topicGroupSlug)))
throw $this->createNotFoundException('A kért témakör nem létezik!');
$topicRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumTopic');
if (!($topic = $topicRepo->findOneBy(array('topic_group' => $topicGroup, 'slug' => $topicSlug))))
throw $this->createNotFoundException('A kért téma nem létezik!');
return $this->render('KekRozsakFrontBundle:Forum:post_list.html.twig', array(
'topicGroup' => $topicGroup,
'topic' => $topic,
));
}
}

View File

@ -0,0 +1,243 @@
<?php
namespace KekRozsak\FrontBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* KekRozsak\FrontBundle\Entity\ForumTopic
*/
class ForumTopic
{
/**
* @var integer $id
*/
private $id;
/**
* @var string $title
*/
private $title;
/**
* @var string $slug
*/
private $slug;
/**
* @var datetime $created_at
*/
private $created_at;
/**
* @var datetime $updated_at
*/
private $updated_at;
/**
* @var text $update_reason
*/
private $update_reason;
/**
* @var KekRozsak\FrontBundle\Entity\User
*/
private $created_by;
/**
* @var KekRozsak\FrontBundle\Entity\User
*/
private $updated_by;
/**
* @var KekRozsak\FrontBundle\Entity\ForumTopicGroup
*/
private $topic_group;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set title
*
* @param string $title
* @return ForumTopic
*/
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 ForumTopic
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set created_at
*
* @param datetime $createdAt
* @return ForumTopic
*/
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 ForumTopic
*/
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 ForumTopic
*/
public function setUpdateReason($updateReason)
{
$this->update_reason = $updateReason;
return $this;
}
/**
* Get update_reason
*
* @return text
*/
public function getUpdateReason()
{
return $this->update_reason;
}
/**
* Set created_by
*
* @param KekRozsak\FrontBundle\Entity\User $createdBy
* @return ForumTopic
*/
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 ForumTopic
*/
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_group
*
* @param KekRozsak\FrontBundle\Entity\ForumTopicGroup $topicGroup
* @return ForumTopic
*/
public function setTopicGroup(\KekRozsak\FrontBundle\Entity\ForumTopicGroup $topicGroup = null)
{
$this->topic_group = $topicGroup;
return $this;
}
/**
* Get topic_group
*
* @return KekRozsak\FrontBundle\Entity\ForumTopicGroup
*/
public function getTopicGroup()
{
return $this->topic_group;
}
}

View File

@ -0,0 +1,262 @@
<?php
namespace KekRozsak\FrontBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* KekRozsak\FrontBundle\Entity\ForumTopicGroup
*/
class ForumTopicGroup
{
/**
* @var integer $id
*/
private $id;
/**
* @var string $title
*/
private $title;
/**
* @var string $slug
*/
private $slug;
/**
* @var datetime $created_at
*/
private $created_at;
/**
* @var datetime $updated_at
*/
private $updated_at;
/**
* @var text $update_reason
*/
private $update_reason;
/**
* @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 title
*
* @param string $title
* @return ForumTopicGroup
*/
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 ForumTopicGroup
*/
public function setSlug($slug)
{
$this->slug = $slug;
return $this;
}
/**
* Get slug
*
* @return string
*/
public function getSlug()
{
return $this->slug;
}
/**
* Set created_at
*
* @param datetime $createdAt
* @return ForumTopicGroup
*/
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 ForumTopicGroup
*/
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 ForumTopicGroup
*/
public function setUpdateReason($updateReason)
{
$this->update_reason = $updateReason;
return $this;
}
/**
* Get update_reason
*
* @return text
*/
public function getUpdateReason()
{
return $this->update_reason;
}
/**
* Set created_by
*
* @param KekRozsak\FrontBundle\Entity\User $createdBy
* @return ForumTopicGroup
*/
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 ForumTopicGroup
*/
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;
}
/**
* @var \Doctrine\Common\Collections\ArrayCollection
*/
private $topic;
public function __construct()
{
$this->topic = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add topic
*
* @param KekRozsak\FrontBundle\Entity\ForumTopic $topic
* @return ForumTopicGroup
*/
public function addForumTopic(\KekRozsak\FrontBundle\Entity\ForumTopic $topic)
{
$this->topic[] = $topic;
return $this;
}
/**
* Get topic
*
* @return Doctrine\Common\Collections\Collection
*/
public function getTopic()
{
return $this->topic;
}
/**
* @var \Doctrine\Common\Collections\ArrayCollection
*/
private $topics;
/**
* Get topics
*
* @return Doctrine\Common\Collections\Collection
*/
public function getTopics()
{
return $this->topics;
}
}

View File

@ -0,0 +1,41 @@
KekRozsak\FrontBundle\Entity\ForumTopic:
type: entity
table: forum_topics
id:
id:
type: integer
generator:
strategy: AUTO
fields:
title:
type: string(100)
nullable: false
slug:
type: string(100)
nullable: false
unique: true
created_at:
type: datetime
nullable: false
updated_at:
type: datetime
nullable: true
update_reason:
type: text
nullable: true
manyToOne:
created_by:
targetEntity: User
inversedBy: articles
nullable: false
updated_by:
targetEntity: User
nullable: true
default: null
topic_group:
targetEntity: ForumTopicGroup
inversedBy: topics
nullable: false
uniqueConstraint:
uniqueSlugByGroup:
columns: [ topic_group, slug ]

View File

@ -0,0 +1,38 @@
KekRozsak\FrontBundle\Entity\ForumTopicGroup:
type: entity
table: forum_topic_groups
id:
id:
type: integer
generator:
strategy: AUTO
fields:
title:
type: string(100)
nullable: false
slug:
type: string(100)
nullable: false
unique: true
created_at:
type: datetime
nullable: false
updated_at:
type: datetime
nullable: true
update_reason:
type: text
nullable: true
manyToOne:
created_by:
targetEntity: User
inversedBy: articles
nullable: false
updated_by:
targetEntity: User
nullable: true
default: null
oneToMany:
topics:
targetEntity: ForumTopic
mappedBy: topic_group

View File

@ -11,4 +11,14 @@ KekRozsakFrontBundle_article:
KekRozsakFrontBundle_forum_main:
pattern: /forum
defaults:
_controller: KekRozsakFrontBundle:Default:forumMain
_controller: KekRozsakFrontBundle:Forum:main
KekRozsakFrontBundle_forum_topic_list:
pattern: /forum/{topicGroupSlug}
defaults:
_controller: KekRozsakFrontBundle:Forum:topicList
KekRozsakFrontBundle_forum_post_list:
pattern: /forum/{topicGroupSlug}/{topicSlug}
defaults:
_controller: KekRozsakFrontBundle:Forum:postList

View File

@ -0,0 +1,5 @@
{% extends '::main_template.html.twig' %}
{% block title %} - Fórum - {{ topicGroup.title }} - {{ topic.title }}{% endblock %}
{% block content %}
<h3>Fórum - {{ topicGroup.title }} - {{ topic.title }}</h3>
{% endblock %}

View File

@ -0,0 +1,29 @@
{% extends '::main_template.html.twig' %}
{% block title %} - Fórum{% endblock %}
{% block content %}
<h3>Fórum</h3>
{% for topicGroup in topicGroups %}
<table id="temakor-lista">
<thead>
<tr>
<td><a href="{{ path('KekRozsakFrontBundle_forum_topic_list', {topicGroupSlug: topicGroup.slug}) }}">{{ topicGroup.title }}</a></td>
<td></td>
</tr>
</thead>
<tbody>
{% if topicGroup.topics|length > 0 %}
{% for topic in topicGroup.topics %}
<tr>
<td><a href="{{ path('KekRozsakFrontBundle_forum_post_list', {topicGroupSlug: topicGroup.slug, topicSlug: topic.slug}) }}">{{ topic.title }}</a></td>
<td></td>
</tr>
{% endfor %}
{% else %}
<tr>
<td colspan="2">Ebben a kategóriában nincsenek témák</td>
</tr>
{% endif %}
</tbody>
</table>
{% endfor %}
{% endblock content %}

View File

@ -0,0 +1,20 @@
{% extends '::main_template.html.twig' %}
{% block title %} - Fórum - {{ topicGroup.title }}{% endblock %}
{% block content %}
<h3>Fórum - {{ topicGroup.title }}</h3>
{% if topicGroup.topics|length > 0 %}
<table>
<thead>
</thead>
<tbody>
{% for topic in topicGroup.topics %}
<tr>
<td><a href="{{ path('KekRozsakFrontBundle_forum_post_list', { topicGroupSlug: topicGroup.slug, topicSlug: topic.slug }) }}">{{ topic.title }}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
Ebben a témakörben nincsenek témák.
{% endif %}
{% endblock content %}

View File

@ -109,3 +109,32 @@ p.hir-datum {
margin: 0;
}
#temakor-lista {
border: 1px solid #3366ff;
border-collapse: collapse;
width: 100%;
margin-bottom: 10px;
}
#temakor-lista thead td {
font-weight: bold;
height: 1.5em;
border-bottom: 2px solid #3366ff;
padding: 3px;
}
#temakor-lista thead td a {
color: #3366ff;
text-decoration: none;
}
#temakor-lista tbody td {
padding: 3px;
border-bottom: 1px solid #3366ff;
}
#temakor-lista tbody td a {
color: #3366ff;
text-decoration: underline;
}