From 6517d7dca20cc35ba7c2fa9317cb0e4c33578f75 Mon Sep 17 00:00:00 2001 From: afornerot Date: Fri, 10 May 2019 13:59:52 +0200 Subject: [PATCH] icon user + cache flux --- .../CoreBundle/Command/PurgeFileCommand.php | 9 + .../src/Cadoles/CoreBundle/Entity/User.php | 42 +++ .../PortalBundle/Command/InitDataCommand.php | 24 +- .../Controller/BookmarkController.php | 15 +- .../Controller/IconController.php | 37 +- .../Controller/PagewidgetController.php | 342 ++++++++++++++---- .../src/Cadoles/PortalBundle/Entity/Icon.php | 31 ++ .../PortalBundle/Resources/config/routing.yml | 36 +- .../Resources/views/Bookmark/edit.html.twig | 19 +- .../Resources/views/Icon/edit.html.twig | 7 +- .../Resources/views/Icon/list.html.twig | 10 +- .../Resources/views/Pagewidget/edit.html.twig | 19 +- .../views/Pagewidget/viewalert.html.twig | 6 +- .../views/Pagewidget/viewblog.html.twig | 6 +- .../views/Pagewidget/viewbookmark.html.twig | 6 +- .../views/Pagewidget/viewcalendar.html.twig | 6 +- .../views/Pagewidget/vieweditor.html.twig | 6 +- .../views/Pagewidget/viewfile.html.twig | 6 +- .../views/Pagewidget/viewflux.html.twig | 34 +- .../views/Pagewidget/viewframe.html.twig | 6 +- .../views/Pagewidget/viewgalery.html.twig | 6 +- .../views/Pagewidget/viewitem.html.twig | 6 +- .../views/Pagewidget/viewlink.html.twig | 10 +- .../views/Pagewidget/viewseparator.html.twig | 6 +- .../views/Pagewidget/viewurl.html.twig | 10 +- 25 files changed, 571 insertions(+), 134 deletions(-) diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/PurgeFileCommand.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/PurgeFileCommand.php index 33c4805e..70650395 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/PurgeFileCommand.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Command/PurgeFileCommand.php @@ -305,6 +305,15 @@ class PurgeFileCommand extends Command } } } + + // /web/uploads/ckeditor + $this->writelnred(''); + $this->writelnred('== Directory = Flux'); + $directory=$this->container->get('kernel')->getRootDir()."/../web/uploads/flux"; + $fs = new Filesystem(); + $fs->remove($directory); + + $this->writeln(''); return 1; diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/User.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/User.php index f291e95d..771d2bc6 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/User.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/User.php @@ -237,6 +237,13 @@ class User implements UserInterface, \Serializable */ private $blogarticles; + /** + * @var ArrayCollection $icon + * @var Icon + * + * @ORM\OneToMany(targetEntity="Cadoles\PortalBundle\Entity\Icon", mappedBy="user", cascade={"persist"}, orphanRemoval=true) + */ + private $icons; //== CODE A NE PAS REGENERER /** @@ -334,6 +341,7 @@ class User implements UserInterface, \Serializable $this->blogs = new \Doctrine\Common\Collections\ArrayCollection(); $this->blogwriters = new \Doctrine\Common\Collections\ArrayCollection(); $this->blogarticles = new \Doctrine\Common\Collections\ArrayCollection(); + $this->icons = new \Doctrine\Common\Collections\ArrayCollection(); } /** @@ -1255,4 +1263,38 @@ class User implements UserInterface, \Serializable { return $this->blogarticles; } + + /** + * Add icon + * + * @param \Cadoles\PortalBundle\Entity\Icon $icon + * + * @return User + */ + public function addIcon(\Cadoles\PortalBundle\Entity\Icon $icon) + { + $this->icons[] = $icon; + + return $this; + } + + /** + * Remove icon + * + * @param \Cadoles\PortalBundle\Entity\Icon $icon + */ + public function removeIcon(\Cadoles\PortalBundle\Entity\Icon $icon) + { + $this->icons->removeElement($icon); + } + + /** + * Get icons + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getIcons() + { + return $this->icons; + } } diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php index c08fedc6..19ff8598 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php @@ -333,7 +333,7 @@ class InitDataCommand extends ContainerAwareCommand $em->persist($entityWidget); } - // Widget Calendrier + // Widget Blog $entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1890); if(!$entityWidget) { $entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_rocket.png"]); @@ -355,6 +355,28 @@ class InitDataCommand extends ContainerAwareCommand $em->persist($entityWidget); } + // Widget RSS + $entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1880); + if(!$entityWidget) { + $entityicon = $em->getRepository('CadolesPortalBundle:Icon')->findoneby(["label"=>"uploads/icon/icon_rss.png"]); + + $entityWidget = new Widget(); + $entityWidget->setId(-1880); + $entityWidget->setRoworder(13); + $entityWidget->setIcon($entityicon); + $entityWidget->setName('RSS'); + $entityWidget->setDescription("Afficher un flux RSS spécifique"); + $entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_rss"); + $entityWidget->setHeight("630"); + $entityWidget->setAutoajust(true); + $entityWidget->setBorder(true); + + $parameter = json_decode('{"fields": [{"id": "url", "loc": "col1", "type": "string", "label": "URL du Flux RSS", "value": "", "mandatory": "true"},{"id": "nbarticle", "loc": "col1", "type": "integer", "label": "Nombre d\'articles affichés", "value": "10", "mandatory": "true"}]}'); + $entityWidget->setParameter($parameter); + + $em->persist($entityWidget); + } + // Widget Séparateur $entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1600); if(!$entityWidget) { diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/BookmarkController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/BookmarkController.php index 6a630740..651e3865 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/BookmarkController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/BookmarkController.php @@ -63,12 +63,17 @@ class BookmarkController extends Controller return $this->redirect($this->generateUrl('cadoles_portal_'.$access.'_page_view',["id"=>$idpage])); } + $icons=$this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findBy(["user"=>null]); + $iconsuser=null; + if($access=="user") $iconsuser=$this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findBy(["user"=>$this->getUser()]); + return $this->render($this->labelentity.':edit.html.twig', [ 'useheader' => ($access=="config"), 'usemenu' => false, 'usesidebar' => ($access=="config"), 'entity' => $data, - 'icons' => $this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findAll(), + 'icons' => $icons, + 'iconsuser' => $iconsuser, 'mode' => "submit", 'access' => $access, 'idpage' => $idpage, @@ -122,14 +127,18 @@ class BookmarkController extends Controller return $this->redirect($this->generateUrl('cadoles_portal_'.$access.'_page_view',["id"=>$idpage])); } - + $icons=$this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findBy(["user"=>null]); + $iconsuser=null; + if($access=="user") $iconsuser=$this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findBy(["user"=>$this->getUser()]); + // Affichage du formulaire return $this->render($this->labelentity.':edit.html.twig', [ 'useheader' => ($access=="config"), 'usemenu' => false, 'usesidebar' => ($access=="config"), 'entity' => $data, - 'icons' => $this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findAll(), + 'icons' => $icons, + 'iconsuser' => $iconsuser, 'mode' => "update", 'access' => $access, 'idpage' => $idpage, diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/IconController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/IconController.php index 45f9e862..8bf0b316 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/IconController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/IconController.php @@ -19,18 +19,24 @@ class IconController extends Controller private $labeldata = 'icon'; private $labeldatas = 'icons'; - public function listAction() + public function listAction($access="config") { + $em = $this->getDoctrine()->getManager(); + if($access=="config") + $icons=$this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findBy(["user"=>null]); + else + $icons=$this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findBy(["user"=>$this->getUser()]); return $this->render($this->labelentity.':list.html.twig',[ 'useheader' => true, 'usemenu' => false, - 'usesidebar' => true, - $this->labeldatas => $this->getDatas() + 'usesidebar' => ($access=="config"), + 'access' => $access, + $this->labeldatas => $icons ]); } - public function submitAction(Request $request) + public function submitAction(Request $request,$access="config") { // Initialisation de l'enregistrement $data = new Icon(); @@ -47,6 +53,8 @@ class IconController extends Controller // Sur validation if ($form->get('submit')->isClicked() && $form->isValid()) { $data = $form->getData(); + if($access=="user") $data->setUser($this->getUser()); + $em = $this->getDoctrine()->getManager(); // Sauvegarde @@ -54,21 +62,22 @@ class IconController extends Controller $em->flush(); // Retour à la liste - return $this->redirectToRoute($this->labelroute); + return $this->redirectToRoute('cadoles_portal_'.$access.'_icon'); } // Affichage du formulaire return $this->render($this->labelentity.':edit.html.twig', [ 'useheader' => true, 'usemenu' => false, - 'usesidebar' => true, + 'usesidebar' => ($access=="config"), + 'access' => $access, $this->labeldata => $data, 'mode' => 'submit', - 'form' => $form->createView() + 'form' => $form->createView(), ]); } - public function updateAction($id,Request $request) + public function updateAction($id,Request $request,$access="config") { // Récupération de l'enregistrement courant $data=$this->getData($id); @@ -94,7 +103,7 @@ class IconController extends Controller $em->flush(); // Retour à la liste - return $this->redirectToRoute($this->labelroute); + return $this->redirectToRoute('cadoles_portal_'.$access.'_icon'); } @@ -102,14 +111,16 @@ class IconController extends Controller return $this->render($this->labelentity.':edit.html.twig', [ 'useheader' => true, 'usemenu' => false, - 'usesidebar' => true, + 'usesidebar' => ($access=="config"), + 'access' => $access, $this->labeldata => $data, 'mode' => 'update', - 'form' => $form->createView() + 'form' => $form->createView(), + 'refresh' => false, ]); } - public function deleteAction($id,Request $request) + public function deleteAction($id,Request $request,$access="config") { // Récupération de l'enregistrement courant $data=$this->getData($id); @@ -121,7 +132,7 @@ class IconController extends Controller $em->remove($data); $em->flush(); - return $this->redirectToRoute($this->labelroute); + return $this->redirectToRoute('cadoles_portal_'.$access.'_icon'); } diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php index 7e31a260..d27ee97f 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php @@ -130,13 +130,18 @@ class PagewidgetController extends Controller return $this->redirect($this->generateUrl('cadoles_core_home',["id"=>$idpage])); } + $icons=$this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findBy(["user"=>null]); + $iconsuser=null; + if($access=="user") $iconsuser=$this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findBy(["user"=>$this->getUser()]); + return $this->render($this->labelentity.':edit.html.twig', [ 'useheader' => true, 'usemenu' => false, 'usesidebar' => ($access=="config"), 'maxwidth' => ($access=="user"), 'entity' => $entity, - 'icons' => $this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findAll(), + 'icons' => $icons, + 'iconsuser' => $iconsuser, 'mode' => "submit", 'access' => $access, 'idpage' => $idpage, @@ -191,13 +196,18 @@ class PagewidgetController extends Controller return $this->redirect($this->generateUrl('cadoles_portal_'.$access.'_page_view',["id"=>$idpage])); } + $icons=$this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findBy(["user"=>null]); + $iconsuser=null; + if($access=="user") $iconsuser=$this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findBy(["user"=>$this->getUser()]); + return $this->render($this->labelentity.':edit.html.twig', [ 'useheader' => ($access=="config"), 'usemenu' => false, 'usesidebar' => ($access=="config"), 'maxwidth' => ($access=="user"), 'entity' => $entity, - 'icons' => $this->getDoctrine()->getRepository("CadolesPortalBundle:Icon")->findAll(), + 'icons' => $icons, + 'iconsuser' => $iconsuser, 'mode' => "update", 'access' => $access, 'idpage' => $idpage, @@ -633,78 +643,110 @@ class PagewidgetController extends Controller $feedIo = new \FeedIo\FeedIo($client, $logger); $feeds=array(); - + $filesystem = new Filesystem(); foreach($fluxsordered as $flux) { // On regarde si le flux a été lu il y a peu - - // On lit le flux rss - $result = $feedIo->read($flux->getUrl()); - $feedtitle = $result->getFeed()->getTitle(); - - // Pour chaque articles - $nbflux=0; - foreach ($result->getFeed() as $item) { - $title = $item->getTitle(); - $link = $item->getLink(); - $description = substr(strip_tags($item->getDescription()),0,250); - $description = str_replace("¶","",$description); - $date = $item->getLastModified(); - $dateformat = $item->getLastModified()->format('d/m/Y H:i:s'); - $content = $item->getDescription(); - $media = $item->getMedias(); - $mediaurl = ""; - - foreach ($item->getMedias() as $itemMedia) { - if($itemMedia->getType()=="image/jpeg") - $mediaurl=$itemMedia->getUrl(); - } - - foreach ($item->getAllElements() as $element) { - - if($element->getName()=="content:encoded") - $content = $element->getValue(); - } - - if($mediaurl!="") { - $imgurl=$mediaurl; - } - else { - // Récupérer la première image du contenu - $imgcontent=""; - $imgurl=""; - $imgstart = stripos($content,"",$imgstart); - $imgcontent=substr($content,$imgstart,$imgend-$imgstart+1); - - $imgstart = stripos($imgcontent,"src="); - $imgurl=substr($imgcontent,$imgstart+5); - $imgend = stripos($imgurl,'"'); - - if($imgend===false) $imgend = stripos($imgurl,"'"); - $imgurl=substr($imgurl,0,$imgend); - } - } - - // Garder le flux - if($nbflux<26) { - array_push($feeds,array( - "feedtitle" => $feedtitle, - "title" => $title, - "link" => $link, - "description" => $description, - "date" => $date, - "dateformat" => $dateformat, - "content" => $content, - "image" => $imgurl, - "color" => $flux->getColor(), - "fluxid" => $flux->getId(), - )); + $toregen=true; + + if($filesystem->exists('uploads/flux/flux-'.$flux->getId().'.txt')) { + // On récupère la date de modification du fichier + $timestampfile = filemtime('uploads/flux/flux-'.$flux->getId().'.txt'); + $datetimeFormat = 'Y-m-d H:i:s'; + $datefile = new \DateTime(); + $datefile->setTimestamp($timestampfile); + + // On ajoute 30mn + $datefile->add(new \DateInterval('PT30M')); + + // Si la date est inférieur à maintenant on regénère le flux + $now = new \DateTime(); + if($datefile>=$now) { + $toregen=false; + $backup = unserialize(file_get_contents('uploads/flux/flux-'.$flux->getId().'.txt')); + $feeds=array_merge($feeds,$backup); } - $nbflux++; - if($nbflux>=$flux->getMaxread()) break; - } + } + + // Si le fichier est trop ancien on relit le flus + if($toregen) { + // On lit le flux rss + $result = $feedIo->read($flux->getUrl()); + $feedtitle = $result->getFeed()->getTitle(); + + + $backup=[]; + + // Pour chaque articles + $nbflux=0; + foreach ($result->getFeed() as $item) { + $title = $item->getTitle(); + $link = $item->getLink(); + $description = substr(strip_tags($item->getDescription()),0,250); + $description = str_replace("¶","",$description); + $date = $item->getLastModified(); + $dateformat = ($date?$item->getLastModified()->format('d/m/Y H:i:s'):""); + $content = $item->getDescription(); + $media = $item->getMedias(); + $mediaurl = ""; + + foreach ($item->getMedias() as $itemMedia) { + if($itemMedia->getType()=="image/jpeg") + $mediaurl=$itemMedia->getUrl(); + } + + foreach ($item->getAllElements() as $element) { + + if($element->getName()=="content:encoded") + $content = $element->getValue(); + } + + if($mediaurl!="") { + $imgurl=$mediaurl; + } + else { + // Récupérer la première image du contenu + $imgcontent=""; + $imgurl=""; + $imgstart = stripos($content,"",$imgstart); + $imgcontent=substr($content,$imgstart,$imgend-$imgstart+1); + + $imgstart = stripos($imgcontent,"src="); + $imgurl=substr($imgcontent,$imgstart+5); + $imgend = stripos($imgurl,'"'); + + if($imgend===false) $imgend = stripos($imgurl,"'"); + $imgurl=substr($imgurl,0,$imgend); + } + } + + // Garder le flux + + $tmp=array( + "feedtitle" => $feedtitle, + "title" => $title, + "link" => $link, + "description" => $description, + "date" => $date, + "dateformat" => $dateformat, + "content" => $content, + "image" => $imgurl, + "color" => "", + "fluxid" => $flux->getId(), + ); + + array_push($feeds,$tmp); + array_push($backup,$tmp); + + $nbflux++; + if($nbflux>=$flux->getMaxread()) break; + } + + // On sauvegarde le résultat en fichier on rechargera son contenu que s'il n'a pas été lu depuis 30mn + $filesystem->dumpFile('uploads/flux/flux-'.$flux->getId().'.txt', serialize($backup)); + } } $libelle=array(); @@ -724,6 +766,166 @@ class PagewidgetController extends Controller } + public function viewrssAction($id,$access="config") { + $em = $this->getDoctrine()->getManager(); + $entity = $em->getRepository($this->labelentity)->find($id); + if (!$entity) throw $this->createNotFoundException('Unable to find entity.'); + + // Permissions + if($access=="config") { + $canupdate = true; + } + else { + // On s'assure que l'utilisateur à la permission de voir + $page=$entity->getPage(); + $em->getRepository("CadolesPortalBundle:Page")->getPermission($this->getUser(),$page,$cansee,$canupdate); + if(!$cansee) throw $this->createNotFoundException('Permission denied'); + } + + // Récupération des paramétres du widget + $url=""; + $nbarticle="_blank"; + foreach($entity->getParameter()["fields"] as $parameter) { + switch($parameter["id"]) { + case "url": + $url=$parameter["value"]; + break; + case "nbarticle": + $nbarticle=$parameter["value"]; + break; + } + } + + // On regarde si le flux a été lu il y a peu + $toregen=true; + + $filesystem = new Filesystem(); + if($filesystem->exists('uploads/flux/widget-'.$id.'.txt')) { + // On récupère la date de modification du fichier + $timestampfile = filemtime('uploads/flux/widget-'.$id.'.txt'); + $datetimeFormat = 'Y-m-d H:i:s'; + $datefile = new \DateTime(); + $datefile->setTimestamp($timestampfile); + + // On ajoute 30mn + $datefile->add(new \DateInterval('PT30M')); + + // Si la date est inférieur à maintenant on regénère le flux + $now = new \DateTime(); + if($datefile>=$now) { + $toregen=false; + $feeds = unserialize(file_get_contents('uploads/flux/widget-'.$id.'.txt')); + } + } + + // Si le fichier est trop ancien on relit le flus + if($toregen) { + // Connexion au client + $PROXYactivate = $em->getRepository("CadolesCoreBundle:Config")->find("PROXYactivate")->getValue(); + + if($PROXYactivate) { + $PROXYserver = $em->getRepository("CadolesCoreBundle:Config")->find("PROXYserver")->getValue(); + $PROXYport = $em->getRepository("CadolesCoreBundle:Config")->find("PROXYport")->getValue(); + $clientguzzle = new \GuzzleHttp\Client(array('proxy' => ['http' => 'tcp://'.$PROXYserver.':'.$PROXYport,'https' => 'tcp://'.$PROXYserver.':'.$PROXYport])); + } + else + $clientguzzle = new \GuzzleHttp\Client(); + + $client = new \FeedIo\Adapter\Guzzle\Client($clientguzzle); + $logger = new \Psr\Log\NullLogger(); + $feedIo = new \FeedIo\FeedIo($client, $logger); + + $feeds=array(); + + + + // On lit le flux rss + $result = $feedIo->read($url); + $feedtitle = $result->getFeed()->getTitle(); + + // Pour chaque articles + $nbflux=0; + foreach ($result->getFeed() as $item) { + $title = $item->getTitle(); + $link = $item->getLink(); + $description = substr(strip_tags($item->getDescription()),0,250); + $description = str_replace("¶","",$description); + $date = $item->getLastModified(); + $dateformat = ($date?$item->getLastModified()->format('d/m/Y H:i:s'):""); + $content = $item->getDescription(); + $media = $item->getMedias(); + $mediaurl = ""; + + foreach ($item->getMedias() as $itemMedia) { + if($itemMedia->getType()=="image/jpeg") + $mediaurl=$itemMedia->getUrl(); + } + + foreach ($item->getAllElements() as $element) { + if($element->getName()=="content:encoded") + $content = $element->getValue(); + } + + if($mediaurl!="") { + $imgurl=$mediaurl; + } + else { + // Récupérer la première image du contenu + $imgcontent=""; + $imgurl=""; + $imgstart = stripos($content,"",$imgstart); + $imgcontent=substr($content,$imgstart,$imgend-$imgstart+1); + + $imgstart = stripos($imgcontent,"src="); + $imgurl=substr($imgcontent,$imgstart+5); + $imgend = stripos($imgurl,'"'); + + if($imgend===false) $imgend = stripos($imgurl,"'"); + $imgurl=substr($imgurl,0,$imgend); + } + } + + // Garder le flux + array_push($feeds,array( + "feedtitle" => $feedtitle, + "title" => $title, + "link" => $link, + "description" => $description, + "date" => $date, + "dateformat" => $dateformat, + "content" => $content, + "image" => $imgurl, + // "color" => $flux->getColor(), + "fluxid" => 0, + )); + + $nbflux++; + if($nbflux>=$nbarticle) break; + } + + + $libelle=array(); + foreach ($feeds as $key => $valeur) { + $libelle[$key] = $valeur["date"]; + } + array_multisort($libelle, SORT_DESC, $feeds); + + // On sauvegarde le résultat en fichier on rechargera son contenu que s'il n'a pas été lu depuis 30mn + $filesystem->dumpFile('uploads/flux/widget-'.$id.'.txt', serialize($feeds)); + } + + // Render + return $this->render($this->labelentity.':viewflux.html.twig', [ + 'entity' => $entity, + 'canupdate' => $canupdate, + //'fluxs' => $fluxsordered, + 'access' => $access, + 'feeds' => $feeds, + ]); + } + public function viewbookmarkAction($id,$access="config") { $em = $this->getDoctrine()->getManager(); $entity = $em->getRepository($this->labelentity)->find($id); diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Icon.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Icon.php index b38e5d06..0d8a4cb5 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Icon.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Icon.php @@ -27,6 +27,12 @@ class Icon */ private $label; + /** + * @ORM\ManyToOne(targetEntity="Cadoles\CoreBundle\Entity\User", inversedBy="icons") + * @ORM\JoinColumn(nullable=true) + */ + private $user; + /** * @var ArrayCollection $items * @var Item @@ -61,6 +67,7 @@ class Icon private $bookmarks; + /** * Constructor */ @@ -106,6 +113,30 @@ class Icon return $this->label; } + /** + * Set user + * + * @param \Cadoles\CoreBundle\Entity\User $user + * + * @return Icon + */ + public function setUser(\Cadoles\CoreBundle\Entity\User $user = null) + { + $this->user = $user; + + return $this; + } + + /** + * Get user + * + * @return \Cadoles\CoreBundle\Entity\User + */ + public function getUser() + { + return $this->user; + } + /** * Add item * diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml index e650a1be..40469018 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/config/routing.yml @@ -2,25 +2,43 @@ #== ICON ================================================================================================================================================= cadoles_portal_config_icon: path: /config/icon - defaults: { _controller: CadolesPortalBundle:Icon:list } + defaults: { _controller: CadolesPortalBundle:Icon:list, access: config } cadoles_portal_config_icon_submit: path: /config/icon/submit - defaults: { _controller: CadolesPortalBundle:Icon:submit } + defaults: { _controller: CadolesPortalBundle:Icon:submit, access: config } cadoles_portal_config_icon_update: path: /config/icon/update/{id} - defaults: { _controller: CadolesPortalBundle:Icon:update } + defaults: { _controller: CadolesPortalBundle:Icon:update, access: config } cadoles_portal_config_icon_delete: path: /config/icon/delete/{id} - defaults: { _controller: CadolesPortalBundle:Icon:delete } + defaults: { _controller: CadolesPortalBundle:Icon:delete, access: config } cadoles_portal_config_icon_icon: path: /config/icon/icon - defaults: { _controller: CadolesPortalBundle:Icon:icon } + defaults: { _controller: CadolesPortalBundle:Icon:icon, access: config } +cadoles_portal_user_icon: + path: /user/icon + defaults: { _controller: CadolesPortalBundle:Icon:list, access: user } +cadoles_portal_user_icon_submit: + path: /user/icon/submit + defaults: { _controller: CadolesPortalBundle:Icon:submit, access: user } + +cadoles_portal_user_icon_update: + path: /user/icon/update/{id} + defaults: { _controller: CadolesPortalBundle:Icon:update, access: user } + +cadoles_portal_user_icon_delete: + path: /user/icon/delete/{id} + defaults: { _controller: CadolesPortalBundle:Icon:delete, access: user } + +cadoles_portal_user_icon_icon: + path: /user/icon/icon + defaults: { _controller: CadolesPortalBundle:Icon:icon, access: user } #== ITEM ================================================================================================================================================= @@ -595,6 +613,10 @@ cadoles_portal_config_panelwidget_view_flux: path: /config/pagewidget/view/flux/{id} defaults: { _controller: CadolesPortalBundle:Pagewidget:viewflux, access: config } +cadoles_portal_config_panelwidget_view_rss: + path: /config/pagewidget/view/rss/{id} + defaults: { _controller: CadolesPortalBundle:Pagewidget:viewrss, access: config } + cadoles_portal_config_panelwidget_view_bookmark: path: /pagewidget/view/bookmark/{id} defaults: { _controller: CadolesPortalBundle:Pagewidget:viewbookmark, access: config } @@ -677,6 +699,10 @@ cadoles_portal_user_panelwidget_view_flux: path: /pagewidget/view/flux/{id} defaults: { _controller: CadolesPortalBundle:Pagewidget:viewflux, access: user } +cadoles_portal_user_panelwidget_view_rss: + path: /pagewidget/view/rss/{id} + defaults: { _controller: CadolesPortalBundle:Pagewidget:viewrss, access: user } + cadoles_portal_user_panelwidget_view_bookmark: path: /pagewidget/view/bookmark/{id} defaults: { _controller: CadolesPortalBundle:Pagewidget:viewbookmark, access: user } diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Bookmark/edit.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Bookmark/edit.html.twig index d02cf7f6..325b4c73 100755 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Bookmark/edit.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Bookmark/edit.html.twig @@ -59,7 +59,7 @@ {{ form_row(form.target) }} {{ form_row(form.color) }} -
+
{% if entity.icon %} {% endif %} @@ -85,11 +85,24 @@
Annuler + {% if access=="user" %} + Gérer mes Icônes + {% endif %}
+ {% if iconsuser is not empty %} +

