ajout widget urlfixe
This commit is contained in:
parent
c05d21545d
commit
688bd52ff2
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 }
|
||||
|
|
Loading…
Reference in New Issue