Пример #1
0
 public function attribute($key)
 {
     switch ($key) {
         case 'start_timestamp':
             return $this->start->format('U');
             break;
         case 'start_js':
             return $this->start->format('U') * 1000;
             break;
         case 'start_solr':
             return ezfSolrDocumentFieldBase::preProcessValue($this->start->format('U'), 'date');
             break;
         case 'end_timestamp':
             return $this->end->format('U');
             break;
         case 'end_js':
             return $this->end->format('U') * 1000;
             break;
         case 'end_solr':
             return ezfSolrDocumentFieldBase::preProcessValue($this->end->format('U'), 'date');
             break;
         default:
             return false;
     }
 }
 /**
  * @return array
  */
 protected function getValues()
 {
     if ($this->values === null) {
         $this->values = array();
         if ($this->contentClassAttribute->attribute('data_type_string') == 'ezobjectrelationlist') {
             //$field = ezfSolrDocumentFieldBase::generateSubattributeFieldName( $this->contentClassAttribute, 'name', 'string' );
             //@todo errore nella definzione del nome del sottoattributo? verifaicare vedi anche in self::buildFetch
             //$field = ezfSolrDocumentFieldBase::$DocumentFieldName->lookupSchemaName(
             //    ezfSolrDocumentFieldBase::SUBMETA_FIELD_PREFIX . $this->contentClassAttribute->attribute( 'identifier' ) . ezfSolrDocumentFieldBase::SUBATTR_FIELD_SEPARATOR . 'name',
             //    'string');
             $field = ezfSolrDocumentFieldBase::$DocumentFieldName->lookupSchemaName(ezfSolrDocumentFieldBase::SUBATTR_FIELD_PREFIX . $this->contentClassAttribute->attribute('identifier') . ezfSolrDocumentFieldBase::SUBATTR_FIELD_SEPARATOR . 'name' . ezfSolrDocumentFieldBase::SUBATTR_FIELD_SEPARATOR, 'string');
         } else {
             $field = ezfSolrDocumentFieldBase::generateAttributeFieldName($this->contentClassAttribute, 'string');
         }
         $facets = array('field' => $field, 'name' => $this->attributes['name'], 'limit' => 300, 'sort' => 'alpha');
         $fetchParameters = array('SearchContentClassID' => array($this->contentClassAttribute->attribute('contentclass_id')), 'Facet' => array($facets));
         $data = $this->client->fetchRemoteNavigationList($fetchParameters);
         if (isset($data[$this->attributes['name']])) {
             $this->values = $data[$this->attributes['name']];
             // setto i valori attivi e inietto il conto nel nome
             foreach ($this->values as $index => $value) {
                 $current = (array) $this->attributes['value'];
                 if (in_array($value['query'], $current)) {
                     $this->values[$index]['active'] = true;
                 }
                 $this->values[$index]['query'] = OCFacetNavgationHelper::encodeValue($this->values[$index]['query']);
                 if (isset($value['count']) && $value['count'] > 0) {
                     $this->values[$index]['name'] = $value['name'] . ' (' . $value['count'] . ')';
                 }
             }
         }
     }
     return $this->values;
 }
 protected function getBounds($includeCurrentParameters = false)
 {
     $start = $end = false;
     $sortField = ezfSolrDocumentFieldBase::getFieldName($this->contentClassAttribute, null, 'sort');
     $currentParameters = array();
     if ($includeCurrentParameters) {
         $currentParameters = OCClassSearchFormHelper::result()->getCurrentParameters();
     }
     $fieldName = ezfSolrDocumentFieldBase::getFieldName($this->contentClassAttribute, null, 'search');
     $params = array_merge(OCClassSearchFormHelper::result()->getBaseParameters(), $currentParameters, array('SearchContentClassID' => $this->contentClassAttribute->attribute('contentclass_id'), 'SearchLimit' => 1, 'SortBy' => array($sortField => 'asc')));
     $startSearch = OCFacetNavgationHelper::fetch($params, OCClassSearchFormHelper::result()->searchText);
     /** @var $startSearchResults eZFindResultNode[] */
     $startSearchResults = $startSearch['SearchResult'];
     if (isset($startSearchResults[0])) {
         $dataMap = $startSearchResults[0]->attribute('object')->attribute('data_map');
         $start = $dataMap[$this->contentClassAttribute->attribute('identifier')];
     }
     $params['SortBy'] = array($sortField => 'desc');
     $endSearch = OCFacetNavgationHelper::fetch($params, OCClassSearchFormHelper::result()->searchText);
     /** @var $endSearchResults eZFindResultNode[] */
     $endSearchResults = $endSearch['SearchResult'];
     if (isset($endSearchResults[0])) {
         $dataMap = $endSearchResults[0]->attribute('object')->attribute('data_map');
         $end = $dataMap[$this->contentClassAttribute->attribute('identifier')];
     }
     $className = $this->getBoundsClassName();
     /** @var OCClassSearchFormFieldBoundsInterface $bounds */
     $bounds = new $className();
     $bounds->setStart($start);
     $bounds->setEnd($end);
     return $bounds;
 }
