/** * Initializes this exception. * * @param array $fieldNames Names of the form fields which caused the exception * @param string $messageKey Message key of the error message to display * @param array $messageParameters List of parameters used in the error message */ public function __construct(array $fieldNames, string $messageKey, array $messageParameters = array()) { // init exception and set message parent::__construct(Application::getI18nHandler()->getTranslator()->translate($messageKey, $messageParameters)); // set field names $this->fieldNames = $fieldNames; }
/** * @see \Ableron\Core\Template\Plugins\Interfaces\CompilerPluginInterface::compileOpeningTag() */ public function compileOpeningTag(TemplateCompiler $templateCompiler) { // get translation $translation = Application::getI18nHandler()->getTranslator()->translate($this->getArgument('key')); // return translation return $this->getArgument('htmlEncode') ? StringUtil::encodeHtml($translation) : $translation; }
/** * @see \Ableron\Core\Controller\AbstractController::run() */ protected function run() { $this->readParameters(); $this->readData(); if ($this->getRequest()->isPost()) { $this->readFormParameters(); if ($this->checkCsrfToken()) { try { $this->validateFormParameters(); $this->processForm(); $this->onProcessFormSuccessful(); } catch (FormParameterException $e) { $this->onValidateFormParametersFailed($e); } } else { $this->setFlashMessage(Application::getI18nHandler()->getTranslator()->translate('core.security.csrf.actionNotExecuted'), null, ControllerInterface::MESSAGE_TYPE_ERROR); } } $this->assignVariables(); $this->display(); }
/** * @see \Ableron\Core\Controller\AbstractController::run() */ protected function run() { // check for valid CSRF token before executing action if ($this->checkCsrfToken()) { try { $this->readParameters(); $this->readData(); $this->execute(); $this->onExecuteSuccessful(); } catch (ExecutionFailedException $e) { $this->onExecuteFailed(); } } else { $this->setFlashMessage(Application::getI18nHandler()->getTranslator()->translate('core.security.csrf.actionNotExecuted'), null, ControllerInterface::MESSAGE_TYPE_ERROR); } // if we are here, no redirect has been sent during execution; so redirect to action source URL if (($encodedActionSourceUrl = $this->getQueryParameter(ABLERON_PARAM_ACTION_SOURCE_URL, false)) !== false && ($actionSourceUrl = StringUtil::base64UrlDecode($encodedActionSourceUrl)) !== false) { $this->redirectTo(new Uri($actionSourceUrl)); } else { $this->redirectTo(EnvironmentUtil::getInternalUrl('/')); } }
/** * Tests whether translate() works as expected with unknown message key. * * @return void */ public function testTranslateWithUnknownMessageKey() { $this->assertSame('', Application::getI18nHandler()->getTranslator()->translate('unknown.message.key')); $this->assertSystemLogFileContainsMessage('Unable to translate text key "unknown.message.key": No translation found'); }
/** * @see \Ableron\Core\Controller\Page\PageInterface::assignVariables() */ public function assignVariables() { parent::assignVariables(); Application::getTemplateHandler()->getVariables()->setAll(array('documentTitle' => Application::getI18nHandler()->getTranslator()->translate('sysInfo.systemInfo.title'), 'ableronCoreVersion' => Application::getVersion(), 'ableronInstallationTime' => StringUtil::formatDateTime(Application::getInstallationTime()), 'databaseManagementSystem' => SystemInformation::getDatabaseManagementSystem(), 'operatingSystem' => SystemInformation::getOperatingSystem(), 'phpVersion' => SystemInformation::getPhpVersion(), 'phpServerApi' => SystemInformation::getPhpServerApi(), 'webServer' => SystemInformation::getWebServer(), 'zendEngineVersion' => SystemInformation::getZendEngineVersion())); }
/** * @see \Ableron\Core\Controller\Page\PageInterface::assignVariables() */ public function assignVariables() { parent::assignVariables(); Application::getTemplateHandler()->getVariables()->setAll(array('documentTitle' => Application::getI18nHandler()->getTranslator()->translate('core.backend.index.title'))); }
/** * Formats the given DateTime object using the current locale. * * @param \DateTime $dateTime The DateTime object to format * @return string */ public static function formatDateTime(DateTime $dateTime) { return $dateTime->format(Application::getI18nHandler()->getTranslator()->translate('stringFormat.dateTime')); }
/** * Returns the file where to save the compiled version of the given source template. * * @param string $sourceTemplateFile The source template file for which to get the file of the compiled version * @throws \Ableron\Core\Exception\SystemException * @return string */ public function getCompiledTemplateFile($sourceTemplateFile) { // make sure "./" and "../" are handled correctly $sourceTemplateFile = StringUtil::contains($sourceTemplateFile, './') ? FileUtil::normalizePath(realpath($sourceTemplateFile)) : $sourceTemplateFile; // extract template information from path (module, area and template name) if (!preg_match('#/Modules/(?<module>[^/]+)(?<path>(/[^/]+)+?)/(?<name>[^/]+)\\.tpl$#', $sourceTemplateFile, $templateInfo)) { throw new SystemException(sprintf('Template file has invalid path: %s (Pattern of valid template file: .../<module>/**/<name>.tpl, e.g. **/app/Modules/Core/Pages/Backend/Templates/IndexPage.tpl)', $sourceTemplateFile), 0, E_USER_ERROR, __FILE__, __LINE__); } // build and return file name of the compiled template return FileUtil::getTempFileName(sprintf('tpl/%s/%s/%s', $templateInfo['module'], $templateInfo['path'], Application::getI18nHandler()->getLocale()->getLocaleCode()), '', $templateInfo['name'], 'php'); }
/** * @see \Ableron\Core\Controller\Page\PageInterface::assignVariables() */ public function assignVariables() { parent::assignVariables(); Application::getTemplateHandler()->getVariables()->setAll(array('documentTitle' => Application::getI18nHandler()->getTranslator()->translate('core.backend.login.title'), 'loginForm' => $this->loginForm, 'username' => $this->username)); }
/** * @see \Ableron\Core\Controller\Page\PageInterface::assignVariables() */ public function assignVariables() { parent::assignVariables(); Application::getTemplateHandler()->getVariables()->setAll(array('documentTitle' => Application::getI18nHandler()->getTranslator()->translate('sysInfo.phpInfo.title'), 'phpInfo' => $this->getPhpInfo())); }