public static function Redirect($ctrl, $action = "Index", $param = null)
 {
     if (!is_null($param)) {
         throw new \Exception("Not Implemented");
     }
     header("Location: " . CommonController::GetLink($ctrl, $action));
 }
Exemplo n.º 2
0
 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");
     }
 }
Exemplo n.º 3
0
 public function Edit()
 {
     if (CommonController::IsAuthentified()) {
         $request = new Request();
         if ($request->isGet()) {
             $data = json_decode($this->GetCurrentCollection(), true);
             if (!is_null($data)) {
                 CommonController::SetView("collection", "edit", array_merge($data, array('url' => array('edit' => CommonController::GetLink("Collection", "edit", $data['collection']['id'])))));
                 return;
             }
         } else {
             if ($request->isPost()) {
                 $label = $request->getPost('label');
                 $description = $request->getPost('description');
                 $id = $request->getPost('id');
                 if (!is_null($label) && !is_null($description)) {
                     if (!is_null($id)) {
                         $WSCtrl = new WebServicesController();
                         $return = $WSCtrl->Call("Collection", "POST", array("id" => $id, "label" => $label, "description" => $description));
                         var_dump($return);
                         if ($return == "true") {
                             CommonController::Redirect("Collection", "Index", $id);
                         } else {
                             $data = json_decode($this->GetCurrentCollection(), true);
                             if (!is_null($data)) {
                                 CommonController::SetView("collection", "index", array_merge($data, array('url' => array('edit' => CommonController::GetLink("Collection", "edit", $data['collection']['id']), 'delete' => CommonController::GetLink("Collection", "delete", $data['collection']['id'])), 'error' => 'Impossible de sauver la collection')));
                                 return;
                             }
                         }
                     } else {
                         //Create
                     }
                 }
             }
         }
     }
     CommonController::Redirect("home");
 }
Exemplo n.º 4
0
 public static function Redirect($ctrl, $action = "Index", $param = null)
 {
     header("Location: " . CommonController::GetLink($ctrl, $action, $param));
 }