Пример #4
0
 /**
  * Returns the list of field names this handler sends to Solr backend
  *
  * @static
  *
  * @param eZContentClassAttribute $classAttribute
  * @param array $exclusiveTypeFilter
  *
  * @return array
  */
 public static function getFieldNameList(eZContentClassAttribute $classAttribute, $exclusiveTypeFilter = array())
 {
     $fieldsList = array();
     if (empty($exclusiveTypeFilter) || !in_array('lckeyword', $exclusiveTypeFilter)) {
         $fieldsList[] = parent::generateAttributeFieldName($classAttribute, 'lckeyword');
     }
     if (empty($exclusiveTypeFilter) || !in_array('text', $exclusiveTypeFilter)) {
         $fieldsList[] = parent::generateAttributeFieldName($classAttribute, 'text');
     }
     if (empty($exclusiveTypeFilter) || !in_array('sint', $exclusiveTypeFilter)) {
         $fieldsList[] = parent::generateSubattributeFieldName($classAttribute, 'tag_ids', 'sint');
     }
     return $fieldsList;
 }
 public static function getFieldName(eZContentClassAttribute $classAttribute, $subAttribute = null, $context = 'search')
 {
     switch ($classAttribute->attribute('data_type_string')) {
         case 'ezmatrix':
             if ($subAttribute and $subAttribute !== '') {
                 // A subattribute was passed
                 return parent::generateSubattributeFieldName($classAttribute, $subAttribute, self::DEFAULT_SUBATTRIBUTE_TYPE);
             } else {
                 // return the default field name here.
                 return parent::generateAttributeFieldName($classAttribute, self::getClassAttributeType($classAttribute, null, $context));
             }
             break;
     }
     return null;
 }
 public function getData()
 {
     $contentClassAttribute = $this->ContentObjectAttribute->attribute('contentclass_attribute');
     switch ($contentClassAttribute->attribute('data_type_string')) {
         case 'ezinteger':
             $returnArray = array();
             $value = $this->ContentObjectAttribute->metaData();
             $fieldName = parent::generateAttributeFieldName($contentClassAttribute, self::DEFAULT_ATTRIBUTE_TYPE);
             $returnArray[$fieldName] = intval($value);
             return $returnArray;
             break;
         default:
             break;
     }
 }
 public function buildFetch(OCClassSearchFormFetcher $fetcher, $requestKey, $requestValue, &$filters)
 {
     if (is_array($requestValue) && count($requestValue) == 1) {
         $requestValue = array_shift($requestValue);
     }
     $fieldName = ezfSolrDocumentFieldBase::getFieldName($this->contentClassAttribute, null, 'search');
     if (is_array($requestValue)) {
         $values = array('or');
         foreach ($requestValue as $v) {
             $values[] = $fieldName . ':' . $fetcher->encode($v, true);
         }
         $filters[] = $values;
     } else {
         $filters[] = $fieldName . ':' . $fetcher->encode($requestValue, true);
     }
     $fetcher->addFetchField(array('name' => $this->contentClassAttribute->attribute('name'), 'value' => $requestValue, 'remove_view_parameters' => $fetcher->getViewParametersString(array($requestKey))));
 }
    /**
     * @return array
     */
    public function getData()
    {
        $contentClassAttribute = $this->ContentObjectAttribute->attribute( 'contentclass_attribute' );

        switch( $contentClassAttribute->attribute( 'identifier' ) )
        {
            case 'additional_keywords':
                $data       = parent::getData();
                $content    = $data['attr_' . $contentClassAttribute->attribute('identifier') . '_t'];
                $data['attr_' . $contentClassAttribute->attribute('identifier') . '_lk'] = $content[0];
                unset($data['attr_' . $contentClassAttribute->attribute('identifier') . '_t']);
                return $data;
            break;
            default:
                return parent::getData();
            break;
        }
    }
 public static function getFieldNameList(eZContentClassAttribute $classAttribute, $exclusiveTypeFilter = array())
 {
     // Generate the list of subfield names.
     $subfields = array();
     //   Handle first the default subattribute
     $subattributesDefinition = self::$subattributesDefinition;
     if (!in_array($subattributesDefinition[self::DEFAULT_SUBATTRIBUTE], $exclusiveTypeFilter)) {
         $subfields[] = parent::generateAttributeFieldName($classAttribute, $subattributesDefinition[self::DEFAULT_SUBATTRIBUTE]);
     }
     unset($subattributesDefinition[self::DEFAULT_SUBATTRIBUTE]);
     //   Then hanlde all other subattributes
     foreach ($subattributesDefinition as $name => $type) {
         if (empty($exclusiveTypeFilter) or !in_array($type, $exclusiveTypeFilter)) {
             $subfields[] = parent::generateSubattributeFieldName($classAttribute, $name, $type);
         }
     }
     return $subfields;
 }
    /**
     * @see ezfSolrDocumentFieldBase::getData()
     */
    public function getData()
    {
        $returnArray = parent::getData();

        $contentClassAttributeIdentifier = $this->ContentObjectAttribute->ContentClassAttributeIdentifier;

        $eZType = eZDataType::create( $this->ContentObjectAttribute->DataTypeString );
        $attributeContent = $eZType->getValues( $this->ContentObjectAttribute->ID );

        foreach( $attributeContent as $key => $value )
        {
            if ( $value > 0 )
            {
                $suffix = self::getPostFix( $contentClassAttributeIdentifier );
                $attribute =  'attr_'.$contentClassAttributeIdentifier.'_'.$key.$suffix;
                $returnArray[$attribute] = $value;
            }
        }
		
        return $returnArray;
    }
