本文整理汇总了PHP中eZLocale::create方法的典型用法代码示例。如果您正苦于以下问题:PHP eZLocale::create方法的具体用法?PHP eZLocale::create怎么用?PHP eZLocale::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZLocale
的用法示例。
在下文中一共展示了eZLocale::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
function init()
{
$this->Error = array('errors' => array());
set_time_limit(10 * 60);
$siteType = $this->chosenSiteType();
// If we are installing a package without extension packages we
// generate the autoload array for extensions.
// For the time being we only do this for the plain_site package.
if ($siteType['identifier'] == 'plain_site') {
ezpAutoloader::updateExtensionAutoloadArray();
}
$saveData = true;
// set to true to save data
//$ini = eZINI::create();
$accessMap = array('url' => array(), 'hostname' => array(), 'port' => array(), 'accesses' => array());
$primaryLanguage = null;
$allLanguages = array();
$allLanguageCodes = array();
$variationsLanguages = array();
$primaryLanguageCode = $this->PersistenceList['regional_info']['primary_language'];
$extraLanguageCodes = isset($this->PersistenceList['regional_info']['languages']) ? $this->PersistenceList['regional_info']['languages'] : array();
$extraLanguageCodes = array_diff($extraLanguageCodes, array($primaryLanguageCode));
/*
if ( isset( $this->PersistenceList['regional_info']['variations'] ) )
{
$variations = $this->PersistenceList['regional_info']['variations'];
foreach ( $variations as $variation )
{
$locale = eZLocale::create( $variation );
if ( $locale->localeCode() == $primaryLanguageCode )
{
$primaryLanguage = $locale;
}
else
{
$variationsLanguages[] = $locale;
}
}
}
*/
if ($primaryLanguage === null) {
$primaryLanguage = eZLocale::create($primaryLanguageCode);
}
$allLanguages[] = $primaryLanguage;
foreach ($extraLanguageCodes as $extraLanguageCode) {
$allLanguages[] = eZLocale::create($extraLanguageCode);
$allLanguageCodes[] = $extraLanguageCode;
}
// If we have already figured out charset we used that
if (isset($this->PersistenceList['regional_info']['site_charset']) and strlen($this->PersistenceList['regional_info']['site_charset']) > 0) {
$charset = $this->PersistenceList['regional_info']['site_charset'];
} else {
// Figure out charset automatically if it is not set yet
$canUseUnicode = $this->PersistenceList['database_info']['use_unicode'];
$charset = $this->findAppropriateCharset($primaryLanguage, $allLanguages, $canUseUnicode);
}
if (!$charset) {
// Make sure kickstart functionality stops
$this->setAllowKickstart(false);
return 'LanguageOptions';
} else {
$i18nINI = eZINI::create('i18n.ini');
// Set ReadOnlySettingsCheck to false: towards
// Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
$i18nINI->setReadOnlySettingsCheck(false);
$i18nINI->setVariable('CharacterSettings', 'Charset', $charset);
$i18nINI->save(false, '.php', 'append', true);
}
$siteINISettings = array();
$result = true;
$accessType = $siteType['access_type'];
$resultArray = array('errors' => array());
$result = $this->initializePackage($siteType, $accessMap, $charset, $allLanguageCodes, $allLanguages, $primaryLanguage, $this->PersistenceList['admin'], $resultArray);
if (!$result) {
$this->Error['errors'] = array_merge($this->Error['errors'], $resultArray['errors']);
$this->Error['errors'][] = array('code' => 'EZSW-040', 'text' => "Failed to initialize site package '" . $siteType['identifier'] . "'");
//$result = false;
return false;
}
if ($resultArray['common_settings']) {
$extraCommonSettings = $resultArray['common_settings'];
foreach ($extraCommonSettings as $extraSetting) {
if ($extraSetting === false) {
continue;
}
$iniName = $extraSetting['name'];
$settings = $extraSetting['settings'];
$resetArray = false;
if (isset($extraSetting['reset_arrays'])) {
$resetArray = $extraSetting['reset_arrays'];
}
if ($iniName == 'site.ini') {
$siteINISettings[] = $settings;
continue;
}
if (file_exists('settings/override/' . $iniName . '.append') || file_exists('settings/override/' . $iniName . '.append.php')) {
$tmpINI = eZINI::instance($iniName, 'settings/override', null, null, false, true);
} else {
$tmpINI = eZINI::create($iniName);
}
//.........这里部分代码省略.........
示例2: checkDatabaseRequirements
/**
* @param string|bool $dbCharset Default charset used if false
* @param array $overrideDBParameters
* @return array
*/
function checkDatabaseRequirements($dbCharset = false, $overrideDBParameters = array())
{
$result = array('error_code' => false, 'use_unicode' => false, 'db_version' => false, 'db_require_version' => false, 'site_charset' => false, 'status' => false);
$databaseMap = eZSetupDatabaseMap();
$databaseInfo = $this->PersistenceList['database_info'];
$databaseInfo['info'] = $databaseMap[$databaseInfo['type']];
$dbDriver = $databaseInfo['info']['driver'];
if ($dbCharset === false) {
$dbCharset = 'iso-8859-1';
}
$dbParameters = array('server' => $databaseInfo['server'], 'port' => $databaseInfo['port'], 'user' => $databaseInfo['user'], 'password' => $databaseInfo['password'], 'socket' => trim($databaseInfo['socket']) == '' ? false : $databaseInfo['socket'], 'database' => $databaseInfo['database'], 'charset' => $dbCharset);
$dbParameters = array_merge($dbParameters, $overrideDBParameters);
// PostgreSQL requires us to specify database name.
// We use template1 here since it exists on all PostgreSQL installations.
if ($dbParameters['database'] == '' and $this->PersistenceList['database_info']['type'] == 'pgsql') {
$dbParameters['database'] = 'template1';
}
try {
$db = eZDB::instance($dbDriver, $dbParameters, true);
$result['db_instance'] = $db;
$result['connected'] = $db->isConnected();
} catch (eZDBNoConnectionException $e) {
$result['error_code'] = self::DB_ERROR_CONNECTION_FAILED;
return $result;
}
// Check if the version of the database fits the minimum required
$dbVersion = $db->databaseServerVersion();
$result['db_version'] = $dbVersion['string'];
$result['db_required_version'] = $databaseInfo['info']['required_version'];
if ($dbVersion != null) {
if (version_compare($result['db_version'], $databaseInfo['info']['required_version']) == -1) {
$result['connected'] = false;
$result['error_code'] = self::DB_ERROR_VERSION_INVALID;
return $result;
}
}
// If we have PostgreSQL we need to make sure we have the 'digest' procedure available.
if ($db->databaseName() == 'postgresql' and $dbParameters['database'] != 'template1') {
$sql = "SELECT count(*) AS count FROM pg_proc WHERE proname='digest'";
$rows = $db->arrayQuery($sql);
$count = $rows[0]['count'];
// If it is 0 we don't have it
if ($count == 0) {
$result['error_code'] = self::DB_ERROR_NO_DIGEST_PROC;
return $result;
}
}
$result['use_unicode'] = false;
if ($db->isCharsetSupported('utf-8')) {
$result['use_unicode'] = true;
}
// If we regional info we can start checking the charset
if (isset($this->PersistenceList['regional_info'])) {
if (isset($this->PersistenceList['regional_info']['site_charset']) and strlen($this->PersistenceList['regional_info']['site_charset']) > 0) {
$charsetsList = array($this->PersistenceList['regional_info']['site_charset']);
} else {
// Figure out charset automatically if it is not set yet
$primaryLanguage = null;
$allLanguages = array();
$allLanguageCodes = array();
$variationsLanguages = array();
$primaryLanguageCode = $this->PersistenceList['regional_info']['primary_language'];
$extraLanguageCodes = isset($this->PersistenceList['regional_info']['languages']) ? $this->PersistenceList['regional_info']['languages'] : array();
$extraLanguageCodes = array_diff($extraLanguageCodes, array($primaryLanguageCode));
/*
if ( isset( $this->PersistenceList['regional_info']['variations'] ) )
{
$variations = $this->PersistenceList['regional_info']['variations'];
foreach ( $variations as $variation )
{
$locale = eZLocale::create( $variation );
if ( $locale->localeCode() == $primaryLanguageCode )
{
$primaryLanguage = $locale;
}
else
{
$variationsLanguages[] = $locale;
}
}
}
*/
if ($primaryLanguage === null) {
$primaryLanguage = eZLocale::create($primaryLanguageCode);
}
$allLanguages[] = $primaryLanguage;
foreach ($extraLanguageCodes as $extraLanguageCode) {
$allLanguages[] = eZLocale::create($extraLanguageCode);
$allLanguageCodes[] = $extraLanguageCode;
}
$charsetsList = $this->findAppropriateCharsetsList($primaryLanguage, $allLanguages, $result['use_unicode']);
}
$checkedCharset = $db->checkCharset($charsetsList, $currentCharset);
if ($checkedCharset === false) {
// If the current charset is utf-8 we use that instead
//.........这里部分代码省略.........
示例3: processPostData
function processPostData()
{
$primaryLanguage = $this->Http->postVariable('eZSetupDefaultLanguage');
$languages = $this->Http->hasPostVariable('eZSetupLanguages') ? $this->Http->postVariable('eZSetupLanguages') : array();
if (!in_array($primaryLanguage, $languages)) {
$languages[] = $primaryLanguage;
}
$regionalInfo = array();
$regionalInfo['language_type'] = 1;
$regionalInfo['primary_language'] = $primaryLanguage;
$regionalInfo['languages'] = $languages;
$regionalInfo['enable_unicode'] = true;
$regionalInfo['site_charset'] = 'utf-8';
$this->PersistenceList['regional_info'] = $regionalInfo;
$charset = false;
//SP experimental code 26.04.2007 commented "if"
// if ( !isset( $this->PersistenceList['database_info']['use_unicode'] ) ||
// $this->PersistenceList['database_info']['use_unicode'] == false )
// {
// If we have already figured out charset and it is utf-8
// we don't have to check the new languages
if (isset($this->PersistenceList['regional_info']['site_charset']) and $this->PersistenceList['regional_info']['site_charset'] == 'utf-8') {
$charset = 'utf-8';
} else {
$primaryLanguage = null;
$allLanguages = array();
$allLanguageCodes = array();
$variationsLanguages = array();
$primaryLanguageCode = $this->PersistenceList['regional_info']['primary_language'];
$extraLanguageCodes = isset($this->PersistenceList['regional_info']['languages']) ? $this->PersistenceList['regional_info']['languages'] : array();
$extraLanguageCodes = array_diff($extraLanguageCodes, array($primaryLanguageCode));
/*
if ( isset( $this->PersistenceList['regional_info']['variations'] ) )
{
$variations = $this->PersistenceList['regional_info']['variations'];
foreach ( $variations as $variation )
{
$locale = eZLocale::create( $variation );
if ( $locale->localeCode() == $primaryLanguageCode )
{
$primaryLanguage = $locale;
}
else
{
$variationsLanguages[] = $locale;
}
}
}
*/
if ($primaryLanguage === null) {
$primaryLanguage = eZLocale::create($primaryLanguageCode);
}
$allLanguages[] = $primaryLanguage;
foreach ($extraLanguageCodes as $extraLanguageCode) {
$allLanguages[] = eZLocale::create($extraLanguageCode);
$allLanguageCodes[] = $extraLanguageCode;
}
$canUseUnicode = isset($this->PersistenceList['database_info']['use_unicode']) ? $this->PersistenceList['database_info']['use_unicode'] : false;
$charset = $this->findAppropriateCharset($primaryLanguage, $allLanguages, $canUseUnicode);
if (!$charset) {
$this->Error = 1;
return false;
}
}
// Store the charset for later handling
$this->PersistenceList['regional_info']['site_charset'] = $charset;
//SP experimental code 26.04.2007 commented "if"
// }
if ($this->PersistenceList['regional_info']['site_charset']) {
$i18nINI = eZINI::create('i18n.ini');
// Set ReadOnlySettingsCheck to false: towards
// Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
$i18nINI->setReadOnlySettingsCheck(false);
$i18nINI->setVariable('CharacterSettings', 'Charset', $this->PersistenceList['regional_info']['site_charset']);
$i18nINI->save(false, '.php', 'append', true);
}
return true;
}