本文整理匯總了PHP中eZContentObject::relationTypeMask方法的典型用法代碼示例。如果您正苦於以下問題:PHP eZContentObject::relationTypeMask方法的具體用法?PHP eZContentObject::relationTypeMask怎麽用?PHP eZContentObject::relationTypeMask使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類eZContentObject
的用法示例。
在下文中一共展示了eZContentObject::relationTypeMask方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: relatedObjectCount
/**
* Fetch the number of (reverse) related objects
*
* @param bool|int $version
* @param int $attributeID
* This parameter only makes sense if $params[AllRelations] is unset,
* set to false, or matches eZContentObject::RELATION_ATTRIBUTE
* Possible values:
* - 0 or false:
* Count relations made with any attribute
* - >0
* Count relations made with attribute $attributeID
* @param int|bool $reverseRelatedObjects
* Wether to count related objects (false) or reverse related
* objects (false)
* @param array|bool $params
* Various params, as an associative array.
* Possible values:
* - AllRelations (bool|int)
* true: count ALL relations, object and attribute level
* false: only count object level relations
* other: bit mask of eZContentObject::RELATION_* constants
* - IgnoreVisibility (bool)
* If true, 'hidden' status will be ignored
*
* @return int The number of (reverse) related objects for the object
*/
function relatedObjectCount( $version = false, $attributeID = 0, $reverseRelatedObjects = false, $params = false )
{
$objectID = $this->ID;
if ( $version == false )
$version = isset( $this->CurrentVersion ) ? $this->CurrentVersion : false;
$version = (int) $version;
$db = eZDB::instance();
$showInvisibleNodesCond = '';
// process params (only IgnoreVisibility currently supported):
if ( is_array( $params ) )
{
if ( isset( $params['IgnoreVisibility'] ) )
{
$showInvisibleNodesCond = self::createFilterByVisibilitySQLString(
$params['IgnoreVisibility'],
// inner_object represents the source of relation while outer_object represents the target
$reverseRelatedObjects ? 'inner_object' : 'outer_object'
);
}
}
$relationTypeMasking = '';
$relationTypeMask = isset( $params['AllRelations'] ) ? $params['AllRelations'] : ( $attributeID === false );
if ( $attributeID && ( $relationTypeMask === false || $relationTypeMask === eZContentObject::RELATION_ATTRIBUTE ) )
{
$attributeID =(int) $attributeID;
$relationTypeMasking .= " AND inner_link.contentclassattribute_id = $attributeID ";
$relationTypeMask = eZContentObject::RELATION_ATTRIBUTE;
}
elseif ( is_bool( $relationTypeMask ) )
{
$relationTypeMask = eZContentObject::relationTypeMask( $relationTypeMask );
}
if ( $db->databaseName() == 'oracle' )
{
$relationTypeMasking .= " AND bitand( inner_link.relation_type, $relationTypeMask ) <> 0 ";
}
else
{
$relationTypeMasking .= " AND ( inner_link.relation_type & $relationTypeMask ) <> 0 ";
}
if ( $reverseRelatedObjects )
{
$outerObjectIDSQL = 'outer_object.id = outer_link.from_contentobject_id';
if ( is_array( $objectID ) )
{
if ( count( $objectID ) > 0 )
{
$objectIDSQL = ' AND ' . $db->generateSQLINStatement( $objectID, 'inner_link.to_contentobject_id', false, false, 'int' ) . ' AND
inner_link.from_contentobject_version = inner_object.current_version';
}
else
{
$objectIDSQL = '';
}
}
else
{
$objectID = (int) $objectID;
$objectIDSQL = " AND inner_link.to_contentobject_id = $objectID
AND inner_link.from_contentobject_version = inner_object.current_version";
}
}
else
{
$outerObjectIDSQL = 'outer_object.id = outer_link.to_contentobject_id';
$objectIDSQL = " AND inner_link.from_contentobject_id = $objectID
AND inner_link.from_contentobject_version = $version";
}
//.........這裏部分代碼省略.........
示例2: contentobjectRelationTypeMask
public static function contentobjectRelationTypeMask($contentObjectRelationTypes = false)
{
$relationTypeMask = 0;
if (is_array($contentObjectRelationTypes)) {
$relationTypeMap = array('common' => eZContentObject::RELATION_COMMON, 'xml_embed' => eZContentObject::RELATION_EMBED, 'xml_link' => eZContentObject::RELATION_LINK, 'attribute' => eZContentObject::RELATION_ATTRIBUTE);
foreach ($contentObjectRelationTypes as $relationType) {
if (isset($relationTypeMap[$relationType])) {
$relationTypeMask |= $relationTypeMap[$relationType];
} else {
eZDebug::writeWarning("Unknown relation type: '{$relationType}'.", __METHOD__);
}
}
} elseif (!is_bool($contentObjectRelationTypes)) {
$contentObjectRelationTypes = false;
}
if (is_bool($contentObjectRelationTypes)) {
$relationTypeMask = eZContentObject::relationTypeMask($contentObjectRelationTypes);
}
return $relationTypeMask;
}
示例3: fastRelatedObjectCount
static function fastRelatedObjectCount($objectId, $objectVersion, $attributeID = 0, $reverseRelatedObjects = false, $params = false)
{
$db = eZDB::instance();
$showInvisibleNodesCond = '';
// process params (only IgnoreVisibility currently supported):
if (is_array($params)) {
if (isset($params['IgnoreVisibility'])) {
$showInvisibleNodesCond = eZContentObject::createFilterByVisibilitySQLString($params['IgnoreVisibility']);
}
}
$relationTypeMasking = '';
$relationTypeMask = isset($params['AllRelations']) ? $params['AllRelations'] : $attributeID === false;
if ($attributeID && ($relationTypeMask === false || $relationTypeMask === eZContentObject::RELATION_ATTRIBUTE)) {
$attributeID = (int) $attributeID;
$relationTypeMasking .= " AND contentclassattribute_id={$attributeID} ";
$relationTypeMask = eZContentObject::RELATION_ATTRIBUTE;
} elseif (is_bool($relationTypeMask)) {
$relationTypeMask = eZContentObject::relationTypeMask($relationTypeMask);
}
if ($db->databaseName() == 'oracle') {
$relationTypeMasking .= " AND bitand( relation_type, {$relationTypeMask} ) <> 0 ";
} else {
$relationTypeMasking .= " AND ( relation_type & {$relationTypeMask} ) <> 0 ";
}
if ($reverseRelatedObjects) {
if (is_array($objectId)) {
if (count($objectId) > 0) {
$objectIDSQL = ' AND ' . $db->generateSQLINStatement($objectId, 'ezcontentobject_link.to_contentobject_id', false, false, 'int') . ' AND
ezcontentobject_link.from_contentobject_version=ezcontentobject.current_version';
} else {
$objectIDSQL = '';
}
} else {
$objectId = (int) $objectId;
$objectIDSQL = ' AND ezcontentobject_link.to_contentobject_id = ' . $objectId . ' AND
ezcontentobject_link.from_contentobject_version=ezcontentobject.current_version';
}
$select = " count( DISTINCT ezcontentobject.id ) AS count";
} else {
$select = " count( ezcontentobject_link.from_contentobject_id ) as count ";
$objectIDSQL = " AND ezcontentobject_link.from_contentobject_id='{$objectId}'\n AND ezcontentobject_link.from_contentobject_version='{$objectVersion}'";
}
// from the following query, this is the excerpted where condition; it causes
// a BC break in 4.7 and does not seem to do anything ...
// AND ezcontentobject_link.op_code='0'
$query = "SELECT {$select}\n FROM\n ezcontentobject, ezcontentobject_link\n WHERE\n ezcontentobject.id=ezcontentobject_link.from_contentobject_id AND\n ezcontentobject.status=" . eZContentObject::STATUS_PUBLISHED . " \n \n {$objectIDSQL}\n {$relationTypeMasking}\n {$showInvisibleNodesCond}";
$rows = $db->arrayQuery($query);
return $rows[0]['count'];
}