本文整理汇总了PHP中eZSolr::nodeAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP eZSolr::nodeAttributes方法的具体用法?PHP eZSolr::nodeAttributes怎么用?PHP eZSolr::nodeAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZSolr
的用法示例。
在下文中一共展示了eZSolr::nodeAttributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: optimize
/**
* Adds object $contentObject to the search database.
*
* @param eZContentObject $contentObject Object to add to search engine
* @param bool $commit Whether to commit after adding the object.
If set, run optimize() as well every 1000nd time this function is run.
* @return bool True if the operation succeed.
*/
function addObject( $contentObject, $commit = true )
{
// Add all translations to the document list
$docList = array();
// Check if we need to index this object after all
// Exclude if class identifier is in the exclude list for classes
$excludeClasses = $this->FindINI->variable( 'IndexExclude', 'ClassIdentifierList' );
if ( $excludeClasses && in_array( $contentObject->attribute( 'class_identifier' ), $excludeClasses ) )
{
return true;
}
// Get global object values
$mainNode = $contentObject->attribute( 'main_node' );
if ( !$mainNode )
{
eZDebug::writeError( 'Unable to fetch main node for object: ' . $contentObject->attribute( 'id' ), __METHOD__ );
return false;
}
$mainNodePathArray = $mainNode->attribute( 'path_array' );
$mainNodeID = $mainNode->attribute( 'node_id' );
// initialize array of parent node path ids, needed for multivalued path field and subtree filters
$nodePathArray = array();
//included in $nodePathArray
//$pathArray = $mainNode->attribute( 'path_array' );
$currentVersion = $contentObject->currentVersion();
// Get object meta attributes.
$metaAttributeValues = self::getMetaAttributesForObject( $contentObject );
// Get node attributes.
$nodeAttributeValues = array();
foreach ( $contentObject->attribute( 'assigned_nodes' ) as $contentNode )
{
$nodeID = $contentNode->attribute( 'node_id' );
foreach ( eZSolr::nodeAttributes() as $attributeName => $fieldType )
{
$nodeAttributeValues[$nodeID][] = array( 'name' => $attributeName,
'value' => $contentNode->attribute( $attributeName ),
'fieldType' => $fieldType );
}
$nodePathArray[] = $contentNode->attribute( 'path_array' );
}
// Check anonymous user access.
if ( $this->FindINI->variable( 'SiteSettings', 'IndexPubliclyAvailable' ) == 'enabled' )
{
$anonymousUserID = $this->SiteINI->variable( 'UserSettings', 'AnonymousUserID' );
$currentUserID = eZUser::currentUserID();
$user = eZUser::instance( $anonymousUserID );
eZUser::setCurrentlyLoggedInUser( $user, $anonymousUserID );
$anonymousAccess = $contentObject->attribute( 'can_read' );
$user = eZUser::instance( $currentUserID );
eZUser::setCurrentlyLoggedInUser( $user, $currentUserID );
$anonymousAccess = $anonymousAccess ? 'true' : 'false';
}
else
{
$anonymousAccess = 'false';
}
// Load index time boost factors if any
//$boostMetaFields = $this->FindINI->variable( "IndexBoost", "MetaField" );
$boostClasses = $this->FindINI->variable( 'IndexBoost', 'Class' );
$boostAttributes = $this->FindINI->variable( 'IndexBoost', 'Attribute' );
$boostDatatypes = $this->FindINI->variable( 'IndexBoost', 'Datatype' );
$reverseRelatedScale = $this->FindINI->variable( 'IndexBoost', 'ReverseRelatedScale' );
// Initialise default doc boost
$docBoost = 1.0;
$contentClassIdentifier = $contentObject->attribute( 'class_identifier' );
// Just test if the boost factor is defined by checking if it has a numeric value
if ( isset( $boostClasses[$contentClassIdentifier] ) && is_numeric( $boostClasses[$contentClassIdentifier] ) )
{
$docBoost += $boostClasses[$contentClassIdentifier];
}
// Google like boosting, using eZ Publish reverseRelatedObjectCount
$reverseRelatedObjectCount = $contentObject->reverseRelatedObjectCount();
$docBoost += $reverseRelatedScale * $reverseRelatedObjectCount;
// Create the list of available languages for this version :
$availableLanguages = $currentVersion->translationList( false, false );
// Loop over each language version and create an eZSolrDoc for it
foreach ( $availableLanguages as $languageCode )
{
$doc = new eZSolrDoc( $docBoost );
// Set global unique object ID
$doc->addField( ezfSolrDocumentFieldBase::generateMetaFieldName( 'guid' ), $this->guid( $contentObject, $languageCode ) );
//.........这里部分代码省略.........
示例2: getData
/**
* @see ezfSolrDocumentFieldBase::getData()
*/
public function getData()
{
/** @var eZContentClassAttribute $contentClassAttribute */
$contentClassAttribute = $this->ContentObjectAttribute->attribute('contentclass_attribute');
switch ($contentClassAttribute->attribute('data_type_string')) {
case 'ezobjectrelation':
$returnArray = array();
/** @var eZContentObject $relatedObject */
$relatedObject = $this->ContentObjectAttribute->content();
if ($relatedObject) {
$returnArray = $this->getArrayRelatedObject($relatedObject, $contentClassAttribute);
eZContentObject::clearCache(array($relatedObject->attribute('id')));
}
return $returnArray;
break;
case 'ezobjectrelationlist':
$returnArray = array();
$returnArrayRelatedObject = array();
$content = $this->ContentObjectAttribute->content();
$relationCount = count($content['relation_list']);
foreach ($content['relation_list'] as $relationItem) {
$subObjectID = $relationItem['contentobject_id'];
if (!$subObjectID) {
continue;
}
/** @var eZContentObjectVersion $subObject */
$subObject = eZContentObjectVersion::fetchVersion($relationItem['contentobject_version'], $subObjectID);
if (!$subObject instanceof eZContentObjectVersion) {
$subObjectWrapper = eZContentObject::fetch($subObjectID);
if ($subObjectWrapper instanceof eZContentObject) {
$subObject = $subObjectWrapper->currentVersion();
} else {
continue;
}
}
/** @var eZContentObject $subContentObject */
$subContentObject = $subObject->attribute('contentobject');
if (intval($subContentObject->attribute('main_node_id')) == 0) {
continue;
}
$metaAttributeValues = eZSolr::getMetaAttributesForObject($subContentObject);
foreach ($metaAttributeValues as $metaInfo) {
$submetaFieldName = ezfSolrDocumentFieldBase::generateSubmetaFieldName($metaInfo['name'], $contentClassAttribute);
if (isset($returnArray[$submetaFieldName])) {
$returnArray[$submetaFieldName] = array_merge($returnArray[$submetaFieldName], array(ezfSolrDocumentFieldBase::preProcessValue($metaInfo['value'], $metaInfo['fieldType'])));
} else {
$returnArray[$submetaFieldName] = array(ezfSolrDocumentFieldBase::preProcessValue($metaInfo['value'], $metaInfo['fieldType']));
}
}
$nodeAttributeValues = array();
$nodePathArray = array();
/** @var eZContentObjectTreeNode $contentNode */
foreach ($subContentObject->attribute('assigned_nodes') as $contentNode) {
foreach (eZSolr::nodeAttributes() as $attributeName => $fieldType) {
$nodeAttributeValues[] = array('name' => $attributeName, 'value' => $contentNode->attribute($attributeName), 'fieldType' => $fieldType);
}
$nodePathArray[] = $contentNode->attribute('path_array');
}
//@todo questo non va... occorre correggere schema.xml?
//foreach ( $nodeAttributeValues as $metaInfo )
//{
// $submetaFieldName = ezfSolrDocumentFieldBase::generateSubmetaFieldName( $metaInfo['name'], $contentClassAttribute );
// if ( isset( $returnArray[$submetaFieldName] ) )
// {
// $returnArray[$submetaFieldName] = array_merge( $returnArray[$submetaFieldName],
// array( ezfSolrDocumentFieldBase::preProcessValue( $metaInfo['value'], $metaInfo['fieldType'] ) ) );
// }
// else
// {
// $returnArray[$submetaFieldName] = array( ezfSolrDocumentFieldBase::preProcessValue( $metaInfo['value'], $metaInfo['fieldType'] ) );
// }
//}
foreach ($nodePathArray as $pathArray) {
$submetaFieldName = ezfSolrDocumentFieldBase::generateSubmetaFieldName('path', $contentClassAttribute);
foreach ($pathArray as $pathNodeID) {
if (isset($returnArray[$submetaFieldName])) {
$returnArray[$submetaFieldName] = array_merge($returnArray[$submetaFieldName], array($pathNodeID));
} else {
$returnArray[$submetaFieldName] = array($pathNodeID);
}
}
}
if ($relationCount < 200) {
$returnArrayRelatedObject = $this->getArrayRelatedObject($subContentObject, $contentClassAttribute, $returnArrayRelatedObject);
} else {
$objectName = $subContentObject->name(false, $this->ContentObjectAttribute->attribute('language_code'));
$fieldName = parent::generateSubattributeFieldName($contentClassAttribute, 'name', self::DEFAULT_SUBATTRIBUTE_TYPE);
if (isset($returnArrayRelatedObject[$fieldName])) {
$returnArrayRelatedObject[$fieldName][] = $objectName;
} else {
$returnArrayRelatedObject[$fieldName] = array($objectName);
}
}
$returnArray = array_merge_recursive($returnArray, $returnArrayRelatedObject);
eZContentObject::clearCache(array($subContentObject->attribute('id')));
}
$defaultFieldName = parent::generateAttributeFieldName($contentClassAttribute, self::$subattributesDefinition[self::DEFAULT_SUBATTRIBUTE]);
//.........这里部分代码省略.........