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


PHP eZSearch::addObject方法代码示例

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


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

示例1: registerSearchObject

 /**
  * Registers the object in search engine.
  *
  * @note Transaction unsafe. If you call several transaction unsafe methods you must enclose
  *       the calls within a db transaction; thus within db->begin and db->commit.
  *
  * @param int $objectID Id of the object.
  */
 public static function registerSearchObject($objectID)
 {
     $objectID = (int) $objectID;
     eZDebug::createAccumulatorGroup('search_total', 'Search Total');
     $ini = eZINI::instance('site.ini');
     $insertPendingAction = false;
     $object = null;
     switch ($ini->variable('SearchSettings', 'DelayedIndexing')) {
         case 'enabled':
             $insertPendingAction = true;
             break;
         case 'classbased':
             $classList = $ini->variable('SearchSettings', 'DelayedIndexingClassList');
             $object = eZContentObject::fetch($objectID);
             if (is_array($classList) && in_array($object->attribute('class_identifier'), $classList)) {
                 $insertPendingAction = true;
             }
     }
     if ($insertPendingAction) {
         eZDB::instance()->query("INSERT INTO ezpending_actions( action, param ) VALUES ( 'index_object', '{$objectID}' )");
         return;
     }
     if ($object === null) {
         $object = eZContentObject::fetch($objectID);
     }
     // Register the object in the search engine.
     $needCommit = eZSearch::needCommit();
     if (eZSearch::needRemoveWithUpdate()) {
         eZDebug::accumulatorStart('remove_object', 'search_total', 'remove object');
         eZSearch::removeObject($object, $needCommit);
         eZDebug::accumulatorStop('remove_object');
     }
     eZDebug::accumulatorStart('add_object', 'search_total', 'add object');
     if (!eZSearch::addObject($object, $needCommit)) {
         eZDebug::writeError("Failed adding object ID {$object->attribute('id')} in the search engine", __METHOD__);
     }
     eZDebug::accumulatorStop('add_object');
 }
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:46,代码来源:ezcontentoperationcollection.php

