70 lines
2.0 KiB
PHP
Executable File
70 lines
2.0 KiB
PHP
Executable File
<?php
|
|
|
|
namespace viewer\view\user;
|
|
use \api\core\ModuleRequest;
|
|
use \api\core\Authentification;
|
|
use \error\core\Error;
|
|
|
|
class view{
|
|
|
|
public static function render(){
|
|
/* [1] Init Twig
|
|
=========================================================*/
|
|
$loader = new \Twig_Loader_Filesystem(__BUILD__.'/viewer/view');
|
|
$twig = new \Twig_Environment($loader, []);
|
|
|
|
|
|
/* [2] Store variables
|
|
=========================================================*/
|
|
$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' ),
|
|
'card' => file_get_contents( __PUBLIC__.'/src/static/container/card.svg' ),
|
|
'mail' => file_get_contents( __PUBLIC__.'/src/static/container/mail.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_users', function(){
|
|
|
|
$request = new ModuleRequest('userDefault/getAll'); // On utilise la methode 'getAll' du module 'userDefault'
|
|
$answer = $request->dispatch(); // On recupere la reponse
|
|
|
|
// si erreur, on affiche rien
|
|
if( $answer->error != Error::Success )
|
|
return [];
|
|
|
|
return $answer->get('users');
|
|
}));
|
|
|
|
$twig->addFunction(new \Twig_Function('f_clusters', function($id_user){
|
|
$clustersReq = new ModuleRequest('userDefault/getClusters', [ 'id_user' => $id_user ]);
|
|
$clustersRes = $clustersReq->dispatch();
|
|
|
|
/* (2) Gestion si erreur */
|
|
if( $clustersRes->error != Error::Success )
|
|
return [];
|
|
|
|
return $clustersRes->get('clusters');
|
|
}));
|
|
|
|
|
|
/* [4] Build the whole stuff
|
|
=========================================================*/
|
|
return $twig->render('user/view.twig', [
|
|
'p_icon' => $variables['p_icon'],
|
|
'p_theme' => $variables['p_theme']
|
|
]);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
?>
|