@@ -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 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | public function setUp() { |
| 14 | 14 | // this needs to be called in order to create the list of searchable |
| 15 | 15 | // classes and fields that are available. Simulates part of a build |
| 16 | - $classes = array('SearchableTestPage','SiteTree','Page','FlickrPhotoTO','FlickrSetTO', |
|
| 16 | + $classes = array('SearchableTestPage', 'SiteTree', 'Page', 'FlickrPhotoTO', 'FlickrSetTO', |
|
| 17 | 17 | 'FlickrTagTO', 'FlickrAuthorTO', 'FlickrSetTO'); |
| 18 | 18 | $this->requireDefaultRecordsFrom = $classes; |
| 19 | 19 | |
@@ -188,15 +188,15 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | |
| 190 | 190 | // check strings |
| 191 | - $shouldBeString = array('Title','Description'); |
|
| 192 | - $shouldBeInt = array('ISO','FlickrID','FocalLength35mm'); |
|
| 191 | + $shouldBeString = array('Title', 'Description'); |
|
| 192 | + $shouldBeInt = array('ISO', 'FlickrID', 'FocalLength35mm'); |
|
| 193 | 193 | $shouldBeBoolean = array('IsInSiteTree'); |
| 194 | 194 | $shouldBeDouble = array('Aperture'); |
| 195 | 195 | $shouldBeDateTime = array('TakenAt'); |
| 196 | 196 | $shouldBeDate = array('FirstViewed'); |
| 197 | 197 | |
| 198 | 198 | // tokens are strings that have analyzer 'not_analyzed', namely the string is indexed as is |
| 199 | - $shouldBeTokens = array('ShutterSpeed','Link'); |
|
| 199 | + $shouldBeTokens = array('ShutterSpeed', 'Link'); |
|
| 200 | 200 | |
| 201 | 201 | |
| 202 | 202 | // check strings |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | // check for unstemmed analaysis |
| 215 | 215 | |
| 216 | - $this->assertEquals($expectedStandardArray,$fieldProperties['fields']['standard']); |
|
| 216 | + $this->assertEquals($expectedStandardArray, $fieldProperties['fields']['standard']); |
|
| 217 | 217 | |
| 218 | 218 | // check for only 3 entries |
| 219 | 219 | $this->assertEquals(4, sizeof(array_keys($fieldProperties))); |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | $fieldProperties = $properties[$fieldName]; |
| 225 | 225 | $type = $fieldProperties['type']; |
| 226 | 226 | $this->assertEquals(1, sizeof(array_keys($fieldProperties))); |
| 227 | - $this->assertEquals('integer',$type); |
|
| 227 | + $this->assertEquals('integer', $type); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | $fieldProperties = $properties[$fieldName]; |
| 234 | 234 | $type = $fieldProperties['type']; |
| 235 | 235 | $this->assertEquals(1, sizeof(array_keys($fieldProperties))); |
| 236 | - $this->assertEquals('double',$type); |
|
| 236 | + $this->assertEquals('double', $type); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | // check boolean |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | $fieldProperties = $properties[$fieldName]; |
| 242 | 242 | $type = $fieldProperties['type']; |
| 243 | 243 | $this->assertEquals(1, sizeof(array_keys($fieldProperties))); |
| 244 | - $this->assertEquals('boolean',$type); |
|
| 244 | + $this->assertEquals('boolean', $type); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | $fieldProperties = $properties[$fieldName]; |
| 250 | 250 | $type = $fieldProperties['type']; |
| 251 | 251 | $this->assertEquals(2, sizeof(array_keys($fieldProperties))); |
| 252 | - $this->assertEquals('date',$type); |
|
| 252 | + $this->assertEquals('date', $type); |
|
| 253 | 253 | $this->assertEquals('y-M-d', $fieldProperties['format']); |
| 254 | 254 | } |
| 255 | 255 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | $fieldProperties = $properties[$fieldName]; |
| 261 | 261 | $type = $fieldProperties['type']; |
| 262 | 262 | $this->assertEquals(2, sizeof(array_keys($fieldProperties))); |
| 263 | - $this->assertEquals('date',$type); |
|
| 263 | + $this->assertEquals('date', $type); |
|
| 264 | 264 | $this->assertEquals('y-M-d H:m:s', $fieldProperties['format']); |
| 265 | 265 | } |
| 266 | 266 | |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | $doc = $flickrPhoto->getElasticaDocument()->getData(); |
| 300 | 300 | |
| 301 | 301 | $expected = array(); |
| 302 | - $expected['Title'] = 'Bangkok' ; |
|
| 302 | + $expected['Title'] = 'Bangkok'; |
|
| 303 | 303 | $expected['FlickrID'] = '1234567'; |
| 304 | 304 | $expected['Description'] = 'Test photograph'; |
| 305 | 305 | $expected['TakenAt'] = '2011-07-04 20:36:00'; |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | $page = $this->objFromFixture('SiteTree', 'sitetree001'); |
| 389 | 389 | $page->doUnpublish(); |
| 390 | 390 | |
| 391 | - $this->checkNumberOfIndexedDocuments($nDocsAtStart-1); |
|
| 391 | + $this->checkNumberOfIndexedDocuments($nDocsAtStart - 1); |
|
| 392 | 392 | |
| 393 | 393 | $page->doPublish(); |
| 394 | 394 | $this->checkNumberOfIndexedDocuments($nDocsAtStart); |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | $flickrPhoto = $this->objFromFixture('FlickrPhotoTO', 'photo0001'); |
| 482 | 482 | $fields = $flickrPhoto->getCMSFields(); |
| 483 | 483 | |
| 484 | - $tab = $this->checkTabExists($fields,'ElasticaTermsset'); |
|
| 484 | + $tab = $this->checkTabExists($fields, 'ElasticaTermsset'); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | $this->assertEquals('The field $searchable_fields must be set for the class FlickrPhotoTO', $e->getMessage()); |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - $config->update('FlickrPhotoTO' ,'searchable_fields', $sf); |
|
| 500 | + $config->update('FlickrPhotoTO', 'searchable_fields', $sf); |
|
| 501 | 501 | } |
| 502 | 502 | |
| 503 | 503 | |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | $this->assertEquals('The field $searchable_fields must be set for the class FlickrTagTO', $e->getMessage()); |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | - $config->update('FlickrTagTO' ,'searchable_fields', $sf); |
|
| 516 | + $config->update('FlickrTagTO', 'searchable_fields', $sf); |
|
| 517 | 517 | |
| 518 | 518 | } |
| 519 | 519 | |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | $this->assertEquals('The field $searchable_fields must be set for the class FlickrAuthorTO', $e->getMessage()); |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | - $config->update('FlickrAuthorTO' ,'searchable_fields', $sf); |
|
| 533 | + $config->update('FlickrAuthorTO', 'searchable_fields', $sf); |
|
| 534 | 534 | |
| 535 | 535 | } |
| 536 | 536 | |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | $config = Config::inst(); |
| 540 | 540 | $sr = $config->get('FlickrPhotoTO', 'searchable_relationships'); |
| 541 | 541 | $config->remove('FlickrPhotoTO', 'searchable_relationships'); |
| 542 | - $config->update('FlickrPhotoTO', 'searchable_relationships',array('thisMethodDoesNotExist')); |
|
| 542 | + $config->update('FlickrPhotoTO', 'searchable_relationships', array('thisMethodDoesNotExist')); |
|
| 543 | 543 | $fp = Injector::inst()->create('FlickrPhotoTO'); |
| 544 | 544 | try { |
| 545 | 545 | $fields = $fp->getAllSearchableFields(); |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | |
| 558 | 558 | // MUST REMOVE FIRST. Otherwise append and the erroroneus value above still exists |
| 559 | 559 | $config->remove('FlickrPhotoTO', 'searchable_relationships'); |
| 560 | - $config->update('FlickrPhotoTO' ,'searchable_relationships', $sr); |
|
| 560 | + $config->update('FlickrPhotoTO', 'searchable_relationships', $sr); |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | |
@@ -669,9 +669,9 @@ discard block |
||
| 669 | 669 | |
| 670 | 670 | $photographer->write(); |
| 671 | 671 | |
| 672 | - $flickrPhoto->PhotographerID = $photographer->ID;; |
|
| 672 | + $flickrPhoto->PhotographerID = $photographer->ID; ; |
|
| 673 | 673 | $flickrPhoto->write(); |
| 674 | - echo 'ID='.$flickrPhoto->PhotographerID; |
|
| 674 | + echo 'ID=' . $flickrPhoto->PhotographerID; |
|
| 675 | 675 | $a = $flickrPhoto->getFieldValuesAsArray(); |
| 676 | 676 | |
| 677 | 677 | print_r($a); |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | |
| 719 | 719 | |
| 720 | 720 | $flickrPhoto->write(); |
| 721 | - echo 'ID='.$flickrPhoto->PhotographerID; |
|
| 721 | + echo 'ID=' . $flickrPhoto->PhotographerID; |
|
| 722 | 722 | $a = $flickrPhoto->getFieldValuesAsArray(); |
| 723 | 723 | |
| 724 | 724 | print_r($a); |
@@ -766,15 +766,15 @@ discard block |
||
| 766 | 766 | foreach ($tab->FieldList() as $field) { |
| 767 | 767 | array_push($tabFields, $field->getName()); |
| 768 | 768 | } |
| 769 | - $expectedName = 'TermsFor'.$tab->getName();; |
|
| 769 | + $expectedName = 'TermsFor' . $tab->getName(); ; |
|
| 770 | 770 | $expected = array($expectedName); |
| 771 | 771 | $this->assertEquals($expected, $tabFields); |
| 772 | 772 | array_push($tabNames, $tab->getName()); |
| 773 | 773 | } |
| 774 | - $expected = array('Description','Description_shingles','Description_standard', |
|
| 775 | - 'ShutterSpeed', 'TestMethod', 'TestMethod_shingles', 'TestMethod_standard', |
|
| 774 | + $expected = array('Description', 'Description_shingles', 'Description_standard', |
|
| 775 | + 'ShutterSpeed', 'TestMethod', 'TestMethod_shingles', 'TestMethod_standard', |
|
| 776 | 776 | 'TestMethodHTML', 'TestMethodHTML_shingles', 'TestMethodHTML_standard', |
| 777 | - 'Title','Title_autocomplete','Title_shingles','Title_standard'); |
|
| 777 | + 'Title', 'Title_autocomplete', 'Title_shingles', 'Title_standard'); |
|
| 778 | 778 | |
| 779 | 779 | $this->assertEquals($expected, $tabNames); |
| 780 | 780 | } |
@@ -798,13 +798,13 @@ discard block |
||
| 798 | 798 | foreach ($tab->FieldList() as $field) { |
| 799 | 799 | array_push($tabFields, $field->getName()); |
| 800 | 800 | } |
| 801 | - $expectedName = 'TermsFor'.$tab->getName();; |
|
| 801 | + $expectedName = 'TermsFor' . $tab->getName(); ; |
|
| 802 | 802 | $expected = array($expectedName); |
| 803 | 803 | $this->assertEquals($expected, $tabFields); |
| 804 | 804 | array_push($tabNames, $tab->getName()); |
| 805 | 805 | } |
| 806 | 806 | $expected = array( |
| 807 | - 'Content','Content_standard','Link','Title','Title_autocomplete','Title_shingles', |
|
| 807 | + 'Content', 'Content_standard', 'Link', 'Title', 'Title_autocomplete', 'Title_shingles', |
|
| 808 | 808 | 'Title_standard'); |
| 809 | 809 | $this->generateAssertionsFromArray1D($tabNames); |
| 810 | 810 | $this->assertEquals($expected, $tabNames); |
@@ -479,6 +479,9 @@ |
||
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | |
| 482 | + /** |
|
| 483 | + * @param string $query |
|
| 484 | + */ |
|
| 482 | 485 | private function getResultsFor($query, $pageLength = 10, $fields = array('Title' => 1, 'Description' => 1)) { |
| 483 | 486 | $es = new ElasticSearcher(); |
| 484 | 487 | $es->setStart(0); |
@@ -31,13 +31,13 @@ |
||
| 31 | 31 | public function testRequireDefaultRecords() { |
| 32 | 32 | $this->AutoCompleteOption->requireDefaultRecords(); |
| 33 | 33 | |
| 34 | - $similar = AutoCompleteOption::get()->filter('Name','Similar')->first(); |
|
| 34 | + $similar = AutoCompleteOption::get()->filter('Name', 'Similar')->first(); |
|
| 35 | 35 | $this->assertEquals(1, $similar->ID); |
| 36 | 36 | |
| 37 | - $search = AutoCompleteOption::get()->filter('Name','Search')->first(); |
|
| 37 | + $search = AutoCompleteOption::get()->filter('Name', 'Search')->first(); |
|
| 38 | 38 | $this->assertEquals(2, $search->ID); |
| 39 | 39 | |
| 40 | - $goto = AutoCompleteOption::get()->filter('Name','GoToRecord')->first(); |
|
| 40 | + $goto = AutoCompleteOption::get()->filter('Name', 'GoToRecord')->first(); |
|
| 41 | 41 | $this->assertEquals(3, $goto->ID); |
| 42 | 42 | |
| 43 | 43 | } |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | |
| 15 | 15 | $fields = $sc->getCMSFields(); |
| 16 | 16 | |
| 17 | - $tab = $this->checkTabExists($fields,'Main'); |
|
| 17 | + $tab = $this->checkTabExists($fields, 'Main'); |
|
| 18 | 18 | |
| 19 | 19 | //Check fields |
| 20 | 20 | $nf = $this->checkFieldExists($tab, 'Name'); |
@@ -9,7 +9,7 @@ |
||
| 9 | 9 | public function setUp() { |
| 10 | 10 | // this needs to be called in order to create the list of searchable |
| 11 | 11 | // classes and fields that are available. Simulates part of a build |
| 12 | - $classes = array('SearchableTestPage','SiteTree','Page','FlickrPhotoTO','FlickrSetTO', |
|
| 12 | + $classes = array('SearchableTestPage', 'SiteTree', 'Page', 'FlickrPhotoTO', 'FlickrSetTO', |
|
| 13 | 13 | 'FlickrTagTO', 'FlickrAuthorTO', 'FlickrSetTO'); |
| 14 | 14 | $this->requireDefaultRecordsFrom = $classes; |
| 15 | 15 | |
@@ -15,7 +15,7 @@ discard block |
||
| 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'); |
@@ -45,7 +45,7 @@ discard block |
||
| 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 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 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 | } |
@@ -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 | |
@@ -6,8 +6,8 @@ discard block |
||
| 6 | 6 | * @subpackage tests |
| 7 | 7 | */ |
| 8 | 8 | class FlickrPhotoTO extends DataObject implements TestOnly { |
| 9 | - private static $searchable_fields = array('Title','FlickrID','Description','TakenAt', 'TakenAtDT', 'FirstViewed', |
|
| 10 | - 'Aperture','ShutterSpeed','FocalLength35mm','ISO','AspectRatio', 'TestMethod', 'TestMethodHTML'); |
|
| 9 | + private static $searchable_fields = array('Title', 'FlickrID', 'Description', 'TakenAt', 'TakenAtDT', 'FirstViewed', |
|
| 10 | + 'Aperture', 'ShutterSpeed', 'FocalLength35mm', 'ISO', 'AspectRatio', 'TestMethod', 'TestMethodHTML'); |
|
| 11 | 11 | |
| 12 | 12 | private static $searchable_relationships = array('Photographer', 'FlickrTagTOs', 'FlickrSetTOs'); |
| 13 | 13 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @subpackage tests |
| 89 | 89 | */ |
| 90 | 90 | class FlickrSetTO extends DataObject implements TestOnly { |
| 91 | - private static $searchable_fields = array('Title','FlickrID','Description'); |
|
| 91 | + private static $searchable_fields = array('Title', 'FlickrID', 'Description'); |
|
| 92 | 92 | |
| 93 | 93 | private static $db = array( |
| 94 | 94 | 'Title' => 'Varchar(255)', |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | |
| 135 | 135 | |
| 136 | -class FlickrPhotoTOTestIndexingExtension extends Extension implements ElasticaIndexingHelperInterface,TestOnly { |
|
| 136 | +class FlickrPhotoTOTestIndexingExtension extends Extension implements ElasticaIndexingHelperInterface, TestOnly { |
|
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | 139 | * Add a mapping for the location of the photograph |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | // add a location with geo point |
| 147 | 147 | $precision1cm = array('format' => 'compressed', 'precision' => '1cm'); |
| 148 | - $properties['location'] = array( |
|
| 148 | + $properties['location'] = array( |
|
| 149 | 149 | 'type' => 'geo_point', |
| 150 | 150 | 'fielddata' => $precision1cm, |
| 151 | 151 | ); |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | if ($this->owner->Lat != null && $this->owner->Lon != null) { |
| 185 | 185 | $coors = array('lat' => $this->owner->Lat, 'lon' => $this->owner->Lon); |
| 186 | - $document->set('location',$coors); |
|
| 186 | + $document->set('location', $coors); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | $sortable = $this->owner->ShutterSpeed; |
@@ -200,8 +200,8 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | } else if (sizeof($sortable) == 2) { |
| 203 | - $sortable = floatval($sortable[0])/intval($sortable[1]); |
|
| 204 | - $sortable = round($sortable,6); |
|
| 203 | + $sortable = floatval($sortable[0]) / intval($sortable[1]); |
|
| 204 | + $sortable = round($sortable, 6); |
|
| 205 | 205 | } |
| 206 | 206 | $sortable = $sortable . '|' . $this->owner->ShutterSpeed; |
| 207 | 207 | $document->set('ShutterSpeed', $sortable); |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | * @subpackage tests |
| 6 | 6 | */ |
| 7 | 7 | class SearchableTestPage extends Page implements TestOnly { |
| 8 | - private static $searchable_fields = array('Country','PageDate'); |
|
| 8 | + private static $searchable_fields = array('Country', 'PageDate'); |
|
| 9 | 9 | |
| 10 | 10 | private static $db = array( |
| 11 | 11 | 'Country' => 'Varchar', |
@@ -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 | /* |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | use SilverStripe\Elastica\RangedAggregation; |
| 7 | 7 | |
| 8 | 8 | |
| 9 | -class FlickrPhotoTOElasticaSearchHelper implements ElasticaSearchHelperInterface,TestOnly { |
|
| 9 | +class FlickrPhotoTOElasticaSearchHelper implements ElasticaSearchHelperInterface, TestOnly { |
|
| 10 | 10 | |
| 11 | 11 | public function __construct() { |
| 12 | 12 | $aspectAgg = new RangedAggregation('Aspect', 'AspectRatio'); |
@@ -123,8 +123,8 @@ discard block |
||
| 123 | 123 | $sortable = ''; |
| 124 | 124 | |
| 125 | 125 | } else { |
| 126 | - $sortable = floatval($sortable[0])/intval($sortable[1]); |
|
| 127 | - $sortable = round($sortable,6); |
|
| 126 | + $sortable = floatval($sortable[0]) / intval($sortable[1]); |
|
| 127 | + $sortable = round($sortable, 6); |
|
| 128 | 128 | $sortable = $sortable . '|' . $filters['ShutterSpeed']; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -13,15 +13,15 @@ discard block |
||
| 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'); |
@@ -185,7 +185,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
@@ -383,18 +383,18 @@ discard block |
||
| 383 | 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); |
|
| 389 | + $start = substr($expectedClass, 0, 6); |
|
| 390 | 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 | 396 | foreach ($expectedNames as $expectedName) { |
| 397 | - $filter = array('Name' => $expectedName, 'SearchableClassID' => $sc->ID ); |
|
| 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++; |