2016-07-12 10:06:46 +00:00
|
|
|
<?php
|
|
|
|
|
2016-10-18 14:03:03 +00:00
|
|
|
namespace viewer\view\group;
|
|
|
|
use \api\core\ModuleRequest;
|
|
|
|
use \api\core\Authentification;
|
2016-10-18 17:09:47 +00:00
|
|
|
use \error\core\Error;
|
2016-07-12 10:06:46 +00:00
|
|
|
|
2016-08-06 09:32:50 +00:00
|
|
|
class group_view{
|
2016-07-12 10:06:46 +00:00
|
|
|
|
2017-01-06 16:09:01 +00:00
|
|
|
public static function render(){
|
|
|
|
/* [1] Init Twig
|
2016-07-12 10:06:46 +00:00
|
|
|
=========================================================*/
|
2017-01-06 16:09:01 +00:00
|
|
|
$loader = new \Twig_Loader_Filesystem(__BUILD__.'/viewer/view');
|
|
|
|
$twig = new \Twig_Environment($loader, []);
|
|
|
|
|
2016-07-12 10:06:46 +00:00
|
|
|
|
2017-01-06 16:09:01 +00:00
|
|
|
/* [2] Store variables
|
2016-07-20 14:50:41 +00:00
|
|
|
=========================================================*/
|
2017-01-06 16:09:01 +00:00
|
|
|
$variables = [
|
|
|
|
'p_icon' => [
|
|
|
|
'remove' => file_get_contents( __PUBLIC__.'/src/static/sub-menu-side/remove.svg' ),
|
|
|
|
'edit' => file_get_contents( __PUBLIC__.'/src/static/sub-menu-side/edit.svg' ),
|
|
|
|
'type' => file_get_contents( __PUBLIC__.'/src/static/menu-side/type.svg' ),
|
|
|
|
'group' => file_get_contents( __PUBLIC__.'/src/static/container/group.svg' )
|
|
|
|
],
|
|
|
|
|
|
|
|
'p_theme' => $_SESSION['WAREHOUSE']['theme']
|
|
|
|
];
|
|
|
|
|
|
|
|
/* [3] Store functions
|
|
|
|
=========================================================*/
|
|
|
|
$twig->addFunction(new \Twig_Function('f_clusters', function($class){
|
|
|
|
/* (1) On récupère les groupes */
|
|
|
|
$getClustersReq = new ModuleRequest('clusterDefault/getAll', ['class' => $class]);
|
|
|
|
$getClusters = $getClustersReq->dispatch();
|
2016-07-20 14:50:41 +00:00
|
|
|
|
2017-01-06 16:09:01 +00:00
|
|
|
/* (2) si erreur, on retourne rien par défaut */
|
|
|
|
if( $getClusters->error != Error::Success )
|
|
|
|
return [];
|
2016-07-20 14:50:41 +00:00
|
|
|
|
2017-01-06 16:09:01 +00:00
|
|
|
/* (3) On enregistre le résultat */
|
|
|
|
return $getClusters->get('clusters');
|
|
|
|
}));
|
2016-07-20 14:50:41 +00:00
|
|
|
|
2017-01-06 16:09:01 +00:00
|
|
|
$twig->addFunction(new \Twig_Function('f_members', function($id_cluster, $class){
|
2016-07-20 14:50:41 +00:00
|
|
|
$membersReq = new ModuleRequest('clusterDefault/getMembers', [
|
2017-01-06 16:09:01 +00:00
|
|
|
'id_cluster' => (int) $id_cluster,
|
|
|
|
'class' => $class
|
2016-07-20 14:50:41 +00:00
|
|
|
]);
|
2017-01-06 16:09:01 +00:00
|
|
|
|
2016-07-12 10:06:46 +00:00
|
|
|
$membersRes = $membersReq->dispatch();
|
2017-01-06 16:09:01 +00:00
|
|
|
//
|
|
|
|
// si erreur, on affiche rien par défaut
|
|
|
|
if( $membersRes->error != Error::Success )
|
|
|
|
return [];
|
2016-07-12 10:06:46 +00:00
|
|
|
|
2017-01-06 16:09:01 +00:00
|
|
|
return $membersRes->get('members');
|
|
|
|
}));
|
2016-07-20 14:50:41 +00:00
|
|
|
|
|
|
|
|
2017-01-06 16:09:01 +00:00
|
|
|
/* [4] Build the whole stuff
|
2016-07-20 14:50:41 +00:00
|
|
|
=========================================================*/
|
2017-01-06 16:09:01 +00:00
|
|
|
return $twig->render('group/group_view.twig', [
|
|
|
|
'p_icon' => $variables['p_icon'],
|
|
|
|
'p_theme' => $variables['p_theme']
|
2016-07-12 10:06:46 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|