本文整理汇总了PHP中Localization::localePresent方法的典型用法代码示例。如果您正苦于以下问题:PHP Localization::localePresent方法的具体用法?PHP Localization::localePresent怎么用?PHP Localization::localePresent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Localization
的用法示例。
在下文中一共展示了Localization::localePresent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
$regenerator = function ($delete) {
$_SESSION = [];
session_regenerate_id($delete);
return session_id();
};
return new Environment\Session($_SESSION, session_id(), 'skyhook', $regenerator);
});
// Register Environment Singletons
foreach (array('Get' => &$_GET, 'Post' => &$_POST, 'Server' => &$_SERVER, 'PostFiles' => &$_FILES, 'Cookie' => &$_COOKIE) as $class => $glbl) {
$c = "Environment\\" . $class;
Container::registerSingleton($c, function () use($c, $glbl) {
return new $c($glbl);
});
}
$cookies = Container::dispense("Environment\\Cookie");
if (isset($cookies['lang']) && Localization::localePresent($cookies['lang'])) {
Localization::setLocale($cookies['lang']);
}
Container::registerSingleton('Environment\\RequestHeaders', function () {
$headers = getallheaders();
return new Environment\RequestHeaders($headers);
});
foreach (array('Delete', 'Put') as $wrapper) {
Container::registerSingleton($wrapper, function () use($wrapper) {
$server = Container::dispense(Environment\Server);
$nsed = "Environment\\" . $wrapper;
$wrapped = $nsed::buildHelper($server);
return new $nsed($wrapped);
});
}
Container::registerSingleton('DB', function () {
示例2: getErrors
public function getErrors(Post $post)
{
$i18n = Localization::getTranslator();
//TODO: implement range checking on modifier values, and static pricing
$walletSettings = [];
if (empty($post['wallet']['id'])) {
$walletSettings[] = ['id' => '#wallet-id-error', 'error' => $i18n->_('A valid Blockchain.info wallet id is required.')];
}
if (empty($post['wallet']['mainPass'])) {
$walletSettings[] = ['id' => '#wallet-mainPass-error', 'error' => $i18n->_('Your respective Blockchain.info password is required.')];
}
if (empty($post['wallet']['fromAddress'])) {
$walletSettings[] = ['id' => '#wallet-fromAddress-error', 'error' => $i18n->_('An address controlled by your Blockchain.info wallet is required to send from.')];
} elseif (!AddressUtility::checkAddress($post['wallet']['fromAddress'])) {
$walletSettings[] = ['id' => '#wallet-fromAddress-error', 'error' => $i18n->_('A valid Bitcoin address is required.')];
}
$emailUser = @$post['email']['username'];
$emailSettings = [];
if (empty($emailUser)) {
$emailSettings[] = ['id' => '#email-username-error', 'error' => $i18n->_('A valid email address is required.')];
} elseif (filter_var($emailUser, FILTER_VALIDATE_EMAIL) !== $emailUser) {
$emailSettings[] = ['id' => '#email-username-error', 'error' => $i18n->_('Email address entered is not valid.')];
}
if (empty($post['email']['password'])) {
$emailSettings[] = ['id' => '#email-password-error', 'error' => $i18n->_('Email password is required.')];
}
$passwordSettings = [];
if (strlen(@$post['admin_password']) < 5) {
$passwordSettings[] = ['id' => '#password-error', 'error' => $i18n->_('Minimum password length is 5 characters.')];
}
if (@$post['admin_password'] !== @$post['confirm_admin_password']) {
$passwordSettings[] = ['id' => '#password-error', 'error' => $i18n->_('Admin passwords must match')];
}
$transactionSettings = [];
if (isset($post['transactions']['maximum'])) {
if (!preg_match('#^[0-9]+$#', $post['transactions']['maximum'])) {
$transactionSettings[] = ['id' => '#maximum-errors', 'error' => $i18n->_('Maximum transaction value must be a positive integer.')];
}
}
$localeSettings = [];
if (isset($post['locale'])) {
if (!Localization::localePresent($post['locale'])) {
$transactionSettings[] = ['id' => '#locale-errors', 'error' => $i18n->_('Unkown Locale.')];
}
}
$errors = [];
if (!empty($transactionSettings)) {
$errors['#locale-settings'] = $localeSettings;
}
if (!empty($transactionSettings)) {
$errors['#transaction-settings'] = $transactionSettings;
}
if (!empty($passwordSettings)) {
$errors['#password-settings'] = $passwordSettings;
}
if (!empty($pricingSettings)) {
$errors['#pricing-settings'] = self::getPricingErrors($post);
}
if (!empty($walletSettings)) {
$errors['#wallet-settings'] = $walletSettings;
}
if (!empty($emailSettings)) {
$errors['#email-settings'] = $emailSettings;
}
return $errors;
}