From b85d03f78cfaaf95bbef37b835938c86cb77463b Mon Sep 17 00:00:00 2001 From: afornerot Date: Sat, 26 Oct 2024 12:08:33 +0200 Subject: [PATCH] multi user --- config/packages/security.yaml | 6 +- config/routes.yaml | 30 +- config/services.yaml | 7 +- docker-compose.yml | 1 + public/styles/css/style.css | 46 ++- src/Command/AppInitCommand.php | 157 ++++---- src/Controller/ConfigController.php | 111 +++++- src/Controller/HomeController.php | 33 +- src/Controller/SecurityController.php | 3 +- src/Controller/UserController.php | 2 +- src/Entity/Category.php | 17 + src/Entity/Config.php | 91 ++++- src/Entity/Link.php | 17 + src/Entity/User.php | 146 ++++++++ src/Entity/Webzine.php | 19 +- src/Form/ConfigType.php | 2 +- src/Form/UserType.php | 8 +- src/Repository/ConfigRepository.php | 25 ++ src/Service/UserSubscriber.php | 108 ++++++ src/Service/sessionInit.php | 45 +-- templates/Config/edit.html.twig | 21 +- templates/Config/list.html.twig | 18 +- templates/Config/render.html.twig | 12 +- templates/Home/home.html.twig | 55 +-- templates/Home/user.html.twig | 496 ++++++++++++++++++++++++++ templates/User/edit.html.twig | 74 +++- 26 files changed, 1310 insertions(+), 240 deletions(-) create mode 100755 src/Service/UserSubscriber.php create mode 100644 templates/Home/user.html.twig diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 65e3660..57a6908 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -39,8 +39,6 @@ security: access_control: - - { path: ^/user, roles: [ROLE_ADMIN, ROLE_MODO, ROLE_MASTER, ROLE_USER] } - - { path: ^/master, roles: [ROLE_ADMIN, ROLE_MODO, ROLE_MASTER] } - - { path: ^/modo, roles: [ROLE_ADMIN, ROLE_MODO] } - - { path: ^/admin, roles: [ROLE_ADMIN] } + - { path: ^/user, roles: [ROLE_ADMIN, ROLE_USER] } + - { path: ^/config, roles: [ROLE_ADMIN] } diff --git a/config/routes.yaml b/config/routes.yaml index 2530bd6..a10f288 100644 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -76,21 +76,29 @@ app_config: defaults: { _controller: App\Controller\ConfigController:list } app_config_render: - path: /admin/config/render/{category} + path: /admin/config/render/{mode}/{category}/{userid} defaults: { _controller: App\Controller\ConfigController:listrender } -app_config_submit: - path: /admin/config/submit - defaults: { _controller: App\Controller\ConfigController:submit } +app_config_user_render: + path: /user/config/render/{mode}/{category} + defaults: { _controller: App\Controller\ConfigController:listuserrender } app_config_update: - path: /admin/config/update/{id} + path: /admin/config/update/{mode}/{id}/{userid} defaults: { _controller: App\Controller\ConfigController:update } +app_config_user_update: + path: /user/config/update/{mode}/{id} + defaults: { _controller: App\Controller\ConfigController:updateuser } + app_config_delete: - path: /admin/config/delete/{id} + path: /admin/config/delete/{mode}/{id}/{userid} defaults: { _controller: App\Controller\ConfigController:delete } +app_config_user_delete: + path: /user/config/delete/{mode}/{id} + defaults: { _controller: App\Controller\ConfigController:deleteuser } + app_config_logo: path: /admin/config/logo defaults: { _controller: App\Controller\ConfigController:logo } @@ -124,10 +132,6 @@ app_user_profil: path: /user/profil defaults: { _controller: App\Controller\UserController:profil } -app_user_survey: - path: /user/surveys - defaults: { _controller: App\Controller\UserController:survey } - #== Group ======================================================================================================== app_group: path: /admin/group @@ -250,3 +254,9 @@ app_webzine_upload: app_slide: path: /slide defaults: { _controller: App\Controller\SlideController:slide } + +#== Home USer================================================================================================== + +app_home_user: + path: /{userpseudo} + defaults: { _controller: App\Controller\HomeController:user } diff --git a/config/services.yaml b/config/services.yaml index af61652..977aa59 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -50,7 +50,7 @@ services: app.session.init: public: true class: App\Service\sessionInit - arguments: ["@service_container","@doctrine.orm.entity_manager","@session",] + arguments: ["@doctrine.orm.entity_manager","@session",] tags: - { name: kernel.event_listener, event: kernel.request, method: onDomainParse } @@ -86,3 +86,8 @@ services: tags: - { name: twig.extension } + App\Service\UserSubscriber: + public: true + arguments: ["@doctrine.orm.entity_manager"] + tags: + - name: "doctrine.event_subscriber" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index b7fa8d7..b33485b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,6 +34,7 @@ services: - ./config:/app/config:delegated - ./public/uploads:/app/public/uploads:delegated - ./misc:/app/misc:delegated + - ./public/styles:/app/public/styles:delegated adminer: image: adminer diff --git a/public/styles/css/style.css b/public/styles/css/style.css index b29768b..b7e7c71 100644 --- a/public/styles/css/style.css +++ b/public/styles/css/style.css @@ -306,6 +306,39 @@ th.dt-center, td.dt-center { text-align: center; } border:none; } +.herousers { + position: absolute; + top: 100px; + flex-wrap: wrap; + left: 400px; + z-index: 10000; + display: flex; +} + +.herousers h3 { + width:100%; + padding-left:15px; +} + +.herouser { + padding:15px; + width:250px; + background-color: var(--colorbgbodydark); + margin:10px; + border-radius:5px; + text-align:center; +} + +.herouser img { + width:80px; + height: 80px; +} + +.herouser h4 { + font-size:16px; + margin-top:15px; +} + .heromenu { padding-top: 30px; font-size: 20px; @@ -338,7 +371,10 @@ th.dt-center, td.dt-center { text-align: center; } width: 100%; } -.herologo img {max-height:200px;} +.herologo img { + max-height:200px; + border-radius: 100%; +} @media (max-width: 980px) { .herobox { display: none; } @@ -347,7 +383,11 @@ th.dt-center, td.dt-center { text-align: center; } .heromenu .facatmenu {display: none;} .catmenu { display:none } .heromenu .linkmenu {zoom:200%} - + .herousers { top:315px; left:0px; width: 100%; justify-content: center; } + .herousers { text-align: center; } + .herousers h3{ padding-left: 0px; } + .herouser { width:170px} + .herouser img { width:50px;height:50px} .herofloatmenu a { font-size: 40px; } @@ -392,7 +432,7 @@ th.dt-center, td.dt-center { text-align: center; } border-bottom: 1px solid var(--colorftbodydark); } -.foliomenu .logo { float:left; height:40px; margin-top:7px } +.foliomenu .logo { float:left; height:40px; margin-top:7px; border-radius: 100%; } .foliomenu .avatar { height: 20px; margin: 3px 3px 0px 0px; width: 20px; } .foliomenu div { padding: 10px; line-height:35px; float:left;} .foliomenu a { diff --git a/src/Command/AppInitCommand.php b/src/Command/AppInitCommand.php index 5fb7fb5..7caedd3 100644 --- a/src/Command/AppInitCommand.php +++ b/src/Command/AppInitCommand.php @@ -53,22 +53,14 @@ class AppInitCommand extends Command $output->writeln('APP = Default Data'); - // Création du compte admin si non existant - $this->insertUser("admin",$this->container->getParameter('appInitpwdadmin'),$this->appname,"Admin",$this->appmailnoreply,['ROLE_ADMIN'],"admin.jpg"); - - // Init Media - //$this->initMedia(); - - // Création d'une catégory par défaut - $this->insertCategory(-100,1,"Illustrations"); - // colorbgbody = Couleur des fonds de page $this->insertConfig( 1, // order + false, // customizable "site", // category "appname", // id "Titre de votre site", // title - "", // value + $this->appname, // value "string", // type, true, // visible true, // changeable @@ -79,10 +71,11 @@ class AppInitCommand extends Command $this->insertConfig( 2, // order + true, // customizable "site", // category "appsubname", // id "Sous-titre de votre site", // title - "", // value + "Portefolio", // value "string", // type, true, // visible true, // changeable @@ -93,6 +86,7 @@ class AppInitCommand extends Command $this->insertConfig( 3, // order + true, // customizable "site", // category "appdescription", // id "Description de votre site", // title @@ -107,6 +101,7 @@ class AppInitCommand extends Command $this->insertConfig( 4, // order + false, // customizable "site", // category "appthumbwidth", // id "Largeur des miniatures", // title @@ -121,6 +116,7 @@ class AppInitCommand extends Command $this->insertConfig( 5, // order + false, // customizable "site", // category "appthumbheight", // id "Hauteur des miniatures", // title @@ -135,6 +131,7 @@ class AppInitCommand extends Command $this->insertConfig( 6, // order + false, // customizable "site", // category "appthumbfilter", // id "Filtre sur les miniatures", // title @@ -149,7 +146,8 @@ class AppInitCommand extends Command $this->insertConfig( 7, // order - "site", // category + false, // customizable + "false", // category "appthumbfiltergrayscale", // id "Filtre grayscale sur les miniatures", // title "100", // value @@ -163,6 +161,7 @@ class AppInitCommand extends Command $this->insertConfig( 8, // order + false, // customizable "site", // category "appthumbfilteropacity", // id "Filtre opacity sur les miniatures", // title @@ -177,6 +176,7 @@ class AppInitCommand extends Command $this->insertConfig( 9, // order + false, // customizable "site", // category "appthumbfiltersepia", // id "Filtre sepia sur les miniatures", // title @@ -192,6 +192,7 @@ class AppInitCommand extends Command $this->insertConfig( 10, // order + false, // customizable "site", // category "appmaxthumbwidth", // id "Largeur maximum de la grille des thumbs", // title @@ -207,6 +208,7 @@ class AppInitCommand extends Command // colorbgbody = Couleur des fonds de page $this->insertConfig( 1, // order + false, // customizable "colorbgbody", // category "colorbgbodydark", // id "Couleur de fond fonçée", // title @@ -221,6 +223,7 @@ class AppInitCommand extends Command $this->insertConfig( 2, // order + false, // customizable "colorbgbody", // category "colorbgbodylight", // id "Couleur de fond claire", // title @@ -236,6 +239,7 @@ class AppInitCommand extends Command // colorfttitle = Couleur des fontes titre $this->insertConfig( 1, // order + false, // customizable "colorfttitle", // category "colorfttitledark", // id "Couleur des titres sur fond fonçé", // title @@ -250,6 +254,7 @@ class AppInitCommand extends Command $this->insertConfig( 2, // order + false, // customizable "colorfttitle", // category "colorfttitlelight", // id "Couleur des titres sur fond claire", // title @@ -265,6 +270,7 @@ class AppInitCommand extends Command // colorftbody = Couleur des fontes titre $this->insertConfig( 1, // order + false, // customizable "colorftbody", // category "colorftbodydark", // id "Couleur de la police sur fond fonçé", // title @@ -279,6 +285,7 @@ class AppInitCommand extends Command $this->insertConfig( 2, // order + false, // customizable "colorftbody", // category "colorftbodylight", // id "Couleur de la police sur fond claire", // title @@ -294,6 +301,7 @@ class AppInitCommand extends Command // font = nom des polices $this->insertConfig( 1, // order + false, // customizable "font", // category "fonttitle", // id "Police pour les titres", // title @@ -308,6 +316,7 @@ class AppInitCommand extends Command $this->insertConfig( 2, // order + false, // customizable "font", // category "fontbody", // id "Police principale", // title @@ -323,10 +332,11 @@ class AppInitCommand extends Command // logo = $this->insertConfig( 1, // order + false, // customizable "logo", // category "logodark", // id "Logo sur fond fonçé", // title - "", // value + "logo.png", // value "logo", // type, true, // visible true, // changeable @@ -337,10 +347,11 @@ class AppInitCommand extends Command $this->insertConfig( 2, // order + false, // customizable "logo", // category "logolight", // id "Logo sur fond clair", // title - "", // value + "logo.png", // value "logo", // type, true, // visible true, // changeable @@ -352,10 +363,11 @@ class AppInitCommand extends Command // image = $this->insertConfig( 1, // order + true, // customizable "image", // category "imgcontact", // id "Image Contact", // title - "", // value + "contact.jpg", // value "image", // type, true, // visible true, // changeable @@ -366,10 +378,11 @@ class AppInitCommand extends Command $this->insertConfig( 1, // order + true, // customizable "image", // category "imglink", // id "Image Liens", // title - "", // value + "link.jpg", // value "image", // type, true, // visible true, // changeable @@ -381,10 +394,11 @@ class AppInitCommand extends Command // hero = $this->insertConfig( 1, // order + true, // customizable "hero", // category "hero01", // id "Carrousel 01", // title - "", // value + "hero.jpg", // value "hero", // type, true, // visible true, // changeable @@ -395,6 +409,7 @@ class AppInitCommand extends Command $this->insertConfig( 2, // order + true, // customizable "hero", // category "hero02", // id "Carrousel 02", // title @@ -409,6 +424,7 @@ class AppInitCommand extends Command $this->insertConfig( 3, // order + true, // customizable "hero", // category "hero03", // id "Carrousel 03", // title @@ -423,6 +439,7 @@ class AppInitCommand extends Command $this->insertConfig( 4, // order + true, // customizable "hero", // category "hero04", // id "Carrousel 04", // title @@ -437,6 +454,7 @@ class AppInitCommand extends Command $this->insertConfig( 5, // order + true, // customizable "hero", // category "hero05", // id "Carrousel 05", // title @@ -452,6 +470,7 @@ class AppInitCommand extends Command // Social = $this->insertConfig( 1, // order + false, // customizable "social", // category "email", // id "Email", // title @@ -466,6 +485,7 @@ class AppInitCommand extends Command $this->insertConfig( 2, // order + true, // customizable "social", // category "facebook", // id "Facebook", // title @@ -480,6 +500,7 @@ class AppInitCommand extends Command $this->insertConfig( 3, // order + true, // customizable "social", // category "instagram", // id "Instagram", // title @@ -494,6 +515,7 @@ class AppInitCommand extends Command $this->insertConfig( 4, // order + true, // customizable "social", // category "twitter", // id "Twitter", // title @@ -508,6 +530,7 @@ class AppInitCommand extends Command $this->insertConfig( 5, // order + true, // customizable "social", // category "google", // id "Google", // title @@ -522,6 +545,7 @@ class AppInitCommand extends Command $this->insertConfig( 6, // order + true, // customizable "social", // category "youtube", // id "Youtube", // title @@ -534,6 +558,11 @@ class AppInitCommand extends Command "Le Youtube du site" ); + + + // Création du compte admin si non existant + $this->insertUser("admin",$this->container->getParameter('appInitpwdadmin'),$this->appname,"Admin",$this->appmailnoreply,['ROLE_ADMIN'],"admin.jpg"); + $output->writeln(''); return Command::SUCCESS; @@ -547,6 +576,7 @@ class AppInitCommand extends Command $entity->setPassword($password); $entity->setFirstname($firstname); $entity->setLastname($lastname); + $entity->SetPseudo($username); $entity->setEmail($email); $entity->setRoles($roles); $entity->setAvatar($avatar); @@ -557,41 +587,38 @@ class AppInitCommand extends Command $this->em->flush(); } - protected function insertCategory($id,$order,$name) { - $metadata = $this->em->getClassMetaData('App:Category'); - $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE); - $metadata->setIdGenerator(new AssignedGenerator()); - - // Création du compte admin par défaut - $entity = $this->em->getRepository('App:Category')->find($id); - if(!$entity) { - $entity = new Category; - $entity->setId($id); - $entity->setOrder($order); - $entity->setName($name); - $entity->setUsecategoryconfig(false); - $entity->setAppthumbfilter(false); - $entity->setAppthumbheight(0); - $entity->setAppthumbwidth(0); - $entity->setAppthumbfilter(false); - $entity->setAppthumbfiltergrayscale(100); - $entity->setAppthumbfilteropacity(100); - $entity->setAppthumbfiltersepia(0); - $this->em->persist($entity); - } + protected function insertCategory($name) { - // On flush - $this->em->flush(); + $users=$this->em->getRepository('App:User')->findAll(); + foreach($users as $user) { + $category=$entity = $this->em->getRepository('App:Category')->findOneBy(["user"=>$user]); + if(!$category) { + $category = new Category; + $category->setOrder(1); + $category->setName($name); + $category->setUsecategoryconfig(false); + $category->setAppthumbfilter(false); + $category->setAppthumbheight(0); + $category->setAppthumbwidth(0); + $category->setAppthumbfilter(false); + $category->setAppthumbfiltergrayscale(100); + $category->setAppthumbfilteropacity(100); + $category->setAppthumbfiltersepia(0); + $category->setUser($user); + $this->em->persist($category); + $this->em->flush(); + } + } } - private function insertConfig($order,$category,$id,$title,$value,$type,$visible,$changeable,$required,$grouped,$help) { - $entity=$this->em->getRepository("App:Config")->find($id); + private function insertConfig($order,$customizable,$category,$key,$title,$value,$type,$visible,$changeable,$required,$grouped,$help) { + $entity=$this->em->getRepository("App:Config")->findOneBy(["keyid"=>$key,"user"=>null]); if(!$entity) { $entity= new Config(); - $entity->setId($id); - $entity->setValue($value); + $entity->setKeyid($key); + $entity->setUser(null); } - + $entity->setDefvalue($value); $entity->setCategory($category); $entity->setOrder($order); $entity->setTitle($title); @@ -601,48 +628,12 @@ class AppInitCommand extends Command $entity->setRequired($required); $entity->setGrouped($grouped); $entity->setHelp($help); + $entity->setCustomizable($customizable&&$changeable&&$visible); $this->em->persist($entity); $this->em->flush(); } - private function initMedia() { - // Initialiser Filesystem - $filesystem = new Filesystem(); - - $sourcePath = $this->container->getParameter('kernel.project_dir') . '/public/styles/medias'; - $destinationPath = $this->container->getParameter('kernel.project_dir') . '/public/uploads'; - - echo "===================="; - echo get_current_user(); - - // Vérifier si le répertoire existe - if (!$filesystem->exists($destinationPath."/logo")) { - $filesystem->mkdir($destinationPath,0777); - $filesystem->mkdir($destinationPath."/image",0777); - $filesystem->mkdir($destinationPath."/logo",0777); - $filesystem->mkdir($destinationPath."/avatar",0777); - $filesystem->mkdir($destinationPath."/hero",0777); - - $filesystem->chown($destinationPath, 'apache'); - $filesystem->chown($destinationPath."/image",'apache'); - $filesystem->chown($destinationPath."/logo",'apache'); - $filesystem->chown($destinationPath."/avatar",'apache'); - $filesystem->chown($destinationPath."/hero",'apache'); - } - - /* - $filesystem->copy($sourcePath."/admin.jpg", $destinationPath."/avatar/"); - $filesystem->copy($sourcePath."/noavatar.png", $destinationPath."/avatar/"); - $filesystem->copy($sourcePath."/system.jpg", $destinationPath."/avatar/"); - $filesystem->copy($sourcePath."/contact.jpg", $destinationPath."/image"); - $filesystem->copy($sourcePath."/link.jpg", $destinationPath."/image"); - $filesystem->copy($sourcePath."/hero.jpg", $destinationPath."/hero"); - $filesystem->copy($sourcePath."/logo.png", $destinationPath."/logo"); - */ - echo "===================="; - } - private function writelnred($string) { $this->output->writeln(''.$string.''); $this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n"); diff --git a/src/Controller/ConfigController.php b/src/Controller/ConfigController.php index c6fd3ef..89ef486 100755 --- a/src/Controller/ConfigController.php +++ b/src/Controller/ConfigController.php @@ -20,32 +20,53 @@ class ConfigController extends AbstractController public function list() { $em = $this->getDoctrine()->getManager(); - $datas = $em->getRepository($this->entity)->findBy(["visible"=>true]); + $datas = $em->getRepository($this->entity)->findBy(["visible"=>true,"user"=>null]); return $this->render($this->render.'list.html.twig',[ $this->data."s" => $datas, "useheader" => true, "usesidebar" => true, + "mode" => "config", ]); } - public function listrender($category) + public function listrender($mode,$category,$userid) { $em = $this->getDoctrine()->getManager(); - $datas = $em->getRepository($this->entity)->findBy(["visible"=>true,"category"=>$category]); + $user=null; + if($userid) $user=$em->getRepository("App:User")->find($userid); + $datas = $em->getRepository($this->entity)->findBy(["visible"=>true,"category"=>$category,"user"=>$user]); return $this->render($this->render.'render.html.twig',[ $this->data."s" => $datas, "useheader" => true, "usesidebar" => true, + "mode" => $mode, + "userid" => $userid, ]); } - public function update($id,Request $request) + public function listuserrender($mode,$category) + { + $em = $this->getDoctrine()->getManager(); + $datas = $em->getRepository($this->entity)->findBy(["visible"=>true,"category"=>$category,"user"=>$this->getUser()]); + + return $this->render($this->render.'render.html.twig',[ + $this->data."s" => $datas, + "useheader" => true, + "usesidebar" => true, + "mode" => $mode, + ]); + } + + public function update($mode,$id,$userid,Request $request) { // Initialisation de l'enregistrement $em = $this->getDoctrine()->getManager(); - $data=$em->getRepository($this->entity)->find($id); + + $user=null; + if($mode!="config") $user=$em->getRepository("App:User")->find($userid); + $data=$em->getRepository($this->entity)->findOneBy(["id"=>$id,"user"=>$user]); // Création du formulaire $form = $this->createForm(Form::class,$data,array("mode"=>"update","id"=>$data->getId(),"type"=>$data->getType(),"required"=>$data->getRequired())); @@ -63,7 +84,12 @@ class ConfigController extends AbstractController $em->flush(); // Retour à la liste - return $this->redirectToRoute($this->route); + if($mode!="config") { + return $this->redirectToRoute("app_user_update",["id"=>$userid]); + } + else { + return $this->redirectToRoute($this->route); + } } // Affichage du formulaire @@ -71,23 +97,76 @@ class ConfigController extends AbstractController 'useheader' => true, 'usesidebar' => true, $this->data => $data, - 'mode' => 'update', - 'form' => $form->createView() + 'mode' => $mode, + 'form' => $form->createView(), + 'userid' => $userid, ]); } - public function delete($id,Request $request) + public function updateuser($mode,$id,Request $request) + { + // Initialisation de l'enregistrement + $em = $this->getDoctrine()->getManager(); + $data=$em->getRepository($this->entity)->findOneBy(["id"=>$id,"user"=>$this->getUser()]); + + // Création du formulaire + $form = $this->createForm(Form::class,$data,array("mode"=>"update","id"=>$data->getId(),"type"=>$data->getType(),"required"=>$data->getRequired())); + + // Récupération des data du formulaire + $form->handleRequest($request); + + // Sur erreur + $this->getErrorForm($id,$form,$request,$data,"update"); + + // Sur validation + if ($form->get('submit')->isClicked() && $form->isValid()) { + $data = $form->getData(); + $em->persist($data); + $em->flush(); + + // Retour à la liste + return $this->redirectToRoute("app_user_profil"); + } + + // Affichage du formulaire + return $this->render($this->render.'edit.html.twig', [ + 'useheader' => true, + 'usesidebar' => false, + $this->data => $data, + 'mode' => $mode, + 'form' => $form->createView(), + 'userid' => $this->getUser()->getId(), + ]); + } + + public function delete($mode,$id,$userid,Request $request) { // Récupération de l'enregistrement courant $em = $this->getDoctrine()->getManager(); - $config=$em->getRepository($this->entity)->find($id); - if(!$config->getRequired()) { - $config->setValue(""); - $em = $this->getDoctrine()->getManager(); - $em->persist($config); - $em->flush(); + $config=$em->getRepository($this->entity)->find(["id"=>$id]); + $config->setValue(null); + $em = $this->getDoctrine()->getManager(); + $em->persist($config); + $em->flush(); + // Retour à la liste + if($mode!="config") { + return $this->redirectToRoute("app_user_update",["id"=>$userid]); } - return $this->redirectToRoute('app_config'); + else { + return $this->redirectToRoute($this->route); + } + } + + public function deleteuser($id,Request $request) + { + // Récupération de l'enregistrement courant + $em = $this->getDoctrine()->getManager(); + $config=$em->getRepository($this->entity)->findOneBy(["id"=>$id,"user"=>$this->getUser()]); + $config->setValue(null); + $em = $this->getDoctrine()->getManager(); + $em->persist($config); + $em->flush(); + return $this->redirectToRoute('app_user_profil'); } public function logo() diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php index b490ba2..3c37362 100755 --- a/src/Controller/HomeController.php +++ b/src/Controller/HomeController.php @@ -12,20 +12,47 @@ class HomeController extends AbstractController public function home() { $em = $this->getDoctrine()->getManager(); - $categorys = $em->getRepository("App:Category")->findAll(); - $links = $em->getRepository("App:Link")->findAll(); - $webzines = $em->getRepository("App:Webzine")->findBy([], ['set' => 'ASC', 'order' => 'ASC']); + + $users = $em->getRepository("App:User")->findBy([],["pseudo"=>"ASC"]); + $categorys = $em->getRepository("App:Category")->findBy(["user"=>null]); + $links = $em->getRepository("App:Link")->findBy(["user"=>null]); + $webzines = $em->getRepository("App:Webzine")->findBy(["user"=>null], ['set' => 'ASC', 'order' => 'ASC']); return $this->render('Home/home.html.twig',[ "useheader" => false, "usesidebar" => false, "usemonocolor" => true, + "users" => $users, "categorys" => $categorys, "links" => $links, "webzines" => $webzines ]); } + public function user($userpseudo) + { + $em = $this->getDoctrine()->getManager(); + $user=$em->getRepository("App:User")->findOneBy(["slug"=>$userpseudo]); + if(!$user) return $this->redirectToRoute("app_home"); + + $categorys = $em->getRepository("App:Category")->findBy(["user"=>$user]); + $links = $em->getRepository("App:Link")->findBy(["user"=>$user]); + $webzines = $em->getRepository("App:Webzine")->findBy(["user"=>$user], ['set' => 'ASC', 'order' => 'ASC']); + $config = $em->getRepository("App:Config")->getUserConfig($user); + + return $this->render('Home/user.html.twig',[ + "useheader" => false, + "usesidebar" => false, + "usemonocolor" => true, + "user" => $user, + "config" => $config, + "categorys" => $categorys, + "links" => $links, + "webzines" => $webzines + ]); + } + + public function feed($nb) { $feeds=[]; diff --git a/src/Controller/SecurityController.php b/src/Controller/SecurityController.php index c4cea94..a5e736a 100755 --- a/src/Controller/SecurityController.php +++ b/src/Controller/SecurityController.php @@ -82,6 +82,7 @@ class SecurityController extends AbstractController $user->setUsername($username); $user->setLastname($lastname); $user->setFirstname($firstname); + $user->setPseudo($username); $user->setEmail($email); $user->setPassword("CASPWD-".$username); @@ -158,5 +159,5 @@ class SecurityController extends AbstractController \phpCAS::logout(array("service"=>$url)); return true; - } + } } diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 5257167..203b4f2 100755 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -157,7 +157,7 @@ class UserController extends AbstractController $em->flush(); // Retour à la liste - return $this->redirectToRoute("app_home"); + return $this->redirectToRoute("app_home_user",["userpseudo"=>$data->getPseudo()]); } // Affichage du formulaire diff --git a/src/Entity/Category.php b/src/Entity/Category.php index ebe9b6e..d4a9c68 100644 --- a/src/Entity/Category.php +++ b/src/Entity/Category.php @@ -66,6 +66,11 @@ class Category */ private $appthumbfiltersepia; + /** + * @ORM\ManyToOne(targetEntity="User") + */ + private $user; + /** * @ORM\OneToMany(targetEntity="Illustration", mappedBy="category", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OrderBy({"id" = "DESC"}) @@ -227,4 +232,16 @@ class Category return $this; } + public function getUser(): ?User + { + return $this->user; + } + + public function setUser(?User $user): self + { + $this->user = $user; + + return $this; + } + } diff --git a/src/Entity/Config.php b/src/Entity/Config.php index 79fb6d9..304c143 100644 --- a/src/Entity/Config.php +++ b/src/Entity/Config.php @@ -7,15 +7,22 @@ use Doctrine\ORM\Mapping as ORM; /** * Cron * - * @ORM\Table(name="config") + * @ORM\Table(name="config",uniqueConstraints={@ORM\UniqueConstraint(name="configkeyid", columns={"keyid","user_id"})}) * @ORM\Entity(repositoryClass="App\Repository\ConfigRepository") */ class Config -{ /** +{ + /** + * @ORM\Column(name="id", type="integer") * @ORM\Id - * @ORM\Column(type="string") + * @ORM\GeneratedValue(strategy="AUTO") */ - protected $id; + private $id; + + /** + * @ORM\Column(type="string", length=250) + */ + protected $keyid; /** * @ORM\Column(type="string", length=250) @@ -23,10 +30,15 @@ class Config protected $title; /** - * @ORM\Column(type="text") + * @ORM\Column(type="text", nullable=true) */ protected $value; + /** + * @ORM\Column(type="text", nullable=true) + */ + protected $defvalue; + /** * @ORM\Column(name="roworder", type="string") */ @@ -67,30 +79,69 @@ class Config */ protected $help; - public function getId(): ?string + /** + * @ORM\Column(type="boolean") + */ + protected $customizable; + + /** + * @ORM\ManyToOne(targetEntity="User") + */ + private $user; + + public function getId(): ?int { return $this->id; } - public function setId(string $id): self + public function getKeyid(): ?string { - $this->id = $id; + return $this->keyid; + } + + public function setKeyid(string $keyid): self + { + $this->keyid = $keyid; + + return $this; + } + + public function getTitle(): ?string + { + return $this->title; + } + + public function setTitle(string $title): self + { + $this->title = $title; return $this; } public function getValue(): ?string { - return $this->value; + return ($this->value?$this->value:($this->user?null:$this->defvalue)); } - public function setValue(string $value): self + public function setValue(?string $value): self { $this->value = $value; return $this; } + public function getDefvalue(): ?string + { + return $this->defvalue; + } + + public function setDefvalue(?string $defvalue): self + { + $this->defvalue = $defvalue; + + return $this; + } + public function getOrder(): ?string { return $this->order; @@ -187,14 +238,26 @@ class Config return $this; } - public function getTitle(): ?string + public function getCustomizable(): ?bool { - return $this->title; + return $this->customizable; } - public function setTitle(string $title): self + public function setCustomizable(bool $customizable): self { - $this->title = $title; + $this->customizable = $customizable; + + return $this; + } + + public function getUser(): ?User + { + return $this->user; + } + + public function setUser(?User $user): self + { + $this->user = $user; return $this; } diff --git a/src/Entity/Link.php b/src/Entity/Link.php index 8367a44..96e7c36 100644 --- a/src/Entity/Link.php +++ b/src/Entity/Link.php @@ -36,6 +36,11 @@ class Link */ protected $url; + /** + * @ORM\ManyToOne(targetEntity="User") + */ + private $user; + public function getId(): ?int { return $this->id; @@ -77,4 +82,16 @@ class Link return $this; } + public function getUser(): ?User + { + return $this->user; + } + + public function setUser(?User $user): self + { + $this->user = $user; + + return $this; + } + } diff --git a/src/Entity/User.php b/src/Entity/User.php index 295be33..ada7ea5 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -14,7 +14,9 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; * * @ORM\Entity(repositoryClass="App\Repository\UserRepository") * @ORM\Table(name="user",uniqueConstraints={@ORM\UniqueConstraint(name="username", columns={"username"})}) + * @ORM\Table(name="user",uniqueConstraints={@ORM\UniqueConstraint(name="pseudo", columns={"pseudo"})}) * @UniqueEntity("username", message="Ce nom d'utilisateur existe dèja") + * @UniqueEntity("pseudo", message="Ce pseudo d'utilisateur existe dèja") */ class User implements UserInterface, \Serializable @@ -65,6 +67,16 @@ class User implements UserInterface, \Serializable private $lastname; private $displayname; + /** + * @ORM\Column(type="string", length=250) + */ + private $pseudo; + + /** + * @ORM\Column(type="string", length=250) + */ + private $slug; + /** * @ORM\Column(type="string", length=200, nullable=true, options={"default" : 0}) */ @@ -84,11 +96,29 @@ class User implements UserInterface, \Serializable */ private $groups; + /** + * @ORM\OneToMany(targetEntity="Category", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true) + */ + private $illustrations; + + /** + * @ORM\OneToMany(targetEntity="Webzine", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true) + */ + private $webzines; + + /** + * @ORM\OneToMany(targetEntity="Link", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true) + */ + private $links; + public function __construct() { $this->groups = new ArrayCollection(); $this->surveys = new ArrayCollection(); $this->guests = new ArrayCollection(); + $this->illustrations = new ArrayCollection(); + $this->webzines = new ArrayCollection(); + $this->links = new ArrayCollection(); } public function getUsername(): ?string @@ -267,4 +297,120 @@ class User implements UserInterface, \Serializable return $this; } + + /** + * @return Collection|Category[] + */ + public function getIllustrations(): Collection + { + return $this->illustrations; + } + + public function addIllustration(Category $illustration): self + { + if (!$this->illustrations->contains($illustration)) { + $this->illustrations[] = $illustration; + $illustration->setUser($this); + } + + return $this; + } + + public function removeIllustration(Category $illustration): self + { + if ($this->illustrations->removeElement($illustration)) { + // set the owning side to null (unless already changed) + if ($illustration->getUser() === $this) { + $illustration->setUser(null); + } + } + + return $this; + } + + /** + * @return Collection|Webzine[] + */ + public function getWebzines(): Collection + { + return $this->webzines; + } + + public function addWebzine(Webzine $webzine): self + { + if (!$this->webzines->contains($webzine)) { + $this->webzines[] = $webzine; + $webzine->setUser($this); + } + + return $this; + } + + public function removeWebzine(Webzine $webzine): self + { + if ($this->webzines->removeElement($webzine)) { + // set the owning side to null (unless already changed) + if ($webzine->getUser() === $this) { + $webzine->setUser(null); + } + } + + return $this; + } + + /** + * @return Collection|Link[] + */ + public function getLinks(): Collection + { + return $this->links; + } + + public function addLink(Link $link): self + { + if (!$this->links->contains($link)) { + $this->links[] = $link; + $link->setUser($this); + } + + return $this; + } + + public function removeLink(Link $link): self + { + if ($this->links->removeElement($link)) { + // set the owning side to null (unless already changed) + if ($link->getUser() === $this) { + $link->setUser(null); + } + } + + return $this; + } + + public function getPseudo(): ?string + { + return $this->pseudo; + } + + public function setPseudo(?string $pseudo): self + { + $this->pseudo = $pseudo; + $pseudo=strtolower($pseudo); + if($pseudo=="admin"||$pseudo=="user"||$pseudo=="feed"||$pseudo=="_uploader") $pseudo.="home"; + $this->slug = $pseudo; + return $this; + } + + public function getSlug(): ?string + { + return $this->slug; + } + + public function setSlug(string $slug): self + { + $this->slug = $slug; + + return $this; + } } diff --git a/src/Entity/Webzine.php b/src/Entity/Webzine.php index a6c96aa..25a4618 100644 --- a/src/Entity/Webzine.php +++ b/src/Entity/Webzine.php @@ -50,7 +50,12 @@ class Webzine * @ORM\Column(type="integer") */ private $mode; - + + /** + * @ORM\ManyToOne(targetEntity="User") + */ + private $user; + /** * @ORM\OneToMany(targetEntity="Webzinepage", mappedBy="webzine", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OrderBy({"order" = "ASC"}) @@ -169,4 +174,16 @@ class Webzine return $this; } + public function getUser(): ?User + { + return $this->user; + } + + public function setUser(?User $user): self + { + $this->user = $user; + + return $this; + } + } diff --git a/src/Form/ConfigType.php b/src/Form/ConfigType.php index b436435..cb8c968 100644 --- a/src/Form/ConfigType.php +++ b/src/Form/ConfigType.php @@ -21,7 +21,7 @@ class ConfigType extends AbstractType array("label" => "Valider", "attr" => array("class" => "btn btn-success"))); - $builder->add('id', + $builder->add('keyid', TextType::class, array("label" =>"Clé", "label_attr" => array("style" => 'margin-top:15px;'), diff --git a/src/Form/UserType.php b/src/Form/UserType.php index 155353c..63fab97 100644 --- a/src/Form/UserType.php +++ b/src/Form/UserType.php @@ -42,11 +42,15 @@ class UserType extends AbstractType ] ); + $builder->add('pseudo', + TextType::class, [ + "label" =>"Pseudo", + ] + ); + if($options["mode"]!="profil") { $choices=[]; $choices['Administrateur']='ROLE_ADMIN'; - $choices['Modérateur']='ROLE_MODO'; - $choices['Master']='ROLE_MASTER'; $choices['Utilisateur']='ROLE_USER'; $builder->add('roles', diff --git a/src/Repository/ConfigRepository.php b/src/Repository/ConfigRepository.php index 0f617a6..230c282 100644 --- a/src/Repository/ConfigRepository.php +++ b/src/Repository/ConfigRepository.php @@ -3,6 +3,7 @@ namespace App\Repository; use App\Entity\Config; +use App\Entity\User; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Common\Persistence\ManagerRegistry; @@ -12,4 +13,28 @@ class ConfigRepository extends ServiceEntityRepository { parent::__construct($registry, Config::class); } + + public function getUserConfig(User $user): array { + $tbconfig=[]; + $custos=$this->_em->getRepository('App:Config')->findBy(["user"=>$user]); + foreach($custos as $custo) { + if($custo->getValue()) { + $tbcusto[$custo->getKeyid()]=$custo->getValue(); + } + else { + // On va prendre la valeur global pour les category hero et image + if($custo->getCategory()=="image"||$custo->getCategory()=="hero") { + $config=$this->_em->getRepository('App:Config')->findOneBy(["keyid"=>$custo->getKeyid(),"user"=>null]); + if($config) { + $tbcusto[$custo->getKeyid()]=$config->getValue(); + } + } + // Sinon clé vide + else { + $tbcusto[$custo->getKeyid()]=null; + } + } + } + return $tbcusto; + } } diff --git a/src/Service/UserSubscriber.php b/src/Service/UserSubscriber.php new file mode 100755 index 0000000..c2b4352 --- /dev/null +++ b/src/Service/UserSubscriber.php @@ -0,0 +1,108 @@ +em = $em; + } + + public function getSubscribedEvents(): array + { + return [ + Events::postPersist, + Events::postUpdate, + ]; + } + + public function postPersist(LifecycleEventArgs $args): void + { + $this->upinsertUser($args); + } + + public function postUpdate(LifecycleEventArgs $args): void + { + $this->upinsertUser($args); + } + + private function upinsertUser(LifecycleEventArgs $args): void { + $this->user = $args->getObject(); + if (!$this->user instanceof User) { + return; + } + + // On s'assure que le user a au moins une category d'illustration + $this->insertCategory(); + + // On initialise l'ensemble des config customizable + $this->insertConfig(); + + } + + private function insertCategory(): void { + $user=$this->user; + $category=$entity = $this->em->getRepository('App:Category')->findOneBy(["user"=>$this->user]); + if(!$category) { + $category = new Category; + $category->setOrder(1); + $category->setName("Illustrations"); + $category->setUsecategoryconfig(false); + $category->setAppthumbfilter(false); + $category->setAppthumbheight(0); + $category->setAppthumbwidth(0); + $category->setAppthumbfilter(false); + $category->setAppthumbfiltergrayscale(100); + $category->setAppthumbfilteropacity(100); + $category->setAppthumbfiltersepia(0); + $category->setUser($this->user); + $this->em->persist($category); + $this->em->flush(); + $this->user=$user; + } + dump($this->user); + } + + private function insertConfig(): void { + $user=$this->user; + $configs=$entity = $this->em->getRepository('App:Config')->findBy(["user"=>null,"customizable"=>true]); + foreach($configs as $config) { + $custo=$this->em->getRepository('App:Config')->findBy(["user"=>$user,"keyid"=>$config->getKeyid()]); + if(!$custo) { + $custo=new Config; + $custo->setKeyid($config->getKeyid()); + $custo->setValue(null); + $custo->setDefvalue(null); + $custo->setCategory($config->getCategory()); + $custo->setOrder($config->getOrder()); + $custo->setTitle($config->getTitle()); + $custo->setType($config->getType()); + $custo->setVisible($config->getVisible()); + $custo->setChangeable($config->getChangeable()); + $custo->setRequired($config->getRequired()); + $custo->setGrouped($config->getGrouped()); + $custo->setHelp($config->getHelp()); + $custo->setCustomizable($config->getCustomizable()); + $custo->setUser($user); + + $this->em->persist($custo); + $this->em->flush(); + $this->user=$user; + } + } + } +} diff --git a/src/Service/sessionInit.php b/src/Service/sessionInit.php index 0451393..feb95b5 100644 --- a/src/Service/sessionInit.php +++ b/src/Service/sessionInit.php @@ -1,60 +1,25 @@ container = $container; $this->session = $session; $this->em = $em; } - public function onDomainParse(RequestEvent $event) { - $configs = $this->em->getRepository("App:Config")->findAll(); - $havehero=false; + public function onDomainParse(RequestEvent $event): void + { + $configs = $this->em->getRepository("App:Config")->findBy(["user"=>null]); foreach($configs as $config) { - if($config->getCategory()=="hero" && $config->getValue()!="") $havehero=true; - $this->session->set($config->getId(), strval($config->getValue())); + $this->session->set($config->getKeyid(), strval($config->getValue())); } - - // Valeur par défaut appname - if($this->session->get("appname")=="") - $this->session->set("appname", $this->container->getParameter('appName')); - - // Valeur par defaut hero - if(!$havehero) $this->session->set("hero01", "hero.jpg"); - - // Valeur par defaut logo - if($this->session->get("logodark")==""&&$this->session->get("logolight")=="") { - $this->session->set("logodark", "logo.png"); - $this->session->set("logolight", "logo.png"); - } - elseif($this->session->get("logodark")=="") - $this->session->set("logodark", $this->session->get("logolight")); - elseif($this->session->get("logolight")=="") - $this->session->set("logolight", $this->session->get("logodark")); - - // Valeur par défaut imgcontact - if($this->session->get("imgcontact")=="") - $this->session->set("imgcontact", "contact.jpg"); - - // Valeur par défaut imglink - if($this->session->get("imglink")=="") - $this->session->set("imglink", "link.jpg"); - - // Calcul des couleurs - /* - $color = $this->container->get('cadoles.core.service.color'); - $color->setColor(); - */ } } diff --git a/templates/Config/edit.html.twig b/templates/Config/edit.html.twig index 846af79..021bdf6 100755 --- a/templates/Config/edit.html.twig +++ b/templates/Config/edit.html.twig @@ -3,24 +3,17 @@ {% block body %} {{ form_start(form) }}

