svg
This commit is contained in:
@ -67,6 +67,7 @@ class CategoryController extends AbstractController
|
||||
$data->setAppthumbfilteropacity(100);
|
||||
$data->setAppthumbfiltersepia(0);
|
||||
|
||||
// Permissions
|
||||
if(!$this->getUser()->hasRole("ROLE_ADMIN")&&($by=="admin"||$by=="update")) {
|
||||
return $this->redirectToRoute("app_home");
|
||||
}
|
||||
@ -104,7 +105,7 @@ class CategoryController extends AbstractController
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
'usesidebar' => ($by=="admin" || $by=="update"),
|
||||
$this->data => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView(),
|
||||
@ -130,7 +131,7 @@ class CategoryController extends AbstractController
|
||||
}
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update","by"=>$by,"user"=>$this->getUser()));
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update","by"=>$by,"user"=>$em->getRepository("App:User")->find($data->getUser()->getId())));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
@ -157,7 +158,7 @@ class CategoryController extends AbstractController
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => true,
|
||||
'usesidebar' => ($by=="admin" || $by=="update"),
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView(),
|
||||
|
@ -16,7 +16,7 @@ class HomeController extends AbstractController
|
||||
$users = $em->getRepository("App:User")->findBy([],["pseudo"=>"ASC"]);
|
||||
$illustrations = $em->getRepository("App:Illustration")->findBy([],["submittime"=>"DESC"]);
|
||||
$links = $em->getRepository("App:Link")->findBy(["user"=>null]);
|
||||
$webzines = $em->getRepository("App:Webzine")->findBy(["user"=>null], ['set' => 'ASC', 'order' => 'ASC']);
|
||||
$webzines = $em->getRepository("App:Webzine")->findBy([],["submittime"=>"DESC"]);
|
||||
|
||||
return $this->render('Home/home.html.twig',[
|
||||
"useheader" => false,
|
||||
|
@ -98,7 +98,7 @@ class IllustrationController extends AbstractController
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => false,
|
||||
'usesidebar' => ($by=="admin" || $by=="update"),
|
||||
$this->data => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView(),
|
||||
@ -152,7 +152,7 @@ class IllustrationController extends AbstractController
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => false,
|
||||
'usesidebar' => ($by=="admin" || $by=="update"),
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView(),
|
||||
|
@ -14,56 +14,64 @@ use App\Entity\Webzinepage as Webzinepage;
|
||||
class WebzineController extends AbstractController
|
||||
{
|
||||
private $data = "webzine";
|
||||
private $route = "app_webzine";
|
||||
private $route = "app_admin_webzine";
|
||||
private $render = "Webzine/";
|
||||
private $entity = "App:Webzine";
|
||||
|
||||
public function list(Request $request)
|
||||
public function list($by,$userid)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$datas = $em->getRepository($this->entity)->findAll();
|
||||
if($by=="admin") {
|
||||
$datas = $em->getRepository($this->entity)->findAll();
|
||||
|
||||
return $this->render($this->render.'list.html.twig',[
|
||||
return $this->render($this->render.'list.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
]);
|
||||
}
|
||||
else {
|
||||
$datas = $em->getRepository($this->entity)->findBy(["user"=>$em->getRepository("App:User")->find($userid)]);
|
||||
|
||||
return $this->render($this->render.'listrender.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"by" => $by,
|
||||
"userid" => $userid,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function listuser()
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$datas = $em->getRepository($this->entity)->findByUser($this->getUser());
|
||||
|
||||
return $this->render($this->render.'listrender.html.twig',[
|
||||
$this->data."s" => $datas,
|
||||
"useheader" => true,
|
||||
"usesidebar" => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function view($idcat,$id,Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$webzine=$em->getRepository($this->entity)->find($idcat);
|
||||
$page=$em->getRepository("App:Webzinepage")->find($id);
|
||||
$sets=$em->getRepository($this->entity)->findBy(["set"=>$webzine->getSet()],["order"=>"ASC"]);
|
||||
|
||||
$datanext=$this->getDataAllNext($idcat,$id,$webzine);
|
||||
$dataprev=$this->getDataAllPrev($idcat,$id,$webzine);
|
||||
|
||||
$pathinfo=pathinfo($page->getIllustration());
|
||||
|
||||
if(!$page) return $this->redirectToRoute('app_home');
|
||||
|
||||
return $this->render($this->render.'view.html.twig', array(
|
||||
$this->data => $webzine,
|
||||
"page" => $page,
|
||||
"sets" => $sets,
|
||||
"prev" => $dataprev,
|
||||
"next" => $datanext,
|
||||
"pathinfo" => $pathinfo,
|
||||
"usemonocolor" => true,
|
||||
));
|
||||
"by" => "profil",
|
||||
"userid" => $this->getUser()->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function submit($by, Request $request)
|
||||
public function submit($by, $userid, Request $request)
|
||||
{
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data = new Entity();
|
||||
|
||||
// Permissions
|
||||
if(!$this->getUser()->hasRole("ROLE_ADMIN")&&($by=="admin"||$by=="update")) {
|
||||
return $this->redirectToRoute("app_home");
|
||||
}
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"submit"));
|
||||
if($by=="admin"||$by=="update") {
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"submit","by"=>$by,"user"=>$em->getRepository("App:User")->find($userid)));
|
||||
} else {
|
||||
$userid=$this->getUser()->getId();
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"submit","by"=>$by,"user"=>$this->getUser()));
|
||||
}
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
@ -98,23 +106,31 @@ class WebzineController extends AbstractController
|
||||
|
||||
$em->persist($page);
|
||||
$em->flush();
|
||||
if($order==1) $firstpage=$page;
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
// Retour à la liste
|
||||
if($by=="console")
|
||||
return $this->redirectToRoute($this->route);
|
||||
if($by=="admin")
|
||||
return $this->redirectToRoute($this->route,["by"=>$by,"userid"=>-1]);
|
||||
elseif($by=="update")
|
||||
return $this->redirectToRoute("app_user_update",["id"=>$data->getUser()->getId()]);
|
||||
elseif($by=="profil")
|
||||
return $this->redirectToRoute("app_user_profil");
|
||||
else
|
||||
return $this->redirectToRoute("app_home");
|
||||
{
|
||||
return $this->redirectToRoute("app_webzine_view",["by"=>"user","idcat"=>$data->getId(),"id"=>$page->getId()]);
|
||||
}
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => false,
|
||||
'usesidebar' => ($by=="admin" || $by=="update"),
|
||||
$this->data => $data,
|
||||
'mode' => 'submit',
|
||||
'form' => $form->createView(),
|
||||
'by' => $by,
|
||||
'userid' => $userid,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -123,13 +139,24 @@ class WebzineController extends AbstractController
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
if(!$data) return $this->redirectToRoute("app_home");
|
||||
|
||||
// Permission
|
||||
if(!$this->getUser()->hasRole("ROLE_ADMIN")&&($by=="admin"||$by=="update")) {
|
||||
return $this->redirectToRoute("app_home");
|
||||
}
|
||||
if($by!="admin"&&$by!="update") {
|
||||
if($this->getUser()!=$data->getUser()&&!$this->getUser()->hasRole("ROLE_ADMIN"))
|
||||
return $this->redirectToRoute("app_home");
|
||||
}
|
||||
|
||||
$oldlstpages = array();
|
||||
foreach($data->getWebzinepages() as $page){
|
||||
$oldlstpages[] = $page->getIllustration();
|
||||
}
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update"));
|
||||
$form = $this->createForm(Form::class,$data,array("mode"=>"update","by"=>$by,"user"=>$em->getRepository("App:User")->find($data->getUser()->getId())));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
$form->handleRequest($request);
|
||||
@ -184,21 +211,26 @@ class WebzineController extends AbstractController
|
||||
$em->flush();
|
||||
|
||||
|
||||
// Retour à l'webzine
|
||||
if($by=="console")
|
||||
return $this->redirectToRoute($this->route);
|
||||
else
|
||||
return $this->redirectToRoute($this->route.'_view',array("idcat"=>$data->getId(),"id"=> $data->getWebzinepages()[0]->getId()));
|
||||
// Retour à la liste
|
||||
if($by=="admin")
|
||||
return $this->redirectToRoute($this->route,["by"=>$by,"userid"=>-1]);
|
||||
elseif($by=="update")
|
||||
return $this->redirectToRoute("app_user_update",["id"=>$data->getUser()->getId()]);
|
||||
elseif($by=="profil")
|
||||
return $this->redirectToRoute("app_user_profil");
|
||||
elseif($by=="illustration")
|
||||
return $this->redirectToRoute("app_webzine_view",["by"=>"user","idcat"=>$data->getId(),"id"=>$data->getWebzinepages()[0]->getId()]);
|
||||
}
|
||||
|
||||
// Affichage du formulaire
|
||||
return $this->render($this->render.'edit.html.twig', [
|
||||
'useheader' => true,
|
||||
'usesidebar' => false,
|
||||
'usesidebar' => ($by=="admin" || $by=="update"),
|
||||
$this->data => $data,
|
||||
'mode' => 'update',
|
||||
'form' => $form->createView(),
|
||||
'by' => $by,
|
||||
'userid' => $data->getUser()->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -207,6 +239,16 @@ class WebzineController extends AbstractController
|
||||
// Initialisation de l'enregistrement
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$data=$em->getRepository($this->entity)->find($id);
|
||||
if(!$data) return $this->redirectToRoute("app_home");
|
||||
|
||||
// Permission
|
||||
if(!$this->getUser()->hasRole("ROLE_ADMIN")&&($by=="admin"||$by=="update")) {
|
||||
return $this->redirectToRoute("app_home");
|
||||
}
|
||||
if($by!="admin"&&$by!="update") {
|
||||
if($this->getUser()!=$data->getUser()&&!$this->getUser()->hasRole("ROLE_ADMIN"))
|
||||
return $this->redirectToRoute("app_home");
|
||||
}
|
||||
|
||||
// Controle avant suppression
|
||||
$error=false;
|
||||
@ -219,10 +261,14 @@ class WebzineController extends AbstractController
|
||||
$em->flush();
|
||||
|
||||
// Retour à la liste
|
||||
if($by=="console")
|
||||
return $this->redirectToRoute($this->route);
|
||||
else
|
||||
return $this->redirectToRoute("app_home");
|
||||
if($by=="admin")
|
||||
return $this->redirectToRoute($this->route,["by"=>$by,"userid"=>-1]);
|
||||
elseif($by=="update")
|
||||
return $this->redirectToRoute("app_user_update",["id"=>$data->getUser()->getId()]);
|
||||
elseif($by=="profil")
|
||||
return $this->redirectToRoute("app_user_profil");
|
||||
elseif($by=="illustration")
|
||||
return $this->redirectToRoute("app_home_user",["userpseudo"=>$data->getUser()->getSlug()]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -231,7 +277,31 @@ class WebzineController extends AbstractController
|
||||
return $this->render($this->render.'upload.html.twig');
|
||||
}
|
||||
|
||||
public function view($idcat,$id,$by,Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$webzine=$em->getRepository($this->entity)->find($idcat);
|
||||
$page=$em->getRepository("App:Webzinepage")->find($id);
|
||||
$sets=$em->getRepository($this->entity)->findBy(["set"=>$webzine->getSet()],["order"=>"ASC"]);
|
||||
|
||||
$datanext=$this->getDataAllNext($idcat,$id,$webzine);
|
||||
$dataprev=$this->getDataAllPrev($idcat,$id,$webzine);
|
||||
|
||||
$pathinfo=pathinfo($page->getIllustration());
|
||||
|
||||
if(!$page) return $this->redirectToRoute('app_home');
|
||||
|
||||
return $this->render($this->render.'view.html.twig', array(
|
||||
$this->data => $webzine,
|
||||
"page" => $page,
|
||||
"sets" => $sets,
|
||||
"prev" => $dataprev,
|
||||
"next" => $datanext,
|
||||
"pathinfo" => $pathinfo,
|
||||
"usemonocolor" => true,
|
||||
"by" => $by,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
protected function getDataAllNext($idcat,$id,$webzine)
|
||||
@ -342,6 +412,10 @@ class WebzineController extends AbstractController
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && ($mode=="submit" || $mode=="update")) {
|
||||
// On récupère les pages et on cacule ceux à ajouter ou à supprimer
|
||||
$lstpages=array_filter(explode(",",$form->get("linkpages")->getData()));
|
||||
if(empty($lstpages))
|
||||
$form->addError(new FormError('Un webzine doit avoir au moins une page'));
|
||||
}
|
||||
|
||||
if ($form->get('submit')->isClicked() && !$form->isValid()) {
|
||||
|
@ -11,6 +11,9 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
||||
class WebzineType extends AbstractType
|
||||
{
|
||||
@ -42,6 +45,28 @@ class WebzineType extends AbstractType
|
||||
]
|
||||
);
|
||||
|
||||
if($options["by"]=="admin") {
|
||||
$builder->add('user',
|
||||
EntityType::class, [
|
||||
"class" => "App:User",
|
||||
"label" => "Utilisateur",
|
||||
"choice_label"=> "username",
|
||||
]
|
||||
);
|
||||
}
|
||||
else {
|
||||
$builder->add('user',
|
||||
EntityType::class, [
|
||||
"class" => "App:User",
|
||||
"label" => "Utilisateur",
|
||||
"choice_label"=> "username",
|
||||
'query_builder' => function (EntityRepository $er) use ($options): QueryBuilder {
|
||||
return $er->createQueryBuilder('u')->where('u.id=:user')->setParameter('user',$options['user']->getId());
|
||||
},
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$builder->add('mode',
|
||||
ChoiceType::class, [
|
||||
"label" =>"Mode de visualisation des planches",
|
||||
@ -62,6 +87,7 @@ class WebzineType extends AbstractType
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
$builder->add('linkpages',HiddenType::class, array("mapped" => false));
|
||||
}
|
||||
|
||||
@ -70,6 +96,8 @@ class WebzineType extends AbstractType
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'App\Entity\Webzine',
|
||||
'mode' => 'string',
|
||||
'by' => 'string',
|
||||
'user' => 'App\Entity\User'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user