MediaWiki
REL1_24
|
00001 <?php 00027 class SearchResultSet { 00035 function termMatches() { 00036 return array(); 00037 } 00038 00039 function numRows() { 00040 return 0; 00041 } 00042 00053 function getTotalHits() { 00054 return null; 00055 } 00056 00063 function hasSuggestion() { 00064 return false; 00065 } 00066 00070 function getSuggestionQuery() { 00071 return null; 00072 } 00073 00077 function getSuggestionSnippet() { 00078 return ''; 00079 } 00080 00086 function getInterwikiResults() { 00087 return null; 00088 } 00089 00095 function hasInterwikiResults() { 00096 return $this->getInterwikiResults() != null; 00097 } 00098 00105 function next() { 00106 return false; 00107 } 00108 00112 function free() { 00113 // ... 00114 } 00115 00122 public function searchContainedSyntax() { 00123 return false; 00124 } 00125 } 00126 00131 class SqlSearchResultSet extends SearchResultSet { 00132 protected $resultSet; 00133 protected $terms; 00134 protected $totalHits; 00135 00136 function __construct( $resultSet, $terms, $total = null ) { 00137 $this->resultSet = $resultSet; 00138 $this->terms = $terms; 00139 $this->totalHits = $total; 00140 } 00141 00142 function termMatches() { 00143 return $this->terms; 00144 } 00145 00146 function numRows() { 00147 if ( $this->resultSet === false ) { 00148 return false; 00149 } 00150 00151 return $this->resultSet->numRows(); 00152 } 00153 00154 function next() { 00155 if ( $this->resultSet === false ) { 00156 return false; 00157 } 00158 00159 $row = $this->resultSet->fetchObject(); 00160 if ( $row === false ) { 00161 return false; 00162 } 00163 00164 return SearchResult::newFromTitle( 00165 Title::makeTitle( $row->page_namespace, $row->page_title ) 00166 ); 00167 } 00168 00169 function free() { 00170 if ( $this->resultSet === false ) { 00171 return false; 00172 } 00173 00174 $this->resultSet->free(); 00175 } 00176 00177 function getTotalHits() { 00178 if ( !is_null( $this->totalHits ) ) { 00179 return $this->totalHits; 00180 } else { 00181 // Special:Search expects a number here. 00182 return $this->numRows(); 00183 } 00184 } 00185 } 00186 00190 class SearchNearMatchResultSet extends SearchResultSet { 00191 private $fetched = false; 00192 00196 public function __construct( $match ) { 00197 $this->result = $match; 00198 } 00199 00200 public function numRows() { 00201 return $this->result ? 1 : 0; 00202 } 00203 00204 public function next() { 00205 if ( $this->fetched || !$this->result ) { 00206 return false; 00207 } 00208 $this->fetched = true; 00209 return SearchResult::newFromTitle( $this->result ); 00210 } 00211 }