From 688bd52ff29974e8a4a367c0d6d861ca8775dd38 Mon Sep 17 00:00:00 2001 From: afornerot Date: Fri, 4 Sep 2020 10:09:30 +0200 Subject: [PATCH] ajout widget urlfixe --- .../PortalBundle/Command/InitDataCommand.php | 6 +- .../Controller/PagewidgetController.php | 58 ++++++++++++++++++- .../PortalBundle/Resources/config/routing.yml | 8 +++ 3 files changed, 67 insertions(+), 5 deletions(-) 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 e4f60cd2..a02da500 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Command/InitDataCommand.php @@ -1377,7 +1377,7 @@ class InitDataCommand extends ContainerAwareCommand $entityWidget->setParameter($parameter); $em->persist($entityWidget); - // Onlyoffice document + // Roundcube $entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find(-1790); if($activate_widroundcube) { if(!$entityWidget) $entityWidget = new Widget(); @@ -1387,13 +1387,13 @@ class InitDataCommand extends ContainerAwareCommand $entityWidget->setIcon($entityicon); $entityWidget->setName('Roundcube'); $entityWidget->setDescription("Webmail"); - $entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_url"); + $entityWidget->setRouteview("cadoles_portal_config_panelwidget_view_urlfixe"); $entityWidget->setHeight("630"); $entityWidget->setAutoajust(false); $entityWidget->setBorder(true); $entityWidget->setOpened(true); $entityWidget->setAccess(["config","user","group"]); - $parameter = json_decode('{"fields": [{"id": "url", "loc": "col1", "type": "string", "label": "URL", "value": "'.$widroundcube_url.'", "mandatory": "true"}]}'); + $parameter = json_decode('{"fields": [{"id": "url", "loc": "col1", "type": "hidden", "label": "URL", "value": "'.$widroundcube_url.'", "mandatory": "true"}]}'); $entityWidget->setParameter($parameter); $em->persist($entityWidget); } 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 5bd24fbb..e5dfeb79 100644 --- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php +++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/PagewidgetController.php @@ -125,7 +125,7 @@ class PagewidgetController extends Controller foreach($jsons->fields as $field) { $tmp=array(); $tmp["id"]=$field->id; - $tmp["value"]=$form->get($field->id)->getData(); + $tmp["value"]=($field->type!="hidden"?$form->get($field->id)->getData():""); array_push($param["fields"],$tmp); } @@ -216,7 +216,7 @@ class PagewidgetController extends Controller $tmp=array(); $tmp["id"]=$field->id; - $tmp["value"]=$form->get($field->id)->getData(); + $tmp["value"]=($field->type!="hidden"?$form->get($field->id)->getData():""); array_push($param["fields"],$tmp); } @@ -436,6 +436,60 @@ class PagewidgetController extends Controller ]); } + public function viewurlfixeAction($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'); + } + + $url=""; + $widgettype= $entity->getWidget(); + $jsons=$widgettype->getParameter(); + $param=array(); + $param["fields"]=array(); + foreach($jsons->fields as $field) { + if($field->id=="url") + $url=$field->value; + } + + // Gestion des url youtuve + $url=str_replace("http://www.youtube.com","https://www.youtube.com",$url); + $url=str_replace("https://www.youtube.com/watch?v=","https://www.youtube.com/embed/",$url); + + // Detecter le type de lien + $imagemedia=false; + $pathinfo = pathinfo($url); + + // Type image + if(array_key_exists("extension",$pathinfo)) { + if($pathinfo['extension']=="jpg"||$pathinfo['extension']=="gif"||$pathinfo['extension']=="png") { + $imagemedia=true; + } + } + + // Spécifique Deviant Art + if(strpos($url, "images-wixmp") !== false) $imagemedia=true; + + + return $this->render($this->labelentity.':viewurl.html.twig', [ + 'entity' => $entity, + 'canupdate' => $canupdate, + 'url' => $url, + 'imagemedia' => $imagemedia, + 'access' => $access + ]); + } + public function viewitemAction($id,$access="config") { $em = $this->getDoctrine()->getManager(); $entity = $em->getRepository($this->labelentity)->find($id); 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 d51f87ff..c7e04063 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 @@ -929,6 +929,10 @@ cadoles_portal_config_panelwidget_view_url: path: /config/pagewidget/view/url/{id} defaults: { _controller: CadolesPortalBundle:Pagewidget:viewurl, access: config } +cadoles_portal_config_panelwidget_view_urlfixe: + path: /config/pagewidget/view/urlfixe/{id} + defaults: { _controller: CadolesPortalBundle:Pagewidget:viewurlfixe, access: config } + cadoles_portal_config_panelwidget_view_item: path: /config/pagewidget/view/item/{id} defaults: { _controller: CadolesPortalBundle:Pagewidget:viewitem, access: config } @@ -1046,6 +1050,10 @@ cadoles_portal_user_panelwidget_view_url: path: /pagewidget/view/url/{id} defaults: { _controller: CadolesPortalBundle:Pagewidget:viewurl, access: user } +cadoles_portal_user_panelwidget_view_urlfixe: + path: /pagewidget/view/urlfixe/{id} + defaults: { _controller: CadolesPortalBundle:Pagewidget:viewurlfixe, access: user } + cadoles_portal_user_panelwidget_view_item: path: /pagewidget/view/item/{id} defaults: { _controller: CadolesPortalBundle:Pagewidget:viewitem, access: user }