- {% if mode=="update" %} Modification CONFIGURATION - {% elseif mode=="submit" %} - Création CONFIGURATION - {% endif %}

{{ form_widget(form.submit) }} - Annuler - - {% if mode=="update" and not config.required %} - - Supprimer - + {% if mode=="profil" %} + Annuler + {% elseif mode=="update" %} + Annuler + {% else %} + Annuler {% endif %}

@@ -49,7 +42,7 @@
- {{ form_row(form.id) }} + {{ form_row(form.keyid) }} {{ form_row(form.value) }} {% if config.type=="logo" %}
diff --git a/templates/Config/list.html.twig b/templates/Config/list.html.twig index 41c5228..98318b7 100644 --- a/templates/Config/list.html.twig +++ b/templates/Config/list.html.twig @@ -9,43 +9,43 @@ CONFIGURATIONS

Générale

- {{ render(path("app_config_render",{category:"site"})) }} + {{ render(path("app_config_render",{mode:mode,category:"site",userid:-1})) }}

Couleurs des fonds de page

- {{ render(path("app_config_render",{category:"colorbgbody"})) }} + {{ render(path("app_config_render",{mode:mode,category:"colorbgbody",userid:-1})) }}

Polices

- {{ render(path("app_config_render",{category:"font"})) }} + {{ render(path("app_config_render",{mode:mode,category:"font",userid:-1})) }}