Mes Icônes

+ {% for icon in iconsuser %} + + + + {% endfor %} + +

Icônes Communs

+ {% endif %} {% for icon in icons %} - + {% endfor %} @@ -98,7 +111,7 @@
-
+ {{ form_end(form) }} {% endblock %} diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/edit.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/edit.html.twig index 134e94f3..06629d1c 100755 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/edit.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/edit.html.twig @@ -11,19 +11,18 @@ {{ form_widget(form.submit) }} - Annuler + Annuler {% if mode=="update" %} - - Supprimer + Supprimer {% endif %}

- {% if app.session.flashbag.has('error') %}
Erreur
diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/list.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/list.html.twig index 2e9189e7..035596db 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/list.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Icon/list.html.twig @@ -3,11 +3,13 @@ {% block pagewrapper %}

Gestion des Icônes

-

Ajouter

+

Ajouter

- {% for icon in icons %} - - {% endfor %} +
+ {% for icon in icons %} + + {% endfor %} +
{% endblock %} diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/edit.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/edit.html.twig index 9a9c7be8..be8581ff 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/edit.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/edit.html.twig @@ -94,13 +94,24 @@ diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewseparator.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewseparator.html.twig index 4f84963c..9bd622c1 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewseparator.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewseparator.html.twig @@ -28,7 +28,11 @@
{% if seeicon %} - + {% if entity.icon %} + + {% else %} + + {% endif %} {% endif %} {% if seetitle %} diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewurl.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewurl.html.twig index 3d3d269b..05d8bec1 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewurl.html.twig +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Pagewidget/viewurl.html.twig @@ -22,7 +22,11 @@ {% if imagemedia %} {% if entity.autoajust %}
+ {% if entity.icon %} + {% else %} + + {% endif %} {{ entity.name }}
@@ -33,7 +37,11 @@ {% endif %} {% else %}
- + {% if entity.icon %} + + {% else %} + + {% endif %} {{ entity.name }}