public function testCanPopulateFromPost() { $request = new Request(); // Just filling the superglobal... $_POST['hi'] = 'hey'; self::assertArrayHasKey('hi', $_POST); $request->populateFromPost(); self::assertEquals('hey', $request->getValue('post-hi')); }
public function doUpdateSubmit() { $areaService = new AreaService(); $areaVo = Request::getValue("area", "AreaValue"); //var_dump($areaVo);exit; if (!$areaVo->checkOptions($areaVo->getCreateOptions())) { View::set("AreaUpdateValue", $areaVo); View::display("Update"); return; } $areaVo = $areaService->updateByPrimary($areaVo); Zee::redirect(Zee::url("area", "list")); }
public function doUpdateSubmit() { $projectService = new ProjectService(); $projectVo = Request::getValue("project", "ProjectValue"); //var_dump($projectVo);exit; if (!$projectVo->checkOptions($projectVo->getCreateOptions())) { View::set("ProjectUpdateValue", $projectVo); View::display("Update"); return; } $projectVo = $projectService->updateByPrimary($projectVo); Zee::redirect(Zee::url("project", "list")); }
public function handleRequest(Request $request) { $translator = new Translator(@$_COOKIE['lang']); foreach ($this->fieldsMap as $field => $constraints) { /** @var Constraint $constraint */ foreach ($constraints as $constraint) { if (!$constraint->validate($request->getValue($field))) { $msg = $constraint->getMessage($data); $this->errors[$field][] = $translator->trans($msg, $data); } } } if ($this->isValid()) { $this->record->setFromData($request->getRequestData()); } else { $this->record = $request->getRequestData(); } return $this; }
public function doUpdateSubmit() { $messageService = new MessageService(); $messageVo = Request::getValue("message", "MessageValue"); //var_dump($messageVo);exit; if (!$messageVo->checkOptions($messageVo->getCreateOptions())) { View::set("MessageUpdateValue", $messageVo); View::display("Update"); return; } $messageVo = $messageService->updateByPrimary($messageVo); Zee::redirect(Zee::url("message", "list")); }
public function doEditSubmit() { $userService = new UserService(); $userVo = Request::getValue("user", "UserValue"); $userVo->user_id = $_SESSION['user_id']; if (trim($userVo->password) != '') { $userVo->password = MD5($userVo->password); } else { $userVo->password = null; } if (!$userVo->checkOptions($userVo->getUpdateOptions())) { View::set("UserUpdateValue", $userVo); View::display("Edit"); return; } $userVo = $userService->updateByPrimary($userVo); View::set('message', '<div class="success_box">更新成功</div>'); View::set("UserUpdateValue", $userVo); View::display("Edit"); }
public function doAjaxSubmit() { $ordersService = new OrdersService(); $ordersVo = Request::getValue("orders", "OrdersValue"); /* if (!$ordersVo->checkOptions($ordersVo->getCreateOptions())) { View::set("OrdersUpdateValue", $ordersVo); View::display("Update"); return; }*/ $ordersVo = $ordersService->updateByPrimary($ordersVo); if (Request::get('message_content') != '') { $messageVo = new MessageValue(); $messageVo->content = Request::get('message_content'); $messageVo->order_id = Request::get('orders_order_id'); $messageVo->user_id = $_SESSION['user_id']; $messageVo->time = date("Y-m-d H:i:s"); $messageVo->status = Value::STATUS_NOT_SEE; $messageService = new MessageService(); $messageVo = $messageService->create($messageVo); } Zee::redirect(Zee::url("orders", "list")); }
/** * Processess the HTTP request sent by the client * * @param httpRequest HTTP request sent by the client */ function process($httpRequest) { // get the name of the action $request = new Request($httpRequest); $i = 0; $performed = false; while (!$performed) { // get the value of this varilable, every loop global $_plogController_forwardAction; global $_plogController_previousAction; // jondaley: 08/29/2005, what are these here for?? // perhaps the global statements should be moved // inside the elseif loop below? $_plogController_forwardAction; $_plogController_previousAction; if ($i == 0) { // if this is the first iteration, then we have to take this path... // since we will use the http request to determine which action to // use next $actionName = $request->getValue($this->_actionParam); $actionClass = $this->_getActionClassName($request->getValue($this->_actionParam)); } elseif (!empty($_plogController_forwardAction)) { // if we're forwarding the current execution flow to another action, then // we'll go this way $actionName = $_plogController_forwardAction; $actionClass = $this->_getActionClassName($_plogController_forwardAction); $httpRequest = HttpVars::getRequest(); $_plogController_forwardAction = null; } else { // if there's nothing else to do, finish $performed = true; } if (!$performed) { // load the class if it hasn't been loaded yet $this->loadActionClass($actionClass); $actionInfo = new ActionInfo($this->_actionParam, $actionName); $actionObject = new $actionClass($actionInfo, $httpRequest); $actionObject->setPreviousAction($_plogController_previousAction); // we can use the validate method to check the values of the form variables. If validate() // returns 'true', then we call the 'perform' method. If not, then we won't :) if ($actionObject->validate()) { if ($actionObject->perform()) { $actionObject->setSuccess(true); } else { $actionObject->setSuccess(false); } } } $i++; } // once the operation has been carried out, fetch and send the view // to the client $view = $actionObject->getView(); // this is not good... if (empty($view)) { $e = new Exception('The view is empty after calling the perform method.'); throw $e; } else { $view->render(); } }