/** * Constructor. * @param $request PKPRequest */ function __construct($request) { parent::__construct($request, 'install/install.tpl'); // FIXME Move the below options to an external configuration file? $this->supportedLocales = AppLocale::getAllLocales(); $this->localesComplete = array(); foreach ($this->supportedLocales as $key => $name) { $this->localesComplete[$key] = AppLocale::isLocaleComplete($key); } $this->supportedClientCharsets = array('utf-8' => 'Unicode (UTF-8)', 'iso-8859-1' => 'Western (ISO-8859-1)'); $this->supportedConnectionCharsets = array('' => __('common.notApplicable'), 'utf8' => 'Unicode (UTF-8)'); $this->supportedDatabaseCharsets = array('' => __('common.notApplicable'), 'utf8' => 'Unicode (UTF-8)'); $this->supportedDatabaseDrivers = array('mysql' => array('mysql', 'MySQL'), 'mysqli' => array('mysqli', 'MySQLi'), 'postgres' => array('pgsql', 'PostgreSQL'), 'oracle' => array('oci8', 'Oracle'), 'mssql' => array('mssql', 'MS SQL Server'), 'fbsql' => array('fbsql', 'FrontBase'), 'ibase' => array('ibase', 'Interbase'), 'firebird' => array('ibase', 'Firebird'), 'informix' => array('ifx', 'Informix'), 'sybase' => array('sybase', 'Sybase'), 'odbc' => array('odbc', 'ODBC')); // Validation checks for this form $this->addCheck(new FormValidatorInSet($this, 'locale', 'required', 'installer.form.localeRequired', array_keys($this->supportedLocales))); $this->addCheck(new FormValidatorCustom($this, 'locale', 'required', 'installer.form.localeRequired', array('AppLocale', 'isLocaleValid'))); $this->addCheck(new FormValidatorInSet($this, 'clientCharset', 'required', 'installer.form.clientCharsetRequired', array_keys($this->supportedClientCharsets))); $this->addCheck(new FormValidator($this, 'filesDir', 'required', 'installer.form.filesDirRequired')); $this->addCheck(new FormValidator($this, 'adminUsername', 'required', 'installer.form.usernameRequired')); $this->addCheck(new FormValidatorUsername($this, 'adminUsername', 'required', 'installer.form.usernameAlphaNumeric')); $this->addCheck(new FormValidator($this, 'adminPassword', 'required', 'installer.form.passwordRequired')); $this->addCheck(new FormValidatorCustom($this, 'adminPassword', 'required', 'installer.form.passwordsDoNotMatch', create_function('$password,$form', 'return $password == $form->getData(\'adminPassword2\');'), array($this))); $this->addCheck(new FormValidatorEmail($this, 'adminEmail', 'required', 'installer.form.emailRequired')); $this->addCheck(new FormValidatorInSet($this, 'databaseDriver', 'required', 'installer.form.databaseDriverRequired', array_keys($this->supportedDatabaseDrivers))); $this->addCheck(new FormValidator($this, 'databaseName', 'required', 'installer.form.databaseNameRequired')); }
/** * Display form to modify site language settings. * @param $args array * @param $request object */ function languages($args, &$request) { $this->validate(); $this->setupTemplate(true); $site =& $request->getSite(); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('localeNames', AppLocale::getAllLocales()); $templateMgr->assign('primaryLocale', $site->getPrimaryLocale()); $templateMgr->assign('supportedLocales', $site->getSupportedLocales()); $localesComplete = array(); foreach (AppLocale::getAllLocales() as $key => $name) { $localesComplete[$key] = AppLocale::isLocaleComplete($key); } $templateMgr->assign('localesComplete', $localesComplete); $templateMgr->assign('installedLocales', $site->getInstalledLocales()); $templateMgr->assign('uninstalledLocales', array_diff(array_keys(AppLocale::getAllLocales()), $site->getInstalledLocales())); $templateMgr->assign('helpTopicId', 'site.siteManagement'); import('classes.i18n.LanguageAction'); $languageAction = new LanguageAction(); if ($languageAction->isDownloadAvailable()) { $templateMgr->assign('downloadAvailable', true); $templateMgr->assign('downloadableLocales', $languageAction->getDownloadableLocales()); } $templateMgr->display('admin/languages.tpl'); }
/** * Constructor. */ function InstallForm() { parent::Form('install/install.tpl'); // FIXME Move the below options to an external configuration file? $this->supportedLocales = AppLocale::getAllLocales(); $this->localesComplete = array(); foreach ($this->supportedLocales as $key => $name) { $this->localesComplete[$key] = AppLocale::isLocaleComplete($key); } $this->supportedClientCharsets = array('utf-8' => 'Unicode (UTF-8)', 'iso-8859-1' => 'Western (ISO-8859-1)'); $this->supportedConnectionCharsets = array('' => __('common.notApplicable'), 'utf8' => 'Unicode (UTF-8)'); $this->supportedDatabaseCharsets = array('' => __('common.notApplicable'), 'utf8' => 'Unicode (UTF-8)'); $this->supportedEncryptionAlgorithms = array('md5' => 'MD5'); if (function_exists('sha1')) { $this->supportedEncryptionAlgorithms['sha1'] = 'SHA1'; } $this->supportedDatabaseDrivers = array('mysql' => array('mysql', 'MySQL'), 'postgres' => array('pgsql', 'PostgreSQL'), 'oracle' => array('oci8', 'Oracle'), 'mssql' => array('mssql', 'MS SQL Server'), 'fbsql' => array('fbsql', 'FrontBase'), 'ibase' => array('ibase', 'Interbase'), 'firebird' => array('ibase', 'Firebird'), 'informix' => array('ifx', 'Informix'), 'sybase' => array('sybase', 'Sybase'), 'odbc' => array('odbc', 'ODBC')); // Validation checks for this form $this->addCheck(new FormValidatorInSet($this, 'locale', 'required', 'installer.form.localeRequired', array_keys($this->supportedLocales))); $this->addCheck(new FormValidatorCustom($this, 'locale', 'required', 'installer.form.localeRequired', array('AppLocale', 'isLocaleValid'))); $this->addCheck(new FormValidatorInSet($this, 'clientCharset', 'required', 'installer.form.clientCharsetRequired', array_keys($this->supportedClientCharsets))); $this->addCheck(new FormValidator($this, 'filesDir', 'required', 'installer.form.filesDirRequired')); $this->addCheck(new FormValidatorInSet($this, 'encryption', 'required', 'installer.form.encryptionRequired', array_keys($this->supportedEncryptionAlgorithms))); $this->addCheck(new FormValidator($this, 'adminUsername', 'required', 'installer.form.usernameRequired')); $this->addCheck(new FormValidatorAlphaNum($this, 'adminUsername', 'required', 'installer.form.usernameAlphaNumeric')); $this->addCheck(new FormValidatorLength($this, 'adminPassword', 'required', 'user.register.form.passwordLengthTooShort', '>=', INSTALLER_DEFAULT_MIN_PASSWORD_LENGTH)); $this->addCheck(new FormValidator($this, 'adminPassword', 'required', 'installer.form.passwordRequired')); $this->addCheck(new FormValidatorCustom($this, 'adminPassword', 'required', 'installer.form.passwordsDoNotMatch', create_function('$password,$form', 'return $password == $form->getData(\'adminPassword2\');'), array(&$this))); $this->addCheck(new FormValidatorEmail($this, 'adminEmail', 'required', 'installer.form.emailRequired')); $this->addCheck(new FormValidatorInSet($this, 'databaseDriver', 'required', 'installer.form.databaseDriverRequired', array_keys($this->supportedDatabaseDrivers))); $this->addCheck(new FormValidator($this, 'databaseName', 'required', 'installer.form.databaseNameRequired')); $this->addCheck(new FormValidatorPost($this)); }
/** * @copydoc GridHandler::loadData() */ protected function loadData($request, $filter) { $site = $request->getSite(); $data = array(); $allLocales = AppLocale::getAllLocales(); $installedLocales = $site->getInstalledLocales(); $supportedLocales = $site->getSupportedLocales(); $primaryLocale = $site->getPrimaryLocale(); foreach ($installedLocales as $localeKey) { $data[$localeKey] = array(); $data[$localeKey]['name'] = $allLocales[$localeKey]; $data[$localeKey]['incomplete'] = !AppLocale::isLocaleComplete($localeKey); if (in_array($localeKey, $supportedLocales)) { $supported = true; } else { $supported = false; } $data[$localeKey]['supported'] = $supported; if ($this->_canManage($request)) { $context = $request->getContext(); $primaryLocale = $context->getPrimaryLocale(); } if ($localeKey == $primaryLocale) { $primary = true; } else { $primary = false; } $data[$localeKey]['primary'] = $primary; } if ($this->_canManage($request)) { $data = $this->addManagementData($request, $data); } return $data; }
/** * @covers PKPLocale */ public function testIsLocaleComplete() { self::assertTrue(AppLocale::isLocaleComplete('en_US')); self::assertFalse(AppLocale::isLocaleComplete('pt_BR')); self::assertFalse(AppLocale::isLocaleComplete('xx_XX')); }