Search/AbstractSearch.php
protected function recomposePattern(array $terms, array $supportedTerms, $domain = NULL)
    {
        $recomposed = '';
        
        if ($domain !== NULL)
        {
            $recomposed .= '@'.$domain.' ';
        }
        
        foreach ($supportedTerms as $term) {
            if (array_key_exists($term, $terms) && $term !== '_default') {
                $recomposed .= ' '.$term.':';
                $recomposed .= (mb_stristr(' ', $terms[$term]) === FALSE) ?  $terms[$term] : '('.$terms[$term].')';
            }
        }
        
        if ($terms['_default'] !== '') {
            $recomposed .= ' '.$terms['_default'];
        }
        
        //strip first character if empty
        if (mb_strcut($recomposed, 0, 1) === ' '){
            $recomposed = mb_strcut($recomposed, 1);
        }
        
        return $recomposed;
    }
protected function recomposePattern(array $terms, array $supportedTerms, $domain = NULL)
    {
        $recomposed = '';
        
        if ($domain !== NULL)
        {
            $recomposed .= '@'.$domain.' ';
        }
        
        foreach ($supportedTerms as $term) {
            if (array_key_exists($term, $terms) && $term !== '_default') {
                $recomposed .= ' '.$term.':';
                $recomposed .= (mb_stristr(' ', $terms[$term]) === FALSE) ?  $terms[$term] : '('.$terms[$term].')';
            }
        }
        
        if ($terms['_default'] !== '') {
            $recomposed .= ' '.$terms['_default'];
        }
        
        //strip first character if empty
        if (mb_strcut($recomposed, 0, 1) === ' '){
            $recomposed = mb_strcut($recomposed, 1);
        }
        
        return $recomposed;
    }
protected function recomposePattern ( array $ terms , array $ supportedTerms , $ domain = NULL ) { $ recomposed = '' ; if ( $ domain !== NULL ) { $ recomposed .= '@' . $ domain . ' ' ; } foreach ( $ supportedTerms as $ term ) { if ( array_key_exists ( $ term , $ terms ) && $ term !== '_default' ) { $ recomposed .= ' ' . $ term . ':' ; $ recomposed .= ( mb_stristr ( ' ' , $ terms [ $ term ] ) === FALSE ) ? $ terms [ $ term ] : '(' . $ terms [ $ term ] . ')' ; } } if ( $ terms [ '_default' ] !== '' ) { $ recomposed .= ' ' . $ terms [ '_default' ] ; } //strip first character if empty if ( mb_strcut ( $ recomposed , 0 , 1 ) === ' ' ) { $ recomposed = mb_strcut ( $ recomposed , 1 ) ; } return $ recomposed ; }
recompose a pattern, retaining only supported terms

the outputted string should be used to show users their search

@param array $terms
@param array $supportedTerms
@param string $domain if your domain is NULL, you should set NULL. You should set used domain instead
@return string
recompose a pattern retaining only supported terms