Пример #11
0
 /**
  * Get an array of class attribute identifiers based on either a class attribute
  * list, or a content classes list
  *
  * @param array $classIDArray
  *        Classes to search in. Either an array of class ID, class identifiers,
  *        a class ID or a class identifier.
  *        Using numerical attribute/class identifiers for $classIDArray is more efficient.
  * @param array $classAttributeID
  *        Class attributes to search in. Either an array of class attribute id,
  *        or a single class attribute. Literal identifiers are not allowed.
  * @param array $fieldTypeExcludeList
  *        filter list. List of field types to exclude. ( set to empty array by default ).
  *
  * @return array List of solr field names.
  */
 protected function getClassAttributes($classIDArray = false, $classAttributeIDArray = false, $fieldTypeExcludeList = null)
 {
     eZDebug::createAccumulator('Class attribute list', 'eZ Find');
     eZDebug::accumulatorStart('Class attribute list');
     $fieldArray = array();
     $classAttributeArray = array();
     // classAttributeIDArray = simple integer (content class attribute ID)
     if (is_numeric($classAttributeIDArray) and $classAttributeIDArray > 0) {
         $classAttributeArray[] = eZContentClassAttribute::fetch($classAttributeIDArray);
     } else {
         if (is_array($classAttributeIDArray)) {
             foreach ($classAttributeIDArray as $classAttributeID) {
                 $classAttributeArray[] = eZContentClassAttribute::fetch($classAttributeID);
             }
         }
     }
     // no class attribute list given, we need a class list
     // this block will create the class attribute array based on $classIDArray
     if (empty($classAttributeArray)) {
         // Fetch class list.
         $condArray = array("is_searchable" => 1, "version" => eZContentClass::VERSION_STATUS_DEFINED);
         if (!$classIDArray) {
             $classIDArray = array();
         } else {
             if (!is_array($classIDArray)) {
                 $classIDArray = array($classIDArray);
             }
         }
         // literal class identifiers are converted to numerical ones
         $tmpClassIDArray = $classIDArray;
         $classIDArray = array();
         foreach ($tmpClassIDArray as $key => $classIdentifier) {
             if (!is_numeric($classIdentifier)) {
                 if (!($contentClass = eZContentClass::fetchByIdentifier($classIdentifier, false))) {
                     eZDebug::writeWarning("Unknown content class identifier '{$classIdentifier}'", __METHOD__);
                 } else {
                     $classIDArray[] = $contentClass['id'];
                 }
             } else {
                 $classIDArray[] = $classIdentifier;
             }
         }
         if (!empty($classIDArray)) {
             $condArray['contentclass_id'] = array($classIDArray);
         }
         $classAttributeArray = eZContentClassAttribute::fetchFilteredList($condArray);
     }
     // $classAttributeArray now contains a list of eZContentClassAttribute
     // we can use to construct the list of fields solr should search in
     // @TODO : retrieve sub attributes here. Mind the types !
     foreach ($classAttributeArray as $classAttribute) {
         $fieldArray = array_merge(ezfSolrDocumentFieldBase::getFieldNameList($classAttribute, $fieldTypeExcludeList), $fieldArray);
     }
     // the array is unified + sorted in order to make it consistent
     $fieldArray = array_unique($fieldArray);
     sort($fieldArray);
     eZDebug::accumulatorStop('Class attribute list');
     return $fieldArray;
 }
}
// Ultimo giorno (Default)
if (!isset($days)) {
    $days = 1;
}
// Tutte le tematiche in OR
$tag_filters = array('or');
foreach ($tematiche as $tag) {
    $tag_filters[] = 'attr_tematica_lk: "' . $tag . '"';
}
// Data inizio è di $days giorni indietro
$_startDate = new DateTime();
$_endDate = new DateTime();
$_startDate->modify("-" . $days . " day");
$startDate = ezfSolrDocumentFieldBase::preProcessValue($_startDate->format('U'), 'date');
$endDate = ezfSolrDocumentFieldBase::preProcessValue($_endDate->format('U'), 'date');
// Composizione del filtro
$filters = array('and', 'meta_published_dt:[' . $startDate . ' TO ' . $endDate . ']', $tag_filters);
$params = array('SortBy' => array('meta_published_dt' => 'desc'), 'Filter' => $filters, 'SearchContentClassID' => array($class_id), 'SearchSubTreeArray' => array(eZINI::instance('content.ini')->variable('NodeSettings', 'RootNode')));
// Esecuzione query Solr
$solrSearch = new eZSolr();
$result = $solrSearch->search('', $params);
// Estrazione del NodeID
$node_ids = array();
foreach ($result['SearchResult'] as $object) {
    $node_ids[] = $object->ContentObject->mainNodeID();
}
// Output in JSON
header('Content-Type: application/json');
echo json_encode($node_ids);
// echo json_encode( $result['SearchResult'] ); // DEBUG
 /**
  * Get ezfSolrDocumentFieldBase instances for all attributes of specified eZContentObjectVersion
  *
  * @param eZContentObjectVersion Instance of eZContentObjectVersion to fetch attributes from.
  *
  * @return array List of ezfSolrDocumentFieldBase instances.
  */
 function getBaseList( eZContentObjectVersion $objectVersion )
 {
     $returnList = array();
     // Get ezfSolrDocumentFieldBase instance for all attributes in related object
     if ( eZContentObject::recursionProtect( $this->ContentObjectAttribute->attribute( 'contentobject_id' ) ) )
     {
         foreach ( $objectVersion->contentObjectAttributes( $this->ContentObjectAttribute->attribute( 'language_code' ) ) as $attribute )
         {
             if ( $attribute->attribute( 'contentclass_attribute' )->attribute( 'is_searchable' ) )
             {
                 $returnList[] = ezfSolrDocumentFieldBase::getInstance( $attribute );
             }
         }
     }
     return $returnList;
 }
 private static function appendData($indexType, $attribute, $targets, $ngIndexerFieldName, &$data)
 {
     if ($indexType != 'object' && empty($attribute)) {
         return;
     }
     if ($indexType == 'object') {
         $handlerData = array();
         foreach ($targets as $target) {
             foreach ($target->dataMap() as $key => $value) {
                 if ($value->attribute('data_type_string') != 'ngindexer') {
                     $handler = ezfSolrDocumentFieldBase::getInstance($value);
                     $handlerData[$key][] = $handler->getData();
                 }
             }
         }
         foreach ($handlerData as $handlerDataArray) {
             foreach ($handlerDataArray as $dataFields) {
                 self::appendDataFields($dataFields, $ngIndexerFieldName, $data);
             }
         }
     } else {
         if ($indexType == 'object_attribute') {
             foreach ($targets as $target) {
                 $fieldName = self::NGINDEXER_FIELD_PREFIX . $ngIndexerFieldName . '_' . $attribute . '____t';
                 $data[$fieldName][] = $target->object()->attribute($attribute);
             }
         } else {
             if ($indexType == 'node_attribute') {
                 foreach ($targets as $target) {
                     $fieldName = self::NGINDEXER_FIELD_PREFIX . $ngIndexerFieldName . '_' . $attribute . '____t';
                     $data[$fieldName][] = $target->attribute($attribute);
                 }
             } else {
                 if ($indexType == 'data_map_attribute') {
                     $handlerData = array();
                     foreach ($targets as $target) {
                         $dataMap = $target->dataMap();
                         if (isset($dataMap[$attribute]) && $dataMap[$attribute]->attribute('data_type_string') != 'ngindexer') {
                             $handler = ezfSolrDocumentFieldBase::getInstance($dataMap[$attribute]);
                             $handlerData[] = $handler->getData();
                         }
                     }
                     foreach ($handlerData as $dataFields) {
                         self::appendDataFields($dataFields, $ngIndexerFieldName, $data);
                     }
                 }
             }
         }
     }
 }
Пример #15
0
$subtreeArray = explode(',', $ParentNodes);
$defaultFilters = $DefaultFilters !== null ? explode(',', $DefaultFilters) : array();
$fieldsToReturn = $fields;
$iDisplayStart = $http->hasGetVariable('iDisplayStart') ? $http->getVariable('iDisplayStart') : 10;
$iDisplayLength = $http->hasGetVariable('iDisplayLength') ? $http->getVariable('iDisplayLength') : 100;
/*
 * Ordering
 */
