public function showResults($results, $pageNum = 0, $currentTable = false)
 {
     $startTime = DataManager::getDebugTime();
     $results = $this->sliceResultsForPage($results, $pageNum);
     $r = '';
     foreach ($results as $result) {
         if ($currentTable === false || $result->tableName != $currentTable) {
             //Start of a new section in results
             if ($currentTable !== false) {
                 //Close the previous section
                 $r .= html_writer::end_tag('ul');
             }
             //Section header in results
             $sectionDetails = $this->tableName($result->tableName);
             $r .= html_writer::tag('h3', $sectionDetails['icon'] . ' ' . $sectionDetails['title'], array('id' => 'searchresults-' . $result->tableName));
             //Show results from this table
             $r .= html_writer::start_tag('ul', array('class' => 'results'));
             $currentTable = $result->tableName;
         }
         $r .= $this->showResult($result->tableName, $result, $sectionDetails['icon']);
     }
     $r .= html_writer::end_tag('ul');
     $this->displayTime = DataManager::debugTimeTaken($startTime);
     return $r;
 }
예제 #2
0
 /**
  * Go through the array of results and remove those the user doesn't have permission to see
  */
 public function filterResults($removeHiddenResults = true)
 {
     //Site admin can see everything so don't bother filtering
     if (is_siteadmin()) {
         return;
     }
     $this->results['filtered'] = time();
     $startTime = DataManager::getDebugTime();
     //Check if each result is visible
     foreach ($this->results['results'] as $i => &$result) {
         $visible = $result->isVisible();
         if ($visible === null) {
             //null means it should never be displayed
             unset($this->results['results'][$i]);
         } elseif ($visible !== true) {
             if ($removeHiddenResults) {
                 unset($this->results['results'][$i]);
             } else {
                 $result->hiddenReason = $visible;
                 $result->hidden = true;
             }
         }
     }
     //Unset hanging references
     unset($result);
     $this->addTableInfoToResults($this->results);
     if (!$removeHiddenResults) {
         // Hidden results are included, but we want them to go to the bottom
         // Sort the results by 'tableName' then by 'hidden'
         $this->results['results'] = Utils::sortMultidimensionalArray($this->results['results'], "tableName ASC, hidden ASC");
     }
     $this->results['filterTime'] = DataManager::debugTimeTaken($startTime);
 }