<commit_before><?php

namespace BeTeen\ForumBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use BeTeen\ForumBundle\Entity\Categorie;
use BeTeen\ForumBundle\Entity\SujetStandard;
use BeTeen\ForumBundle\Form\SujetStandardType;
use BeTeen\ForumBundle\Entity\ReponseStandard;
use BeTeen\ForumBundle\Form\ReponseStandardType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;

class ForumController extends Controller
{
    public function categorieAction($categorie)
    {
        $manager = $this->getDoctrine()->getManager();
	$repository = $manager->getRepository("BeTeenForumBundle:Categorie");
        
        $position = $repository->findOneBy(array("slug"=>$categorie));
        
        if($position == null)
        {
            throw $this->createNotFoundException('Catégorie non trouvée');
        }
        
	$categories = $repository->children($position,true);
        
        return $this->render('BeTeenForumBundle:Forum:categorie.html.twig',array("listeCategories"=>$categories,"categorieActuelle"=>$position));
    }
	
    public function sujetAction($categorie,$sujet)
    {
        $manager = $this->getDoctrine()->getManager();
	$repository = $manager->getRepository("BeTeenForumBundle:SujetStandard");
	$sujet = $repository->findOneSubjectSlug($sujet);
        
        $reponse = new ReponseStandard();
        $reponse->setSujet($sujet);
        $form = $this->createForm(new ReponseStandardType, $reponse);
        
        if($sujet == null)
        {
            throw $this->createNotFoundException('Sujet non trouvé');
        }
	return $this->render('BeTeenForumBundle:Forum:Sujet.html.twig',array("sujet"=>$sujet,"form"=>$form->createView()));
    }
    
  /**
   * @Security("has_role('ROLE_USER')")
   */
    public function ajouterSujetAction($categorie)
    {
        $manager = $this->getDoctrine()->getManager();
	$repository = $manager->getRepository("BeTeenForumBundle:Categorie");
        
        $sujet = new SujetStandard();
        $position = $repository->findOneBySlug($categorie);
        if($position->getAllowSujetStandard())
        {
            $sujet->setCategorie($position);
            $sujet->setAuteur($this->get('security.context')->getToken()->getUser());
            $form = $this->createForm(new SujetStandardType, $sujet);<commit_msg>Resolution du bug d'affichage des sujets<commit_after><?php

namespace BeTeen\ForumBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use BeTeen\ForumBundle\Entity\Categorie;
use BeTeen\ForumBundle\Entity\SujetStandard;
use BeTeen\ForumBundle\Form\SujetStandardType;
use BeTeen\ForumBundle\Entity\ReponseStandard;
use BeTeen\ForumBundle\Form\ReponseStandardType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;

class ForumController extends Controller
{
    public function categorieAction($categorie)
    {
        $manager = $this->getDoctrine()->getManager();
	$repository = $manager->getRepository("BeTeenForumBundle:Categorie");
        
        $position = $repository->findOneBy(array("slug"=>$categorie));
        
        if($position == null)
        {
            throw $this->createNotFoundException('Catégorie non trouvée');
        }
        
	$categories = $repository->children($position,true);
        
        return $this->render('BeTeenForumBundle:Forum:categorie.html.twig',array("listeCategories"=>$categories,"categorieActuelle"=>$position));
    }
	
    public function sujetAction($categorie,$sujet)
    {
        $manager = $this->getDoctrine()->getManager();
	$repository = $manager->getRepository("BeTeenForumBundle:SujetStandard");
	$sujet = $repository->findOneSubjectSlug($sujet);
        
        $reponse = new ReponseStandard();
        $reponse->setSujet($sujet);
        $form = $this->createForm(new ReponseStandardType, $reponse);
        
        if($sujet == null)
        {
            throw $this->createNotFoundException('Sujet non trouvé');
        }
	return $this->render('BeTeenForumBundle:Forum:sujet.html.twig',array("sujet"=>$sujet,"form"=>$form->createView()));
    }
    
  /**
   * @Security("has_role('ROLE_USER')")
   */
    public function ajouterSujetAction($categorie)
    {
        $manager = $this->getDoctrine()->getManager();
	$repository = $manager->getRepository("BeTeenForumBundle:Categorie");
        
        $sujet = new SujetStandard();
        $position = $repository->findOneBySlug($categorie);
        if($position->getAllowSujetStandard())
        {
            $sujet->setCategorie($position);
            $sujet->setAuteur($this->get('security.context')->getToken()->getUser());
            $form = $this->createForm(new SujetStandardType, $sujet);
{'fraction_non_alphanumeric': 0.14565171167339996, 'fraction_numerical': 0.0, 'mean_word_length': 3.7134268537074147, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6435312', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1429, 'n_words': 174}