mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-01 13:48:37 +02:00
BUGFIX Fixed searching on sapphire/trunk due to Form changes - FormAction was useless on SearchForm anyway
MINOR Removed unused code from SearchForm, commented out junk etc git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@65616 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
91c0ca0755
commit
917fcbff66
@ -11,35 +11,29 @@ class SearchForm extends Form {
|
|||||||
|
|
||||||
protected $showInSearchTurnOn;
|
protected $showInSearchTurnOn;
|
||||||
|
|
||||||
/**
|
|
||||||
* the constructor of a Simple/basic SearchForm
|
|
||||||
*/
|
|
||||||
function __construct($controller, $name, $fields = null, $actions = null, $showInSearchTurnOn = true) {
|
function __construct($controller, $name, $fields = null, $actions = null, $showInSearchTurnOn = true) {
|
||||||
$this->showInSearchTurnOn = $showInSearchTurnOn;
|
$this->showInSearchTurnOn = $showInSearchTurnOn;
|
||||||
|
|
||||||
if(!$fields) {
|
if(!$fields) {
|
||||||
$fields = new FieldSet(new TextField("Search", _t('SearchForm.SEARCH', 'Search')));
|
$fields = new FieldSet(
|
||||||
|
new TextField('Search', _t('SearchForm.SEARCH', 'Search')
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$actions) {
|
if(!$actions) {
|
||||||
$actions = new FieldSet(
|
$actions = new FieldSet(
|
||||||
new FormAction("getResults", _t('SearchForm.GO', 'Go'))
|
new FormAction("getResults", _t('SearchForm.GO', 'Go'))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO:: This is a iiccky yucky hack. controller link isnt avaliable here for some wierd reason
|
|
||||||
//if(($controllerlink = $controller->RelativeLink())== "/") $controllerLink = 'home';
|
|
||||||
|
|
||||||
// We need this because it's a get form. It can't go in the action value
|
// We need this because it's a get form. It can't go in the action value
|
||||||
// Hayden: Sorry if I've got it mixed up, but on the results or not found pages, the
|
// Hayden: Sorry if I've got it mixed up, but on the results or not found pages, the
|
||||||
// RelativeLink seems to be empty and it packs a sad
|
// RelativeLink seems to be empty and it packs a sad
|
||||||
$formController = isset($_GET['formController']) ? $_GET['formController'] : null;
|
$formController = isset($_GET['formController']) ? $_GET['formController'] : null;
|
||||||
if( !$formController ) {
|
if(!$formController) $formController = $controller->RelativeLink();
|
||||||
$formController = $controller->RelativeLink();
|
|
||||||
}
|
|
||||||
|
|
||||||
$fields->push(new HiddenField("formController", null, $formController));
|
$fields->push(new HiddenField('formController', null, $formController));
|
||||||
// $fields->push(new HiddenField("formController", null, $controller->RelativeLink()));
|
$fields->push(new HiddenField('executeForm', null, $name));
|
||||||
$fields->push(new HiddenField("executeForm", null, $name));
|
|
||||||
|
|
||||||
parent::__construct($controller, $name, $fields, $actions);
|
parent::__construct($controller, $name, $fields, $actions);
|
||||||
|
|
||||||
@ -50,21 +44,11 @@ class SearchForm extends Form {
|
|||||||
return "get";
|
return "get";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the attributes of the form tag - used by the templates
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function FormAction() {
|
|
||||||
$link = $this->controller->Link();
|
|
||||||
|
|
||||||
if( $link{strlen($link)-1} != "/" )
|
|
||||||
$link .= '/';
|
|
||||||
|
|
||||||
return $link . 'results';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function forTemplate(){
|
public function forTemplate(){
|
||||||
return $this->renderWith(array("SearchForm","Form"));
|
return $this->renderWith(array(
|
||||||
|
'SearchForm',
|
||||||
|
'Form'
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,8 +80,6 @@ class SearchForm extends Form {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function addStarsToKeywords($keywords) {
|
function addStarsToKeywords($keywords) {
|
||||||
if(!trim($keywords)) return "";
|
if(!trim($keywords)) return "";
|
||||||
// Add * to each keyword
|
// Add * to each keyword
|
||||||
@ -170,12 +152,8 @@ class SearchForm extends Form {
|
|||||||
$fullQuery = $queryContent->sql() . " UNION " . $queryFiles->sql() . " ORDER BY $sortBy LIMIT $limit";
|
$fullQuery = $queryContent->sql() . " UNION " . $queryFiles->sql() . " ORDER BY $sortBy LIMIT $limit";
|
||||||
$totalCount = $queryContent->unlimitedRowCount() + $queryFiles->unlimitedRowCount();
|
$totalCount = $queryContent->unlimitedRowCount() + $queryFiles->unlimitedRowCount();
|
||||||
|
|
||||||
// die($fullQuery);
|
|
||||||
// Debug::show($fullQuery);
|
|
||||||
|
|
||||||
$records = DB::query($fullQuery);
|
$records = DB::query($fullQuery);
|
||||||
|
|
||||||
|
|
||||||
foreach($records as $record)
|
foreach($records as $record)
|
||||||
$objects[] = new $record['ClassName']($record);
|
$objects[] = new $record['ClassName']($record);
|
||||||
|
|
||||||
@ -184,20 +162,8 @@ class SearchForm extends Form {
|
|||||||
|
|
||||||
$doSet->setPageLimits($start, $numPerPage, $totalCount);
|
$doSet->setPageLimits($start, $numPerPage, $totalCount);
|
||||||
return $doSet;
|
return $doSet;
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
$keywords = preg_replace_callback('/("[^"]+")(\040or\040)("[^"]+")/', $orProcessor, $keywords);
|
|
||||||
$keywords = preg_replace_callback('/([^ ]+)(\040or\040)([^ ]+)/', $orProcessor, $keywords);
|
|
||||||
|
|
||||||
$limit = (int)$_GET['start'] . ", " . $numPerPage;
|
|
||||||
|
|
||||||
$ret = DataObject::get("SiteTree", "MATCH (Title, MenuTitle, Content, MetaTitle, MetaDescription, MetaKeywords) "
|
|
||||||
."AGAINST ('$keywords' IN BOOLEAN MODE) AND `ShowInSearch` = 1","Title","", $limit);
|
|
||||||
|
|
||||||
return $ret;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSearchQuery() {
|
public function getSearchQuery() {
|
||||||
return Convert::raw2xml($_REQUEST['Search']);
|
return Convert::raw2xml($_REQUEST['Search']);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user