Couleurs des titres

- {{ render(path("app_config_render",{category:"colorfttitle"})) }} + {{ render(path("app_config_render",{mode:mode,category:"colorfttitle",userid:-1})) }}

Couleurs de la police

- {{ render(path("app_config_render",{category:"colorftbody"})) }} + {{ render(path("app_config_render",{mode:mode,category:"colorftbody",userid:-1})) }}

Logo

- {{ render(path("app_config_render",{category:"logo"})) }} + {{ render(path("app_config_render",{mode:mode,category:"logo",userid:-1})) }}

Social

- {{ render(path("app_config_render",{category:"social"})) }} + {{ render(path("app_config_render",{mode:mode,category:"social",userid:-1})) }}

Carrousel

- {{ render(path("app_config_render",{category:"hero"})) }} + {{ render(path("app_config_render",{mode:mode,category:"hero",userid:-1})) }}

Image

- {{ render(path("app_config_render",{category:"image"})) }} + {{ render(path("app_config_render",{mode:mode,category:"image",userid:-1})) }}
diff --git a/templates/Config/render.html.twig b/templates/Config/render.html.twig index e6a1e28..c01210e 100644 --- a/templates/Config/render.html.twig +++ b/templates/Config/render.html.twig @@ -13,11 +13,13 @@ {% if config.changeable %} - - {% endif %} - - {% if not config.required %} - + {% if mode=="profil" %} + + + {% else %} + + + {% endif %} {% endif %} {{config.title}} diff --git a/templates/Home/home.html.twig b/templates/Home/home.html.twig index b54fb63..5731e0f 100644 --- a/templates/Home/home.html.twig +++ b/templates/Home/home.html.twig @@ -76,9 +76,6 @@ - - - @@ -131,9 +128,6 @@ - - - @@ -149,15 +143,13 @@
-

