示例#1
0
 public function ShowResults()
 {
     global $langmessage;
     if (!count($this->results)) {
         echo '<p>';
         echo \gp\tool\Output::GetAddonText($langmessage['search_no_results']);
         echo '</p>';
         return;
     }
     $this->RemoveDups();
     usort($this->results, array($this, 'sort'));
     $total = count($this->results);
     $len = 20;
     $total_pages = ceil($total / $len);
     $current_page = self::ReqPage('pg', $total_pages);
     $start = $current_page * $len;
     $end = min($start + $len, $total);
     $this->results = array_slice($this->results, $start, $len, true);
     echo '<p class="search_nav search_nav_top">';
     echo sprintf($langmessage['SHOWING'], $start + 1, $end, $total);
     echo '</p>';
     echo '<div class="result_list">';
     foreach ($this->results as $result) {
         echo '<div><h4>';
         echo isset($result['link']) ? $result['link'] : \gp\tool::Link($result['slug'], $result['label'], $result['query']);
         echo '</h4>';
         echo $result['content'];
         if ($this->show_stats) {
             echo ' <span class="match_stats">';
             echo $result['matches'] . ' match(es) out of ' . $result['words'] . ' words ';
             echo ' </span>';
         }
         echo '</div>';
     }
     echo '</div>';
     $attr = '';
     if ($this->gpabox) {
         $attr = 'data-cmd="gpabox"';
     }
     $query = 'q=' . rawurlencode($_REQUEST['q']);
     self::PaginationLinks($current_page, $total_pages, 'special_gpsearch', $query, 'pg', $attr);
 }