public function Index() { if (CommonController::IsAuthentified()) { $data = array($_SESSION['id']); $WSCtrl = new WebServicesController(); $userResponse = $WSCtrl->Call("User", "GET", $data); $user = json_decode($userResponse, true); $collectionCtrl = new CollectionController(); $data = array('user' => $user, 'url' => array('newCollection' => CommonController::GetLink("Collection", "Create"), 'displayCollection' => CommonController::GetLink("Collection"), 'signUp' => CommonController::GetLink("Login", "SignIn")), 'collections' => $collectionCtrl->GetPrivateCollections()); CommonController::SetView("home", "index", $data); } else { CommonController::Redirect("Login"); } }
public static function SetView($controller, $name, $params = null) { $initialParams = ['fixedUrl' => ['home' => CommonController::GetLink("Home"), 'signIn' => CommonController::GetLink("Login", "SignIn"), 'logOut' => CommonController::GetLink("Login", "Logout"), 'LogIn' => CommonController::GetLink("Login", "Index")], 'jwt' => isset($_SESSION['jwt']) ? $_SESSION['jwt'] : "", 'fixedUser' => array('isLogged' => CommonController::IsAuthentified())]; $params = is_null($params) ? $initialParams : array_merge($initialParams, $params); CommonController::$view = CommonController::$twig->render($controller . '/' . $name . '.twig', $params); }
public function GetCollection($id) { if (CommonController::IsAuthentified()) { $wSCtrl = new WebServicesController(); $response = $wSCtrl->Call("Collection", "GET", ["id" => $id]); return json_decode($response, true); } return null; }