original_string: static public function suggest( $args )
      {
          $http = eZHTTPTool::instance();
  
          $searchEngine = eZINI::instance()->variable( 'SearchSettings', 'SearchEngine' );
          if ( !class_exists( 'eZSolr' ) || $searchEngine != 'ezsolr' )
              return array( 'status' => 'success', 'message' => '', 'tags' => array() );
  
          $tagIDs = $http->postVariable( 'tag_ids', '' );
          if ( empty( $tagIDs ) )
              return array( 'status' => 'success', 'message' => '', 'tags' => array() );
          if ( is_array( $tagIDs ) ) {
              $tagIDs = implode( '|#', $tagIDs );
          }
  
          $tagIDs = array_values( array_unique( explode( '|#', $tagIDs ) ) );
  
          $solrSearch = new eZSolr();
          $params = array(
              'SearchOffset'   => 0,
              'SearchLimit'    => 0,
              'Facet'          => array(
                  array(
                      'field' => 'ezf_df_tag_ids',
                      'limit' => 5 + count( $tagIDs ),
                      'mincount' => 1
                  )
              ),
              'Filter'         => array(
                  'ezf_df_tag_ids' => implode( ' OR ', $tagIDs )
              ),
              'QueryHandler'   => 'ezpublish',
              'AsObjects'      => false
          );
  
          $searchResult = $solrSearch->search( '', $params );
          if ( !isset( $searchResult['SearchExtras'] ) || !$searchResult['SearchExtras'] instanceof ezfSearchResultInfo )
          {
              eZDebug::writeWarning( 'There was an error fetching tag suggestions from Solr. Maybe server is not running or using unpatched schema?', __METHOD__ );
              return array( 'status' => 'success', 'message' => '', 'tags' => array() );
          }
  
          $facetResult = $searchResult['SearchExtras']->attribute( 'facet_fields' );
          if ( !is_array( $facetResult ) || !is_array( $facetResult[0]['nameList'] ) )
          {
              eZDebug::writeWarning( 'There was an error fetching tag suggestions from Solr. Maybe server is not running or using unpatched schema?', __METHOD__ );
              return array( 'status' => 'success', 'message' => '', 'tags' => array() );
          }
  
          $facetResult = array_values( $facetResult[0]['nameList'] );
  
          $tagsToSuggest = array();
          foreach ( $facetResult as $result )
          {
              if ( !in_array( $result, $tagIDs ) )
                  $tagsToSuggest[] = $result;
          }
  
          if ( empty( $tagsToSuggest ) )
              return array( 'status' => 'success', 'message' => '', 'tags' => array() );
  
          return self::generateOutput(
              array( 'id' => array( $tagsToSuggest ) ),
              $http->postVariable( 'subtree_limit', 0 ),
              false,
              $http->postVariable( 'locale', '' )
          );
      }
code: static public function suggest( $args )
      {
          $http = eZHTTPTool::instance();
  
          $searchEngine = eZINI::instance()->variable( 'SearchSettings', 'SearchEngine' );
          if ( !class_exists( 'eZSolr' ) || $searchEngine != 'ezsolr' )
              return array( 'status' => 'success', 'message' => '', 'tags' => array() );
  
          $tagIDs = $http->postVariable( 'tag_ids', '' );
          if ( empty( $tagIDs ) )
              return array( 'status' => 'success', 'message' => '', 'tags' => array() );
          if ( is_array( $tagIDs ) ) {
              $tagIDs = implode( '|#', $tagIDs );
          }
  
          $tagIDs = array_values( array_unique( explode( '|#', $tagIDs ) ) );
  
          $solrSearch = new eZSolr();
          $params = array(
              'SearchOffset'   => 0,
              'SearchLimit'    => 0,
              'Facet'          => array(
                  array(
                      'field' => 'ezf_df_tag_ids',
                      'limit' => 5 + count( $tagIDs ),
                      'mincount' => 1
                  )
              ),
              'Filter'         => array(
                  'ezf_df_tag_ids' => implode( ' OR ', $tagIDs )
              ),
              'QueryHandler'   => 'ezpublish',
              'AsObjects'      => false
          );
  
          $searchResult = $solrSearch->search( '', $params );
          if ( !isset( $searchResult['SearchExtras'] ) || !$searchResult['SearchExtras'] instanceof ezfSearchResultInfo )
          {
              eZDebug::writeWarning( 'There was an error fetching tag suggestions from Solr. Maybe server is not running or using unpatched schema?', __METHOD__ );
              return array( 'status' => 'success', 'message' => '', 'tags' => array() );
          }
  
          $facetResult = $searchResult['SearchExtras']->attribute( 'facet_fields' );
          if ( !is_array( $facetResult ) || !is_array( $facetResult[0]['nameList'] ) )
          {
              eZDebug::writeWarning( 'There was an error fetching tag suggestions from Solr. Maybe server is not running or using unpatched schema?', __METHOD__ );
              return array( 'status' => 'success', 'message' => '', 'tags' => array() );
          }
  
          $facetResult = array_values( $facetResult[0]['nameList'] );
  
          $tagsToSuggest = array();
          foreach ( $facetResult as $result )
          {
              if ( !in_array( $result, $tagIDs ) )
                  $tagsToSuggest[] = $result;
          }
  
          if ( empty( $tagsToSuggest ) )
              return array( 'status' => 'success', 'message' => '', 'tags' => array() );
  
          return self::generateOutput(
              array( 'id' => array( $tagsToSuggest ) ),
              $http->postVariable( 'subtree_limit', 0 ),
              false,
              $http->postVariable( 'locale', '' )
          );
      }
