本文整理汇总了PHP中eZSearch类的典型用法代码示例。如果您正苦于以下问题:PHP eZSearch类的具体用法?PHP eZSearch怎么用?PHP eZSearch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZSearch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
public static function build(\Closure $legacyKernelClosure)
{
try {
$searchEngine = $legacyKernelClosure()->runCallback(function () {
return \eZSearch::getEngine();
});
} catch (\Exception $e) {
$searchEngine = new NullSearchEngine();
}
return $searchEngine;
}
示例2: fetchContentSearch
public static function fetchContentSearch($searchText, $subTreeArray, $offset, $limit, $searchTimestamp, $publishDate, $sectionID, $classID, $classAttributeID, $ignoreVisibility, $limitation, $sortArray)
{
$searchArray = eZSearch::buildSearchArray();
$parameters = array();
if ($classID !== false) {
$parameters['SearchContentClassID'] = $classID;
}
if ($classAttributeID !== false) {
$parameters['SearchContentClassAttributeID'] = $classAttributeID;
}
if ($sectionID !== false) {
$parameters['SearchSectionID'] = $sectionID;
}
if ($publishDate !== false) {
$parameters['SearchDate'] = $publishDate;
}
if ($sortArray !== false) {
$parameters['SortArray'] = $sortArray;
}
$parameters['SearchLimit'] = $limit;
$parameters['SearchOffset'] = $offset;
$parameters['IgnoreVisibility'] = $ignoreVisibility;
$parameters['Limitation'] = $limitation;
if ($subTreeArray !== false) {
$parameters['SearchSubTreeArray'] = $subTreeArray;
}
if ($searchTimestamp) {
$parameters['SearchTimestamp'] = $searchTimestamp;
}
$searchResult = eZSearch::search($searchText, $parameters, $searchArray);
return array('result' => $searchResult);
}
示例3: search
/**
* Returns search results based on given post params
*
* @param mixed $args Only used if post parameter is not set
* 0 => SearchStr
* 1 => SearchOffset
* 2 => SearchLimit (10 by default, max 50)
* @return array
*/
public static function search($args)
{
$http = eZHTTPTool::instance();
if ($http->hasPostVariable('SearchStr')) {
$searchStr = trim($http->postVariable('SearchStr'));
} else {
if (isset($args[0])) {
$searchStr = trim($args[0]);
}
}
if ($http->hasPostVariable('SearchOffset')) {
$searchOffset = (int) $http->postVariable('SearchOffset');
} else {
if (isset($args[1])) {
$searchOffset = (int) $args[1];
} else {
$searchOffset = 0;
}
}
if ($http->hasPostVariable('SearchLimit')) {
$searchLimit = (int) $http->postVariable('SearchLimit');
} else {
if (isset($args[2])) {
$searchLimit = (int) $args[2];
} else {
$searchLimit = 10;
}
}
// Do not allow to search for more then x items at a time
$ini = eZINI::instance();
$maximumSearchLimit = (int) $ini->variable('SearchSettings', 'MaximumSearchLimit');
if ($searchLimit > $maximumSearchLimit) {
$searchLimit = $maximumSearchLimit;
}
// Prepare node encoding parameters
$encodeParams = array();
if (self::hasPostValue($http, 'EncodingLoadImages')) {
$encodeParams['loadImages'] = true;
}
if (self::hasPostValue($http, 'EncodingFetchChildrenCount')) {
$encodeParams['fetchChildrenCount'] = true;
}
if (self::hasPostValue($http, 'EncodingFetchSection')) {
$encodeParams['fetchSection'] = true;
}
if (self::hasPostValue($http, 'EncodingFormatDate')) {
$encodeParams['formatDate'] = $http->postVariable('EncodingFormatDate');
}
// Prepare search parameters
$params = array('SearchOffset' => $searchOffset, 'SearchLimit' => $searchLimit, 'SortArray' => array('published', 0), 'SortBy' => array('published' => 'desc'));
if (self::hasPostValue($http, 'SearchContentClassAttributeID')) {
$params['SearchContentClassAttributeID'] = self::makePostArray($http, 'SearchContentClassAttributeID');
} else {
if (self::hasPostValue($http, 'SearchContentClassID')) {
$params['SearchContentClassID'] = self::makePostArray($http, 'SearchContentClassID');
} else {
if (self::hasPostValue($http, 'SearchContentClassIdentifier')) {
$params['SearchContentClassID'] = eZContentClass::classIDByIdentifier(self::makePostArray($http, 'SearchContentClassIdentifier'));
}
}
}
if (self::hasPostValue($http, 'SearchSubTreeArray')) {
$params['SearchSubTreeArray'] = self::makePostArray($http, 'SearchSubTreeArray');
}
if (self::hasPostValue($http, 'SearchSectionID')) {
$params['SearchSectionID'] = self::makePostArray($http, 'SearchSectionID');
}
if (self::hasPostValue($http, 'SearchDate')) {
$params['SearchDate'] = (int) $http->postVariable('SearchDate');
} else {
if (self::hasPostValue($http, 'SearchTimestamp')) {
$params['SearchTimestamp'] = self::makePostArray($http, 'SearchTimestamp');
if (!isset($params['SearchTimestamp'][1])) {
$params['SearchTimestamp'] = $params['SearchTimestamp'][0];
}
}
}
if (self::hasPostValue($http, 'EnableSpellCheck') || self::hasPostValue($http, 'enable-spellcheck', '0')) {
$params['SpellCheck'] = array(true);
}
if (self::hasPostValue($http, 'GetFacets') || self::hasPostValue($http, 'show-facets', '0')) {
$params['facet'] = eZFunctionHandler::execute('ezfind', 'getDefaultSearchFacets', array());
}
$result = array('SearchOffset' => $searchOffset, 'SearchLimit' => $searchLimit, 'SearchResultCount' => 0, 'SearchCount' => 0, 'SearchResult' => array(), 'SearchString' => $searchStr, 'SearchExtras' => array());
// Possibility to keep track of callback reference for use in js callback function
if ($http->hasPostVariable('CallbackID')) {
$result['CallbackID'] = $http->postVariable('CallbackID');
}
// Only search if there is something to search for
if ($searchStr) {
$searchList = eZSearch::search($searchStr, $params);
//.........这里部分代码省略.........
示例4: 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);
}
}
}
示例5: removeThis
/**
* Archives the current object and removes assigned nodes
*
* 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 $nodeID
*/
function removeThis( $nodeID = null )
{
$delID = $this->ID;
// Who deletes which content should be logged.
eZAudit::writeAudit( 'content-delete', array( 'Object ID' => $delID, 'Content Name' => $this->attribute( 'name' ),
'Comment' => 'Setted archived status for the current object: eZContentObject::remove()' ) );
$nodes = $this->attribute( 'assigned_nodes' );
if ( $nodeID === null or count( $nodes ) <= 1 )
{
$db = eZDB::instance();
$db->begin();
$mainNodeKey = false;
foreach ( $nodes as $key => $node )
{
if ( $node->attribute( 'main_node_id' ) == $node->attribute( 'node_id' ) )
{
$mainNodeKey = $key;
}
else
{
$node->removeThis();
}
}
if ( $mainNodeKey !== false )
{
$nodes[$mainNodeKey]->removeNodeFromTree( true );
}
$this->setAttribute( 'status', eZContentObject::STATUS_ARCHIVED );
eZSearch::removeObjectById( $delID );
$this->store();
eZContentObject::fixReverseRelations( $delID, 'trash' );
// Delete stored attribute from other tables
$db->commit();
}
else if ( $nodeID !== null )
{
$node = eZContentObjectTreeNode::fetch( $nodeID , false );
if ( is_object( $node ) )
{
if ( $node->attribute( 'main_node_id' ) == $nodeID )
{
$db = eZDB::instance();
$db->begin();
foreach ( $additionalNodes as $additionalNode )
{
if ( $additionalNode->attribute( 'node_id' ) != $node->attribute( 'main_node_id' ) )
{
$additionalNode->remove();
}
}
$node->removeNodeFromTree( true );
$this->setAttribute( 'status', eZContentObject::STATUS_ARCHIVED );
eZSearch::removeObjectById( $delID );
$this->store();
eZContentObject::fixReverseRelations( $delID, 'trash' );
$db->commit();
}
else
{
eZContentObjectTreeNode::removeNode( $nodeID );
}
}
}
else
{
eZContentObjectTreeNode::removeNode( $nodeID );
}
}
示例6: QuestionInteractiveCli
}
$pathIdentificationString = $node->attribute('path_identification_string');
if ( $node->IsHidden )
{
$cli->warning ( " Already hidden : [" . $nodeId . "] " . $pathIdentificationString . " : " . $node->getName() );
continue;
}
$validCalculatorsNodeId[] = $nodeId;
$possibleReplies[] = $nodeId . " " . $pathIdentificationString . " : " . $node->getName();
}
$questionHandler = new QuestionInteractiveCli();
$question = "Hide which nodes";
$response = $questionHandler->askQuestionMultipleChoices($question, $possibleReplies, 'validateReplyMultiple', true);
foreach ( $response as $indexToHide )
{
$nodeId = $validCalculatorsNodeId[$indexToHide];
$node = eZContentObjectTreeNode::fetch($nodeId);
eZContentObjectTreeNode::hideSubTree( $node );
eZSearch::updateNodeVisibility( $node->NodeID, 'hide' );
$pathIdentificationString = $node->attribute('path_identification_string');
$cli->warning ( " Hiding : [" . $nodeId . "] " . $pathIdentificationString . " : " . $node->getName() );
}
示例7: array
} else {
$subTreeList = array($http->variable('SubTreeArray'));
}
foreach ($subTreeList as $subTreeItem) {
// as form input is generally a string, is_int cannot be used for checking the value type
if (is_numeric($subTreeItem) && $subTreeItem > 0) {
$subTreeArray[] = $subTreeItem;
}
}
}
$Module->setTitle("Search for: {$searchText}");
$classArray = eZContentClass::fetchList(eZContentClass::VERSION_STATUS_DEFINED, true, false, array('name' => 'asc'));
$sectionArray = eZSection::fetchList();
$searchArray = eZSearch::buildSearchArray();
if ($useSearchCode) {
$searchResult = eZSearch::search($searchText, array('SearchSectionID' => $searchSectionID, 'SearchContentClassID' => $searchContentClassID, 'SearchContentClassAttributeID' => $searchContentClassAttributeID, 'SearchSubTreeArray' => $subTreeArray, 'SearchDate' => $searchDate, 'SearchTimestamp' => $searchTimestamp, 'SearchLimit' => $pageLimit, 'SearchOffset' => $Offset), $searchArray);
if (strlen(trim($searchText)) == 0 && count($searchArray) > 0) {
$searchText = 'search by additional parameter';
}
}
$viewParameters = array('offset' => $Offset);
$searchData = false;
$tpl->setVariable("search_data", $searchData);
$tpl->setVariable('search_contentclass_id', $searchContentClassID);
$tpl->setVariable('search_contentclass_attribute_id', $searchContentClassAttributeID);
$tpl->setVariable('search_section_id', $searchSectionID);
$tpl->setVariable('search_date', $searchDate);
$tpl->setVariable('search_timestamp', $searchTimestamp);
$tpl->setVariable('search_sub_tree', $subTreeArray);
$tpl->setVariable('search_text', $searchText);
$tpl->setVariable('search_page_limit', $searchPageLimit);
示例8:
<?php
/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
* @version 2014.07.0
*/
if (!$isQuiet) {
$cli->output("Starting solr index optimization");
}
// check that solr is enabled and used
$eZSolr = eZSearch::getEngine();
if (!$eZSolr instanceof eZSolr) {
$script->shutdown(1, 'The current search engine plugin is not eZSolr');
}
$eZSolr->optimize(false);
if (!$isQuiet) {
$cli->output("Done");
}
示例9: move
static function move($nodeID, $newParentNodeID)
{
$result = false;
if (!is_numeric($nodeID) || !is_numeric($newParentNodeID)) {
return false;
}
$node = eZContentObjectTreeNode::fetch($nodeID);
if (!$node) {
return false;
}
$object = $node->object();
if (!$object) {
return false;
}
$objectID = $object->attribute('id');
$oldParentNode = $node->fetchParent();
$oldParentObject = $oldParentNode->object();
// clear user policy cache if this is a user object
if (in_array($object->attribute('contentclass_id'), eZUser::contentClassIDs())) {
eZUser::purgeUserCacheByUserId($object->attribute('id'));
}
// clear cache for old placement.
// If child count exceeds threshold, do nothing here, and instead clear all view cache at the end.
$childCountInThresholdRange = eZContentCache::inCleanupThresholdRange($node->childrenCount(false));
if ($childCountInThresholdRange) {
eZContentCacheManager::clearContentCacheIfNeeded($objectID);
}
$db = eZDB::instance();
$db->begin();
$node->move($newParentNodeID);
$newNode = eZContentObjectTreeNode::fetchNode($objectID, $newParentNodeID);
if ($newNode) {
$newNode->updateSubTreePath(true, true);
if ($newNode->attribute('main_node_id') == $newNode->attribute('node_id')) {
// If the main node is moved we need to check if the section ID must change
$newParentNode = $newNode->fetchParent();
$newParentObject = $newParentNode->object();
if ($object->attribute('section_id') != $newParentObject->attribute('section_id')) {
eZContentObjectTreeNode::assignSectionToSubTree($newNode->attribute('main_node_id'), $newParentObject->attribute('section_id'), $oldParentObject->attribute('section_id'));
}
}
// modify assignment
$curVersion = $object->attribute('current_version');
$nodeAssignment = eZNodeAssignment::fetch($objectID, $curVersion, $oldParentNode->attribute('node_id'));
if ($nodeAssignment) {
$nodeAssignment->setAttribute('parent_node', $newParentNodeID);
$nodeAssignment->setAttribute('op_code', eZNodeAssignment::OP_CODE_MOVE);
$nodeAssignment->store();
// update search index specifying we are doing a move operation
$nodeIDList = array($nodeID);
eZSearch::removeNodeAssignment($node->attribute('main_node_id'), $newNode->attribute('main_node_id'), $object->attribute('id'), $nodeIDList);
eZSearch::addNodeAssignment($newNode->attribute('main_node_id'), $object->attribute('id'), $nodeIDList, true);
}
$result = true;
} else {
eZDebug::writeError("Node {$nodeID} was moved to {$newParentNodeID} but fetching the new node failed");
}
$db->commit();
// clear cache for new placement.
// If child count exceeds threshold, clear all view cache instead.
if ($childCountInThresholdRange) {
eZContentCacheManager::clearContentCacheIfNeeded($objectID);
} else {
eZContentCacheManager::clearAllContentCache();
}
return $result;
}
示例10: 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 {
示例11: eZPendingActions
$nodeID = $module->actionParameter( 'NodeID' );
$languageCode = $module->actionParameter( 'LanguageCode' );
$viewMode = 'full';
if ( !$module->hasActionParameter( 'ViewMode' ) )
{
$viewMode = $module->actionParameter( 'ViewMode' );
}
if ( $module->isCurrentAction( 'IndexObject' )
|| $module->isCurrentAction( 'IndexSubtree' )) {
eZContentOperationCollection::registerSearchObject( $objectID );
}
if ( $module->isCurrentAction( 'IndexSubtree' ) ) {
$pendingAction = new eZPendingActions(
array(
'action' => eZSolr::PENDING_ACTION_INDEX_SUBTREE,
'created' => time(),
'param' => $nodeID
)
);
$pendingAction->store();
}
if ( $module->isCurrentAction( 'RemoveObject' ) ) {
$object = eZContentObject::fetch($objectID);
eZSearch::removeObject($object, true);
}
return $module->redirect( 'content', 'view', array( $viewMode, $nodeID, $languageCode ) );
示例12: move
static function move( $nodeID, $newParentNodeID )
{
$result = false;
if ( !is_numeric( $nodeID ) || !is_numeric( $newParentNodeID ) )
return false;
$node = eZContentObjectTreeNode::fetch( $nodeID );
if ( !$node )
return false;
$object = $node->object();
if ( !$object )
return false;
$objectID = $object->attribute( 'id' );
$oldParentNode = $node->fetchParent();
$oldParentObject = $oldParentNode->object();
// clear user policy cache if this is a user object
if ( in_array( $object->attribute( 'contentclass_id' ), eZUser::contentClassIDs() ) )
{
eZUser::purgeUserCacheByUserId( $object->attribute( 'id' ) );
}
// clear cache for old placement.
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
$db = eZDB::instance();
$db->begin();
$node->move( $newParentNodeID );
$newNode = eZContentObjectTreeNode::fetchNode( $objectID, $newParentNodeID );
if ( $newNode )
{
$newNode->updateSubTreePath( true, true );
if ( $newNode->attribute( 'main_node_id' ) == $newNode->attribute( 'node_id' ) )
{
// If the main node is moved we need to check if the section ID must change
$newParentNode = $newNode->fetchParent();
$newParentObject = $newParentNode->object();
if ( $object->attribute( 'section_id' ) != $newParentObject->attribute( 'section_id' ) )
{
eZContentObjectTreeNode::assignSectionToSubTree( $newNode->attribute( 'main_node_id' ),
$newParentObject->attribute( 'section_id' ),
$oldParentObject->attribute( 'section_id' ) );
}
}
// modify assignment
$curVersion = $object->attribute( 'current_version' );
$nodeAssignment = eZNodeAssignment::fetch( $objectID, $curVersion, $oldParentNode->attribute( 'node_id' ) );
if ( $nodeAssignment )
{
$nodeAssignment->setAttribute( 'parent_node', $newParentNodeID );
$nodeAssignment->setAttribute( 'op_code', eZNodeAssignment::OP_CODE_MOVE );
$nodeAssignment->store();
// update search index
$nodeIDList = array( $nodeID );
eZSearch::removeNodeAssignment( $node->attribute( 'main_node_id' ), $newNode->attribute( 'main_node_id' ), $object->attribute( 'id' ), $nodeIDList );
eZSearch::addNodeAssignment( $newNode->attribute( 'main_node_id' ), $object->attribute( 'id' ), $nodeIDList );
}
$result = true;
}
else
{
eZDebug::writeError( "Node $nodeID was moved to $newParentNodeID but fetching the new node failed" );
}
$db->commit();
// clear cache for new placement.
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
return $result;
}
示例13: updateGlobalLimitation
/**
* @param eZContentObject $contentObject
* @param bool|null $parentIsInvisible Only defined as boolean true|false if we are recursively going in a child
*/
public static function updateGlobalLimitation ( $contentObject, $parentIsInvisible = null )
{
/* @type $contentMainNode eZContentObjectTreeNode */
$db = eZDB::instance();
$contentObjectID = $contentObject->attribute('id');
$contentMainNode = $contentObject->mainNode();
if ( !($contentMainNode instanceof eZContentObjectTreeNode) )
return;
/* @type $dm eZContentObjectAttribute[] */
$contentDepth = $contentMainNode->attribute('depth');
$merckINI = eZINI::instance('merck.ini');
$onlineDateAttribute = $merckINI->variable("ArticleVisibility","OnlineDate");
$offlineDateAttribute = $merckINI->variable("ArticleVisibility","OfflineDate");
$dm = $contentObject->attribute("data_map");
if ( !is_array($dm) )
return;
/* @type $onlineDateContent eZDateTime */
/* @type $offlineDateContent eZDateTime */
$onlineDateContent = $dm[$onlineDateAttribute]->content();
$onlineDate = $onlineDateContent->timeStamp();
$offlineDateContent = $dm[$offlineDateAttribute]->content();
$offlineDate = $offlineDateContent->timeStamp();
$visibility = MMEventManager::visibilityDates($contentObject);
$isInvisible = !$visibility;
// We have a parent article, we check its visibility
if ( !$isInvisible && $parentIsInvisible === null && $contentDepth > 4 )
{
$parentNode = $contentMainNode->fetchParent();
$isInvisible = self::isGloballyLimited( $parentNode->attribute('contentobject_id') );
}
elseif ( !$isInvisible )
{
if ( $parentIsInvisible !== null && $parentIsInvisible === true )
$isInvisible = true;
}
$db->beginQuery();
$visibilityChange = self::updateGlobalLimitationEntry( $contentObjectID, $offlineDate, $onlineDate, $visibility, $isInvisible);
if ( $visibilityChange && $visibility && !$isInvisible )
{
eZSearch::updateNodeVisibility($contentObject->mainNodeID(), 'show');
}
elseif ( $visibilityChange && ( !$visibility || $isInvisible ) )
{
eZSearch::updateNodeVisibility($contentObject->mainNodeID(), 'hide');
}
if ( $visibilityChange )
self::spreadGlobalLimitationChange( $contentMainNode, $isInvisible );
$db->commitQuery();
}
示例14: 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
//.........这里部分代码省略.........
示例15: updateObjectState
/**
* Update a contentobject's state
*
* @param int $objectID
* @param int $selectedStateIDList
*
* @return array An array with operation status, always true
*/
public static function updateObjectState($objectID, $selectedStateIDList)
{
$object = eZContentObject::fetch($objectID);
// we don't need to re-assign states the object currently already has assigned
$currentStateIDArray = $object->attribute('state_id_array');
$selectedStateIDList = array_diff($selectedStateIDList, $currentStateIDArray);
// filter out any states the current user is not allowed to assign
$canAssignStateIDList = $object->attribute('allowed_assign_state_id_list');
$selectedStateIDList = array_intersect($selectedStateIDList, $canAssignStateIDList);
foreach ($selectedStateIDList as $selectedStateID) {
$state = eZContentObjectState::fetchById($selectedStateID);
$object->assignState($state);
}
//call appropriate method from search engine
eZSearch::updateObjectState($objectID, $selectedStateIDList);
eZContentCacheManager::clearContentCacheIfNeeded($objectID);
return array('status' => true);
}