{{ app.session.get("appname") }}

+

{{ (app.session.get("appname")) }}

{% if not app.session.get("appsubname") is empty %} {{ app.session.get("appsubname") }}
{% endif %} - -
{% if app.session.get('email') is not empty %} @@ -180,22 +172,38 @@
-
{% for category in categorys|sort((a, b) => a.order <=> b.order) %} {% if not category.illustrations is empty %} {{category.name}}
{% endif %} {% endfor %} + {% if not webzines is empty %} - Webzines
+ Webzines
{% endif %} - Liens
+ + {% if not links is empty %} + Liens
+ {% endif %} + Contact
-
+ +
+

Membres

+ {% for user in users %} + + {% endfor %} +
+ @@ -267,7 +275,6 @@ {% endfor %} - {% if not webzines is empty %}

Webzines

{% endif %} @@ -293,16 +300,18 @@ {% endfor %} - - -
-
+ {% if not webzines is empty %} + + +
+
-
- {% for link in links|sort((a, b) => a.order <=> b.order) %} - {{ link.name }} - {% endfor %} -
+
+ {% for link in links|sort((a, b) => a.order <=> b.order) %} + {{ link.name }} + {% endfor %} +
+ {% endif %}

Contact

diff --git a/templates/Home/user.html.twig b/templates/Home/user.html.twig new file mode 100644 index 0000000..12f6969 --- /dev/null +++ b/templates/Home/user.html.twig @@ -0,0 +1,496 @@ +{% extends "base.html.twig" %} + +{% block localstyle %} + #main { + padding: 0px; + display:none; + margin-bottom:200px; + } + + {% if app.session.get("appthumbfilter")=="1" %} + .cssfilter { + filter: grayscale({{app.session.get("appthumbfiltergrayscale")}}%) opacity({{app.session.get("appthumbfilteropacity")}}%) sepia({{app.session.get("appthumbfiltersepia")}}%); + transition: -webkit-filter 0.1s; + } + + .cssfilter:hover { + filter: unset; + -webkit-filter: unset; + -moz-filter: unset; + -o-filter: unset; + -ms-filter: unset; + + -webkit-transition: -webkit-filter 0.1s; + transition: -webkit-filter 0.1s; + } + {% endif %} + + {% for category in categorys|sort((a, b) => a.order <=> b.order) %} + {% if category.usecategoryconfig and category.appthumbfilter %} + .cssfilter-{{category.id}} { + filter: grayscale({{category.appthumbfiltergrayscale}}%) opacity({{category.appthumbfilteropacity}}%) sepia({{category.appthumbfiltersepia}}%); + transition: -webkit-filter 0.1s; + } + + .cssfilter-{{category.id}}:hover { + filter: unset; + -webkit-filter: unset; + -moz-filter: unset; + -o-filter: unset; + -ms-filter: unset; + + -webkit-transition: -webkit-filter 0.1s; + transition: -webkit-filter 0.1s; + } + {% endif %} + {% endfor %} +{% endblock %} + +{% block body %} + + + +
+ + +
+ Accueil  + {% for category in categorys|sort((a, b) => a.order <=> b.order) %} + {% if not category.illustrations is empty %} + {{category.name}}  + {% endif %} + {% endfor %} + {% if not webzines is empty %} + Webzines  + {% endif %} + Liens  + Contact  +
+ +
+ {% if app.user %} + + + + + {% if is_granted('ROLE_ADMIN') %} + + + + + + + {% endif %} + + + + {% else %} + + + + {% endif %} +
+
+ +
+ +
+ + +
+ {%if not config.hero01 is empty %} +
+ {%endif%} + + {%if not config.hero02 is empty %} +
+ {%endif%} + + {%if not config.hero03 is empty %} +
+ {%endif%} + + {%if not config.hero04 is empty %} +
+ {%endif%} + + {%if not config.hero05 is empty %} +
+ {%endif%} +
+ +
+ {% if app.user %} + + + + + {% if is_granted('ROLE_ADMIN') %} + + + + + + + {% endif %} + + + + {% else %} + + + + {% endif %} +
+
+
+

