Completed
Push — dev2 ( cc8d6e...f0efe9 )
by Gordon
03:05
created
src/SilverStripe/Elastica/FindElasticaSearchPageExtension.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 		$searchPage = $this->getSearchPage($identifier);
14 14
 
15
-		if ($searchPage) {
15
+		if($searchPage) {
16 16
 			$result = $searchPage->AbsoluteLink();
17 17
 		}
18 18
 		return $result;
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
 		$searchPage = $this->getSearchPage($identifier);
26 26
 
27
-		if ($searchPage) {
27
+		if($searchPage) {
28 28
 			$result = $searchPage->SearchForm($buttonTextOverride);
29 29
 		}
30 30
 		return $result;
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
 
34 34
 	public function getSearchPage($identifier) {
35
-		if (!isset($this->_CachedLastEdited)) {
35
+		if(!isset($this->_CachedLastEdited)) {
36 36
 			$this->_CachedLastEdited = ElasticSearchPage::get()->max('LastEdited');
37 37
 		}
38 38
 		$ck = $this->_CachedLastEdited;
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 
43 43
 		$cache = SS_Cache::factory('searchpagecache');
44 44
 		$searchPage = null;
45
-		$cachekeyname = 'searchpageuri'.$identifier.$this->owner->Locale.$ck;
45
+		$cachekeyname = 'searchpageuri' . $identifier . $this->owner->Locale . $ck;
46 46
 
47 47
 		if(!($searchPage = unserialize($cache->load($cachekeyname)))) {
48
-			$searchPage = ElasticSearchPage::get()->filter('Identifier',$identifier)->first();
48
+			$searchPage = ElasticSearchPage::get()->filter('Identifier', $identifier)->first();
49 49
 			$cache->save(serialize($searchPage), $cachekeyname);
50 50
 		}
51 51
 		return $searchPage;
Please login to merge, or discard this patch.
src/SilverStripe/Elastica/ReindexTask.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
 	*/
28 28
 
29 29
 	public function run($request) {
30
-		$message = function ($content) {
30
+		$message = function($content) {
31 31
 			print(\Director::is_cli() ? "$content\n" : "<p>$content</p>");
32 32
 		};
33 33
 
34 34
 		$locales = array();
35 35
 		if(class_exists('Translatable') && singleton('SiteTree')->hasExtension('Translatable')) {
36
-			foreach (\Translatable::get_existing_content_languages('SiteTree') as $code => $val) {
36
+			foreach(\Translatable::get_existing_content_languages('SiteTree') as $code => $val) {
37 37
 				array_push($locales, $code);
38 38
 			}
39 39
 		} else {
@@ -41,11 +41,11 @@  discard block
 block discarded – undo
41 41
 		}
42 42
 
43 43
 		// now iterate all the locales indexing each locale in turn using it's owner index settings
44
-		foreach ($locales as $locale) {
44
+		foreach($locales as $locale) {
45 45
 			Searchable::$index_ctr = 0;
46
-			$message('Indexing locale '.$locale);
46
+			$message('Indexing locale ' . $locale);
47 47
 
48
-			if (class_exists('Translatable')) {
48
+			if(class_exists('Translatable')) {
49 49
 				\Translatable::set_current_locale($locale);
50 50
 			}
51 51
 
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
 			$this->service->refresh();
63 63
 			// display indexing speed stats
64 64
 			$endTime = microtime(true);
65
-			$elapsed = $endTime-$startTime;
65
+			$elapsed = $endTime - $startTime;
66 66
 			$perSecond = Searchable::$index_ctr / $elapsed;
67
-			$info = "\nReindexing $locale completed \n ".Searchable::$index_ctr." docs in ".round($elapsed,2)." seconds ";
68
-			$info .= "at ".round($perSecond,2)." documents per second\n\n";
67
+			$info = "\nReindexing $locale completed \n " . Searchable::$index_ctr . " docs in " . round($elapsed, 2) . " seconds ";
68
+			$info .= "at " . round($perSecond, 2) . " documents per second\n\n";
69 69
 			$message($info);
70 70
 		}
71 71
 
Please login to merge, or discard this patch.
src/SilverStripe/Elastica/SearchIndexTask.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -21,17 +21,17 @@  discard block
 block discarded – undo
21 21
 	}
22 22
 
23 23
 	public function run($request) {
24
-		$message = function ($content) {
24
+		$message = function($content) {
25 25
 			print(\Director::is_cli() ? "$content\n" : "<p>$content</p>");
26 26
 		};
27 27
 
28 28
 		$locales = array();
29 29
 
30
-		if ($this->locale == null) {
31
-			if (class_exists('Translatable') && \SiteTree::has_extension('Translatable')) {
30
+		if($this->locale == null) {
31
+			if(class_exists('Translatable') && \SiteTree::has_extension('Translatable')) {
32 32
 				$this->locale = \Translatable::get_current_locale();
33 33
 			} else {
34
-				foreach (\Translatable::get_existing_content_languages('SiteTree') as $code => $val) {
34
+				foreach(\Translatable::get_existing_content_languages('SiteTree') as $code => $val) {
35 35
 					array_push($locales, $code);
36 36
 				}
37 37
 			}
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 		$es->setPageLength(20);
45 45
 		$es->addFilter('IsInSiteTree', true);
46 46
 		$results = $es->search($query);
47
-		foreach ($results as $result) {
48
-			$title = '['.$result->ClassName.', '.$result->ID.']  ';
47
+		foreach($results as $result) {
48
+			$title = '[' . $result->ClassName . ', ' . $result->ID . ']  ';
49 49
 			$title .= $result->Title;
50 50
 			$message($title);
51
-			if ($result->SearchHighlightsByField->Content) {
52
-				foreach ($result->SearchHighlightsByField->Content as $highlight) {
53
-					$message("- ".$highlight->Snippet);
51
+			if($result->SearchHighlightsByField->Content) {
52
+				foreach($result->SearchHighlightsByField->Content as $highlight) {
53
+					$message("- " . $highlight->Snippet);
54 54
 				}
55 55
 			}
56 56
 
Please login to merge, or discard this patch.
tests/AutocompleteControllerTest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,17 +21,17 @@  discard block
 block discarded – undo
21 21
 
22 22
 		// Delete and assert that it does not exist
23 23
 		echo "Displaying searchable fields\n";
24
-		$sql =  "SELECT ID,Name,ClazzName from SearchableField";
24
+		$sql = "SELECT ID,Name,ClazzName from SearchableField";
25 25
 		$records = DB::query($sql);
26
-		foreach ($records as $record) {
26
+		foreach($records as $record) {
27 27
 			print_r($record);
28 28
 		}
29 29
 
30 30
 		$filter = array('Name' => 'Title', 'ClazzName' => 'FlickrPhotoTO');
31 31
 		$sf = SearchableField::get()->filter($filter)->first();
32 32
 		print_r($sf);
33
-		$sql = "UPDATE ElasticSearchPage_ElasticaSearchableFields SET Searchable=1,".
34
-				"EnableAutocomplete=1 where SearchableFieldID=".$sf->ID;
33
+		$sql = "UPDATE ElasticSearchPage_ElasticaSearchableFields SET Searchable=1," .
34
+				"EnableAutocomplete=1 where SearchableFieldID=" . $sf->ID;
35 35
 		echo $sql;
36 36
 
37 37
 		DB::query($sql);
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
 		$this->assertEquals('the', $result->Query);
58 58
 		$lquery = strtolower($result->Query);
59
-		foreach ($result->suggestions as $suggestion) {
59
+		foreach($result->suggestions as $suggestion) {
60 60
 			$value = $suggestion->value;
61 61
 			$value = strtolower($value);
62 62
 			$this->assertContains($lquery, $value);
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
 		$this->assertEquals('the', $result->Query);
112 112
 		$lquery = strtolower($result->Query);
113
-		foreach ($result->suggestions as $suggestion) {
113
+		foreach($result->suggestions as $suggestion) {
114 114
 			$value = $suggestion->value;
115 115
 			$value = strtolower($value);
116 116
 			$this->assertContains($lquery, $value);
Please login to merge, or discard this patch.
tests/ElasticSearchPageTest.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@  discard block
 block discarded – undo
13 13
 
14 14
 		$fields = $searchPage->getCMSFields();
15 15
 
16
-		$mainTab = $this->checkTabExists($fields,'Main');
16
+		$mainTab = $this->checkTabExists($fields, 'Main');
17 17
 		$this->checkFieldExists($mainTab, 'Identifier');
18 18
 		$this->checkFieldExists($mainTab, 'ContentForEmptySearch');
19 19
 
20
-		$searchTab = $this->checkTabExists($fields,'Search.SearchFor');
21
-		$fieldsTab = $this->checkTabExists($fields,'Search.Fields');
22
-		$autoCompleteTab = $this->checkTabExists($fields,'Search.AutoComplete');
23
-		$aggTab = $this->checkTabExists($fields,'Search.Aggregations');
24
-		$simTab = $this->checkTabExists($fields,'Search.Similarity');
20
+		$searchTab = $this->checkTabExists($fields, 'Search.SearchFor');
21
+		$fieldsTab = $this->checkTabExists($fields, 'Search.Fields');
22
+		$autoCompleteTab = $this->checkTabExists($fields, 'Search.AutoComplete');
23
+		$aggTab = $this->checkTabExists($fields, 'Search.Aggregations');
24
+		$simTab = $this->checkTabExists($fields, 'Search.Similarity');
25 25
 
26 26
 		$this->checkFieldExists($searchTab, 'InfoField');
27 27
 		$this->checkFieldExists($searchTab, 'SiteTreeOnly');
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 		$tab = $fields->findOrMakeTab("Root.Search.Fields");
50 50
 		$fieldsTab = $tab->Fields();
51 51
 
52
-		foreach ($fieldsTab as $field) {
52
+		foreach($fieldsTab as $field) {
53 53
 			echo "FIELD:{$field->getName()}\n";
54 54
 		}
55 55
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		$gridDetailForm = $pickerConfig->getComponentByType('GridFieldDetailForm');
59 59
 
60 60
 		echo "SEARCHABLE FIELDS\n";
61
-		foreach ($searchPage->ElasticaSearchableFields()->getIterator() as $sf) {
61
+		foreach($searchPage->ElasticaSearchableFields()->getIterator() as $sf) {
62 62
 			echo "SEARCHABLE FIELD {$sf->ClazzName},{$sf->Name}!\n";
63 63
 
64 64
 		}
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 		$pageLength = 10; // the default
186 186
 		$searchPageObj->ResultsPerPage = $pageLength;
187 187
 		$searchPageObj->write();
188
-		$searchPageObj->publish('Stage','Live');
188
+		$searchPageObj->publish('Stage', 'Live');
189 189
 
190 190
 		$form = $searchPageObj->SearchForm();
191 191
 		$fields = $form->Fields();
@@ -317,11 +317,11 @@  discard block
 block discarded – undo
317 317
 		$filter = array('ClazzName' => 'FlickrPhotoTO', 'Name' => 'Title');
318 318
 
319 319
 		//Check fieldnames as expected
320
-		$searchableFields = $searchPage->ElasticaSearchableFields()->filter('Active',1);
320
+		$searchableFields = $searchPage->ElasticaSearchableFields()->filter('Active', 1);
321 321
 		$sfs = $searchableFields->map('Name')->toArray();
322 322
 		sort($sfs);
323
-		$expected = array('Aperture','AspectRatio','Description','FirstViewed','FlickrID',
324
-			'FlickrSetTOs','FlickrTagTOs','FocalLength35mm','ISO','Photographer','ShutterSpeed',
323
+		$expected = array('Aperture', 'AspectRatio', 'Description', 'FirstViewed', 'FlickrID',
324
+			'FlickrSetTOs', 'FlickrTagTOs', 'FocalLength35mm', 'ISO', 'Photographer', 'ShutterSpeed',
325 325
 			'TakenAt', 'TakenAtDT', 'TestMethod', 'TestMethodHTML', 'Title');
326 326
 		$this->assertEquals($expected, $sfs);
327 327
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 		$searchPage->Title = '**** SiteTree Search ****';
332 332
 		$searchPage->write();
333 333
 
334
-		$searchableFields = $searchPage->ElasticaSearchableFields()->filter('Active',1);
334
+		$searchableFields = $searchPage->ElasticaSearchableFields()->filter('Active', 1);
335 335
 		$sfs = $searchableFields->map('Name')->toArray();
336 336
 		sort($sfs);
337 337
 		$expected = array('Content', 'Country', 'PageDate', 'Title');
@@ -351,15 +351,15 @@  discard block
 block discarded – undo
351 351
 		// expected mapping of searchable classes to searchable fields that will be
352 352
 		// stored in the database as SearchableClass and SearchableField
353 353
 		$expected = array(
354
-			'Page' => array('Title','Content'),
355
-			'SiteTree' => array('Title','Content'),
356
-			'SearchableTestPage' => array('Title','Content','Country','PageDate'),
354
+			'Page' => array('Title', 'Content'),
355
+			'SiteTree' => array('Title', 'Content'),
356
+			'SearchableTestPage' => array('Title', 'Content', 'Country', 'PageDate'),
357 357
 			'FlickrTagTO' => array('RawValue'),
358
-			'FlickrAuthorTO' => array('PathAlias','DisplayName','FlickrPhotoTOs'),
359
-			'FlickrPhotoTO' => array('Title','FlickrID','Description','TakenAt', 'TakenAtDT', 'Aperture',
360
-				'ShutterSpeed','FocalLength35mm','ISO','Photographer','FlickrTagTOs','FlickrSetTOs',
361
-				'FirstViewed','AspectRatio', 'TestMethod', 'TestMethodHTML'),
362
-			'FlickrSetTO' => array('Title','FlickrID','Description')
358
+			'FlickrAuthorTO' => array('PathAlias', 'DisplayName', 'FlickrPhotoTOs'),
359
+			'FlickrPhotoTO' => array('Title', 'FlickrID', 'Description', 'TakenAt', 'TakenAtDT', 'Aperture',
360
+				'ShutterSpeed', 'FocalLength35mm', 'ISO', 'Photographer', 'FlickrTagTOs', 'FlickrSetTOs',
361
+				'FirstViewed', 'AspectRatio', 'TestMethod', 'TestMethodHTML'),
362
+			'FlickrSetTO' => array('Title', 'FlickrID', 'Description')
363 363
 		);
364 364
 
365 365
 		// check the expected classes
@@ -380,21 +380,21 @@  discard block
 block discarded – undo
380 380
 		// check the names expected to appear
381 381
 
382 382
 		$fieldCtr = 0;
383
-		foreach ($expectedClasses as $expectedClass) {
383
+		foreach($expectedClasses as $expectedClass) {
384 384
 			$expectedFields = array();
385 385
 			$sc = SearchableClass::get()->filter('Name', $expectedClass)->first();
386
-			$this->assertEquals($expectedClass,$sc->Name);
386
+			$this->assertEquals($expectedClass, $sc->Name);
387 387
 
388 388
 			$inSiteTree = 1;
389
-			$start = substr($expectedClass, 0,6);
390
-			if ($start == 'Flickr') {
389
+			$start = substr($expectedClass, 0, 6);
390
+			if($start == 'Flickr') {
391 391
 				$inSiteTree = 0;
392 392
 			};
393
-			$this->assertEquals($inSiteTree,$sc->InSiteTree);
393
+			$this->assertEquals($inSiteTree, $sc->InSiteTree);
394 394
 
395 395
 			$expectedNames = $expected[$expectedClass];
396
-			foreach ($expectedNames as $expectedName) {
397
-				$filter = array('Name' => $expectedName, 'SearchableClassID' => $sc->ID );
396
+			foreach($expectedNames as $expectedName) {
397
+				$filter = array('Name' => $expectedName, 'SearchableClassID' => $sc->ID);
398 398
 				$sf = SearchableField::get()->filter($filter)->first();
399 399
 				$this->assertEquals($expectedName, $sf->Name);
400 400
 				$fieldCtr++;
Please login to merge, or discard this patch.
tests/InheritanceTest.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 		$expected = array('first');
27 27
 		$this->assertEquals($expected, array_keys($terms['Title.standard']['terms']));
28 28
 
29
-		$expected = array('fi','fir','firs','first','ir','irs','irst','rs','rst','st');
29
+		$expected = array('fi', 'fir', 'firs', 'first', 'ir', 'irs', 'irst', 'rs', 'rst', 'st');
30 30
 		$this->assertEquals($expected, array_keys($terms['Title.autocomplete']['terms']));
31 31
 
32 32
 		// ---- now a parental class page ----
@@ -60,20 +60,20 @@  discard block
 block discarded – undo
60 60
 		$terms = $page->getTermVectors();
61 61
 
62 62
 		//Check the expected fields are indexed
63
-		$expected = array('Content','Content.shingles','Content.standard','FatherText','FatherText.shingles','FatherText.standard',
64
-			'GrandFatherText','GrandFatherText.shingles','GrandFatherText.standard','Link','Title','Title.autocomplete',
65
-			'Title.shingles','Title.standard');
63
+		$expected = array('Content', 'Content.shingles', 'Content.standard', 'FatherText', 'FatherText.shingles', 'FatherText.standard',
64
+			'GrandFatherText', 'GrandFatherText.shingles', 'GrandFatherText.standard', 'Link', 'Title', 'Title.autocomplete',
65
+			'Title.shingles', 'Title.standard');
66 66
 		$indexedFields = array_keys($terms);
67 67
 		sort($indexedFields);
68
-		foreach ($indexedFields as $field) {
69
-			echo "'".$field."',";
68
+		foreach($indexedFields as $field) {
69
+			echo "'" . $field . "',";
70 70
 		}
71 71
 		$this->assertEquals($expected, $indexedFields);
72 72
 
73 73
 		$fatherTerms = $terms['FatherText.standard']['terms'];
74 74
 		$grandFatherTerms = $terms['GrandFatherText.standard']['terms'];
75 75
 
76
-		$expected = array('father', 'field', 'grandfather', 'page', 'trace3');;
76
+		$expected = array('father', 'field', 'grandfather', 'page', 'trace3'); ;
77 77
 		$this->assertEquals($expected, array_keys($fatherTerms));
78 78
 
79 79
 		$expected = array('grandfather', 'page', 'trace4');
Please login to merge, or discard this patch.
tests/SearchableFieldTest.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
 		$fields = $sf->getCMSFields();
17 17
 
18
-		$tab = $this->checkTabExists($fields,'Main');
18
+		$tab = $this->checkTabExists($fields, 'Main');
19 19
 
20 20
 		//Check fields
21 21
 		$nf = $this->checkFieldExists($tab, 'Name');
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 		$extraFields = array('Searchable' => 1, 'SimilarSearchable' => 1, 'Active' => 1,
34 34
 			'Weight' => 0);
35 35
 		$esfs = $searchPage->ElasticaSearchableFields();
36
-		foreach ($esfs as $sf) {
37
-			if ($sf->Name == 'Title' || $sf->Name == 'Description') {
36
+		foreach($esfs as $sf) {
37
+			if($sf->Name == 'Title' || $sf->Name == 'Description') {
38 38
 				$esfs->remove($sf);
39 39
 				$esfs->add($sf, $extraFields);
40 40
 			}
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 			$this->fail('Searchable fail should have failed to write');
46 46
 		} catch (ValidationException $e) {
47 47
 			$this->assertInstanceOf('ValidationException', $e);
48
-			$expected = 'The field SearchableTestPage.Title has a zero weight. ; The field '.
48
+			$expected = 'The field SearchableTestPage.Title has a zero weight. ; The field ' .
49 49
 			'SiteTree.Title has a zero weight. ; The field Page.Title has a zero weight. ';
50 50
 			$this->assertEquals($expected, $e->getMessage());
51 51
 		}
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 		$extraFields = array('Searchable' => 1, 'SimilarSearchable' => 1, 'Active' => 1,
65 65
 			'Weight' => -1);
66 66
 		$esfs = $searchPage->ElasticaSearchableFields();
67
-		foreach ($esfs as $sf) {
68
-			if ($sf->Name == 'Title' || $sf->Name == 'Description') {
67
+		foreach($esfs as $sf) {
68
+			if($sf->Name == 'Title' || $sf->Name == 'Description') {
69 69
 				$esfs->remove($sf);
70 70
 				$esfs->add($sf, $extraFields);
71 71
 			}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			$this->fail('Searchable fail should have failed to write');
77 77
 		} catch (ValidationException $e) {
78 78
 			$this->assertInstanceOf('ValidationException', $e);
79
-			$expected = 'The field SearchableTestPage.Title has a negative weight. ; The field '.
79
+			$expected = 'The field SearchableTestPage.Title has a negative weight. ; The field ' .
80 80
 			'SiteTree.Title has a negative weight. ; The field Page.Title has a negative weight. ';
81 81
 			$this->assertEquals($expected, $e->getMessage());
82 82
 		}
Please login to merge, or discard this patch.
searchpage/ElasticSearchPage.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	);
63 63
 
64 64
 	private static $many_many_extraFields = array(
65
-    	'ElasticaSearchableFields' => array(
65
+		'ElasticaSearchableFields' => array(
66 66
 		'Searchable' => 'Boolean', // allows the option of turning off a single field for searching
67 67
 		'SimilarSearchable' => 'Boolean', // allows field to be used in more like this queries.
68 68
 		'Active' => 'Boolean', // preserve previous edits of weighting when classes changed
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
 		$sortedWords = $this->SimilarityStopWords;
105 105
 
106 106
 		$stopwordsField = StringTagField::create(
107
-		    'SimilarityStopWords',
108
-		    'Stop Words for Similar Search',
109
-		    $sortedWords,
110
-		    $sortedWords
107
+			'SimilarityStopWords',
108
+			'Stop Words for Similar Search',
109
+			$sortedWords,
110
+			$sortedWords
111 111
 		);
112 112
 
113 113
 		$stopwordsField->setShouldLazyLoad(true); // tags should be lazy loaded
@@ -190,15 +190,15 @@  discard block
 block discarded – undo
190 190
 		$fields->addFieldToTab('Root.Search.Aggregations', new TextField('SearchHelper',
191 191
 			'ClassName of object to manipulate search details and results.  Leave blank for standard search'));
192 192
 
193
-        $ottos = AutoCompleteOption::get()->Filter('Locale', $this->Locale)->map('ID', 'Name')->
194
-        									toArray();
195
-        $df = DropdownField::create('AutoCompleteFunctionID', 'Autocomplete Function')->
196
-        							setSource($ottos);
197
-        $df->setEmptyString('-- Please select what do do after find as you type has occurred --');
193
+		$ottos = AutoCompleteOption::get()->Filter('Locale', $this->Locale)->map('ID', 'Name')->
194
+											toArray();
195
+		$df = DropdownField::create('AutoCompleteFunctionID', 'Autocomplete Function')->
196
+									setSource($ottos);
197
+		$df->setEmptyString('-- Please select what do do after find as you type has occurred --');
198 198
 
199
-        $ottos = $this->ElasticaSearchableFields()->filter('EnableAutocomplete',1)->Map('ID', 'Name')->toArray();
200
-        $autoCompleteFieldDF = DropDownField::create('AutoCompleteFieldID', 'Field to use for autocomplete')->setSource($ottos);
201
-        $autoCompleteFieldDF->setEmptyString('-- Please select which field to use for autocomplete --');
199
+		$ottos = $this->ElasticaSearchableFields()->filter('EnableAutocomplete',1)->Map('ID', 'Name')->toArray();
200
+		$autoCompleteFieldDF = DropDownField::create('AutoCompleteFieldID', 'Field to use for autocomplete')->setSource($ottos);
201
+		$autoCompleteFieldDF->setEmptyString('-- Please select which field to use for autocomplete --');
202 202
 
203 203
 		$fields->addFieldToTab("Root.Search.AutoComplete",
204 204
 		  		FieldGroup::create(
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		$pickerConfig->removeComponentsByType(new PickerFieldAddExistingSearchButton());
224 224
 		$pickerConfig->getComponentByType('GridFieldPaginator')->setItemsPerPage(100);
225 225
 
226
-        $searchPicker->enableEdit();
226
+		$searchPicker->enableEdit();
227 227
 		$edittest = $pickerConfig->getComponentByType('GridFieldDetailForm');
228 228
 		$edittest->setFields(FieldList::create(
229 229
 			TextField::create('Name', 'Field Name'),
@@ -257,23 +257,23 @@  discard block
 block discarded – undo
257 257
 
258 258
 		// What do display on the grid of searchable fields
259 259
 		$dataColumns = $pickerConfig->getComponentByType('GridFieldDataColumns');
260
-        $dataColumns->setDisplayFields(array(
260
+		$dataColumns->setDisplayFields(array(
261 261
 			'Name' => 'Name',
262
-        	'ClazzName' => 'Class',
262
+			'ClazzName' => 'Class',
263 263
 			'Type' => 'Type',
264 264
 			'Searchable' => 'Use for Search?',
265 265
 			'SimilarSearchable' => 'Use for Similar Search?',
266 266
 			'ShowHighlights' => 'Show Search Highlights',
267 267
 			'Weight' => 'Weighting'
268
-        ));
268
+		));
269 269
 
270 270
 		return $fields;
271 271
 	}
272 272
 
273 273
 
274 274
 	public function getCMSValidator() {
275
-        return new ElasticSearchPage_Validator();
276
-    }
275
+		return new ElasticSearchPage_Validator();
276
+	}
277 277
 
278 278
 
279 279
 	/**
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 		$esfs = $this->ElasticaSearchableFields();
359 359
 
360 360
 		// Remove existing searchable fields for this page from the list of all available
361
-    	$delta = array_keys($esfs->map()->toArray());
361
+		$delta = array_keys($esfs->map()->toArray());
362 362
 		$newSearchableFields = $sfs->exclude('ID', $delta);
363 363
 
364 364
 		if ($newSearchableFields->count() > 0) {
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -118,29 +118,29 @@  discard block
 block discarded – undo
118 118
 			'Default values are those used by Elastica'));
119 119
 		$fields->addFieldToTab("Root.Search.Similarity", $lf);
120 120
 		$fields->addFieldToTab("Root.Search.Similarity", new TextField('MinTermFreq',
121
-			'The minimum term frequency below which the terms will be ignored from the input '.
121
+			'The minimum term frequency below which the terms will be ignored from the input ' .
122 122
 			'document. Defaults to 2.'));
123 123
 		$fields->addFieldToTab("Root.Search.Similarity", new TextField('MaxTermFreq',
124
-			'The maximum number of query terms that will be selected. Increasing this value gives '.
124
+			'The maximum number of query terms that will be selected. Increasing this value gives ' .
125 125
 			'greater accuracy at the expense of query execution speed. Defaults to 25.'));
126 126
 		$fields->addFieldToTab("Root.Search.Similarity", new TextField('MinWordLength',
127 127
 			'The minimum word length below which the terms will be ignored.  Defaults to 0.'));
128 128
 		$fields->addFieldToTab("Root.Search.Similarity", new TextField('MinDocFreq',
129
-			'The minimum document frequency below which the terms will be ignored from the input '.
129
+			'The minimum document frequency below which the terms will be ignored from the input ' .
130 130
 			'document. Defaults to 5.'));
131 131
 		$fields->addFieldToTab("Root.Search.Similarity", new TextField('MaxDocFreq',
132
-			'The maximum document frequency above which the terms will be ignored from the input '.
133
-			'document. This could be useful in order to ignore highly frequent words such as stop '.
132
+			'The maximum document frequency above which the terms will be ignored from the input ' .
133
+			'document. This could be useful in order to ignore highly frequent words such as stop ' .
134 134
 			'words. Defaults to unbounded (0).'));
135 135
 		$fields->addFieldToTab("Root.Search.Similarity", new TextField('MinWordLength',
136
-			'The minimum word length below which the terms will be ignored. The old name min_'.
136
+			'The minimum word length below which the terms will be ignored. The old name min_' .
137 137
 			'word_len is deprecated. Defaults to 0.'));
138 138
 		$fields->addFieldToTab("Root.Search.Similarity", new TextField('MaxWordLength',
139
-			'The maximum word length above which the terms will be ignored. The old name max_word_'.
139
+			'The maximum word length above which the terms will be ignored. The old name max_word_' .
140 140
 			'len is deprecated. Defaults to unbounded (0).'));
141 141
 		$fields->addFieldToTab("Root.Search.Similarity", new TextField('MinShouldMatch',
142
-			'This parameter controls the number of terms that must match. This can be either a '.
143
-			'number or a percentage.  See '.
142
+			'This parameter controls the number of terms that must match. This can be either a ' .
143
+			'number or a percentage.  See ' .
144 144
 			'https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html'));
145 145
 
146 146
 		// ---- search details tab ----
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
 		$classes = array();
159 159
 		$records = DB::query($sql);
160
-		foreach ($records as $record) {
160
+		foreach($records as $record) {
161 161
 			array_push($classes, $record['ClassName']);
162 162
 		}
163 163
 		$list = implode(',', $classes);
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 
178 178
 		$html = '<div class="field text" id="SiteTreeOnlyInfo">';
179 179
 		$html .= "<p>Copy the following into the above field to ensure that all SiteTree classes are searched</p>";
180
-		$html .= '<p class="message">'.$list;
180
+		$html .= '<p class="message">' . $list;
181 181
 		$html .= "</p></div>";
182
-		$infoField = new LiteralField('InfoField',$html);
182
+		$infoField = new LiteralField('InfoField', $html);
183 183
 		$fields->addFieldToTab('Root.Search.SearchFor', $infoField);
184 184
 
185 185
 		$fields->addFieldToTab('Root.Main', new HTMLEditorField('ContentForEmptySearch'));
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         							setSource($ottos);
197 197
         $df->setEmptyString('-- Please select what do do after find as you type has occurred --');
198 198
 
199
-        $ottos = $this->ElasticaSearchableFields()->filter('EnableAutocomplete',1)->Map('ID', 'Name')->toArray();
199
+        $ottos = $this->ElasticaSearchableFields()->filter('EnableAutocomplete', 1)->Map('ID', 'Name')->toArray();
200 200
         $autoCompleteFieldDF = DropDownField::create('AutoCompleteFieldID', 'Field to use for autocomplete')->setSource($ottos);
201 201
         $autoCompleteFieldDF->setEmptyString('-- Please select which field to use for autocomplete --');
202 202
 
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
 		 );
209 209
 
210 210
 		// ---- grid of searchable fields ----
211
-		$html = '<p id="SearchFieldIntro">'._t('SiteConfig.ELASTICA_SEARCH_INFO',
212
-				"Select a field to edit it's properties").'</p>';
213
-		$fields->addFieldToTab('Root.Search.Fields', $h1=new LiteralField('SearchInfo', $html));
211
+		$html = '<p id="SearchFieldIntro">' . _t('SiteConfig.ELASTICA_SEARCH_INFO',
212
+				"Select a field to edit it's properties") . '</p>';
213
+		$fields->addFieldToTab('Root.Search.Fields', $h1 = new LiteralField('SearchInfo', $html));
214 214
 		$searchPicker = new PickerField('ElasticaSearchableFields', 'Searchable Fields',
215 215
 			$this->ElasticaSearchableFields()->filter('Active', 1)->sort('Name'));
216 216
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 			$fields->dataFieldByName('Name')->setReadOnly(true);
247 247
 			$fields->dataFieldByName('Name')->setDisabled(true);
248 248
 
249
-			if (!$fieldAutocomplete->Value() == '1') {
249
+			if(!$fieldAutocomplete->Value() == '1') {
250 250
 				$fieldEnableAutcomplete->setDisabled(true);
251 251
 				$fieldEnableAutcomplete->setReadOnly(true);
252 252
 				$fieldEnableAutcomplete->setTitle("Autcomplete is not available for this field");
@@ -283,49 +283,49 @@  discard block
 block discarded – undo
283 283
 	public function validate() {
284 284
 		$result = parent::validate();
285 285
 		$mode = Versioned::get_reading_mode();
286
-		$suffix =  '';
287
-		if ($mode == 'Stage.Live') {
286
+		$suffix = '';
287
+		if($mode == 'Stage.Live') {
288 288
 			$suffix = '_Live';
289 289
 		}
290 290
 
291
-		if (!$this->Identifier) {
291
+		if(!$this->Identifier) {
292 292
 			$result->error('The identifier cannot be blank');
293 293
 		}
294 294
 
295
-		$where = 'ElasticSearchPage'.$suffix.'.ID != '.$this->ID." AND `Identifier` = '{$this->Identifier}'";
295
+		$where = 'ElasticSearchPage' . $suffix . '.ID != ' . $this->ID . " AND `Identifier` = '{$this->Identifier}'";
296 296
 		$existing = ElasticSearchPage::get()->where($where)->count();
297
-		if ($existing > 0) {
298
-			$result->error('The identifier '.$this->Identifier.' already exists');
297
+		if($existing > 0) {
298
+			$result->error('The identifier ' . $this->Identifier . ' already exists');
299 299
 		}
300 300
 
301 301
 
302
-		error_log('CTS:'.$this->ClassesToSearch);
302
+		error_log('CTS:' . $this->ClassesToSearch);
303 303
 
304 304
 		// now check classes to search actually exist, assuming in site tree not set
305
-		error_log('STO:'.$this->SiteTreeOnly);
306
-		if (!$this->SiteTreeOnly) {
307
-			if ($this->ClassesToSearch == '') {
305
+		error_log('STO:' . $this->SiteTreeOnly);
306
+		if(!$this->SiteTreeOnly) {
307
+			if($this->ClassesToSearch == '') {
308 308
 				$result->error('At least one searchable class must be available, or SiteTreeOnly flag set');
309 309
 			} else {
310 310
 				$toSearch = explode(',', $this->ClassesToSearch);
311
-				foreach ($toSearch as $clazz) {
311
+				foreach($toSearch as $clazz) {
312 312
 					try {
313 313
 						$instance = Injector::inst()->create($clazz);
314
-						if (!$instance->hasExtension('SilverStripe\Elastica\Searchable')) {
315
-							$result->error('The class '.$clazz.' must have the Searchable extension');
314
+						if(!$instance->hasExtension('SilverStripe\Elastica\Searchable')) {
315
+							$result->error('The class ' . $clazz . ' must have the Searchable extension');
316 316
 						}
317 317
 					} catch (ReflectionException $e) {
318
-						$result->error('The class '.$clazz.' does not exist');
318
+						$result->error('The class ' . $clazz . ' does not exist');
319 319
 					}
320 320
 				}
321 321
 			}
322 322
 		}
323 323
 
324 324
 
325
-		foreach ($this->ElasticaSearchableFields() as $esf) {
326
-			if ($esf->Weight == 0) {
325
+		foreach($this->ElasticaSearchableFields() as $esf) {
326
+			if($esf->Weight == 0) {
327 327
 				$result->error("The field {$esf->ClazzName}.{$esf->Name} has a zero weight. ");
328
-			} else if ($esf->Weight < 0) {
328
+			} else if($esf->Weight < 0) {
329 329
 				$result->error("The field {$esf->ClazzName}.{$esf->Name} has a negative weight. ");
330 330
 			}
331 331
 		}
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 
342 342
 		#FIXME -  SiteTree only
343 343
 		$relevantClasses = $this->ClassesToSearch; // due to validation this will be valid
344
-		if ($this->SiteTreeOnly) {
344
+		if($this->SiteTreeOnly) {
345 345
 			$relevantClasses = SearchableClass::get()->filter('InSiteTree', true)->Map('Name')->toArray();
346 346
 
347 347
 		}
@@ -361,9 +361,9 @@  discard block
 block discarded – undo
361 361
     	$delta = array_keys($esfs->map()->toArray());
362 362
 		$newSearchableFields = $sfs->exclude('ID', $delta);
363 363
 
364
-		if ($newSearchableFields->count() > 0) {
365
-			foreach ($newSearchableFields->getIterator() as $newSearchableField) {
366
-				error_log('NEW FIELD:'.$newSearchableField->Name);
364
+		if($newSearchableFields->count() > 0) {
365
+			foreach($newSearchableFields->getIterator() as $newSearchableField) {
366
+				error_log('NEW FIELD:' . $newSearchableField->Name);
367 367
 				$newSearchableField->Active = true;
368 368
 				$newSearchableField->Weight = 1;
369 369
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 
372 372
 				// Note 1 used instead of true for SQLite3 testing compatibility
373 373
 				$sql = "UPDATE ElasticSearchPage_ElasticaSearchableFields SET ";
374
-				$sql .= 'Active=1, Weight=1 WHERE ElasticSearchPageID = '.$this->ID;
374
+				$sql .= 'Active=1, Weight=1 WHERE ElasticSearchPageID = ' . $this->ID;
375 375
 				DB::query($sql);
376 376
 			}
377 377
 		}
@@ -406,19 +406,19 @@  discard block
 block discarded – undo
406 406
 		$qField = $fields->fieldByName('q');
407 407
 
408 408
 
409
-		if ($buttonTextOverride) {
409
+		if($buttonTextOverride) {
410 410
 			$result->setButtonText($buttonTextOverride);
411 411
 		}
412 412
 
413 413
 		/*
414 414
 		A field needs to be chosen for autocompletion, if not no autocomplete
415 415
 		 */
416
-		if ($this->AutoCompleteFieldID > 0) {
416
+		if($this->AutoCompleteFieldID > 0) {
417 417
 			$qField->setAttribute('data-autocomplete', 'true');
418 418
 			$qField->setAttribute('data-autocomplete-field', 'Title');
419 419
 			$qField->setAttribute('data-autocomplete-classes', $this->ClassesToSearch);
420 420
 			$qField->setAttribute('data-autocomplete-sitetree', $this->SiteTreeOnly);
421
-			$qField->setAttribute('data-autocomplete-source',$this->Link());
421
+			$qField->setAttribute('data-autocomplete-source', $this->Link());
422 422
 			$qField->setAttribute('data-autocomplete-function',
423 423
 			$this->AutocompleteFunction()->Slug);
424 424
 		}
Please login to merge, or discard this patch.
searchpage/ElasticSearchPage_Controller.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 		Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
11 11
 		Requirements::javascript("elastica/javascript/jquery.autocomplete.js");
12 12
 		Requirements::javascript("elastica/javascript/elastica.js");
13
-        Requirements::css("elastica/css/elastica.css");
13
+		Requirements::css("elastica/css/elastica.css");
14 14
 	}
15 15
 
16 16
 
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 
85 85
 		try {
86 86
 			// Simulate server being down for testing purposes
87
-	        if (isset($_GET['ServerDown'])) {
88
-	        	throw new Elastica\Exception\Connection\HttpException('Unable to reach search server');
89
-	        }
87
+			if (isset($_GET['ServerDown'])) {
88
+				throw new Elastica\Exception\Connection\HttpException('Unable to reach search server');
89
+			}
90 90
 			if (class_exists($class)) {
91 91
 				$instance = \DataObject::get_by_id($class,$instanceID);
92 92
 
@@ -226,9 +226,9 @@  discard block
 block discarded – undo
226 226
 		$paginated = null;
227 227
 		try {
228 228
 			// Simulate server being down for testing purposes
229
-	        if (isset($_GET['ServerDown'])) {
230
-	        	throw new Elastica\Exception\Connection\HttpException('Unable to reach search server');
231
-	        }
229
+			if (isset($_GET['ServerDown'])) {
230
+				throw new Elastica\Exception\Connection\HttpException('Unable to reach search server');
231
+			}
232 232
 
233 233
 			// now actually perform the search using the original query
234 234
 			$paginated = $es->search($queryText, $fieldsToSearch, $testMode);
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 class ElasticSearchPage_Controller extends Page_Controller {
4 4
 
5
-	private static $allowed_actions = array('SearchForm', 'submit','index','similar');
5
+	private static $allowed_actions = array('SearchForm', 'submit', 'index', 'similar');
6 6
 
7 7
 	public function init() {
8 8
 		parent::init();
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
 
58 58
 		// filter by class or site tree
59
-		if ($ep->SiteTreeOnly) {
59
+		if($ep->SiteTreeOnly) {
60 60
 			T7; //FIXME test missing
61 61
 			$es->addFilter('IsInSiteTree', true);
62 62
 		} else {
@@ -72,23 +72,23 @@  discard block
 block discarded – undo
72 72
 			'SimilarSearchable' => true
73 73
 		));
74 74
 
75
-		foreach ($editedSearchFields->getIterator() as $searchField) {
75
+		foreach($editedSearchFields->getIterator() as $searchField) {
76 76
 			$fieldsToSearch[$searchField->Name] = $searchField->Weight;
77 77
 		}
78 78
 
79 79
 		// Use the standard field for more like this, ie not stemmed
80
-		foreach ($fieldsToSearch as $field => $value) {
81
-			$fieldsToSearch[$field.'.standard'] = $value;
80
+		foreach($fieldsToSearch as $field => $value) {
81
+			$fieldsToSearch[$field . '.standard'] = $value;
82 82
 			unset($fieldsToSearch[$field]);
83 83
 		}
84 84
 
85 85
 		try {
86 86
 			// Simulate server being down for testing purposes
87
-	        if (isset($_GET['ServerDown'])) {
87
+	        if(isset($_GET['ServerDown'])) {
88 88
 	        	throw new Elastica\Exception\Connection\HttpException('Unable to reach search server');
89 89
 	        }
90
-			if (class_exists($class)) {
91
-				$instance = \DataObject::get_by_id($class,$instanceID);
90
+			if(class_exists($class)) {
91
+				$instance = \DataObject::get_by_id($class, $instanceID);
92 92
 
93 93
 				$paginated = $es->moreLikeThis($instance, $fieldsToSearch);
94 94
 
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
 
103 103
 				$moreLikeThisTerms = $paginated->getList()->MoreLikeThisTerms;
104 104
 				$fieldToTerms = new ArrayList();
105
-				foreach (array_keys($moreLikeThisTerms) as $fieldName) {
105
+				foreach(array_keys($moreLikeThisTerms) as $fieldName) {
106 106
 					$readableFieldName = str_replace('.standard', '', $fieldName);
107 107
 					$fieldTerms = new ArrayList();
108
-					foreach ($moreLikeThisTerms[$fieldName] as $value) {
108
+					foreach($moreLikeThisTerms[$fieldName] as $value) {
109 109
 						$do = new DataObject();
110 110
 						$do->Term = $value;
111 111
 						$fieldTerms->push($do);
@@ -132,14 +132,14 @@  discard block
 block discarded – undo
132 132
 
133 133
 		// calculate time
134 134
 		$endTime = microtime(true);
135
-		$elapsed = round(100*($endTime-$startTime))/100;
135
+		$elapsed = round(100 * ($endTime - $startTime)) / 100;
136 136
 
137 137
 		// store variables for the template to use
138 138
 		$data['ElapsedTime'] = $elapsed;
139 139
 		$data['Elapsed'] = $elapsed;
140 140
 
141 141
 		// allow the optional use of overriding the search result page, e.g. for photos, maps or facets
142
-		if ($this->hasExtension('PageControllerTemplateOverrideExtension')) {
142
+		if($this->hasExtension('PageControllerTemplateOverrideExtension')) {
143 143
 			return $this->useTemplateOverride($data);
144 144
 		} else {
145 145
 			return $data;
@@ -179,23 +179,23 @@  discard block
 block discarded – undo
179 179
 
180 180
 		// query string
181 181
 		$queryText = '';
182
-		if (isset($_GET['q'])) {
182
+		if(isset($_GET['q'])) {
183 183
 			$queryText = $_GET['q'];
184 184
 		}
185 185
 
186 186
 		$testMode = isset($_GET['TestMode']);
187 187
 
188 188
 		// filters for aggregations
189
-		$ignore = array('url', 'start','q','is');
189
+		$ignore = array('url', 'start', 'q', 'is');
190 190
 		$ignore = \Config::inst()->get('Elastica', 'BlackList');
191
-		foreach ($this->request->getVars() as $key => $value) {
192
-			if (!in_array($key, $ignore)) {
193
-				$es->addFilter($key,$value);
191
+		foreach($this->request->getVars() as $key => $value) {
192
+			if(!in_array($key, $ignore)) {
193
+				$es->addFilter($key, $value);
194 194
 			}
195 195
 		}
196 196
 
197 197
 		// filter by class or site tree
198
-		if ($ep->SiteTreeOnly) {
198
+		if($ep->SiteTreeOnly) {
199 199
 			$es->addFilter('IsInSiteTree', true);
200 200
 		} else {
201 201
 			$es->setClasses($ep->ClassesToSearch);
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 		// set the optional aggregation manipulator
205 205
 		// In the event of a manipulator being present, show all the results for search
206 206
 		// Otherwise aggregations are all zero
207
-		if ($this->SearchHelper) {
207
+		if($this->SearchHelper) {
208 208
 			$es->setQueryResultManipulator($this->SearchHelper);
209 209
 			$es->showResultsForEmptySearch();
210 210
 		} else {
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
 			'Searchable' => true
220 220
 		));
221 221
 
222
-		foreach ($editedSearchFields->getIterator() as $searchField) {
222
+		foreach($editedSearchFields->getIterator() as $searchField) {
223 223
 			$fieldsToSearch[$searchField->Name] = $searchField->Weight;
224 224
 		}
225 225
 
226 226
 		$paginated = null;
227 227
 		try {
228 228
 			// Simulate server being down for testing purposes
229
-	        if (isset($_GET['ServerDown'])) {
229
+	        if(isset($_GET['ServerDown'])) {
230 230
 	        	throw new Elastica\Exception\Connection\HttpException('Unable to reach search server');
231 231
 	        }
232 232
 
@@ -235,11 +235,11 @@  discard block
 block discarded – undo
235 235
 
236 236
 			// This is the case of the original query having a better one suggested.  Do a
237 237
 			// second search for the suggested query, throwing away the original
238
-			if ($es->hasSuggestedQuery() && !$ignoreSuggestions) {
238
+			if($es->hasSuggestedQuery() && !$ignoreSuggestions) {
239 239
 				$data['SuggestedQuery'] = $es->getSuggestedQuery();
240 240
 				$data['SuggestedQueryHighlighted'] = $es->getSuggestedQueryHighlighted();
241 241
 				//Link for if the user really wants to try their original query
242
-				$sifLink = rtrim($this->Link(),'/').'?q='.$queryText.'&is=1';
242
+				$sifLink = rtrim($this->Link(), '/') . '?q=' . $queryText . '&is=1';
243 243
 				$data['SearchInsteadForLink'] = $sifLink;
244 244
 				$paginated = $es->search($es->getSuggestedQuery(), $fieldsToSearch);
245 245
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 
248 248
 			// calculate time
249 249
 			$endTime = microtime(true);
250
-			$elapsed = round(100*($endTime-$startTime))/100;
250
+			$elapsed = round(100 * ($endTime - $startTime)) / 100;
251 251
 
252 252
 			// store variables for the template to use
253 253
 			$data['ElapsedTime'] = $elapsed;
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 		$data['OriginalQuery'] = $queryText;
265 265
 		$data['IgnoreSuggestions'] = $ignoreSuggestions;
266 266
 
267
-		if ($this->has_extension('PageControllerTemplateOverrideExtension')) {
267
+		if($this->has_extension('PageControllerTemplateOverrideExtension')) {
268 268
 			return $this->useTemplateOverride($data);
269 269
 		} else {
270 270
 			return $data;
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 	 */
279 279
 	public function QueryIsEmpty() {
280 280
 		$result = !isset($_GET['q']);
281
-		if (isset($_GET['q']))	{
281
+		if(isset($_GET['q'])) {
282 282
 			$queryText = $_GET['q'];
283
-			if ($queryText == '') {
283
+			if($queryText == '') {
284 284
 				$result = true;
285 285
 			}
286 286
 		}
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 		$queryText = $data['q'];
298 298
 		$url = $this->Link();
299 299
 		$url = rtrim($url, '/');
300
-		$link = rtrim($url, '/').'?q='.$queryText.'&sfid='.$data['identifier'];
300
+		$link = rtrim($url, '/') . '?q=' . $queryText . '&sfid=' . $data['identifier'];
301 301
 		$this->redirect($link);
302 302
 	}
303 303
 
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
 		$fields->push($identifierField);
315 315
 		$queryField = $fields->fieldByName('q');
316 316
 
317
-		 if (isset($_GET['q']) && isset($_GET['sfid'])) {
318
-			if ($_GET['sfid'] == $ep->Identifier) {
317
+		 if(isset($_GET['q']) && isset($_GET['sfid'])) {
318
+			if($_GET['sfid'] == $ep->Identifier) {
319 319
 				$queryField->setValue($_GET['q']);
320 320
 			}
321 321
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 		if($this->action == 'similar') {
325 325
 			$queryField->setDisabled(true);
326 326
 			$actions = $form->Actions();
327
-			foreach ($actions as $field) {
327
+			foreach($actions as $field) {
328 328
 				$field->setDisabled(true);
329 329
 			}
330 330
 		}
@@ -332,12 +332,12 @@  discard block
 block discarded – undo
332 332
 		/*
333 333
 		A field needs to be chosen for autocompletion, if not no autocomplete
334 334
 		 */
335
-		if ($this->AutoCompleteFieldID > 0) {
335
+		if($this->AutoCompleteFieldID > 0) {
336 336
 			$queryField->setAttribute('data-autocomplete', 'true');
337 337
 			$queryField->setAttribute('data-autocomplete-field', 'Title');
338 338
 			$queryField->setAttribute('data-autocomplete-classes', $this->ClassesToSearch);
339 339
 			$queryField->setAttribute('data-autocomplete-sitetree', $this->SiteTreeOnly);
340
-			$queryField->setAttribute('data-autocomplete-source',$this->Link());
340
+			$queryField->setAttribute('data-autocomplete-source', $this->Link());
341 341
 			$queryField->setAttribute('data-autocomplete-function',
342 342
 			$this->AutocompleteFunction()->Slug);
343 343
 		}
Please login to merge, or discard this patch.