mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX fixing the build, making the code happier
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@78497 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
d064eeb36b
commit
bfaa938897
@ -720,12 +720,10 @@ class MySQLDatabase extends Database {
|
||||
*
|
||||
* @param string $keywords Keywords as a string.
|
||||
*/
|
||||
public function searchEngine($keywords, $pageLength = null, $sortBy = "Relevance DESC", $extraFilter = "", $booleanSearch = false, $alternativeFileFilter = "", $invertedMatch = false) {
|
||||
if(!$pageLength) $pageLength = $this->pageLength;
|
||||
public function searchEngine($classesToSearch, $keywords, $start, $pageLength, $sortBy = "Relevance DESC", $extraFilter = "", $booleanSearch = false, $alternativeFileFilter = "", $invertedMatch = false) {
|
||||
$fileFilter = '';
|
||||
$keywords = Convert::raw2sql($keywords);
|
||||
$htmlEntityKeywords = htmlentities($keywords);
|
||||
$classesToSearch = explode(',', SearchForm::$classesToSearch);
|
||||
|
||||
$extraFilters = array('SiteTree' => '', 'File' => '');
|
||||
|
||||
@ -741,7 +739,6 @@ class MySQLDatabase extends Database {
|
||||
// Always ensure that only pages with ShowInSearch = 1 can be searched
|
||||
$extraFilters['SiteTree'] .= " AND ShowInSearch <> 0";
|
||||
|
||||
$start = isset($_GET['start']) ? (int)$_GET['start'] : 0;
|
||||
$limit = $start . ", " . (int) $pageLength;
|
||||
|
||||
$notMatch = $invertedMatch ? "NOT " : "";
|
||||
|
@ -23,7 +23,9 @@ class SearchForm extends Form {
|
||||
/**
|
||||
* Classes to search
|
||||
*/
|
||||
static public $classesToSearch = "SiteTree,File";
|
||||
protected $classesToSearch = array(
|
||||
"SiteTree", "File"
|
||||
);
|
||||
|
||||
/**
|
||||
*
|
||||
@ -111,10 +113,13 @@ class SearchForm extends Form {
|
||||
|
||||
$keywords = $this->addStarsToKeywords($keywords);
|
||||
|
||||
if(!$pageLength) $pageLength = $this->pageLength;
|
||||
$start = isset($_GET['start']) ? (int)$_GET['start'] : 0;
|
||||
|
||||
if(strpos($keywords, '"') !== false || strpos($keywords, '+') !== false || strpos($keywords, '-') !== false || strpos($keywords, '*') !== false) {
|
||||
$results = DB::GetConn()->searchEngine($keywords, $pageLength, "Relevance DESC", "", true);
|
||||
$results = DB::GetConn()->searchEngine($this->classesToSearch, $keywords, $start, $pageLength, "Relevance DESC", "", true);
|
||||
} else {
|
||||
$results = DB::GetConn()->searchEngine($keywords, $pageLength);
|
||||
$results = DB::GetConn()->searchEngine($this->classesToSearch, $keywords, $start, $pageLength);
|
||||
}
|
||||
|
||||
// filter by permission
|
||||
@ -126,7 +131,7 @@ class SearchForm extends Form {
|
||||
if(singleton('SiteTree')->hasExtension('Translatable') && isset($data['locale'])) {
|
||||
Translatable::set_current_locale($origLocale);
|
||||
}
|
||||
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user