{{ (user.pseudo?user.pseudo:user.displayname) }}

+ +
+ {% if not config.appsubname is empty %} + {{ config.appsubname }}
+ {% endif %} + + + +
+ {% if user.email is not empty %} + + {% endif %} + {% if config.facebook is not empty %} + + {% endif %} + {% if config.instagram is not empty %} + + {% endif %} + {% if config.twitter is not empty %} + + {% endif %} + {% if config.google is not empty %} + + {% endif %} + {% if config.youtube is not empty %} + + {% endif %} + +
+ + +
+ Accueil
+ + {% for category in categorys|sort((a, b) => a.order <=> b.order) %} + {% if not category.illustrations is empty %} + {{category.name}}
+ {% endif %} + {% endfor %} + + {% if not webzines is empty %} + Webzines
+ {% endif %} + + {% if not links is empty %} + Liens
+ {% endif %} + + Contact
+
+ +
+
+ + + + {% set style="margin:30px" %} + {% if app.session.get("appmaxthumbwidth")!="0" %} + {% set style="max-width:"~app.session.get("appmaxthumbwidth")~"px; margin:30px auto;" %} + {% endif %} +
+
+
+ + {% for category in categorys|sort((a, b) => a.order <=> b.order) %} + {% if not category.illustrations is empty %} +

