本文整理汇总了PHP中eZContentObjectAttribute::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectAttribute::remove方法的具体用法?PHP eZContentObjectAttribute::remove怎么用?PHP eZContentObjectAttribute::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectAttribute
的用法示例。
在下文中一共展示了eZContentObjectAttribute::remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeTranslation
/**
* Removes a translation from the current object
*
* @param int $languageID
* @return bool
*/
function removeTranslation( $languageID )
{
$language = eZContentLanguage::fetch( $languageID );
if ( !$language )
{
return false;
}
// check permissions for editing
if ( !$this->checkAccess( 'edit', false, false, false, $languageID ) )
{
return false;
}
// check if it is not the initial language
$objectInitialLanguageID = $this->attribute( 'initial_language_id' );
if ( $objectInitialLanguageID == $languageID )
{
return false;
}
// change language_mask of the object
$languageMask = (int) $this->attribute( 'language_mask' );
$languageMask = (int) $languageMask & ~ (int) $languageID;
$this->setAttribute( 'language_mask', $languageMask );
$db = eZDB::instance();
$db->begin();
$this->store();
$objectID = $this->ID;
// If the current version has initial_language_id $languageID, change it to the initial_language_id of the object.
$currentVersion = $this->currentVersion();
if ( $currentVersion->attribute( 'initial_language_id' ) == $languageID )
{
$currentVersion->setAttribute( 'initial_language_id', $objectInitialLanguageID );
$currentVersion->store();
}
// Remove all versions which had the language as its initial ID. Because of previous checks, it is sure we will not remove the published version.
$versionsToRemove = $this->versions( true, array( 'conditions' => array( 'initial_language_id' => $languageID ) ) );
foreach ( $versionsToRemove as $version )
{
$version->removeThis();
}
$altLanguageID = $languageID++;
// Remove all attributes in the language
$attributes = $db->arrayQuery( "SELECT * FROM ezcontentobject_attribute
WHERE contentobject_id='$objectID'
AND ( language_id='$languageID' OR language_id='$altLanguageID' )" );
foreach ( $attributes as $attribute )
{
$attributeObject = new eZContentObjectAttribute( $attribute );
$attributeObject->remove( $attributeObject->attribute( 'id' ), $attributeObject->attribute( 'version' ) );
unset( $attributeObject );
}
// Remove all names in the language
$db->query( "DELETE FROM ezcontentobject_name
WHERE contentobject_id='$objectID'
AND ( language_id='$languageID' OR language_id='$altLanguageID' )" );
// Update masks of the objects
$mask = eZContentLanguage::maskForRealLanguages() - (int) $languageID;
if ( $db->databaseName() == 'oracle' )
{
$db->query( "UPDATE ezcontentobject_version SET language_mask = bitand( language_mask, $mask )
WHERE contentobject_id='$objectID'" );
}
else
{
$db->query( "UPDATE ezcontentobject_version SET language_mask = language_mask & $mask
WHERE contentobject_id='$objectID'" );
}
$urlElementfilter = new eZURLAliasQuery();
$urlElementfilter->type = 'name';
// We want all languages present here, so we are turning off
// language filtering
$urlElementfilter->languages = false;
$urlElementfilter->limit = false;
$nodes = $this->assignedNodes();
foreach ( $nodes as $node )
{
$parent = null;
$textMD5 = null;
//.........这里部分代码省略.........