Permalink
Browse files

FIX: Rename search locale variable to avoid conflicts with locale swi…

  • Loading branch information...
1 parent d766af5 commit 7c68414fe75138dfd2e427d872faa65a9d5e60c6 @wilr wilr committed May 11, 2013
Showing with 20 additions and 7 deletions.
  1. +20 −7 code/search/SearchForm.php
View
27 code/search/SearchForm.php
@@ -43,7 +43,7 @@ public function __construct($controller, $name, $fields = null, $actions = null)
}
if(class_exists('Translatable') && singleton('SiteTree')->hasExtension('Translatable')) {
- $fields->push(new HiddenField('locale', 'locale', Translatable::get_current_locale()));
+ $fields->push(new HiddenField('searchlocale', 'searchlocale', Translatable::get_current_locale()));
}
if(!$actions) {
@@ -101,11 +101,18 @@ public function getResults($pageLength = null, $data = null){
if(!isset($data) || !is_array($data)) $data = $_REQUEST;
// set language (if present)
- if(class_exists('Translatable') && singleton('SiteTree')->hasExtension('Translatable') && isset($data['locale'])) {
- $origLocale = Translatable::get_current_locale();
- Translatable::set_current_locale($data['locale']);
+ if(class_exists('Translatable')) {
+ if(singleton('SiteTree')->hasExtension('Translatable') && isset($data['searchlocale'])) {
+ if($data['searchlocale'] == "ALL") {
+ Translatable::disable_locale_filter();
+ } else {
+ $origLocale = Translatable::get_current_locale();
+
+ Translatable::set_current_locale($data['searchlocale']);
+ }
+ }
}
-
+
$keywords = $data['Search'];
$andProcessor = create_function('$matches','
@@ -137,8 +144,14 @@ public function getResults($pageLength = null, $data = null){
}
// reset locale
- if(class_exists('Translatable') && singleton('SiteTree')->hasExtension('Translatable') && isset($data['locale'])) {
- Translatable::set_current_locale($origLocale);
+ if(class_exists('Translatable')) {
+ if(singleton('SiteTree')->hasExtension('Translatable') && isset($data['searchlocale'])) {
+ if($data['searchlocale'] == "ALL") {
+ Translatable::enable_locale_filter();
+ } else {
+ Translatable::set_current_locale($origLocale);
+ }
+ }
}
return $results;

0 comments on commit 7c68414

Please sign in to comment.