本文整理汇总了PHP中eZContentLanguage::idByLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentLanguage::idByLocale方法的具体用法?PHP eZContentLanguage::idByLocale怎么用?PHP eZContentLanguage::idByLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentLanguage
的用法示例。
在下文中一共展示了eZContentLanguage::idByLocale方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Initialize ezpClass object
*
* @param string $name
* @param string $identifier
* @param string $contentObjectName
* @param int $creatorID
* @param string $language
* @param int $groupID
* @param string $groupName
*/
public function __construct($name = 'Test class', $identifier = 'test_class', $contentObjectName = '<test_attribute>', $creatorID = 14, $language = 'eng-GB', $groupID = 1, $groupName = 'Content')
{
if (eZContentLanguage::fetchByLocale($language) === false) {
$topPriorityLanguage = eZContentLanguage::topPriorityLanguage();
if ($topPriorityLanguage) {
$language = $topPriorityLanguage->attribute('locale');
}
}
$this->language = $language;
$this->class = eZContentClass::create($creatorID, array(), $this->language);
$this->class->setName($name, $this->language);
$this->class->setAttribute('contentobject_name', $contentObjectName);
$this->class->setAttribute('identifier', $identifier);
$this->class->store();
$languageID = eZContentLanguage::idByLocale($this->language);
$this->class->setAlwaysAvailableLanguageID($languageID);
$this->classGroup = eZContentClassClassGroup::create($this->id, $this->version, $groupID, $groupName);
$this->classGroup->store();
}
示例2: array
}
} else {
if ($http->hasPostVariable('ClassIdentifier')) {
$contentClassIdentifier = $http->postVariable('ClassIdentifier');
$class = eZContentClass::fetchByIdentifier($contentClassIdentifier);
if (is_object($class)) {
$contentClassID = $class->attribute('id');
if ($contentClassID) {
$hasClassInformation = true;
}
}
}
}
if ($http->hasPostVariable('ContentLanguageCode')) {
$languageCode = $http->postVariable('ContentLanguageCode');
$languageID = eZContentLanguage::idByLocale($languageCode);
if ($languageID === false) {
eZDebug::writeError("The language code [{$languageCode}] specified in ContentLanguageCode does not exist in the system.");
return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
} else {
$allLanguages = eZContentLanguage::prioritizedLanguages();
// Only show language selection if there are more than 1 languages.
if (count($allLanguages) > 1 && $hasClassInformation) {
$tpl = eZTemplate::factory();
$tpl->setVariable('node_id', $http->postVariable('NodeID'));
$tpl->setVariable('class_id', $contentClassID);
$tpl->setVariable('assignment_remote_id', $http->postVariable('AssignmentRemoteID', false));
$tpl->setVariable('redirect_uri_after_publish', $http->postVariable('RedirectURIAfterPublish', false));
$tpl->setVariable('redirect_uri_after_discard', $http->postVariable('RedirectIfDiscarded', false));
$Result = array();
示例3: translationByLocale
public function translationByLocale($locale)
{
$languageID = eZContentLanguage::idByLocale($locale);
if ($languageID) {
$translations = $this->allTranslations();
foreach ($translations as $translation) {
if ($translation->realLanguageID() == $languageID) {
return $translation;
}
}
}
return false;
}
示例4: setName
function setName($name, $languageLocale = false)
{
if (!$languageLocale) {
$languageLocale = $this->topPriorityLanguageLocale();
}
$this->NameList->setNameByLanguageLocale($name, $languageLocale);
$languageID = eZContentLanguage::idByLocale($languageLocale);
$languageMask = $this->attribute('language_mask');
$this->setAttribute('language_mask', $languageMask | $languageID);
}
示例5: checkAccess
function checkAccess($functionName, $originalClassID = false, $parentClassID = false, $returnAccessList = false, $language = false)
{
$classID = $originalClassID;
$user = eZUser::currentUser();
$userID = $user->attribute('contentobject_id');
// Fetch the ID of the language if we get a string with a language code
// e.g. 'eng-GB'
$originalLanguage = $language;
if (is_string($language) && strlen($language) > 0) {
$language = eZContentLanguage::idByLocale($language);
} else {
$language = false;
}
// This will be filled in with the available languages of the object
// if a Language check is performed.
$languageList = false;
// This will be filled if parent object is needed.
$parentObject = false;
$origFunctionName = $functionName;
// The 'move' function simply reuses 'edit' for generic access
// but adds another top-level check below
// The original function is still available in $origFunctionName
if ($functionName == 'move') {
$functionName = 'edit';
}
// Manage locations depends if it's removal or not.
if ($functionName == 'can_add_location' || $functionName == 'can_remove_location') {
$functionName = 'manage_locations';
}
$accessResult = $user->hasAccessTo('content', $functionName);
$accessWord = $accessResult['accessWord'];
if ($origFunctionName == 'can_remove_location') {
if ($this->ParentNodeID <= 1) {
return 0;
}
$currentNode = eZContentObjectTreeNode::fetch($this->ParentNodeID);
if (!$currentNode instanceof eZContentObjectTreeNode) {
return 0;
}
$contentObject = $currentNode->attribute('object');
} else {
$currentNode = $this;
$contentObject = $this->attribute('object');
}
/*
// Uncomment this part if 'create' permissions should become implied 'edit'.
// Merges in 'create' policies with 'edit'
if ( $functionName == 'edit' &&
!in_array( $accessWord, array( 'yes', 'no' ) ) )
{
// Add in create policies.
$accessExtraResult = $user->hasAccessTo( 'content', 'create' );
if ( $accessExtraResult['accessWord'] != 'no' )
{
$accessWord = $accessExtraResult['accessWord'];
if ( isset( $accessExtraResult['policies'] ) )
{
$accessResult['policies'] = array_merge( $accessResult['policies'],
$accessExtraResult['policies'] );
}
if ( isset( $accessExtraResult['accessList'] ) )
{
$accessResult['accessList'] = array_merge( $accessResult['accessList'],
$accessExtraResult['accessList'] );
}
}
}
*/
if ($origFunctionName == 'remove' or $origFunctionName == 'move' or $origFunctionName == 'can_remove_location') {
// We do not allow these actions on top-level nodes
// - remove
// - move
if ($this->ParentNodeID <= 1) {
return 0;
}
}
if ($classID === false) {
$classID = $contentObject->attribute('contentclass_id');
}
if ($accessWord == 'yes') {
return 1;
} else {
if ($accessWord == 'no') {
if ($functionName == 'edit') {
// Check if we have 'create' access under the main parent
$object = $currentNode->object();
if ($object && $object->attribute('current_version') == 1 && !$object->attribute('status')) {
$mainNode = eZNodeAssignment::fetchForObject($object->attribute('id'), $object->attribute('current_version'));
$parentObj = $mainNode[0]->attribute('parent_contentobject');
if ($parentObj instanceof eZContentObject) {
$result = $parentObj->checkAccess('create', $object->attribute('contentclass_id'), $parentObj->attribute('contentclass_id'), false, $originalLanguage);
return $result;
} else {
eZDebug::writeError("Error retrieving parent object of main node for object id: " . $object->attribute('id'), __METHOD__);
}
}
}
return 0;
} else {
$policies = $accessResult['policies'];
//.........这里部分代码省略.........
示例6: createNewRelatedObject
function createNewRelatedObject($http, $action, $objectAttribute, $parameters)
{
$hasClassInformation = false;
$contentClassID = false;
$contentClassIdentifier = false;
$languageCode = false;
$class = false;
$languageCode = $objectAttribute->attribute('language_code');
$originalContentObjectID = $objectAttribute->attribute('contentobject_id');
$originalContentObjectVersion = $objectAttribute->attribute('version');
$contentObject = false;
$addVersion = false;
if ($this->Num != 0) {
$contentObject = eZContentObject::fetch($this->Num);
}
if ($this->Num == 0 or !(get_class($contentObject) == 'eZContentObject')) {
$addVersion = true;
$ini = eZINI::instance('ezsurvey.ini');
$configList = eZSurveyRelatedConfig::fetchList();
if (count($configList) > 0) {
$config = $configList[0];
$contentClassID = $config->attribute('contentclass_id');
$contentClass = eZContentClass::fetch($contentClassID);
$nodeID = $config->attribute('node_id');
$attributeParentNode = eZContentObjectTreeNode::fetch($nodeID);
if (get_class($contentClass) == 'eZContentClass' and get_class($attributeParentNode) == 'eZContentObjectTreeNode') {
$languageID = eZContentLanguage::idByLocale($languageCode);
$contentObject = eZContentObject::fetch($objectAttribute->attribute('contentobject_id'));
$node = eZContentObjectTreeNode::fetch($nodeID, $languageCode);
if (get_class($node) == "eZContentObjectTreeNode") {
$contentObject = eZContentObject::createWithNodeAssignment($node, $contentClassID, $languageCode, false);
} else {
eZDebug::writeWarning('node is not a valid eZContentObjectTreeNode', 'eZSurveyRelatedObject::createNewRelatedObject');
}
} else {
eZDebug::writeWarning('Config is not valid', 'eZSurveyRelatedObject::createNewRelatedObject');
}
}
}
if ($contentObject) {
$redirectHref = 'content/edit/' . $originalContentObjectID . '/' . $originalContentObjectVersion;
$http->setSessionVariable('LastAccessesURI_Backup_' . $originalContentObjectID . '_' . $this->ID, array('content' => $http->sessionVariable('LastAccessesURI')));
$http->setSessionVariable('RedirectURIAfterPublish_Backup_' . $originalContentObjectID . '_' . $this->ID, array('content' => $http->sessionVariable('RedirectURIAfterPublish')));
$http->setSessionVariable('RedirectIfDiscarded_Backup_' . $originalContentObjectID . '_' . $this->ID, array('content' => $http->sessionVariable('RedirectIfDiscarded')));
$http->setSessionVariable('LastAccessesURI', $redirectHref);
$http->setSessionVariable('RedirectURIAfterPublish', $redirectHref);
$http->setSessionVariable('RedirectIfDiscarded', $redirectHref);
$this->Num = $contentObject->attribute('id');
$this->store();
$parameters = array($contentObject->attribute('id'));
if ($addVersion === true) {
$parameters[] = $contentObject->attribute('current_version');
}
$module = $GLOBALS['module'];
$module->redirectToView('edit', $parameters);
}
return true;
}
示例7: array
$language = eZContentLanguage::topPriorityLanguage();
if ($language) {
$EditLanguage = $language->attribute('locale');
} else {
eZDebug::writeError('Undefined default language', 'class/edit.php');
$Module->setExitStatus(eZModule::STATUS_FAILED);
return;
}
}
if (is_numeric($GroupID) and is_string($GroupName) and $GroupName != '') {
$user = eZUser::currentUser();
$user_id = $user->attribute('contentobject_id');
$class = eZContentClass::create($user_id, array(), $EditLanguage);
$class->setName(ezpI18n::tr('kernel/class/edit', 'New Class'), $EditLanguage);
$class->store();
$editLanguageID = eZContentLanguage::idByLocale($EditLanguage);
$class->setAlwaysAvailableLanguageID($editLanguageID);
$ClassID = $class->attribute('id');
$ClassVersion = $class->attribute('version');
$ingroup = eZContentClassClassGroup::create($ClassID, $ClassVersion, $GroupID, $GroupName);
$ingroup->store();
$Module->redirectTo($Module->functionURI('edit') . '/' . $ClassID . '/(language)/' . $EditLanguage);
return;
} else {
$errorResponseGroupName = $GroupName == '' ? '<Empty name>' : $GroupName;
$errorResponseGroupID = !is_numeric($GroupID) ? '<Empty ID>' : $GroupID;
eZDebug::writeError("Unknown class group: {$errorResponseGroupName} (ID: {$errorResponseGroupID})", 'Kernel - Class - Edit');
$Module->setExitStatus(eZModule::STATUS_FAILED);
return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
}
示例8: create
static function create( $contentobjectID, $userID = false, $version = 1, $initialLanguageCode = false )
{
if ( $userID === false )
{
$user = eZUser::currentUser();
$userID = $user->attribute( 'contentobject_id' );
}
$time = time();
if ( $initialLanguageCode == false )
{
$initialLanguageCode = eZContentObject::defaultLanguage();
}
$initialLanguageID = eZContentLanguage::idByLocale( $initialLanguageCode );
$row = array(
"contentobject_id" => $contentobjectID,
'initial_language_id' => $initialLanguageID,
'language_mask' => $initialLanguageID,
"version" => $version,
"created" => $time,
"modified" => $time,
'creator_id' => $userID );
return new eZContentObjectVersion( $row );
}
示例9: languageMask
function languageMask()
{
$mask = 0;
foreach ($this->NameList as $languageLocale => $name) {
if ($languageLocale == eZSerializedObjectNameList::ALWAYS_AVAILABLE_STR) {
$mask += 1;
} else {
$languageID = eZContentLanguage::idByLocale($languageLocale);
$mask += $languageID;
}
}
return $mask;
}
示例10: createClass
private function createClass($displayName, $classIdentifier, $groupIdentifier, $groupId)
{
$adminUserObject = eZUser::fetchByName("admin");
$adminUserObject->loginCurrent();
$adminUserId = $adminUserObject->attribute('contentobject_id');
$language = eZContentLanguage::topPriorityLanguage();
$editLanguage = $language->attribute('locale');
$class = eZContentClass::create($adminUserId, array(), $editLanguage);
// this is the display name, ez automatically creates the content-class-identifier from it
$class->setName($displayName, $editLanguage);
$class->setAttribute("identifier", $classIdentifier);
// default naming for objects - content classes should update this value once they have attributes added
$class->setAttribute('contentobject_name', 'eep-created-content-class');
$class->store();
$editLanguageID = eZContentLanguage::idByLocale($editLanguage);
$class->setAlwaysAvailableLanguageID($editLanguageID);
$ClassID = $class->attribute('id');
$ClassVersion = $class->attribute('version');
$ingroup = eZContentClassClassGroup::create($ClassID, $ClassVersion, $groupId, $groupIdentifier);
$ingroup->store();
// clean up the content class status
$class->storeDefined(array());
$adminUserObject->logoutCurrent();
}
示例11: createNew
protected function createNew($identifier)
{
$remote = self::fetchRemoteByIdentifier($identifier);
if ($remote === null) {
throw new Exception("Classe remota non trovata");
}
$this->syncAllGroups($remote);
$classGroup = false;
foreach ($remote->InGroups as $group) {
$classGroup = eZContentClassGroup::fetchByName($group->GroupName);
if ($classGroup instanceof eZContentClassGroup) {
break;
}
}
if (!$classGroup instanceof eZContentClassGroup) {
throw new Exception('Errore creando la nuova classe');
}
$db = eZDB::instance();
$db->begin();
$options = array('serialized_name_list' => $remote->SerializedNameList, 'serialized_description_list' => $remote->SerializedDescriptionList);
$user = eZUser::currentUser();
$userID = $user->attribute('contentobject_id');
$class = eZContentClass::create($userID, $options, $this->EditLanguage);
$class->setName('New automatic', $this->EditLanguage);
$class->store();
$editLanguageID = eZContentLanguage::idByLocale($this->EditLanguage);
$class->setAlwaysAvailableLanguageID($editLanguageID);
$ClassID = $class->attribute('id');
$ClassVersion = $class->attribute('version');
$ingroup = eZContentClassClassGroup::create($ClassID, $ClassVersion, $classGroup->attribute('id'), $classGroup->attribute('name'));
$ingroup->store();
$class->setAttribute('identifier', $identifier);
foreach ($this->properties as $identifier => $remoteProperty) {
$class->setAttribute($identifier, $remote->{$remoteProperty});
}
$class->storeVersioned(array(), eZContentClass::VERSION_STATUS_DEFINED);
$db->commit();
return $class;
}
示例12: linkTag
/**
* Links the content object attribute and tag
*
* @static
*
* @param eZContentObjectAttribute $attribute
* @param eZTagsObject $tagObject
* @param string $keyword
* @param string $locale
*/
private static function linkTag(eZContentObjectAttribute $attribute, eZTagsObject $tagObject, $keyword, $locale, $priority)
{
$languageID = eZContentLanguage::idByLocale($locale);
if ($languageID === false) {
return;
}
if ($locale == $attribute->attribute('language_code')) {
if (!$tagObject->hasTranslation($locale)) {
$tagKeywordObject = new eZTagsKeyword(array('keyword_id' => $tagObject->attribute('id'), 'language_id' => $languageID, 'keyword' => $keyword, 'locale' => $locale, 'status' => eZTagsKeyword::STATUS_PUBLISHED));
$tagKeywordObject->store();
$tagObject->updateLanguageMask();
}
}
$linkObject = new eZTagsAttributeLinkObject(array('keyword_id' => $tagObject->attribute('id'), 'objectattribute_id' => $attribute->attribute('id'), 'objectattribute_version' => $attribute->attribute('version'), 'object_id' => $attribute->attribute('contentobject_id'), 'priority' => $priority));
$linkObject->store();
}