{{ category.name }}

+ {% for illustration in category.illustrations %} + {% set appthumbwidth=app.session.get("appthumbwidth") %} + {% set appthumbheight=app.session.get("appthumbheight") %} + {% if category.usecategoryconfig %} + {% set appthumbwidth=category.appthumbwidth %} + {% set appthumbheight=category.appthumbheight %} + {% endif %} + + {% if appthumbwidth==0 %} + {% set class="" %} + {% if loop.index < 40 %} + {% if loop.index == 1 %} + {% set class="grid-item-size-4" %} + {% elseif loop.index is divisible by(28) %} + {% set class="grid-item-size-4" %} + {% elseif loop.index is divisible by(7) %} + {% set class="grid-item-size-2" %} + {% elseif loop.index is divisible by(46) %} + {% set class="grid-item-size-4" %} + {% endif %} + {% elseif loop.index > 48 %} + {% if loop.index == 49 %} + {% set class="grid-item-size-4" %} + {% elseif (loop.index-49) is divisible by(28) %} + {% set class="grid-item-size-4" %} + {% elseif (loop.index-49) is divisible by(7) %} + {% set class="grid-item-size-2" %} + {% endif %} + {% endif %} + {% elseif appthumbwidth==1 %} {% set class="" %} + {% elseif appthumbwidth==2 %} {% set class="grid-item-size-2" %} + {% endif %} + + {%if appthumbheight==0 %} + {% set class=class~" grid-item-size-square" %} + {% elseif appthumbheight==1 %} + {% set class=class~" grid-item-size-proportion" %} + {% else %} + {% set class=class~" grid-item-size-page" %} + {% endif %} + + {% set source="thumb_"~illustration.illustration %} + {% if appthumbheight!=0 %} + {% set source="thumbori_"~illustration.illustration %} + {% endif %} + + +
+
+
+ {% endfor %} + {% endif %} + {% endfor %} + + + + {% if not webzines is empty %} +

