Exemplo n.º 1
0
 /**
  * Support function to display spelling suggestions.
  *
  * @param string                          $msg     HTML to display at the top of
  * the spelling section.
  * @param \VuFind\Search\Base\Results     $results Results object
  * @param \Zend\View\Renderer\PhpRenderer $view    View renderer object
  *
  * @return string
  */
 public function renderSpellingSuggestions($msg, $results, $view)
 {
     $spellingSuggestions = $results->getSpellingSuggestions();
     if (empty($spellingSuggestions)) {
         return '';
     }
     $html = '<div class="' . $this->getContainerClass() . '">';
     $html .= $msg;
     foreach ($spellingSuggestions as $term => $details) {
         $html .= '<br/>' . $view->escapeHtml($term) . ' &raquo; ';
         $i = 0;
         foreach ($details['suggestions'] as $word => $data) {
             if ($i++ > 0) {
                 $html .= ', ';
             }
             $html .= '<a href="' . $results->getUrlQuery()->replaceTerm($term, $data['new_term']) . '">' . $view->escapeHtml($word) . '</a>';
             if (isset($data['expand_term']) && !empty($data['expand_term'])) {
                 $url = $results->getUrlQuery()->replaceTerm($term, $data['expand_term']);
                 $html .= $this->renderExpandLink($url, $view);
             }
         }
     }
     $html .= '</div>';
     return $html;
 }