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:
Tom Rix 2009-06-05 04:37:45 +00:00
parent d064eeb36b
commit bfaa938897
2 changed files with 10 additions and 8 deletions

View File

@ -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 " : "";

View File

@ -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