code_tokens: static public function suggest ( $ args ) { $ http = eZHTTPTool :: instance ( ) ; $ searchEngine = eZINI :: instance ( ) -> variable ( 'SearchSettings' , 'SearchEngine' ) ; if ( ! class_exists ( 'eZSolr' ) || $ searchEngine != 'ezsolr' ) return array ( 'status' => 'success' , 'message' => '' , 'tags' => array ( ) ) ; $ tagIDs = $ http -> postVariable ( 'tag_ids' , '' ) ; if ( empty ( $ tagIDs ) ) return array ( 'status' => 'success' , 'message' => '' , 'tags' => array ( ) ) ; if ( is_array ( $ tagIDs ) ) { $ tagIDs = implode ( '|#' , $ tagIDs ) ; } $ tagIDs = array_values ( array_unique ( explode ( '|#' , $ tagIDs ) ) ) ; $ solrSearch = new eZSolr ( ) ; $ params = array ( 'SearchOffset' => 0 , 'SearchLimit' => 0 , 'Facet' => array ( array ( 'field' => 'ezf_df_tag_ids' , 'limit' => 5 + count ( $ tagIDs ) , 'mincount' => 1 ) ) , 'Filter' => array ( 'ezf_df_tag_ids' => implode ( ' OR ' , $ tagIDs ) ) , 'QueryHandler' => 'ezpublish' , 'AsObjects' => false ) ; $ searchResult = $ solrSearch -> search ( '' , $ params ) ; if ( ! isset ( $ searchResult [ 'SearchExtras' ] ) || ! $ searchResult [ 'SearchExtras' ] instanceof ezfSearchResultInfo ) { eZDebug :: writeWarning ( 'There was an error fetching tag suggestions from Solr. Maybe server is not running or using unpatched schema?' , __METHOD__ ) ; return array ( 'status' => 'success' , 'message' => '' , 'tags' => array ( ) ) ; } $ facetResult = $ searchResult [ 'SearchExtras' ] -> attribute ( 'facet_fields' ) ; if ( ! is_array ( $ facetResult ) || ! is_array ( $ facetResult [ 0 ] [ 'nameList' ] ) ) { eZDebug :: writeWarning ( 'There was an error fetching tag suggestions from Solr. Maybe server is not running or using unpatched schema?' , __METHOD__ ) ; return array ( 'status' => 'success' , 'message' => '' , 'tags' => array ( ) ) ; } $ facetResult = array_values ( $ facetResult [ 0 ] [ 'nameList' ] ) ; $ tagsToSuggest = array ( ) ; foreach ( $ facetResult as $ result ) { if ( ! in_array ( $ result , $ tagIDs ) ) $ tagsToSuggest [ ] = $ result ; } if ( empty ( $ tagsToSuggest ) ) return array ( 'status' => 'success' , 'message' => '' , 'tags' => array ( ) ) ; return self :: generateOutput ( array ( 'id' => array ( $ tagsToSuggest ) ) , $ http -> postVariable ( 'subtree_limit' , 0 ) , false , $ http -> postVariable ( 'locale' , '' ) ) ; }
docstring: Provides suggestion results when adding tags to object
  
  @static
  
  @param array $args
  
  @return array
docstring_tokens: Provides suggestion results when adding tags to object