示例2: normalizeValue

             $newValue = normalizeValue($newValue, $currentValue, $attribute);
             if ($newValue != $currentValue) {
                 if ($createNewVersion) {
                     $params = array('attributes' => array($attributeIdentifier => $newValue));
                     $result = eZContentFunctions::updateAndPublishObject($object, $params);
                     if (!$result) {
                         $data['status'] = 'error';
                         $data['message'] = "Error creating new object version";
                         $data['header'] = "HTTP/1.1 400 Bad Request";
                     } else {
                         $data['status'] = 'success';
                     }
                 } else {
                     $attribute->fromString($newValue);
                     $attribute->store();
                     eZSearch::addObject($object);
                     eZContentCacheManager::clearObjectViewCacheIfNeeded($object->attribute('id'));
                     $data['status'] = 'success';
                 }
             }
         } else {
             $data['status'] = 'error';
             $data['message'] = "Attribute not found";
             $data['header'] = "HTTP/1.1 404 Not Found";
         }
     } else {
         $data['status'] = 'error';
         $data['message'] = "Attribute not found";
         $data['header'] = "HTTP/1.1 404 Not Found";
     }
 } else {
开发者ID:OpencontentCoop,项目名称:ocoperatorscollection,代码行数:31,代码来源:attribute.php

示例3: removeNodeFromTree

 function removeNodeFromTree($moveToTrash = true)
 {
     $nodeID = $this->attribute('node_id');
     $object = $this->object();
     $assignedNodes = $object->attribute('assigned_nodes');
     if ($nodeID == $this->attribute('main_node_id')) {
         if (count($assignedNodes) > 1) {
             $newMainNode = false;
             foreach ($assignedNodes as $assignedNode) {
                 $assignedNodeID = $assignedNode->attribute('node_id');
                 if ($assignedNodeID == $nodeID) {
                     continue;
                 }
                 $newMainNode = $assignedNode;
                 break;
             }
             // We need to change the main node ID before we remove the current node
             $db = eZDB::instance();
             $db->begin();
             eZContentObjectTreeNode::updateMainNodeID($newMainNode->attribute('node_id'), $object->attribute('id'), $object->attribute('current_version'), $newMainNode->attribute('parent_node_id'));
             $this->removeThis();
             eZSearch::addObject($object);
             $db->commit();
         } else {
             // This is the last assignment so we remove the object too
             $db = eZDB::instance();
             $db->begin();
             $this->removeThis();
             if ($moveToTrash) {
                 // saving information about this node in ..trash_node table
                 $trashNode = eZContentObjectTrashNode::createFromNode($this);
                 $db = eZDB::instance();
                 $db->begin();
                 $trashNode->storeToTrash();
                 $db->commit();
                 $object->removeThis();
             } else {
                 $object->purge();
             }
             $db->commit();
         }
     } else {
         $this->removeThis();
         if (count($assignedNodes) > 1) {
             eZSearch::addObject($object);
         }
     }
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:48,代码来源:ezcontentobjecttreenode.php

示例4: nodeHasForbiddenWords

    /**
     * @param eZContentObjectTreenode $node
     * @param array $row
     * @return array
     */
    protected static function nodeHasForbiddenWords( &$node, &$row )
    {
        /* @type $clustersToHide array */
        $clustersToHide = eZINI::instance( 'merck.ini' )->variable( 'PublishSettings', 'clustersToHide' );
        $returnArray    = array();
        
        foreach ($clustersToHide as $cluster)
        {
            /* @type $languageList array */
            $clusterIni = eZINI::fetchFromFile( "./extension/$cluster/settings/site.ini" );
            $languageList = $clusterIni->variable('RegionalSettings', 'SiteLanguageList');
        
            foreach( $languageList as $locale )
            {
                /* @type $nodeDatamap eZContentObjectAttribute[] */
                $nodeDatamap = $node->object()->fetchDataMap(false, $locale);

                if( !$nodeDatamap )
                    continue;

                if( $nodeDatamap['forbidden_article']->attribute('data_int') == 1 )
                {
                    // node is marked from publisher as containing some forbidden words = we hide
                    $returnArray[$cluster] = array(
                        'toHide'   => true,
                        'toDelete' => true,
                        'comment'  => 'marked by publisher',
                    );
                    break;
                }
                
                $forbiddenWordsArray = self::getForbiddenWordsArray($cluster);

                if(empty($forbiddenWordsArray))
                {
                    $returnArray[$cluster] = array(
                        'toHide'   => false,
                        'toDelete' => true,
                        'comment'  => 'no forbidden words on cluster',
                    );
                    continue;
                }

                $lgExplode      = explode('-', $locale);
                $languageFilter = $lgExplode[0] . '-*';

                $params = array(
                            'indent'   => 'on',
                            'qt'       => 'standard',
                            'q'        => '*:*',
                            'start'    => 0,
                            'stop'     => 0,
                            'fq'       => implode(' AND ', array(
                                'meta_node_id_si:'.$node->attribute('node_id'),
                                'meta_language_code_ms:'.$languageFilter,
                                'meta_installation_id_ms:'.eZSolr::installationID()
                    )),
                );

                $isInSolrResult = SolrTool::rawSearch($params, 'php', false);

                if( !$isInSolrResult['response']['numFound'] )
                {
                    // the node is not in solr. We postpone its check
                    if( $row['created'] < time() - 3600 * 4 )
                    {
                        // the node was added more than 4 hours ago. It should be in solr. We ask for a reindex
                        eZSearch::addObject( $node->object() );

                        $returnArray[$cluster] = array(    
                            'toHide'   => true,
                            'toDelete' => false,
                            'comment'  => 'not indexed in solr yet',
                        );
                        break;
                    }

                    if( $row['created'] < time() - 3600 * 48 )
                    {
                        eZLog::write( sprintf( "%s\t Node %s still not in solr after 48h", date('Y-m-d H:i:s'), $node->attribute('node_id') ), 'updatevisibility.log' );
                        $returnArray[$cluster] = array(
                            'toHide'   => true,
                            'toDelete' => true,
                            'comment'  => 'node is taking too long to be indexed',
                        );
                        break;
                    }
                }

                $params['q'] = implode(' ', $forbiddenWordsArray);
                $solrResults = SolrTool::rawSearch($params, 'php', false);

                if( !$solrResults['response']['numFound'] )
                {
                    // content has forbidden words => we hide
//.........这里部分代码省略.........
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:101,代码来源:nodevisibilitycheck.php


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