Webzines

+ {% endif %} + + {% set setname="" %} + {% for webzine in webzines %} + {% if not webzine.webzinepages is empty %} + {% if setname!=webzine.set %} + {% if not webzine.set is empty %} +

{{webzine.set}}

+ {% endif %} + {% set setname=webzine.set %} + {% endif %} + {% set page=webzine.webzinepages[0] %} + {% set source="thumbori_"~page.illustration %} + {% set class=" grid-item-size-2 grid-item-size-page" %} + + +
+
+
+ {% endif %} + {% endfor %} + + + {% if not links is empty %} + + +
+
+ +
+ {% for link in links|sort((a, b) => a.order <=> b.order) %} + {{ link.name }} + {% endfor %} +
+ {%endif%} + + +

Contact

+ +
+ +
+ +
+

{{ user.pseudo }}

+ {% if not config.appsubname is empty %} + {{ config.appsubname }}
+ {%endif%} + {% if not config.appdescription is empty %} + +
{{ config.appdescription|raw }}

+ + {%endif%} + +
+ + {% if user.email is not empty %} + Email = {{ user.email }}
+ {% endif %} + {% if config.facebook is not empty %} + Facebook = {{ config.facebook }}
+ {% endif %} + {% if config.instagram is not empty %} + Instagram = {{ config.instagram }}
+ {% endif %} + {% if config.twitter is not empty %} + Twitter = {{ config.twitter }}
+ {% endif %} + {% if config.google is not empty %} + Google = {{ config.google }}
+ {% endif %} + {% if config.youtube is not empty %} + Youtube = {{ config.youtube }}
+ {% endif %} + +
+
+ + + +{% endblock %} + +{% block localjavascript %} +function getNoCacheBgElements() { + return document.querySelectorAll('.no-cache-bg'); +} + +function loadBgImageForElement(element) { + element.style['background-image'] = + 'url('+ element.attributes['data-background-image'].value + '?' + (new Date()).getTime() +')'; +} + +function loadBgImages() { + for( + var i = 0, elements = getNoCacheBgElements(); + i < elements.length; + loadBgImageForElement(elements[i]), i++ + ); +} + + +window.onload = function() { + loadBgImages(); +}; + + $(document).ready(function() { + $('body').imagesLoaded(function() { + height=Math.max(500,$(window).height()); + $('.heroheader').height(height); + $('.herologo').css({ top: (height-250) +'px' }); + + $('.heroheader').slick({ + slidesToShow: 1, + slidesToScroll: 1, + autoplay: true, + autoplaySpeed: 6000, + dots: true, + touchMove: false, + pauseOnDotsHover: true, + fade: true, + cssEase: 'linear', + prevArrow: false, + nextArrow: false, + customPaging: function(slider, i) { + return ''; + } + }); + + $("#main").show(); + + + resizeThumb(); + + + $('.grid').masonry({ + columnWidth: '.grid-sizer', + gutter: '.gutter-sizer', + itemSelector: '.grid-item', + percentPosition: true, + horizontalOrder: false, + }); + + if (location.hash) { + console.log(location.hash); + $(document).scrollTop( $(location.hash).offset().top -60); + // = location.hash; + } + }); + }); + + $(window).resize(function() { + $(window).scroll(); + height=Math.max(500,$(window).height()); + $('.heroheader').height(height); + $('.herologo').css({ top: (height-250) +'px' }); + resizeThumb(); + + }); + + $(window).scroll(function () { + if($(window).width()>=980) { + // set distance user needs to scroll before we start fadeIn + if ($(this).scrollTop() > 300) { + if($('.foliomenu').is(":hidden")) $('.foliomenu').show(); + } else { + if($('.foliomenu').is(":visible")) $('.foliomenu').hide(); + } + } + else { + if($('.foliomenu').is(":hidden")) $('.foliomenu').show(); + } + + if ($(this).scrollTop() > 300) { + if($('.foliotop').is(":hidden")) $('.foliotop').show(); + } else { + if($('.foliotop').is(":visible")) $('.foliotop').hide(); + } + }); + + function resizeThumb() { + {% if app.session.get("appmaxthumbwidth")!="0" %} + width=$(window).width(); + maxwidth={{ app.session.get("appmaxthumbwidth") }}; + + if(maxwidth+30>width) { + $(".grid").css("max-width","none"); + $(".grid").css("margin","30px"); + } + else { + $(".grid").css("max-width","{{ app.session.get("appmaxthumbwidth") }}px"); + $(".grid").css("margin","30px auto"); + } + {% endif %} + + $(".grid-item-size").each(function() { + if(!$(this).hasClass("grid-item-size-noresize")) { + if($(this).hasClass("grid-item-size-square")) { + $(this).height($(this).width()); + } + else if($(this).hasClass("grid-item-size-proportion")) { + var width=$(this).width(); + var oriwidth=$(this).data("width") + if(oriwidth>0) { + pourcentage=width*100/oriwidth; + height=$(this).data("height")*pourcentage/100; + $(this).height(height); + } + else { + $(this).height($(this).width()); + } + } + else { + $(this).height($(this).width()*30/21); + } + } + }); + } +{% endblock %} + + + + diff --git a/templates/User/edit.html.twig b/templates/User/edit.html.twig index 877e540..25b4fc0 100755 --- a/templates/User/edit.html.twig +++ b/templates/User/edit.html.twig @@ -15,7 +15,7 @@ {{ form_widget(form.submit) }} {% if mode=="profil" %} - Annuler + Annuler {% else %} Annuler {% endif %} @@ -61,7 +61,7 @@
-
+
Informations
@@ -73,25 +73,81 @@ {%endif%} {{ form_row(form.lastname) }} {{ form_row(form.firstname) }} + {{ form_row(form.pseudo) }} {{ form_row(form.email) }}
- {% if form.roles is defined %}
-
+ {% if form.roles is defined %} +
Organisation
-
- {{ form_row(form.groups) }} - {{ form_row(form.roles) }} -
+
+ {{ form_row(form.groups) }} + {{ form_row(form.roles) }} +
+ {%endif%} + + {%if mode!="submit" %} +
+
+ Ma Page +
+
+ {% if mode=="profil" %} + {{ render(path("app_config_user_render",{mode:mode,category:"site"})) }} + {% else %} + {{ render(path("app_config_render",{mode:mode,category:"site",userid:user.id})) }} + {% endif %} +
+
+ +
+
+ Social +
+
+ {% if mode=="profil" %} + {{ render(path("app_config_user_render",{mode:mode,category:"social"})) }} + {% else %} + {{ render(path("app_config_render",{mode:mode,category:"social",userid:user.id})) }} + {% endif %} +
+
+ +
+
+ Hero +
+
+ {% if mode=="profil" %} + {{ render(path("app_config_user_render",{mode:mode,category:"hero"})) }} + {% else %} + {{ render(path("app_config_render",{mode:mode,category:"hero",userid:user.id})) }} + {% endif %} +
+
+ +
+
+ Images +
+
+ {% if mode=="profil" %} + {{ render(path("app_config_user_render",{mode:mode,category:"image"})) }} + {% else %} + {{ render(path("app_config_render",{mode:mode,category:"image",userid:user.id})) }} + {% endif %} +
+
+ {% endif %} +
- {%endif%}
{{ form_end(form) }}