本文整理匯總了PHP中eZContentLanguage::prioritizedLanguages方法的典型用法代碼示例。如果您正苦於以下問題:PHP eZContentLanguage::prioritizedLanguages方法的具體用法?PHP eZContentLanguage::prioritizedLanguages怎麽用?PHP eZContentLanguage::prioritizedLanguages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類eZContentLanguage
的用法示例。
在下文中一共展示了eZContentLanguage::prioritizedLanguages方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: array
$limit = 25;
$filter->prepare();
// Reset SQLs from previous calls
$filter->actions = array('eznode:' . $node->attribute('node_id'));
$filter->type = 'alias';
$filter->offset = $Offset;
$filter->limit = $limit;
$count = $filter->count();
$aliasList = $filter->fetchAll();
$path = array();
$nodePath = $node->attribute('path');
foreach ($nodePath as $pathEntry) {
$url = $pathEntry->attribute('url_alias');
if (strlen($url) == 0) {
$url = 'content/view/full/' . $pathEntry->attribute('node_id');
}
$path[] = array('url' => $url, 'text' => $pathEntry->attribute('name'));
}
$path[] = array('url' => false, 'text' => $node->attribute('name'));
$languages = eZContentLanguage::prioritizedLanguages();
$tpl->setVariable('node', $node);
$tpl->setVariable('filter', $filter);
$tpl->setVariable('elements', $elements);
$tpl->setVariable('languages', $languages);
$tpl->setVariable('info_code', $infoCode);
$tpl->setVariable('info_data', $infoData);
$tpl->setVariable('aliasText', $aliasText);
$tpl->setVariable('view_parameters', $viewParameters);
$Result = array();
$Result['content'] = $tpl->fetch('design:content/urlalias.tpl');
$Result['path'] = $path;
示例2: languageScore
private static function languageScore($mask)
{
$prioritizedLanguages = eZContentLanguage::prioritizedLanguages();
$scores = array();
$score = 1;
$mask = (int) $mask;
krsort($prioritizedLanguages);
foreach ($prioritizedLanguages as $prioritizedLanguage) {
$id = (int) $prioritizedLanguage->attribute('id');
if ($id & $mask) {
$scores[] = $score;
}
++$score;
}
if (count($scores) > 0) {
return max($scores);
} else {
return 0;
}
}
示例3: fetchPrioritizedLanguages
public static function fetchPrioritizedLanguages()
{
$languages = eZContentLanguage::prioritizedLanguages();
if ($languages === null) {
$result = array('error' => array('error_type' => 'kernel', 'error_code' => eZError::KERNEL_NOT_FOUND));
} else {
$result = array('result' => $languages);
}
return $result;
}
示例4: initializePackage
//.........這裏部分代碼省略.........
$engines = $db->arrayQuery('SHOW ENGINES');
foreach ($engines as $engine) {
if ($engine['Engine'] == 'InnoDB' && in_array($engine['Support'], array('YES', 'DEFAULT'))) {
$params['table_type'] = 'innodb';
break;
}
}
}
if (!$dbSchema->insertSchema($params)) {
$resultArray['errors'][] = array('code' => 'EZSW-004', 'text' => "Failed inserting data to " . $db->databaseName() . "\n" . $db->errorMessage());
$result = false;
}
}
}
}
if ($result) {
// Inserting data from the dba-data files of the datatypes
eZDataType::loadAndRegisterAllTypes();
$registeredDataTypes = eZDataType::registeredDataTypes();
foreach ($registeredDataTypes as $dataType) {
if (!$dataType->importDBDataFromDBAFile()) {
$resultArray['errors'][] = array('code' => 'EZSW-002', 'text' => "Failed importing datatype related data into database: \n" . 'datatype - ' . $dataType->DataTypeString . ", \n" . 'dba-data file - ' . $dataType->getDBAFilePath());
}
}
}
}
if (!$result) {
return false;
}
// Database initialization done
// Prepare languages
$primaryLanguageLocaleCode = $primaryLanguage->localeCode();
$primaryLanguageName = $primaryLanguage->languageName();
$prioritizedLanguages = array_merge(array($primaryLanguageLocaleCode), $extraLanguageCodes);
$installParameters = array('path' => '.');
$installParameters['ini'] = array();
$siteINIChanges = array();
$url = $siteType['url'];
if (preg_match("#^[a-zA-Z0-9]+://(.*)\$#", $url, $matches)) {
$url = $matches[1];
}
$siteINIChanges['SiteAccessSettings'] = array('RelatedSiteAccessList' => $accessMap['accesses']);
$siteINIChanges['ContentSettings'] = array('TranslationList' => implode(';', $extraLanguageCodes));
$siteINIChanges['SiteSettings'] = array('SiteName' => $siteType['title'], 'SiteURL' => $url);
$siteINIChanges['DatabaseSettings'] = array('DatabaseImplementation' => $dbDriver, 'Server' => $dbServer, 'Port' => $dbPort, 'Database' => $dbName, 'User' => $dbUser, 'Password' => $dbPwd, 'Charset' => false);
$siteINIChanges['FileSettings'] = array('VarDir' => 'var/' . $siteType['identifier']);
if (trim($dbSocket) != '') {
$siteINIChanges['DatabaseSettings']['Socket'] = $dbSocket;
} else {
$siteINIChanges['DatabaseSettings']['Socket'] = 'disabled';
}
if ($admin['email']) {
$siteINIChanges['InformationCollectionSettings'] = array('EmailReceiver' => false);
$siteINIChanges['UserSettings'] = array('RegistrationEmail' => false);
$siteINIChanges['MailSettings'] = array('AdminEmail' => $admin['email'], 'EmailSender' => false);
}
$siteINIChanges['RegionalSettings'] = array('Locale' => $primaryLanguage->localeFullCode(), 'ContentObjectLocale' => $primaryLanguage->localeCode(), 'SiteLanguageList' => $prioritizedLanguages);
if ($primaryLanguage->localeCode() == 'eng-GB') {
$siteINIChanges['RegionalSettings']['TextTranslation'] = 'disabled';
} else {
$siteINIChanges['RegionalSettings']['TextTranslation'] = 'enabled';
}
$installParameters['ini']['siteaccess'][$adminSiteaccessName]['site.ini.append'] = $siteINIChanges;
$installParameters['ini']['siteaccess'][$userSiteaccessName]['site.ini.append'] = $siteINIChanges;
$installParameters['ini']['siteaccess'][$userSiteaccessName]['site.ini']['DesignSettings'] = array('SiteDesign' => $userDesignName);
$installParameters['variables']['user_siteaccess'] = $userSiteaccessName;
示例5: sqlFilter
/**
* Returns the SQL where-condition for selecting the rows (with object names, attributes etc.) in the correct language,
* i. e. in the most prioritized language from those in which an object exists.
*
* @param string $languageTable Name of the table containing the attribute with the language id.
* @param string $languageListTable Name of the table containing the attribute with the available languages bitmap.
* @param string $languageAttributeName Optional. Name of the attribute in $languageTable which contains
* the language id. 'language_id' by default.
* @param string $languageListAttributeName Optional. Name of the attribute in $languageListTable which contains
* the bitmap mask. 'language_mask' by default.
* @param string $lang Language code of the most prioritized language
* @return string
*/
static function sqlFilter($languageTable, $languageListTable = null, $languageAttributeName = 'language_id', $languageListAttributeName = 'language_mask', $lang = false)
{
$db = eZDB::instance();
if ($languageListTable === null) {
$languageListTable = $languageTable;
}
$prioritizedLanguages = eZContentLanguage::prioritizedLanguages();
if (is_string($lang)) {
$lang = eZContentLanguage::fetchByLocale($lang);
}
if ($lang instanceof eZContentLanguage) {
array_unshift($prioritizedLanguages, $lang);
}
if ($db->databaseName() == 'oracle') {
$leftSide = "bitand( {$languageListTable}.{$languageListAttributeName} - bitand( {$languageListTable}.{$languageListAttributeName}, {$languageTable}.{$languageAttributeName} ), 1 )\n";
$rightSide = "bitand( {$languageTable}.{$languageAttributeName}, 1 )\n";
} else {
$leftSide = " ( ( {$languageListTable}.{$languageListAttributeName} - ( {$languageListTable}.{$languageListAttributeName} & {$languageTable}.{$languageAttributeName} ) ) & 1 )\n";
$rightSide = " ( {$languageTable}.{$languageAttributeName} & 1 )\n";
}
for ($index = count($prioritizedLanguages) - 1, $multiplier = 2; $index >= 0; $index--, $multiplier *= 2) {
$id = $prioritizedLanguages[$index]->attribute('id');
if ($db->databaseName() == 'oracle') {
$leftSide .= " + bitand( {$languageListTable}.{$languageListAttributeName} - bitand( {$languageListTable}.{$languageListAttributeName}, {$languageTable}.{$languageAttributeName} ), {$id} )";
$rightSide .= " + bitand( {$languageTable}.{$languageAttributeName}, {$id} )";
} else {
$leftSide .= " + ( ( ( {$languageListTable}.{$languageListAttributeName} - ( {$languageListTable}.{$languageListAttributeName} & {$languageTable}.{$languageAttributeName} ) ) & {$id} )";
$rightSide .= " + ( ( {$languageTable}.{$languageAttributeName} & {$id} )";
}
if ($multiplier > $id) {
$factor = $multiplier / $id;
if ($db->databaseName() == 'oracle') {
$factorTerm = ' * ' . $factor;
} else {
for ($shift = 0; $factor > 1; $factor = $factor / 2, $shift++) {
}
$factorTerm = ' << ' . $shift;
}
$leftSide .= $factorTerm;
$rightSide .= $factorTerm;
} else {
if ($multiplier < $id) {
$factor = $id / $multiplier;
if ($db->databaseName() == 'oracle') {
$factorTerm = ' / ' . $factor;
} else {
for ($shift = 0; $factor > 1; $factor = $factor / 2, $shift++) {
}
$factorTerm = ' >> ' . $shift;
}
$leftSide .= $factorTerm;
$rightSide .= $factorTerm;
}
}
if ($db->databaseName() != 'oracle') {
$leftSide .= " )\n";
$rightSide .= " )\n";
}
}
if ($db->databaseName() == 'oracle') {
$sql = "bitand( {$languageTable}.{$languageAttributeName}, {$languageListTable}.{$languageListAttributeName} ) > 0";
} else {
$sql = "{$languageTable}.{$languageAttributeName} & {$languageListTable}.{$languageListAttributeName} > 0";
}
return "\n ( {$sql} AND\n {$leftSide} <\n {$rightSide} ) \n";
}
示例6: unserialize
//.........這裏部分代碼省略.........
if ( $importedLanguage == 'skip' )
continue;
// if there is no needed translation in system then add it
$locale = eZLocale::instance( $importedLanguage );
$translationName = $locale->internationalLanguageName();
$translationLocale = $locale->localeCode();
if ( $locale->isValid() )
{
eZContentLanguage::addLanguage( $locale->localeCode(), $locale->internationalLanguageName() );
$hasTranslation = true;
}
else
$hasTranslation = false;
}
if ( $hasTranslation )
{
$importedLanguages[] = $importedLanguage;
$importedLanguages = array_unique( $importedLanguages );
}
}
}
// If object exists we return a error.
// Minimum install element is an object now.
$contentObject = eZContentObject::fetchByRemoteID( $remoteID );
// Figure out initial language
if ( !$initialLanguage ||
!in_array( $initialLanguage, $importedLanguages ) )
{
$initialLanguage = false;
foreach ( eZContentLanguage::prioritizedLanguages() as $language )
{
if ( in_array( $language->attribute( 'locale' ), $importedLanguages ) )
{
$initialLanguage = $language->attribute( 'locale' );
break;
}
}
}
if ( !$contentObject )
{
$firstVersion = true;
$contentObject = $contentClass->instantiateIn( $initialLanguage, $ownerID, $sectionID );
}
else
{
$firstVersion = false;
$description = "Object '$name' already exists.";
$choosenAction = eZPackageHandler::errorChoosenAction( self::PACKAGE_ERROR_EXISTS,
$options, $description, $handlerType, false );
switch( $choosenAction )
{
case eZPackage::NON_INTERACTIVE:
case self::PACKAGE_UPDATE:
{
// Keep existing contentobject.
} break;
case self::PACKAGE_REPLACE:
{
eZContentObjectOperations::remove( $contentObject->attribute( 'id' ) );
示例7: unserialize
static function unserialize( $domNode, $contentObject, $ownerID, $sectionID, $activeVersion, $firstVersion, &$nodeList, &$options, $package, $handlerType = 'ezcontentobject' )
{
$oldVersion = $domNode->getAttributeNS( 'http://ez.no/ezobject', 'version' );
$status = $domNode->getAttributeNS( 'http://ez.no/ezobject', 'status' );
$languageNodeArray = $domNode->getElementsByTagName( 'object-translation' );
$initialLanguage = false;
$importedLanguages = $options['language_array'];
$currentLanguages = array();
foreach( $languageNodeArray as $languageNode )
{
$language = eZContentObjectVersion::mapLanguage( $languageNode->getAttribute( 'language' ), $options );
if ( in_array( $language, $importedLanguages ) )
{
$currentLanguages[] = $language;
}
}
foreach ( eZContentLanguage::prioritizedLanguages() as $language )
{
if ( in_array( $language->attribute( 'locale' ), $currentLanguages ) )
{
$initialLanguage = $language->attribute( 'locale' );
break;
}
}
if ( !$initialLanguage )
{
$initialLanguage = $currentLanguages[0];
}
if ( $firstVersion )
{
$contentObjectVersion = $contentObject->version( 1 );
}
else
{
// Create new version in specific language but with empty data.
$contentObjectVersion = $contentObject->createNewVersionIn( $initialLanguage );
}
$created = eZDateUtils::textToDate( $domNode->getAttributeNS( 'http://ez.no/ezobject', 'created' ) );
$modified = eZDateUtils::textToDate( $domNode->getAttributeNS( 'http://ez.no/ezobject', 'modified' ) );
$contentObjectVersion->setAttribute( 'created', $created );
$contentObjectVersion->setAttribute( 'modified', $modified );
$contentObjectVersion->setAttribute( 'status', eZContentObjectVersion::STATUS_DRAFT );
$contentObjectVersion->store();
$db = eZDB::instance();
$db->begin();
foreach( $languageNodeArray as $languageNode )
{
$language = eZContentObjectVersion::mapLanguage( $languageNode->getAttribute( 'language' ), $options );
// Only import allowed languages.
if ( !in_array( $language, $importedLanguages ) )
{
continue;
}
$attributeArray = $contentObjectVersion->contentObjectAttributes( $language );
if ( count( $attributeArray ) == 0)
{
$hasTranslation = eZContentLanguage::fetchByLocale( $language );
if ( !$hasTranslation )
{
// if there is no needed translation in system then add it
$locale = eZLocale::instance( $language );
if ( $locale->isValid() )
{
eZContentLanguage::addLanguage( $locale->localeCode(), $locale->internationalLanguageName() );
$hasTranslation = true;
}
else
$hasTranslation = false;
}
if ( $hasTranslation )
{
// Add translated attributes for the translation
$originalContentAttributes = $contentObjectVersion->contentObjectAttributes( $initialLanguage );
foreach ( $originalContentAttributes as $originalContentAttribute )
{
$contentAttribute = $originalContentAttribute->translateTo( $language );
$contentAttribute->sync();
$attributeArray[] = $contentAttribute;
}
}
// unserialize object name in current version-translation
$objectName = $languageNode->getAttribute( 'object_name' );
if ( $objectName )
$contentObject->setName( $objectName, $contentObjectVersion->attribute( 'version' ), $language );
}
$xpath = new DOMXPath( $domNode->ownerDocument );
$xpath->registerNamespace( 'ezobject', 'http://ez.no/object/' );
$xpath->registerNamespace( 'ezremote', 'http://ez.no/ezobject' );
//.........這裏部分代碼省略.........
示例8: untranslatedLanguages
function untranslatedLanguages()
{
$availableLanguages = $this->prioritizedLanguages();
$availableLanguagesCodes = array_keys($availableLanguages);
$languages = array();
foreach (eZContentLanguage::prioritizedLanguages() as $language) {
$languageCode = $language->attribute('locale');
if (!in_array($languageCode, $availableLanguagesCodes)) {
$languages[$languageCode] = $language;
}
}
return $languages;
}
示例9: sqlFilter
/**
* Returns the SQL where-condition for selecting the rows (with object names, attributes etc.) in the correct language,
* i. e. in the most prioritized language from those in which an object exists.
*
* \param languageTable Name of the table containing the attribute with the language id.
* \param languageListTable Name of the table containing the attribute with the available languages bitmap.
* \param languageAttributeName Optional. Name of the attribute in $languageTable which contains
* the language id. 'language_id' by default.
* \param languageListAttributeName Optional. Name of the attribute in $languageListTable which contains
* the bitmap mask. 'language_mask' by default.
* \return SQL where-condition described above.
*/
static function sqlFilter( $languageTable, $languageListTable = null, $languageAttributeName = 'language_id', $languageListAttributeName = 'language_mask' )
{
$db = eZDB::instance();
if ( $languageListTable === null )
{
$languageListTable = $languageTable;
}
$prioritizedLanguages = eZContentLanguage::prioritizedLanguages();
if ( $db->databaseName() == 'oracle' )
{
$leftSide = "bitand( $languageListTable.$languageListAttributeName - bitand( $languageListTable.$languageListAttributeName, $languageTable.$languageAttributeName ), 1 )\n";
$rightSide = "bitand( $languageTable.$languageAttributeName, 1 )\n";
}
else
{
$leftSide = " ( ( $languageListTable.$languageListAttributeName - ( $languageListTable.$languageListAttributeName & $languageTable.$languageAttributeName ) ) & 1 )\n";
$rightSide = " ( $languageTable.$languageAttributeName & 1 )\n";
}
for ( $index = count( $prioritizedLanguages ) - 1, $multiplier = 2; $index >= 0; $index--, $multiplier *= 2 )
{
$id = $prioritizedLanguages[$index]->attribute( 'id' );
if ( $db->databaseName() == 'oracle' )
{
$leftSide .= " + bitand( $languageListTable.$languageListAttributeName - bitand( $languageListTable.$languageListAttributeName, $languageTable.$languageAttributeName ), $id )";
$rightSide .= " + bitand( $languageTable.$languageAttributeName, $id )";
}
else
{
$leftSide .= " + ( ( ( $languageListTable.$languageListAttributeName - ( $languageListTable.$languageListAttributeName & $languageTable.$languageAttributeName ) ) & $id )";
$rightSide .= " + ( ( $languageTable.$languageAttributeName & $id )";
}
if ( $multiplier > $id )
{
$factor = $multiplier / $id;
if ( $db->databaseName() == 'oracle' )
{
$factorTerm = ' * ' . $factor;
}
else
{
for ( $shift = 0; $factor > 1; $factor = $factor / 2, $shift++ ) ;
$factorTerm = ' << '. $shift;
}
$leftSide .= $factorTerm;
$rightSide .= $factorTerm;
}
else if ( $multiplier < $id )
{
$factor = $id / $multiplier;
if ( $db->databaseName() == 'oracle' )
{
$factorTerm = ' / ' . $factor;
}
else
{
for ( $shift = 0; $factor > 1; $factor = $factor / 2, $shift++ ) ;
$factorTerm = ' >> '. $shift;
}
$leftSide .= $factorTerm;
$rightSide .= $factorTerm;
}
if ( $db->databaseName() != 'oracle' )
{
$leftSide .= " )\n";
$rightSide .= " )\n";
}
}
if ( $db->databaseName() == 'oracle' )
{
$sql = "bitand( $languageTable.$languageAttributeName, $languageListTable.$languageListAttributeName ) > 0";
}
else
{
$sql = "$languageTable.$languageAttributeName & $languageListTable.$languageListAttributeName > 0";
}
return "\n ( $sql AND\n $leftSide <\n $rightSide ) \n";
}