$sortBy = array(ezfSolrDocumentFieldBase::generateMetaFieldName('sort_name') => 'asc');
if ($http->hasGetVariable('iSortCol_0')) {
    for ($i = 0; $i < intval($http->getVariable('iSortingCols')); $i++) {
        $sortBy = array();
        if ($http->getVariable('bSortable_' . intval($http->getVariable('iSortCol_' . $i))) == "true") {
            $sortKey = $fields[intval($http->getVariable('iSortCol_' . $i))];
            if ($sortKey == 'name_t' || $sortKey == 'name') {
                $sortKey = ezfSolrDocumentFieldBase::generateMetaFieldName('sort_name');
            }
            $sortBy[] = array($sortKey, $http->getVariable('sSortDir_' . $i));
        }
    }
}
$query = '';
if ($http->getVariable('sSearch') != "") {
    $query = str_replace(' ', ' AND ', $http->getVariable('sSearch')) . '*';
}
/* 
 * Individual column filtering
 */
$filters = array();
if (!empty($defaultFilters)) {
    if ($DefaultFilters > 1) {
Пример #16
0
    /**
     * Clean up search index for current installation.
     * @return bool true if cleanup was successful
     * @todo:  handle multicore configs (need a parameter for it) for return values
    **/
    function cleanup( $allInstallations = false, $optimize = false )
    {
        if ( $allInstallations === true )
        {
            $optimize = true;
            $deleteQuery = '*:*';
        }
        else
        {
            $deleteQuery = ezfSolrDocumentFieldBase::generateMetaFieldName( 'installation_id' ) . ':' . self::installationID();
        }
        if ( $this->UseMultiLanguageCores == true )
        {
            foreach ( $this->SolrLanguageShards as $shard )
            {
                $shard->deleteDocs( array(), $deleteQuery, true, $optimize );
            }
            return true;
        }
        else
        {
            return $this->Solr->deleteDocs( array(), $deleteQuery, true );
        }

    }
     *
     * @example
     *      Metadata attributes of a related object will be indexed
     *      as submetas in a Solr document, their names starting
     *      with 'submeta_' instead of '_meta'
     */
    const SUBMETA_FIELD_PREFIX = 'submeta_';
    /**
     * Prefix for attribute field names in Solr.
     */
    const ATTR_FIELD_PREFIX = 'attr_';
    /**
     * Prefix for subattribute field names in Solr.
     *
     * @example
     *      Content attributes of a related object will be indexed
     *      as subattributes in a Solr document, their names starting
     *      with 'subattr_' instead of '_attr'
     */
    const SUBATTR_FIELD_PREFIX = 'subattr_';
    /**
     * Separator for sub attributes
     * Since eZ Find 2.3, this is changed to a lucene query syntax friendly string
     * which is important for function queries and some internal Solr calls
     * as well
     */
    const SUBATTR_FIELD_SEPARATOR = '___';
}
ezfSolrDocumentFieldBase::$FindINI = eZINI::instance('ezfind.ini');
ezfSolrDocumentFieldBase::$DocumentFieldName = new ezfSolrDocumentFieldName();
 /**
  * test for getData()
  */
 public function testGetData()
 {
     $providerArray = array();
     #start 1 : the simplest attribute
     $content1 = "Hello world";
     $ezcca1 = new eZContentClassAttribute(array('identifier' => 'title', 'data_type_string' => 'ezstring'));
     $ezcoa1 = new eZContentObjectAttributeTester(array("data_type_string" => 'ezstring', "id" => 100123, "data_text" => $content1, "contentclass_attribute" => $ezcca1));
     $fieldName1 = ezfSolrDocumentFieldBase::getFieldName($ezcca1);
     $expectedData1 = array($fieldName1 => $content1);
     $providerArray[] = array($expectedData1, $ezcoa1);
     #end 1
     #start 2 : attribute with subattributes
     $ezcca2 = new eZContentClassAttribute(array('identifier' => 'dummy', 'data_type_string' => 'dummy_example'));
     $ezcoa2 = new eZContentObjectAttributeTester(array("data_type_string" => 'dummy_example', "id" => 100124, "contentclass_attribute" => $ezcca2));
     $fieldList2 = ezfSolrDocumentFieldBase::getFieldNameList($ezcca2);
     $expectedData2 = array();
     foreach ($fieldList2 as $fieldName) {
         $expectedData2[$fieldName] = 'DATA_FOR_' . $fieldName;
     }
     $fieldName2 = ezfSolrDocumentFieldBase::getFieldName($ezcca2);
     $providerArray[] = array($expectedData2, $ezcoa2);
     #end 2
     #start 3 : object relations
     $expectedData3 = array();
     $tester3 = new ezfSolrDocumentFieldObjectRelationTester(new eZContentObjectAttribute(array()));
     $time3 = time();
     $image3 = new ezpObject("image", 2);
     $image3->name = __METHOD__ . $time3;
     $image3->caption = __METHOD__ . $time3;
     $imageId3 = $image3->publish();
     // $image3->object->clearCache();
     $dataMapImage3 = $image3->dataMap;
     // eZContentObjectAttribute objects, attributes of the related Image
     $imageName3 = $dataMapImage3['name'];
     $imageCaption3 = $dataMapImage3['caption'];
     $article3 = new ezpObject("article", 2);
     $articleId3 = $article3->publish();
     // Create object relation
     $article3->object->addContentObjectRelation($imageId3, $article3->current_version, 154, eZContentObject::RELATION_ATTRIBUTE);
     $dataMapArticle3 = $article3->attribute('data_map');
     $ezcoa3 = $dataMapArticle3['image'];
     $ezcoa3->setAttribute('data_int', $imageId3);
     $ezcoa3->store();
     $ezcca3 = $ezcoa3->attribute('contentclass_attribute');
     $defaultFieldName3 = ezfSolrDocumentFieldBase::generateAttributeFieldName($ezcca3, ezfSolrDocumentFieldObjectRelation::$subattributesDefinition[ezfSolrDocumentFieldObjectRelation::DEFAULT_SUBATTRIBUTE]);
     $expectedData3[$defaultFieldName3] = $tester3->getPlainTextRepresentation($ezcoa3);
     // required to allow another call to metaData()
     // on $ezcoa3 in getPlainTextRepresentation, called from the getData() method :
     eZContentObject::recursionProtectionEnd();
     $fieldNameImageName3 = ezfSolrDocumentFieldBase::generateSubattributeFieldName($ezcca3, $imageName3->attribute('contentclass_attribute_identifier'), ezfSolrDocumentFieldObjectRelation::getClassAttributeType($imageName3->attribute('contentclass_attribute')));
     $expectedData3[$fieldNameImageName3] = trim(implode(' ', array_values(ezfSolrDocumentFieldBase::getInstance($imageName3)->getData())), "\t\r\n ");
     $fieldNameImageCaption3 = ezfSolrDocumentFieldBase::generateSubattributeFieldName($ezcca3, $imageCaption3->attribute('contentclass_attribute_identifier'), ezfSolrDocumentFieldObjectRelation::getClassAttributeType($imageCaption3->attribute('contentclass_attribute')));
     $expectedData3[$fieldNameImageCaption3] = trim(implode(' ', array_values(ezfSolrDocumentFieldBase::getInstance($imageCaption3)->getData())), "\t\r\n ");
     $image3 = eZContentObject::fetch($imageId3);
     $metaAttributeValues = eZSolr::getMetaAttributesForObject($image3);
     foreach ($metaAttributeValues as $metaInfo) {
         $expectedData3[ezfSolrDocumentFieldBase::generateSubmetaFieldName($metaInfo['name'], $ezcca3)] = ezfSolrDocumentFieldBase::preProcessValue($metaInfo['value'], $metaInfo['fieldType']);
     }
     $providerArray[] = array($expectedData3, $ezcoa3);
     #end 3
     // Let's perform the actual testing :
     foreach ($providerArray as $input) {
         $expected = $input[0];
         $contentObjectAttribute = $input[1];
         $instance = ezfSolrDocumentFieldBase::getInstance($contentObjectAttribute);
         self::assertEquals($expected, $instance->getData());
     }
 }
 protected function getDateFilter()
 {
     $startDateTime = DateTime::createFromFormat('H i s n j Y', implode(' ', $this->startDateArray), self::timezone());
     $startTimeStamp = $startDateTime->format('U');
     $endDateTime = clone $startDateTime;
     $this->addInterval($endDateTime);
     $endTimeStamp = $endDateTime->format('U');
     $endDateTime = $endTimeStamp > $startTimeStamp ? $endTimeStamp-- : $startTimeStamp--;
     $startDate = ezfSolrDocumentFieldBase::preProcessValue($startTimeStamp, 'date');
     $endDate = ezfSolrDocumentFieldBase::preProcessValue($endTimeStamp, 'date');
     if ($endTimeStamp > $startTimeStamp) {
         return array('meta_published_dt:[' . $startDate . ' TO ' . $endDate . ']');
     } else {
         return array('meta_published_dt:[' . $endDate . ' TO ' . $startDate . ']');
     }
 }
Пример #20
0
 /**
  * Translates a solr response into result objects or a slightly modified array.
  * The $asObjects parameter controls which of the 2 return formats get send back.
  * @see eZSolrBase::search
  * @see eZSolrBase::moreLikeThis
  */
 protected function buildResultObjects($resultArray, &$searchCount, $asObjects = true, $fieldsToReturn = array())
 {
     $objectRes = array();
     $highLights = array();
     if (!empty($resultArray['highlighting'])) {
         foreach ($resultArray['highlighting'] as $id => $highlight) {
             $highLightStrings = array();
             //implode apparently does not work on associative arrays that contain arrays
             //$element being an array as well
             foreach ($highlight as $key => $element) {
                 $highLightStrings[] = implode(' ', $element);
             }
             $highLights[$id] = implode(' ...  ', $highLightStrings);
         }
     }
     if (!empty($resultArray)) {
         $result = $resultArray['response'];
         $maxScore = $result['maxScore'];
         $docs = $result['docs'];
         $localNodeIDList = array();
         $nodeRowList = array();
         // Loop through result, and get eZContentObjectTreeNode ID
         foreach ($docs as $idx => $doc) {
             if ($doc[ezfSolrDocumentFieldBase::generateMetaFieldName('installation_id')] == self::installationID()) {
                 $localNodeIDList[] = $this->getNodeID($doc);
             }
         }
         if (!empty($localNodeIDList)) {
             $tmpNodeRowList = eZContentObjectTreeNode::fetch($localNodeIDList, false, false);
             // Workaround for eZContentObjectTreeNode::fetch behaviour
             if (count($localNodeIDList) === 1) {
                 $tmpNodeRowList = array($tmpNodeRowList);
             }
             if ($tmpNodeRowList) {
                 foreach ($tmpNodeRowList as $nodeRow) {
                     $nodeRowList[$nodeRow['node_id']] = $nodeRow;
                 }
             }
             unset($tmpNodeRowList);
         }
         //need refactoring from the moment Solr has globbing in fl parameter
         foreach ($docs as $idx => $doc) {
             if (!$asObjects) {
                 $emit = array();
                 foreach ($doc as $fieldName => $fieldValue) {
                     // check if field is not in the explicit field list, to keep explode from generating notices.
                     if (strpos($fieldName, '_') !== false) {
                         list($prefix, $rest) = explode('_', $fieldName, 2);
                         // get the identifier for meta, binary fields
                         $inner = implode('_', explode('_', $rest, -1));
                         if ($prefix === 'meta') {
                             $emit[$inner] = $fieldValue;
                         } elseif ($prefix === 'as') {
                             $emit['data_map'][$inner] = ezfSolrStorage::unserializeData($fieldValue);
                         }
                     } elseif (in_array($fieldName, $fieldsToReturn)) {
                         $emit['fields'][$fieldName] = $fieldValue;
                     }
                 }
                 $emit['highlight'] = isset($highLights[$doc[ezfSolrDocumentFieldBase::generateMetaFieldName('guid')]]) ? $highLights[$doc[ezfSolrDocumentFieldBase::generateMetaFieldName('guid')]] : null;
                 $objectRes[] = $emit;
                 unset($emit);
                 continue;
             } elseif ($doc[ezfSolrDocumentFieldBase::generateMetaFieldName('installation_id')] == self::installationID()) {
                 // Search result document is from current installation
                 $nodeID = $this->getNodeID($doc);
                 // Invalid $nodeID
                 // This can happen if a content has been deleted while Solr was not running, provoking desynchronization
                 if (!isset($nodeRowList[$nodeID])) {
                     $searchCount--;
                     eZDebug::writeError("Node #{$nodeID} (/{$doc[ezfSolrDocumentFieldBase::generateMetaFieldName('main_url_alias')]}) returned by Solr cannot be found in the database. Please consider reindexing your content", __METHOD__);
                     continue;
                 }
                 $resultTree = new eZFindResultNode($nodeRowList[$nodeID]);
                 $node = $nodeRowList[$nodeID];
                 $resultTree->setContentObject(new eZContentObject(array("id" => $node["id"], "section_id" => $node["section_id"], "owner_id" => $node["owner_id"], "contentclass_id" => $node["contentclass_id"], "name" => $node["name"], "published" => $node["published"], "modified" => $node["modified"], "current_version" => $node["current_version"], "status" => $node["status"], "remote_id" => $node["object_remote_id"], "language_mask" => $node["language_mask"], "initial_language_id" => $node["initial_language_id"], "class_identifier" => $node["class_identifier"], "serialized_name_list" => $node["class_serialized_name_list"])));
                 $resultTree->setAttribute('is_local_installation', true);
                 // can_read permission must be checked as they could be out of sync in Solr, however, when called from template with:
                 // limitation, hash( 'accessWord', ... ) this check should not be performed as it has precedence.
                 // See: http://issues.ez.no/15978
                 if (!isset($params['Limitation'], $params['Limitation']['accessWord']) && !$resultTree->attribute('object')->attribute('can_read')) {
                     $searchCount--;
                     eZDebug::writeNotice('Access denied for eZ Find result, node_id: ' . $nodeID, __METHOD__);
                     continue;
                 }
                 $urlAlias = $this->getUrlAlias($doc);
                 $globalURL = $urlAlias . '/(language)/' . $doc[ezfSolrDocumentFieldBase::generateMetaFieldName('language_code')];
                 eZURI::transformURI($globalURL);
             } else {
                 $resultTree = new eZFindResultNode();
                 $resultTree->setAttribute('is_local_installation', false);
                 $globalURL = $doc[ezfSolrDocumentFieldBase::generateMetaFieldName('installation_url')] . $doc[ezfSolrDocumentFieldBase::generateMetaFieldName('main_url_alias')] . '/(language)/' . $doc[ezfSolrDocumentFieldBase::generateMetaFieldName('language_code')];
             }
             $resultTree->setAttribute('name', $doc[ezfSolrDocumentFieldBase::generateMetaFieldName('name')]);
             $resultTree->setAttribute('published', $doc[ezfSolrDocumentFieldBase::generateMetaFieldName('published')]);
             $resultTree->setAttribute('global_url_alias', $globalURL);
             $resultTree->setAttribute('highlight', isset($highLights[$doc[ezfSolrDocumentFieldBase::generateMetaFieldName('guid')]]) ? $highLights[$doc[ezfSolrDocumentFieldBase::generateMetaFieldName('guid')]] : null);
             /**
              * $maxScore may be equal to 0 when the QueryElevationComponent is used.
              * It returns as first results the elevated documents, with a score equal to 0. In case no
              * other document than the elevated ones are returned, maxScore is then 0 and the
              * division below raises a warning. If maxScore is equal to zero, we can safely assume
              * that only elevated documents were returned. The latter have an articifial relevancy of 100%,
              * which must be reflected in the 'score_percent' attribute of the result node.
              */
             $maxScore != 0 ? $resultTree->setAttribute('score_percent', (int) ($doc['score'] / $maxScore * 100)) : $resultTree->setAttribute('score_percent', 100);
             $resultTree->setAttribute('language_code', $doc[ezfSolrDocumentFieldBase::generateMetaFieldName('language_code')]);
             $objectRes[] = $resultTree;
         }
     }
     return $objectRes;
 }
 /**
  * Get ezfSolrDocumentFieldBase instances for all attributes of specified eZContentObjectVersion
  *
  * @param eZContentObjectVersion $objectVersion Instance of eZContentObjectVersion to fetch attributes from.
  * @return ezfSolrDocumentFieldBase[]|ocSolrDocumentFieldObjectRelation[] List of ezfSolrDocumentFieldBase instances.
  */
 function getBaseList(eZContentObjectVersion $objectVersion)
 {
     $returnList = array();
     // Get ezfSolrDocumentFieldBase instance for all attributes in related object
     /** @var eZContentObjectAttribute $attribute */
     foreach ($objectVersion->contentObjectAttributes($this->ContentObjectAttribute->attribute('language_code')) as $attribute) {
         /** @var eZContentClassAttribute $classAttribute */
         $classAttribute = $attribute->attribute('contentclass_attribute');
         if ($classAttribute->attribute('is_searchable')) {
             $returnList[] = ezfSolrDocumentFieldBase::getInstance($attribute);
         }
     }
     return $returnList;
 }
 public function fetch()
 {
     $startDateArray = array('hour' => '00', 'minute' => '00', 'second' => '00', 'month' => $this->parameters['month'], 'day' => $this->parameters['day'], 'year' => $this->parameters['year']);
     $originalStartDateTime = DateTime::createFromFormat('H i s n j Y', implode(' ', $startDateArray), self::timezone());
     $this->parameters['picker_date'] = date(self::PICKER_DATE_FORMAT, $originalStartDateTime->getTimestamp());
     if ($this->parameters['interval'] == self::INTERVAL_MONTH) {
         $startDateArray['day'] = 1;
     }
     $startDateTime = DateTime::createFromFormat('H i s n j Y', implode(' ', $startDateArray), self::timezone());
     if (!$startDateTime instanceof DateTime) {
         throw new Exception("Data non valida");
     }
     $interval = new DateInterval($this->parameters['interval']);
     if (!$interval instanceof DateInterval) {
         throw new Exception("Intervallo non valido");
     }
     // start day
     $this->parameters['timestamp'] = $startDateTime->getTimestamp();
     $this->parameters['days_of_month'] = date('t', $startDateTime->getTimestamp());
     $this->parameters['start_weekday'] = date('w', $startDateTime->getTimestamp());
     $endOfMonthArray = array_merge($startDateArray, array('day' => $this->parameters['days_of_month']));
     $endOfMonthDateTime = DateTime::createFromFormat('H i s n j Y', implode(' ', $endOfMonthArray), self::timezone());
     $this->parameters['end_weekday'] = date('w', $endOfMonthDateTime->getTimestamp());
     $fromTimeStamp = $startDateTime->format('U');
     $this->parameters['search_from_solr'] = ezfSolrDocumentFieldBase::preProcessValue($startDateTime->getTimestamp(), 'date');
     $this->parameters['search_from_timestamp'] = $startDateTime->getTimestamp();
     // end day
     $endDateTime = clone $startDateTime;
     $endDateTime->add($interval);
     $endTimeStamp = $endDateTime->format('U');
     $this->parameters['search_to_solr'] = ezfSolrDocumentFieldBase::preProcessValue($endDateTime->getTimestamp() - 1, 'date');
     $this->parameters['search_to_timestamp'] = $endDateTime->getTimestamp();
     $this->parameters['search_to_picker_date'] = date(self::PICKER_DATE_FORMAT, $endDateTime->getTimestamp());
     // filter
     $this->filters[] = array('or', 'attr_from_time_dt:[' . $this->parameters['search_from_solr'] . ' TO ' . $this->parameters['search_to_solr'] . ']', 'attr_to_time_dt:[' . $this->parameters['search_from_solr'] . ' TO ' . $this->parameters['search_to_solr'] . ']', array('and', 'attr_from_time_dt:[* TO ' . $this->parameters['search_from_solr'] . ']', 'attr_to_time_dt:[' . $this->parameters['search_to_solr'] . ' TO *]'));
     $facets = array();
     //esempio: $this->parameters['Materia'] = '"Economia e diritto"';
     foreach (self::relatedParameters() as $fieldIdentifier => $fieldName) {
         if (isset($this->parameters[$fieldName]) && $this->parameters[$fieldName] !== false) {
             if (is_array($this->parameters[$fieldName])) {
                 $orFilter = array('or');
                 foreach ($this->parameters[$fieldName] as $value) {
                     $filterValue = addcslashes($value, '"');
                     $orFilter[] = "subattr_{$fieldIdentifier}___name____s:\"{$filterValue}\"";
                 }
                 $this->filters[] = $orFilter;
             } else {
                 $filterValue = addcslashes($this->parameters[$fieldName], '"');
                 $this->filters[] = "subattr_{$fieldIdentifier}___name____s:\"{$filterValue}\"";
             }
         }
         $facets[] = array('field' => "subattr_{$fieldIdentifier}___name____s", 'name' => $fieldName, 'limit' => 100, 'sort' => 'alpha');
     }
     if (is_array($this->parameters['filter'])) {
         $this->filters = array_merge($this->filters, $this->parameters['filter']);
     }
     $sortBy = array('attr_priority_si' => 'desc', 'attr_special_b' => 'desc');
     if (class_exists('ezfIndexEventDuration')) {
         $sortBy['extra_event_duration_s'] = 'asc';
     }
     $sortBy['attr_from_time_dt'] = 'asc';
     $solrFetchParams = array('SearchOffset' => 0, 'SearchLimit' => 1000, 'Facet' => $facets, 'SortBy' => $sortBy, 'Filter' => $this->filters, 'SearchContentClassID' => null, 'SearchSectionID' => null, 'SearchSubTreeArray' => $this->parameters['subtree'], 'AsObjects' => false, 'SpellCheck' => null, 'IgnoreVisibility' => null, 'Limitation' => null, 'BoostFunctions' => null, 'QueryHandler' => 'ezpublish', 'EnableElevation' => true, 'ForceElevation' => true, 'SearchDate' => null, 'DistributedSearch' => null, 'FieldsToReturn' => self::fieldsToReturn(), 'SearchResultClustering' => null, 'ExtendedAttributeFilter' => array());
     $solrSearch = new OCSolr();
     $solrResult = $solrSearch->search($this->parameters['query'], $solrFetchParams);
     //eZDebug::writeNotice( $this->filters, __METHOD__ );
     //eZDebug::writeNotice( $solrResult, __METHOD__ );
     $this->data['parameters'] = $this->parameters;
     $this->data['fetch_parameters'] = $solrFetchParams;
     $facetFields = $solrResult['SearchExtras']->attribute('facet_fields');
     //eZDebug::writeNotice( $solrResult['SearchExtras'], __METHOD__ );
     $resultFacets = array();
     foreach ($facets as $index => $facet) {
         if (isset($facetFields[$index]['queryLimit']) && !empty($facetFields[$index]['queryLimit'])) {
             if (isset($facetFields[$index]['fieldList'])) {
                 foreach ($facetFields[$index]['fieldList'] as $key => $value) {
                     $resultFacets[$facet['name']][] = $key;
                 }
             } else {
                 foreach ($facetFields[$index]['nameList'] as $key => $value) {
                     $resultFacets[$facet['name']][] = $key;
                 }
             }
         }
     }
     $this->data['search_facets'] = $this->sortFacets($resultFacets);
     $events = array();
     foreach ($solrResult['SearchResult'] as $item) {
         $event = OCCalendarItem::fromEzfindResultArray($item);
         if ($event->isValid()) {
             $events[] = $event;
         }
     }
     $timeTableEvents = $this->fetchTimeTableEvents();
     if (count($timeTableEvents)) {
         $events = self::reorderEvents(array_merge($events, $timeTableEvents));
     }
     //eZDebug::writeNotice( $events, __METHOD__ );
     $this->data['search_count'] = count($events);
     $eventsByDay = array();
     $byDayInterval = new DateInterval('P1D');
     $byDayPeriod = new DatePeriod($startDateTime, $byDayInterval, $endDateTime);
     foreach ($byDayPeriod as $date) {
         $identifier = $date->format(self::FULLDAY_IDENTIFIER_FORMAT);
         $calendarDay = new OCCalendarDay($identifier);
         $calendarDay->addEvents($events);
         $eventsByDay[$identifier] = $calendarDay;
     }
     $this->data['events'] = $events;
     $this->data['day_by_day'] = $eventsByDay;
     //eZDebug::writeNotice( $eventsByDay, __METHOD__ );
     //eZDebug::writeNotice( $this->data['search_facets'], __METHOD__ );
 }
Пример #23
0
 /**
  * Sets the static DocumentFieldName instance
  *
  * @return ezfSolrDocumentFieldName
  */
 public static function getDocumentFieldName()
 {
     return self::$DocumentFieldName = self::$DocumentFieldName instanceof ezfSolrDocumentFieldName ? self::$DocumentFieldName : new ezfSolrDocumentFieldName();
 }
Пример #24
0
function fakeAddObject($contentObject)
{
    $eZSolr = new eZSolr();
    // 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 = $eZSolr->FindINI->variable('IndexExclude', 'ClassIdentifierList');
    if ($excludeClasses && in_array($contentObject->attribute('class_identifier'), $excludeClasses)) {
        return false;
    }
    // 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');
    // 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 = eZSolr::getMetaAttributesForObject($contentObject);
    // Get node attributes.
    $nodeAttributeValues = array();
    foreach ($contentObject->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');
    }
    // Check anonymous user access.
    if ($eZSolr->FindINI->variable('SiteSettings', 'IndexPubliclyAvailable') == 'enabled') {
        $anonymousUserID = $eZSolr->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 = $eZSolr->FindINI->variable( "IndexBoost", "MetaField" );
    $boostClasses = $eZSolr->FindINI->variable('IndexBoost', 'Class');
    $boostAttributes = $eZSolr->FindINI->variable('IndexBoost', 'Attribute');
    $boostDatatypes = $eZSolr->FindINI->variable('IndexBoost', 'Datatype');
    $reverseRelatedScale = $eZSolr->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'), $eZSolr->guid($contentObject, $languageCode));
        // Set installation identifier
        $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('installation_id'), eZSolr::installationID());
        $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('installation_url'), $eZSolr->FindINI->variable('SiteSettings', 'URLProtocol') . $eZSolr->SiteINI->variable('SiteSettings', 'SiteURL') . '/');
        // Set Object attributes
        $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('name'), $contentObject->name(false, $languageCode));
        // Also add value to the "sort_name" field as "name" is unsortable, due to Solr limitation (tokenized field)
        $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('sort_name'), $contentObject->name(false, $languageCode));
        $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('anon_access'), $anonymousAccess);
        $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('language_code'), $languageCode);
        $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('available_language_codes'), $availableLanguages);
        if ($owner = $contentObject->attribute('owner')) {
            // Set owner name
            $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('owner_name'), $owner->name(false, $languageCode));
            // Set owner group ID
            foreach ($owner->attribute('parent_nodes') as $groupID) {
                $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('owner_group_id'), $groupID);
            }
        }
        // from eZ Publish 4.1 only: object states
        // so let's check if the content object has it
        if (method_exists($contentObject, 'stateIDArray')) {
            $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('object_states'), $contentObject->stateIDArray());
        }
        // Set content object meta attribute values.
        foreach ($metaAttributeValues as $metaInfo) {
            $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName($metaInfo['name']), ezfSolrDocumentFieldBase::preProcessValue($metaInfo['value'], $metaInfo['fieldType']));
        }
        // Set content node meta attribute values.
        foreach ($nodeAttributeValues as $metaInfo) {
            $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName($metaInfo['name']), ezfSolrDocumentFieldBase::preProcessValue($metaInfo['value'], $metaInfo['fieldType']));
        }
        // Add main url_alias
        $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('main_url_alias'), $mainNode->attribute('url_alias'));
        // Add main path_string
        $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('main_path_string'), $mainNode->attribute('path_string'));
        // add nodeid of all parent nodes path elements
        foreach ($nodePathArray as $pathArray) {
            foreach ($pathArray as $pathNodeID) {
                $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('path'), $pathNodeID);
            }
        }
        // Since eZ Fnd 2.3
        // cannot call metafield field bame constructor as we are creating multiple fields
        foreach ($mainNodePathArray as $key => $pathNodeID) {
            $doc->addField('meta_main_path_element_' . $key . '_si', $pathNodeID);
        }
        eZContentObject::recursionProtectionStart();
        // Loop through all eZContentObjectAttributes and add them to the Solr document.
        // @since eZ Find 2.3: look for the attribute storage setting
        $doAttributeStorage = $eZSolr->FindINI->variable('IndexOptions', 'EnableSolrAttributeStorage') === 'true' ? true : false;
        if ($doAttributeStorage) {
            $allAttributeData = array();
        }
        foreach ($currentVersion->contentObjectAttributes($languageCode) as $attribute) {
            $metaDataText = '';
            $classAttribute = $attribute->contentClassAttribute();
            $attributeIdentifier = $classAttribute->attribute('identifier');
            $combinedIdentifier = $contentClassIdentifier . '/' . $attributeIdentifier;
            $boostAttribute = false;
            if (isset($boostAttributes[$attributeIdentifier]) && is_numeric($boostAttributes[$attributeIdentifier])) {
                $boostAttribute = $boostAttributes[$attributeIdentifier];
            }
            if (isset($boostAttributes[$combinedIdentifier]) && is_numeric($boostAttributes[$combinedIdentifier])) {
                $boostAttribute += $boostAttributes[$combinedIdentifier];
            }
            if ($classAttribute->attribute('is_searchable') == 1) {
                $documentFieldBase = ezfSolrDocumentFieldBase::getInstance($attribute);
                $eZSolr->addFieldBaseToDoc($documentFieldBase, $doc, $boostAttribute);
            }
            if ($doAttributeStorage) {
                $storageFieldName = ezfSolrStorage::getSolrStorageFieldName($attributeIdentifier);
                $attributeData = ezfSolrStorage::getAttributeData($attribute);
                $allAttributeData['data_map'][$attributeIdentifier] = $attributeData;
                $doc->addField($storageFieldName, ezfSolrStorage::serializeData($attributeData));
            }
        }
        eZContentObject::recursionProtectionEnd();
        if ($doAttributeStorage) {
            $doc->addField('as_all_bst', ezfSolrStorage::serializeData($allAttributeData));
        }
        $docList[$languageCode] = $doc;
        $generalPlugins = (array) eZINI::instance('ezfind.ini')->variable('IndexPlugins', 'General');
        $classPlugins = (array) eZINI::instance('ezfind.ini')->variable('IndexPlugins', 'Class');
        if (!empty($generalPlugins)) {
            foreach ($generalPlugins as $pluginClassString) {
                if (!class_exists($pluginClassString)) {
                    eZDebug::writeError("Unable to find the PHP class '{$pluginClassString}' defined for index time plugins for eZ Find", __METHOD__);
                    continue;
                }
                $plugin = new $pluginClassString();
                if ($plugin instanceof ezfIndexPlugin) {
                    $plugin->modify($contentObject, $docList);
                }
            }
        }
        if (array_key_exists($contentObject->attribute('class_identifier'), $classPlugins)) {
            $pluginClassString = $classPlugins[$contentObject->attribute('class_identifier')];
            if (class_exists($pluginClassString)) {
                $plugin = new $pluginClassString();
                if ($plugin instanceof ezfIndexPlugin) {
                    $plugin->modify($contentObject, $docList);
                }
            }
        }
    }
    return $docList;
}