/** * Generate html grid string * * @return string with html form * @since 0.17.0 */ public function render() { $sort = 0; $query = $this->request->getQuery(); if (isset($query['sort']) && isset($this->columns[$query['sort']])) { $sort = $query['sort']; } return $this->formatter->render($this->columns, $this->getRecords(), $this->dataManager->getTotalCount(), $this->limit, $this->page, $sort); }
/** * Render view * * @param \Arbor\Core\RequestProvider $request * @param \Arbor\Core\Presenter $presenter * @param \Arbor\Provider\Response $response * @since 0.1.0 */ protected function prepareView(RequestProvider $request, Presenter $presenter, Response $response) { $event = new ExecutePresenterEvent($request, $response); $this->eventManager->fire('executePresenter', $event); $presenter->render($request->getConfig(), $response); }
/** * Submit form. Check http confirm and validate fields * * @param \Arbor\Core\RequestProvider $request * @since 0.17.0 */ public function submit(RequestProvider $request) { $this->isConfirmed = false; if ($this->formTags['method'] == 'post' && $request->getType() == 'POST') { $this->isConfirmed = true; } $query = $request->getQuery(); if (count($this->fields) > 0 && $this->formTags['method'] == 'get' && isset($query[$this->fields[0]->getName()])) { $this->isConfirmed = true; } if (!$this->isConfirmed) { return; } $storage = array(); if ($this->formTags['method'] == 'post') { $storage = $request->getData(); } else { $storage = $request->getQuery(); } //set field data $result = array(); foreach ($this->fields as $field) { if (isset($storage[$field->getName()])) { $field->setData($storage[$field->getName()]); } else { if ($field instanceof FileField) { try { $field->setData($request->getFile($field->getName())); } catch (FileNotUploadedException $e) { $field->setData(''); } } else { if (preg_match('/^(.*?)\\[(.*)\\]$/', $field->getName(), $result)) { if ($result[2] == '') { //FIXME autoincrement field } else { $field->setData($storage[$result[1]][$result[2]]); } } } } } //validate if ($request->isFullUploadedData()) { foreach ($this->fields as $field) { if ($field->getValidator()) { if ($error = $this->validatorService->validate($field->getValidator(), $field->getData())) { $field->setError($error); } } } } else { foreach ($this->fields as $field) { $field->setError('Request data is too large.'); } } }
/** * Constructor. * * @param \Arbor\Core\RequestProvider $request * @param \Arbor\Core\ExecuteResources $executeResources * @since 0.1.0 */ public function __construct(RequestProvider $request, ExecuteResources $executeResources) { $this->request = $request; $this->session = $request->getSession(); parent::__construct($executeResources); }
/** * Check authenticate. * * @param string $redirect * @param \Arbor\Core\RequestProvider $request * @return \Arbor\Provider\Response * @since 0.1.0 */ private function createResponseRedirect($redirect, RequestProvider $request) { $response = new Response(); if ($request->isAjax()) { $response->setStatusCode(401); $response->setHeader('X-Location', $redirect); } else { $response->redirect($redirect); } return $response; }