当前位置: 首页>>代码示例>>PHP>>正文


PHP eZSolr::guid方法代码示例

本文整理汇总了PHP中eZSolr::guid方法的典型用法代码示例。如果您正苦于以下问题:PHP eZSolr::guid方法的具体用法?PHP eZSolr::guid怎么用?PHP eZSolr::guid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZSolr的用法示例。


在下文中一共展示了eZSolr::guid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGenerateConfiguration

    /**
     * test for generateConfiguration()
     */
    public function testGenerateConfiguration()
    {
        // clean up the table beforehand
        $db = eZDB::instance();
        $rows = $db->query('TRUNCATE TABLE ezfind_elevate_configuration;');
        $solr = new eZSolr();
        # start 1
        $queryString = "test 1";
        $objectID = 1;
        $object = eZContentObject::fetch($objectID);
        $language = "eng-GB";
        $docId = $solr->guid($object, $language);
        eZFindElevateConfiguration::add($queryString, $objectID, $language);
        eZFindElevateConfigurationTester::generateConfiguration();
        $configuration1 = eZFindElevateConfigurationTester::getConfiguration();
        $expected1 = <<<ENDT
<?xml version="1.0" encoding="UTF-8"?>
<elevate><query text="test 1"><doc id="
ENDT;
        $expected1 .= $docId;
        $expected1 .= <<<ENDT
"/></query></elevate>

ENDT;
        self::assertEquals($expected1, $configuration1);
        # end 1
    }
开发者ID:kevindejour,项目名称:ezfind,代码行数:30,代码来源:ezfindelevateconfiguration_test.php

示例2: generateConfiguration

 /**
  * Extracts the configuration stored in the DB and turns it into a Solr-compliant XML string.
  * Stores the result string in the local property $configurationXML
  *
  * @see $configurationXML
  * @return boolean true if the generation run correctly, false otherwise.
  *
  */
 protected static function generateConfiguration()
 {
     $db = eZDB::instance();
     $def = self::definition();
     $query = "SELECT DISTINCT search_query FROM " . $def['name'];
     $limit = 50;
     $offset = 0;
     $solr = new eZSolr();
     $xml = new SimpleXMLElement(self::XML_SKELETON);
     self::$configurationXML = $xml->asXML();
     while (true) {
         // fetch distinct search queries
         $rows = $db->arrayQuery($query, array('limit' => $limit, 'offset' => $offset));
         if (empty($rows)) {
             break;
         }
         // For each query string, generate the corresponding bloc in elevate.xml
         // Looks like this :
         //
         // <query text="foo bar">
         //    <doc id="1" />
         //    <doc id="2" />
         //    <doc id="3" />
         // </query>
         $xml = new SimpleXMLElement(self::$configurationXML);
         foreach ($rows as $row) {
             $searchQuery = $xml->addChild('query');
             $searchQuery->addAttribute('text', $row['search_query']);
             $results = self::fetchObjectsForQueryString($row['search_query']);
             foreach ($results as $languageCode => $objects) {
                 foreach ($objects as $object) {
                     if ($languageCode === self::WILDCARD) {
                         $currentVersion = $object->currentVersion();
                         foreach ($currentVersion->translationList(false, false) as $lang) {
                             $guid = $solr->guid($object, $lang);
                             $doc = $searchQuery->addChild('doc');
                             $doc->addAttribute('id', $guid);
                         }
                     } else {
                         $guid = $solr->guid($object, $languageCode);
                         $doc = $searchQuery->addChild('doc');
                         $doc->addAttribute('id', $guid);
                     }
                 }
             }
         }
         $offset += $limit;
         self::$configurationXML = $xml->asXML();
     }
     return true;
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:59,代码来源:ezfindelevateconfiguration.php

示例3: fakeAddObject

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']));
        }
//.........这里部分代码省略.........
开发者ID:OpencontentCoop,项目名称:ocsearchtools,代码行数:101,代码来源:object.php


注:本文中的eZSolr::guid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。