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


PHP eZContentObject::recursionProtectionEnd方法代码示例

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


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

示例1: addObject

 /**
  * 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
  * @return bool True if the operation succeed.
  */
 public function addObject($contentObject, $commit = true)
 {
     $contentObjectID = $contentObject->attribute('id');
     $currentVersion = $contentObject->currentVersion();
     if (!$currentVersion) {
         $errCurrentVersion = $contentObject->attribute('current_version');
         eZDebug::writeError("Failed to fetch \"current version\" ({$errCurrentVersion})" . " of content object (ID: {$contentObjectID})", 'eZSearchEngine');
         return false;
     }
     $indexArray = array();
     $indexArrayOnlyWords = array();
     $wordCount = 0;
     $placement = 0;
     $previousWord = '';
     eZContentObject::recursionProtectionStart();
     foreach ($currentVersion->contentObjectAttributes() as $attribute) {
         $metaData = array();
         $classAttribute = $attribute->contentClassAttribute();
         if ($classAttribute->attribute("is_searchable") == 1) {
             // Fetch attribute translations
             $attributeTranslations = $attribute->fetchAttributeTranslations();
             foreach ($attributeTranslations as $translation) {
                 $tmpMetaData = $translation->metaData();
                 if (!is_array($tmpMetaData)) {
                     $tmpMetaData = array(array('id' => $attribute->attribute('contentclass_attribute_identifier'), 'text' => $tmpMetaData));
                 }
                 $metaData = array_merge($metaData, $tmpMetaData);
             }
             foreach ($metaData as $metaDataPart) {
                 $text = eZSearchEngine::normalizeText(htmlspecialchars($metaDataPart['text'], ENT_NOQUOTES, 'UTF-8'), true);
                 // Split text on whitespace
                 if (is_numeric(trim($text))) {
                     $integerValue = (int) $text;
                 } else {
                     $integerValue = 0;
                 }
                 $wordArray = explode(' ', $text);
                 foreach ($wordArray as $word) {
                     if (trim($word) != "") {
                         // words stored in search index are limited to 150 characters
                         if (strlen($word) > 150) {
                             $word = substr($word, 0, 150);
                         }
                         $indexArray[] = array('Word' => $word, 'ContentClassAttributeID' => $attribute->attribute('contentclassattribute_id'), 'identifier' => $metaDataPart['id'], 'integer_value' => $integerValue);
                         $indexArrayOnlyWords[$word] = 1;
                         $wordCount++;
                         //if we have "www." before word than
                         //treat it as url and add additional entry to the index
                         if (substr(strtolower($word), 0, 4) == 'www.') {
                             $additionalUrlWord = substr($word, 4);
                             $indexArray[] = array('Word' => $additionalUrlWord, 'ContentClassAttributeID' => $attribute->attribute('contentclassattribute_id'), 'identifier' => $metaDataPart['id'], 'integer_value' => $integerValue);
                             $indexArrayOnlyWords[$additionalUrlWord] = 1;
                             $wordCount++;
                         }
                     }
                 }
             }
         }
     }
     eZContentObject::recursionProtectionEnd();
     $wordIDArray = $this->buildWordIDArray(array_keys($indexArrayOnlyWords));
     $db = eZDB::instance();
     $db->begin();
     for ($arrayCount = 0; $arrayCount < $wordCount; $arrayCount += 1000) {
         $placement = $this->indexWords($contentObject, array_slice($indexArray, $arrayCount, 1000), $wordIDArray, $placement);
     }
     $db->commit();
     return true;
 }
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:76,代码来源:ezsearchengine.php

示例2: optimize


//.........这里部分代码省略.........
            {
                $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 );
                    $this->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;
        }

        // Since eZFind 2.7: indexhooks
        $generalPlugins = $this->FindINI->variable( 'IndexPlugins', 'General' );
        $classPlugins   = $this->FindINI->variable( 'IndexPlugins', 'Class' );
        if ( !empty( $generalPlugins ) )
        {
            foreach ( $generalPlugins as $pluginClassString )
            {
                if( !class_exists( $pluginClassString ) )
                {
                    eZDebug::writeError( "Unable to find the PHP class '$classname' 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' )];
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:67,代码来源:ezsolr.php

示例3: elseif

    $db->commit();
}
elseif ( $storingAllowed )
{
    if ( !isset( $currentRedirectionURI ) )
        $currentRedirectionURI = $Module->redirectionURI( 'content', 'edit', array( $ObjectID, $EditVersion, $EditLanguage ) );
    eZContentObject::recursionProtectionStart();
    foreach( $contentObjectAttributes as $contentObjectAttribute )
    {
        $object->handleCustomHTTPActions( $contentObjectAttribute,  $attributeDataBaseName,
                                          $customActionAttributeArray,
                                          array( 'module' => $Module,
                                                 'current-redirection-uri' => $currentRedirectionURI ) );
        $contentObjectAttribute->setContent( $contentObjectAttribute->attribute( 'content' ) );
    }
    eZContentObject::recursionProtectionEnd();
}

$invalidNodeAssignmentList = array();
if ( $Module->isCurrentAction( 'Publish' ) )
{
    $mainFound = false;
    $assignments = $version->attribute( 'parent_nodes' );
    $db = eZDB::instance();
    $db->begin();
    foreach ( array_keys( $assignments ) as $key )
    {
        // Check that node assignment node exists.
        if ( !$assignments[$key]->attribute( 'parent_node_obj' ) )
        {
            $validation[ 'placement' ][] = array( 'text' => ezpI18n::tr( 'kernel/content', 'A node in the node assignment list has been deleted.' ) );
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:31,代码来源:attribute_edit.php

示例4: testGetData

 /**
  * 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());
     }
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:71,代码来源:ezfsolrdocumentfieldbase_test.php


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