/** * If the language has been changed, set a cookie with the new default language and force a page reload */ public function onLanguageChange() { if ($this->request->getPost()->has('lang')) { setcookie('ACP3_INSTALLER_LANG', $this->request->getPost()->get('lang', ''), time() + 3600, '/'); $this->redirect->temporary($this->request->getFullPath())->send(); exit; } }
/** * Selektion eines Eintrages in einem Dropdown-Menü * * @param string $formFieldName * @param mixed $defaultValue * @param string|integer|array $currentValue * @param string $htmlAttribute * * @return string */ public function selectEntry($formFieldName, $defaultValue, $currentValue = '', $htmlAttribute = '') { $htmlAttribute = $this->buildHtmlAttribute($htmlAttribute); $currentValue = $this->request->getPost()->get($formFieldName, $currentValue); if (is_array($currentValue) === false && $currentValue == $defaultValue) { return $htmlAttribute; } elseif (is_array($currentValue) === true && in_array($defaultValue, $currentValue)) { return $htmlAttribute; } return ''; }
/** * Removes the form token from the session * * @param string $token */ public function unsetFormToken($token = '') { $tokenName = Core\Session\SessionHandlerInterface::XSRF_TOKEN_NAME; if (empty($token) && $this->request->getPost()->has($tokenName)) { $token = $this->request->getPost()->get($tokenName, ''); } if (!empty($token)) { $sessionToken = $this->sessionHandler->get($tokenName); if (!empty($sessionToken)) { $this->sessionHandler->remove($tokenName); } } }
/** * Returns the SEO form fields * * @param string $path * * @return array */ public function formFields($path = '') { if (!empty($path)) { $path .= !preg_match('/\\/$/', $path) ? '/' : ''; $alias = $this->request->getPost()->get('alias', $this->aliases->getUriAlias($path, true)); $keywords = $this->request->getPost()->get('seo_keywords', $this->metaStatements->getKeywords($path)); $description = $this->request->getPost()->get('seo_description', $this->metaStatements->getDescription($path)); $robots = $this->metaStatements->getSeoInformation($path, 'robots', 0); } else { $alias = $keywords = $description = ''; $robots = 0; } return ['alias' => $alias, 'keywords' => $keywords, 'description' => $description, 'robots' => $this->formsHelper->choicesGenerator('seo_robots', $this->getRobotsChoicesGeneratorValues(), $robots)]; }
/** * @param string $name * @param string $value * @param bool $showTime * * @return string */ protected function fetchSimpleDatePickerValue($name, $value, $showTime) { if ($this->request->getPost()->has($name)) { return $this->request->getPost()->get($name, ''); } elseif ($this->dateValidationRule->isValid($value) === true) { return $this->date->format($value, $this->getDateFormat($showTime)); } return $this->date->format('now', $this->getDateFormat($showTime), false); }
/** * @return array */ private function prepareRequestData() { $entries = []; if (is_array($this->request->getPost()->get('entries')) === true) { $entries = $this->request->getPost()->get('entries'); } elseif ((bool) preg_match('/^((\\d+)\\|)*(\\d+)$/', $this->request->getParameters()->get('entries')) === true) { $entries = explode('|', $this->request->getParameters()->get('entries')); } return $entries; }
/** * Listet alle Kategorien eines Moduls auf * * @param string $module * @param string $categoryId * @param boolean $categoryCreate * @param string $formFieldName * @param string $customText * * @return array */ public function categoriesList($module, $categoryId = '', $categoryCreate = false, $formFieldName = 'cat', $customText = '') { $categories = []; $categories['custom_text'] = !empty($customText) ? $customText : $this->translator->t('system', 'pls_select'); $categories['name'] = $formFieldName; $categories['categories'] = $this->categoriesCache->getCache($module); $cData = count($categories['categories']); for ($i = 0; $i < $cData; ++$i) { $categories['categories'][$i]['selected'] = $this->formsHelper->selectEntry($formFieldName, $categories['categories'][$i]['id'], $categoryId); } if ($categoryCreate === true && $this->acl->hasPermission('admin/categories/index/create') === true) { $categories['create']['name'] = $formFieldName . '_create'; $categories['create']['value'] = $this->request->getPost()->get('create', ['name' => ''])['name']; } return $categories; }
/** * @inheritdoc */ public function isValid($data, $field = '', array $extra = []) { $tokenName = SessionHandlerInterface::XSRF_TOKEN_NAME; $sessionToken = $this->sessionHandler->get($tokenName, ''); return $this->request->getPost()->get($tokenName, '') === $sessionToken; }
/** * @param string $language * @param string $timeZone * @param int $displayAddress * @param int $displayBirthday * @param int $displayCountry * @param int $displayMail * @return array */ public function fetchUserSettingsFormFields($language, $timeZone, $displayAddress = 0, $displayBirthday = 0, $displayCountry = 0, $displayMail = 0) { return ['languages' => $this->translator->getLanguagePack($this->request->getPost()->get('language', $language)), 'time_zones' => $this->dateHelpers->getTimeZones($timeZone), 'address_display' => $this->displayAddress($displayAddress), 'birthday_display' => $this->displayBirthday($displayBirthday), 'country_display' => $this->displayCountry($displayCountry), 'mail_display' => $this->displayMail($displayMail)]; }