protected function getArguments() { $arrArgumentValues = array(); $arrArguments = $this->arrAttributes['arguments']; $arrOptional = is_array($this->arrAttributes['optional']) ? $this->arrAttributes['optional'] : array(); $strMethod = Request::getInstance()->getMethod(); foreach ($arrArguments as $argument) { if (is_array($argument) || is_bool($argument)) { $arrArgumentValues[] = $argument; continue; } if (!in_array($argument, $arrOptional) && ($strMethod == 'POST' && !isset($_POST[$argument]) || $strMethod == 'GET' && !isset($_GET[$argument]))) { header('HTTP/1.1 400 Bad Request'); die('Bad Request, missing argument ' . $argument); } $varValue = $strMethod == 'POST' ? Request::getPost($argument) : Request::getGet($argument); if ($varValue === 'true' || $varValue === 'false') { $varValue = filter_var($varValue, FILTER_VALIDATE_BOOLEAN); } $arrArgumentValues[] = $varValue; } return $arrArgumentValues; }
/** * Redirect and append idGetParameter to url, depending on current configuration * * @param null $intId The entity id, if null $this->intId will be used from context */ protected function doIdDependentRedirectToEntity($intId = null) { if ($intId === null) { $intId = $this->intId; } if (!$intId) { return; } if ($this->allowIdAsGetParameter && $this->appendIdToUrlOnCreation && \Input::get($this->idGetParameter) != $intId) { $strUrl = Url::addQueryString($this->idGetParameter . '=' . $this->intId); // Use AjaxAction::generateUrl(Form::FORMHYBRID_NAME, null, array(Ajax::AJAX_ATTR_AJAXID => $this->objModule->id)) for formhybrid ajax create links if (Ajax::isRelated(Form::FORMHYBRID_NAME) !== null && \HeimrichHannot\Request\Request::getGet(Ajax::AJAX_ATTR_AJAXID)) { $objResponse = new ResponseRedirect(); $objResponse->setUrl($strUrl); $objResponse->output(); } \Controller::redirect($strUrl); } }
/** * Get the active ajax action object * * @param $strGroupRequested Requested ajax group * @param $strActionRequested Requested ajax action within group * * @return AjaxAction|null A valid AjaxAction | null if the action is not a registered ajax action */ public static function getActiveAction($strGroupRequested, $strActionRequested) { $strAct = Request::getGet(static::AJAX_ATTR_ACT); if (!$strAct) { return null; } if (($strGroup = static::getActiveGroup($strGroupRequested)) === null) { return null; } if ($strActionRequested != $strAct) { return null; } $arrConfig = $GLOBALS['AJAX']; if (!is_array($arrConfig)) { return null; } if (!isset($arrConfig[$strGroup])) { return AJAX_ERROR_INVALID_GROUP; } if (!is_array($arrConfig[$strGroup]['actions'])) { return AJAX_ERROR_NO_AVAILABLE_ACTIONS; } $arrActions = $arrConfig[$strGroup]['actions']; if (!array_key_exists($strActionRequested, $arrActions)) { return AJAX_ERROR_INVALID_ACTION; } $arrAttributes = $arrActions[$strAct]; return new AjaxAction($strGroup, $strAct, $arrAttributes); }