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"); }
public function Show404() { CommonController::SetView("home", "404", []); CommonController::Display(true); }