@@ -29,20 +29,20 @@ discard block |
||
29 | 29 | $config->removeComponent($config->getComponentByType('GridFieldDeleteAction')); |
30 | 30 | |
31 | 31 | $config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array( |
32 | - 'Name' => 'Name', |
|
33 | - 'Weight' => 'Weighting', |
|
34 | - 'Searchable' => 'Search this field?' |
|
35 | - )); |
|
32 | + 'Name' => 'Name', |
|
33 | + 'Weight' => 'Weighting', |
|
34 | + 'Searchable' => 'Search this field?' |
|
35 | + )); |
|
36 | 36 | |
37 | 37 | |
38 | - $gridField = new GridField( |
|
39 | - 'SearchableField', // Field name |
|
40 | - 'Field Name', // Field title |
|
41 | - SearchableField::get()->filter('SearchableClassID', $this->ID)->sort('Name'), |
|
42 | - $config |
|
43 | - ); |
|
38 | + $gridField = new GridField( |
|
39 | + 'SearchableField', // Field name |
|
40 | + 'Field Name', // Field title |
|
41 | + SearchableField::get()->filter('SearchableClassID', $this->ID)->sort('Name'), |
|
42 | + $config |
|
43 | + ); |
|
44 | 44 | |
45 | - $fields->addFieldToTab('Root.Main', $gridField); |
|
45 | + $fields->addFieldToTab('Root.Main', $gridField); |
|
46 | 46 | |
47 | 47 | /* |
48 | 48 | $fields = new FieldList(); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | |
52 | 52 | */ |
53 | - return $fields; |
|
53 | + return $fields; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 |
@@ -92,26 +92,26 @@ discard block |
||
92 | 92 | //Need to check capitalisation of terms suggested that are different |
93 | 93 | |
94 | 94 | $chr = mb_substr ($possiblyUppercase, 0, 1, "UTF-8"); |
95 | - if (mb_strtolower($chr, "UTF-8") != $chr) { |
|
96 | - $upperLowercaseWord = $lowercaseWord; |
|
97 | - $upperLowercaseWord[0] = $chr; |
|
95 | + if (mb_strtolower($chr, "UTF-8") != $chr) { |
|
96 | + $upperLowercaseWord = $lowercaseWord; |
|
97 | + $upperLowercaseWord[0] = $chr; |
|
98 | 98 | |
99 | - //$possiblyUppercaseHighlighted = str_replace($lowercaseWord, $possiblyUppercase, $possiblyUppercaseHighlighted); |
|
100 | - $withHighlights = str_replace($lowercaseWord, $upperLowercaseWord, $possiblyUppercaseHighlighted); |
|
99 | + //$possiblyUppercaseHighlighted = str_replace($lowercaseWord, $possiblyUppercase, $possiblyUppercaseHighlighted); |
|
100 | + $withHighlights = str_replace($lowercaseWord, $upperLowercaseWord, $possiblyUppercaseHighlighted); |
|
101 | 101 | |
102 | - $lowercaseWord[0] = $chr; |
|
102 | + $lowercaseWord[0] = $chr; |
|
103 | 103 | |
104 | - //str_replace(search, replace, subject) |
|
104 | + //str_replace(search, replace, subject) |
|
105 | 105 | |
106 | - array_push($plain, $lowercaseWord); |
|
107 | - array_push($highlighted, $withHighlights); |
|
108 | - } else { |
|
109 | - //No need to capitalise, so add suggested word |
|
110 | - array_push($plain, $lowercaseWord); |
|
106 | + array_push($plain, $lowercaseWord); |
|
107 | + array_push($highlighted, $withHighlights); |
|
108 | + } else { |
|
109 | + //No need to capitalise, so add suggested word |
|
110 | + array_push($plain, $lowercaseWord); |
|
111 | 111 | |
112 | - //No need to capitalise, so add suggested highlighted word |
|
113 | - array_push($highlighted, $possiblyUppercaseHighlighted); |
|
114 | - } |
|
112 | + //No need to capitalise, so add suggested highlighted word |
|
113 | + array_push($highlighted, $possiblyUppercaseHighlighted); |
|
114 | + } |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -144,37 +144,37 @@ discard block |
||
144 | 144 | |
145 | 145 | $explanation = explode('-ConstantScore', $explanation)[0]; |
146 | 146 | |
147 | - $bracketPos = strpos($explanation, ')~'); |
|
147 | + $bracketPos = strpos($explanation, ')~'); |
|
148 | 148 | |
149 | - if (substr($explanation, 0,2) == '((') { |
|
150 | - $explanation = substr($explanation, 2, $bracketPos-2); |
|
151 | - } elseif (substr($explanation, 0,1) == '(') { |
|
152 | - $explanation = substr($explanation, 1, $bracketPos-2); |
|
153 | - } |
|
149 | + if (substr($explanation, 0,2) == '((') { |
|
150 | + $explanation = substr($explanation, 2, $bracketPos-2); |
|
151 | + } elseif (substr($explanation, 0,1) == '(') { |
|
152 | + $explanation = substr($explanation, 1, $bracketPos-2); |
|
153 | + } |
|
154 | 154 | |
155 | - $terms = array(); |
|
155 | + $terms = array(); |
|
156 | 156 | |
157 | - //Field name(s) => terms |
|
158 | - $splits = explode(' ', $explanation); |
|
157 | + //Field name(s) => terms |
|
158 | + $splits = explode(' ', $explanation); |
|
159 | 159 | |
160 | - foreach ($splits as $fieldAndTerm) { |
|
161 | - $splits = explode(':', $fieldAndTerm); |
|
160 | + foreach ($splits as $fieldAndTerm) { |
|
161 | + $splits = explode(':', $fieldAndTerm); |
|
162 | 162 | |
163 | - // This is the no terms case |
|
164 | - if (sizeof($splits) < 2) { |
|
165 | - break; |
|
166 | - } |
|
163 | + // This is the no terms case |
|
164 | + if (sizeof($splits) < 2) { |
|
165 | + break; |
|
166 | + } |
|
167 | 167 | |
168 | - $fieldname = $splits[0]; |
|
169 | - $term = $splits[1]; |
|
168 | + $fieldname = $splits[0]; |
|
169 | + $term = $splits[1]; |
|
170 | 170 | |
171 | - if (!isset($terms[$fieldname])) { |
|
172 | - $terms[$fieldname] = array(); |
|
173 | - } |
|
171 | + if (!isset($terms[$fieldname])) { |
|
172 | + $terms[$fieldname] = array(); |
|
173 | + } |
|
174 | 174 | |
175 | - array_push($terms[$fieldname], $term); |
|
176 | - } |
|
175 | + array_push($terms[$fieldname], $term); |
|
176 | + } |
|
177 | 177 | |
178 | - return $terms; |
|
178 | + return $terms; |
|
179 | 179 | } |
180 | 180 | } |
@@ -208,11 +208,11 @@ |
||
208 | 208 | */ |
209 | 209 | public function invokeMethod(&$object, $methodName, array $parameters = array()) |
210 | 210 | { |
211 | - $reflection = new \ReflectionClass(get_class($object)); |
|
212 | - $method = $reflection->getMethod($methodName); |
|
213 | - $method->setAccessible(true); |
|
211 | + $reflection = new \ReflectionClass(get_class($object)); |
|
212 | + $method = $reflection->getMethod($methodName); |
|
213 | + $method->setAccessible(true); |
|
214 | 214 | |
215 | - return $method->invokeArgs($object, $parameters); |
|
215 | + return $method->invokeArgs($object, $parameters); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 |
@@ -553,10 +553,10 @@ |
||
553 | 553 | print_r($sr); |
554 | 554 | |
555 | 555 | |
556 | - //$sr2 = array('Photographer', 'FlickrTagTOs', 'FlickrSetTOs'); |
|
556 | + //$sr2 = array('Photographer', 'FlickrTagTOs', 'FlickrSetTOs'); |
|
557 | 557 | |
558 | - // MUST REMOVE FIRST. Otherwise append and the erroroneus value above still exists |
|
559 | - $config->remove('FlickrPhotoTO', 'searchable_relationships'); |
|
558 | + // MUST REMOVE FIRST. Otherwise append and the erroroneus value above still exists |
|
559 | + $config->remove('FlickrPhotoTO', 'searchable_relationships'); |
|
560 | 560 | $config->update('FlickrPhotoTO' ,'searchable_relationships', $sr); |
561 | 561 | } |
562 | 562 |
@@ -139,37 +139,37 @@ discard block |
||
139 | 139 | * Add a mapping for the location of the photograph |
140 | 140 | */ |
141 | 141 | public function updateElasticsearchMapping(\Elastica\Type\Mapping $mapping) |
142 | - { |
|
143 | - // get the properties of the individual fields as an array |
|
144 | - $properties = $mapping->getProperties(); |
|
145 | - |
|
146 | - // add a location with geo point |
|
147 | - $precision1cm = array('format' => 'compressed', 'precision' => '1cm'); |
|
148 | - $properties['location'] = array( |
|
149 | - 'type' => 'geo_point', |
|
150 | - 'fielddata' => $precision1cm, |
|
151 | - ); |
|
152 | - |
|
153 | - $properties['ShutterSpeed'] = array( |
|
154 | - 'type' => 'string', |
|
155 | - 'index' => 'not_analyzed' |
|
142 | + { |
|
143 | + // get the properties of the individual fields as an array |
|
144 | + $properties = $mapping->getProperties(); |
|
145 | + |
|
146 | + // add a location with geo point |
|
147 | + $precision1cm = array('format' => 'compressed', 'precision' => '1cm'); |
|
148 | + $properties['location'] = array( |
|
149 | + 'type' => 'geo_point', |
|
150 | + 'fielddata' => $precision1cm, |
|
156 | 151 | ); |
157 | 152 | |
158 | - $properties['Aperture'] = array( |
|
159 | - // do not use float as the rounding makes facets impossible |
|
160 | - 'type' => 'double' |
|
161 | - ); |
|
153 | + $properties['ShutterSpeed'] = array( |
|
154 | + 'type' => 'string', |
|
155 | + 'index' => 'not_analyzed' |
|
156 | + ); |
|
162 | 157 | |
163 | - $properties['FlickrID'] = array('type' => 'integer'); |
|
158 | + $properties['Aperture'] = array( |
|
159 | + // do not use float as the rounding makes facets impossible |
|
160 | + 'type' => 'double' |
|
161 | + ); |
|
164 | 162 | |
165 | - // by default casted as a string, we want a date 2015-07-25 18:15:33 y-M-d H:m:s |
|
166 | - //$properties['TakenAt'] = array('type' => 'date', 'format' => 'y-M-d H:m:s'); |
|
163 | + $properties['FlickrID'] = array('type' => 'integer'); |
|
167 | 164 | |
168 | - // set the new properties on the mapping |
|
169 | - $mapping->setProperties($properties); |
|
165 | + // by default casted as a string, we want a date 2015-07-25 18:15:33 y-M-d H:m:s |
|
166 | + //$properties['TakenAt'] = array('type' => 'date', 'format' => 'y-M-d H:m:s'); |
|
170 | 167 | |
171 | - return $mapping; |
|
172 | - } |
|
168 | + // set the new properties on the mapping |
|
169 | + $mapping->setProperties($properties); |
|
170 | + |
|
171 | + return $mapping; |
|
172 | + } |
|
173 | 173 | |
174 | 174 | |
175 | 175 | /** |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | } |
206 | 206 | $sortable = $sortable . '|' . $this->owner->ShutterSpeed; |
207 | 207 | $document->set('ShutterSpeed', $sortable); |
208 | - return $document; |
|
208 | + return $document; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | |
11 | 11 | public function __construct() { |
12 | 12 | $aspectAgg = new RangedAggregation('Aspect', 'AspectRatio'); |
13 | - $aspectAgg->addRange(0.0000001, 0.3, 'Panoramic'); |
|
14 | - $aspectAgg->addRange(0.3, 0.9, 'Horizontal'); |
|
15 | - $aspectAgg->addRange(0.9, 1.2, 'Square'); |
|
16 | - $aspectAgg->addRange(1.2, 1.79, 'Vertical'); |
|
17 | - $aspectAgg->addRange(1.79, 1e7, 'Tallest'); |
|
13 | + $aspectAgg->addRange(0.0000001, 0.3, 'Panoramic'); |
|
14 | + $aspectAgg->addRange(0.3, 0.9, 'Horizontal'); |
|
15 | + $aspectAgg->addRange(0.9, 1.2, 'Square'); |
|
16 | + $aspectAgg->addRange(1.2, 1.79, 'Vertical'); |
|
17 | + $aspectAgg->addRange(1.79, 1e7, 'Tallest'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | private static $titleFieldMapping = array( |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | |
75 | 75 | $aspectRangedAgg = RangedAggregation::getByTitle('Aspect'); |
76 | - $query->addAggregation($aspectRangedAgg->getRangeAgg()); |
|
76 | + $query->addAggregation($aspectRangedAgg->getRangeAgg()); |
|
77 | 77 | |
78 | 78 | // leave this out for the moment as way too many terms being returned slowing things down |
79 | 79 | /* |
@@ -115,10 +115,10 @@ discard block |
||
115 | 115 | $this->assertEquals(200, $searchPage->getStatusCode()); |
116 | 116 | $url = rtrim($url,'/'); |
117 | 117 | |
118 | - $response = $this->get($url); |
|
119 | - $this->assertEquals(200, $response->getStatusCode()); |
|
118 | + $response = $this->get($url); |
|
119 | + $this->assertEquals(200, $response->getStatusCode()); |
|
120 | 120 | |
121 | - $this->assertSelectorStartsWithOrEquals('span.count', 0, '(5)'); |
|
121 | + $this->assertSelectorStartsWithOrEquals('span.count', 0, '(5)'); |
|
122 | 122 | $this->assertSelectorStartsWithOrEquals('span.count', 1, '(11)'); |
123 | 123 | $this->assertSelectorStartsWithOrEquals('span.count', 2, '(12)'); |
124 | 124 | $this->assertSelectorStartsWithOrEquals('span.count', 3, '(13)'); |
@@ -168,10 +168,10 @@ discard block |
||
168 | 168 | $url = rtrim($url,'/'); |
169 | 169 | $url .= '?ISO=400'; |
170 | 170 | |
171 | - $response = $this->get($url); |
|
172 | - $this->assertEquals(200, $response->getStatusCode()); |
|
171 | + $response = $this->get($url); |
|
172 | + $this->assertEquals(200, $response->getStatusCode()); |
|
173 | 173 | |
174 | - // These are less than in the no facets selected case, as expected |
|
174 | + // These are less than in the no facets selected case, as expected |
|
175 | 175 | $this->assertSelectorStartsWithOrEquals('span.count', 0, '(2)'); |
176 | 176 | $this->assertSelectorStartsWithOrEquals('span.count', 1, '(1)'); |
177 | 177 | $this->assertSelectorStartsWithOrEquals('span.count', 2, '(2)'); |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | $url = rtrim($url,'/'); |
216 | 216 | $url .= '?ISO=400&ShutterSpeed=2%2F250'; |
217 | 217 | |
218 | - $response = $this->get($url); |
|
218 | + $response = $this->get($url); |
|
219 | 219 | print_r($response); |
220 | - $this->assertEquals(200, $response->getStatusCode()); |
|
220 | + $this->assertEquals(200, $response->getStatusCode()); |
|
221 | 221 | |
222 | - // These are less than in the one facet selected case, as expected |
|
223 | - $this->assertSelectorStartsWithOrEquals('span.count', 0, '(1)'); |
|
222 | + // These are less than in the one facet selected case, as expected |
|
223 | + $this->assertSelectorStartsWithOrEquals('span.count', 0, '(1)'); |
|
224 | 224 | $this->assertSelectorStartsWithOrEquals('span.count', 1, '(2)'); |
225 | 225 | $this->assertSelectorStartsWithOrEquals('span.count', 2, '(1)'); |
226 | 226 | $this->assertSelectorStartsWithOrEquals('span.count', 3, '(1)'); |
@@ -249,12 +249,12 @@ discard block |
||
249 | 249 | $url = rtrim($url,'/'); |
250 | 250 | $url .= '?ISO=400&ShutterSpeed=2%2F250&Aspect=Vertical'; |
251 | 251 | |
252 | - $response = $this->get($url); |
|
252 | + $response = $this->get($url); |
|
253 | 253 | print_r($response); |
254 | - $this->assertEquals(200, $response->getStatusCode()); |
|
254 | + $this->assertEquals(200, $response->getStatusCode()); |
|
255 | 255 | |
256 | - // These are less than in the one facet selected case, as expected |
|
257 | - $this->assertSelectorStartsWithOrEquals('span.count', 0, '(2)'); |
|
256 | + // These are less than in the one facet selected case, as expected |
|
257 | + $this->assertSelectorStartsWithOrEquals('span.count', 0, '(2)'); |
|
258 | 258 | $this->assertSelectorStartsWithOrEquals('span.count', 1, '(1)'); |
259 | 259 | $this->assertSelectorStartsWithOrEquals('span.count', 2, '(1)'); |
260 | 260 | } |
@@ -602,13 +602,13 @@ discard block |
||
602 | 602 | $searchPage = $this->get($searchPageObj->URLSegment); |
603 | 603 | $this->assertEquals(200, $searchPage->getStatusCode()); |
604 | 604 | |
605 | - $response = $this->submitForm("ElasticSearchForm_SearchForm", null, array( |
|
606 | - 'q' => 'New Zealand' |
|
607 | - )); |
|
605 | + $response = $this->submitForm("ElasticSearchForm_SearchForm", null, array( |
|
606 | + 'q' => 'New Zealand' |
|
607 | + )); |
|
608 | 608 | |
609 | 609 | $url = rtrim($url,'/'); |
610 | - $this->assertEquals(302, $response->getStatusCode()); |
|
611 | - $this->assertEquals($url.'?q=New Zealand&sfid=testwithagg', $response->getHeader('Location')); |
|
610 | + $this->assertEquals(302, $response->getStatusCode()); |
|
611 | + $this->assertEquals($url.'?q=New Zealand&sfid=testwithagg', $response->getHeader('Location')); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 |
@@ -140,7 +140,7 @@ |
||
140 | 140 | |
141 | 141 | public function testEach() { |
142 | 142 | $callback = function($fp) { |
143 | - $this->assertTrue(true, 'Callback reached'); |
|
143 | + $this->assertTrue(true, 'Callback reached'); |
|
144 | 144 | }; |
145 | 145 | $resultList = $this->getResultsFor('New Zealand',10); |
146 | 146 | $resultList->each($callback); |
@@ -434,11 +434,11 @@ discard block |
||
434 | 434 | |
435 | 435 | |
436 | 436 | |
437 | - $query = new Query(); |
|
438 | - $query->setParams(array('query' => array('more_like_this' => $mlt))); |
|
437 | + $query = new Query(); |
|
438 | + $query->setParams(array('query' => array('more_like_this' => $mlt))); |
|
439 | 439 | |
440 | 440 | |
441 | - $elasticService = \Injector::inst()->create('SilverStripe\Elastica\ElasticaService'); |
|
441 | + $elasticService = \Injector::inst()->create('SilverStripe\Elastica\ElasticaService'); |
|
442 | 442 | $elasticService->setLocale($this->locale); |
443 | 443 | if ($testMode) { |
444 | 444 | $elasticService->setTestMode(true); |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | $query->setFrom($this->start); |
451 | 451 | |
452 | 452 | $resultList = new ResultList($elasticService, $query, null); |
453 | - // at this point ResultList object, not yet executed search query |
|
453 | + // at this point ResultList object, not yet executed search query |
|
454 | 454 | $paginated = new \PaginatedList( |
455 | 455 | $resultList |
456 | 456 | ); |