$resultList->addResult($result);
}
+ // sort list and reduce results
+ $resultList->sort();
+ $resultList->reduceResultsTo($maxResultsPerProvider);
+
$data[] = $resultList;
$totalResultCount += count($resultList);
}
$this->rewind();
}
+ /**
+ * Reduces the result collection to specified size.
+ *
+ * @param integer $size
+ */
+ public function reduceResultsTo($size) {
+ $count = count($this->results);
+
+ if ($size && ($count > $size)) {
+ $reduceBy = $count - $size;
+ $this->reduceResults($reduceBy);
+ }
+ }
+
/**
* Sorts results by title.
*/
* Returns a list of seach results for given query.
*
* @param string $query
- * @param integer $limit
* @return array<wcf\system\search\acp\ACPSearchResult>
*/
- public function search($query, $limit = 5);
+ public function search($query);
}
<?php
namespace wcf\system\search\acp;
-use wcf\data\acp\menu\item\ACPMenuItem;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\package\PackageDependencyHandler;
use wcf\system\request\LinkHandler;
/**
* @see wcf\system\search\acp\IACPSearchResultProvider::search()
*/
- public function search($query, $limit = 5) {
+ public function search($query) {
$results = array();
// search by language item
$statement = WCF::getDB()->prepareStatement($sql); // don't use a limit here
$statement->execute($conditions->getParameters());
- $count = 0;
- while ($row = $statement->fetchArray()) {
- if ($count == $limit) {
- break;
- }
-
- $menuItem = new ACPMenuItem(null, $row);
+ while ($menuItem = $statement->fetchObject('wcf\data\acp\menu\item\ACPMenuItem')) {
if (!$this->validate($menuItem)) {
continue;
}
- $results[] = new ACPSearchResult($languageItems[$row['menuItem']], $row['menuItemLink'] . SID_ARG_1ST);
- $count++;
+ $results[] = new ACPSearchResult($languageItems[$menuItem->menuItem], $menuItem->getLink());
}
return $results;
<?php
namespace wcf\system\search\acp;
-use wcf\data\option\Option;
-use wcf\data\option\category\OptionCategoryList;
use wcf\system\database\util\PreparedStatementConditionBuilder;
-use wcf\system\exception\SystemException;
use wcf\system\package\PackageDependencyHandler;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
/**
* @see wcf\system\search\acp\IACPSearchResultProvider::search()
*/
- public function search($query, $limit = 5) {
+ public function search($query) {
$results = array();
// search by language item
FROM wcf".WCF_N."_language_item
".$conditions."
ORDER BY languageItemValue ASC";
- $statement = WCF::getDB()->prepareStatement($sql, $limit);
+ $statement = WCF::getDB()->prepareStatement($sql); // don't use a limit here
$statement->execute($conditions->getParameters());
$languageItems = array();
$optionNames = array();
$sql = "SELECT optionName, categoryName, options, permissions
FROM wcf".WCF_N."_option
".$conditions;
- $statement = WCF::getDB()->prepareStatement($sql);
+ $statement = WCF::getDB()->prepareStatement($sql); // don't use a limit here
$statement->execute($conditions->getParameters());
- while ($row = $statement->fetchArray()) {
+ while ($option = $statement->fetchObject('wcf\data\option\Option')) {
// category is not accessible
- if (!$this->isValid($row['categoryName'])) {
+ if (!$this->isValid($option->categoryName)) {
continue;
}
// option is not accessible
- $option = new Option(null, $row);
if (!$this->validate($option)) {
continue;
}
- $link = LinkHandler::getInstance()->getLink('Option', array('id' => $this->getCategoryID($row['categoryName'])), 'optionName='.$row['optionName'].'#'.$this->getCategoryName($row['categoryName']));
- $results[] = new ACPSearchResult($languageItems[$row['optionName']], $link);
+ $link = LinkHandler::getInstance()->getLink('Option', array('id' => $this->getCategoryID($option->categoryName)), 'optionName='.$option->optionName.'#'.$this->getCategoryName($option->categoryName));
+ $results[] = new ACPSearchResult($languageItems[$option->optionName], $link);
}
return $results;
<?php
namespace wcf\system\search\acp;
-use wcf\data\user\group\option\UserGroupOption;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\package\PackageDependencyHandler;
use wcf\system\request\LinkHandler;
/**
* @see wcf\system\search\acp\IACPSearchResultProvider::search()
*/
- public function search($query, $limit = 5) {
+ public function search($query) {
$results = array();
// search by language item
$statement = WCF::getDB()->prepareStatement($sql); // don't use a limit here
$statement->execute($conditions->getParameters());
- $count = 0;
- while ($row = $statement->fetchArray()) {
- if ($count == $limit) {
- break;
- }
-
+ while ($userGroupOption = $statement->fetchObject('wcf\data\user\group\option\UserGroupOption')) {
// category is not accessible
- if (!$this->isValid($row['categoryName'])) {
+ if (!$this->isValid($userGroupOption->categoryName)) {
continue;
}
// option is not accessible
- $userGroupOption = new UserGroupOption(null, $row);
if (!$this->validate($userGroupOption)) {
continue;
}
- $link = LinkHandler::getInstance()->getLink('UserGroupOption', array('id' => $row['optionID']));
- $results[] = new ACPSearchResult($languageItems[$row['optionName']], $link);
- $count++;
+ $link = LinkHandler::getInstance()->getLink('UserGroupOption', array('id' => $userGroupOption->optionID));
+ $results[] = new ACPSearchResult($languageItems[$userGroupOption->optionName], $link);
}
return $results;